diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 9212e42865..e689e1d606 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -114,7 +114,7 @@ foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 's } // Format text area for display. -foreach ( array( 'term_description', 'get_the_author_description' ) as $filter ) { +foreach ( array( 'term_description', 'get_the_author_description', 'get_the_post_type_description' ) as $filter ) { add_filter( $filter, 'wptexturize' ); add_filter( $filter, 'convert_chars' ); add_filter( $filter, 'wpautop' ); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 087f47ad2a..6a0170d81d 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1554,20 +1554,7 @@ function get_the_archive_description() { if ( is_author() ) { $description = get_the_author_meta( 'description' ); } elseif ( is_post_type_archive() ) { - $post_type = get_query_var( 'post_type' ); - - if ( is_array( $post_type ) ) { - $post_type = reset( $post_type ); - } - - $post_type_obj = get_post_type_object( $post_type ); - - // Check if a description is set. - if ( isset( $post_type_obj->description ) ) { - $description = $post_type_obj->description; - } else { - $description = ''; - } + $description = get_the_post_type_description(); } else { $description = term_description(); } @@ -1582,6 +1569,40 @@ function get_the_archive_description() { return apply_filters( 'get_the_archive_description', $description ); } +/** + * Retrieves the description for a post type archive. + * + * @since 4.9.0 + * + * @return string The post type description. + */ +function get_the_post_type_description() { + $post_type = get_query_var( 'post_type' ); + + if ( is_array( $post_type ) ) { + $post_type = reset( $post_type ); + } + + $post_type_obj = get_post_type_object( $post_type ); + + // Check if a description is set. + if ( isset( $post_type_obj->description ) ) { + $description = $post_type_obj->description; + } else { + $description = ''; + } + + /** + * Filters the description for a post type archive. + * + * @since 4.9.0 + * + * @param string $description The post type description. + * @param WP_Post_Type $post_type_obj The post type object. + */ + return apply_filters( 'get_the_post_type_description', $description, $post_type_obj ); +} + /** * Retrieve archive link content based on predefined or custom code. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 2c5f2c838b..5ade7df60a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-alpha-41231'; +$wp_version = '4.9-alpha-41232'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.