Moving default template stuff into wp-includes, uncluttering root

git-svn-id: http://svn.automattic.com/wordpress/trunk@2009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-12-30 10:58:06 +00:00
parent 8c472b4241
commit 232e019cc6
12 changed files with 56 additions and 69 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
/* Don't remove this line. */ /* Don't remove this line. */
require('./wp-blog-header.php'); require('./wp-blog-header.php');
include(ABSPATH . '/wp-header.php'); get_header();
?> ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
@ -27,7 +27,7 @@ include(ABSPATH . '/wp-header.php');
</div> </div>
<?php comments_template(); // Get wp-comments.php template ?> <?php comments_template( is_single() ); // Get wp-comments.php template ?>
<?php endwhile; else: ?> <?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
@ -35,4 +35,4 @@ include(ABSPATH . '/wp-header.php');
<?php posts_nav_link(' &#8212; ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?> <?php posts_nav_link(' &#8212; ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
<?php include(ABSPATH . '/wp-footer.php'); ?> <?php get_footer(); ?>

View File

@ -210,7 +210,7 @@ function populate_options() {
add_option('use_linksupdate', 0); add_option('use_linksupdate', 0);
add_option('template', 'default'); add_option('template', 'default');
add_option('stylesheet', 'default'); add_option('stylesheet', 'default');
add_option('comment_whitelist', 0); add_option('comment_whitelist', 1);
add_option('page_uris'); add_option('page_uris');
// Delete unused options // Delete unused options

View File

@ -65,16 +65,16 @@ class WP_Query {
if ('' != $qv['name']) { if ('' != $qv['name']) {
$this->is_single = true; $this->is_single = true;
} else if (($qv['p'] != '') && ($qv['p'] != 'all') && (intval($q['p']) != 0)) { } elseif ( intval( $q['p'] ) != 0 && $qv['p'] != 'all' ) {
$this->is_single = true; $this->is_single = true;
} else if (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) { } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
// If year, month, day, hour, minute, and second are set, a single // If year, month, day, hour, minute, and second are set, a single
// post is being queried. // post is being queried.
$this->is_single = true; $this->is_single = true;
} else if ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) { } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
$this->is_page = true; $this->is_page = true;
$this->is_single = false; $this->is_single = false;
} else if (!empty($qv['s'])) { } elseif (!empty($qv['s'])) {
$this->is_search = true; $this->is_search = true;
} else { } else {
// Look for archive queries. Dates, categories, authors. // Look for archive queries. Dates, categories, authors.

View File

@ -2,8 +2,8 @@
// Template functions // Template functions
function comments_template() { function comments_template( $show ) {
global $withcomments, $post, $wpdb, $id, $comment; global $wp_query, $withcomments, $post, $wpdb, $id, $comment;
if ( is_single() || is_page() || $withcomments ) : if ( is_single() || is_page() || $withcomments ) :
$req = get_settings('require_name_email'); $req = get_settings('require_name_email');
@ -12,14 +12,10 @@ 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");
$template = get_template_directory(); if ( file_exists( TEMPLATEPATH . '/comments.php') )
$template .= "/comments.php"; require( TEMPLATEPATH . '/comments.php');
else
if (file_exists($template)) { require( ABSPATH . 'wp-includes/wp-comments.php');
include($template);
} else {
include(ABSPATH . 'wp-comments.php');
}
endif; endif;
} }
@ -72,12 +68,10 @@ 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)) {
$template = TEMPLATEPATH . '/comments-popup.php'; if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
if (file_exists($template)) { require( TEMPLATEPATH . '/comments-popup.php');
$wpcommentspopupfile = str_replace(ABSPATH, '', $template); else
} else { require( ABSPATH . 'wp-includes/wp-comments-popup.php');
$wpcommentspopupfile = 'wp-comments-popup.php';
}
} else { } else {
$wpcommentspopupfile = $file; $wpcommentspopupfile = $file;
} }

View File

