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

git-svn-id: http://svn.automattic.com/wordpress/trunk@4956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-02-28 05:22:29 +00:00
parent 2ecae0f50d
commit 0f8983c364
1 changed files with 51 additions and 22 deletions

View File

@ -561,14 +561,13 @@ class WP_Query {
$this->is_admin = true;
}
if ( $this->is_single || $this->is_page || $this->is_attachment )
$this->is_singular = true;
if ( false !== strpos($qv['feed'], 'comments-') ) {
$this->query_vars['feed'] = $qv['feed'] = str_replace('comments-', '', $qv['feed']);
$qv['withcomments'] = 1;
}
$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) )
$this->is_comment_feed = true;
@ -576,6 +575,42 @@ class WP_Query {
$this->is_home = true;
}
// Correct is_* for page_on_front and page_for_posts
if ( $this->is_home && ( empty($this->query) || $qv['preview'] == 'true' ) && 'page' == get_option('show_on_front') && get_option('page_on_front') ) {
$this->is_page = true;
$this->is_home = false;
$this->query_vars['page_id'] = get_option('page_on_front');
}
if ( '' != $qv['pagename'] ) {
$this->queried_object =& get_page_by_path($qv['pagename']);
if ( !empty($this->queried_object) )
$this->queried_object_id = $this->queried_object->ID;
else
unset($this->queried_object);
if ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) {
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
}
}
if ( '' != $qv['page_id'] && 0 != intval($qv['page_id']) ) {
$this->query_vars['page_id'] = intval($qv['page_id']);
if ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) {
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
}
}
if ( $this->is_posts_page && !$qv['withcomments'] )
$this->is_comment_feed = false;
$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
// Done correcting is_* for page_on_front and page_for_posts
if ( !empty($query) ) {
do_action_ref_array('parse_query', array(&$this));
}
@ -724,18 +759,17 @@ class WP_Query {
$q['name'] = sanitize_title($q['name']);
$where .= " AND post_name = '" . $q['name'] . "'";
} else if ('' != $q['pagename']) {
if ( isset($this->queried_object_id) )
$reqpage = $this->queried_object_id;
else {
$reqpage = get_page_by_path($q['pagename']);
if ( !empty($reqpage) )
$reqpage = $reqpage->ID;
else
$reqpage = 0;
}
if ( ('page' == get_option('show_on_front') ) && ( $reqpage == get_option('page_for_posts') ) ) {
$this->is_singular = false;
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
} else {
if ( ('page' != get_option('show_on_front') ) || ( $reqpage != get_option('page_for_posts') ) ) {
$q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename'])));
$page_paths = '/' . trim($q['pagename'], '/');
$q['pagename'] = sanitize_title(basename($page_paths));
@ -770,12 +804,7 @@ class WP_Query {
if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
$q['page_id'] = intval($q['page_id']);
if ( ('page' == get_option('show_on_front') ) && ( $q['page_id'] == get_option('page_for_posts') ) ) {
$this->is_singular = false;
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
} else {
if ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) {
$q['p'] = $q['page_id'];
$where = ' AND ID = '.$q['page_id'];
}