Make WordPress Core

Ticket #16784: 16784.patch

File 16784.patch, 1.5 KB (added by Jayjdk, 10 years ago)
  • src/wp-includes/general-template.php

     
    731731}
    732732
    733733/**
     734 * Display or retrieve description for a post type archive.
     735 *
     736 * This is optimized for archive.php and archive-{$post_type}.php template files
     737 * for displaying the description of the post type.
     738 *
     739 * @since 3.9.0
     740 *
     741 * @param bool $display Optional, default is true. Whether to display or retrieve description.
     742 * @return string|null Description when retrieving, null when displaying or failure.
     743 */
     744function post_type_archive_description( $display = true ) {
     745        if ( ! is_post_type_archive() ) {
     746                return;
     747        }
     748
     749        $post_type = get_query_var( 'post_type' );
     750        if ( is_array( $post_type ) ) {
     751                $post_type = reset( $post_type );
     752        }
     753
     754        $post_type_obj = get_post_type_object( $post_type );
     755        /**
     756         * Filter the post type archive description.
     757         *
     758         * @since 3.1.0
     759         *
     760         * @param string $post_type_description Post type 'description' argument.
     761         * @param string $post_type             Post type.
     762         */
     763        $description = apply_filters( 'post_type_archive_description', $post_type_obj->description, $post_type );
     764
     765        if ( $display ) {
     766                echo $description;
     767        } else {
     768                return $description;
     769        }
     770}
     771
     772/**
    734773 * Display or retrieve page title for category archive.
    735774 *
    736775 * This is useful for category template file or files, because it is optimized