Ticket #22743: 22743.diff
File 22743.diff, 1.6 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
1837 1837 wp_send_json_error(); 1838 1838 1839 1839 $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); 1840 1840 1841 $query = array_intersect_key( $query, array_flip( array( 1841 1842 's', 'order', 'orderby', 'posts_per_page', 'paged', 'post_mime_type', 1842 'post_parent', 'post__in', 'post__not_in', 1843 'post_parent', 'post__in', 'post__not_in', '_query_attachments_post_modified_gmt_since' 1843 1844 ) ) ); 1844 1845 1845 1846 $query['post_type'] = 'attachment'; … … 1847 1848 if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) 1848 1849 $query['post_status'] .= ',private'; 1849 1850 1851 add_filter( 'posts_where', '_query_attachments_post_modified_gmt_since', 10, 2 ); 1850 1852 $query = new WP_Query( $query ); 1853 remove_filter( 'posts_where', '_query_attachments_post_modified_gmt_since', 10 ); 1851 1854 1852 1855 $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts ); 1853 1856 $posts = array_filter( $posts ); … … 1855 1858 wp_send_json_success( $posts ); 1856 1859 } 1857 1860 1861 function _query_attachments_post_modified_gmt_since( $where, $query ) { 1862 global $wpdb; 1863 1864 if ( $modified_since = absint( $query->get('_query_attachments_post_modified_gmt_since') ) ) { 1865 $modified_since = gmdate( 'Y-m-d H:i:s', $modified_since ); 1866 $where .= $wpdb->prepare( " AND $wpdb->posts.post_modified_gmt > %s", $modified_since ); 1867 } 1868 1869 return $where; 1870 } 1871 1858 1872 /** 1859 1873 * Save attachment attributes. 1860 1874 *