WordPress.org

Make WordPress Core

Ticket #38545: 38545.7.diff

File 38545.7.diff, 4.7 KB (added by audrasjb, 15 months ago)

refreshed patch

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

    diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
    index 57a7b67..19f8ea5 100644
    a b function single_month_title( $prefix = '', $display = true ) { 
    14721472 *
    14731473 * @param string $before Optional. Content to prepend to the title. Default empty.
    14741474 * @param string $after  Optional. Content to append to the title. Default empty.
     1475 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14751476 */
    1476 function the_archive_title( $before = '', $after = '' ) {
    1477         $title = get_the_archive_title();
     1477function the_archive_title( $before = '', $after = '', $span_class = '' ) {
     1478        $title = get_the_archive_title( $span_class );
    14781479
    14791480        if ( ! empty( $title ) ) {
    14801481                echo $before . $title . $after;
    function the_archive_title( $before = '', $after = '' ) { 
    14851486 * Retrieve the archive title based on the queried object.
    14861487 *
    14871488 * @since 4.1.0
     1489 * @since 4.9.0 Added $span_class parameter.
    14881490 *
     1491 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14891492 * @return string Archive title.
    14901493 */
    1491 function get_the_archive_title() {
     1494function get_the_archive_title( $span_class = '' ) {
     1495        if ( ! empty( $span_class ) ) {
     1496                $span_class = sprintf( ' class="%s"', esc_attr( $span_class ) );
     1497        }
    14921498        if ( is_category() ) {
    1493                 /* translators: Category archive title. %s: Category name */
    1494                 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
     1499                /* translators: Category archive title. */
     1500                $type = __( 'Category:' );
     1501                $name = single_cat_title( '', false );
    14951502        } elseif ( is_tag() ) {
    1496                 /* translators: Tag archive title. %s: Tag name */
    1497                 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
     1503                /* translators: Tag archive title. */
     1504                $type = __( 'Tag:' );
     1505                $name = single_tag_title( '', false );
    14981506        } elseif ( is_author() ) {
    14991507                /* translators: Author archive title. %s: Author name */
    1500                 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
     1508                $type = __( 'Author:' );
     1509                $name = sprintf( '<span class="vcard">%s</span>', get_the_author() );
    15011510        } elseif ( is_year() ) {
    1502                 /* translators: Yearly archive title. %s: Year */
    1503                 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
     1511                /* translators: Yearly archive title. */
     1512                $type = __( 'Year:' );
     1513                $name = get_the_date( _x( 'Y', 'yearly archives date format' ) );
    15041514        } 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' ) ) );
     1515                /* translators: Monthly archive title. */
     1516                $type = __( 'Month:' );
     1517                $name = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
    15071518        } 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' ) ) {
     1519                /* translators: Daily archive title. */
     1520                $type = __( 'Day:' );
     1521                $name = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
     1522        } elseif ( is_post_type_archive() ) {
     1523                /* translators: Post type archive title. */
     1524                $type = __( 'Archives:' );
     1525                $name = post_type_archive_title( '', false );
     1526        } elseif ( is_tax() ) {
     1527                $tax = get_taxonomy( get_queried_object()->taxonomy );
     1528                /* translators: Taxonomy term archive title. 1: Taxonomy singular name */
     1529                $type = sprintf( __( '%s:' ), $tax->labels->singular_name );
     1530                $name = single_term_title( '', false );
     1531        }
     1532
     1533        if ( is_tax( 'post_format' ) ) {
    15111534                if ( is_tax( 'post_format', 'post-format-aside' ) ) {
    15121535                        $title = _x( 'Asides', 'post format archive title' );
    15131536                } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
    function get_the_archive_title() { 
    15271550                } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
    15281551                        $title = _x( 'Chats', 'post format archive title' );
    15291552                }
    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 ) );
     1553        } elseif ( isset( $type ) && isset( $name ) ) {
     1554                $title = sprintf( '<span%s>%s </span>%s', $span_class, $type, $name );
    15371555        } else {
    15381556                $title = __( 'Archives' );
    15391557        }