Make WordPress Core

Changeset 4956


Ignore:
Timestamp:
02/28/2007 05:22:29 AM (18 years ago)
Author:
ryan
Message:

Fix up page_for_posts feed. Rework some query bits. Props mdawaffe. fixes #3885

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r4953 r4956  
    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']);
     
    570567        }
    571568
    572         if ( $this->is_feed && (!empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) )
     569        $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
     570
     571        if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) )
    573572            $this->is_comment_feed = true;
    574573
    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)) {
     574        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 ) ) {
    576575            $this->is_home = true;
    577576        }
     577
     578        // Correct is_* for page_on_front and page_for_posts
     579        if ( $this->is_home && ( empty($this->query) || $qv['preview'] == 'true' ) && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {
     580            $this->is_page = true;
     581            $this->is_home = false;
     582            $this->query_vars['page_id'] = get_option('page_on_front');
     583        }
     584
     585        if ( '' != $qv['pagename'] ) {
     586            $this->queried_object =& get_page_by_path($qv['pagename']);
     587            if ( !empty($this->queried_object) )
     588                $this->queried_object_id = $this->queried_object->ID;
     589            else
     590                unset($this->queried_object);
     591
     592            if  ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) {
     593                $this->is_page = false;
     594                $this->is_home = true;
     595                $this->is_posts_page = true;
     596            }
     597        }
     598
     599        if ( '' != $qv['page_id'] && 0 != intval($qv['page_id']) ) {
     600            $this->query_vars['page_id'] = intval($qv['page_id']);
     601            if  ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) {
     602                $this->is_page = false;
     603                $this->is_home = true;
     604                $this->is_posts_page = true;
     605            }
     606        }
     607
     608        if ( $this->is_posts_page && !$qv['withcomments'] )
     609            $this->is_comment_feed = false;
     610
     611        $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
     612        // Done correcting is_* for page_on_front and page_for_posts
    578613
    579614        if ( !empty($query) ) {
     
    725760            $where .= " AND post_name = '" . $q['name'] . "'";
    726761        } 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;
    732 
    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 {
     762            if ( isset($this->queried_object_id) )
     763                $reqpage = $this->queried_object_id;
     764            else {
     765                $reqpage = get_page_by_path($q['pagename']);
     766                if ( !empty($reqpage) )
     767                    $reqpage = $reqpage->ID;
     768                else
     769                    $reqpage = 0;
     770            }
     771
     772            if  ( ('page' != get_option('show_on_front') ) || ( $reqpage != get_option('page_for_posts') ) ) {
    739773                $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename'])));
    740774                $page_paths = '/' . trim($q['pagename'], '/');
     
    771805        if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
    772806            $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 {
     807            if  ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) {
    779808                $q['p'] = $q['page_id'];
    780809                $where = ' AND ID = '.$q['page_id'];
Note: See TracChangeset for help on using the changeset viewer.