WordPress.org

Make WordPress Core

Changeset 24693


Ignore:
Timestamp:
07/12/2013 10:35:38 PM (5 years ago)
Author:
nacin
Message:

Revert title auto-generation for asides and statuses.

Reverts [24043] and related.

fixes #24011.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-filters.php

    r24650 r24693  
    128128add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
    129129
    130 // Pre save post data
    131 add_filter( 'wp_insert_post_data', '_post_formats_fix_empty_title', 10, 2 );
    132 
    133130// Display filters
    134131add_filter( 'the_title', 'wptexturize'   );
    135132add_filter( 'the_title', 'convert_chars' );
    136133add_filter( 'the_title', 'trim'          );
    137 add_filter( 'the_title', '_post_formats_title', 10, 2 );
    138134
    139135add_filter( 'the_content', 'wptexturize'        );
  • trunk/wp-includes/post-formats.php

    r24683 r24693  
    234234}
    235235add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
    236 
    237 /**
    238  * Don't display post titles for asides and status posts on the front end.
    239  *
    240  * @since 3.6.0
    241  * @access private
    242  */
    243 function _post_formats_title( $title, $post_id = 0 ) {
    244     if ( ! $post_id || is_admin() || is_feed() || ! in_array( get_post_format( $post_id ), array( 'aside', 'status' ) ) )
    245         return $title;
    246 
    247     // Return an empty string only if the title is auto-generated.
    248     $post = get_post( $post_id );
    249     if ( $title == _post_formats_generate_title( $post->post_content, get_post_format( $post_id ) ) )
    250         $title = '';
    251 
    252     return $title;
    253 }
    254 
    255 /**
    256  * Generate a title from the post content or format.
    257  *
    258  * @since 3.6.0
    259  * @access private
    260  */
    261 function _post_formats_generate_title( $content, $post_format = '' ) {
    262     $title = wp_trim_words( strip_shortcodes( $content ), 8, '' );
    263 
    264     if ( empty( $title ) )
    265         $title = get_post_format_string( $post_format );
    266 
    267     return $title;
    268 }
    269 
    270 /**
    271  * Fixes empty titles for aside and status formats.
    272  *
    273  * Passes a generated post title to the 'wp_insert_post_data' filter.
    274  *
    275  * @since 3.6.0
    276  * @access private
    277  *
    278  * @uses _post_formats_generate_title()
    279  */
    280 function _post_formats_fix_empty_title( $data, $postarr ) {
    281     if ( 'auto-draft' == $data['post_status'] || ! post_type_supports( $data['post_type'], 'post-formats' ) )
    282         return $data;
    283 
    284     $post_id = ( isset( $postarr['ID'] ) ) ? absint( $postarr['ID'] ) : 0;
    285     $post_format = '';
    286 
    287     if ( $post_id )
    288         $post_format = get_post_format( $post_id );
    289 
    290     if ( isset( $postarr['post_format'] ) )
    291         $post_format = ( in_array( $postarr['post_format'], get_post_format_slugs() ) ) ? $postarr['post_format'] : '';
    292 
    293     if ( ! in_array( $post_format, array( 'aside', 'status' ) ) )
    294         return $data;
    295 
    296     if ( $data['post_title'] == _post_formats_generate_title( $data['post_content'], $post_format ) )
    297         return $data;
    298 
    299     // If updating an existing post, check whether the title was auto-generated.
    300     if ( $post_id && $post = get_post( $post_id ) )
    301         if ( $post->post_title == $data['post_title'] && $post->post_title == _post_formats_generate_title( $post->post_content, get_post_format( $post->ID ) ) )
    302             $data['post_title'] = '';
    303 
    304     if ( empty( $data['post_title'] ) )
    305         $data['post_title'] = _post_formats_generate_title( $data['post_content'], $post_format );
    306 
    307     return $data;
    308 }
Note: See TracChangeset for help on using the changeset viewer.