Make WordPress Core

Changeset 45817


Ignore:
Timestamp:
08/16/2019 12:23:40 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Taxonomy: In feed_links_extra() and get_the_archive_title(), make sure the queried taxonomy term exists before accessing its properties.

Props donmhico, truchot, zaantar.
Fixes #46420.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r45816 r45817  
    15551555 */
    15561556function get_the_archive_title() {
     1557    $title = __( 'Archives' );
     1558
    15571559    if ( is_category() ) {
    15581560        /* translators: Category archive title. %s: Category name */
     
    15971599        $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
    15981600    } elseif ( is_tax() ) {
    1599         $tax = get_taxonomy( get_queried_object()->taxonomy );
    1600         /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
    1601         $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
    1602     } else {
    1603         $title = __( 'Archives' );
     1601        $queried_object = get_queried_object();
     1602        if ( $queried_object ) {
     1603            $tax = get_taxonomy( $queried_object->taxonomy );
     1604            /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
     1605            $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
     1606        }
    16041607    }
    16051608
     
    29092912        }
    29102913    } elseif ( is_tax() ) {
    2911         $term  = get_queried_object();
    2912         $tax   = get_taxonomy( $term->taxonomy );
    2913         $title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name );
    2914         $href  = get_term_feed_link( $term->term_id, $term->taxonomy );
     2914        $term = get_queried_object();
     2915
     2916        if ( $term ) {
     2917            $tax   = get_taxonomy( $term->taxonomy );
     2918            $title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name );
     2919            $href  = get_term_feed_link( $term->term_id, $term->taxonomy );
     2920        }
    29152921    } elseif ( is_author() ) {
    29162922        $author_id = intval( get_query_var( 'author' ) );
Note: See TracChangeset for help on using the changeset viewer.