Ticket #38545: 38545.5.patch
File 38545.5.patch, 4.5 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; … … 1461 1462 * @since 4.1.0 1462 1463 * 1463 1464 * @return string Archive title. 1465 * @param string $span_class Optional. Class name to apply to the span around the archive type description. Default empty. 1464 1466 */ 1465 function get_the_archive_title() { 1467 function get_the_archive_title( $span_class = '' ) { 1468 if ( ! empty( $span_class ) ) { 1469 $span_class = sprintf( ' class="%s"', esc_attr( $span_class ) ); 1470 } 1466 1471 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 ); 1469 1475 } 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 ); 1472 1479 } 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() ); 1475 1483 } 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' ) ); 1478 1487 } 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' ) ); 1481 1491 } 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' ) ) { 1485 1509 if ( is_tax( 'post_format', 'post-format-aside' ) ) { 1486 1510 $title = _x( 'Asides', 'post format archive title' ); 1487 1511 } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { … … 1501 1525 } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { 1502 1526 $title = _x( 'Chats', 'post format archive title' ); 1503 1527 } 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 ) );1511 1528 } else { 1512 1529 $title = __( 'Archives' ); 1513 1530 }