Version Description
- Major fix: Post type weights did not work; improving the caching had broken them.
- Minor fix: Relevanssi works better with soft hyphens now, removing them in indexing and excerpt-building.
- Minor fix: Stops indexing error messages in WPML.
Download this release
Release Info
| Developer | msaari |
| Plugin | |
| Version | 4.12.3 |
| Comparing to | |
| See all releases | |
Code changes from version 4.12.2 to 4.12.3
- lib/common.php +13 -10
- lib/excerpts-highlights.php +1 -0
- lib/indexing.php +1 -1
- lib/search.php +6 -7
- readme.txt +10 -2
- relevanssi.php +2 -2
lib/common.php
CHANGED
|
@@ -219,15 +219,13 @@ function relevanssi_default_post_ok( $post_ok, $post_id ) {
|
|
| 219 |
* query, instead of doing up to 500 separate get_post() queries.
|
| 220 |
*
|
| 221 |
* @global array $relevanssi_post_array An array of fetched posts.
|
| 222 |
-
* @global array $relevanssi_post_types An array of post types, to be used by
|
| 223 |
-
* relevanssi_get_post_type() (again to avoid DB calls).
|
| 224 |
* @global object $wpdb The WordPress database interface.
|
| 225 |
*
|
| 226 |
* @param array $matches An array of search matches.
|
| 227 |
* @param int $blog_id The blog ID for multisite searches. Default -1.
|
| 228 |
*/
|
| 229 |
function relevanssi_populate_array( $matches, $blog_id = -1 ) {
|
| 230 |
-
global $relevanssi_post_array, $
|
| 231 |
|
| 232 |
if ( -1 === $blog_id ) {
|
| 233 |
$blog_id = get_current_blog_id();
|
|
@@ -238,20 +236,24 @@ function relevanssi_populate_array( $matches, $blog_id = -1 ) {
|
|
| 238 |
|
| 239 |
$ids = array();
|
| 240 |
foreach ( $matches as $match ) {
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
| 242 |
}
|
| 243 |
|
| 244 |
$ids = array_keys( array_flip( $ids ) ); // Remove duplicate IDs.
|
| 245 |
do {
|
| 246 |
$hundred_ids = array_splice( $ids, 0, 100 );
|
| 247 |
$id_list = implode( ', ', $hundred_ids );
|
| 248 |
-
|
|
|
|
| 249 |
|
| 250 |
-
|
| 251 |
-
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
| 255 |
}
|
| 256 |
} while ( $ids );
|
| 257 |
|
|
@@ -356,6 +358,7 @@ function relevanssi_remove_punct( $a ) {
|
|
| 356 |
'©' => '',
|
| 357 |
'™' => '',
|
| 358 |
'­' => '',
|
|
|
|
| 359 |
' ' => ' ',
|
| 360 |
chr( 194 ) . chr( 160 ) => ' ',
|
| 361 |
'×' => ' ',
|
|
@@ -702,7 +705,7 @@ function relevanssi_get_post_status( $post_id ) {
|
|
| 702 |
} elseif ( $post ) {
|
| 703 |
if ( 'inherit' === $post->post_status ) {
|
| 704 |
// Attachment, let's see what the parent says.
|
| 705 |
-
$parent = $relevanssi_post_array[ $post_id ]->post_parent;
|
| 706 |
if ( ! $parent ) {
|
| 707 |
// Attachment without a parent, let's assume it's public.
|
| 708 |
$status = 'publish';
|
| 219 |
* query, instead of doing up to 500 separate get_post() queries.
|
| 220 |
*
|
| 221 |
* @global array $relevanssi_post_array An array of fetched posts.
|
|
|
|
|
|
|
| 222 |
* @global object $wpdb The WordPress database interface.
|
| 223 |
*
|
| 224 |
* @param array $matches An array of search matches.
|
| 225 |
* @param int $blog_id The blog ID for multisite searches. Default -1.
|
| 226 |
*/
|
| 227 |
function relevanssi_populate_array( $matches, $blog_id = -1 ) {
|
| 228 |
+
global $relevanssi_post_array, $wpdb;
|
| 229 |
|
| 230 |
if ( -1 === $blog_id ) {
|
| 231 |
$blog_id = get_current_blog_id();
|
| 236 |
|
| 237 |
$ids = array();
|
| 238 |
foreach ( $matches as $match ) {
|
| 239 |
+
$cache_id = $blog_id . '|' . $match->doc;
|
| 240 |
+
if ( $match->doc > 0 && ! isset( $relevanssi_post_array[ $cache_id ] ) ) {
|
| 241 |
+
array_push( $ids, $match->doc );
|
| 242 |
+
}
|
| 243 |
}
|
| 244 |
|
| 245 |
$ids = array_keys( array_flip( $ids ) ); // Remove duplicate IDs.
|
| 246 |
do {
|
| 247 |
$hundred_ids = array_splice( $ids, 0, 100 );
|
| 248 |
$id_list = implode( ', ', $hundred_ids );
|
| 249 |
+
if ( ! empty( $id_list ) ) {
|
| 250 |
+
$posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE id IN ( $id_list )", OBJECT ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
| 251 |
|
| 252 |
+
foreach ( $posts as $post ) {
|
| 253 |
+
$cache_id = $blog_id . '|' . $post->ID;
|
| 254 |
|
| 255 |
+
$relevanssi_post_array[ $cache_id ] = $post;
|
| 256 |
+
}
|
| 257 |
}
|
| 258 |
} while ( $ids );
|
| 259 |
|
| 358 |
'©' => '',
|
| 359 |
'™' => '',
|
| 360 |
'­' => '',
|
| 361 |
+
"\xC2\xAD" => '',
|
| 362 |
' ' => ' ',
|
| 363 |
chr( 194 ) . chr( 160 ) => ' ',
|
| 364 |
'×' => ' ',
|
| 705 |
} elseif ( $post ) {
|
| 706 |
if ( 'inherit' === $post->post_status ) {
|
| 707 |
// Attachment, let's see what the parent says.
|
| 708 |
+
$parent = $relevanssi_post_array[ $post_id ]->post_parent ?? null;
|
| 709 |
if ( ! $parent ) {
|
| 710 |
// Attachment without a parent, let's assume it's public.
|
| 711 |
$status = 'publish';
|
lib/excerpts-highlights.php
CHANGED
|
@@ -600,6 +600,7 @@ function relevanssi_highlight_terms( $content, $query, $convert_entities = false
|
|
| 600 |
|
| 601 |
usort( $terms, 'relevanssi_strlen_sort' );
|
| 602 |
|
|
|
|
| 603 |
$content = html_entity_decode( $content, ENT_QUOTES, 'UTF-8' );
|
| 604 |
$content = str_replace( "\n", ' ', $content );
|
| 605 |
|
| 600 |
|
| 601 |
usort( $terms, 'relevanssi_strlen_sort' );
|
| 602 |
|
| 603 |
+
$content = strtr( $content, array( "\xC2\xAD" => '' ) );
|
| 604 |
$content = html_entity_decode( $content, ENT_QUOTES, 'UTF-8' );
|
| 605 |
$content = str_replace( "\n", ' ', $content );
|
| 606 |
|
lib/indexing.php
CHANGED
|
@@ -615,7 +615,7 @@ function relevanssi_index_taxonomy_terms( &$insert_data, $post_id, $taxonomy, $d
|
|
| 615 |
$min_word_length = get_option( 'relevanssi_min_word_length', 3 );
|
| 616 |
$post_taxonomy_terms = get_the_terms( $post_id, $taxonomy );
|
| 617 |
|
| 618 |
-
if ( false === $post_taxonomy_terms ) {
|
| 619 |
return $n;
|
| 620 |
}
|
| 621 |
|
| 615 |
$min_word_length = get_option( 'relevanssi_min_word_length', 3 );
|
| 616 |
$post_taxonomy_terms = get_the_terms( $post_id, $taxonomy );
|
| 617 |
|
| 618 |
+
if ( false === $post_taxonomy_terms || is_wp_error( $post_taxonomy_terms ) ) {
|
| 619 |
return $n;
|
| 620 |
}
|
| 621 |
|
lib/search.php
CHANGED
|
@@ -108,7 +108,6 @@ function relevanssi_query( $posts, $query = false ) {
|
|
| 108 |
* @global object $wpdb The WordPress database interface.
|
| 109 |
* @global array $relevanssi_variables The global Relevanssi variables array.
|
| 110 |
* @global WP_Query $wp_query The WP_Query object.
|
| 111 |
-
* @global array $relevanssi_post_types Cache array for post type values.
|
| 112 |
*
|
| 113 |
* @param array $args Array of arguments.
|
| 114 |
*
|
|
@@ -412,7 +411,6 @@ function relevanssi_search( $args ) {
|
|
| 412 |
}
|
| 413 |
|
| 414 |
relevanssi_populate_array( $matches );
|
| 415 |
-
global $relevanssi_post_types;
|
| 416 |
|
| 417 |
$total_hits += count( $matches );
|
| 418 |
|
|
@@ -558,10 +556,7 @@ function relevanssi_search( $args ) {
|
|
| 558 |
$mysqlcolumn_matches[ $match->doc ] += $match->mysqlcolumn;
|
| 559 |
|
| 560 |
/* Post type weights. */
|
| 561 |
-
$type =
|
| 562 |
-
if ( isset( $relevanssi_post_types[ $match->doc ] ) ) {
|
| 563 |
-
$type = $relevanssi_post_types[ $match->doc ];
|
| 564 |
-
}
|
| 565 |
if ( ! empty( $post_type_weights[ $type ] ) ) {
|
| 566 |
$match->weight = $match->weight * $post_type_weights[ $type ];
|
| 567 |
}
|
|
@@ -978,9 +973,13 @@ function relevanssi_do_query( &$query ) {
|
|
| 978 |
$highlight = get_option( 'relevanssi_highlight' );
|
| 979 |
if ( 'none' !== $highlight ) {
|
| 980 |
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 981 |
$post->post_highlighted_title = relevanssi_highlight_terms(
|
| 982 |
$post->post_highlighted_title,
|
| 983 |
-
$
|
| 984 |
);
|
| 985 |
}
|
| 986 |
}
|
| 108 |
* @global object $wpdb The WordPress database interface.
|
| 109 |
* @global array $relevanssi_variables The global Relevanssi variables array.
|
| 110 |
* @global WP_Query $wp_query The WP_Query object.
|
|
|
|
| 111 |
*
|
| 112 |
* @param array $args Array of arguments.
|
| 113 |
*
|
| 411 |
}
|
| 412 |
|
| 413 |
relevanssi_populate_array( $matches );
|
|
|
|
| 414 |
|
| 415 |
$total_hits += count( $matches );
|
| 416 |
|
| 556 |
$mysqlcolumn_matches[ $match->doc ] += $match->mysqlcolumn;
|
| 557 |
|
| 558 |
/* Post type weights. */
|
| 559 |
+
$type = relevanssi_get_post_type( $match->doc );
|
|
|
|
|
|
|
|
|
|
| 560 |
if ( ! empty( $post_type_weights[ $type ] ) ) {
|
| 561 |
$match->weight = $match->weight * $post_type_weights[ $type ];
|
| 562 |
}
|
| 973 |
$highlight = get_option( 'relevanssi_highlight' );
|
| 974 |
if ( 'none' !== $highlight ) {
|
| 975 |
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
| 976 |
+
$q_for_highlight = 'on' === get_option( 'relevanssi_index_synonyms', 'off' )
|
| 977 |
+
? relevanssi_add_synonyms( $q )
|
| 978 |
+
: $q;
|
| 979 |
+
|
| 980 |
$post->post_highlighted_title = relevanssi_highlight_terms(
|
| 981 |
$post->post_highlighted_title,
|
| 982 |
+
$q_for_highlight
|
| 983 |
);
|
| 984 |
}
|
| 985 |
}
|
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 |
Requires PHP: 7.0
|
| 8 |
-
Stable tag: 4.12.
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
|
@@ -131,6 +131,11 @@ 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.12.2 =
|
| 135 |
* Major fix: Stops more problems with ACF custom field indexing.
|
| 136 |
* Major fix: Fixes a bug in search result caching that caused Relevanssi to make lots of unnecessary database queries.
|
|
@@ -215,6 +220,9 @@ Each document database is full of useless words. All the little words that appea
|
|
| 215 |
* Minor fix: The category inclusion and exclusion setting checkboxes on the Searching tab didn't work. The setting was saved, but the checkboxes wouldn't appear.
|
| 216 |
|
| 217 |
== Upgrade notice ==
|
|
|
|
|
|
|
|
|
|
| 218 |
= 4.12.2 =
|
| 219 |
* Stops Relevanssi from crashing when saving posts with ACF fields, major performance boost.
|
| 220 |
|
| 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
|
| 7 |
Requires PHP: 7.0
|
| 8 |
+
Stable tag: 4.12.3
|
| 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.12.3 =
|
| 135 |
+
* Major fix: Post type weights did not work; improving the caching had broken them.
|
| 136 |
+
* Minor fix: Relevanssi works better with soft hyphens now, removing them in indexing and excerpt-building.
|
| 137 |
+
* Minor fix: Stops indexing error messages in WPML.
|
| 138 |
+
|
| 139 |
= 4.12.2 =
|
| 140 |
* Major fix: Stops more problems with ACF custom field indexing.
|
| 141 |
* Major fix: Fixes a bug in search result caching that caused Relevanssi to make lots of unnecessary database queries.
|
| 220 |
* Minor fix: The category inclusion and exclusion setting checkboxes on the Searching tab didn't work. The setting was saved, but the checkboxes wouldn't appear.
|
| 221 |
|
| 222 |
== Upgrade notice ==
|
| 223 |
+
= 4.12.3 =
|
| 224 |
+
* Fixes post type weights and WPML indexing problems.
|
| 225 |
+
|
| 226 |
= 4.12.2 =
|
| 227 |
* Stops Relevanssi from crashing when saving posts with ACF fields, major performance boost.
|
| 228 |
|
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.12.
|
| 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.12.
|
| 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.12.3
|
| 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.12.3';
|
| 71 |
|
| 72 |
require_once 'lib/admin-ajax.php';
|
| 73 |
require_once 'lib/common.php';
|
