Revert title auto-generation for asides and statuses.

Reverts [24043] and related.

fixes #24011.



git-svn-id: https://develop.svn.wordpress.org/trunk@24693 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-07-12 22:35:38 +00:00
parent e1edb8a3c8
commit a8fb7603c6
2 changed files with 0 additions and 77 deletions

View File

@ -127,14 +127,10 @@ foreach ( array( 'term_name_rss' ) as $filter ) {
add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 );
add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
// Pre save post data
add_filter( 'wp_insert_post_data', '_post_formats_fix_empty_title', 10, 2 );
// Display filters
add_filter( 'the_title', 'wptexturize' );
add_filter( 'the_title', 'convert_chars' );
add_filter( 'the_title', 'trim' );
add_filter( 'the_title', '_post_formats_title', 10, 2 );
add_filter( 'the_content', 'wptexturize' );
add_filter( 'the_content', 'convert_smilies' );

View File

@ -233,76 +233,3 @@ function _post_format_wp_get_object_terms( $terms ) {
return $terms;
}
add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' );
/**
* Don't display post titles for asides and status posts on the front end.
*
* @since 3.6.0
* @access private
*/
function _post_formats_title( $title, $post_id = 0 ) {
if ( ! $post_id || is_admin() || is_feed() || ! in_array( get_post_format( $post_id ), array( 'aside', 'status' ) ) )
return $title;
// Return an empty string only if the title is auto-generated.
$post = get_post( $post_id );
if ( $title == _post_formats_generate_title( $post->post_content, get_post_format( $post_id ) ) )
$title = '';
return $title;
}
/**
* Generate a title from the post content or format.
*
* @since 3.6.0
* @access private
*/
function _post_formats_generate_title( $content, $post_format = '' ) {
$title = wp_trim_words( strip_shortcodes( $content ), 8, '' );
if ( empty( $title ) )
$title = get_post_format_string( $post_format );
return $title;
}
/**
* Fixes empty titles for aside and status formats.
*
* Passes a generated post title to the 'wp_insert_post_data' filter.
*
* @since 3.6.0
* @access private
*
* @uses _post_formats_generate_title()
*/
function _post_formats_fix_empty_title( $data, $postarr ) {
if ( 'auto-draft' == $data['post_status'] || ! post_type_supports( $data['post_type'], 'post-formats' ) )
return $data;
$post_id = ( isset( $postarr['ID'] ) ) ? absint( $postarr['ID'] ) : 0;
$post_format = '';
if ( $post_id )
$post_format = get_post_format( $post_id );
if ( isset( $postarr['post_format'] ) )
$post_format = ( in_array( $postarr['post_format'], get_post_format_slugs() ) ) ? $postarr['post_format'] : '';
if ( ! in_array( $post_format, array( 'aside', 'status' ) ) )
return $data;
if ( $data['post_title'] == _post_formats_generate_title( $data['post_content'], $post_format ) )
return $data;
// If updating an existing post, check whether the title was auto-generated.
if ( $post_id && $post = get_post( $post_id ) )
if ( $post->post_title == $data['post_title'] && $post->post_title == _post_formats_generate_title( $post->post_content, get_post_format( $post->ID ) ) )
$data['post_title'] = '';
if ( empty( $data['post_title'] ) )
$data['post_title'] = _post_formats_generate_title( $data['post_content'], $post_format );
return $data;
}