Ticket #1595: prerendering__functions-post.php.diff
File prerendering__functions-post.php.diff, 3.1 KB (added by , 19 years ago) |
---|
-
functions-post.php
7 7 */ 8 8 function wp_insert_post($postarr = array()) { 9 9 global $wpdb, $allowedtags, $user_ID; 10 11 // for content prerendering, to simulate the loop 12 global $post, $id; 10 13 11 14 // export array as variables 12 15 extract($postarr); … … 15 18 $update = false; 16 19 if ( !empty($ID) ) { 17 20 $update = true; 18 $p ost= & get_post($ID);19 $previous_status = $p ost->post_status;21 $previous_version = & get_post($ID); 22 $previous_status = $previous_version->post_status; 20 23 } 21 24 22 25 // Get the basics. … … 104 107 $post_name = $alt_post_name; 105 108 } 106 109 } 110 111 /* WP Content Prerendering by Mark Jaquith */ 112 // In order to maintain backwards compatability with plugins that may be designed to be run from within the loop, we 113 // will now "simulate" the conditions of the loop, so that all expected global variables are availiable to the filters. 114 $post = $previous_version; 115 $fields = array( 116 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 117 'post_status', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 118 'post_modified', 'post_modified_gmt', 'post_parent','menu_order' 119 ); 107 120 121 // creating the post object, as it would look in the loop 122 foreach ( $fields as $field ) { 123 $post->$field = $$field; 124 } 125 $post->ID = $post_ID; 126 $id = $post_ID; 127 128 $post_content_filtered = apply_filters('the_content_filtered', $post_content); 129 130 108 131 if ($update) { 109 132 $postquery = 110 133 "UPDATE $wpdb->posts SET … … 112 135 post_date = '$post_date', 113 136 post_date_gmt = '$post_date_gmt', 114 137 post_content = '$post_content', 138 post_content_filtered = '$post_content_filtered', 115 139 post_title = '$post_title', 116 140 post_excerpt = '$post_excerpt', 117 141 post_status = '$post_status', … … 128 152 } else { 129 153 $postquery = 130 154 "INSERT INTO $wpdb->posts 131 (ID, post_author, post_date, post_date_gmt, post_content, post_ title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order)155 (ID, post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt, post_parent, menu_order) 132 156 VALUES 133 ('$post_ID', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_ title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order')";157 ('$post_ID', '$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order')"; 134 158 } 135 159 136 160 $result = $wpdb->query($postquery);