diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index ca58200d61..f04180c62c 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -465,7 +465,7 @@ function wp_list_categories( $args = '' ) { if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) { $current_term_object = get_queried_object(); - if ( $r['taxonomy'] == $current_term_object->taxonomy ) + if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) $r['current_category'] = get_queried_object_id(); } @@ -1037,10 +1037,12 @@ function tag_description( $tag = 0 ) { * @return string Term description, available. */ function term_description( $term = 0, $taxonomy = 'post_tag' ) { - if ( !$term && ( is_tax() || is_tag() || is_category() ) ) { + if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) { $term = get_queried_object(); - $taxonomy = $term->taxonomy; - $term = $term->term_id; + if ( $term ) { + $taxonomy = $term->taxonomy; + $term = $term->term_id; + } } $description = get_term_field( 'description', $term, $taxonomy ); return is_wp_error( $description ) ? '' : $description; diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 598ccefdf4..e42ccc9505 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -592,14 +592,17 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { // If there's a taxonomy if ( is_tax() ) { $term = get_queried_object(); - $tax = get_taxonomy( $term->taxonomy ); - $title = single_term_title( $tax->labels->name . $t_sep, false ); + if ( $term ) { + $tax = get_taxonomy( $term->taxonomy ); + $title = single_term_title( $tax->labels->name . $t_sep, false ); + } } // If there's an author if ( is_author() ) { $author = get_queried_object(); - $title = $author->display_name; + if ( $author ) + $title = $author->display_name; } // Post type archives with has_archive should override terms. @@ -1692,13 +1695,17 @@ function feed_links_extra( $args = array() ) { } elseif ( is_category() ) { $term = get_queried_object(); - $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); - $href = get_category_feed_link( $term->term_id ); + if ( $term ) { + $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); + $href = get_category_feed_link( $term->term_id ); + } } elseif ( is_tag() ) { $term = get_queried_object(); - $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); - $href = get_tag_feed_link( $term->term_id ); + if ( $term ) { + $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); + $href = get_tag_feed_link( $term->term_id ); + } } elseif ( is_author() ) { $author_id = intval( get_query_var('author') ); @@ -1709,7 +1716,9 @@ function feed_links_extra( $args = array() ) { $href = get_search_feed_link(); } elseif ( is_post_type_archive() ) { $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) ); - $href = get_post_type_archive_feed_link( get_queried_object()->name ); + $post_type_obj = get_queried_object(); + if ( $post_type_obj ) + $href = get_post_type_archive_feed_link( $post_type_obj->name ); } if ( isset($title) && isset($href) ) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index dd2a217c31..26e37ce4ed 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -713,12 +713,14 @@ function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { * @return string HTML content. */ function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) { - if ( is_null( $term ) ) { + if ( is_null( $term ) ) $term = get_queried_object(); - } + + if ( ! $term ) + return; $tax = get_taxonomy( $term->taxonomy ); - if ( !current_user_can($tax->cap->edit_terms) ) + if ( ! current_user_can( $tax->cap->edit_terms ) ) return; if ( empty( $link ) ) diff --git a/wp-includes/template.php b/wp-includes/template.php index 78557e8a48..9ae769e090 100644 --- a/wp-includes/template.php +++ b/wp-includes/template.php @@ -256,7 +256,8 @@ function get_page_template() { if ( ! $pagename && $id ) { // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object $post = get_queried_object(); - $pagename = $post->post_name; + if ( $post ) + $pagename = $post->post_name; } $templates = array();