WordPress.org

Make WordPress Core

Ticket #9559: bug9559.omit-passworded-posts-from-search.diff

File bug9559.omit-passworded-posts-from-search.diff, 648 bytes (added by coffee2code, 5 years ago)

Aforementioned patch

  • wp-includes/query.php

     
    17591759                        if (empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) 
    17601760                                $search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')"; 
    17611761 
    1762                         if ( !empty($search) ) 
     1762                        if ( !empty($search) ) { 
    17631763                                $search = " AND ({$search}) "; 
     1764                                if ( !$this->is_admin ) 
     1765                                        $search .= " AND ($wpdb->posts.post_password = '') "; 
     1766                        } 
    17641767                } 
    17651768 
    17661769                // Category stuff