Relevanssi – A Better Search - Version 4.10.1

Version Description

  • Major fix: The multilingual stopwords and synonyms were used based on the global language. Now when indexing posts, the post language is used instead of the global language.
Download this release

Release Info

Developer msaari
Plugin Icon 128x128 Relevanssi – A Better Search
Version 4.10.1
Comparing to
See all releases

Code changes from version 4.10.0 to 4.10.1

Files changed (3) hide show
  1. lib/utils.php +31 -12
  2. readme.txt +7 -1
  3. relevanssi.php +2 -2
lib/utils.php CHANGED
@@ -140,13 +140,19 @@ function relevanssi_generate_closing_tags( $tags ) {
140
  /**
141
  * Returns the locale or language code.
142
  *
143
- * First checks `pll_current_language()`, then `wpml_current_language`, then
144
- * falls back to `get_locale()`.
 
 
 
 
 
 
145
  *
146
  * @param boolean $locale If true, return locale; if false, return language
147
  * code.
148
  *
149
- * @return string The locale for the current site language.
150
  */
151
  function relevanssi_get_current_language( $locale = true ) {
152
  $current_language = get_locale();
@@ -154,19 +160,32 @@ function relevanssi_get_current_language( $locale = true ) {
154
  $current_language = substr( $locale, 0, 2 );
155
  }
156
  if ( function_exists( 'pll_current_language' ) ) {
157
- $current_language = pll_current_language( $locale ? 'locale' : 'slug' );
 
 
 
 
 
 
158
  }
159
  if ( function_exists( 'icl_object_id' ) && ! function_exists( 'pll_is_translated_post_type' ) ) {
160
- if ( $locale ) {
161
- $languages = apply_filters( 'wpml_active_languages', null );
162
- foreach ( $languages as $l ) {
163
- if ( $l['active'] ) {
164
- $current_language = $l['default_locale'];
165
- break;
 
 
 
 
 
 
 
166
  }
 
 
167
  }
168
- } else {
169
- $current_language = apply_filters( 'wpml_current_language', null );
170
  }
171
  }
172
 
140
  /**
141
  * Returns the locale or language code.
142
  *
143
+ * If WPML or Polylang is not available, returns `get_locale()` value. With
144
+ * WPML or Polylang, first this function checks to see if the global $post is
145
+ * set. If it is, the function returns the language of the post, as we're
146
+ * working on a post and need to use the correct language.
147
+ *
148
+ * If the global $post is not set, this function returns for Polylang the
149
+ * results of `pll_current_language()`, for WPML it uses `wpml_current_language`
150
+ * and `wpml_active_languages`.
151
  *
152
  * @param boolean $locale If true, return locale; if false, return language
153
  * code.
154
  *
155
+ * @return string The locale or the language code.
156
  */
157
  function relevanssi_get_current_language( $locale = true ) {
158
  $current_language = get_locale();
160
  $current_language = substr( $locale, 0, 2 );
161
  }
162
  if ( function_exists( 'pll_current_language' ) ) {
163
+ global $post;
164
+
165
+ if ( isset( $post ) ) {
166
+ $current_language = pll_get_post_language( $post->ID, $locale ? 'locale' : 'slug' );
167
+ } else {
168
+ $current_language = pll_current_language( $locale ? 'locale' : 'slug' );
169
+ }
170
  }
171
  if ( function_exists( 'icl_object_id' ) && ! function_exists( 'pll_is_translated_post_type' ) ) {
172
+ global $post;
173
+
174
+ if ( isset( $post ) ) {
175
+ $language_details = apply_filters( 'wpml_post_language_details', null, $post->ID );
176
+ $current_language = $language_details[ $locale ? 'locale' : 'language_code' ];
177
+ } else {
178
+ if ( $locale ) {
179
+ $languages = apply_filters( 'wpml_active_languages', null );
180
+ foreach ( $languages as $l ) {
181
+ if ( $l['active'] ) {
182
+ $current_language = $l['default_locale'];
183
+ break;
184
+ }
185
  }
186
+ } else {
187
+ $current_language = apply_filters( 'wpml_current_language', null );
188
  }
 
 
189
  }
190
  }
191
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: search, relevance, better search, product search, woocommerce search
5
  Requires at least: 4.9
6
  Tested up to: 5.6.1
7
  Requires PHP: 7.0
8
- Stable tag: 4.10.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -133,6 +133,9 @@ Each document database is full of useless words. All the little words that appea
133
  * John Calahan for extensive 4.0 beta testing.
134
 
135
  == Changelog ==
 
 
 
136
  = 4.10.0 =
137
  * New feature: Relevanssi now supports multilingual synonyms and stopwords. Relevanssi now has a different set of synonyms and stopwords for each language. This feature is compatible with WPML and Polylang.
138
  * New feature: SEO by Rank Math compatibility is added: posts marked as 'noindex' with Rank Math are not indexed by Relevanssi.
@@ -199,6 +202,9 @@ Each document database is full of useless words. All the little words that appea
199
  * Minor fix: Relevanssi only updates doc count on `relevanssi_insert_edit()` when the post is indexed.
200
 
201
  == Upgrade notice ==
 
 
 
202
  = 4.10.0 =
203
  * Adds support for multilingual stopwords and synonyms.
204
 
5
  Requires at least: 4.9
6
  Tested up to: 5.6.1
7
  Requires PHP: 7.0
8
+ Stable tag: 4.10.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
133
  * John Calahan for extensive 4.0 beta testing.
134
 
135
  == Changelog ==
136
+ = 4.10.1 =
137
+ * Major fix: The multilingual stopwords and synonyms were used based on the global language. Now when indexing posts, the post language is used instead of the global language.
138
+
139
  = 4.10.0 =
140
  * New feature: Relevanssi now supports multilingual synonyms and stopwords. Relevanssi now has a different set of synonyms and stopwords for each language. This feature is compatible with WPML and Polylang.
141
  * New feature: SEO by Rank Math compatibility is added: posts marked as 'noindex' with Rank Math are not indexed by Relevanssi.
202
  * Minor fix: Relevanssi only updates doc count on `relevanssi_insert_edit()` when the post is indexed.
203
 
204
  == Upgrade notice ==
205
+ = 4.10.1 =
206
+ * Corrects the multilingual stopwords and synonyms.
207
+
208
  = 4.10.0 =
209
  * Adds support for multilingual stopwords and synonyms.
210
 
relevanssi.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: Relevanssi
14
  * Plugin URI: https://www.relevanssi.com/
15
  * Description: This plugin replaces WordPress search with a relevance-sorting search.
16
- * Version: 4.10.0
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
@@ -67,7 +67,7 @@ $relevanssi_variables['database_version'] = 6;
67
  $relevanssi_variables['file'] = __FILE__;
68
  $relevanssi_variables['plugin_dir'] = plugin_dir_path( __FILE__ );
69
  $relevanssi_variables['plugin_basename'] = plugin_basename( __FILE__ );
70
- $relevanssi_variables['plugin_version'] = '4.10.0';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';
13
  * Plugin Name: Relevanssi
14
  * Plugin URI: https://www.relevanssi.com/
15
  * Description: This plugin replaces WordPress search with a relevance-sorting search.
16
+ * Version: 4.10.1
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
67
  $relevanssi_variables['file'] = __FILE__;
68
  $relevanssi_variables['plugin_dir'] = plugin_dir_path( __FILE__ );
69
  $relevanssi_variables['plugin_basename'] = plugin_basename( __FILE__ );
70
+ $relevanssi_variables['plugin_version'] = '4.10.1';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';