Relevanssi – A Better Search - Version 4.13.2

Version Description

  • New feature: Adds support for Avada Live Search.
  • New feature: Adds support for Fibo Search.
  • Minor fix: Elementor library searches are not broken anymore when Relevanssi is enabled in admin.
  • Minor fix: Relevanssi now understands array-style post_type[] parameters.
  • Minor fix: Relevanssi now automatically considers the Turkish '' the same as 'i'.
Download this release

Release Info

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

Code changes from version 4.13.1 to 4.13.2

lib/common.php CHANGED
@@ -366,6 +366,7 @@ function relevanssi_remove_punct( $a ) {
366
 
367
  $replacement_array = array(
368
  'ß' => 'ss',
 
369
  '₂' => '2',
370
  '·' => '',
371
  '…' => '',
@@ -966,20 +967,7 @@ function relevanssi_add_highlight( $permalink, $link_post = null ) {
966
  $highlight_docs = get_option( 'relevanssi_highlight_docs', 'off' );
967
  $query = get_search_query();
968
  if ( isset( $highlight_docs ) && 'off' !== $highlight_docs && ! empty( $query ) ) {
969
- $frontpage_id = intval( get_option( 'page_on_front' ) );
970
- // We won't add the highlight parameter for the front page, as that will break the link.
971
- $front_page = false;
972
- if ( is_object( $link_post ) ) {
973
- if ( $link_post->ID === $frontpage_id ) {
974
- $front_page = true;
975
- }
976
- } else {
977
- global $post;
978
- if ( is_object( $post ) && $post->ID === $frontpage_id ) {
979
- $front_page = true;
980
- }
981
- }
982
- if ( ! $front_page ) {
983
  $query = str_replace( '"', '"', $query );
984
  $permalink = esc_attr( add_query_arg( array( 'highlight' => rawurlencode( $query ) ), $permalink ) );
985
  }
@@ -987,6 +975,31 @@ function relevanssi_add_highlight( $permalink, $link_post = null ) {
987
  return $permalink;
988
  }
989
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
990
  /**
991
  * Adjusts the permalink to use the Relevanssi-generated link.
992
  *
@@ -1016,9 +1029,10 @@ function relevanssi_permalink( $link, $link_post = null ) {
1016
  $link = $link_post->relevanssi_link;
1017
  }
1018
 
1019
- if ( is_search() && property_exists( $link_post, 'relevance_score' ) ) {
1020
  $link = relevanssi_add_highlight( $link, $link_post );
1021
  }
 
1022
  return $link;
1023
  }
1024
 
@@ -1705,3 +1719,28 @@ function relevanssi_replace_stems_in_terms( array $terms, array $all_terms = nul
1705
  )
1706
  );
1707
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
 
367
  $replacement_array = array(
368
  'ß' => 'ss',
369
+ 'ı' => 'i',
370
  '₂' => '2',
371
  '·' => '',
372
  '…' => '',
967
  $highlight_docs = get_option( 'relevanssi_highlight_docs', 'off' );
968
  $query = get_search_query();
969
  if ( isset( $highlight_docs ) && 'off' !== $highlight_docs && ! empty( $query ) ) {
970
+ if ( ! relevanssi_is_front_page_id( isset( $link_post->ID ) ?? null ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
971
  $query = str_replace( '"', '"', $query );
972
  $permalink = esc_attr( add_query_arg( array( 'highlight' => rawurlencode( $query ) ), $permalink ) );
973
  }
975
  return $permalink;
976
  }
977
 
978
+ /**
979
+ * Checks if a post ID is the front page ID.
980
+ *
981
+ * Gets the front page ID from the `page_on_front` option and checks the given
982
+ * ID against that.
983
+ *
984
+ * @param integer $post_id The post ID to check. If null, checks the global
985
+ * $post ID. Default null.
986
+ * @return boolean True if the post ID or global $post matches the front page.
987
+ */
988
+ function relevanssi_is_front_page_id( int $post_id = null ) : bool {
989
+ $frontpage_id = intval( get_option( 'page_on_front' ) );
990
+ if ( $post_id === $frontpage_id ) {
991
+ return true;
992
+ } elseif ( isset( $post_id ) ) {
993
+ return false;
994
+ }
995
+
996
+ global $post;
997
+ if ( is_object( $post ) && $post->ID === $frontpage_id ) {
998
+ return true;
999
+ }
1000
+ return false;
1001
+ }
1002
+
1003
  /**
1004
  * Adjusts the permalink to use the Relevanssi-generated link.
1005
  *
1029
  $link = $link_post->relevanssi_link;
1030
  }
1031
 
1032
+ if ( is_search() && is_object( $link_post ) && property_exists( $link_post, 'relevance_score' ) ) {
1033
  $link = relevanssi_add_highlight( $link, $link_post );
1034
  }
1035
+
1036
  return $link;
1037
  }
1038
 
1719
  )
1720
  );
1721
  }
1722
+
1723
+ /**
1724
+ * Returns an array of bot user agents for Relevanssi to block.
1725
+ *
1726
+ * The bot user agent is the value and a human-readable name (not used for
1727
+ * anything) is in the index. This same list is used for different contexts,
1728
+ * and there are separate filters for modifying the list in various contexts.
1729
+ *
1730
+ * @return array An array of name => user-agent pairs.
1731
+ */
1732
+ function relevanssi_bot_block_list() : array {
1733
+ $bots = array(
1734
+ 'Google Mediapartners' => 'Mediapartners-Google',
1735
+ 'GoogleBot' => 'Googlebot',
1736
+ 'Bing' => 'Bingbot',
1737
+ 'Yahoo' => 'Slurp',
1738
+ 'DuckDuckGo' => 'DuckDuckBot',
1739
+ 'Baidu' => 'Baiduspider',
1740
+ 'Yandex' => 'YandexBot',
1741
+ 'Sogou' => 'Sogou',
1742
+ 'Exalead' => 'Exabot',
1743
+ 'Majestic' => 'MJ12Bot',
1744
+ );
1745
+ return $bots;
1746
+ }
lib/compatibility/avada.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * /lib/compatibility/avada.php
4
+ *
5
+ * Avada theme compatibility features.
6
+ *
7
+ * @package Relevanssi
8
+ * @author Mikko Saari
9
+ * @license https://wordpress.org/about/gpl/ GNU General Public License
10
+ * @see https://www.relevanssi.com/
11
+ */
12
+
13
+ add_filter(
14
+ 'fusion_live_search_query_args',
15
+ function( $args ) {
16
+ $args['relevanssi'] = true;
17
+ return $args;
18
+ }
19
+ );
lib/compatibility/elementor.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * /lib/compatibility/elementor.php
4
+ *
5
+ * Elementor page builder compatibility features.
6
+ *
7
+ * @package Relevanssi
8
+ * @author Mikko Saari
9
+ * @license https://wordpress.org/about/gpl/ GNU General Public License
10
+ * @see https://www.relevanssi.com/
11
+ */
12
+
13
+ add_filter( 'relevanssi_search_ok', 'relevanssi_block_elementor_library', 10, 2 );
14
+
15
+ /**
16
+ * Blocks Relevanssi from interfering with the Elementor Library searches.
17
+ *
18
+ * @param bool $ok Should Relevanssi be allowed to process the query.
19
+ * @param WP_Query $query The WP_Query object.
20
+ *
21
+ * @return bool Returns false, if this is an Elementor library search.
22
+ */
23
+ function relevanssi_block_elementor_library( bool $ok, WP_Query $query ) : bool {
24
+ if ( 'elementor_library' === $query->query_vars['post_type'] ) {
25
+ $ok = false;
26
+ }
27
+ return $ok;
28
+ }
lib/compatibility/fibosearch.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * /lib/compatibility/fibosearch.php
4
+ *
5
+ * Fibo Search compatibility features.
6
+ *
7
+ * @package Relevanssi
8
+ * @author Mikko Saari
9
+ * @license https://wordpress.org/about/gpl/ GNU General Public License
10
+ * @see https://www.relevanssi.com/
11
+ */
12
+
13
+ add_filter( 'dgwt/wcas/search_query/args', 'relevanssi_enable_relevanssi_in_fibo' );
14
+
15
+ /**
16
+ * Adds the 'relevanssi' parameter to the Fibo Search.
17
+ *
18
+ * Uses the dgwt/wcas/search_query_args filter hook to modify the search query.
19
+ *
20
+ * @params array $args The search arguments.
21
+ *
22
+ * @return array
23
+ */
24
+ function relevanssi_enable_relevanssi_in_fibo( $args ) {
25
+ $args['relevanssi'] = true;
26
+ return $args;
27
+ }
lib/indexing.php CHANGED
@@ -578,7 +578,7 @@ function relevanssi_index_doc( $index_post, $remove_first = false, $custom_field
578
 
579
  if ( ! empty( $values ) ) {
580
  $values = implode( ', ', $values );
581
- $query = "INSERT IGNORE INTO $relevanssi_table (doc, term, term_reverse, content, title, comment, tag, link, author, category, excerpt, taxonomy, customfield, type, taxonomy_detail, customfield_detail, mysqlcolumn) VALUES $values";
582
  if ( $debug ) {
583
  relevanssi_debug_echo( "Final indexing query:\n\t$query" );
584
  }
@@ -1047,7 +1047,7 @@ function relevanssi_remove_doc( $post_id, $keep_internal_links = false ) {
1047
  return;
1048
  }
1049
 
1050
- $rows_updated = $wpdb->query(
1051
  $wpdb->prepare(
1052
  'DELETE FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc=%d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
1053
  $post_id
@@ -1287,7 +1287,7 @@ function relevanssi_index_custom_fields( &$insert_data, $post_id, $custom_fields
1287
  $context = 'custom_field';
1288
  $remove_stops = true;
1289
  if ( '_relevanssi_pdf_content' === $field ) {
1290
- $context = 'body';
1291
  $remove_stops = 'body';
1292
  }
1293
 
@@ -1672,6 +1672,7 @@ function relevanssi_convert_data_to_values( $insert_data, $post ) {
1672
  $mysqlcolumn = isset( $data['mysqlcolumn'] ) ? $data['mysqlcolumn'] : 0;
1673
  $taxonomy_detail = isset( $data['taxonomy_detail'] ) ? $data['taxonomy_detail'] : '';
1674
  $customfield_detail = isset( $data['customfield_detail'] ) ? $data['customfield_detail'] : '';
 
1675
 
1676
  if ( 'utf8' === $charset ) {
1677
  $term = wp_encode_emoji( $term );
@@ -1680,7 +1681,7 @@ function relevanssi_convert_data_to_values( $insert_data, $post ) {
1680
  $term = trim( $term );
1681
 
1682
  $value = $wpdb->prepare(
1683
- '(%d, %s, REVERSE(%s), %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, %s, %s, %d)',
1684
  $post->ID,
1685
  $term,
1686
  $term,
@@ -1697,7 +1698,8 @@ function relevanssi_convert_data_to_values( $insert_data, $post ) {
1697
  $type,
1698
  $taxonomy_detail,
1699
  $customfield_detail,
1700
- $mysqlcolumn
 
1701
  );
1702
 
1703
  array_push( $values, $value );
578
 
579
  if ( ! empty( $values ) ) {
580
  $values = implode( ', ', $values );
581
+ $query = "INSERT IGNORE INTO $relevanssi_table (doc, term, term_reverse, content, title, comment, tag, link, author, category, excerpt, taxonomy, customfield, type, taxonomy_detail, customfield_detail, mysqlcolumn, mysqlcolumn_detail) VALUES $values";
582
  if ( $debug ) {
583
  relevanssi_debug_echo( "Final indexing query:\n\t$query" );
584
  }
1047
  return;
1048
  }
1049
 
1050
+ $wpdb->query(
1051
  $wpdb->prepare(
1052
  'DELETE FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc=%d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
1053
  $post_id
1287
  $context = 'custom_field';
1288
  $remove_stops = true;
1289
  if ( '_relevanssi_pdf_content' === $field ) {
1290
+ $context = 'content';
1291
  $remove_stops = 'body';
1292
  }
1293
 
1672
  $mysqlcolumn = isset( $data['mysqlcolumn'] ) ? $data['mysqlcolumn'] : 0;
1673
  $taxonomy_detail = isset( $data['taxonomy_detail'] ) ? $data['taxonomy_detail'] : '';
1674
  $customfield_detail = isset( $data['customfield_detail'] ) ? $data['customfield_detail'] : '';
1675
+ $mysqlcolumn_detail = isset( $data['mysqlcolumn_detail'] ) ? $data['mysqlcolumn_detail'] : '';
1676
 
1677
  if ( 'utf8' === $charset ) {
1678
  $term = wp_encode_emoji( $term );
1681
  $term = trim( $term );
1682
 
1683
  $value = $wpdb->prepare(
1684
+ '(%d, %s, REVERSE(%s), %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, %s, %s, %d, %s)',
1685
  $post->ID,
1686
  $term,
1687
  $term,
1698
  $type,
1699
  $taxonomy_detail,
1700
  $customfield_detail,
1701
+ $mysqlcolumn,
1702
+ $mysqlcolumn_detail
1703
  );
1704
 
1705
  array_push( $values, $value );
lib/init.php CHANGED
@@ -308,8 +308,8 @@ function relevanssi_create_database_tables( $relevanssi_db_version ) {
308
  customfield mediumint(9) NOT NULL DEFAULT '0',
309
  mysqlcolumn mediumint(9) NOT NULL DEFAULT '0',
310
  taxonomy_detail longtext NOT NULL,
311
- customfield_detail longtext NOT NULL,
312
- mysqlcolumn_detail longtext NOT NULL,
313
  type varchar(210) NOT NULL DEFAULT 'post',
314
  item bigint(20) NOT NULL DEFAULT '0',
315
  PRIMARY KEY doctermitem (doc, term, item)) $charset_collate";
@@ -468,13 +468,16 @@ function relevanssi_export_log_check() {
468
  */
469
  function relevanssi_load_compatibility_code() {
470
  class_exists( 'acf', false ) && require_once 'compatibility/acf.php';
 
471
  class_exists( 'MeprUpdateCtrl', false ) && MeprUpdateCtrl::is_activated() && require_once 'compatibility/memberpress.php';
472
  class_exists( 'Obenland_Wp_Search_Suggest', false ) && require_once 'compatibility/wp-search-suggest.php';
473
  class_exists( 'Polylang', false ) && require_once 'compatibility/polylang.php';
474
  class_exists( 'RankMath', false ) && require_once 'compatibility/rankmath.php';
475
  class_exists( 'WooCommerce', false ) && require_once 'compatibility/woocommerce.php';
476
  defined( 'AIOSEO_DIR' ) && require_once 'compatibility/aioseo.php';
 
477
  defined( 'CT_VERSION' ) && require_once 'compatibility/oxygen.php';
 
478
  defined( 'GROUPS_CORE_VERSION' ) && require_once 'compatibility/groups.php';
479
  defined( 'NINJA_TABLES_VERSION' ) && require_once 'compatibility/ninjatables.php';
480
  defined( 'PRLI_PLUGIN_NAME' ) && require_once 'compatibility/pretty-links.php';
308
  customfield mediumint(9) NOT NULL DEFAULT '0',
309
  mysqlcolumn mediumint(9) NOT NULL DEFAULT '0',
310
  taxonomy_detail longtext NOT NULL,
311
+ customfield_detail longtext NOT NULL DEFAULT '',
312
+ mysqlcolumn_detail longtext NOT NULL DEFAULT '',
313
  type varchar(210) NOT NULL DEFAULT 'post',
314
  item bigint(20) NOT NULL DEFAULT '0',
315
  PRIMARY KEY doctermitem (doc, term, item)) $charset_collate";
468
  */
469
  function relevanssi_load_compatibility_code() {
470
  class_exists( 'acf', false ) && require_once 'compatibility/acf.php';
471
+ class_exists( 'DGWT_WC_Ajax_Search', false ) && require_once 'compatibility/fibosearch.php';
472
  class_exists( 'MeprUpdateCtrl', false ) && MeprUpdateCtrl::is_activated() && require_once 'compatibility/memberpress.php';
473
  class_exists( 'Obenland_Wp_Search_Suggest', false ) && require_once 'compatibility/wp-search-suggest.php';
474
  class_exists( 'Polylang', false ) && require_once 'compatibility/polylang.php';
475
  class_exists( 'RankMath', false ) && require_once 'compatibility/rankmath.php';
476
  class_exists( 'WooCommerce', false ) && require_once 'compatibility/woocommerce.php';
477
  defined( 'AIOSEO_DIR' ) && require_once 'compatibility/aioseo.php';
478
+ defined( 'AVADA_VERSION' ) && require_once 'compatibility/avada.php';
479
  defined( 'CT_VERSION' ) && require_once 'compatibility/oxygen.php';
480
+ defined( 'ELEMENTOR_VERSION' ) && require_once 'compatibility/elementor.php';
481
  defined( 'GROUPS_CORE_VERSION' ) && require_once 'compatibility/groups.php';
482
  defined( 'NINJA_TABLES_VERSION' ) && require_once 'compatibility/ninjatables.php';
483
  defined( 'PRLI_PLUGIN_NAME' ) && require_once 'compatibility/pretty-links.php';
lib/log.php CHANGED
@@ -31,17 +31,6 @@ function relevanssi_update_log( $query, $hits ) {
31
  $user_agent = '';
32
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
33
  $user_agent = $_SERVER['HTTP_USER_AGENT'];
34
- $bots = array(
35
- 'Google 1' => 'Mediapartners-Google',
36
- 'Google 2' => 'Googlebot',
37
- 'Bing' => 'Bingbot',
38
- 'Yahoo' => 'Slurp',
39
- 'DuckDuckGo' => 'DuckDuckBot',
40
- 'Baidu' => 'Baiduspider',
41
- 'Yandex' => 'YandexBot',
42
- 'Sogou' => 'Sogou',
43
- 'Exalead' => 'Exabot',
44
- );
45
 
46
  /**
47
  * Filters the bots Relevanssi should block from logs.
@@ -50,7 +39,7 @@ function relevanssi_update_log( $query, $hits ) {
50
  *
51
  * @param array $bots An array of bot user agents.
52
  */
53
- $bots = apply_filters( 'relevanssi_bots_to_not_log', $bots );
54
  foreach ( array_values( $bots ) as $lookfor ) {
55
  if ( false !== stristr( $user_agent, $lookfor ) ) {
56
  return false;
@@ -64,7 +53,7 @@ function relevanssi_update_log( $query, $hits ) {
64
  * The current user is checked before logging a query to omit particular users.
65
  * You can use this filter to filter out the user.
66
  *
67
- * @param object The current user object.
68
  */
69
  $user = apply_filters( 'relevanssi_log_get_user', wp_get_current_user() );
70
  if ( 0 !== $user->ID && get_option( 'relevanssi_omit_from_logs' ) ) {
31
  $user_agent = '';
32
  if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
33
  $user_agent = $_SERVER['HTTP_USER_AGENT'];
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  /**
36
  * Filters the bots Relevanssi should block from logs.
39
  *
40
  * @param array $bots An array of bot user agents.
41
  */
42
+ $bots = apply_filters( 'relevanssi_bots_to_not_log', relevanssi_bot_block_list() );
43
  foreach ( array_values( $bots ) as $lookfor ) {
44
  if ( false !== stristr( $user_agent, $lookfor ) ) {
45
  return false;
53
  * The current user is checked before logging a query to omit particular users.
54
  * You can use this filter to filter out the user.
55
  *
56
+ * @param WP_User The current user object.
57
  */
58
  $user = apply_filters( 'relevanssi_log_get_user', wp_get_current_user() );
59
  if ( 0 !== $user->ID && get_option( 'relevanssi_omit_from_logs' ) ) {
lib/search.php CHANGED
@@ -170,6 +170,9 @@ function relevanssi_search( $args ) {
170
  * @param string The MySQL code that restricts the query.
171
  */
172
  $query_restrictions = apply_filters( 'relevanssi_where', $query_restrictions );
 
 
 
173
 
174
  /**
175
  * Filters the meta query JOIN for the Relevanssi search query.
@@ -1416,10 +1419,10 @@ function relevanssi_update_term_hits( &$term_hits, &$match_arrays, $match, $term
1416
  * Increases a value. If it's not set, sets it first to the default value.
1417
  *
1418
  * @param int $value The value to increase (passed by reference).
1419
- * @param int $increase The amount to increase the value.
1420
  * @param int $default The default value, default 0.
1421
  */
1422
- function relevanssi_increase_value( &$value, $increase, $default = 0 ) {
1423
  if ( ! isset( $value ) ) {
1424
  $value = $default;
1425
  }
@@ -1597,13 +1600,13 @@ function relevanssi_adjust_match_doc( $match ) {
1597
  * @param string $term The search term.
1598
  * @param bool $search_again If true, this is a repeat search (partial matching).
1599
  * @param bool $no_terms If true, no search term is used.
1600
- * @param string $query_join The MySQL JOIN clause.
1601
- * @param string $query_restrictions The MySQL query restrictions.
1602
  *
1603
  * @return string The MySQL search query.
1604
  */
1605
  function relevanssi_generate_search_query( string $term, bool $search_again,
1606
- bool $no_terms, string $query_join, string $query_restrictions ) : string {
1607
  global $relevanssi_variables;
1608
  $relevanssi_table = $relevanssi_variables['relevanssi_table'];
1609
 
@@ -1673,6 +1676,9 @@ function relevanssi_compile_common_args( $query ) {
1673
  $date_query = relevanssi_wp_date_query_from_query_vars( $query );
1674
 
1675
  $post_type = false;
 
 
 
1676
  if ( isset( $query->query_vars['post_type'] ) && 'any' !== $query->query_vars['post_type'] ) {
1677
  $post_type = $query->query_vars['post_type'];
1678
  }
@@ -1700,7 +1706,19 @@ function relevanssi_compile_common_args( $query ) {
1700
  );
1701
  }
1702
 
1703
- function relevanssi_add_include_matches( &$matches, $include, $params ) {
 
 
 
 
 
 
 
 
 
 
 
 
1704
  if ( count( $include['posts'] ) < 1 && count( $include['items'] ) < 1 ) {
1705
  return;
1706
  }
170
  * @param string The MySQL code that restricts the query.
171
  */
172
  $query_restrictions = apply_filters( 'relevanssi_where', $query_restrictions );
173
+ if ( ! $query_restrictions ) {
174
+ $query_restrictions = '';
175
+ }
176
 
177
  /**
178
  * Filters the meta query JOIN for the Relevanssi search query.
1419
  * Increases a value. If it's not set, sets it first to the default value.
1420
  *
1421
  * @param int $value The value to increase (passed by reference).
1422
+ * @param int $increase The amount to increase the value, default 1.
1423
  * @param int $default The default value, default 0.
1424
  */
1425
+ function relevanssi_increase_value( &$value, $increase = 1, $default = 0 ) {
1426
  if ( ! isset( $value ) ) {
1427
  $value = $default;
1428
  }
1600
  * @param string $term The search term.
1601
  * @param bool $search_again If true, this is a repeat search (partial matching).
1602
  * @param bool $no_terms If true, no search term is used.
1603
+ * @param string $query_join The MySQL JOIN clause, default empty string.
1604
+ * @param string $query_restrictions The MySQL query restrictions, default empty string.
1605
  *
1606
  * @return string The MySQL search query.
1607
  */
1608
  function relevanssi_generate_search_query( string $term, bool $search_again,
1609
+ bool $no_terms, string $query_join = '', string $query_restrictions = '' ) : string {
1610
  global $relevanssi_variables;
1611
  $relevanssi_table = $relevanssi_variables['relevanssi_table'];
1612
 
1676
  $date_query = relevanssi_wp_date_query_from_query_vars( $query );
1677
 
1678
  $post_type = false;
1679
+ if ( isset( $query->query_vars['post_type'] ) && is_array( $query->query_vars['post_type'] ) ) {
1680
+ $query->query_vars['post_type'] = implode( ',', $query->query_vars['post_type'] );
1681
+ }
1682
  if ( isset( $query->query_vars['post_type'] ) && 'any' !== $query->query_vars['post_type'] ) {
1683
  $post_type = $query->query_vars['post_type'];
1684
  }
1706
  );
1707
  }
1708
 
1709
+ /**
1710
+ * Adds posts to the matches list from the other term queries.
1711
+ *
1712
+ * Without this functionality, AND searches would not return all posts. If a
1713
+ * post appears within the best results for one word, but not for another word
1714
+ * even though the word appears in the post (because of throttling), the post
1715
+ * would be excluded. This functionality makes sure it is included.
1716
+ *
1717
+ * @param array $matches The found posts array.
1718
+ * @param array $include The posts to include.
1719
+ * @param array $params Search parameters.
1720
+ */
1721
+ function relevanssi_add_include_matches( array &$matches, array $include, array $params ) {
1722
  if ( count( $include['posts'] ) < 1 && count( $include['items'] ) < 1 ) {
1723
  return;
1724
  }
lib/utils.php CHANGED
@@ -347,6 +347,7 @@ function relevanssi_get_permalink() {
347
  * @param string The permalink, generated by get_permalink().
348
  */
349
  $permalink = apply_filters( 'relevanssi_permalink', get_permalink() );
 
350
  return $permalink;
351
  }
352
 
347
  * @param string The permalink, generated by get_permalink().
348
  */
349
  $permalink = apply_filters( 'relevanssi_permalink', get_permalink() );
350
+
351
  return $permalink;
352
  }
353
 
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: msaari
3
  Donate link: https://www.relevanssi.com/buy-premium/
4
  Tags: search, relevance, better search, product search, woocommerce search
5
  Requires at least: 4.9
6
- Tested up to: 5.7.1
7
  Requires PHP: 7.0
8
- Stable tag: 4.13.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -131,6 +131,13 @@ Each document database is full of useless words. All the little words that appea
131
  * John Calahan for extensive 4.0 beta testing.
132
 
133
  == Changelog ==
 
 
 
 
 
 
 
134
  = 4.13.1 =
135
  * New feature: Adds compatibility for WP-Members plugin, preventing blocked posts from showing up in the search results.
136
  * New feature: New function `relevanssi_get_attachment_suffix()` can be used to return the attachment file suffix based on a post object or a post ID.
@@ -226,6 +233,9 @@ Each document database is full of useless words. All the little words that appea
226
  * Minor fix: Improved Oxygen Builder support makes sure `ct_builder_shortcodes` custom field is always indexed.
227
 
228
  == Upgrade notice ==
 
 
 
229
  = 4.13.1 =
230
  * Compatibility for WP-Members added.
231
 
3
  Donate link: https://www.relevanssi.com/buy-premium/
4
  Tags: search, relevance, better search, product search, woocommerce search
5
  Requires at least: 4.9
6
+ Tested up to: 5.7.2
7
  Requires PHP: 7.0
8
+ Stable tag: 4.13.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
131
  * John Calahan for extensive 4.0 beta testing.
132
 
133
  == Changelog ==
134
+ = 4.13.2 =
135
+ * New feature: Adds support for Avada Live Search.
136
+ * New feature: Adds support for Fibo Search.
137
+ * Minor fix: Elementor library searches are not broken anymore when Relevanssi is enabled in admin.
138
+ * Minor fix: Relevanssi now understands array-style post_type[] parameters.
139
+ * Minor fix: Relevanssi now automatically considers the Turkish 'ı' the same as 'i'.
140
+
141
  = 4.13.1 =
142
  * New feature: Adds compatibility for WP-Members plugin, preventing blocked posts from showing up in the search results.
143
  * New feature: New function `relevanssi_get_attachment_suffix()` can be used to return the attachment file suffix based on a post object or a post ID.
233
  * Minor fix: Improved Oxygen Builder support makes sure `ct_builder_shortcodes` custom field is always indexed.
234
 
235
  == Upgrade notice ==
236
+ = 4.13.2 =
237
+ * Small bug and compatibility fixes.
238
+
239
  = 4.13.1 =
240
  * Compatibility for WP-Members added.
241
 
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.13.1
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.13.1';
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.13.2
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.13.2';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';