From 098ea1a7596b183137d29f8ef50e1b99b0c71226 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 12 Jul 2013 22:35:38 +0000 Subject: [PATCH] Revert title auto-generation for asides and statuses. Reverts [24043] and related. fixes #24011. git-svn-id: http://core.svn.wordpress.org/trunk@24693 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 4 -- wp-includes/post-formats.php | 73 --------------------------------- 2 files changed, 77 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 465d8aaec5..006e9f4e12 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -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' ); diff --git a/wp-includes/post-formats.php b/wp-includes/post-formats.php index 214beacf6b..7fc11575be 100644 --- a/wp-includes/post-formats.php +++ b/wp-includes/post-formats.php @@ -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; -}