Make WordPress Core


Ignore:
Timestamp:
05/20/2013 11:05:50 AM (13 years ago)
Author:
ryan
Message:
  • 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r24115 r24301  
    36823682 * @return bool True when finished.
    36833683 */
    3684 function setup_postdata($post) {
    3685     global $id, $authordata, $currentday, $currentmonth, $page, $pages, $format_pages, $multipage, $more, $numpages;
     3684function setup_postdata( $post ) {
     3685    global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;
    36863686
    36873687    $id = (int) $post->ID;
     
    36933693    $numpages = 1;
    36943694    $page = get_query_var('page');
    3695     if ( !$page )
     3695    if ( ! $page )
    36963696        $page = 1;
    36973697    if ( is_single() || is_page() || is_feed() )
    36983698        $more = 1;
    3699     $split_content = $content = $post->post_content;
    3700     $format = get_post_format( $post );
    3701     if ( $format && in_array( $format, array( 'image', 'audio', 'video', 'quote' ) ) ) {
    3702         switch ( $format ) {
    3703         case 'image':
    3704             get_the_post_format_image( 'full', $post );
    3705             if ( isset( $post->split_content ) )
    3706                 $split_content = $post->split_content;
    3707             break;
    3708         case 'audio':
    3709             get_the_post_format_media( 'audio', $post, 1 );
    3710             if ( isset( $post->split_content ) )
    3711                 $split_content = $post->split_content;
    3712             break;
    3713         case 'video':
    3714             get_the_post_format_media( 'video', $post, 1 );
    3715             if ( isset( $post->split_content ) )
    3716                 $split_content = $post->split_content;
    3717             break;
    3718         case 'quote':
    3719             get_the_post_format_quote( $post );
    3720             if ( isset( $post->split_content ) )
    3721                 $split_content = $post->split_content;
    3722             break;
    3723         }
    3724     }
    3725 
    3726     if ( strpos( $content, '<!--nextpage-->' ) ) {
    3727         if ( $page > 1 )
     3699
     3700    extract( wp_parse_post_content( $post, false ) );
     3701
     3702    if ( $multipage && ( $page > 1 ) )
    37283703            $more = 1;
    3729         $multipage = 1;
    3730         $pages = paginate_content( $content );
    3731         $format_pages = paginate_content( $split_content );
    3732         $numpages = count( $pages );
    3733     } else {
    3734         $pages = array( $post->post_content );
    3735         $format_pages = array( $split_content );
    3736         $multipage = 0;
    3737     }
    37383704
    37393705    do_action_ref_array('the_post', array(&$post));
Note: See TracChangeset for help on using the changeset viewer.