* Introduce wp_parse_post_content() and use it in setup_postdata(), get_the_content(), and get_the_remaining_content().

* Add a post ID argument to the_content(), get_the_content(), the_remaining_content(), and get_the_remaining_content().
* Pass the post ID to the the_content filter.
* Remove the format_pages global.
* Declare format_content and split_content as vars in WP_Post.
* phpdoc for the the_content filter that documents the new ID argument and denotes it as not-so-portable.

Props gcorne, DrewAPicture, duck_, aaroncampbell
see #24330


git-svn-id: https://develop.svn.wordpress.org/trunk@24301 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2013-05-20 11:05:50 +00:00
parent 5b742721ec
commit 2662748593
6 changed files with 128 additions and 65 deletions
+6 -40
View File
@@ -3681,8 +3681,8 @@ function get_paged_content( $content = '', $paged = 0 ) {
* @uses do_action_ref_array() Calls 'the_post'
* @return bool True when finished.
*/
function setup_postdata($post) {
global $id, $authordata, $currentday, $currentmonth, $page, $pages, $format_pages, $multipage, $more, $numpages;
function setup_postdata( $post ) {
global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
$id = (int) $post->ID;
@@ -3692,49 +3692,15 @@ function setup_postdata($post) {
$currentmonth = mysql2date('m', $post->post_date, false);
$numpages = 1;
$page = get_query_var('page');
if ( !$page )
if ( ! $page )
$page = 1;
if ( is_single() || is_page() || is_feed() )
$more = 1;
$split_content = $content = $post->post_content;
$format = get_post_format( $post );
if ( $format && in_array( $format, array( 'image', 'audio', 'video', 'quote' ) ) ) {
switch ( $format ) {
case 'image':
get_the_post_format_image( 'full', $post );
if ( isset( $post->split_content ) )
$split_content = $post->split_content;
break;
case 'audio':
get_the_post_format_media( 'audio', $post, 1 );
if ( isset( $post->split_content ) )
$split_content = $post->split_content;
break;
case 'video':
get_the_post_format_media( 'video', $post, 1 );
if ( isset( $post->split_content ) )
$split_content = $post->split_content;
break;
case 'quote':
get_the_post_format_quote( $post );
if ( isset( $post->split_content ) )
$split_content = $post->split_content;
break;
}
}
if ( strpos( $content, '<!--nextpage-->' ) ) {
if ( $page > 1 )
extract( wp_parse_post_content( $post, false ) );
if ( $multipage && ( $page > 1 ) )
$more = 1;
$multipage = 1;
$pages = paginate_content( $content );
$format_pages = paginate_content( $split_content );
$numpages = count( $pages );
} else {
$pages = array( $post->post_content );
$format_pages = array( $split_content );
$multipage = 0;
}
do_action_ref_array('the_post', array(&$post));