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/post-formats.php

    r24249 r24301  
    867867 * @param string $more_link_text Optional. Content for when there is more text.
    868868 * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false.
     869 * @param int $id Optional. A post id. Defaults to the current post when in The Loop, undefined otherwise.
    869870 * @return string The content minus the extracted post format content.
    870871 */
    871 function get_the_remaining_content( $more_link_text = null, $strip_teaser = false ) {
    872         global $more, $page, $format_pages, $multipage, $preview;
    873 
    874         $post = get_post();
     872function get_the_remaining_content( $more_link_text = null, $strip_teaser = false, $id = 0 ) {
     873        global $more, $page, $preview;
     874
     875        $post = get_post( $id );
     876
     877        extract( wp_parse_post_content( $post, true ) );
    875878
    876879        if ( null === $more_link_text )
     
    881884
    882885        // If post password required and it doesn't match the cookie.
    883         if ( post_password_required() )
    884                 return get_the_password_form();
    885 
    886         if ( $page > count( $format_pages ) ) // if the requested page doesn't exist
    887                 $page = count( $format_pages ); // give them the highest numbered page that DOES exist
    888 
    889         $content = $format_pages[$page-1];
     886        if ( post_password_required( $post ) )
     887                return get_the_password_form( $post );
     888
     889        if ( $page > count( $pages ) ) // if the requested page doesn't exist
     890                $page = count( $pages ); // give them the highest numbered page that DOES exist
     891
     892        $content = $pages[$page-1];
    890893        if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
    891894                $content = explode( $matches[0], $content, 2 );
     
    932935 * @param string $more_link_text Optional. Content for when there is more text.
    933936 * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false.
    934  */
    935 function the_remaining_content( $more_link_text = null, $strip_teaser = false ) {
    936         $extra = get_the_remaining_content( $more_link_text, $strip_teaser );
     937 * @param int $id Optional. A post id. Defaults to the current post when in The Loop, undefined otherwise.
     938 */
     939function the_remaining_content( $more_link_text = null, $strip_teaser = false, $id = 0 ) {
     940        $post = get_post( $id );
     941
     942        $extra = get_the_remaining_content( $more_link_text, $strip_teaser, $post->ID );
    937943
    938944        remove_filter( 'the_content', 'post_formats_compat', 7 );
    939         $content = apply_filters( 'the_content', $extra );
    940         add_filter( 'the_content', 'post_formats_compat', 7 );
     945        $content = apply_filters( 'the_content', $extra, $post->ID );
     946        add_filter( 'the_content', 'post_formats_compat', 7, 2 );
    941947
    942948        echo str_replace( ']]>', ']]&gt;', $content );
Note: See TracChangeset for help on using the changeset viewer.