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'); $f = fopen("$site_dir/$newfile", 'w');
foreach ($lines as $line) { foreach ($lines as $line) {
if (preg_match('/require.*wp-blog-header/', $line)) { if (preg_match('/require.*wp-blog-header/', $line))
if ($newfile == 'comments-popup.php') $line = '//' . $line;
$line = "require('../../../wp-blog-header.php');";
else
$line = '//' . $line;
}
// Update stylesheet references. // Update stylesheet references.
$line = str_replace("<?php echo get_settings('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line); $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); $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() ) { } else if ( is_archive() && get_archive_template() ) {
include(get_archive_template()); include(get_archive_template());
exit; exit;
} else if ( is_comments_popup() && get_comments_popup_template() ) {
include(get_comments_popup_template());
exit;
} else if ( is_paged() && get_paged_template() ) { } else if ( is_paged() && get_paged_template() ) {
include(get_paged_template()); include(get_paged_template());
exit; exit;

View File

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

View File

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

View File

@ -26,6 +26,7 @@ class WP_Query {
var $is_trackback = false; var $is_trackback = false;
var $is_home = false; var $is_home = false;
var $is_404 = false; var $is_404 = false;
var $is_comments_popup = false;
var $is_admin = false; var $is_admin = false;
function init () { function init () {
@ -187,11 +188,15 @@ class WP_Query {
$this->is_paged = true; $this->is_paged = true;
} }
if ('' != $qv['comments_popup']) {
$this->is_comments_popup = true;
}
if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
$this->is_admin = true; $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; $this->is_home = true;
} }
@ -312,6 +317,9 @@ class WP_Query {
$where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'"; $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 a post number is specified, load that post
if (($q['p'] != '') && intval($q['p']) != 0) { if (($q['p'] != '') && intval($q['p']) != 0) {
$q['p'] = (int) $q['p']; $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; global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
if (empty ($file)) { if (empty ($file)) {
if ( file_exists( TEMPLATEPATH . '/comments-popup.php') ) $wpcommentspopupfile = ''; // Use the index.
$wpcommentspopupfile = str_replace(ABSPATH, '', TEMPLATEPATH . '/comments-popup.php');
else
$wpcommentspopupfile = 'wp-content/themes/default/comments-popup.php';
} else { } else {
$wpcommentspopupfile = $file; $wpcommentspopupfile = $file;
} }
@ -112,9 +109,12 @@ function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Com
} }
echo '<a href="'; echo '<a href="';
if ($wpcommentsjavascript) { if ($wpcommentsjavascript) {
echo get_settings('siteurl') . '/' . $wpcommentspopupfile.'?p='.$id.'amp;c=1'; if ( empty($wpcommentspopupfile) )
//echo get_permalink(); $home = get_settings('home');
echo '" onclick="wpopen(this.href); return false"'; else
$home = get_settings('siteurl');
echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
echo '" onclick="wpopen(this.href); return false"';
} else { } else {
// if comments_popup_script() is not in the template, display simple comment link // if comments_popup_script() is not in the template, display simple comment link
comments_link(); comments_link();

View File

@ -1244,6 +1244,12 @@ function is_404 () {
return $wp_query->is_404; return $wp_query->is_404;
} }
function is_comments_popup () {
global $wp_query;
return $wp_query->is_comments_popup;
}
function is_paged () { function is_paged () {
global $wp_query; global $wp_query;
@ -1576,6 +1582,15 @@ function get_single_template() {
return get_query_template('single'); 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 // Borrowed from the PHP Manual user notes. Convert entities, while
// preserving already-encoded entities: // preserving already-encoded entities:
function htmlentities2($myHTML) { function htmlentities2($myHTML) {