Move scheduling of old auto-draft posts deletion to get_default_post_to_edit() (where auto-drafts are created).

Fixes #44337.

git-svn-id: https://develop.svn.wordpress.org/trunk@43338 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2018-06-08 15:52:22 +00:00
parent 2325faeb96
commit d3014a47b4
2 changed files with 5 additions and 5 deletions

View File

@ -647,6 +647,11 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
set_post_format( $post, get_option( 'default_post_format' ) );
}
// Schedule auto-draft cleanup
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
}
} else {
$post = new stdClass;
$post->ID = 0;

View File

@ -63,11 +63,6 @@ if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_
);
}
// Schedule auto-draft cleanup
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
}
$post = get_default_post_to_edit( $post_type, true );
$post_ID = $post->ID;