Introduce get_template_directory() and bloginfo('stylesheet_directory'). Make comments_popup_script() theme aware.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1726 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-09-30 17:56:16 +00:00
parent e531de6f04
commit d5c9465fa9
4 changed files with 118 additions and 97 deletions

View File

@ -192,15 +192,7 @@ if (1 == count($posts)) {
$wp_did_header = true; $wp_did_header = true;
endif; endif;
$wp_template = get_settings('template'); $wp_template_dir = get_template_directory();
if ($wp_template == 'default') {
$wp_template = '';
}
if (! empty($wp_template)) {
$wp_template = "themes/$wp_template/";
}
// Template redirection // Template redirection
if ($pagenow == 'index.php') { if ($pagenow == 'index.php') {
@ -214,55 +206,55 @@ if ($pagenow == 'index.php') {
include(dirname(__FILE__) . '/wp-trackback.php'); include(dirname(__FILE__) . '/wp-trackback.php');
exit; exit;
} else if (is_home() && } else if (is_home() &&
file_exists(ABSPATH . "wp-content/${wp_template}index.php")) { file_exists("$wp_template_dir/index.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}index.php"); include("$wp_template_dir/index.php");
exit; exit;
} else if (is_single() && } else if (is_single() &&
file_exists(ABSPATH . "wp-content/${wp_template}single.php")) { file_exists("$wp_template_dir/single.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}single.php"); include("$wp_template_dir/single.php");
exit; exit;
} else if (is_page() && } else if (is_page() &&
file_exists(ABSPATH . "wp-content/${wp_template}page.php")) { file_exists("$wp_template_dir/page.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}page.php"); include("$wp_template_dir/page.php");
exit; exit;
} else if (is_category() && } else if (is_category() &&
file_exists(ABSPATH . "wp-content/${wp_template}category.php")) { file_exists("$wp_template_dir/category.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}category.php"); include("$wp_template_dir/category.php");
exit; exit;
} else if (is_author() && } else if (is_author() &&
file_exists(ABSPATH . "wp-content/${wp_template}author.php")) { file_exists("$wp_template_dir/author.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}author.php"); include("$wp_template_dir/author.php");
exit; exit;
} else if (is_date() && } else if (is_date() &&
file_exists(ABSPATH . "wp-content/${wp_template}date.php")) { file_exists("$wp_template_dir/date.php")) {
$wp_did_date = true; $wp_did_date = true;
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}date.php"); include("$wp_template_dir/date.php");
exit; exit;
} else if (is_archive() && } else if (is_archive() &&
file_exists(ABSPATH . "wp-content/${wp_template}archive.php")) { file_exists("$wp_template_dir/archive.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}archive.php"); include("$wp_template_dir/archive.php");
exit; exit;
} else if (is_search() && } else if (is_search() &&
file_exists(ABSPATH . "wp-content/${wp_template}search.php")) { file_exists("$wp_template_dir/search.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}search.php"); include("$wp_template_dir/search.php");
exit; exit;
} else if (is_404() && } else if (is_404() &&
file_exists(ABSPATH . "wp-content/${wp_template}404.php")) { file_exists("$wp_template_dir/404.php")) {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}404.php"); include("$wp_template_dir/404.php");
exit; exit;
} else if (file_exists(ABSPATH . "wp-content/${wp_template}index.php")) } else if (file_exists("$wp_template_dir/index.php"))
{ {
$wp_did_template_redirect = true; $wp_did_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}index.php"); include("$wp_template_dir/index.php");
exit; exit;
} }
} }

View File

@ -1704,4 +1704,16 @@ function the_post() {
start_wp(true); start_wp(true);
} }
function get_template_directory() {
$template = get_settings('template');
if (empty($template) || $template == 'default') {
$template = ABSPATH . "wp-content";
} else {
$template = ABSPATH . "wp-content/themes/$template";
}
return $template;
}
?> ?>

View File

@ -26,15 +26,11 @@ function comments_template() {
$comment_author_url = isset($_COOKIE['comment_author_url_'.$cookiehash]) ? trim(stripslashes($_COOKIE['comment_author_url_'.$cookiehash])) : ''; $comment_author_url = isset($_COOKIE['comment_author_url_'.$cookiehash]) ? trim(stripslashes($_COOKIE['comment_author_url_'.$cookiehash])) : '';
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date"); $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
$wp_template = get_settings('template'); $template = get_template_directory();
if ($wp_template == 'default') { $template .= "/comments.php";
$wp_template = '';
} else {
$wp_template = ABSPATH . "wp-content/themes/$wp_template/comments.php";
}
if(! empty($wp_template) && file_exists($wp_template)) { if (file_exists($template)) {
include($wp_template); include($template);
} else { } else {
include(ABSPATH . 'wp-comments.php'); include(ABSPATH . 'wp-comments.php');
} }
@ -75,7 +71,19 @@ function comments_link($file='', $echo=true) {
function comments_popup_script($width=400, $height=400, $file='wp-comments-popup.php') { function comments_popup_script($width=400, $height=400, $file='wp-comments-popup.php') {
global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript; global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
if (empty ($file)) {
$template = get_template_directory();
$template .= '/comments-popup.php';
if (file_exists($template)) {
$wpcommentspopupfile = $template;
} else {
$wpcommentspopupfile = 'wp-comments-popup.php';
}
} else {
$wpcommentspopupfile = $file; $wpcommentspopupfile = $file;
}
$wpcommentsjavascript = 1; $wpcommentsjavascript = 1;
$javascript = "<script type=\"text/javascript\">\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n"; $javascript = "<script type=\"text/javascript\">\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
echo $javascript; echo $javascript;

View File

@ -85,6 +85,15 @@ function get_bloginfo($show='') {
$output = get_settings('siteurl') . "/wp-content/themes/$output/style.css"; $output = get_settings('siteurl') . "/wp-content/themes/$output/style.css";
} }
break; break;
case 'stylesheet_directory':
$output = get_settings('stylesheet');;
if (empty($output) || $output == 'default') {
$output = get_settings('siteurl');
} else {
$output = get_settings('siteurl') . "/wp-content/themes/$output";
}
break;
case 'template_directory':
case 'template_url': case 'template_url':
$output = get_settings('template');; $output = get_settings('template');;
if (empty($output) || $output == 'default') { if (empty($output) || $output == 'default') {