From 3f1186166dcbedf4848299f99b0bce73271fca5f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 16 Aug 2019 00:24:54 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@45817 git-svn-id: http://core.svn.wordpress.org/trunk@45628 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 24 +++++++++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 66d6551091..c2356376ca 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1554,6 +1554,8 @@ function the_archive_title( $before = '', $after = '' ) { * @return string Archive title. */ function get_the_archive_title() { + $title = __( 'Archives' ); + if ( is_category() ) { /* translators: Category archive title. %s: Category name */ $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) ); @@ -1596,11 +1598,12 @@ function get_the_archive_title() { /* translators: Post type archive title. %s: Post type name */ $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) ); } elseif ( is_tax() ) { - $tax = get_taxonomy( get_queried_object()->taxonomy ); - /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */ - $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) ); - } else { - $title = __( 'Archives' ); + $queried_object = get_queried_object(); + if ( $queried_object ) { + $tax = get_taxonomy( $queried_object->taxonomy ); + /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */ + $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) ); + } } /** @@ -2908,10 +2911,13 @@ function feed_links_extra( $args = array() ) { $href = get_tag_feed_link( $term->term_id ); } } elseif ( is_tax() ) { - $term = get_queried_object(); - $tax = get_taxonomy( $term->taxonomy ); - $title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name ); - $href = get_term_feed_link( $term->term_id, $term->taxonomy ); + $term = get_queried_object(); + + if ( $term ) { + $tax = get_taxonomy( $term->taxonomy ); + $title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name ); + $href = get_term_feed_link( $term->term_id, $term->taxonomy ); + } } elseif ( is_author() ) { $author_id = intval( get_query_var( 'author' ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 3016fb52e2..73b86c0c63 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45816'; +$wp_version = '5.3-alpha-45817'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.