Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Experiment: Advanced search qualifiers #87

Open
wants to merge 14 commits into
base: trunk
Choose a base branch
from

Conversation

StevenDufresne
Copy link
Contributor

@StevenDufresne StevenDufresne commented Jun 7, 2022

Mentioned in: meta:3158.

Allow some basic search qualifiers to make searching a little bit more powerful.

Filter by type:
You can combine multiple types to filter.

  • type:hook
  • type:function
  • type:method
  • type:class

Filter by file:
You can filter within 1 or more files. Will match partial paths. Uses name__like.

  • file:wp-settings.php

Filter by version:
You can filter within 1 version. Must be a full version.

  • version:4.8.0

Examples:
Search: version:4.8.0 file:class-wp-editor.php get

See version 4.8.0, file: class-wp-editor.php, looking for functions that have get in them.

Returns:

@StevenDufresne StevenDufresne marked this pull request as ready for review June 8, 2022 05:19
Comment on lines 84 to 86
if ( str_contains( $s, '(' ) ) {
// Modify the search query to omit the parentheses.
$keyword = rtrim( $keyword, '()' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. Well this breaks some of this code :D

I guess I should've done this instead, @StevenDufresne does my change look proper this time?

Suggested change
if ( str_contains( $s, '(' ) ) {
// Modify the search query to omit the parentheses.
$keyword = rtrim( $keyword, '()' );
if ( str_contains( $s, '(' ) ) {
// Modify the search query to omit the parentheses.
$keyword = str_replace( array( '()', '(' ), '', $keyword );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the code to use the str_replace again. It appears to work. 👍

@StevenDufresne StevenDufresne changed the title Experiment: Advanced search qualifiers WIP: Experiment: Advanced search qualifiers Jun 13, 2022
@StevenDufresne
Copy link
Contributor Author

I think this works well, the only problem I don't have a solution for is that the search query and the filter boxes can fall out of sync seeing that we don't automatically append the advanced search qualifiers when using the filter boxes.

For example:

  1. Start with a query type:hook get
  2. Search
  3. Click [] Methods

It will apply the filter but the search keyword will still be type:hook get but in reality it will be searching like:type:hook type:method get.

I don't think we want to add/remove to the searchbox everytime a checkbox is clicked though... 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants