ID; if (!empty($post->post_password)) { // if there's a password if (stripslashes($_COOKIE['wp-postpass_'.$cookiehash]) != $post->post_password) { // and it doesn't match the cookie $output = get_the_password_form(); echo $output; } } if ($more_file != '') { $file = $more_file; } else { $file = $pagenow; //$_SERVER['PHP_SELF']; } // if there is no prerendered content create it if (strlen($post->post_content_filtered) == 0) { pre_render($post->ID); $post->post_content_filtered = $wpdb->get_var("SELECT post_content_filtered FROM $tableposts WHERE ID=$post->ID;"); } $content = $post->post_content_filtered; $content = explode('', $content); $teaser = $content[0]; $output .= $teaser; if (count($content)>1) { if ($more) { $output .= ''.$content[1]; } else { $output .= ' '.$more_link_text.'

'; } } echo apply_filters('the_prerendered_content', $output); } function pre_render($id) { global $wpdb, $tableposts; // first fetch the post $post_text = $wpdb->get_var("SELECT post_content FROM $tableposts WHERE ID=$id;"); // then apply all the filters we have set $rendered = apply_filters('the_content', $post_text); $rendered = str_replace(']]>', ']]>', $rendered); // an finally fix it up for entering into the database $rendered_done = addslashes($rendered); // put it in the database $wpdb->query("UPDATE $tableposts SET post_content_filtered='$rendered_done' WHERE ID=$id;"); // return the id as per the filter spec return $id; } // set it so that the prerendered version is updated whenever a post is published or edited add_action('edit_post', 'pre_render',6); add_action('publish_post', 'pre_render',6); ?>