Skip to content

Commit

Permalink
Manually apply rebase conflict fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Jun 13, 2022
1 parent 3018724 commit 3d2c2f4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
36 changes: 0 additions & 36 deletions source/wp-content/themes/wporg-developer/inc/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 3d2c2f4

Please sign in to comment.