wppaste
WordPress

apply_filters( 'wp_insert_post_empty_content', bool $maybe_empty, array $postarr )

Since
3.3.0
Filters whether the post should be considered "empty".

Description

The post is considered "empty" if both:

  1. The post type supports the title, editor, and excerpt fields
  2. The title, editor, and excerpt fields are all empty

Returning a truthy value from the filter will effectively short-circuit the new post being inserted and return 0. If $wp_error is true, a WP_Error will be returned instead.

Compatibility

WordPress
since 3.3.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$maybe_emptybool
Whether the post should be considered "empty".
$postarrarray
Array of post data.

Where this hook fires · 1

  • wp-includes/post.php:4695wp_insert_post()

Source code

	 *	 * @since 3.3.0	 *	 * @param bool  $maybe_empty Whether the post should be considered "empty".	 * @param array $postarr     Array of post data.	 */	if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {		if ( $wp_error ) {			return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) );		} else {			return 0;		}	}

Changelog

Introduced in 3.3.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.