From 032dbc8c79ce2888ae13bd6ce3ca6e169839919b Mon Sep 17 00:00:00 2001 From: rboren Date: Wed, 19 Jan 2005 02:21:36 +0000 Subject: [PATCH] Deprecate start_wp(). Move start_wp functionality to setup_postdata(). Add the_post() method to WP_Query. git-svn-id: http://svn.automattic.com/wordpress/trunk@2104 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/classes.php | 6 +++++ wp-includes/functions.php | 27 +++++++++++++--------- wp-includes/template-functions-general.php | 12 ++++++---- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 187b417ad..03cdecdb9 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -571,6 +571,12 @@ class WP_Query { return $this->post; } + function the_post() { + global $post; + $post = $this->next_post(); + setup_postdata($post); + } + function have_posts() { if ($this->current_post + 1 < $this->post_count) { return true; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index ab5084ec8..493f31333 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -796,15 +796,20 @@ function do_enclose( $content, $post_ID ) { } } -function start_wp($use_wp_query = false) { - global $post, $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages, $wp_query; - global $pagenow; +// Deprecated. Use the new post loop. +function start_wp() { + global $wp_query, $post; - if ($use_wp_query) { - $post = $wp_query->next_post(); - } else { - $wp_query->next_post(); - } + // Since the old style loop is being used, advance the query iterator here. + $wp_query->next_post(); + + setup_postdata($post); +} + +// Setup global post data. +function setup_postdata($post) { + global $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages, $wp_query; + global $pagenow; if (!$preview) { $id = $post->ID; @@ -831,11 +836,10 @@ function start_wp($use_wp_query = false) { if (isset($p)) $more = 1; $content = $post->post_content; - if (preg_match('//', $post->post_content)) { + if (preg_match('//', $content)) { if ($page > 1) $more = 1; $multipage = 1; - $content = $post->post_content; $content = str_replace("\n\n", '', $content); $content = str_replace("\n", '', $content); $content = str_replace("\n", '', $content); @@ -1240,7 +1244,8 @@ function rewind_posts() { } function the_post() { - start_wp(true); + global $wp_query; + $wp_query->the_post(); } function get_stylesheet() { diff --git a/wp-includes/template-functions-general.php b/wp-includes/template-functions-general.php index 032db101b..5b54fc152 100644 --- a/wp-includes/template-functions-general.php +++ b/wp-includes/template-functions-general.php @@ -607,18 +607,20 @@ function the_time( $d = '' ) { function get_the_time( $d = '' ) { if ( '' == $d ) - $the_time = date( get_settings('time_format'), get_post_time() ); + $the_time = get_post_time(get_settings('time_format')); else - $the_time = date( $d, get_post_time() ); + $the_time = get_post_time($d); return apply_filters('get_the_time', $the_time); } -function get_post_time( $gmt = false ) { // returns timestamp +function get_post_time( $d = 'U', $gmt = false ) { // returns timestamp global $post; if ( $gmt ) - $time = mysql2date('U', $post->post_date_gmt); + $time = $post->post_date_gmt; else - $time = mysql2date('U', $post->post_date); + $time = $post->post_date; + + $time = mysql2date($d, $time); return apply_filters('get_the_time', $time); }