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
This commit is contained in:
parent
01ee685d3c
commit
032dbc8c79
|
@ -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;
|
||||
|
|
|
@ -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('/<!--nextpage-->/', $post->post_content)) {
|
||||
if (preg_match('/<!--nextpage-->/', $content)) {
|
||||
if ($page > 1)
|
||||
$more = 1;
|
||||
$multipage = 1;
|
||||
$content = $post->post_content;
|
||||
$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
|
||||
$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
|
||||
$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
|
||||
|
@ -1240,7 +1244,8 @@ function rewind_posts() {
|
|||
}
|
||||
|
||||
function the_post() {
|
||||
start_wp(true);
|
||||
global $wp_query;
|
||||
$wp_query->the_post();
|
||||
}
|
||||
|
||||
function get_stylesheet() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue