Opened 13 years ago
Closed 12 years ago
#25587 closed defect (bug) (maybelater)
wp_search_stopwords filter shouldn't be cached
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.7 |
| Component: | Query | Keywords: | has-patch |
| Focuses: | Cc: |
Description
Caching wp_search_stopwords hook, make it harder to remove the filter and add other filters after the function invoke.
Some reasons:
- When we make a dynamic stopwords list depending on the 'Input language' or the WP query object.
- I may add some stopwords using the ar.php file in wp-content/languages , becuase Arabic language has more than 1000 stopword. so I want to provide the ability to remove the filter easily!
Attachments (1)
Change History (8)
#4
in reply to:
↑ 3
@
13 years ago
Replying to azaozz:
Arabic language has more than 1000 stopword.
Keep in mind that WordPress should use the shortest list of stopwords possible. The default English stopwords are approximately what the search engines use, however there is a much longer list used in MySQL for full-text queries which is not suitable.
OK..
So is there any real reason about why wp_search_stopwords filter is cached?
#7
@
12 years ago
- Keywords needs-testing removed
- Milestone Awaiting Review deleted
- Resolution set to maybelater
- Status changed from new to closed
You can filter every object instance of WP_Query differently:
function a_whatever() {
remove_filter( 'wp_search_stopwords', __FUNCTION__ );
// do whatever you want
}
function b_whatever() {
remove_filter( 'wp_search_stopwords', __FUNCTION__ );
// do whatever you want differently
}
add_filter( 'wp_search_stopwords', 'a_whatever' );
$q = new WP_Query( array( 's' => 'woo' ) );
add_filter( 'wp_search_stopwords', 'b_whatever' );
$q = new WP_Query( array( 's' => 'hoo' ) );
I don't see a great use case for filtering the same object multiple times. If there is one, please enlighten us and reopen.
Keep in mind that WordPress should use the shortest list of stopwords possible. The default English stopwords are approximately what the search engines use, however there is a much longer list used in MySQL for full-text queries which is not suitable.