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
/* Don't remove this line. */
require('./wp-blog-header.php');
include(ABSPATH . '/wp-header.php');
get_header();
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
@ -27,7 +27,7 @@ include(ABSPATH . '/wp-header.php');
</div>
<?php comments_template(); // Get wp-comments.php template ?>
<?php comments_template( is_single() ); // Get wp-comments.php template ?>
<?php endwhile; else: ?>
<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 include(ABSPATH . '/wp-footer.php'); ?>
<?php get_footer(); ?>

View File

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

View File

@ -65,16 +65,16 @@ class WP_Query {
if ('' != $qv['name']) {
$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;
} 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
// post is being queried.
$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_single = false;
} else if (!empty($qv['s'])) {
} elseif (!empty($qv['s'])) {
$this->is_search = true;
} else {
// Look for archive queries. Dates, categories, authors.

View File

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

View File

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

View File

@ -2,6 +2,31 @@
/* 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() {
global $user_level;
get_currentuserinfo();
@ -84,7 +109,7 @@ function get_bloginfo($show='') {
case 'stylesheet_url':
$output = get_stylesheet();
if (empty($output) || $output == 'default') {
$output = get_settings('siteurl') . "/wp-layout.css";
$output = get_settings('siteurl') . "/wp-includes/wp-layout.css";
} else {
$output = get_settings('siteurl') . "/wp-content/themes/$output/style.css";
}

View File

@ -1,18 +1,7 @@
<?php
// 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 :
?>
<!-- begin footer -->
</div>
<?php
// This code pulls in the sidebar:
include(ABSPATH . '/wp-sidebar.php');
?>
<?php get_sidebar(); ?>
</div>
@ -20,5 +9,4 @@ include(ABSPATH . '/wp-sidebar.php');
<?php do_action('wp_footer', ''); ?>
</body>
</html>
<?php endif; ?>
</html>

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">
<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>
<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">
<ul>
@ -17,7 +11,7 @@ else :
</li>
<li id="search">
<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>
<input type="text" name="s" id="s" size="15" /><br />
<input type="submit" name="submit" value="<?php _e('Search'); ?>" />
@ -29,9 +23,6 @@ else :
<?php wp_get_archives('type=monthly'); ?>
</ul>
</li>
<li id="calendar">
<?php get_calendar(); ?>
</li>
<li id="meta"><?php _e('Meta:'); ?>
<ul>
<li><?php wp_register(); ?></li>
@ -48,5 +39,4 @@ else :
</ul>
</div>
<?php endif; ?>
<!-- end sidebar -->