WordPress.org

Make WordPress Core

Ticket #1595: prerendering__functions.php.diff

File prerendering__functions.php.diff, 1.3 KB (added by markjaquith, 13 years ago)

for WP 1.6 SVN

  • functions.php

     
    916916
    917917// Setup global post data.
    918918function setup_postdata($post) {
    919   global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
     919  global $wpdb, $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
    920920        global $pagenow;
    921921
    922922        $id = $post->ID;
     
    931931                $page = 1;
    932932        if (is_single() || is_page())
    933933                $more = 1;
    934         $content = $post->post_content;
     934
     935        // check for missing post_content_filtered
     936        if ( strlen($post->post_content_filtered) == 0 && strlen($post->post_content) != 0 ) {
     937                // we need to run the filters
     938                $post->post_content_filtered = apply_filters('the_content_filtered', $post->post_content);
     939                $wpdb->query("UPDATE $wpdb->posts SET post_content_filtered = '$post->post_content_filtered' WHERE ID = '$post->ID'");
     940        }
     941
     942        $content = $post->post_content_filtered;
    935943        if (preg_match('/<!--nextpage-->/', $content)) {
    936944                if ($page > 1)
    937945                        $more = 1;
     
    942950                $pages = explode('<!--nextpage-->', $content);
    943951                $numpages = count($pages);
    944952        } else {
    945                 $pages[0] = $post->post_content;
     953                $pages[0] = $post->post_content_filtered;
    946954                $multipage = 0;
    947955        }
    948956        return true;