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:
parent
c96b33e3a5
commit
41f71598f7
|
@ -114,7 +114,7 @@ foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 's
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format text area for display.
|
// 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, 'wptexturize' );
|
||||||
add_filter( $filter, 'convert_chars' );
|
add_filter( $filter, 'convert_chars' );
|
||||||
add_filter( $filter, 'wpautop' );
|
add_filter( $filter, 'wpautop' );
|
||||||
|
|
|
@ -1554,20 +1554,7 @@ function get_the_archive_description() {
|
||||||
if ( is_author() ) {
|
if ( is_author() ) {
|
||||||
$description = get_the_author_meta( 'description' );
|
$description = get_the_author_meta( 'description' );
|
||||||
} elseif ( is_post_type_archive() ) {
|
} elseif ( is_post_type_archive() ) {
|
||||||
$post_type = get_query_var( 'post_type' );
|
$description = get_the_post_type_description();
|
||||||
|
|
||||||
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 = '';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$description = term_description();
|
$description = term_description();
|
||||||
}
|
}
|
||||||
|
@ -1582,6 +1569,40 @@ function get_the_archive_description() {
|
||||||
return apply_filters( 'get_the_archive_description', $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.
|
* Retrieve archive link content based on predefined or custom code.
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue