WordPress.org

Make WordPress Core

Ticket #19663: patch_19663.diff

File patch_19663.diff, 1.7 KB (added by mgolawala, 6 years ago)

Move deletion of auto-draft posts to the wp_scheduled_delete cron function

  • wp-admin/includes/post.php

     
    415415                $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
    416416
    417417        if ( $create_in_db ) {
    418                 // Cleanup old auto-drafts more than 7 days old
    419                 $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
    420                 foreach ( (array) $old_posts as $delete )
    421                         wp_delete_post( $delete, true ); // Force delete
    422418                $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
    423419                $post = get_post( $post_id );
    424420                if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
  • wp-includes/functions.php

     
    33483348
    33493349/**
    33503350 * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
     3351 * Deletes auto-drafts for new posts that are > 7 days old
    33513352 *
    33523353 * @since 2.9.0
    33533354 */
     
    33893390                        wp_delete_comment($comment_id);
    33903391                }
    33913392        }
     3393
     3394        // Cleanup old auto-drafts more than 7 days old
     3395        $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
     3396        foreach ( (array) $old_posts as $delete )
     3397                wp_delete_post( $delete, true ); // Force delete
    33923398}
    33933399
    33943400/**