Make WordPress Core

Ticket #38545: 38545.5.patch

File 38545.5.patch, 4.5 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;
     
    14611462 * @since 4.1.0
    14621463 *
    14631464 * @return string Archive title.
     1465 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty.
    14641466 */
    1465 function get_the_archive_title() {
     1467function get_the_archive_title( $span_class = '' ) {
     1468        if ( ! empty( $span_class ) ) {
     1469                $span_class = sprintf( ' class="%s"', esc_attr( $span_class ) );
     1470        }
    14661471        if ( is_category() ) {
    1467                 /* translators: Category archive title. 1: Category name */
    1468                 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
     1472                /* translators: Category archive title. */
     1473                $type = __( 'Category:' );
     1474                $name = single_cat_title( '', false );
    14691475        } elseif ( is_tag() ) {
    1470                 /* translators: Tag archive title. 1: Tag name */
    1471                 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
     1476                /* translators: Tag archive title. */
     1477                $type = __( 'Tag:' );
     1478                $name = single_tag_title( '', false );
    14721479        } elseif ( is_author() ) {
    1473                 /* translators: Author archive title. 1: Author name */
    1474                 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
     1480                /* translators: Author archive title. %s: Author name */
     1481                $type = __( 'Author:' );
     1482                $name = sprintf( '<span class="vcard">%s</span>', get_the_author() );
    14751483        } elseif ( is_year() ) {
    1476                 /* translators: Yearly archive title. 1: Year */
    1477                 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
     1484                /* translators: Yearly archive title. */
     1485                $type = __( 'Year:' );
     1486                $name = get_the_date( _x( 'Y', 'yearly archives date format' ) );
    14781487        } 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' ) ) );
     1488                /* translators: Monthly archive title. */
     1489                $type = __( 'Month:' );
     1490                $name = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
    14811491        } 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' ) ) {
     1492                /* translators: Daily archive title. */
     1493                $type = __( 'Day:' );
     1494                $name = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
     1495        } elseif ( is_post_type_archive() ) {
     1496                /* translators: Post type archive title. */
     1497                $type = __( 'Archives:' );
     1498                $name = post_type_archive_title( '', false );
     1499        } elseif ( is_tax() ) {
     1500                $tax = get_taxonomy( get_queried_object()->taxonomy );
     1501                /* translators: Taxonomy term archive title. 1: Taxonomy singular name */
     1502                $type = sprintf( __( '%s:' ), $tax->labels->singular_name );
     1503                $name = single_term_title( '', false );
     1504        }
     1505        if ( isset( $type ) && isset( $name ) ) {
     1506                $title = sprintf( '<span%s>%s </span>%s', $span_class, $type, $name );
     1507        }
     1508        if ( is_tax( 'post_format' ) ) {
    14851509                if ( is_tax( 'post_format', 'post-format-aside' ) ) {
    14861510                        $title = _x( 'Asides', 'post format archive title' );
    14871511                } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
     
    15011525                } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
    15021526                        $title = _x( 'Chats', 'post format archive title' );
    15031527                }
    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 ) );
    15111528        } else {
    15121529                $title = __( 'Archives' );
    15131530        }