Ticket #30584: 30584.diff
File 30584.diff, 5.5 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
2159 2159 wp_send_json_error(); 2160 2160 2161 2161 $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); 2162 $ query = array_intersect_key( $query, array_flip(array(2162 $keys = array( 2163 2163 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', 2164 2164 'post_parent', 'post__in', 'post__not_in', 'year', 'monthnum' 2165 ) ) ); 2165 ); 2166 foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) { 2167 if ( $t->query_var && isset( $query[ $t->query_var ] ) ) { 2168 $keys[] = $t->query_var; 2169 } 2170 } 2166 2171 2172 $query = array_intersect_key( $query, array_flip( $keys ) ); 2167 2173 $query['post_type'] = 'attachment'; 2168 2174 if ( MEDIA_TRASH 2169 2175 && ! empty( $_REQUEST['query']['post_status'] ) -
src/wp-admin/includes/post.php
1021 1021 } 1022 1022 1023 1023 /** 1024 * Executes a query for attachments. An array of WP_Query arguments 1025 * can be passed in, which will override the arguments set by this function. 1024 * Get the query vars for the current attachments request 1026 1025 * 1027 * @since 2.5.01026 * @since 4.2.0 1028 1027 * 1029 * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal. 1030 * @return array 1028 * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal. 1029 * 1030 * @return array The parsed query vars. 1031 1031 */ 1032 function wp_edit_attachments_query ( $q = false ) {1033 if ( false === $q ) 1032 function wp_edit_attachments_query_vars( $q = false ) { 1033 if ( false === $q ) { 1034 1034 $q = $_GET; 1035 1035 } 1036 1036 $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0; 1037 1037 $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; 1038 1038 $q['post_type'] = 'attachment'; 1039 1039 $post_type = get_post_type_object( 'attachment' ); 1040 1040 $states = 'inherit'; 1041 if ( current_user_can( $post_type->cap->read_private_posts ) ) 1041 if ( current_user_can( $post_type->cap->read_private_posts ) ) { 1042 1042 $states .= ',private'; 1043 } 1043 1044 1044 1045 $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states; 1045 1046 $q['post_status'] = isset( $q['attachment-filter'] ) && 'trash' == $q['attachment-filter'] ? 'trash' : $states; 1046 1047 1047 1048 $media_per_page = (int) get_user_option( 'upload_per_page' ); 1048 if ( empty( $media_per_page ) || $media_per_page < 1 ) 1049 if ( empty( $media_per_page ) || $media_per_page < 1 ) { 1049 1050 $media_per_page = 20; 1051 } 1050 1052 1051 1053 /** 1052 1054 * Filter the number of items to list per page when listing media items. … … 1058 1060 $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page ); 1059 1061 1060 1062 $post_mime_types = get_post_mime_types(); 1061 $avail_post_mime_types = get_available_post_mime_types('attachment'); 1062 1063 if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) 1063 if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) { 1064 1064 unset($q['post_mime_type']); 1065 } 1065 1066 1066 1067 foreach( array_keys( $post_mime_types ) as $type ) { 1067 1068 if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" == $q['attachment-filter'] ) { … … 1074 1075 $q['post_parent'] = 0; 1075 1076 } 1076 1077 1077 wp( $q ); 1078 return $q; 1079 } 1078 1080 1079 return array($post_mime_types, $avail_post_mime_types); 1081 /** 1082 * Executes a query for attachments. An array of WP_Query arguments 1083 * can be passed in, which will override the arguments set by this function. 1084 * 1085 * @since 2.5.0 1086 * 1087 * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal. 1088 * @return array 1089 */ 1090 function wp_edit_attachments_query( $q = false ) { 1091 wp( wp_edit_attachments_query_vars( $q ) ); 1092 1093 $post_mime_types = get_post_mime_types(); 1094 $avail_post_mime_types = get_available_post_mime_types( 'attachment' ); 1095 1096 return array( $post_mime_types, $avail_post_mime_types ); 1080 1097 } 1081 1098 1082 1099 /** -
src/wp-admin/js/media.js
1 /* global ajaxurl, attachMediaBoxL10n */1 /* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings */ 2 2 3 3 var findPosts; 4 4 ( function( $ ){ … … 72 72 }; 73 73 74 74 $( document ).ready( function() { 75 var $mediaGridWrap = $( '#wp-media-grid' );75 var settings, $mediaGridWrap = $( '#wp-media-grid' ); 76 76 77 77 // Open up a manage media frame into the grid. 78 78 if ( $mediaGridWrap.length && window.wp && window.wp.media ) { 79 settings = _wpMediaGridSettings; 80 79 81 window.wp.media({ 80 82 frame: 'manage', 81 container: $mediaGridWrap 83 container: $mediaGridWrap, 84 library: settings.queryVars 82 85 }).open(); 83 86 } 84 87 -
src/wp-admin/upload.php
24 24 wp_enqueue_media(); 25 25 wp_enqueue_script( 'media-grid' ); 26 26 wp_enqueue_script( 'media' ); 27 28 $vars = wp_edit_attachments_query_vars(); 29 unset( $vars['mode'], $vars['post_type'], $vars['post_status'], $vars['posts_per_page'] ); 30 27 31 wp_localize_script( 'media-grid', '_wpMediaGridSettings', array( 28 32 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), 33 'queryVars' => $vars 29 34 ) ); 30 35 31 36 get_current_screen()->add_help_tab( array(