Make WordPress Core

Ticket #38545: 38545.6.patch

File 38545.6.patch, 4.6 KB (added by grapplerulrich, 8 years ago)
  • src/wp-includes/general-template.php

     
    14461446 *
    14471447 * @param string $before Optional. Content to prepend to the title. Default empty.
    14481448 * @param string $after  Optional. Content to append to the title. Default empty.
     1449 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14491450 */
    1450 function the_archive_title( $before = '', $after = '' ) {
    1451         $title = get_the_archive_title();
     1451function the_archive_title( $before = '', $after = '', $span_class = '' ) {
     1452        $title = get_the_archive_title( $span_class );
    14521453
    14531454        if ( ! empty( $title ) ) {
    14541455                echo $before . $title . $after;
     
    14591460 * Retrieve the archive title based on the queried object.
    14601461 *
    14611462 * @since 4.1.0
     1463 * @since 4.9.0 Added $span_class parameter.
    14621464 *
     1465 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14631466 * @return string Archive title.
    14641467 */
    1465 function get_the_archive_title() {
     1468function get_the_archive_title( $span_class = '' ) {
     1469        if ( ! empty( $span_class ) ) {
     1470                $span_class = sprintf( ' class="%s"', esc_attr( $span_class ) );
     1471        }
    14661472        if ( is_category() ) {
    1467                 /* translators: Category archive title. 1: Category name */
    1468                 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
     1473                /* translators: Category archive title. */
     1474                $type = __( 'Category:' );
     1475                $name = single_cat_title( '', false );
    14691476        } elseif ( is_tag() ) {
    1470                 /* translators: Tag archive title. 1: Tag name */
    1471                 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
     1477                /* translators: Tag archive title. */
     1478                $type = __( 'Tag:' );
     1479                $name = single_tag_title( '', false );
    14721480        } elseif ( is_author() ) {
    1473                 /* translators: Author archive title. 1: Author name */
    1474                 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
     1481                /* translators: Author archive title. %s: Author name */
     1482                $type = __( 'Author:' );
     1483                $name = sprintf( '<span class="vcard">%s</span>', get_the_author() );
    14751484        } elseif ( is_year() ) {
    1476                 /* translators: Yearly archive title. 1: Year */
    1477                 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
     1485                /* translators: Yearly archive title. */
     1486                $type = __( 'Year:' );
     1487                $name = get_the_date( _x( 'Y', 'yearly archives date format' ) );
    14781488        } elseif ( is_month() ) {
    1479                 /* translators: Monthly archive title. 1: Month name and year */
    1480                 $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
     1489                /* translators: Monthly archive title. */
     1490                $type = __( 'Month:' );
     1491                $name = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
    14811492        } elseif ( is_day() ) {
    1482                 /* translators: Daily archive title. 1: Date */
    1483                 $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
    1484         } elseif ( is_tax( 'post_format' ) ) {
     1493                /* translators: Daily archive title. */
     1494                $type = __( 'Day:' );
     1495                $name = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
     1496        } elseif ( is_post_type_archive() ) {
     1497                /* translators: Post type archive title. */
     1498                $type = __( 'Archives:' );
     1499                $name = post_type_archive_title( '', false );
     1500        } elseif ( is_tax() ) {
     1501                $tax = get_taxonomy( get_queried_object()->taxonomy );
     1502                /* translators: Taxonomy term archive title. 1: Taxonomy singular name */
     1503                $type = sprintf( __( '%s:' ), $tax->labels->singular_name );
     1504                $name = single_term_title( '', false );
     1505        }
     1506
     1507        if ( is_tax( 'post_format' ) ) {
    14851508                if ( is_tax( 'post_format', 'post-format-aside' ) ) {
    14861509                        $title = _x( 'Asides', 'post format archive title' );
    14871510                } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
     
    15011524                } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
    15021525                        $title = _x( 'Chats', 'post format archive title' );
    15031526                }
    1504         } elseif ( is_post_type_archive() ) {
    1505                 /* translators: Post type archive title. 1: Post type name */
    1506                 $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
    1507         } elseif ( is_tax() ) {
    1508                 $tax = get_taxonomy( get_queried_object()->taxonomy );
    1509                 /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
    1510                 $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
     1527        } elseif ( isset( $type ) && isset( $name ) ) {
     1528                $title = sprintf( '<span%s>%s </span>%s', $span_class, $type, $name );
    15111529        } else {
    15121530                $title = __( 'Archives' );
    15131531        }