[wp-trac] [WordPress Trac] #43867: Introduce the ability to control which fields are searched in a search query
WordPress Trac
noreply at wordpress.org
Fri Apr 27 15:56:51 UTC 2018
#43867: Introduce the ability to control which fields are searched in a search
query
------------------------------------------+------------------------------
Reporter: johnbillion | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+------------------------------
Comment (by birgire):
[attachment:43867.diff] is a first iteration with unit tests in
{{{tests/query/searchColumns.php}}}.
Some notes on this first iteration:
- It uses the default search columns: {{{post_title}}}, {{{post_excerpt}}}
and {{{post_content}}}.
- It uses the supported search columns: {{{post_title}}},
{{{post_excerpt}}} and {{{post_content}}}. We could consider expanding
this further.
- It uses the default search columns as a fallback for empty input:
{{{'search_columns' => array()}}}.
- It uses the default search columns as a fallback for an existing but not
supported search field, e.g. {{{'search_columns' => array( 'post_name'
)}}}.
- It ignores non-existing or non supported search column(s) together with
supported search column(s), e.g. {{{'search_columns' => array(
'post_title', 'post_name' )}}} is the same as {{{'search_columns' =>
array( 'post_title' )}}}.
- Introduces the {{{post_search_columns}}} filter. We restrict it to the
supported search columns, to avoid any kind of column names in the SQL
query.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43867#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list