WordPress.org

Make WordPress Core

Ticket #21276: 21276.diff

File 21276.diff, 2.1 KB (added by brandondove, 6 years ago)
  • wp-includes/query.php

     
    22012201                }
    22022202
    22032203                // Allow plugins to contextually add/remove/modify the search section of the database query
    2204                 $search = apply_filters_ref_array('posts_search', array( $search, &$this ) );
     2204                if ( !$q['suppress_filters'] )
     2205                        $search = apply_filters_ref_array('posts_search', array( $search, &$this ) );
     2206               
    22052207
    22062208                // Taxonomies
    22072209                if ( !$this->is_singular ) {
     
    26092611
    26102612                $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
    26112613
    2612                 if ( !$q['suppress_filters'] ) {
     2614                if ( !$q['suppress_filters'] )
    26132615                        $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) );
    2614                 }
    26152616
    26162617                if ( 'ids' == $q['fields'] ) {
    26172618                        $this->posts = $wpdb->get_col($this->request);
     
    26302631                }
    26312632
    26322633                $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 );
    2633                 $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );
     2634                if ( !$q['suppress_filters'] )
     2635                        $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this );
     2636               
    26342637
    26352638                if ( $split_the_query ) {
    26362639                        // First get the IDs and then fill in the objects
    26372640
    26382641                        $this->request = "SELECT $found_rows $distinct $wpdb->posts.ID FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
    26392642
    2640                         $this->request = apply_filters( 'posts_request_ids', $this->request, $this );
     2643                        if ( !$q['suppress_filters'] )
     2644                                $this->request = apply_filters( 'posts_request_ids', $this->request, $this );
    26412645
    26422646                        $ids = $wpdb->get_col( $this->request );
    26432647
     
    27012705                                }
    27022706                        }
    27032707
    2704                         if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) )
     2708                        if ( $this->is_preview && $this->posts && current_user_can( $edit_cap, $this->posts[0]->ID ) && !$q['suppress_filters'] )
    27052709                                $this->posts[0] = apply_filters_ref_array('the_preview', array( $this->posts[0], &$this ));
    27062710                }
    27072711