Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_insert_post_empty_content

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
2971       * Returning a truthy value to the filter will effectively short-circuit
2972       * the new post being inserted, returning 0. If $wp_error is true, a WP_Error
2973       * will be returned instead.
2974       *
2975       * @since 3.3.0
2976       *
2977       * @param bool  $maybe_empty Whether the post should be considered "empty".
2978       * @param array $postarr     Array of post data.
2979       */
2980      if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {
2981           if ( $wp_error ) {
2982                return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) );
2983           } else {
2984                return 0;
2985           }
2986      }
2987
2988      $post_status = empty( $postarr['post_status'] ) ? 'draft' : $postarr['post_status'];
2989      if ( 'attachment' === $post_type && ! in_array( $post_status, array( 'inherit', 'private', 'trash' ) ) ) {