@ -1058,23 +1058,20 @@ function wp_head() {
function is_single ($post = '') { function is_single ($post = '') {
global $wp_query; global $wp_query;
if (! $wp_query->is_single) { if ( !$wp_query->is_single )
return false; return false;
}
if (empty($post)) { if ( empty( $post) )
return true; return true;
}
$post_obj = $wp_query->get_queried_object(); $post_obj = $wp_query->get_queried_object();
if ($post == $post_obj->ID) { if ( $post == $post_obj->ID )
return true; return true;
} else if ($post == $post_obj->post_title) { elseif ( $post == $post_obj->post_title )
return true; return true;
} else if ($post == $post_obj->post_name) { elseif ( $post == $post_obj->post_name )
return true; return true;
}
return false; return false;
} }

View File

@ -2,6 +2,31 @@
/* Note: these tags go anywhere in the template */ /* Note: these tags go anywhere in the template */
function get_header() {
global $wpdb, $wp_query;
if ( file_exists( TEMPLATEPATH . '/header.php') )
require_once( TEMPLATEPATH . '/header.php');
else
require_once( ABSPATH . 'wp-includes/wp-header.php');
}
function get_footer() {
global $wpdb, $wp_query;
if ( file_exists( TEMPLATEPATH . '/footer.php') )
require_once( TEMPLATEPATH . '/footer.php');
else
require_once( ABSPATH . 'wp-includes/wp-footer.php');
}
function get_sidebar() {
global $wpdb, $wp_query;
if ( file_exists( TEMPLATEPATH . '/sidebar.php') )
require_once( TEMPLATEPATH . '/sidebar.php');
else
require_once( ABSPATH . 'wp-includes/wp-sidebar.php');
}
function wp_loginout() { function wp_loginout() {
global $user_level; global $user_level;
get_currentuserinfo(); get_currentuserinfo();
@ -84,7 +109,7 @@ function get_bloginfo($show='') {
case 'stylesheet_url': case 'stylesheet_url':
$output = get_stylesheet(); $output = get_stylesheet();
if (empty($output) || $output == 'default') { if (empty($output) || $output == 'default') {
$output = get_settings('siteurl') . "/wp-layout.css"; $output = get_settings('siteurl') . "/wp-includes/wp-layout.css";
} else { } else {
$output = get_settings('siteurl') . "/wp-content/themes/$output/style.css"; $output = get_settings('siteurl') . "/wp-content/themes/$output/style.css";
} }

View File

@ -1,18 +1,7 @@
<?php <!-- begin footer -->
// If a footer.php file exists in the WP root directory we
// use that, otherwise use this default wp-footer.php file.
if ( file_exists(TEMPLATEPATH . '/footer.php') ) :
include_once(TEMPLATEPATH . '/footer.php');
else :
?>
</div> </div>
<?php get_sidebar(); ?>
<?php
// This code pulls in the sidebar:
include(ABSPATH . '/wp-sidebar.php');
?>
</div> </div>
@ -21,4 +10,3 @@ include(ABSPATH . '/wp-sidebar.php');
<?php do_action('wp_footer', ''); ?> <?php do_action('wp_footer', ''); ?>
</body> </body>
</html> </html>
<?php endif; ?>

View File

@ -1,10 +1,3 @@
<?php
// If a header.php file exists in the WP root directory we
// use that, otherwise use this default wp-header.php file.
if ( file_exists(TEMPLATEPATH . '/header.php') ) :
include_once(TEMPLATEPATH . '/header.php');
else :
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
@ -33,4 +26,4 @@ else :
<h1 id="header"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1> <h1 id="header"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
<div id="content"> <div id="content">
<?php endif; ?> <!-- end header -->

View File

@ -1,11 +1,5 @@
<?php
// If a sidebar.php file exists in the WP root directory we
// use that, otherwise use this default wp-sidebar.php file.
if ( file_exists(TEMPLATEPATH . '/sidebar.php') ) :
include_once(TEMPLATEPATH . '/sidebar.php');
else :
?>
<!-- begin sidebar -->
<div id="menu"> <div id="menu">
<ul> <ul>
@ -17,7 +11,7 @@ else :
</li> </li>
<li id="search"> <li id="search">
<label for="s"><?php _e('Search:'); ?></label> <label for="s"><?php _e('Search:'); ?></label>
<form id="searchform" method="get" action="<?php echo $PHP_SELF; ?>"> <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div> <div>
<input type="text" name="s" id="s" size="15" /><br /> <input type="text" name="s" id="s" size="15" /><br />
<input type="submit" name="submit" value="<?php _e('Search'); ?>" /> <input type="submit" name="submit" value="<?php _e('Search'); ?>" />
@ -29,9 +23,6 @@ else :
<?php wp_get_archives('type=monthly'); ?> <?php wp_get_archives('type=monthly'); ?>
</ul> </ul>
</li> </li>
<li id="calendar">
<?php get_calendar(); ?>
</li>
<li id="meta"><?php _e('Meta:'); ?> <li id="meta"><?php _e('Meta:'); ?>
<ul> <ul>
<li><?php wp_register(); ?></li> <li><?php wp_register(); ?></li>
@ -48,5 +39,4 @@ else :
</ul> </ul>
</div> </div>
<!-- end sidebar -->
<?php endif; ?>