Changeset 11878
- Timestamp:
- 08/25/2009 10:05:15 PM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/capabilities.php
r11873 r11878 777 777 $caps[] = 'delete_published_posts'; 778 778 } elseif ( 'trash' == $post->post_status ) { 779 $trash_meta = get_option('wp_trash_meta'); 780 if (is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish') 779 if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) ) 781 780 $caps[] = 'delete_published_posts'; 782 781 } else { … … 806 805 $caps[] = 'delete_published_pages'; 807 806 } elseif ( 'trash' == $page->post_status ) { 808 $trash_meta = get_option('wp_trash_meta'); 809 if (is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish') 807 if ('publish' == get_post_meta($page->ID, '_wp_trash_meta_status', true) ) 810 808 $caps[] = 'delete_published_pages'; 811 809 } else { … … 841 839 $caps[] = 'edit_published_posts'; 842 840 } elseif ( 'trash' == $post->post_status ) { 843 $trash_meta = get_option('wp_trash_meta'); 844 if ( is_array($trash_meta) && isset($trash_meta['posts'][$post->ID]['status']) && $trash_meta['posts'][$post->ID]['status'] == 'publish' ) 841 if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true) ) 845 842 $caps[] = 'edit_published_posts'; 846 843 } else { … … 870 867 $caps[] = 'edit_published_pages'; 871 868 } elseif ( 'trash' == $page->post_status ) { 872 $trash_meta = get_option('wp_trash_meta'); 873 if ( is_array($trash_meta) && isset($trash_meta['posts'][$page->ID]['status']) && $trash_meta['posts'][$page->ID]['status'] == 'publish' ) 869 if ('publish' == get_post_meta($page->ID, '_wp_trash_meta_status', true) ) 874 870 $caps[] = 'edit_published_pages'; 875 871 } else { -
trunk/wp-includes/functions.php
r11750 r11878 3347 3347 */ 3348 3348 function wp_scheduled_delete() { 3349 global $wpdb; 3350 3351 $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); 3352 3353 $posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A); 3354 3355 foreach ( (array) $posts_to_delete as $post ) { 3356 wp_delete_post($post['post_id']); 3357 } 3358 3359 //Trashed Comments 3360 //TODO Come up with a better store for the comment trash meta. 3349 3361 $trash_meta = get_option('wp_trash_meta'); 3350 3362 if ( !is_array($trash_meta) ) 3351 3363 return; 3352 3353 $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);3354 3364 3355 3365 foreach ( (array) $trash_meta['comments'] as $id => $meta ) { … … 3359 3369 } 3360 3370 } 3361 foreach ( (array) $trash_meta['posts'] as $id => $meta ) {3362 if ( $meta['time'] < $delete_timestamp ) {3363 wp_delete_post($id);3364 unset($trash_meta['posts'][$id]);3365 }3366 }3367 3371 3368 3372 update_option('wp_trash_meta', $trash_meta); 3369 3373 } 3374 ?> -
trunk/wp-includes/post.php
r11841 r11878 1150 1150 do_action('delete_post', $postid); 1151 1151 1152 $trash_meta = get_option('wp_trash_meta'); 1153 if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { 1154 unset($trash_meta['posts'][$postid]); 1155 update_option('wp_trash_meta', $trash_meta); 1156 } 1152 delete_post_meta($postid,'_wp_trash_meta_status'); 1153 delete_post_meta($postid,'_wp_trash_meta_time'); 1157 1154 1158 1155 /** @todo delete for pluggable post taxonomies too */ … … 1225 1222 * @return mixed False on failure 1226 1223 */ 1227 function wp_trash_post($post id = 0) {1224 function wp_trash_post($post_id = 0) { 1228 1225 if ( EMPTY_TRASH_DAYS == 0 ) 1229 return wp_delete_post($post id);1230 1231 if ( !$post = wp_get_single_post($post id, ARRAY_A) )1226 return wp_delete_post($post_id); 1227 1228 if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) 1232 1229 return $post; 1233 1230 1234 do_action('trash_post', $postid); 1235 1236 $trash_meta = get_option('wp_trash_meta'); 1237 if ( !is_array($trash_meta) ) 1238 $trash_meta = array(); 1239 $trash_meta['posts'][$postid]['status'] = $post['post_status']; 1240 $trash_meta['posts'][$postid]['time'] = time(); 1241 update_option('wp_trash_meta', $trash_meta); 1231 do_action('trash_post', $post_id); 1232 1233 add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']); 1234 add_post_meta($post_id,'_wp_trash_meta_time', time()); 1242 1235 1243 1236 $post['post_status'] = 'trash'; 1244 1237 wp_insert_post($post); 1245 1238 1246 do_action('trashed_post', $post id);1239 do_action('trashed_post', $post_id); 1247 1240 1248 1241 return $post; … … 1259 1252 * @return mixed False on failure 1260 1253 */ 1261 function wp_untrash_post($post id = 0) {1262 if ( !$post = wp_get_single_post($post id, ARRAY_A) )1254 function wp_untrash_post($post_id = 0) { 1255 if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) 1263 1256 return $post; 1264 1257 1265 do_action('untrash_post', $postid); 1266 1267 $post['post_status'] = ($post->post_type == 'attachment') ? 'inherit' : 'draft'; 1268 1269 $trash_meta = get_option('wp_trash_meta'); 1270 if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { 1271 $post['post_status'] = $trash_meta['posts'][$postid]['status']; 1272 unset($trash_meta['posts'][$postid]); 1273 update_option('wp_trash_meta', $trash_meta); 1274 } 1258 do_action('untrash_post', $post_id); 1259 1260 $post['post_status'] = ('attachment' == $post['post_type'] ) ? 'inherit' : 'draft'; 1261 1262 delete_post_meta($post_id,'_wp_trash_meta_status'); 1263 delete_post_meta($post_id,'_wp_trash_meta_time'); 1275 1264 1276 1265 wp_insert_post($post); 1277 1266 1278 do_action('untrashed_post', $post id);1267 do_action('untrashed_post', $post_id); 1279 1268 1280 1269 return $post; … … 2667 2656 return wp_trash_post($postid); 2668 2657 2669 $trash_meta = get_option('wp_trash_meta'); 2670 if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) { 2671 unset($trash_meta['posts'][$postid]); 2672 update_option('wp_trash_meta', $trash_meta); 2673 } 2658 delete_post_meta($post_id,'_wp_trash_meta_status'); 2659 delete_post_meta($post_id,'_wp_trash_meta_time'); 2660 2674 2661 2675 2662 $meta = wp_get_attachment_metadata( $postid );
Note: See TracChangeset
for help on using the changeset viewer.