Changeset 12050 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php
- Timestamp:
- 09/05/2022 05:14:31 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php
r9866 r12050 69 69 public static function pre_get_posts( $query ) { 70 70 // Don't modify anything if not a non-admin main search query. 71 if ( ! ( ! is_admin() && $query->is_main_query() && $query->is_search() ) ) { 71 if ( 72 ( 73 // Not the admin 74 is_admin() || 75 // Not non-main queries / non-searches 76 ( ! $query->is_main_query() || ! $query->is_search() ) 77 ) && 78 // but yes if it's the autocomplete search (which is admin, and not the main query). 79 ! $query->get( '_autocomplete_search' ) 80 ) { 72 81 return; 73 82 } … … 86 95 // If user has '()' at end of a search string, assume they want a specific function/method. 87 96 $s = htmlentities( $query->get( 's' ) ); 88 if ( '()' === substr( $s, -2 ) ) {97 if ( '()' === substr( $s, -2 ) || '(' == substr( $s, -1 ) ) { 89 98 // Enable exact search. 90 99 $query->set( 'exact', true ); 91 100 // Modify the search query to omit the parentheses. 92 $query->set( 's', substr( $s, 0, -2 ) ); // remove '()'101 $query->set( 's', trim( $s, '()' ) ); 93 102 // Restrict search to function-like content. 94 103 $query->set( 'post_type', array( 'wp-parser-function', 'wp-parser-method' ) );
Note: See TracChangeset
for help on using the changeset viewer.