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 git-svn-id: https://develop.svn.wordpress.org/trunk@41232 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
db49a16f00
commit
1f26d318ab
@ -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,6 +1554,29 @@ 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() ) {
|
||||||
|
$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' );
|
$post_type = get_query_var( 'post_type' );
|
||||||
|
|
||||||
if ( is_array( $post_type ) ) {
|
if ( is_array( $post_type ) ) {
|
||||||
@ -1568,18 +1591,16 @@ function get_the_archive_description() {
|
|||||||
} else {
|
} else {
|
||||||
$description = '';
|
$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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user