WordPress Version: 3.9
/**
* Set up global post data.
*
* @since 1.5.0
*
* @param object $post Post data.
* @uses do_action_ref_array() Calls 'the_post'
* @return bool True when finished.
*/
function setup_postdata($post)
{
global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
$id = (int) $post->ID;
$authordata = get_userdata($post->post_author);
$currentday = mysql2date('d.m.y', $post->post_date, false);
$currentmonth = mysql2date('m', $post->post_date, false);
$numpages = 1;
$multipage = 0;
$page = get_query_var('page');
if (!$page) {
$page = 1;
}
if (is_single() || is_page() || is_feed()) {
$more = 1;
}
$content = $post->post_content;
if (false !== strpos($content, '<!--nextpage-->')) {
if ($page > 1) {
$more = 1;
}
$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
// Ignore nextpage at the beginning of the content.
if (0 === strpos($content, '<!--nextpage-->')) {
$content = substr($content, 15);
}
$pages = explode('<!--nextpage-->', $content);
$numpages = count($pages);
if ($numpages > 1) {
$multipage = 1;
}
} else {
$pages = array($post->post_content);
}
/**
* Fires once the post data has been setup.
*
* @since 2.8.0
*
* @param WP_Post &$post The Post object (passed by reference).
*/
do_action_ref_array('the_post', array(&$post));
return true;
}