Make WordPress Core

Ticket #29169: 29169.3.patch

File 29169.3.patch, 2.9 KB (added by ocean90, 12 years ago)
  • src/wp-admin/includes/class-wp-media-list-table.php

     
    1111
    1212        /**
    1313         * Constructor.
    14          * 
     14         *
    1515         * @since 3.1.0
    1616         * @access public
    1717         *
    1818         * @see WP_List_Table::__construct() for more information on default arguments.
    1919         *
    2020         * @param array $args An associative array of arguments.
    21          */     
     21         */
    2222        public function __construct( $args = array() ) {
    23                 $this->detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
     23                $this->detached = isset( $_REQUEST['detached'] );
    2424
    2525                parent::__construct( array(
    2626                        'plural' => 'media',
     
    3333        }
    3434
    3535        public function prepare_items() {
    36                 global $lost, $wp_query, $post_mime_types, $avail_post_mime_types, $mode;
     36                global $wp_query, $post_mime_types, $avail_post_mime_types, $mode;
    3737
    38                 $q = $_REQUEST;
     38                list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST );
    3939
    40                 if ( !empty( $lost ) )
    41                         $q['post__in'] = implode( ',', $lost );
    42 
    43                 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $q );
    44 
    4540                $this->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status'];
    4641
    4742                $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
     
    107102                        submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
    108103                }
    109104
    110                 if ( $this->detached ) {
    111                         submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false );
    112                 } elseif ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
     105                if ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
    113106                        submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
    114107                } ?>
    115108                </div>
     
    117110        }
    118111
    119112        public function current_action() {
    120                 if ( isset( $_REQUEST['find_detached'] ) )
    121                         return 'find_detached';
    122 
    123113                if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
    124114                        return 'attach';
    125115
  • src/wp-admin/upload.php

     
    8989        }
    9090
    9191        switch ( $doaction ) {
    92                 case 'find_detached':
    93                         if ( !current_user_can('edit_posts') )
    94                                 wp_die( __('You are not allowed to scan for lost attachments.') );
    95 
    96                         $lost = $wpdb->get_col( "
    97                                 SELECT ID FROM $wpdb->posts
    98                                 WHERE post_type = 'attachment' AND post_parent > '0'
    99                                 AND post_parent NOT IN (
    100                                         SELECT ID FROM $wpdb->posts
    101                                         WHERE post_type NOT IN ( 'attachment', '" . join( "', '", get_post_types( array( 'public' => false ) ) ) . "' )
    102                                 )
    103                         " );
    104 
    105                         $_REQUEST['detached'] = 1;
    106                         break;
    10792                case 'attach':
    10893                        $parent_id = (int) $_REQUEST['found_post_id'];
    10994                        if ( !$parent_id )