From 6b12e25d035b741397b9bdcf68981cb17f3820ae Mon Sep 17 00:00:00 2001 From: rboren Date: Wed, 28 Jul 2004 02:43:54 +0000 Subject: [PATCH] Support timestamp permalinks. Make wider use of is_single(). Bug 0000194. git-svn-id: http://svn.automattic.com/wordpress/trunk@1491 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-blog-header.php | 2 +- wp-includes/classes.php | 6 ++++++ wp-includes/functions.php | 3 ++- wp-includes/template-functions-comment.php | 9 +++++---- wp-includes/template-functions-general.php | 4 ++-- wp-trackback.php | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/wp-blog-header.php b/wp-blog-header.php index db0c0a7aa3..46d012905d 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -149,7 +149,7 @@ update_category_cache(); $posts = query_posts($query_string); if (1 == count($posts)) { - if ($p || $name) { + if (is_single()) { $more = 1; $single = 1; } diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 9df0fb8446..8f3d0a48a2 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -65,6 +65,12 @@ class WP_Query_State { $this->date = true; } + // If year, month, day, hour, minute, and second are set, a single + // post is being queried. + if (('' != $hour) && ('' != $minute) &&('' != $second) && ('' != $year) && ('' != $monthnum) && ('' != $day)) { + $this->single = true; + } + if (!empty($s)) { $this->search = true; } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index aca0d24aa6..02214ea5a1 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1248,7 +1248,8 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') { $feedquery = $feedindex . '?' . $query . '&feed=' . preg_index($num_toks + 1, $matches); $post = 0; - if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')) { + if (strstr($struct, '%postname%') || strstr($struct, '%post_id%') + || (strstr($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) { $post = 1; $trackbackmatch = $match . $trackbackregex; $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; diff --git a/wp-includes/template-functions-comment.php b/wp-includes/template-functions-comment.php index 4b8daf3ed3..2a3b2040ea 100644 --- a/wp-includes/template-functions-comment.php +++ b/wp-includes/template-functions-comment.php @@ -17,9 +17,9 @@ add_filter('comment_text', 'convert_smilies', 20); add_filter('comment_excerpt', 'convert_chars'); function comments_template() { - global $withcomments, $single, $post, $wpdb, $id, $comment, $cookiehash; + global $withcomments, $post, $wpdb, $id, $comment, $cookiehash; - if ( $single || $withcomments ) : + if ( is_single() || $withcomments ) : $req = get_settings('require_name_email'); $comment_author = isset($_COOKIE['comment_author_'.$cookiehash]) ? trim(stripslashes($_COOKIE['comment_author_'.$cookiehash])) : ''; $comment_author_email = isset($_COOKIE['comment_author_email_'.$cookiehash]) ? trim(stripslashes($_COOKIE['comment_author_email_'.$cookiehash])) : ''; @@ -71,8 +71,9 @@ function comments_popup_script($width=400, $height=400, $file='wp-comments-popup function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $cookiehash; global $querystring_start, $querystring_equal, $querystring_separator; - global $comment_count_cache, $single; - if (!$single) { + global $comment_count_cache; + + if (! is_single()) { if ('' == $comment_count_cache["$id"]) { $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';"); } else { diff --git a/wp-includes/template-functions-general.php b/wp-includes/template-functions-general.php index 12de99ffbf..3cedac1c22 100644 --- a/wp-includes/template-functions-general.php +++ b/wp-includes/template-functions-general.php @@ -98,7 +98,7 @@ function get_bloginfo($show='') { function wp_title($sep = '»', $display = true) { global $wpdb; - global $m, $year, $monthnum, $day, $cat, $p, $name, $month, $posts, $single; + global $m, $year, $monthnum, $day, $cat, $p, $name, $month, $posts; // If there's a category if(!empty($cat)) { @@ -128,7 +128,7 @@ function wp_title($sep = '»', $display = true) { } // If there's a post - if ($single) { + if (is_single()) { $title = strip_tags($posts[0]->post_title); $title = apply_filters('single_post_title', $title); } diff --git a/wp-trackback.php b/wp-trackback.php index 737d54b514..891ab1aea3 100644 --- a/wp-trackback.php +++ b/wp-trackback.php @@ -15,7 +15,7 @@ if (! $doing_trackback) { require('wp-blog-header.php'); } -if ( (($p != '') && ($p != 'all')) || ($name != '') ) { +if (is_single()) { $tb_id = $posts[0]->ID; }