Add clean_post_cache() and clean_page_cache(). Reset GUID when transitioning from draft to publish. fixes #1257
git-svn-id: http://svn.automattic.com/wordpress/trunk@2873 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5ba66d6c04
commit
8552177520
|
@ -134,20 +134,24 @@ function wp_insert_post($postarr = array()) {
|
|||
}
|
||||
|
||||
$result = $wpdb->query($postquery);
|
||||
if ( $update )
|
||||
$rval = $wpdb->rows_affected;
|
||||
|
||||
wp_set_post_cats('', $post_ID, $post_category);
|
||||
|
||||
if ( 'static' == $post_status )
|
||||
clean_page_cache($post_ID);
|
||||
else
|
||||
$rval = $wpdb->insert_id;
|
||||
clean_post_cache($post_ID);
|
||||
|
||||
// Set GUID
|
||||
if ( ! $update )
|
||||
$wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'");
|
||||
|
||||
wp_set_post_cats('', $post_ID, $post_category);
|
||||
|
||||
if ( $update) {
|
||||
if ($previous_status != 'publish' && $post_status == 'publish')
|
||||
if ($previous_status != 'publish' && $post_status == 'publish') {
|
||||
// Reset GUID if transitioning to publish.
|
||||
$wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'");
|
||||
do_action('private_to_published', $post_ID);
|
||||
}
|
||||
|
||||
do_action('edit_post', $post_ID);
|
||||
}
|
||||
|
|
|
@ -1167,6 +1167,13 @@ function update_post_cache(&$posts) {
|
|||
}
|
||||
}
|
||||
|
||||
function clean_post_cache($id) {
|
||||
global $post_cache;
|
||||
|
||||
if ( isset( $post_cache[$id] ) )
|
||||
unset( $post_cache[$id] );
|
||||
}
|
||||
|
||||
function update_page_cache(&$pages) {
|
||||
global $page_cache;
|
||||
|
||||
|
@ -1178,6 +1185,14 @@ function update_page_cache(&$pages) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function clean_page_cache($id) {
|
||||
global $page_cache;
|
||||
|
||||
if ( isset( $page_cache[$id] ) )
|
||||
unset( $page_cache[$id] );
|
||||
}
|
||||
|
||||
function update_post_category_cache($post_ids) {
|
||||
global $wpdb, $category_cache, $cache_categories;
|
||||
|
||||
|
@ -1264,6 +1279,8 @@ function update_category_cache() {
|
|||
}
|
||||
|
||||
function clean_user_cache($id) {
|
||||
global $cache_userdata;
|
||||
|
||||
if ( isset( $cache_userdata[$id] ) )
|
||||
unset( $cache_userdata[$id] );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue