Relevanssi – A Better Search - Version 4.8.0

Version Description

  • Changed behaviour: Relevanssi now requires PHP 7.
  • Changed behaviour: Relevanssi now sorts strings with strnatcasecmp() instead of strcasecmp(), leading to a more natural results with strings that include numbers.
  • Changed behaviour: Relevanssi init is now moved from priority 10 to priority 1 on the init hook to avoid problems with missing TablePress compatibility.
  • New feature: New filter hook relevanssi_get_approved_comments_args filters the arguments to get_approved_comments in comment indexing. This can be used to index custom comment types, for example.
  • New feature: Content wrapped in the noindex tags is no longer used for excerpts.
  • New feature: The [et_pb_fullwidth_code] shortcode is now removed completely, including the contents, when Relevanssi is indexing and building excerpts.
  • Major fix: Relevanssi didn't index new comments when they were added; when a post was indexed or the whole index rebuilt, comment content was included. We don't know how long this bug has existed, but it is now fixed. Rebuild the index to get all comment content included in the index.
  • Minor fix: Autoload has been disabled for several options that are not needed often.
  • Minor fix: Phrase matching did not work correctly in visible custom fields.
  • Minor fix: TablePress support could cause halting errors if posts were inserted before Relevanssi has loaded itself (on init priority 10). These errors will no longer happen.
  • Minor fix: The doc count update, which is a heavy task, is now moved to an asynchronous action to avoid slowing down the site for users.
  • Minor fix: Relevanssi only updates doc count on relevanssi_insert_edit() when the post is indexed.
Download this release

Release Info

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

Code changes from version 4.7.2.1 to 4.8.0

changelog.txt CHANGED
@@ -1,3 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 4.3.4 =
2
  * New feature: You can now give Gutenberg blocks a CSS class `relevanssi_noindex` to exclude them from being indexed. Relevanssi will not index Gutenberg blocks that have the class.
3
  * New feature: Relevanssi automatically skips some custom fields from common plugins that only contain unnecessary metadata.
1
+ = 4.5.0 =
2
+ * New feature: New filter hook `relevanssi_disable_stopwords` can be used to disable stopwords completely. Just add a filter function that returns `true`.
3
+ * Changed behaviour: Stopwords are no longer automatically restored if emptied. It's now possible to empty the stopword list. If you want to restore the stopwords from the file (or from the database, if you're upgrading from an earlier version of Relevanssi and find your stopwords missing), just click the button on the stopwords settings page that restores the stopwords.
4
+ * Changed behaviour: Changes to post weights in the `relevanssi_results` hook did not affect the relevance scores shown in excerpts. That's changed now, and the displayed scores are now taken from the `$doc_weight` array, which is returned in the return value array from `relevanssi_search()`.
5
+ * Changed behaviour: Excerpt length and type are now checked outside the loop that goes through the posts. This reduces the number of database calls required.
6
+ * Minor fix: Searching for regex special characters (for example parentheses, brackets) caused problems in excerpts.
7
+ * Minor fix: Improvements in handling highlighting for words with apostrophes.
8
+ * Minor fix: Disregard hanging commas at the end of post exclusion settings.
9
+ * Minor fix: Sometimes excerpts wouldn't have an ellipsis in the beginning even though they should.
10
+
11
+ = 4.4.1 =
12
+ * Major fix: Returns the missing stopwords.
13
+
14
+ = 4.4.0 =
15
+ * New feature: It's now possible to exclude image attachments from the index with a simple setting on the indexing settings page.
16
+ * New feature: Page builder short codes are now removed in Relevanssi indexing. This should reduce the amount of garbage data indexed for posts in Divi, Avada and other page builder themes.
17
+ * Changed behaviour: The `relevanssi_page_builder_shortcodes` filter hook is now applied both in indexing and excerpts, and has a second parameter that will inform you of the current context.
18
+ * Minor fix: Stopwords weren't case insensitive like they should. They are now. Also, stopwords are no longer stored in the `wp_relevanssi_stopwords` database table, but are now stored in the `relevanssi_stopwords` option.
19
+ * Minor fix: A comma at the end of the custom field indexing setting made Relevanssi index all custom fields. This doesn't happen anymore and trailing commas are automatically removed, too.
20
+ * Minor fix: Accessibility improvements all around the admin interface. Screen reader support should be better, feel free to report any further ways to make this better.
21
+ * Minor fix: Doing searches without search terms and with the throttle disabled could cause problems. Relevanssi now makes sure throttle is always on when doing termless searches.
22
+ * Minor fix: Untokenized search terms are used for building excerpts, which makes highlighting in excerpts work better.
23
+ * Minor fix: Indexing did not adjust the number of posts indexed at one go like it should.
24
+
25
  = 4.3.4 =
26
  * New feature: You can now give Gutenberg blocks a CSS class `relevanssi_noindex` to exclude them from being indexed. Relevanssi will not index Gutenberg blocks that have the class.
27
  * New feature: Relevanssi automatically skips some custom fields from common plugins that only contain unnecessary metadata.
lib/admin-ajax.php CHANGED
@@ -14,6 +14,7 @@ add_action( 'wp_ajax_relevanssi_count_posts', 'relevanssi_count_posts_ajax_wrapp
14
  add_action( 'wp_ajax_relevanssi_count_missing_posts', 'relevanssi_count_missing_posts_ajax_wrapper' );
15
  add_action( 'wp_ajax_relevanssi_list_categories', 'relevanssi_list_categories' );
16
  add_action( 'wp_ajax_relevanssi_admin_search', 'relevanssi_admin_search' );
 
17
 
18
  /**
19
  * Truncates the Relevanssi index.
@@ -386,3 +387,31 @@ function relevanssi_admin_search_debugging_info( $query ) {
386
 
387
  return $result;
388
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  add_action( 'wp_ajax_relevanssi_count_missing_posts', 'relevanssi_count_missing_posts_ajax_wrapper' );
15
  add_action( 'wp_ajax_relevanssi_list_categories', 'relevanssi_list_categories' );
16
  add_action( 'wp_ajax_relevanssi_admin_search', 'relevanssi_admin_search' );
17
+ add_action( 'wp_ajax_relevanssi_update_counts', 'relevanssi_update_counts' );
18
 
19
  /**
20
  * Truncates the Relevanssi index.
387
 
388
  return $result;
389
  }
390
+
391
+ /**
392
+ * Updates count options.
393
+ *
394
+ * Updates 'relevanssi_doc_count', 'relevanssi_terms_count' (and in Premium
395
+ * 'relevanssi_user_count' and 'relevanssi_taxterm_count'). These are slightly
396
+ * expensive queries, so they are updated when necessary as a non-blocking AJAX
397
+ * action and stored in options for quick retrieval.
398
+ *
399
+ * @global object $wpdb The WordPress database interface.
400
+ * @global array $relevanssi_variables The Relevanssi global variable, used for table names.
401
+ */
402
+ function relevanssi_update_counts() {
403
+ global $wpdb, $relevanssi_variables;
404
+
405
+ relevanssi_update_doc_count();
406
+
407
+ $terms_count = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $relevanssi_variables['relevanssi_table'] ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
408
+ update_option( 'relevanssi_terms_count', is_null( $terms_count ) ? 0 : $terms_count, false );
409
+
410
+ if ( RELEVANSSI_PREMIUM ) {
411
+ $user_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE type = 'user'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
412
+ $taxterm_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE (type != 'post' AND type != 'attachment' AND type != 'user')" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
413
+
414
+ update_option( 'relevanssi_user_count', is_null( $user_count ) ? 0 : $user_count, false );
415
+ update_option( 'relevanssi_taxterm_count', is_null( $taxterm_count ) ? 0 : $taxterm_count, false );
416
+ }
417
+ }
lib/admin_scripts.js CHANGED
@@ -1,18 +1,18 @@
1
  /* Confirmation for copying options between blogs */
2
 
3
- jQuery(document).ready(function($) {
4
- $("#copy_config").submit(function() {
5
  var c = confirm(relevanssi.confirm)
6
  return c //you can just return c because it will be true or false
7
  })
8
 
9
- $("#removeallstopwords").click(function() {
10
  var c = confirm(relevanssi.confirm_stopwords)
11
  return c //you can just return c because it will be true or false
12
  })
13
  })
14
 
15
- jQuery(document).ready(function($) {
16
  $(".color-field").wpColorPicker()
17
 
18
  var txtcol_control = $("#tr_relevanssi_txt_col")
@@ -20,7 +20,7 @@ jQuery(document).ready(function($) {
20
  var class_control = $("#tr_relevanssi_class")
21
  var css_control = $("#tr_relevanssi_css")
22
 
23
- $("#relevanssi_highlight").change(function() {
24
  txtcol_control.addClass("screen-reader-text")
25
  bgcol_control.addClass("screen-reader-text")
26
  class_control.addClass("screen-reader-text")
@@ -32,67 +32,67 @@ jQuery(document).ready(function($) {
32
  if (this.value == "css") css_control.toggleClass("screen-reader-text")
33
  })
34
 
35
- $("#relevanssi_hilite_title").click(function() {
36
  $("#title_description").toggleClass("screen-reader-text", !this.checked)
37
  })
38
 
39
  var or_fallback = $("#orfallback")
40
- $("#relevanssi_implicit_operator").change(function() {
41
  or_fallback.toggleClass("screen-reader-text")
42
  })
43
 
44
  var index_subscribers = $("#index_subscribers")
45
  var user_extra_fields = $("#user_extra_fields")
46
- $("#relevanssi_index_users").click(function() {
47
  $("#user_profile_notice").toggleClass("screen-reader-text", !this.checked)
48
  index_subscribers.toggleClass("screen-reader-text", !this.checked)
49
  user_extra_fields.toggleClass("screen-reader-text", !this.checked)
50
  })
51
 
52
  var taxonomies = $("#taxonomies")
53
- $("#relevanssi_index_taxonomies").click(function() {
54
  taxonomies.toggleClass("screen-reader-text", !this.checked)
55
  })
56
 
57
  var post_type_archives = $("#posttypearchives")
58
- $("#relevanssi_index_post_type_archives").click(function() {
59
  post_type_archives.toggleClass("screen-reader-text", !this.checked)
60
  })
61
 
62
  var fields_content = $("#index_field_input")
63
  var fields_select = $("#relevanssi_index_fields_select")
64
- fields_select.change(function() {
65
  if (this.value == "some") fields_content.show()
66
  if (this.value != "some") fields_content.hide()
67
  })
68
 
69
  var index_images = $("#row_index_image_files")
70
  var index_attachments = $("#relevanssi_index_type_attachment")
71
- index_attachments.click(function() {
72
  if (this.checked) index_images.show()
73
  if (!this.checked) index_images.hide()
74
  })
75
 
76
- $("#show_advanced_indexing").click(function(e) {
77
  $("#advanced_indexing").toggleClass("screen-reader-text")
78
  $("#hide_advanced_indexing").show()
79
  $("#show_advanced_indexing").hide()
80
  })
81
 
82
- $("#hide_advanced_indexing").click(function(e) {
83
  $("#advanced_indexing").toggleClass("screen-reader-text")
84
  $("#show_advanced_indexing").show()
85
  $("#hide_advanced_indexing").hide()
86
  })
87
 
88
- $("#indexing_tab :input").change(function(e) {
89
  $("#build_index").attr("disabled", "disabled")
90
  var relevanssi_note = $("#relevanssi-note")
91
  relevanssi_note.show()
92
  relevanssi_note.html(relevanssi.options_changed)
93
  })
94
 
95
- $("#relevanssi_default_orderby").change(function(e) {
96
  if (this.value == "post_date") {
97
  $("#relevanssi_throttle").prop("checked", false)
98
  }
@@ -100,18 +100,18 @@ jQuery(document).ready(function($) {
100
  $("#throttle_enabled").toggleClass("screen-reader-text")
101
  })
102
 
103
- $("#relevanssi_show_pdf_errors").click(function(e) {
104
  var error_box = $("#relevanssi_pdf_errors")
105
  error_box.toggle()
106
  var data = {
107
- action: "relevanssi_get_pdf_errors"
108
  }
109
- jQuery.post(ajaxurl, data, function(response) {
110
  error_box.val(JSON.parse(response))
111
  })
112
  })
113
 
114
- $("#relevanssi_excerpts").click(function() {
115
  $("#relevanssi_breakdown").toggleClass("relevanssi_disabled", !this.checked)
116
  $("#relevanssi_highlighting").toggleClass(
117
  "relevanssi_disabled",
@@ -143,7 +143,7 @@ jQuery(document).ready(function($) {
143
  $("#relevanssi_show_matches_text").attr("disabled", !this.checked)
144
  })
145
 
146
- $("#relevanssi_searchblogs_all").click(function() {
147
  $("#relevanssi_searchblogs").attr("disabled", this.checked)
148
  })
149
  })
@@ -157,8 +157,8 @@ function relevanssiUpdateClock() {
157
  document.getElementById("relevanssi_elapsed").innerHTML = time_formatted
158
  }
159
 
160
- jQuery(document).ready(function($) {
161
- $("#continue_indexing").click(function() {
162
  $("#relevanssi-progress").show()
163
  $("#results").show()
164
  $("#relevanssi-timer").show()
@@ -170,11 +170,11 @@ jQuery(document).ready(function($) {
170
  intervalID = window.setInterval(relevanssiUpdateClock, 1000)
171
 
172
  var data = {
173
- action: "relevanssi_count_missing_posts"
174
  }
175
  console.log("Counting posts.")
176
  results.value += relevanssi.counting_posts + " "
177
- jQuery.post(ajaxurl, data, function(response) {
178
  count_response = JSON.parse(response)
179
  console.log("Counted " + count_response + " posts.")
180
  results.value += count_response + " " + relevanssi.posts_found + "\n"
@@ -187,7 +187,7 @@ jQuery(document).ready(function($) {
187
  limit: relevanssi_params.indexing_limit,
188
  adjust: relevanssi_params.indexing_adjust,
189
  extend: true,
190
- security: nonce.indexing_nonce
191
  }
192
  process_indexing_step(args)
193
  } else {
@@ -211,10 +211,10 @@ function process_indexing_step(args) {
211
  limit: args.limit,
212
  adjust: args.adjust,
213
  extend: args.extend,
214
- security: args.security
215
  },
216
  dataType: "json",
217
- success: function(response) {
218
  console.log(response)
219
  if (response.completed == "done") {
220
  //console.log("response " + parseInt(response.total_posts));
@@ -234,10 +234,10 @@ function process_indexing_step(args) {
234
  results_textarea.scrollTop = results_textarea.scrollHeight
235
  jQuery(".rpi-progress div").animate(
236
  {
237
- width: response.percentage + "%"
238
  },
239
  50,
240
- function() {
241
  // Animation complete.
242
  }
243
  )
@@ -285,10 +285,10 @@ function process_indexing_step(args) {
285
 
286
  jQuery(".rpi-progress div").animate(
287
  {
288
- width: percentage_rounded + "%"
289
  },
290
  50,
291
- function() {
292
  // Animation complete.
293
  }
294
  )
@@ -301,12 +301,12 @@ function process_indexing_step(args) {
301
  limit: args.limit,
302
  adjust: args.adjust,
303
  extend: args.extend,
304
- security: args.security
305
  }
306
 
307
  process_indexing_step(new_args)
308
  }
309
- }
310
  })
311
  }
312
 
@@ -345,8 +345,8 @@ function rlv_format_approximate_time(total_seconds) {
345
  return time
346
  }
347
 
348
- jQuery(document).ready(function($) {
349
- $("#search").click(function(e) {
350
  var results = document.getElementById("results")
351
  results.innerHTML = "Searching..."
352
  e.preventDefault()
@@ -359,30 +359,30 @@ jQuery(document).ready(function($) {
359
  posts_per_page: document.getElementById("posts_per_page").value,
360
  post_types: document.getElementById("post_types").value,
361
  s: document.getElementById("s").value,
362
- security: nonce.searching_nonce
363
  },
364
  dataType: "json",
365
- success: function(response) {
366
  results.innerHTML = response
367
- }
368
  })
369
  })
370
 
371
  // Show the filters on the "Admin search" page.
372
- $(document).on("click", "#show_filters", function(e) {
373
  $("#relevanssi_filter_list").toggle()
374
  $("#show_filters").toggle()
375
  $("#hide_filters").toggle()
376
  })
377
 
378
  // Hide the filters on the "Admin search" page.
379
- $(document).on("click", "#hide_filters", function(e) {
380
  $("#relevanssi_filter_list").toggle()
381
  $("#show_filters").toggle()
382
  $("#hide_filters").toggle()
383
  })
384
 
385
- $(document).on("click", "#next_page", function(e) {
386
  e.preventDefault()
387
  var results = document.getElementById("results")
388
  var offset = parseInt(document.getElementById("offset").innerHTML)
@@ -397,16 +397,16 @@ jQuery(document).ready(function($) {
397
  posts_per_page: posts,
398
  s: document.getElementById("s").value,
399
  offset: offset,
400
- security: nonce.searching_nonce
401
  },
402
  dataType: "json",
403
- success: function(response) {
404
  results.innerHTML = response
405
- }
406
  })
407
  })
408
 
409
- $(document).on("click", "#prev_page", function(e) {
410
  e.preventDefault()
411
  var results = document.getElementById("results")
412
  var offset = parseInt(document.getElementById("offset").innerHTML)
@@ -423,16 +423,16 @@ jQuery(document).ready(function($) {
423
  posts_per_page: document.getElementById("posts_per_page").value,
424
  s: document.getElementById("s").value,
425
  offset: offset,
426
- security: nonce.searching_nonce
427
  },
428
  dataType: "json",
429
- success: function(response) {
430
  results.innerHTML = response
431
- }
432
  })
433
  })
434
 
435
- $(document).on("click", ".pin", function(e) {
436
  e.preventDefault()
437
  var keyword = e.target.dataset.keyword
438
  var post_id = e.target.dataset.postid
@@ -443,10 +443,10 @@ jQuery(document).ready(function($) {
443
  action: "relevanssi_pin_post",
444
  keyword,
445
  post_id,
446
- security: nonce.searching_nonce
447
  },
448
  dataType: "json",
449
- success: function(response) {
450
  var results = document.getElementById("results")
451
  results.innerHTML = "Searching..."
452
  e.preventDefault()
@@ -458,18 +458,18 @@ jQuery(document).ready(function($) {
458
  args: document.getElementById("args").value,
459
  posts_per_page: document.getElementById("posts_per_page").value,
460
  s: document.getElementById("s").value,
461
- security: nonce.searching_nonce
462
  },
463
  dataType: "json",
464
- success: function(response) {
465
  results.innerHTML = response
466
- }
467
  })
468
- }
469
  })
470
  })
471
 
472
- $(document).on("click", ".unpin", function(e) {
473
  e.preventDefault()
474
  var keyword = e.target.dataset.keyword
475
  var post_id = e.target.dataset.postid
@@ -480,10 +480,10 @@ jQuery(document).ready(function($) {
480
  action: "relevanssi_unpin_post",
481
  keyword,
482
  post_id,
483
- security: nonce.searching_nonce
484
  },
485
  dataType: "json",
486
- success: function(response) {
487
  var results = document.getElementById("results")
488
  results.innerHTML = "Searching..."
489
  e.preventDefault()
@@ -495,14 +495,14 @@ jQuery(document).ready(function($) {
495
  args: document.getElementById("args").value,
496
  posts_per_page: document.getElementById("posts_per_page").value,
497
  s: document.getElementById("s").value,
498
- security: nonce.searching_nonce
499
  },
500
  dataType: "json",
501
- success: function(response) {
502
  results.innerHTML = response
503
- }
504
  })
505
- }
506
  })
507
  })
508
  })
1
  /* Confirmation for copying options between blogs */
2
 
3
+ jQuery(document).ready(function ($) {
4
+ $("#copy_config").submit(function () {
5
  var c = confirm(relevanssi.confirm)
6
  return c //you can just return c because it will be true or false
7
  })
8
 
9
+ $("#removeallstopwords").click(function () {
10
  var c = confirm(relevanssi.confirm_stopwords)
11
  return c //you can just return c because it will be true or false
12
  })
13
  })
14
 
15
+ jQuery(document).ready(function ($) {
16
  $(".color-field").wpColorPicker()
17
 
18
  var txtcol_control = $("#tr_relevanssi_txt_col")
20
  var class_control = $("#tr_relevanssi_class")
21
  var css_control = $("#tr_relevanssi_css")
22
 
23
+ $("#relevanssi_highlight").change(function () {
24
  txtcol_control.addClass("screen-reader-text")
25
  bgcol_control.addClass("screen-reader-text")
26
  class_control.addClass("screen-reader-text")
32
  if (this.value == "css") css_control.toggleClass("screen-reader-text")
33
  })
34
 
35
+ $("#relevanssi_hilite_title").click(function () {
36
  $("#title_description").toggleClass("screen-reader-text", !this.checked)
37
  })
38
 
39
  var or_fallback = $("#orfallback")
40
+ $("#relevanssi_implicit_operator").change(function () {
41
  or_fallback.toggleClass("screen-reader-text")
42
  })
43
 
44
  var index_subscribers = $("#index_subscribers")
45
  var user_extra_fields = $("#user_extra_fields")
46
+ $("#relevanssi_index_users").click(function () {
47
  $("#user_profile_notice").toggleClass("screen-reader-text", !this.checked)
48
  index_subscribers.toggleClass("screen-reader-text", !this.checked)
49
  user_extra_fields.toggleClass("screen-reader-text", !this.checked)
50
  })
51
 
52
  var taxonomies = $("#taxonomies")
53
+ $("#relevanssi_index_taxonomies").click(function () {
54
  taxonomies.toggleClass("screen-reader-text", !this.checked)
55
  })
56
 
57
  var post_type_archives = $("#posttypearchives")
58
+ $("#relevanssi_index_post_type_archives").click(function () {
59
  post_type_archives.toggleClass("screen-reader-text", !this.checked)
60
  })
61
 
62
  var fields_content = $("#index_field_input")
63
  var fields_select = $("#relevanssi_index_fields_select")
64
+ fields_select.change(function () {
65
  if (this.value == "some") fields_content.show()
66
  if (this.value != "some") fields_content.hide()
67
  })
68
 
69
  var index_images = $("#row_index_image_files")
70
  var index_attachments = $("#relevanssi_index_type_attachment")
71
+ index_attachments.click(function () {
72
  if (this.checked) index_images.show()
73
  if (!this.checked) index_images.hide()
74
  })
75
 
76
+ $("#show_advanced_indexing").click(function (e) {
77
  $("#advanced_indexing").toggleClass("screen-reader-text")
78
  $("#hide_advanced_indexing").show()
79
  $("#show_advanced_indexing").hide()
80
  })
81
 
82
+ $("#hide_advanced_indexing").click(function (e) {
83
  $("#advanced_indexing").toggleClass("screen-reader-text")
84
  $("#show_advanced_indexing").show()
85
  $("#hide_advanced_indexing").hide()
86
  })
87
 
88
+ $("#indexing_tab :input").change(function (e) {
89
  $("#build_index").attr("disabled", "disabled")
90
  var relevanssi_note = $("#relevanssi-note")
91
  relevanssi_note.show()
92
  relevanssi_note.html(relevanssi.options_changed)
93
  })
94
 
95
+ $("#relevanssi_default_orderby").change(function (e) {
96
  if (this.value == "post_date") {
97
  $("#relevanssi_throttle").prop("checked", false)
98
  }
100
  $("#throttle_enabled").toggleClass("screen-reader-text")
101
  })
102
 
103
+ $("#relevanssi_show_pdf_errors").click(function (e) {
104
  var error_box = $("#relevanssi_pdf_errors")
105
  error_box.toggle()
106
  var data = {
107
+ action: "relevanssi_get_pdf_errors",
108
  }
109
+ jQuery.post(ajaxurl, data, function (response) {
110
  error_box.val(JSON.parse(response))
111
  })
112
  })
113
 
114
+ $("#relevanssi_excerpts").click(function () {
115
  $("#relevanssi_breakdown").toggleClass("relevanssi_disabled", !this.checked)
116
  $("#relevanssi_highlighting").toggleClass(
117
  "relevanssi_disabled",
143
  $("#relevanssi_show_matches_text").attr("disabled", !this.checked)
144
  })
145
 
146
+ $("#relevanssi_searchblogs_all").click(function () {
147
  $("#relevanssi_searchblogs").attr("disabled", this.checked)
148
  })
149
  })
157
  document.getElementById("relevanssi_elapsed").innerHTML = time_formatted
158
  }
159
 
160
+ jQuery(document).ready(function ($) {
161
+ $("#continue_indexing").click(function () {
162
  $("#relevanssi-progress").show()
163
  $("#results").show()
164
  $("#relevanssi-timer").show()
170
  intervalID = window.setInterval(relevanssiUpdateClock, 1000)
171
 
172
  var data = {
173
+ action: "relevanssi_count_missing_posts",
174
  }
175
  console.log("Counting posts.")
176
  results.value += relevanssi.counting_posts + " "
177
+ jQuery.post(ajaxurl, data, function (response) {
178
  count_response = JSON.parse(response)
179
  console.log("Counted " + count_response + " posts.")
180
  results.value += count_response + " " + relevanssi.posts_found + "\n"
187
  limit: relevanssi_params.indexing_limit,
188
  adjust: relevanssi_params.indexing_adjust,
189
  extend: true,
190
+ security: nonce.indexing_nonce,
191
  }
192
  process_indexing_step(args)
193
  } else {
211
  limit: args.limit,
212
  adjust: args.adjust,
213
  extend: args.extend,
214
+ security: args.security,
215
  },
216
  dataType: "json",
217
+ success: function (response) {
218
  console.log(response)
219
  if (response.completed == "done") {
220
  //console.log("response " + parseInt(response.total_posts));
234
  results_textarea.scrollTop = results_textarea.scrollHeight
235
  jQuery(".rpi-progress div").animate(
236
  {
237
+ width: response.percentage + "%",
238
  },
239
  50,
240
+ function () {
241
  // Animation complete.
242
  }
243
  )
285
 
286
  jQuery(".rpi-progress div").animate(
287
  {
288
+ width: percentage_rounded + "%",
289
  },
290
  50,
291
+ function () {
292
  // Animation complete.
293
  }
294
  )
301
  limit: args.limit,
302
  adjust: args.adjust,
303
  extend: args.extend,
304
+ security: args.security,
305
  }
306
 
307
  process_indexing_step(new_args)
308
  }
309
+ },
310
  })
311
  }
312
 
345
  return time
346
  }
347
 
348
+ jQuery(document).ready(function ($) {
349
+ $("#search").click(function (e) {
350
  var results = document.getElementById("results")
351
  results.innerHTML = "Searching..."
352
  e.preventDefault()
359
  posts_per_page: document.getElementById("posts_per_page").value,
360
  post_types: document.getElementById("post_types").value,
361
  s: document.getElementById("s").value,
362
+ security: nonce.searching_nonce,
363
  },
364
  dataType: "json",
365
+ success: function (response) {
366
  results.innerHTML = response
367
+ },
368
  })
369
  })
370
 
371
  // Show the filters on the "Admin search" page.
372
+ $(document).on("click", "#show_filters", function (e) {
373
  $("#relevanssi_filter_list").toggle()
374
  $("#show_filters").toggle()
375
  $("#hide_filters").toggle()
376
  })
377
 
378
  // Hide the filters on the "Admin search" page.
379
+ $(document).on("click", "#hide_filters", function (e) {
380
  $("#relevanssi_filter_list").toggle()
381
  $("#show_filters").toggle()
382
  $("#hide_filters").toggle()
383
  })
384
 
385
+ $(document).on("click", "#next_page", function (e) {
386
  e.preventDefault()
387
  var results = document.getElementById("results")
388
  var offset = parseInt(document.getElementById("offset").innerHTML)
397
  posts_per_page: posts,
398
  s: document.getElementById("s").value,
399
  offset: offset,
400
+ security: nonce.searching_nonce,
401
  },
402
  dataType: "json",
403
+ success: function (response) {
404
  results.innerHTML = response
405
+ },
406
  })
407
  })
408
 
409
+ $(document).on("click", "#prev_page", function (e) {
410
  e.preventDefault()
411
  var results = document.getElementById("results")
412
  var offset = parseInt(document.getElementById("offset").innerHTML)
423
  posts_per_page: document.getElementById("posts_per_page").value,
424
  s: document.getElementById("s").value,
425
  offset: offset,
426
+ security: nonce.searching_nonce,
427
  },
428
  dataType: "json",
429
+ success: function (response) {
430
  results.innerHTML = response
431
+ },
432
  })
433
  })
434
 
435
+ $(document).on("click", ".pin", function (e) {
436
  e.preventDefault()
437
  var keyword = e.target.dataset.keyword
438
  var post_id = e.target.dataset.postid
443
  action: "relevanssi_pin_post",
444
  keyword,
445
  post_id,
446
+ security: nonce.searching_nonce,
447
  },
448
  dataType: "json",
449
+ success: function (response) {
450
  var results = document.getElementById("results")
451
  results.innerHTML = "Searching..."
452
  e.preventDefault()
458
  args: document.getElementById("args").value,
459
  posts_per_page: document.getElementById("posts_per_page").value,
460
  s: document.getElementById("s").value,
461
+ security: nonce.searching_nonce,
462
  },
463
  dataType: "json",
464
+ success: function (response) {
465
  results.innerHTML = response
466
+ },
467
  })
468
+ },
469
  })
470
  })
471
 
472
+ $(document).on("click", ".unpin", function (e) {
473
  e.preventDefault()
474
  var keyword = e.target.dataset.keyword
475
  var post_id = e.target.dataset.postid
480
  action: "relevanssi_unpin_post",
481
  keyword,
482
  post_id,
483
+ security: nonce.searching_nonce,
484
  },
485
  dataType: "json",
486
+ success: function (response) {
487
  var results = document.getElementById("results")
488
  results.innerHTML = "Searching..."
489
  e.preventDefault()
495
  args: document.getElementById("args").value,
496
  posts_per_page: document.getElementById("posts_per_page").value,
497
  s: document.getElementById("s").value,
498
+ security: nonce.searching_nonce,
499
  },
500
  dataType: "json",
501
+ success: function (response) {
502
  results.innerHTML = response
503
+ },
504
  })
505
+ },
506
  })
507
  })
508
  })
lib/admin_scripts_free.js CHANGED
@@ -1,5 +1,5 @@
1
- jQuery(document).ready(function($) {
2
- $("#build_index").click(function() {
3
  $("#relevanssi-progress").show()
4
  $("#results").show()
5
  $("#relevanssi-timer").show()
@@ -10,14 +10,14 @@ jQuery(document).ready(function($) {
10
  results.value = ""
11
 
12
  var data = {
13
- action: "relevanssi_truncate_index"
14
  }
15
 
16
  intervalID = window.setInterval(relevanssiUpdateClock, 1000)
17
 
18
  console.log("Truncating index.")
19
  results.value += relevanssi.truncating_index + " "
20
- jQuery.post(ajaxurl, data, function(response) {
21
  truncate_response = JSON.parse(response)
22
  console.log("Truncate index: " + truncate_response)
23
  if (truncate_response == true) {
@@ -25,11 +25,11 @@ jQuery(document).ready(function($) {
25
  }
26
 
27
  var data = {
28
- action: "relevanssi_count_posts"
29
  }
30
  console.log("Counting posts.")
31
  results.value += relevanssi.counting_posts + " "
32
- jQuery.post(ajaxurl, data, function(response) {
33
  count_response = JSON.parse(response)
34
  console.log("Counted " + count_response + " posts.")
35
  var post_total = parseInt(count_response)
@@ -43,7 +43,7 @@ jQuery(document).ready(function($) {
43
  limit: relevanssi_params.indexing_limit,
44
  adjust: relevanssi_params.indexing_adjust,
45
  extend: false,
46
- security: nonce.indexing_nonce
47
  }
48
  process_indexing_step(args)
49
  })
1
+ jQuery(document).ready(function ($) {
2
+ $("#build_index").click(function () {
3
  $("#relevanssi-progress").show()
4
  $("#results").show()
5
  $("#relevanssi-timer").show()
10
  results.value = ""
11
 
12
  var data = {
13
+ action: "relevanssi_truncate_index",
14
  }
15
 
16
  intervalID = window.setInterval(relevanssiUpdateClock, 1000)
17
 
18
  console.log("Truncating index.")
19
  results.value += relevanssi.truncating_index + " "
20
+ jQuery.post(ajaxurl, data, function (response) {
21
  truncate_response = JSON.parse(response)
22
  console.log("Truncate index: " + truncate_response)
23
  if (truncate_response == true) {
25
  }
26
 
27
  var data = {
28
+ action: "relevanssi_count_posts",
29
  }
30
  console.log("Counting posts.")
31
  results.value += relevanssi.counting_posts + " "
32
+ jQuery.post(ajaxurl, data, function (response) {
33
  count_response = JSON.parse(response)
34
  console.log("Counted " + count_response + " posts.")
35
  var post_total = parseInt(count_response)
43
  limit: relevanssi_params.indexing_limit,
44
  adjust: relevanssi_params.indexing_adjust,
45
  extend: false,
46
+ security: nonce.indexing_nonce,
47
  }
48
  process_indexing_step(args)
49
  })
lib/common.php CHANGED
@@ -23,12 +23,12 @@
23
  */
24
  function relevanssi_mb_strcasecmp( $str1, $str2, $encoding = null ) {
25
  if ( ! function_exists( 'mb_internal_encoding' ) ) {
26
- return strcasecmp( $str1, $str2 );
27
  } else {
28
  if ( null === $encoding ) {
29
  $encoding = mb_internal_encoding();
30
  }
31
- return strcmp( mb_strtoupper( $str1, $encoding ), mb_strtoupper( $str2, $encoding ) );
32
  }
33
  }
34
 
@@ -557,7 +557,7 @@ function relevanssi_generate_phrase_queries( $phrases, $taxonomies, $custom_fiel
557
  }
558
 
559
  if ( 'visible' === $custom_fields ) {
560
- $keys = "AND (m.meta_key NOT LIKE '_%' OR m.meta_key = '_relevanssi_pdf_content')";
561
  }
562
 
563
  $query = "(SELECT ID
@@ -1052,6 +1052,12 @@ function relevanssi_get_post_status( $post_id ) {
1052
  return 'publish';
1053
  }
1054
 
 
 
 
 
 
 
1055
  if ( isset( $relevanssi_post_array[ $post_id ] ) ) {
1056
  $status = $relevanssi_post_array[ $post_id ]->post_status;
1057
  if ( 'inherit' === $status ) {
@@ -1066,14 +1072,32 @@ function relevanssi_get_post_status( $post_id ) {
1066
  }
1067
  return $status;
1068
  } else {
1069
- // No hit from the cache; let's add this post to the cache.
1070
- $post = get_post( $post_id );
1071
- if ( ! $post ) {
1072
- return '';
1073
- }
1074
 
1075
- $relevanssi_post_array[ $post_id ] = $post;
1076
- return $post->post_status;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1077
  }
1078
  }
1079
 
@@ -1091,17 +1115,27 @@ function relevanssi_get_post_status( $post_id ) {
1091
  */
1092
  function relevanssi_get_post_type( $post_id ) {
1093
  global $relevanssi_post_array;
 
 
 
 
 
 
 
 
1094
  if ( isset( $relevanssi_post_array[ $post_id ] ) ) {
1095
  return $relevanssi_post_array[ $post_id ]->post_type;
1096
  } else {
1097
- // No hit from the cache; let's add this post to the cache.
1098
- $post = relevanssi_get_post( $post_id );
1099
 
1100
  if ( is_wp_error( $post ) ) {
1101
- $post->add_data( 'not_found', "relevanssi_get_post_type() didn't get a post, relevanssi_get_post() returned null." );
 
 
 
1102
  return $post;
1103
  } elseif ( $post ) {
1104
- $relevanssi_post_array[ $post_id ] = $post;
1105
  return $post->post_type;
1106
  } else {
1107
  return new WP_Error( 'not_found', 'Something went wrong.' );
@@ -1368,10 +1402,20 @@ function relevanssi_get_the_title( $post_id ) {
1368
  function relevanssi_update_doc_count() {
1369
  global $wpdb, $relevanssi_variables;
1370
  $doc_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT(doc)) FROM ' . $relevanssi_variables['relevanssi_table'] ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
1371
- update_option( 'relevanssi_doc_count', $doc_count );
 
1372
  return $doc_count;
1373
  }
1374
 
 
 
 
 
 
 
 
 
 
1375
  /**
1376
  * Returns the length of the string.
1377
  *
@@ -2003,6 +2047,7 @@ function relevanssi_remove_page_builder_shortcodes( $content ) {
2003
  '/\[et_pb_code.*?\].*\[\/et_pb_code\]/im',
2004
  '/\[et_pb_sidebar.*?\].*\[\/et_pb_sidebar\]/im',
2005
  '/\[et_pb_fullwidth_slider.*?\].*\[\/et_pb_fullwidth_slider\]/im',
 
2006
  '/\[vc_raw_html.*?\].*\[\/vc_raw_html\]/im',
2007
  '/\[fusion_imageframe.*?\].*\[\/fusion_imageframe\]/im',
2008
  '/\[fusion_code.*?\].*\[\/fusion_code\]/im',
@@ -2083,7 +2128,7 @@ function relevanssi_check_indexing_restriction() {
2083
  $callbacks = array_flip(
2084
  array_keys(
2085
  array_merge(
2086
- [],
2087
  ...$wp_filter['relevanssi_indexing_restriction']->callbacks
2088
  )
2089
  )
@@ -2100,7 +2145,13 @@ function relevanssi_check_indexing_restriction() {
2100
  if ( ! empty( $callbacks ) ) {
2101
  $returns_string = array();
2102
  foreach ( array_keys( $callbacks ) as $callback ) {
2103
- $return = call_user_func( $callback, array( 'mysql' => '', 'reason' => '' ) );
 
 
 
 
 
 
2104
  if ( is_string( $return ) ) {
2105
  $returns_string[] = '<code>' . $callback . '</code>';
2106
  }
@@ -2120,3 +2171,43 @@ EOH;
2120
  }
2121
  return $notice;
2122
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  */
24
  function relevanssi_mb_strcasecmp( $str1, $str2, $encoding = null ) {
25
  if ( ! function_exists( 'mb_internal_encoding' ) ) {
26
+ return strnatcasecmp( $str1, $str2 );
27
  } else {
28
  if ( null === $encoding ) {
29
  $encoding = mb_internal_encoding();
30
  }
31
+ return strnatcmp( mb_strtoupper( $str1, $encoding ), mb_strtoupper( $str2, $encoding ) );
32
  }
33
  }
34
 
557
  }
558
 
559
  if ( 'visible' === $custom_fields ) {
560
+ $keys = "AND (m.meta_key NOT LIKE '\_%' OR m.meta_key = '_relevanssi_pdf_content')";
561
  }
562
 
563
  $query = "(SELECT ID
1052
  return 'publish';
1053
  }
1054
 
1055
+ $original_id = $post_id;
1056
+ $blog_id = -1;
1057
+ if ( is_multisite() ) {
1058
+ $blog_id = get_current_blog_id();
1059
+ $post_id = $blog_id . '|' . $post_id;
1060
+ }
1061
  if ( isset( $relevanssi_post_array[ $post_id ] ) ) {
1062
  $status = $relevanssi_post_array[ $post_id ]->post_status;
1063
  if ( 'inherit' === $status ) {
1072
  }
1073
  return $status;
1074
  } else {
1075
+ // No hit from the cache; let's fetch.
1076
+ $post = relevanssi_get_post( $original_id, $blog_id );
 
 
 
1077
 
1078
+ if ( is_wp_error( $post ) ) {
1079
+ $post->add_data(
1080
+ 'not_found',
1081
+ "relevanssi_get_post_status() didn't get a post, relevanssi_get_post() returned null."
1082
+ );
1083
+ return $post;
1084
+ } elseif ( $post ) {
1085
+ if ( 'inherit' === $post->post_status ) {
1086
+ // Attachment, let's see what the parent says.
1087
+ $parent = $relevanssi_post_array[ $post_id ]->post_parent;
1088
+ if ( ! $parent ) {
1089
+ // Attachment without a parent, let's assume it's public.
1090
+ $status = 'publish';
1091
+ } else {
1092
+ $status = relevanssi_get_post_status( $parent );
1093
+ }
1094
+ } else {
1095
+ $status = $post->post_status;
1096
+ }
1097
+ return $status;
1098
+ } else {
1099
+ return new WP_Error( 'not_found', 'Something went wrong.' );
1100
+ }
1101
  }
1102
  }
1103
 
1115
  */
1116
  function relevanssi_get_post_type( $post_id ) {
1117
  global $relevanssi_post_array;
1118
+
1119
+ $original_id = $post_id;
1120
+ $blog_id = -1;
1121
+ if ( function_exists( 'get_current_blog_id' ) ) {
1122
+ $blog_id = get_current_blog_id();
1123
+ $post_id = $blog_id . '|' . $post_id;
1124
+ }
1125
+
1126
  if ( isset( $relevanssi_post_array[ $post_id ] ) ) {
1127
  return $relevanssi_post_array[ $post_id ]->post_type;
1128
  } else {
1129
+ // No hit from the cache; let's fetch.
1130
+ $post = relevanssi_get_post( $original_id, $blog_id );
1131
 
1132
  if ( is_wp_error( $post ) ) {
1133
+ $post->add_data(
1134
+ 'not_found',
1135
+ "relevanssi_get_post_type() didn't get a post, relevanssi_get_post() returned null."
1136
+ );
1137
  return $post;
1138
  } elseif ( $post ) {
 
1139
  return $post->post_type;
1140
  } else {
1141
  return new WP_Error( 'not_found', 'Something went wrong.' );
1402
  function relevanssi_update_doc_count() {
1403
  global $wpdb, $relevanssi_variables;
1404
  $doc_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT(doc)) FROM ' . $relevanssi_variables['relevanssi_table'] ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
1405
+ update_option( 'relevanssi_doc_count', is_null( $doc_count ) ? 0 : $doc_count );
1406
+
1407
  return $doc_count;
1408
  }
1409
 
1410
+ /**
1411
+ * Launches an asynchronous action to update the doc count and other counts.
1412
+ *
1413
+ * This function should be used instead of relevanssi_update_doc_count().
1414
+ */
1415
+ function relevanssi_async_update_doc_count() {
1416
+ relevanssi_launch_ajax_action( 'relevanssi_update_counts' );
1417
+ }
1418
+
1419
  /**
1420
  * Returns the length of the string.
1421
  *
2047
  '/\[et_pb_code.*?\].*\[\/et_pb_code\]/im',
2048
  '/\[et_pb_sidebar.*?\].*\[\/et_pb_sidebar\]/im',
2049
  '/\[et_pb_fullwidth_slider.*?\].*\[\/et_pb_fullwidth_slider\]/im',
2050
+ '/\[et_pb_fullwidth_code.*?\].*\[\/et_pb_fullwidth_code\]/im',
2051
  '/\[vc_raw_html.*?\].*\[\/vc_raw_html\]/im',
2052
  '/\[fusion_imageframe.*?\].*\[\/fusion_imageframe\]/im',
2053
  '/\[fusion_code.*?\].*\[\/fusion_code\]/im',
2128
  $callbacks = array_flip(
2129
  array_keys(
2130
  array_merge(
2131
+ array(),
2132
  ...$wp_filter['relevanssi_indexing_restriction']->callbacks
2133
  )
2134
  )
2145
  if ( ! empty( $callbacks ) ) {
2146
  $returns_string = array();
2147
  foreach ( array_keys( $callbacks ) as $callback ) {
2148
+ $return = call_user_func(
2149
+ $callback,
2150
+ array(
2151
+ 'mysql' => '',
2152
+ 'reason' => '',
2153
+ )
2154
+ );
2155
  if ( is_string( $return ) ) {
2156
  $returns_string[] = '<code>' . $callback . '</code>';
2157
  }
2171
  }
2172
  return $notice;
2173
  }
2174
+
2175
+ /**
2176
+ * Launches an asynchronous Ajax action.
2177
+ *
2178
+ * Makes a wp_remote_post() call with the specific action. Handles nonce
2179
+ * verification.
2180
+ *
2181
+ * @see wp_remove_post()
2182
+ * @see wp_create_nonce()
2183
+ *
2184
+ * @param string $action The action to trigger (also the name of the
2185
+ * nonce).
2186
+ * @param array $payload_args The parameters sent to the action. Defaults to
2187
+ * an empty array.
2188
+ *
2189
+ * @return WP_Error|array The wp_remote_post() response or WP_Error on failure.
2190
+ */
2191
+ function relevanssi_launch_ajax_action( $action, $payload_args = array() ) {
2192
+ $cookies = array();
2193
+ foreach ( $_COOKIE as $name => $value ) {
2194
+ $cookies[] = "$name=" . rawurlencode(
2195
+ is_array( $value ) ? wp_json_encode( $value ) : $value
2196
+ );
2197
+ }
2198
+ $default_payload = array(
2199
+ 'action' => $action,
2200
+ '_nonce' => wp_create_nonce( $action ),
2201
+ );
2202
+ $payload = array_merge( $default_payload, $payload_args );
2203
+ $args = array(
2204
+ 'timeout' => 0.01,
2205
+ 'blocking' => false,
2206
+ 'body' => $payload,
2207
+ 'headers' => array(
2208
+ 'cookie' => implode( '; ', $cookies ),
2209
+ ),
2210
+ );
2211
+ $url = admin_url( 'admin-ajax.php' );
2212
+ return wp_remote_post( $url, $args );
2213
+ }
lib/excerpts-highlights.php CHANGED
@@ -134,9 +134,15 @@ function relevanssi_do_excerpt( $t_post, $query, $excerpt_length = null, $excerp
134
  // don't want that.
135
  remove_filter( 'the_content', 'prepend_attachment' );
136
 
 
 
 
137
  /** This filter is documented in wp-includes/post-template.php */
138
  $content = apply_filters( 'the_content', $content );
139
 
 
 
 
140
  /**
141
  * Filters the post content after 'the_content'.
142
  *
134
  // don't want that.
135
  remove_filter( 'the_content', 'prepend_attachment' );
136
 
137
+ remove_shortcode( 'noindex' );
138
+ add_shortcode( 'noindex', 'relevanssi_noindex_shortcode_indexing' );
139
+
140
  /** This filter is documented in wp-includes/post-template.php */
141
  $content = apply_filters( 'the_content', $content );
142
 
143
+ remove_shortcode( 'noindex' );
144
+ add_shortcode( 'noindex', 'relevanssi_noindex_shortcode' );
145
+
146
  /**
147
  * Filters the post content after 'the_content'.
148
  *
lib/indexing.php CHANGED
@@ -308,7 +308,7 @@ function relevanssi_build_index( $extend_offset = false, $verbose = null, $post_
308
  relevanssi_premium_indexing();
309
  }
310
 
311
- update_option( 'relevanssi_index', '' );
312
  }
313
 
314
  $indexing_query_args = relevanssi_indexing_query_args( $extend_offset, $post_limit );
@@ -366,11 +366,11 @@ function relevanssi_build_index( $extend_offset = false, $verbose = null, $post_
366
 
367
  if ( ( 0 === $size ) || ( count( $content ) < $size ) ) {
368
  $complete = true;
369
- update_option( 'relevanssi_indexed', 'done' );
370
- }
371
 
372
- // Update the document count variable.
373
- relevanssi_update_doc_count();
 
374
 
375
  wp_suspend_cache_addition( false );
376
 
@@ -858,6 +858,8 @@ function relevanssi_insert_edit( $post_id ) {
858
  if ( $index_this_post ) {
859
  $bypass_global_post = true;
860
  $return_value = relevanssi_publish( $post_id, $bypass_global_post );
 
 
861
  } else {
862
  // The post isn't supposed to be indexed anymore, remove it from index.
863
  relevanssi_remove_doc( $post_id );
@@ -869,8 +871,6 @@ function relevanssi_insert_edit( $post_id ) {
869
  $return_value = 'removed';
870
  }
871
 
872
- relevanssi_update_doc_count();
873
-
874
  return $return_value;
875
  }
876
 
@@ -892,7 +892,6 @@ function relevanssi_insert_edit( $post_id ) {
892
  function relevanssi_index_comment( $comment_id ) {
893
  $comment_indexing_type = get_option( 'relevanssi_index_comments' );
894
  $no_pingbacks = false;
895
- $post_id = null;
896
 
897
  if ( 'normal' === $comment_indexing_type ) {
898
  $no_pingbacks = true;
@@ -905,7 +904,7 @@ function relevanssi_index_comment( $comment_id ) {
905
  if ( ! $comment ) {
906
  return 'nocommentfound';
907
  }
908
- if ( $no_pingbacks && ! empty( $comment->comment_type ) ) {
909
  return 'donotindex';
910
  }
911
  if ( 1 !== intval( $comment->comment_approved ) ) {
@@ -955,7 +954,21 @@ function relevanssi_get_comments( $post_id ) {
955
  'number' => $limit,
956
  'type' => $comment_types,
957
  );
958
- $comments = get_approved_comments( $post_id, $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
959
  if ( count( $comments ) === 0 ) {
960
  break;
961
  }
@@ -1021,8 +1034,6 @@ function relevanssi_remove_doc( $post_id, $keep_internal_links = false ) {
1021
  return;
1022
  }
1023
 
1024
- $doc_count = get_option( 'relevanssi_doc_count' );
1025
-
1026
  $rows_updated = $wpdb->query(
1027
  $wpdb->prepare(
1028
  'DELETE FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc=%d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
@@ -1031,7 +1042,7 @@ function relevanssi_remove_doc( $post_id, $keep_internal_links = false ) {
1031
  );
1032
 
1033
  if ( $rows_updated && $rows_updated > 0 ) {
1034
- update_option( 'relevanssi_doc_count', $doc_count - $rows_updated );
1035
  }
1036
  }
1037
  }
@@ -1474,7 +1485,9 @@ function relevanssi_index_content( &$insert_data, $post, $min_word_length, $debu
1474
 
1475
  if ( 'on' === get_option( 'relevanssi_expand_shortcodes' ) ) {
1476
  // TablePress support.
1477
- $tablepress_controller = relevanssi_enable_tablepress_shortcodes();
 
 
1478
 
1479
  relevanssi_disable_shortcodes();
1480
 
@@ -1501,6 +1514,7 @@ function relevanssi_index_content( &$insert_data, $post, $min_word_length, $debu
1501
  $contents,
1502
  $post
1503
  );
 
1504
  $contents = relevanssi_strip_invisibles( $contents );
1505
 
1506
  // Premium feature for better control over internal links.
308
  relevanssi_premium_indexing();
309
  }
310
 
311
+ update_option( 'relevanssi_index', '', false );
312
  }
313
 
314
  $indexing_query_args = relevanssi_indexing_query_args( $extend_offset, $post_limit );
366
 
367
  if ( ( 0 === $size ) || ( count( $content ) < $size ) ) {
368
  $complete = true;
369
+ update_option( 'relevanssi_indexed', 'done', false );
 
370
 
371
+ // Update the document count variable.
372
+ relevanssi_async_update_doc_count();
373
+ }
374
 
375
  wp_suspend_cache_addition( false );
376
 
858
  if ( $index_this_post ) {
859
  $bypass_global_post = true;
860
  $return_value = relevanssi_publish( $post_id, $bypass_global_post );
861
+
862
+ relevanssi_async_update_doc_count();
863
  } else {
864
  // The post isn't supposed to be indexed anymore, remove it from index.
865
  relevanssi_remove_doc( $post_id );
871
  $return_value = 'removed';
872
  }
873
 
 
 
874
  return $return_value;
875
  }
876
 
892
  function relevanssi_index_comment( $comment_id ) {
893
  $comment_indexing_type = get_option( 'relevanssi_index_comments' );
894
  $no_pingbacks = false;
 
895
 
896
  if ( 'normal' === $comment_indexing_type ) {
897
  $no_pingbacks = true;
904
  if ( ! $comment ) {
905
  return 'nocommentfound';
906
  }
907
+ if ( $no_pingbacks && 'pingback' === $comment->comment_type ) {
908
  return 'donotindex';
909
  }
910
  if ( 1 !== intval( $comment->comment_approved ) ) {
954
  'number' => $limit,
955
  'type' => $comment_types,
956
  );
957
+ $comments = get_approved_comments(
958
+ $post_id,
959
+ /**
960
+ * Filters the arguments for get_approved_comments().
961
+ *
962
+ * Useful for indexing custom comment types, for example.
963
+ *
964
+ * @param array An array of arguments. Don't adjust 'offset' or
965
+ * 'number' to avoid problems.
966
+ */
967
+ apply_filters(
968
+ 'relevanssi_get_approved_comments_args',
969
+ $args
970
+ )
971
+ );
972
  if ( count( $comments ) === 0 ) {
973
  break;
974
  }
1034
  return;
1035
  }
1036
 
 
 
1037
  $rows_updated = $wpdb->query(
1038
  $wpdb->prepare(
1039
  'DELETE FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc=%d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
1042
  );
1043
 
1044
  if ( $rows_updated && $rows_updated > 0 ) {
1045
+ relevanssi_async_update_doc_count();
1046
  }
1047
  }
1048
  }
1485
 
1486
  if ( 'on' === get_option( 'relevanssi_expand_shortcodes' ) ) {
1487
  // TablePress support.
1488
+ if ( function_exists( 'relevanssi_enable_tablepress_shortcodes' ) ) {
1489
+ $tablepress_controller = relevanssi_enable_tablepress_shortcodes();
1490
+ }
1491
 
1492
  relevanssi_disable_shortcodes();
1493
 
1514
  $contents,
1515
  $post
1516
  );
1517
+
1518
  $contents = relevanssi_strip_invisibles( $contents );
1519
 
1520
  // Premium feature for better control over internal links.
lib/init.php CHANGED
@@ -9,7 +9,7 @@
9
  */
10
 
11
  // Setup.
12
- add_action( 'init', 'relevanssi_init' );
13
  add_filter( 'query_vars', 'relevanssi_query_vars' );
14
  add_filter( 'rest_api_init', 'relevanssi_rest_api_disable' );
15
  add_action( 'switch_blog', 'relevanssi_switch_blog', 1, 2 );
9
  */
10
 
11
  // Setup.
12
+ add_action( 'init', 'relevanssi_init', 1 );
13
  add_filter( 'query_vars', 'relevanssi_query_vars' );
14
  add_filter( 'rest_api_init', 'relevanssi_rest_api_disable' );
15
  add_action( 'switch_blog', 'relevanssi_switch_blog', 1, 2 );
lib/interface.php CHANGED
@@ -295,9 +295,9 @@ function update_relevanssi_options() {
295
  }
296
 
297
  if ( 'indexing' === $_REQUEST['tab'] ) {
298
- update_option( 'relevanssi_index_taxonomies_list', array_keys( $index_taxonomies_list ) );
299
  if ( RELEVANSSI_PREMIUM ) {
300
- update_option( 'relevanssi_index_terms', array_keys( $index_terms_list ) );
301
  }
302
  }
303
 
@@ -306,7 +306,7 @@ function update_relevanssi_options() {
306
  }
307
 
308
  if ( count( $index_post_types ) > 0 ) {
309
- update_option( 'relevanssi_index_post_types', array_keys( $index_post_types ) );
310
  }
311
 
312
  if ( isset( $_REQUEST['relevanssi_index_fields_select'] ) ) {
@@ -322,7 +322,7 @@ function update_relevanssi_options() {
322
  $fields_option = rtrim( $_REQUEST['relevanssi_index_fields'], " \t\n\r\0\x0B," );
323
  }
324
  }
325
- update_option( 'relevanssi_index_fields', $fields_option );
326
  }
327
 
328
  if ( isset( $_REQUEST['relevanssi_trim_logs'] ) ) {
@@ -370,7 +370,7 @@ function update_relevanssi_options() {
370
  }
371
 
372
  if ( isset( $_REQUEST['relevanssi_admin_search'] ) ) {
373
- update_option( 'relevanssi_admin_search', $_REQUEST['relevanssi_admin_search'] );
374
  }
375
  if ( isset( $_REQUEST['relevanssi_excerpts'] ) ) {
376
  update_option( 'relevanssi_excerpts', $_REQUEST['relevanssi_excerpts'] );
@@ -415,22 +415,22 @@ function update_relevanssi_options() {
415
  update_option( 'relevanssi_hilite_title', $_REQUEST['relevanssi_hilite_title'] );
416
  }
417
  if ( isset( $_REQUEST['relevanssi_index_comments'] ) ) {
418
- update_option( 'relevanssi_index_comments', $_REQUEST['relevanssi_index_comments'] );
419
  }
420
  if ( isset( $_REQUEST['relevanssi_index_author'] ) ) {
421
- update_option( 'relevanssi_index_author', $_REQUEST['relevanssi_index_author'] );
422
  }
423
  if ( isset( $_REQUEST['relevanssi_index_excerpt'] ) ) {
424
- update_option( 'relevanssi_index_excerpt', $_REQUEST['relevanssi_index_excerpt'] );
425
  }
426
  if ( isset( $_REQUEST['relevanssi_index_image_files'] ) ) {
427
- update_option( 'relevanssi_index_image_files', $_REQUEST['relevanssi_index_image_files'] );
428
  }
429
  if ( isset( $_REQUEST['relevanssi_fuzzy'] ) ) {
430
  update_option( 'relevanssi_fuzzy', $_REQUEST['relevanssi_fuzzy'] );
431
  }
432
  if ( isset( $_REQUEST['relevanssi_expand_shortcodes'] ) ) {
433
- update_option( 'relevanssi_expand_shortcodes', $_REQUEST['relevanssi_expand_shortcodes'] );
434
  }
435
  if ( isset( $_REQUEST['relevanssi_implicit_operator'] ) ) {
436
  update_option( 'relevanssi_implicit_operator', $_REQUEST['relevanssi_implicit_operator'] );
295
  }
296
 
297
  if ( 'indexing' === $_REQUEST['tab'] ) {
298
+ update_option( 'relevanssi_index_taxonomies_list', array_keys( $index_taxonomies_list ), false );
299
  if ( RELEVANSSI_PREMIUM ) {
300
+ update_option( 'relevanssi_index_terms', array_keys( $index_terms_list ), false );
301
  }
302
  }
303
 
306
  }
307
 
308
  if ( count( $index_post_types ) > 0 ) {
309
+ update_option( 'relevanssi_index_post_types', array_keys( $index_post_types ), false );
310
  }
311
 
312
  if ( isset( $_REQUEST['relevanssi_index_fields_select'] ) ) {
322
  $fields_option = rtrim( $_REQUEST['relevanssi_index_fields'], " \t\n\r\0\x0B," );
323
  }
324
  }
325
+ update_option( 'relevanssi_index_fields', $fields_option, false );
326
  }
327
 
328
  if ( isset( $_REQUEST['relevanssi_trim_logs'] ) ) {
370
  }
371
 
372
  if ( isset( $_REQUEST['relevanssi_admin_search'] ) ) {
373
+ update_option( 'relevanssi_admin_search', $_REQUEST['relevanssi_admin_search'], false );
374
  }
375
  if ( isset( $_REQUEST['relevanssi_excerpts'] ) ) {
376
  update_option( 'relevanssi_excerpts', $_REQUEST['relevanssi_excerpts'] );
415
  update_option( 'relevanssi_hilite_title', $_REQUEST['relevanssi_hilite_title'] );
416
  }
417
  if ( isset( $_REQUEST['relevanssi_index_comments'] ) ) {
418
+ update_option( 'relevanssi_index_comments', $_REQUEST['relevanssi_index_comments'], false );
419
  }
420
  if ( isset( $_REQUEST['relevanssi_index_author'] ) ) {
421
+ update_option( 'relevanssi_index_author', $_REQUEST['relevanssi_index_author'], false );
422
  }
423
  if ( isset( $_REQUEST['relevanssi_index_excerpt'] ) ) {
424
+ update_option( 'relevanssi_index_excerpt', $_REQUEST['relevanssi_index_excerpt'], false );
425
  }
426
  if ( isset( $_REQUEST['relevanssi_index_image_files'] ) ) {
427
+ update_option( 'relevanssi_index_image_files', $_REQUEST['relevanssi_index_image_files'], false );
428
  }
429
  if ( isset( $_REQUEST['relevanssi_fuzzy'] ) ) {
430
  update_option( 'relevanssi_fuzzy', $_REQUEST['relevanssi_fuzzy'] );
431
  }
432
  if ( isset( $_REQUEST['relevanssi_expand_shortcodes'] ) ) {
433
+ update_option( 'relevanssi_expand_shortcodes', $_REQUEST['relevanssi_expand_shortcodes'], false );
434
  }
435
  if ( isset( $_REQUEST['relevanssi_implicit_operator'] ) ) {
436
  update_option( 'relevanssi_implicit_operator', $_REQUEST['relevanssi_implicit_operator'] );
lib/search.php CHANGED
@@ -179,10 +179,11 @@ function relevanssi_search( $args ) {
179
  */
180
  $query_join = apply_filters( 'relevanssi_join', $query_join );
181
 
182
- // Go get the count from the options, but run the full query if it's not available.
183
- $doc_count = get_option( 'relevanssi_doc_count' );
184
  if ( ! $doc_count || $doc_count < 1 ) {
185
- $doc_count = relevanssi_update_doc_count();
 
186
  }
187
 
188
  $total_hits = 0;
179
  */
180
  $query_join = apply_filters( 'relevanssi_join', $query_join );
181
 
182
+ // Get the count from the options.
183
+ $doc_count = get_option( 'relevanssi_doc_count', 0 );
184
  if ( ! $doc_count || $doc_count < 1 ) {
185
+ // Doc count is 0, update async in case there's some problem.
186
+ relevanssi_async_update_doc_count();
187
  }
188
 
189
  $total_hits = 0;
lib/sorting.php CHANGED
@@ -348,6 +348,13 @@ function relevanssi_cmp_function( $a, $b ) {
348
  $level = -1;
349
  $val = 0;
350
 
 
 
 
 
 
 
 
351
  while ( 0 === $val ) {
352
  $level++;
353
  if ( ! isset( $relevanssi_keys[ $level ] ) ) {
348
  $level = -1;
349
  $val = 0;
350
 
351
+ if ( is_integer( $a ) ) {
352
+ $a = get_post( $a );
353
+ }
354
+ if ( is_integer( $b ) ) {
355
+ $b = get_post( $b );
356
+ }
357
+
358
  while ( 0 === $val ) {
359
  $level++;
360
  if ( ! isset( $relevanssi_keys[ $level ] ) ) {
lib/tabs/indexing-tab.php CHANGED
@@ -89,13 +89,13 @@ function relevanssi_indexing_tab() {
89
  $punct_hyphens_remove = relevanssi_select( $punctuation['hyphens'], 'remove' );
90
  $punct_hyphens_keep = relevanssi_select( $punctuation['hyphens'], 'keep' );
91
 
92
- $docs_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT doc) FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc != -1' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
93
- $terms_count = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $relevanssi_variables['relevanssi_table'] ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
94
  $lowest_doc = $wpdb->get_var( 'SELECT doc FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc > 0 ORDER BY doc ASC LIMIT 1' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
95
 
96
  if ( RELEVANSSI_PREMIUM ) {
97
- $user_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE type = 'user'" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
98
- $taxterm_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE (type != 'post' AND type != 'attachment' AND type != 'user')" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
99
  }
100
 
101
  ?>
89
  $punct_hyphens_remove = relevanssi_select( $punctuation['hyphens'], 'remove' );
90
  $punct_hyphens_keep = relevanssi_select( $punctuation['hyphens'], 'keep' );
91
 
92
+ $docs_count = get_option( 'relevanssi_doc_count', 0 );
93
+ $terms_count = get_option( 'relevanssi_terms_count', 0 );
94
  $lowest_doc = $wpdb->get_var( 'SELECT doc FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc > 0 ORDER BY doc ASC LIMIT 1' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
95
 
96
  if ( RELEVANSSI_PREMIUM ) {
97
+ $user_count = get_option( 'relevanssi_user_count', 0 );
98
+ $taxterm_count = get_option( 'relevanssi_taxterm_count', 0 );
99
  }
100
 
101
  ?>
lib/uninstall.php CHANGED
@@ -106,6 +106,7 @@ function relevanssi_uninstall_free() {
106
  delete_option( 'relevanssi_show_post_controls' );
107
  delete_option( 'relevanssi_stopwords' );
108
  delete_option( 'relevanssi_synonyms' );
 
109
  delete_option( 'relevanssi_thousand_separator' );
110
  delete_option( 'relevanssi_throttle' );
111
  delete_option( 'relevanssi_throttle_limit' );
106
  delete_option( 'relevanssi_show_post_controls' );
107
  delete_option( 'relevanssi_stopwords' );
108
  delete_option( 'relevanssi_synonyms' );
109
+ delete_option( 'relevanssi_terms_count' );
110
  delete_option( 'relevanssi_thousand_separator' );
111
  delete_option( 'relevanssi_throttle' );
112
  delete_option( 'relevanssi_throttle_limit' );
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === Relevanssi - A Better Search ===
2
  Contributors: msaari
3
  Donate link: https://www.relevanssi.com/buy-premium/
4
- Tags: search, relevance, better search
5
  Requires at least: 4.9
6
- Tested up to: 5.4
7
- Requires PHP: 5.6
8
- Stable tag: 4.7.2.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -113,6 +113,18 @@ to your search results template inside a PHP code block to display the relevance
113
  = Did you mean? suggestions =
114
  Relevanssi offers Google-style "Did you mean?" suggestions. See ["Did you mean" suggestions](https://www.relevanssi.com/knowledge-base/did-you-mean-suggestions/) in the Knowledge Base for more details.
115
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  == Thanks ==
117
  * Cristian Damm for tag indexing, comment indexing, post/page exclusion and general helpfulness.
118
  * Marcus Dalgren for UTF-8 fixing.
@@ -121,10 +133,19 @@ Relevanssi offers Google-style "Did you mean?" suggestions. See ["Did you mean"
121
  * John Calahan for extensive 4.0 beta testing.
122
 
123
  == Changelog ==
124
- = 4.7.2.1 =
125
- * For some reason the plugin files didn't update in the previous update, ie. 4.7.2 is equal to 4.7.1. This is the real 4.7.2 update.
126
- * Minor fix: Media Library searches failed if Relevanssi was enabled in the WP admin, but the `attachment` post type wasn't indexed. Relevanssi will no longer block the default Media Library search in these cases.
127
- * Minor fix: Adds more backwards compatibility for the `relevanssi_indexing_restriction` change, there's now an alert on indexing tab if there's a problem.
 
 
 
 
 
 
 
 
 
128
 
129
  = 4.7.2 =
130
  * Minor fix: Media Library searches failed if Relevanssi was enabled in the WP admin, but the `attachment` post type wasn't indexed. Relevanssi will no longer block the default Media Library search in these cases.
@@ -142,9 +163,13 @@ Relevanssi offers Google-style "Did you mean?" suggestions. See ["Did you mean"
142
  * Changed behaviour: Content stopwords are removed from the search queries when doing excerpts and highlights. When Relevanssi uses the untokenized search terms for excerpt-building, stopwords are removed from those words. This should lead to better excerpts.
143
  * Minor fix: Improves handling of emoji in indexing. If the database supports emoji, they are allowed, otherwise they are encoded.
144
 
 
 
 
 
145
  == Upgrade notice ==
146
- = 4.7.2.1 =
147
- * The actual 4.7.2 upgrade.
148
 
149
  = 4.7.2 =
150
  * Improved backwards compatibility for the `relevanssi_indexing_restriction` filter hook change, better Media Library support.
@@ -154,3 +179,6 @@ Relevanssi offers Google-style "Did you mean?" suggestions. See ["Did you mean"
154
 
155
  = 4.7.0 =
156
  * The `relevanssi_indexing_restriction` filter hook has been changed, stopwords are handled in a different way in excerpts.
 
 
 
1
  === Relevanssi - A Better Search ===
2
  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.5
7
+ Requires PHP: 7.0
8
+ Stable tag: 4.8.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
113
  = Did you mean? suggestions =
114
  Relevanssi offers Google-style "Did you mean?" suggestions. See ["Did you mean" suggestions](https://www.relevanssi.com/knowledge-base/did-you-mean-suggestions/) in the Knowledge Base for more details.
115
 
116
+ = What is tf * idf weighing? =
117
+
118
+ It's the basic weighing scheme used in information retrieval. Tf stands for *term frequency* while idf is *inverted document frequency*. Term frequency is simply the number of times the term appears in a document, while document frequency is the number of documents in the database where the term appears.
119
+
120
+ Thus, the weight of the word for a document increases the more often it appears in the document and the less often it appears in other documents.
121
+
122
+ = What are stop words? =
123
+
124
+ Each document database is full of useless words. All the little words that appear in just about every document are completely useless for information retrieval purposes. Basically, their inverted document frequency is really low, so they never have much power in matching. Also, removing those words helps to make the index smaller and searching faster.
125
+
126
+ [](http://coderisk.com/wp/plugin/relevanssi/RIPS-XC1ekC4JKr)
127
+
128
  == Thanks ==
129
  * Cristian Damm for tag indexing, comment indexing, post/page exclusion and general helpfulness.
130
  * Marcus Dalgren for UTF-8 fixing.
133
  * John Calahan for extensive 4.0 beta testing.
134
 
135
  == Changelog ==
136
+ = 4.8.0 =
137
+ * Changed behaviour: Relevanssi now requires PHP 7.
138
+ * Changed behaviour: Relevanssi now sorts strings with `strnatcasecmp()` instead of `strcasecmp()`, leading to a more natural results with strings that include numbers.
139
+ * Changed behaviour: Relevanssi init is now moved from priority 10 to priority 1 on the `init` hook to avoid problems with missing TablePress compatibility.
140
+ * New feature: New filter hook `relevanssi_get_approved_comments_args` filters the arguments to `get_approved_comments` in comment indexing. This can be used to index custom comment types, for example.
141
+ * New feature: Content wrapped in the `noindex` tags is no longer used for excerpts.
142
+ * New feature: The `[et_pb_fullwidth_code]` shortcode is now removed completely, including the contents, when Relevanssi is indexing and building excerpts.
143
+ * Major fix: Relevanssi didn't index new comments when they were added; when a post was indexed or the whole index rebuilt, comment content was included. We don't know how long this bug has existed, but it is now fixed. Rebuild the index to get all comment content included in the index.
144
+ * Minor fix: Autoload has been disabled for several options that are not needed often.
145
+ * Minor fix: Phrase matching did not work correctly in visible custom fields.
146
+ * Minor fix: TablePress support could cause halting errors if posts were inserted before Relevanssi has loaded itself (on `init` priority 10). These errors will no longer happen.
147
+ * Minor fix: The doc count update, which is a heavy task, is now moved to an asynchronous action to avoid slowing down the site for users.
148
+ * Minor fix: Relevanssi only updates doc count on `relevanssi_insert_edit()` when the post is indexed.
149
 
150
  = 4.7.2 =
151
  * Minor fix: Media Library searches failed if Relevanssi was enabled in the WP admin, but the `attachment` post type wasn't indexed. Relevanssi will no longer block the default Media Library search in these cases.
163
  * Changed behaviour: Content stopwords are removed from the search queries when doing excerpts and highlights. When Relevanssi uses the untokenized search terms for excerpt-building, stopwords are removed from those words. This should lead to better excerpts.
164
  * Minor fix: Improves handling of emoji in indexing. If the database supports emoji, they are allowed, otherwise they are encoded.
165
 
166
+ = 4.6.0 =
167
+ * Changed behaviour: Phrases in OR search are now less restrictive. A search for 'foo "bar baz"' used to only return posts with the "bar baz" phrase, but now also posts with just the word 'foo' will be returned.
168
+ * Minor fix: User Access Manager showed drafts in search results for all users. This is now fixed.
169
+
170
  == Upgrade notice ==
171
+ = 4.8.0 =
172
+ * Fixes a major bug in comment indexing, if you include comments in the index rebuild the index after updating.
173
 
174
  = 4.7.2 =
175
  * Improved backwards compatibility for the `relevanssi_indexing_restriction` filter hook change, better Media Library support.
179
 
180
  = 4.7.0 =
181
  * The `relevanssi_indexing_restriction` filter hook has been changed, stopwords are handled in a different way in excerpts.
182
+
183
+ = 4.6.0 =
184
+ * Changes how phrases work in OR search and fixes a User Access Manager issue.
relevanssi.php CHANGED
@@ -13,10 +13,12 @@
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.7.2.1
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
 
 
20
  */
21
 
22
  /**
@@ -65,7 +67,7 @@ $relevanssi_variables['database_version'] = 5;
65
  $relevanssi_variables['file'] = __FILE__;
66
  $relevanssi_variables['plugin_dir'] = plugin_dir_path( __FILE__ );
67
  $relevanssi_variables['plugin_basename'] = plugin_basename( __FILE__ );
68
- $relevanssi_variables['plugin_version'] = '4.7.2.1';
69
 
70
  require_once 'lib/admin-ajax.php';
71
  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.8.0
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
20
+ * License: GPLv2 or later
21
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
22
  */
23
 
24
  /**
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.8.0';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';
uninstall.php CHANGED
@@ -24,8 +24,8 @@ if ( function_exists( 'is_multisite' ) && is_multisite() ) {
24
  foreach ( $blogids as $uninstall_blog_id ) {
25
  switch_to_blog( $uninstall_blog_id );
26
  relevanssi_uninstall_free();
 
27
  }
28
- switch_to_blog( $old_blogid );
29
  } else {
30
  relevanssi_uninstall_free();
31
  }
24
  foreach ( $blogids as $uninstall_blog_id ) {
25
  switch_to_blog( $uninstall_blog_id );
26
  relevanssi_uninstall_free();
27
+ restore_current_blog();
28
  }
 
29
  } else {
30
  relevanssi_uninstall_free();
31
  }