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;
endif;
$wp_template = get_settings('template');
if ($wp_template == 'default') {
$wp_template = '';
}
if (! empty($wp_template)) {
$wp_template = "themes/$wp_template/";
}
$wp_template_dir = get_template_directory();
// Template redirection
if ($pagenow == 'index.php') {
@ -214,55 +206,55 @@ if ($pagenow == 'index.php') {
include(dirname(__FILE__) . '/wp-trackback.php');
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}index.php");
include("$wp_template_dir/index.php");
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}single.php");
include("$wp_template_dir/single.php");
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}page.php");
include("$wp_template_dir/page.php");
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}category.php");
include("$wp_template_dir/category.php");
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}author.php");
include("$wp_template_dir/author.php");
exit;
} 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_template_redirect = true;
include(ABSPATH . "wp-content/${wp_template}date.php");
include("$wp_template_dir/date.php");
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}archive.php");
include("$wp_template_dir/archive.php");
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}search.php");
include("$wp_template_dir/search.php");
exit;
} 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;
include(ABSPATH . "wp-content/${wp_template}404.php");
include("$wp_template_dir/404.php");
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;
include(ABSPATH . "wp-content/${wp_template}index.php");
include("$wp_template_dir/index.php");
exit;
}
}

View File

@ -1704,4 +1704,16 @@ function the_post() {
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])) : '';
$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');
if ($wp_template == 'default') {
$wp_template = '';
} else {
$wp_template = ABSPATH . "wp-content/themes/$wp_template/comments.php";
}
$template = get_template_directory();
$template .= "/comments.php";
if(! empty($wp_template) && file_exists($wp_template)) {
include($wp_template);
if (file_exists($template)) {
include($template);
} else {
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') {
global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
$wpcommentspopupfile = $file;
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;
}
$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";
echo $javascript;

View File

@ -51,65 +51,74 @@ function bloginfo_unicode($show='') {
function get_bloginfo($show='') {
switch($show) {
case 'url':
case 'siteurl':
$output = get_settings('home');
break;
case 'description':
$output = get_settings('blogdescription');
break;
case 'rdf_url':
$output = get_feed_link('rdf');
break;
case 'rss_url':
$output = get_feed_link('rss');
break;
case 'rss2_url':
$output = get_feed_link('rss2');
break;
case 'atom_url':
$output = get_feed_link('atom');
break;
case 'comments_rss2_url':
$output = get_feed_link('comments_rss2');
break;
case 'pingback_url':
$output = get_settings('siteurl') .'/xmlrpc.php';
break;
case 'stylesheet_url':
$output = get_settings('stylesheet');;
if (empty($output) || $output == 'default') {
$output = get_settings('siteurl') . "/wp-layout.css";
} else {
$output = get_settings('siteurl') . "/wp-content/themes/$output/style.css";
}
break;
case 'template_url':
$output = get_settings('template');;
if (empty($output) || $output == 'default') {
$output = get_settings('siteurl');
} else {
$output = get_settings('siteurl') . "/wp-content/themes/$output";
}
break;
case 'admin_email':
$output = get_settings('admin_email');
break;
case 'charset':
$output = get_settings('blog_charset');
if ('' == $output) $output = 'UTF-8';
break;
case 'version':
global $wp_version;
$output = $wp_version;
break;
case 'name':
default:
$output = get_settings('blogname');
break;
}
return $output;
switch($show) {
case 'url':
case 'siteurl':
$output = get_settings('home');
break;
case 'description':
$output = get_settings('blogdescription');
break;
case 'rdf_url':
$output = get_feed_link('rdf');
break;
case 'rss_url':
$output = get_feed_link('rss');
break;
case 'rss2_url':
$output = get_feed_link('rss2');
break;
case 'atom_url':
$output = get_feed_link('atom');
break;
case 'comments_rss2_url':
$output = get_feed_link('comments_rss2');
break;
case 'pingback_url':
$output = get_settings('siteurl') .'/xmlrpc.php';
break;
case 'stylesheet_url':
$output = get_settings('stylesheet');;
if (empty($output) || $output == 'default') {
$output = get_settings('siteurl') . "/wp-layout.css";
} else {
$output = get_settings('siteurl') . "/wp-content/themes/$output/style.css";
}
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':
$output = get_settings('template');;
if (empty($output) || $output == 'default') {
$output = get_settings('siteurl');
} else {
$output = get_settings('siteurl') . "/wp-content/themes/$output";
}
break;
case 'admin_email':
$output = get_settings('admin_email');
break;
case 'charset':
$output = get_settings('blog_charset');
if ('' == $output) $output = 'UTF-8';
break;
case 'version':
global $wp_version;
$output = $wp_version;
break;
case 'name':
default:
$output = get_settings('blogname');
break;
}
return $output;
}
function wp_title($sep = '&raquo;', $display = true) {