WordPress.org

Make WordPress Core

Ticket #38545: 38545.9.diff

File 38545.9.diff, 5.6 KB (added by audrasjb, 13 months ago)

Patch refreshed for 4.9.7 milestone

  • src/wp-includes/general-template.php

    diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
    index d521a64..95a7df1 100644
    a b function single_month_title( $prefix = '', $display = true ) { 
    14671467 * Display the archive title based on the queried object.
    14681468 *
    14691469 * @since 4.1.0
     1470 * @since 4.9.7 Added $span_class parameter.
    14701471 *
    14711472 * @see get_the_archive_title()
    14721473 *
    1473  * @param string $before Optional. Content to prepend to the title. Default empty.
    1474  * @param string $after  Optional. Content to append to the title. Default empty.
     1474 * @param string $before     Optional. Content to prepend to the title. Default empty.
     1475 * @param string $after      Optional. Content to append to the title. Default empty.
     1476 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14751477 */
    1476 function the_archive_title( $before = '', $after = '' ) {
    1477         $title = get_the_archive_title();
     1478function the_archive_title( $before = '', $after = '', $span_class = '' ) {
     1479        $title = get_the_archive_title( $span_class );
    14781480
    14791481        if ( ! empty( $title ) ) {
    14801482                echo $before . $title . $after;
    function the_archive_title( $before = '', $after = '' ) { 
    14851487 * Retrieve the archive title based on the queried object.
    14861488 *
    14871489 * @since 4.1.0
     1490 * @since 4.9.7 Added $span_class parameter.
    14881491 *
     1492 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14891493 * @return string Archive title.
    14901494 */
    1491 function get_the_archive_title() {
     1495function get_the_archive_title( $span_class = '' ) {
    14921496        if ( is_category() ) {
    1493                 /* translators: Category archive title. %s: Category name */
    1494                 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
     1497                /* translators: Category archive title. */
     1498                $type = __( 'Category:' );
     1499                $name = single_cat_title( '', false );
    14951500        } elseif ( is_tag() ) {
    1496                 /* translators: Tag archive title. %s: Tag name */
    1497                 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
     1501                /* translators: Tag archive title. */
     1502                $type = __( 'Tag:' );
     1503                $name = single_tag_title( '', false );
    14981504        } elseif ( is_author() ) {
    1499                 /* translators: Author archive title. %s: Author name */
    1500                 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
     1505                /* translators: Author archive title. */
     1506                $type = __( 'Author:' );
     1507                /* translators: %s: Author name. */
     1508                $name = sprintf( '<span class="vcard">%s</span>', get_the_author() );
    15011509        } elseif ( is_year() ) {
    1502                 /* translators: Yearly archive title. %s: Year */
    1503                 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
     1510                /* translators: Yearly archive title. */
     1511                $type = __( 'Year:' );
     1512                $name = get_the_date( _x( 'Y', 'yearly archives date format' ) );
    15041513        } elseif ( is_month() ) {
    1505                 /* translators: Monthly archive title. %s: Month name and year */
    1506                 $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
     1514                /* translators: Monthly archive title. */
     1515                $type = __( 'Month:' );
     1516                $name = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
    15071517        } elseif ( is_day() ) {
    1508                 /* translators: Daily archive title. %s: Date */
    1509                 $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
    1510         } elseif ( is_tax( 'post_format' ) ) {
     1518                /* translators: Daily archive title. */
     1519                $type = __( 'Day:' );
     1520                $name = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
     1521        } elseif ( is_post_type_archive() ) {
     1522                /* translators: Post type archive title. */
     1523                $type = __( 'Archives:' );
     1524                $name = post_type_archive_title( '', false );
     1525        } elseif ( is_tax() ) {
     1526                $tax = get_taxonomy( get_queried_object()->taxonomy );
     1527                /* translators: Taxonomy singular name */
     1528                $type = sprintf( __( '%s:' ), $tax->labels->singular_name );
     1529                $name = single_term_title( '', false );
     1530        }
     1531       
     1532        if ( is_tax( 'post_format' ) ) {
    15111533                if ( is_tax( 'post_format', 'post-format-aside' ) ) {
    15121534                        $title = _x( 'Asides', 'post format archive title' );
    15131535                } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
    function get_the_archive_title() { 
    15271549                } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
    15281550                        $title = _x( 'Chats', 'post format archive title' );
    15291551                }
    1530         } elseif ( is_post_type_archive() ) {
    1531                 /* translators: Post type archive title. %s: Post type name */
    1532                 $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
    1533         } elseif ( is_tax() ) {
    1534                 $tax = get_taxonomy( get_queried_object()->taxonomy );
    1535                 /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
    1536                 $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
     1552        } elseif ( isset( $type ) && isset( $name ) ) {
     1553                if ( ! empty( $span_class ) ) {
     1554                        $span_class = sprintf( ' class="%s"', esc_attr( $span_class ) );
     1555                        $title = sprintf( '<span%s>%s </span>%s', $span_class, $type, $name );
     1556                } else {
     1557                        $title = sprintf( '%s %s', $type, $name );
     1558                }
    15371559        } else {
    15381560                $title = __( 'Archives' );
    15391561        }
    function get_the_archive_title() { 
    15421564         * Filters the archive title.
    15431565         *
    15441566         * @since 4.1.0
     1567         * @since 4.9.7 Added $span_class parameter.
    15451568         *
    15461569         * @param string $title Archive title to be displayed.
     1570         * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    15471571         */
    1548         return apply_filters( 'get_the_archive_title', $title );
     1572        return apply_filters( 'get_the_archive_title', $title, $span_class );
    15491573}
    15501574
    15511575/**