Changeset 31037 for trunk/src/wp-admin/includes/post.php
- Timestamp:
- 01/03/2015 08:23:06 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r30791 r31037 1022 1022 1023 1023 /** 1024 * Executes a query for attachments. An array of WP_Query arguments1025 * can be passed in, which will override the arguments set by this function.1026 * 1027 * @since 2.5.01028 * 1029 * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.1030 * @return array 1031 */ 1032 function wp_edit_attachments_query ( $q = false ) {1033 if ( false === $q ) 1024 * Get the query vars for the current attachments request 1025 * 1026 * @since 4.2.0 1027 * 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 */ 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; … … 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; … … 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 /** … … 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 ) { … … 1075 1076 } 1076 1077 1077 wp( $q ); 1078 1079 return array($post_mime_types, $avail_post_mime_types); 1078 return $q; 1079 } 1080 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
Note: See TracChangeset
for help on using the changeset viewer.