Ticket #29169: 29169.3.patch
| File 29169.3.patch, 2.9 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/includes/class-wp-media-list-table.php
11 11 12 12 /** 13 13 * Constructor. 14 * 14 * 15 15 * @since 3.1.0 16 16 * @access public 17 17 * 18 18 * @see WP_List_Table::__construct() for more information on default arguments. 19 19 * 20 20 * @param array $args An associative array of arguments. 21 */ 21 */ 22 22 public function __construct( $args = array() ) { 23 $this->detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );23 $this->detached = isset( $_REQUEST['detached'] ); 24 24 25 25 parent::__construct( array( 26 26 'plural' => 'media', … … 33 33 } 34 34 35 35 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; 37 37 38 $q = $_REQUEST;38 list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); 39 39 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 45 40 $this->is_trash = isset( $_REQUEST['status'] ) && 'trash' == $_REQUEST['status']; 46 41 47 42 $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; … … 107 102 submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); 108 103 } 109 104 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' ) ) { 113 106 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); 114 107 } ?> 115 108 </div> … … 117 110 } 118 111 119 112 public function current_action() { 120 if ( isset( $_REQUEST['find_detached'] ) )121 return 'find_detached';122 123 113 if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) 124 114 return 'attach'; 125 115 -
src/wp-admin/upload.php
89 89 } 90 90 91 91 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->posts98 WHERE post_type = 'attachment' AND post_parent > '0'99 AND post_parent NOT IN (100 SELECT ID FROM $wpdb->posts101 WHERE post_type NOT IN ( 'attachment', '" . join( "', '", get_post_types( array( 'public' => false ) ) ) . "' )102 )103 " );104 105 $_REQUEST['detached'] = 1;106 break;107 92 case 'attach': 108 93 $parent_id = (int) $_REQUEST['found_post_id']; 109 94 if ( !$parent_id )