Make WordPress Core

Ticket #38545: 38545.4.patch

File 38545.4.patch, 5.2 KB (added by shireling, 8 years ago)

Updated inline docs, updated translator notes, escaped new class name

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

    diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
    index 715dab7..3de64a9 100644
    a b function single_month_title($prefix = '', $display = true ) { 
    14431443 *
    14441444 * @param string $before Optional. Content to prepend to the title. Default empty.
    14451445 * @param string $after  Optional. Content to append to the title. Default empty.
     1446 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14461447 */
    1447 function the_archive_title( $before = '', $after = '' ) {
    1448         $title = get_the_archive_title();
     1448function the_archive_title( $before = '', $after = '', $span_class = '' ) {
     1449        $title = get_the_archive_title( $span_class );
    14491450
    14501451        if ( ! empty( $title ) ) {
    14511452                echo $before . $title . $after;
    function the_archive_title( $before = '', $after = '' ) { 
    14581459 * @since 4.1.0
    14591460 *
    14601461 * @return string Archive title.
     1462 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14611463 */
    1462 function get_the_archive_title() {
    1463         if ( is_category() ) {
    1464                 /* translators: Category archive title. 1: Category name */
    1465                 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
    1466         } elseif ( is_tag() ) {
    1467                 /* translators: Tag archive title. 1: Tag name */
    1468                 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
    1469         } elseif ( is_author() ) {
    1470                 /* translators: Author archive title. 1: Author name */
    1471                 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
    1472         } elseif ( is_year() ) {
    1473                 /* translators: Yearly archive title. 1: Year */
    1474                 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
    1475         } elseif ( is_month() ) {
    1476                 /* translators: Monthly archive title. 1: Month name and year */
    1477                 $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
    1478         } elseif ( is_day() ) {
    1479                 /* translators: Daily archive title. 1: Date */
    1480                 $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
     1464function get_the_archive_title( $span_class = '' ) {
     1465        if ( is_category() || is_tag() || is_author() || is_year() || is_month() || is_day() || is_post_type_archive() || ( is_tax() && ! is_tax( 'post_format') ) ) {
     1466                if ( ! '' == $span_class ) {
     1467                        $span_class = sprintf( 'class="%s"', sanitize_html_class( $span_class ) );
     1468                }
     1469                if ( is_category() ) {
     1470                        /* translators: Category archive title. */
     1471                        $type = __( 'Category: ' );
     1472                        $name = single_cat_title( '', false );
     1473                } elseif ( is_tag() ) {
     1474                        /* translators: Tag archive title. */
     1475                        $type = __( 'Tag: ' );
     1476                        $name = single_tag_title( '', false );
     1477                } elseif ( is_author() ) {
     1478                        /* translators: Author archive title. %s: Author name */
     1479                        $type = __( 'Author: ' );
     1480                        $name = sprintf( '<span class="vcard">%s</span>', get_the_author() );
     1481                } elseif ( is_year() ) {
     1482                        /* translators: Yearly archive title. */
     1483                        $type = __( 'Year: ' );
     1484                        $name = get_the_date( _x( 'Y', 'yearly archives date format' ) );
     1485                } elseif ( is_month() ) {
     1486                        /* translators: Monthly archive title. */
     1487                        $type = __( 'Month: ' );
     1488                        $name = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
     1489                } elseif ( is_day() ) {
     1490                        /* translators: Daily archive title. */
     1491                        $type =__( 'Day: ' );
     1492                        $name = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
     1493                } elseif ( is_post_type_archive() ) {
     1494                        /* translators: Post type archive title. */
     1495                        $type = __( 'Archives: ' );
     1496                        $name = post_type_archive_title( '', false );
     1497                } elseif ( is_tax() ) {
     1498                        $tax = get_taxonomy( get_queried_object()->taxonomy );
     1499                        /* translators: Taxonomy term archive title. 1: Taxonomy singular name */
     1500                        $type = sprintf( __( '%s: ' ), $tax->labels->singular_name );
     1501                        $name =  single_term_title( '', false );
     1502                }
     1503                $format ='<span %s>%s</span>%s';
     1504                $title = sprintf( $format, $span_class, $type, $name );
    14811505        } elseif ( is_tax( 'post_format' ) ) {
    14821506                if ( is_tax( 'post_format', 'post-format-aside' ) ) {
    14831507                        $title = _x( 'Asides', 'post format archive title' );
    function get_the_archive_title() { 
    14981522                } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
    14991523                        $title = _x( 'Chats', 'post format archive title' );
    15001524                }
    1501         } elseif ( is_post_type_archive() ) {
    1502                 /* translators: Post type archive title. 1: Post type name */
    1503                 $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
    1504         } elseif ( is_tax() ) {
    1505                 $tax = get_taxonomy( get_queried_object()->taxonomy );
    1506                 /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
    1507                 $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
    15081525        } else {
    15091526                $title = __( 'Archives' );
    15101527        }