Load comments-popup template through the index.

git-svn-id: http://svn.automattic.com/wordpress/trunk@2332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2005-02-14 09:17:23 +00:00
parent 5524255aa5
commit 6a11fa21a2
7 changed files with 37 additions and 19 deletions

View File

@ -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("<?php echo get_settings('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);

View File

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

View File

@ -1,7 +1,5 @@
<?php
/* Don't remove these lines. */
$blog = 1;
require ('../../../wp-blog-header.php');
add_filter('comment_text', 'popuplinks');
foreach ($posts as $post) { start_wp();
?>

View File

@ -1,7 +1,5 @@
<?php
/* Don't remove these lines. */
$blog = 1;
require ('../../../wp-blog-header.php');
add_filter('comment_text', 'popuplinks');
foreach ($posts as $post) { start_wp();
?>

View File

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

View File

@ -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 '<a href="';
if ($wpcommentsjavascript) {
echo get_settings('siteurl') . '/' . $wpcommentspopupfile.'?p='.$id.'amp;c=1';
//echo get_permalink();
echo '" onclick="wpopen(this.href); return false"';
if ( empty($wpcommentspopupfile) )
$home = get_settings('home');
else
$home = get_settings('siteurl');
echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
echo '" onclick="wpopen(this.href); return false"';
} else {
// if comments_popup_script() is not in the template, display simple comment link
comments_link();

View File

@ -1244,6 +1244,12 @@ function is_404 () {
return $wp_query->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) {