WordPress.org

Make WordPress Core

Ticket #38545: patch.2.diff

File patch.2.diff, 3.6 KB (added by Confridin, 4 months ago)

Add another filter to get_the_archive_title()

  • wp-includes/general-template.php

    diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
    index 11d4b77..5ec7e4b 100644
    a b function the_archive_title( $before = '', $after = '' ) { 
    14951495 */
    14961496function get_the_archive_title() {
    14971497        if ( is_category() ) {
    1498                 /* translators: Category archive title. %s: Category name */
    1499                 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
     1498       $title = single_cat_title( '', false );
     1499       $prefix = __( 'Category: ' );
    15001500        } elseif ( is_tag() ) {
    1501                 /* translators: Tag archive title. %s: Tag name */
    1502                 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
     1501       $title = single_tag_title( '', false );
     1502       $prefix = __( 'Tag: ' );
    15031503        } elseif ( is_author() ) {
    1504                 /* translators: Author archive title. %s: Author name */
    1505                 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
     1504       $title = '<span class="vcard">' . get_the_author() . '</span>';
     1505       $prefix = __( 'Author: ' );
    15061506        } elseif ( is_year() ) {
    1507                 /* translators: Yearly archive title. %s: Year */
    1508                 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
     1507       $title = get_the_date( _x( 'Y', 'yearly archives date format' ) );
     1508       $prefix = __( 'Year: ' );
    15091509        } elseif ( is_month() ) {
    1510                 /* translators: Monthly archive title. %s: Month name and year */
    1511                 $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
     1510       $title = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
     1511       $prefix = __( 'Month: ' );
    15121512        } elseif ( is_day() ) {
    1513                 /* translators: Daily archive title. %s: Date */
    1514                 $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
     1513       $title = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
     1514       $prefix = __( 'Day: ' );
    15151515        } elseif ( is_tax( 'post_format' ) ) {
     1516                $prefix = '';
    15161517                if ( is_tax( 'post_format', 'post-format-aside' ) ) {
    15171518                        $title = _x( 'Asides', 'post format archive title' );
    15181519                } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
    function get_the_archive_title() { 
    15331534                        $title = _x( 'Chats', 'post format archive title' );
    15341535                }
    15351536        } elseif ( is_post_type_archive() ) {
    1536                 /* translators: Post type archive title. %s: Post type name */
    1537                 $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
     1537       $title = post_type_archive_title( '', false );
     1538       $prefix = __( 'Archives: ' );
    15381539        } elseif ( is_tax() ) {
     1540                $title = single_term_title( '', false );
    15391541                $tax = get_taxonomy( get_queried_object()->taxonomy );
    1540                 /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
    1541                 $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
     1542                /* translators: 1: Taxonomy singular name */
     1543                $prefix = sprintf( _x( '%1$s: ', 'Taxonomy singular name' ), $tax->labels->singular_name );
    15421544        } else {
    1543                 $title = __( 'Archives' );
     1545                $title = '';
     1546                $prefix = __( 'Archives' );
    15441547        }
    1545 
    15461548        /**
    1547          * Filters the archive title.
     1549         * Filters the archive title prefix.
     1550         *
     1551         * @since 5.2
     1552         *
     1553         * @param string $prefix Archive title prefix.
     1554         */
     1555        $prefix = apply_filters( 'get_the_archive_title_prefix', $prefix );
     1556        /* translators: archive title with prefix. 1: archive prefix, 2: archive name */
     1557        $title = sprintf( __( '%1$s%2$s' ), $prefix, $title );
     1558        /**
     1559         * Filters the archive title (with the archive title prefix).
    15481560         *
    15491561         * @since 4.1.0
    15501562         *