WordPress.org

Make WordPress Core

Ticket #35480: general-template.php.patch

File general-template.php.patch, 2.2 KB (added by overclokk, 5 years ago)
  • general-template.php

     
    11841184}
    11851185
    11861186/**
     1187 * Display or retrieve description for a post type archive.
     1188 *
     1189 * This is optimized for archive.php and archive-{$post_type}.php template files
     1190 * for displaying the description of the post type.
     1191 *
     1192 * @since 4.4.0
     1193 *
     1194 * @param string $prefix  Optional. What to display before the description.
     1195 * @param bool   $display Optional, default is true. Whether to display or retrieve description.
     1196 * @return string|void description when retrieving, null when displaying or failure.
     1197 */
     1198function post_type_archive_description( $prefix = '', $display = true ) {
     1199        if ( ! is_post_type_archive() )
     1200                return;
     1201
     1202        $post_type = get_query_var( 'post_type' );
     1203        if ( is_array( $post_type ) )
     1204                $post_type = reset( $post_type );
     1205
     1206        $post_type_obj = get_post_type_object( $post_type );
     1207
     1208        /**
     1209         * Filter the post type archive description.
     1210         *
     1211         * @since 3.1.0
     1212         *
     1213         * @param string $post_type_name Post type 'name' label.
     1214         * @param string $post_type      Post type.
     1215         */
     1216        $description = apply_filters( 'post_type_archive_description', $post_type_obj->description, $post_type );
     1217
     1218        if ( $display )
     1219                echo $prefix . $description;
     1220        else
     1221                return $prefix . $description;
     1222}
     1223
     1224/**
    11871225 * Display or retrieve page title for category archive.
    11881226 *
    11891227 * Useful for category template files for displaying the category page title.
     
    14201458 * @return string Archive description.
    14211459 */
    14221460function get_the_archive_description() {
     1461
     1462        $description = '';
     1463
     1464        if ( is_post_type_archive() ) {
     1465                $description = post_type_archive_description( '', false );
     1466        } else {
     1467                $description = term_description();
     1468        }
    14231469        /**
    14241470         * Filter the archive description.
    14251471         *
     
    14261472         * @since 4.1.0
    14271473         *
    14281474         * @see term_description()
     1475         * @see post_type_archive_description();
    14291476         *
    14301477         * @param string $description Archive description to be displayed.
    14311478         */
    1432         return apply_filters( 'get_the_archive_description', term_description() );
     1479        return apply_filters( 'get_the_archive_description', $description );
    14331480}
    14341481
    14351482/**