Schedule auto-draft deletion from post-new.php instead of from admin.php. This provides better throttling for large multisite installs and reduces the risk of a delete avalanche.

fixes #19663


git-svn-id: https://develop.svn.wordpress.org/trunk@20453 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2012-04-12 18:49:48 +00:00
parent c08d986825
commit d1100bacb4
4 changed files with 19 additions and 6 deletions
+14
View File
@@ -5163,6 +5163,20 @@ function get_post_format_link( $format ) {
return get_term_link( $term );
}
/**
* Deletes auto-drafts for new posts that are > 7 days old
*
* @since 3.4.0
*/
function wp_delete_auto_drafts() {
global $wpdb;
// Cleanup old auto-drafts more than 7 days old
$old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
foreach ( (array) $old_posts as $delete )
wp_delete_post( $delete, true ); // Force delete
}
/**
* Filters the request to allow for the format prefix.
*