From 0971447cf6804d78a4c20cd25883e6552b0913ed Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 18 Dec 2004 00:28:24 +0000 Subject: [PATCH] Rework query precedence for bug 541. Add is_trackback(). git-svn-id: https://develop.svn.wordpress.org/trunk@1972 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-blog-header.php | 18 +--- wp-includes/classes.php | 186 ++++++++++++++++++-------------------- wp-includes/functions.php | 6 ++ 3 files changed, 98 insertions(+), 112 deletions(-) diff --git a/wp-blog-header.php b/wp-blog-header.php index 79b1b28ff0..9052a862e3 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -107,7 +107,7 @@ if ('' != $feed) { $doing_rss = true; } -if (1 == $tb) { +if (is_trackback()) { $doing_trackback = true; } @@ -210,66 +210,52 @@ if ($pagenow == 'index.php') { $wp_did_template_redirect = true; do_action('template_redirect', ''); if (is_feed()) { - $wp_did_template_redirect = true; include(dirname(__FILE__) . '/wp-feed.php'); exit; - } else if ($tb == 1) { - $wp_did_template_redirect = true; + } else if (is_trackback()) { include(dirname(__FILE__) . '/wp-trackback.php'); exit; } else if (is_404() && file_exists("$wp_template_dir/404.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/404.php"); exit; } else if (is_home() && file_exists("$wp_template_dir/index.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/index.php"); exit; } else if (is_single() && file_exists("$wp_template_dir/single.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/single.php"); exit; } else if (is_page() && file_exists(get_page_template())) { - $wp_did_template_redirect = true; include(get_page_template()); exit; } else if (is_category() && file_exists("$wp_template_dir/category.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/category.php"); exit; } else if (is_author() && file_exists("$wp_template_dir/author.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/author.php"); exit; } else if (is_date() && file_exists("$wp_template_dir/date.php")) { - $wp_did_date = true; - $wp_did_template_redirect = true; include("$wp_template_dir/date.php"); exit; } else if (is_archive() && file_exists("$wp_template_dir/archive.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/archive.php"); exit; } else if (is_search() && file_exists("$wp_template_dir/search.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/search.php"); exit; } else if (is_paged() && file_exists("$wp_template_dir/paged.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/paged.php"); exit; } else if (file_exists("$wp_template_dir/index.php")) { - $wp_did_template_redirect = true; include("$wp_template_dir/index.php"); exit; } diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 86f21f4230..50314827ca 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -23,6 +23,7 @@ class WP_Query { var $is_category = false; var $is_search = false; var $is_feed = false; + var $is_trackback = false; var $is_home = false; var $is_404 = false; @@ -39,6 +40,7 @@ class WP_Query { $this->is_category = false; $this->is_search = false; $this->is_feed = false; + $this->is_trackback = false; $this->is_home = false; $this->is_404 = false; $this->is_paged = false; @@ -61,113 +63,110 @@ class WP_Query { if ('' != $qv['name']) { $this->is_single = true; - } - - if (($qv['p'] != '') && ($qv['p'] != 'all')) { + } else if (($qv['p'] != '') && ($qv['p'] != 'all')) { $this->is_single = true; - } - - if ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) { + } else if (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) { + // If year, month, day, hour, minute, and second are set, a single + // post is being queried. + $this->is_single = true; + } else if ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) { $this->is_page = true; $this->is_single = false; - } - - if ( (int) $qv['second']) { - $this->is_time = true; - $this->is_date = true; - } - - if ( (int) $qv['minute']) { - $this->is_time = true; - $this->is_date = true; - } - - if ( (int) $qv['hour']) { - $this->is_time = true; - $this->is_date = true; - } - - if ( (int) $qv['day']) { - if (! $this->is_date) { - $this->is_day = true; - $this->is_date = true; - } - } - - if ( (int) $qv['monthnum']) { - if (! $this->is_date) { - $this->is_month = true; - $this->is_date = true; - } - } - - if ( (int) $qv['year']) { - if (! $this->is_date) { - $this->is_year = true; - $this->is_date = true; - } - } - - if ( (int) $qv['m']) { - $this->is_date = true; - if (strlen($qv['m']) > 9) { - $this->is_time = true; - } else if (strlen($qv['m']) > 7) { - $this->is_day = true; - } else if (strlen($qv['m']) > 5) { - $this->is_month = true; - } else { - $this->is_year = true; - } - } - - if ('' != $qv['w']) { - $this->is_date = true; - } - - // If year, month, day, hour, minute, and second are set, a single - // post is being queried. - if (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) { - $this->is_single = true; - } - - if (!empty($qv['s'])) { + } else if (!empty($qv['s'])) { $this->is_search = true; - } - - if (empty($qv['cat']) || ($qv['cat'] == 'all') || ($qv['cat'] == '0')) { - $this->is_category = false; } else { - if (stristr($qv['cat'],'-')) { + // Look for archive queries. Dates, categories, authors. + + if ( (int) $qv['second']) { + $this->is_time = true; + $this->is_date = true; + } + + if ( (int) $qv['minute']) { + $this->is_time = true; + $this->is_date = true; + } + + if ( (int) $qv['hour']) { + $this->is_time = true; + $this->is_date = true; + } + + if ( (int) $qv['day']) { + if (! $this->is_date) { + $this->is_day = true; + $this->is_date = true; + } + } + + if ( (int) $qv['monthnum']) { + if (! $this->is_date) { + $this->is_month = true; + $this->is_date = true; + } + } + + if ( (int) $qv['year']) { + if (! $this->is_date) { + $this->is_year = true; + $this->is_date = true; + } + } + + if ( (int) $qv['m']) { + $this->is_date = true; + if (strlen($qv['m']) > 9) { + $this->is_time = true; + } else if (strlen($qv['m']) > 7) { + $this->is_day = true; + } else if (strlen($qv['m']) > 5) { + $this->is_month = true; + } else { + $this->is_year = true; + } + } + + if ('' != $qv['w']) { + $this->is_date = true; + } + + if (empty($qv['cat']) || ($qv['cat'] == 'all') || ($qv['cat'] == '0')) { $this->is_category = false; } else { + if (stristr($qv['cat'],'-')) { + $this->is_category = false; + } else { + $this->is_category = true; + } + } + + if ('' != $qv['category_name']) { $this->is_category = true; } - } - - if ('' != $qv['category_name']) { - $this->is_category = true; - } - // single, page, date, and search override category. - if ($this->is_single || $this->is_page || $this->is_date || $this->is_search) { - $this->is_category = false; - } + if ((empty($qv['author'])) || ($qv['author'] == 'all') || ($qv['author'] == '0')) { + $this->is_author = false; + } else { + $this->is_author = true; + } - if ((empty($qv['author'])) || ($qv['author'] == 'all') || ($qv['author'] == '0')) { - $this->is_author = false; - } else { - $this->is_author = true; - } + if ('' != $qv['author_name']) { + $this->is_author = true; + } - if ('' != $qv['author_name']) { - $this->is_author = true; + if ( ($this->is_date || $this->is_author || $this->is_category)) { + $this->is_archive = true; + } } if ('' != $qv['feed']) { $this->is_feed = true; } + if ('' != $qv['tb']) { + $this->is_trackback = true; + } + if ('404' == $qv['error']) { $this->is_404 = true; } @@ -176,12 +175,7 @@ class WP_Query { $this->is_paged = true; } - if ( ($this->is_date || $this->is_author || $this->is_category) - && (! ($this->is_single || $this->is_page)) ) { - $this->is_archive = true; - } - - if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_404)) { + if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404)) { $this->is_home = true; } } @@ -899,7 +893,7 @@ class WP_Rewrite { $this->queryreplace[] = $query; } - function generate_rewrite_rules($permalink_structure = '', $page = true, $feed = true, $forcomments = false) { + function generate_rewrite_rules($permalink_structure, $page = true, $feed = true, $forcomments = false, $walk_dirs = true) { $feedregex2 = '(feed|rdf|rss|rss2|atom)/?$'; $feedregex = 'feed/' . $feedregex2; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index ed7d20d488..6624cae918 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1195,6 +1195,12 @@ function is_feed () { return $wp_query->is_feed; } +function is_trackback () { + global $wp_query; + + return $wp_query->is_trackback; +} + function is_home () { global $wp_query;