From 8da221507615d8c632fc8c3f2fdd92036415d918 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 24 Aug 2004 08:43:01 +0000 Subject: [PATCH] Template redirection. git-svn-id: https://develop.svn.wordpress.org/trunk@1558 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-blog-header.php | 52 +++++++++++++++++++++++++++++++++------ wp-includes/classes.php | 11 ++++++--- wp-includes/functions.php | 6 +++++ 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/wp-blog-header.php b/wp-blog-header.php index 5f30e2a42e..1b7b6d7a8a 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -1,5 +1,6 @@ wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file."); @@ -159,14 +160,51 @@ if (1 == count($posts)) { } } -if ($pagenow != 'wp-feed.php' && $feed != '') { - require(dirname(__FILE__) . '/wp-feed.php'); - exit; -} +$wp_did_header = true; +endif; -if ($pagenow != 'wp-trackback.php' && $tb == 1) { - require(dirname(__FILE__) . '/wp-trackback.php'); - exit; +// Template redirection +if (is_single() && (! isset($wp_did_single)) && + file_exists(ABSPATH . 'wp-content/single.php')) { + $wp_did_single = true; + include(ABSPATH . 'wp-content/single.php'); + exit; +} else if (is_page() && (! isset($wp_did_page)) && + file_exists(ABSPATH . 'wp-content/page.php')) { + $wp_did_page = true; + include(ABSPATH . 'wp-content/page.php'); + exit; +} else if (is_category() && (! isset($wp_did_category)) && + file_exists(ABSPATH . 'wp-content/category.php')) { + $wp_did_category = true; + include(ABSPATH . 'wp-content/category.php'); + exit; +} else if (is_author() && (! isset($wp_did_author)) && + file_exists(ABSPATH . 'wp-content/author.php')) { + $wp_did_author = true; + include(ABSPATH . 'wp-content/author.php'); + exit; +} else if (is_date() && (! isset($wp_did_date)) && + file_exists(ABSPATH . 'wp-content/date.php')) { + $wp_did_date = true; + include(ABSPATH . 'wp-content/date.php'); + exit; +} else if (is_archive() && (! isset($wp_did_archive)) && + file_exists(ABSPATH . 'wp-content/archive.php')) { + $wp_did_archive = true; + include(ABSPATH . 'wp-content/archive.php'); + exit; +} else if (is_search() && (! isset($wp_did_search)) && + file_exists(ABSPATH . 'wp-content/search.php')) { + $wp_did_search = true; + include(ABSPATH . 'wp-content/search.php'); + exit; +} else if (is_feed() && $pagenow != 'wp-feed.php') { + include(dirname(__FILE__) . '/wp-feed.php'); + exit; +} else if ($pagenow != 'wp-trackback.php' && $tb == 1) { + include(dirname(__FILE__) . '/wp-trackback.php'); + exit; } if ($pagenow != 'post.php' && $pagenow != 'edit.php') { diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 30fd03433d..a2e9626510 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -10,6 +10,7 @@ class WP_Query { var $post; var $is_single = false; + var $is_page = false; var $is_archive = false; var $is_date = false; var $is_year = false; @@ -24,6 +25,7 @@ class WP_Query { function init () { $this->is_single = false; + $this->is_page = false; $this->is_archive = false; $this->is_date = false; $this->is_year = false; @@ -152,15 +154,18 @@ class WP_Query { if ('' != $qv['feed']) { $this->is_feed = true; - $this->feed = $qv['feed']; + } + + if ('' != $qv['static'] || '' != $qv['pagename']) { + $this->is_page = true; } if ( ($this->is_date || $this->is_author || $this->is_category) - && (! $this->is_single)) { + && (! ($this->is_single || $this->is_page)) ) { $this->is_archive = true; } - if ( ! ($this->is_archive || $this->is_single || $this->is_search || $this->is_feed)) { + if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed)) { $this->is_home = true; } } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 4ab91fdba7..c17ad1fc76 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1590,6 +1590,12 @@ function is_single () { return $wp_query->is_single; } +function is_page () { + global $wp_query; + + return $wp_query->is_page; +} + function is_archive () { global $wp_query;