Ticket #3885: 3885.diff

File 3885.diff, 4.4 KB (added by mdawaffe, 5 years ago)
  • wp-includes/query.php

     
    561561                        $this->is_admin = true; 
    562562                } 
    563563 
    564                 if ( $this->is_single || $this->is_page || $this->is_attachment ) 
    565                         $this->is_singular = true; 
    566  
    567564                if ( false !== strpos($qv['feed'], 'comments-') ) { 
    568565                        $this->query_vars['feed'] = $qv['feed'] = str_replace('comments-', '', $qv['feed']); 
    569566                        $qv['withcomments'] = 1; 
     
    572569                if ( $this->is_feed && (!empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) 
    573570                        $this->is_comment_feed = true; 
    574571 
    575                 if ( ! ($this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) { 
     572                if ( ! ($this->is_single || $this->is_page || $this->is_attachment || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) { 
    576573                        $this->is_home = true; 
    577574                } 
    578575 
     576                if ( $this->is_home && (empty($this->query) || $qv['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) { 
     577                        $this->is_page = true; 
     578                        $this->is_home = false; 
     579                        $this->query_vars['page_id'] = get_option('page_on_front'); 
     580                } 
     581 
     582                if ( '' != $qv['pagename']) { 
     583                        $this->queried_object =& get_page_by_path($qv['pagename']); 
     584                        if ( !empty($this->queried_object) ) 
     585                                $this->queried_object_id = $this->queried_object->ID; 
     586                        else 
     587                                unset($this->queried_object); 
     588 
     589                        if  ( ('page' == get_option('show_on_front') ) && ( isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) ) { 
     590                                $this->is_page = false; 
     591                                $this->is_home = true; 
     592                                $this->is_posts_page = true; 
     593                        } 
     594                } 
     595 
     596                if (($qv['page_id'] != '') && (intval($qv['page_id']) != 0)) { 
     597                        $this->query_vars['page_id'] = intval($qv['page_id']); 
     598                        if  ( ('page' == get_option('show_on_front') ) && ( $qv['page_id'] == get_option('page_for_posts') ) ) { 
     599                                $this->is_page = false; 
     600                                $this->is_home = true; 
     601                                $this->is_posts_page = true; 
     602                        } 
     603                } 
     604 
     605                if ( $this->is_single || $this->is_page || $this->is_attachment ) 
     606                        $this->is_singular = true; 
     607 
    579608                if ( !empty($query) ) { 
    580609                        do_action_ref_array('parse_query', array(&$this)); 
    581610                } 
     
    724753                        $q['name'] = sanitize_title($q['name']); 
    725754                        $where .= " AND post_name = '" . $q['name'] . "'"; 
    726755                } else if ('' != $q['pagename']) { 
    727                         $reqpage = get_page_by_path($q['pagename']); 
    728                         if ( !empty($reqpage) ) 
    729                                 $reqpage = $reqpage->ID; 
    730                         else 
    731                                 $reqpage = 0; 
     756                        if ( isset($this->queried_object_id) ) 
     757                                $reqpage = $this->queried_object_id; 
     758                        else { 
     759                                $reqpage = get_page_by_path($q['pagename']); 
     760                                if ( !empty($reqpage) ) 
     761                                        $reqpage = $reqpage->ID; 
     762                                else 
     763                                        $reqpage = 0; 
     764                        } 
    732765 
    733                         if  ( ('page' == get_option('show_on_front') ) && ( $reqpage == get_option('page_for_posts') ) ) { 
    734                                 $this->is_singular = false; 
    735                                 $this->is_page = false; 
    736                                 $this->is_home = true; 
    737                                 $this->is_posts_page = true; 
    738                         } else { 
     766                        if  ( ('page' != get_option('show_on_front') ) || ( $reqpage != get_option('page_for_posts') ) ) { 
    739767                                $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename']))); 
    740768                                $page_paths = '/' . trim($q['pagename'], '/'); 
    741769                                $q['pagename'] = sanitize_title(basename($page_paths)); 
     
    770798 
    771799                if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) { 
    772800                        $q['page_id'] = intval($q['page_id']); 
    773                         if  ( ('page' == get_option('show_on_front') ) && ( $q['page_id'] == get_option('page_for_posts') ) ) { 
    774                                 $this->is_singular = false; 
    775                                 $this->is_page = false; 
    776                                 $this->is_home = true; 
    777                                 $this->is_posts_page = true; 
    778                         } else { 
     801                        if  ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) { 
    779802                                $q['p'] = $q['page_id']; 
    780803                                $where = ' AND ID = '.$q['page_id']; 
    781804                        } 
     
    10031026                } 
    10041027 
    10051028                // Comments feeds 
     1029                if ( $this->is_posts_page && !$q['withcomments'] ) 
     1030                        $this->is_comment_feed = false; 
     1031 
    10061032                if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular ) ) { 
    10071033                        if ( $this->is_archive || $this->is_search ) { 
    10081034                                $cjoin = "LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join ";