Ticket #38545: 38545.6.patch
File 38545.6.patch, 4.6 KB (added by , 8 years ago) |
---|
-
src/wp-includes/general-template.php
1446 1446 * 1447 1447 * @param string $before Optional. Content to prepend to the title. Default empty. 1448 1448 * @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. 1449 1450 */ 1450 function the_archive_title( $before = '', $after = '' ) {1451 $title = get_the_archive_title( );1451 function the_archive_title( $before = '', $after = '', $span_class = '' ) { 1452 $title = get_the_archive_title( $span_class ); 1452 1453 1453 1454 if ( ! empty( $title ) ) { 1454 1455 echo $before . $title . $after; … … 1459 1460 * Retrieve the archive title based on the queried object. 1460 1461 * 1461 1462 * @since 4.1.0 1463 * @since 4.9.0 Added $span_class parameter. 1462 1464 * 1465 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty. 1463 1466 * @return string Archive title. 1464 1467 */ 1465 function get_the_archive_title() { 1468 function get_the_archive_title( $span_class = '' ) { 1469 if ( ! empty( $span_class ) ) { 1470 $span_class = sprintf( ' class="%s"', esc_attr( $span_class ) ); 1471 } 1466 1472 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 ); 1469 1476 } 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 ); 1472 1480 } 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() ); 1475 1484 } 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' ) ); 1478 1488 } 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' ) ); 1481 1492 } 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' ) ) { 1485 1508 if ( is_tax( 'post_format', 'post-format-aside' ) ) { 1486 1509 $title = _x( 'Asides', 'post format archive title' ); 1487 1510 } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { … … 1501 1524 } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { 1502 1525 $title = _x( 'Chats', 'post format archive title' ); 1503 1526 } 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 ); 1511 1529 } else { 1512 1530 $title = __( 'Archives' ); 1513 1531 }