Make WordPress Core

Ticket #22743: 22743.diff

File 22743.diff, 1.6 KB (added by nacin, 12 years ago)
  • wp-admin/includes/ajax-actions.php

     
    18371837                wp_send_json_error();
    18381838
    18391839        $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array();
     1840
    18401841        $query = array_intersect_key( $query, array_flip( array(
    18411842                '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'
    18431844        ) ) );
    18441845
    18451846        $query['post_type'] = 'attachment';
     
    18471848        if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) )
    18481849                $query['post_status'] .= ',private';
    18491850
     1851        add_filter( 'posts_where', '_query_attachments_post_modified_gmt_since', 10, 2 );
    18501852        $query = new WP_Query( $query );
     1853        remove_filter( 'posts_where', '_query_attachments_post_modified_gmt_since', 10 );
    18511854
    18521855        $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts );
    18531856        $posts = array_filter( $posts );
     
    18551858        wp_send_json_success( $posts );
    18561859}
    18571860
     1861function _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
    18581872/**
    18591873 * Save attachment attributes.
    18601874 *