From 6a11fa21a2b9f3f3785d2277656b3101551b5088 Mon Sep 17 00:00:00 2001 From: rboren Date: Mon, 14 Feb 2005 09:17:23 +0000 Subject: [PATCH] Load comments-popup template through the index. git-svn-id: http://svn.automattic.com/wordpress/trunk@2332 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/upgrade-functions.php | 8 ++------ wp-blog-header.php | 5 ++++- wp-content/themes/classic/comments-popup.php | 2 -- wp-content/themes/default/comments-popup.php | 2 -- wp-includes/classes.php | 10 +++++++++- wp-includes/comment-functions.php | 14 +++++++------- wp-includes/functions.php | 15 +++++++++++++++ 7 files changed, 37 insertions(+), 19 deletions(-) diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 49ffc79e84..e45775de56 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -554,12 +554,8 @@ function make_site_theme_from_oldschool($theme_name, $template) { $f = fopen("$site_dir/$newfile", 'w'); foreach ($lines as $line) { - if (preg_match('/require.*wp-blog-header/', $line)) { - if ($newfile == 'comments-popup.php') - $line = "require('../../../wp-blog-header.php');"; - else - $line = '//' . $line; - } + if (preg_match('/require.*wp-blog-header/', $line)) + $line = '//' . $line; // Update stylesheet references. $line = str_replace("/wp-layout.css", "", $line); diff --git a/wp-blog-header.php b/wp-blog-header.php index 4595c6a52f..54993ca609 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -85,7 +85,7 @@ if ((isset($_GET['error']) && $_GET['error'] == '404') || } } -$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error'); +$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup'); $wpvarstoreset = apply_filters('query_vars', $wpvarstoreset); @@ -227,6 +227,9 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) { } else if ( is_archive() && get_archive_template() ) { include(get_archive_template()); exit; + } else if ( is_comments_popup() && get_comments_popup_template() ) { + include(get_comments_popup_template()); + exit; } else if ( is_paged() && get_paged_template() ) { include(get_paged_template()); exit; diff --git a/wp-content/themes/classic/comments-popup.php b/wp-content/themes/classic/comments-popup.php index 6ca50f2a35..4d22c93c7e 100644 --- a/wp-content/themes/classic/comments-popup.php +++ b/wp-content/themes/classic/comments-popup.php @@ -1,7 +1,5 @@ diff --git a/wp-content/themes/default/comments-popup.php b/wp-content/themes/default/comments-popup.php index 6ca50f2a35..4d22c93c7e 100644 --- a/wp-content/themes/default/comments-popup.php +++ b/wp-content/themes/default/comments-popup.php @@ -1,7 +1,5 @@ diff --git a/wp-includes/classes.php b/wp-includes/classes.php index f3de3f3fc9..5bda602bdd 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -26,6 +26,7 @@ class WP_Query { var $is_trackback = false; var $is_home = false; var $is_404 = false; + var $is_comments_popup = false; var $is_admin = false; function init () { @@ -187,11 +188,15 @@ class WP_Query { $this->is_paged = true; } + if ('' != $qv['comments_popup']) { + $this->is_comments_popup = true; + } + if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { $this->is_admin = true; } - if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin)) { + if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) { $this->is_home = true; } @@ -312,6 +317,9 @@ class WP_Query { $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'"; } + if ( intval($q['comments_popup']) ) + $q['p'] = intval($q['comments_popup']); + // If a post number is specified, load that post if (($q['p'] != '') && intval($q['p']) != 0) { $q['p'] = (int) $q['p']; diff --git a/wp-includes/comment-functions.php b/wp-includes/comment-functions.php index 07f3b0dfd2..c0db08d73e 100644 --- a/wp-includes/comment-functions.php +++ b/wp-includes/comment-functions.php @@ -77,10 +77,7 @@ function comments_popup_script($width=400, $height=400, $file='') { global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript; if (empty ($file)) { - if ( file_exists( TEMPLATEPATH . '/comments-popup.php') ) - $wpcommentspopupfile = str_replace(ABSPATH, '', TEMPLATEPATH . '/comments-popup.php'); - else - $wpcommentspopupfile = 'wp-content/themes/default/comments-popup.php'; + $wpcommentspopupfile = ''; // Use the index. } else { $wpcommentspopupfile = $file; } @@ -112,9 +109,12 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com } echo 'is_404; } +function is_comments_popup () { + global $wp_query; + + return $wp_query->is_comments_popup; +} + function is_paged () { global $wp_query; @@ -1576,6 +1582,15 @@ function get_single_template() { return get_query_template('single'); } +function get_comments_popup_template() { + if ( file_exists( TEMPLATEPATH . '/comments-popup.php') ) + $template = TEMPLATEPATH . '/comments-popup.php'; + else + $template = get_theme_base() . '/default/comments-popup.php'; + + return apply_filters('comments_popup_template', $template); +} + // Borrowed from the PHP Manual user notes. Convert entities, while // preserving already-encoded entities: function htmlentities2($myHTML) {