diff --git a/source/wp-content/themes/wporg-developer/inc/advanced-search-filters.php b/source/wp-content/themes/wporg-developer/inc/advanced-search-filters.php index 0a1963355..d3080fbdb 100644 --- a/source/wp-content/themes/wporg-developer/inc/advanced-search-filters.php +++ b/source/wp-content/themes/wporg-developer/inc/advanced-search-filters.php @@ -81,9 +81,9 @@ public static function modify_query( $query ) { // If user has '()' at end of a search string, assume they want a specific function/method. $s = htmlentities( $split[0] ); - if ( str_contains( $s, '(' ) ) { + if ( str_contains( $s, '(' ) || '(' == substr( $s, -1 ) ) { // Modify the search query to omit the parentheses. - $keyword = rtrim( $keyword, '()' ); + $keyword = str_replace( array( '()', '(' ), '', $keyword ); // Restrict search to function-like content. $post_types[] = 'wp-parser-function'; diff --git a/source/wp-content/themes/wporg-developer/inc/search.php b/source/wp-content/themes/wporg-developer/inc/search.php index 538d96887..9e657bb8e 100644 --- a/source/wp-content/themes/wporg-developer/inc/search.php +++ b/source/wp-content/themes/wporg-developer/inc/search.php @@ -61,42 +61,6 @@ public static function invalid_post_type_filter_404( $query ) { } } - /** - * Modifies the query if user has used advanced search filters - * - * @param \WP_Query $query - * @return void - */ - public static function process_qualifiers( $query ) { - // Check if {qualifier}:{keyword} is used; - $split = explode(':', $query->get( 's' )); - - // TODO - We don't want to match on :: - if( count( $split ) > 1 ) { - $qualifier = strtolower( $split[0] ); - - switch ( $qualifier ) { - case 'hook': - case 'function': - case 'method': - case 'class': - $query->set( 's', substr( $query->get( 's' ), strlen($qualifier) + 1 ) ); - $query->set( 'post_type', array( 'wp-parser-'. $qualifier ) ); - } - } - - // If user has '()' at end of a search string, assume they want a specific function/method. - $s = htmlentities( $query->get( 's' ) ); - if ( '()' === substr( $s, -2 ) || '(' == substr( $s, -1 ) ) { - // Enable exact search. - $query->set( 'exact', true ); - // Modify the search query to omit the parentheses. - $query->set( 's', substr( $s, 0, -2 ) ); // remove '()' - // Restrict search to function-like content. - $query->set( 'post_type', array( 'wp-parser-function', 'wp-parser-method' ) ); - } - } - /** * Query modifications. *