Ticket #20904: 20904.patch

File 20904.patch, 3.0 KB (added by boonebgorges, 11 months ago)
  • wp-includes/query.php

    diff --git wp-includes/query.php wp-includes/query.php
    index dc56be4..1b6438d 100644
    class WP_Query { 
    28202820                        do_action_ref_array('loop_start', array(&$this)); 
    28212821 
    28222822                $post = $this->next_post(); 
    2823                 setup_postdata($post); 
     2823                $this->setup_postdata($post); 
    28242824        } 
    28252825 
    28262826        /** 
    class WP_Query { 
    30133013        } 
    30143014 
    30153015        /** 
     3016         * Set up global post data. 
     3017         * 
     3018         * @param object $post Post data. 
     3019         * @uses do_action_ref_array() Calls 'the_post' 
     3020         * @return bool True when finished. 
     3021         */ 
     3022        function setup_postdata($post) { 
     3023                global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages; 
     3024 
     3025                $id = (int) $post->ID; 
     3026 
     3027                $authordata = get_userdata($post->post_author); 
     3028 
     3029                $currentday = mysql2date('d.m.y', $post->post_date, false); 
     3030                $currentmonth = mysql2date('m', $post->post_date, false); 
     3031                $numpages = 1; 
     3032                $page = $this->get('page'); 
     3033                if ( !$page ) 
     3034                        $page = 1; 
     3035 
     3036                if ( $this->is_single() || $this->is_page() || $this->is_feed() ) 
     3037                        $more = 1; 
     3038                $content = $post->post_content; 
     3039                if ( strpos( $content, '<!--nextpage-->' ) ) { 
     3040                        if ( $page > 1 ) 
     3041                                $more = 1; 
     3042                        $multipage = 1; 
     3043                        $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content); 
     3044                        $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content); 
     3045                        $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content); 
     3046                        $pages = explode('<!--nextpage-->', $content); 
     3047                        $numpages = count($pages); 
     3048                } else { 
     3049                        $pages = array( $post->post_content ); 
     3050                        $multipage = 0; 
     3051                } 
     3052 
     3053                do_action_ref_array('the_post', array(&$post)); 
     3054 
     3055                return true; 
     3056        } 
     3057 
     3058 
     3059        /** 
    30163060         * Constructor. 
    30173061         * 
    30183062         * Sets up the WordPress query, if parameter is not empty. 
    function wp_old_slug_redirect() { 
    35873631 * @return bool True when finished. 
    35883632 */ 
    35893633function setup_postdata($post) { 
    3590         global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages; 
    3591  
    3592         $id = (int) $post->ID; 
    3593  
    3594         $authordata = get_userdata($post->post_author); 
     3634        global $wp_query; 
    35953635 
    3596         $currentday = mysql2date('d.m.y', $post->post_date, false); 
    3597         $currentmonth = mysql2date('m', $post->post_date, false); 
    3598         $numpages = 1; 
    3599         $page = get_query_var('page'); 
    3600         if ( !$page ) 
    3601                 $page = 1; 
    3602         if ( is_single() || is_page() || is_feed() ) 
    3603                 $more = 1; 
    3604         $content = $post->post_content; 
    3605         if ( strpos( $content, '<!--nextpage-->' ) ) { 
    3606                 if ( $page > 1 ) 
    3607                         $more = 1; 
    3608                 $multipage = 1; 
    3609                 $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content); 
    3610                 $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content); 
    3611                 $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content); 
    3612                 $pages = explode('<!--nextpage-->', $content); 
    3613                 $numpages = count($pages); 
    3614         } else { 
    3615                 $pages = array( $post->post_content ); 
    3616                 $multipage = 0; 
     3636        if ( is_a( $wp_query, 'WP_Query' ) ) { 
     3637                return $wp_query->setup_postdata( $post ); 
    36173638        } 
    36183639 
    3619         do_action_ref_array('the_post', array(&$post)); 
    3620  
    3621         return true; 
     3640        return false; 
    36223641}