Skip to content

WIP: Experiment: Advanced search qualifiers#87

Open
StevenDufresne wants to merge 14 commits intotrunkfrom
try/search-qualifiers
Open

WIP: Experiment: Advanced search qualifiers#87
StevenDufresne wants to merge 14 commits intotrunkfrom
try/search-qualifiers

Conversation

@StevenDufresne
Copy link
Copy Markdown
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
@StevenDufresne StevenDufresne requested review from dd32 and tellyworth June 8, 2022 05:22
Comment thread source/wp-content/themes/wporg-developer/inc/advanced-search-filters.php Outdated
Comment on lines +84 to +86
if ( str_contains( $s, '(' ) ) {
// Modify the search query to omit the parentheses.
$keyword = rtrim( $keyword, '()' );
Copy link
Copy Markdown
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
Copy Markdown
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 force-pushed the try/search-qualifiers branch from c671123 to 3d2c2f4 Compare June 13, 2022 01:16
@StevenDufresne StevenDufresne changed the title Experiment: Advanced search qualifiers WIP: Experiment: Advanced search qualifiers Jun 13, 2022
@StevenDufresne
Copy link
Copy Markdown
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.

2 participants