Skip to content

Commit

Permalink
Add SearchWP 4.0 support for stopwords
Browse files Browse the repository at this point in the history
  • Loading branch information
olethomas committed Sep 2, 2020
1 parent 051ac58 commit a40e3ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion theme-supports/searchwp/norwegian-stopwords.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
*/
function add_norwegian_stopwords( array $terms ) : array {
if ( file_exists( __DIR__ . '/stopwords-nb_NO.txt' ) ) {
$terms = explode( PHP_EOL, file_get_contents( __DIR__ . '/stopwords-nb_NO.txt' ) );
$terms = explode( PHP_EOL, trim( file_get_contents( __DIR__ . '/stopwords-nb_NO.txt' ) ) );
}

return $terms;
}
// SearchWP < 4
add_filter( 'searchwp_stopwords', __NAMESPACE__ . '\\add_norwegian_stopwords' );
// SearchWP > 4
add_filter( 'searchwp\stopwords', __NAMESPACE__ . '\\add_norwegian_stopwords' );

0 comments on commit a40e3ba

Please sign in to comment.