WordPress.org

Make WordPress Core

Ticket #21394: 21394.2.diff

File 21394.2.diff, 5.0 KB (added by wonderboymusic, 5 years ago)
  • wp-includes/category-template.php

    diff --git wp-includes/category-template.php wp-includes/category-template.php
    index 96a61cf..b82fcfd 100644
    function wp_list_categories( $args = '' ) { 
    467467
    468468                if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
    469469                        $current_term_object = get_queried_object();
    470                         if ( $r['taxonomy'] == $current_term_object->taxonomy )
     470                        if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy )
    471471                                $r['current_category'] = get_queried_object_id();
    472472                }
    473473
    function tag_description( $tag = 0 ) { 
    10391039 * @return string Term description, available.
    10401040 */
    10411041function term_description( $term = 0, $taxonomy = 'post_tag' ) {
    1042         if ( !$term && ( is_tax() || is_tag() || is_category() ) ) {
     1042        if ( ! $term && ( is_tax() || is_tag() || is_category() ) ) {
    10431043                $term = get_queried_object();
    1044                 $taxonomy = $term->taxonomy;
    1045                 $term = $term->term_id;
     1044                if ( $term ) {
     1045                        $taxonomy = $term->taxonomy;
     1046                        $term = $term->term_id;
     1047                }
    10461048        }
    10471049        $description = get_term_field( 'description', $term, $taxonomy );
    10481050        return is_wp_error( $description ) ? '' : $description;
  • wp-includes/general-template.php

    diff --git wp-includes/general-template.php wp-includes/general-template.php
    index b586762..4ad561c 100644
    function wp_title($sep = '»', $display = true, $seplocation = '') { 
    585585        // If there's a taxonomy
    586586        if ( is_tax() ) {
    587587                $term = get_queried_object();
    588                 $tax = get_taxonomy( $term->taxonomy );
    589                 $title = single_term_title( $tax->labels->name . $t_sep, false );
     588                if ( $term ) {
     589                        $tax = get_taxonomy( $term->taxonomy );
     590                        $title = single_term_title( $tax->labels->name . $t_sep, false );
     591                }
    590592        }
    591593
    592594        // If there's an author
    593595        if ( is_author() ) {
    594596                $author = get_queried_object();
    595                 $title = $author->display_name;
     597                if ( $author )
     598                        $title = $author->display_name;
    596599        }
    597600
    598601        // If there's a post type archive
    function post_type_archive_title( $prefix = '', $display = true ) { 
    696699        if ( ! is_post_type_archive() )
    697700                return;
    698701
     702        $_title = '';
     703
    699704        $post_type_obj = get_queried_object();
    700         $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
     705        if ( $post_type_obj )
     706                $_title = $post_type_obj->labels->name;
     707
     708        $title = apply_filters( 'post_type_archive_title', $_title );
    701709
    702710        if ( $display )
    703711                echo $prefix . $title;
    function feed_links_extra( $args = array() ) { 
    16811689        } elseif ( is_category() ) {
    16821690                $term = get_queried_object();
    16831691
    1684                 $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
    1685                 $href = get_category_feed_link( $term->term_id );
     1692                if ( $term ) {
     1693                        $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
     1694                        $href = get_category_feed_link( $term->term_id );
     1695                }
    16861696        } elseif ( is_tag() ) {
    16871697                $term = get_queried_object();
    16881698
    1689                 $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
    1690                 $href = get_tag_feed_link( $term->term_id );
     1699                if ( $term ) {
     1700                        $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
     1701                        $href = get_tag_feed_link( $term->term_id );
     1702                }
    16911703        } elseif ( is_author() ) {
    16921704                $author_id = intval( get_query_var('author') );
    16931705
    function feed_links_extra( $args = array() ) { 
    16981710                $href = get_search_feed_link();
    16991711        } elseif ( is_post_type_archive() ) {
    17001712                $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
    1701                 $href = get_post_type_archive_feed_link( get_queried_object()->name );
     1713                $post_type_obj = get_queried_object();
     1714                if ( $post_type_obj )
     1715                        $href = get_post_type_archive_feed_link( $post_type_obj->name );
    17021716        }
    17031717
    17041718        if ( isset($title) && isset($href) )
  • wp-includes/link-template.php

    diff --git wp-includes/link-template.php wp-includes/link-template.php
    index 5fb6172..3770a23 100644
    function get_edit_term_link( $term_id, $taxonomy, $object_type = '' ) { 
    713713 * @return string HTML content.
    714714 */
    715715function edit_term_link( $link = '', $before = '', $after = '', $term = null, $echo = true ) {
    716         if ( is_null( $term ) ) {
     716        if ( is_null( $term ) )
    717717                $term = get_queried_object();
    718         }
     718
     719        if ( ! $term )
     720                return;
    719721
    720722        $tax = get_taxonomy( $term->taxonomy );
    721         if ( !current_user_can($tax->cap->edit_terms) )
     723        if ( ! current_user_can( $tax->cap->edit_terms ) )
    722724                return;
    723725
    724726        if ( empty( $link ) )
  • wp-includes/template.php

    diff --git wp-includes/template.php wp-includes/template.php
    index 5bee8ad..26bdb41 100644
    function get_page_template() { 
    241241        if ( ! $pagename && $id ) {
    242242                // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
    243243                $post = get_queried_object();
    244                 $pagename = $post->post_name;
     244                if ( $post )
     245                        $pagename = $post->post_name;
    245246        }
    246247
    247248        $templates = array();