Rework query precedence for bug 541. Add is_trackback().

git-svn-id: http://svn.automattic.com/wordpress/trunk@1972 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-12-18 00:28:24 +00:00
parent 15745c2230
commit 71e989b683
3 changed files with 98 additions and 112 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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;