WordPress.org

Make WordPress Core

Ticket #19663: 19663.diff

File 19663.diff, 2.9 KB (added by ryan, 2 years ago)
  • wp-includes/default-filters.php

     
    253253add_action( 'transition_post_status',     '_update_term_count_on_transition_post_status', 10, 3 ); 
    254254add_action( 'comment_form',               'wp_comment_form_unfiltered_html_nonce'          ); 
    255255add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'                            ); 
     256add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts'                      ); 
    256257add_action( 'admin_init',                 'send_frame_options_header',               10, 0 ); 
    257258add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment'                           ); 
    258259add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment'                           ); 
  • wp-includes/post.php

     
    51645164} 
    51655165 
    51665166/** 
     5167 * Deletes auto-drafts for new posts that are > 7 days old 
     5168 * 
     5169 * @since 3.4.0 
     5170 */ 
     5171function wp_delete_auto_drafts() { 
     5172        global $wpdb; 
     5173 
     5174        // Cleanup old auto-drafts more than 7 days old 
     5175        $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); 
     5176        foreach ( (array) $old_posts as $delete ) 
     5177                wp_delete_post( $delete, true ); // Force delete 
     5178} 
     5179 
     5180/** 
    51675181 * Filters the request to allow for the format prefix. 
    51685182 * 
    51695183 * @access private 
  • wp-includes/functions.php

     
    33083308 
    33093309/** 
    33103310 * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS. 
    3311  * Deletes auto-drafts for new posts that are > 7 days old 
    33123311 * 
    33133312 * @since 2.9.0 
    33143313 */ 
     
    33503349                        wp_delete_comment($comment_id); 
    33513350                } 
    33523351        } 
    3353  
    3354         // Cleanup old auto-drafts more than 7 days old 
    3355         $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" ); 
    3356         foreach ( (array) $old_posts as $delete ) 
    3357                 wp_delete_post( $delete, true ); // Force delete 
    33583352} 
    33593353 
    33603354/** 
  • wp-admin/post-new.php

     
    3939if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) 
    4040        wp_die( __( 'Cheatin’ uh?' ) ); 
    4141 
     42// Schedule auto-draft cleanup 
     43if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) 
     44        wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' ); 
     45 
    4246wp_enqueue_script('autosave'); 
    4347 
    4448// Show post form.