wp_insert_post_empty_content
Filters whether the post should be considered "empty".
The post is considered "empty" if both:
- The post type supports the title, editor, and excerpt fields
- 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.
Использование
add_filter( 'wp_insert_post_empty_content', 'wp_kama_insert_post_empty_content_filter', 10, 2 ); /** * Function for `wp_insert_post_empty_content` filter-hook. * * @param bool $maybe_empty Whether the post should be considered "empty". * @param array $postarr Array of post data. * * @return bool */ function wp_kama_insert_post_empty_content_filter( $maybe_empty, $postarr ){ // filter... return $maybe_empty; }
- $maybe_empty(true|false)
- Whether the post should be considered "empty".
- $postarr(массив)
- Array of post data.
Список изменений
С версии 3.3.0 | Введена. |
Где вызывается хук
wp_insert_post_empty_content
wp-includes/post.php 4479
if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {
Где используется хук в WordPress
wp-includes/class-wp-customize-nav-menus.php 977
add_filter( 'wp_insert_post_empty_content', '__return_false', 1000 );
wp-includes/class-wp-customize-nav-menus.php 979
remove_filter( 'wp_insert_post_empty_content', '__return_false', 1000 );