Make WordPress Core

Ticket #24330: 24330.3.diff

File 24330.3.diff, 8.3 KB (added by DrewAPicture, 12 years ago)

Better phpdoc, remove extra $page global in the else

  • wp-includes/comment.php

     
    17491749        }
    17501750
    17511751        if ( empty($post->post_excerpt) )
    1752                 $excerpt = apply_filters('the_content', $post->post_content);
     1752                $excerpt = apply_filters('the_content', $post->post_content, $post->ID);
    17531753        else
    17541754                $excerpt = apply_filters('the_excerpt', $post->post_excerpt);
    17551755        $excerpt = str_replace(']]>', ']]>', $excerpt);
  • wp-includes/default-filters.php

     
    136136add_filter( 'the_title', 'trim'          );
    137137add_filter( 'the_title', '_post_formats_title', 10, 2 );
    138138
    139 add_filter( 'the_content', 'post_formats_compat', 7 );
     139add_filter( 'the_content', 'post_formats_compat', 7, 2 );
    140140add_filter( 'the_content', 'wptexturize'            );
    141141add_filter( 'the_content', 'convert_smilies'        );
    142142add_filter( 'the_content', 'convert_chars'          );
  • wp-includes/post-template.php

     
    160160 *
    161161 * @param string $more_link_text Optional. Content for when there is more text.
    162162 * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false.
     163 * @param int $id Optional. A post id. Defaults to the current post when in The Loop, undefined otherwise.
    163164 */
    164 function the_content( $more_link_text = null, $strip_teaser = false ) {
    165         $content = apply_filters( 'the_content', get_the_content( $more_link_text, $strip_teaser ) );
     165function the_content( $more_link_text = null, $strip_teaser = false, $id = 0 ) {
     166        $post = get_post( $id );
     167
     168        /*
     169         * Filter: the_content
     170         *
     171         * param string Post content as returned by get_the_content()
     172         * param int The ID of the post to which the content belongs. This was introduced
     173         *           in 3.6.0 and is not reliably passed by all plugins and themes that
     174         *           directly apply the_content. As such, it is not considered portable.
     175         */
     176        $content = apply_filters( 'the_content', get_the_content( $more_link_text, $strip_teaser, $post->ID ), $post->ID );
    166177        echo str_replace( ']]>', ']]>', $content );
    167178}
    168179
     
    173184 *
    174185 * @param string $more_link_text Optional. Content for when there is more text.
    175186 * @param bool $stripteaser Optional. Strip teaser content before the more text. Default is false.
     187 * @param int $id Optional. A post id. Defaults to the current post when in The Loop, undefined otherwise.
    176188 * @return string
    177189 */
    178 function get_the_content( $more_link_text = null, $strip_teaser = false ) {
    179         global $more, $page, $pages, $multipage, $preview;
     190function get_the_content( $more_link_text = null, $strip_teaser = false, $id = 0 ) {
     191        global $page, $more, $preview;
    180192
    181         $post = get_post();
     193        $post = get_post( $id );
     194        if ( $post->ID != $_GLOBALS['id'] )
     195                extract( wp_parse_post_content( $post ) );
     196        else
     197                global $pages, $multipage;
    182198
    183199        if ( null === $more_link_text )
    184200                $more_link_text = __( '(more…)' );
     
    187203        $has_teaser = false;
    188204
    189205        // If post password required and it doesn't match the cookie.
    190         if ( post_password_required() )
    191                 return get_the_password_form();
     206        if ( post_password_required( $post ) )
     207                return get_the_password_form( $post );
    192208
    193209        if ( $page > count( $pages ) ) // if the requested page doesn't exist
    194210                $page = count( $pages ); // give them the highest numbered page that DOES exist
     
    226242
    227243        if ( $preview ) // preview fix for javascript bug with foreign languages
    228244                $output =       preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
    229 
    230245        return $output;
    231246}
    232247
     
    12251240 *
    12261241 * @since 1.0.0
    12271242 * @uses apply_filters() Calls 'the_password_form' filter on output.
    1228  *
     1243 * @param int $id Optional. A post id. Defaults to the current post when in The Loop, undefined otherwise.
    12291244 * @return string HTML content for password form for password protected post.
    12301245 */
    1231 function get_the_password_form() {
     1246function get_the_password_form( $id = 0 ) {
    12321247        $post = get_post();
    12331248        $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID );
    12341249        $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
  • wp-includes/post.php

     
    49624962                update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache );
    49634963        }
    49644964}
     4965
     4966/**
     4967 * Parse post content for pagination
     4968 *
     4969 * @since 3.6.0
     4970 *
     4971 * @uses paginate_content()
     4972 *
     4973 * @param object $post The post object.
     4974 * @return array An array of values used for paginating the parsed content.
     4975 */
     4976function wp_parse_post_content( $post ) {
     4977        $split_content = $content = $post->post_content;
     4978        $format = get_post_format( $post );
     4979        if ( $format && in_array( $format, array( 'image', 'audio', 'video', 'quote' ) ) ) {
     4980                switch ( $format ) {
     4981                case 'image':
     4982                        get_the_post_format_image( 'full', $post );
     4983                        if ( isset( $post->split_content ) )
     4984                                $split_content = $post->split_content;
     4985                        break;
     4986                case 'audio':
     4987                        get_the_post_format_media( 'audio', $post, 1 );
     4988                        if ( isset( $post->split_content ) )
     4989                                $split_content = $post->split_content;
     4990                        break;
     4991                case 'video':
     4992                        get_the_post_format_media( 'video', $post, 1 );
     4993                        if ( isset( $post->split_content ) )
     4994                                $split_content = $post->split_content;
     4995                        break;
     4996                case 'quote':
     4997                        get_the_post_format_quote( $post );
     4998                        if ( isset( $post->split_content ) )
     4999                                $split_content = $post->split_content;
     5000                        break;
     5001                }
     5002        }
     5003
     5004        $numpages = 1;
     5005        if ( strpos( $content, '<!--nextpage-->' ) ) {
     5006                $multipage = 1;
     5007                $pages = paginate_content( $content );
     5008                $format_pages = paginate_content( $split_content );
     5009                $numpages = count( $pages );
     5010        } else {
     5011                $pages = array( $post->post_content );
     5012                $format_pages = array( $split_content );
     5013                $multipage = 0;
     5014        }
     5015
     5016        return compact( 'multipage', 'pages', 'numpages', 'format_pages' );
     5017}
  • wp-includes/query.php

     
    36813681 * @uses do_action_ref_array() Calls 'the_post'
    36823682 * @return bool True when finished.
    36833683 */
    3684 function setup_postdata($post) {
     3684function setup_postdata( $post ) {
    36853685        global $id, $authordata, $currentday, $currentmonth, $page, $pages, $format_pages, $multipage, $more, $numpages;
    36863686
    36873687        $id = (int) $post->ID;
     
    36923692        $currentmonth = mysql2date('m', $post->post_date, false);
    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         }
    37253699
    3726         if ( strpos( $content, '<!--nextpage-->' ) ) {
    3727                 if ( $page > 1 )
     3700        extract( wp_parse_post_content( $post ) );
     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));
    37403706