Formatting: Introduce `get_the_post_type_description()` to allow post type archive descriptions to be formatted the same as author and term archives.

Props henry.wright

Fixes #40040

Built from https://develop.svn.wordpress.org/trunk@41232


git-svn-id: http://core.svn.wordpress.org/trunk@41072 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2017-08-04 23:01:44 +00:00
parent c96b33e3a5
commit 41f71598f7
3 changed files with 37 additions and 16 deletions

View File

@ -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' );

View File

@ -1554,6 +1554,29 @@ function get_the_archive_description() {
if ( is_author() ) {
$description = get_the_author_meta( 'description' );
} elseif ( is_post_type_archive() ) {
$description = get_the_post_type_description();
} else {
$description = term_description();
}
/**
* Filters the archive description.
*
* @since 4.1.0
*
* @param string $description Archive description to be displayed.
*/
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 ) ) {
@ -1568,18 +1591,16 @@ function get_the_archive_description() {
} else {
$description = '';
}
} else {
$description = term_description();
}
/**
* Filters the archive description.
* Filters the description for a post type archive.
*
* @since 4.1.0
* @since 4.9.0
*
* @param string $description Archive description to be displayed.
* @param string $description The post type description.
* @param WP_Post_Type $post_type_obj The post type object.
*/
return apply_filters( 'get_the_archive_description', $description );
return apply_filters( 'get_the_post_type_description', $description, $post_type_obj );
}
/**

View File

@ -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.