Relevanssi – A Better Search - Version 4.15.1

Version Description

  • Changed behaviour: Relevanssi now ignores WordPress metadata custom fields that aren't interesting for Relevanssi indexing.
  • Changed behaviour: Both relevanssi_get_permalink() and relevanssi_the_permalink() now can take post ID or a post object as a parameter and can thus be used outside the Loop.
  • Changed behaviour: The relevanssi_hits_filter hook now gets the WP_Query object as the second parameter.
  • Minor fix: Avoid error messages for missing mysqlcolumn_matches array key.
Download this release

Release Info

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

Code changes from version 4.16.0 to 4.15.1

lib/class-relevanssi-taxonomy-walker.php CHANGED
@@ -57,18 +57,18 @@ class Relevanssi_Taxonomy_Walker extends Walker_Category_Checklist {
57
  $aria_checked = 'false';
58
  $inner_class = 'category';
59
 
 
60
  $output .= "\n" . '<li' . $class . '>' .
61
  '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
62
  ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
63
- /** This filter is documented in wp-includes/category-template.php */
64
- esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
65
  } else {
 
66
  $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
67
  '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
68
  checked( in_array( intval( $category->term_id ), $args['selected_cats'], true ), true, false ) .
69
  disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
70
- /** This filter is documented in wp-includes/category-template.php */
71
- esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
72
  }
73
  }
74
  }
57
  $aria_checked = 'false';
58
  $inner_class = 'category';
59
 
60
+ /** This filter is documented in wp-includes/category-template.php */
61
  $output .= "\n" . '<li' . $class . '>' .
62
  '<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
63
  ' tabindex="0" role="checkbox" aria-checked="' . $aria_checked . '">' .
64
+ esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
 
65
  } else {
66
+ /** This filter is documented in wp-includes/category-template.php */
67
  $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
68
  '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
69
  checked( in_array( intval( $category->term_id ), $args['selected_cats'], true ), true, false ) .
70
  disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
71
+ esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
 
72
  }
73
  }
74
  }
lib/common.php CHANGED
@@ -224,7 +224,7 @@ function relevanssi_default_post_ok( $post_ok, $post_id ) {
224
  apply_filters( 'relevanssi_valid_admin_status', array( 'draft', 'pending', 'future' ) ),
225
  true
226
  )
227
- && is_admin() && ! relevanssi_is_live_search() ) {
228
  // Only show drafts, pending and future posts in admin search.
229
  $post_ok = true;
230
  }
@@ -1226,7 +1226,6 @@ function relevanssi_get_forbidden_post_types() {
1226
  'astra_adv_header', // Astra.
1227
  'udb_widgets', // Ultimate Dashboard.
1228
  'udb_admin_page', // Ultimate Dashboard.
1229
- 'oxy_user_library', // Oxygen.
1230
  );
1231
  }
1232
 
@@ -1731,9 +1730,6 @@ function relevanssi_replace_synonyms_in_terms( array $terms ) : array {
1731
  function ( $term ) use ( $synonyms ) {
1732
  $new_term = array();
1733
  foreach ( $synonyms as $pair ) {
1734
- if ( empty( $pair ) ) {
1735
- continue;
1736
- }
1737
  list( $key, $value ) = explode( '=', $pair );
1738
  if ( $value === $term ) {
1739
  $new_term[] = $key;
224
  apply_filters( 'relevanssi_valid_admin_status', array( 'draft', 'pending', 'future' ) ),
225
  true
226
  )
227
+ && is_admin() ) {
228
  // Only show drafts, pending and future posts in admin search.
229
  $post_ok = true;
230
  }
1226
  'astra_adv_header', // Astra.
1227
  'udb_widgets', // Ultimate Dashboard.
1228
  'udb_admin_page', // Ultimate Dashboard.
 
1229
  );
1230
  }
1231
 
1730
  function ( $term ) use ( $synonyms ) {
1731
  $new_term = array();
1732
  foreach ( $synonyms as $pair ) {
 
 
 
1733
  list( $key, $value ) = explode( '=', $pair );
1734
  if ( $value === $term ) {
1735
  $new_term[] = $key;
lib/compatibility/oxygen.php CHANGED
@@ -35,23 +35,6 @@ add_action( 'save_post', 'relevanssi_insert_edit', 99, 1 );
35
  * @return array|null An array of custom field values, null if no value exists.
36
  */
37
  function relevanssi_oxygen_compatibility( $value, $field, $post_id ) {
38
- if ( 'ct_builder_json' === $field ) {
39
- $json = array();
40
- foreach ( $value as $row ) {
41
- $json[] = json_decode( $row );
42
- }
43
-
44
- $content = '';
45
- if ( isset( $json[0]->children ) ) {
46
- foreach ( $json[0]->children as $child ) {
47
- $content .= relevanssi_process_oxygen_child( $child );
48
- }
49
- }
50
-
51
- $value[0] = $content;
52
- return $value;
53
- }
54
-
55
  if ( 'ct_builder_shortcodes_revisions_dates' === $field ) {
56
  return '';
57
  }
@@ -59,9 +42,6 @@ function relevanssi_oxygen_compatibility( $value, $field, $post_id ) {
59
  return '';
60
  }
61
  if ( 'ct_builder_shortcodes' === $field ) {
62
- if ( version_compare( CT_VERSION, '4.0', '>=' ) ) {
63
- return null;
64
- }
65
  if ( empty( $value ) ) {
66
  return null;
67
  }
@@ -138,66 +118,18 @@ function relevanssi_oxygen_compatibility( $value, $field, $post_id ) {
138
  }
139
 
140
  /**
141
- * Recursively processes the Oxygen JSON data.
142
- *
143
- * This function extracts all the ct_content data from the JSON. All elements
144
- * are run through the relevanssi_oxygen_element filter hook. You can use that
145
- * filter hook to modify or to eliminate elements from the JSON.
146
- *
147
- * @param array $child The child element array.
148
- *
149
- * @return string The content from the child and the grandchildren.
150
- */
151
- function relevanssi_process_oxygen_child( $child ) : string {
152
- /**
153
- * Filters the Oxygen JSON child element.
154
- *
155
- * If the filter returns an empty value, the child element and all its
156
- * children will be ignored.
157
- *
158
- * @param array $child The JSON child element.
159
- */
160
- $child = apply_filters( 'relevanssi_oxygen_element', $child );
161
- if ( empty( $child ) ) {
162
- return '';
163
- }
164
-
165
- $child_content = ' ';
166
- if ( isset( $child->options->ct_content ) ) {
167
- $child_content .= $child->options->ct_content;
168
- }
169
-
170
- if ( isset( $child->options->original->{'code-php'} ) ) {
171
- // For code and HTML blocks, strip all tags.
172
- $child_content .= wp_strip_all_tags( $child->options->original->{'code-php'} );
173
- }
174
-
175
- if ( isset( $child->children ) ) {
176
- foreach ( $child->children as $grandchild ) {
177
- $child_content .= relevanssi_process_oxygen_child( $grandchild );
178
- }
179
- }
180
-
181
- return $child_content;
182
- }
183
-
184
- /**
185
- * Adds the Oxygen custom field to the list of indexed custom fields.
186
  *
187
  * @param array|boolean $fields An array of custom fields to index, or false.
188
  *
189
- * @return array An array of custom fields, including `ct_builder_json` or
190
- * `ct_builder_shortcodes`.
191
  */
192
  function relevanssi_add_oxygen( $fields ) {
193
- $oxygen_field = version_compare( CT_VERSION, '4.0', '>=' )
194
- ? 'ct_builder_json'
195
- : 'ct_builder_shortcodes';
196
  if ( ! is_array( $fields ) ) {
197
  $fields = array();
198
  }
199
- if ( ! in_array( $oxygen_field, $fields, true ) ) {
200
- $fields[] = $oxygen_field;
201
  }
202
 
203
  return $fields;
@@ -211,14 +143,11 @@ function relevanssi_add_oxygen( $fields ) {
211
  * is ignored, Relevanssi disables this filter and then checks the option to
212
  * see what the value is.
213
  *
214
- * @return string If value is undefined, it's set to 'ct_builder_json' or
215
- * 'ct_builder_shortcodes'.
216
  */
217
  function relevanssi_oxygen_fix_none_setting( $value ) {
218
  if ( ! $value ) {
219
- $value = version_compare( CT_VERSION, '4.0', '>=' )
220
- ? 'ct_builder_json'
221
- : 'ct_builder_shortcodes';
222
  }
223
 
224
  return $value;
35
  * @return array|null An array of custom field values, null if no value exists.
36
  */
37
  function relevanssi_oxygen_compatibility( $value, $field, $post_id ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  if ( 'ct_builder_shortcodes_revisions_dates' === $field ) {
39
  return '';
40
  }
42
  return '';
43
  }
44
  if ( 'ct_builder_shortcodes' === $field ) {
 
 
 
45
  if ( empty( $value ) ) {
46
  return null;
47
  }
118
  }
119
 
120
  /**
121
+ * Adds the `ct_builder_shortcodes` to the list of indexed custom fields.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  *
123
  * @param array|boolean $fields An array of custom fields to index, or false.
124
  *
125
+ * @return array An array of custom fields, including `ct_builder_shortcodes`.
 
126
  */
127
  function relevanssi_add_oxygen( $fields ) {
 
 
 
128
  if ( ! is_array( $fields ) ) {
129
  $fields = array();
130
  }
131
+ if ( ! in_array( 'ct_builder_shortcodes', $fields, true ) ) {
132
+ $fields[] = 'ct_builder_shortcodes';
133
  }
134
 
135
  return $fields;
143
  * is ignored, Relevanssi disables this filter and then checks the option to
144
  * see what the value is.
145
  *
146
+ * @return string If value is undefined, it's set to 'ct_builder_shortcodes'.
 
147
  */
148
  function relevanssi_oxygen_fix_none_setting( $value ) {
149
  if ( ! $value ) {
150
+ $value = 'ct_builder_shortcodes';
 
 
151
  }
152
 
153
  return $value;
lib/didyoumean.php CHANGED
@@ -161,22 +161,6 @@ function relevanssi_simple_generate_suggestion( $query ) {
161
  $suggestion = '';
162
 
163
  foreach ( $tokens as $token => $count ) {
164
- /**
165
- * Filters the tokens for Did you mean suggestions.
166
- *
167
- * You can use this filter hook to modify the tokens before Relevanssi
168
- * tries to come up with Did you mean suggestions for them. If you
169
- * return an empty string, the token will be skipped and no suggestion
170
- * will be made for the token.
171
- *
172
- * @param string $token An individual word from the search query.
173
- *
174
- * @return string The token.
175
- */
176
- $token = apply_filters( 'relevanssi_didyoumean_token', trim( $token ) );
177
- if ( ! $token ) {
178
- continue;
179
- }
180
  $closest = '';
181
  $distance = -1;
182
  foreach ( $data as $row ) {
161
  $suggestion = '';
162
 
163
  foreach ( $tokens as $token => $count ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  $closest = '';
165
  $distance = -1;
166
  foreach ( $data as $row ) {
lib/excerpts-highlights.php CHANGED
@@ -122,11 +122,7 @@ function relevanssi_do_excerpt( $t_post, $query, $excerpt_length = null, $excerp
122
 
123
  // Add the custom field content.
124
  if ( 'on' === get_option( 'relevanssi_excerpt_custom_fields' ) ) {
125
- if ( 'user' === $post->post_type && function_exists( 'relevanssi_get_user_custom_field_content' ) ) {
126
- $content .= relevanssi_get_user_custom_field_content( $post->ID );
127
- } else {
128
- $content .= relevanssi_get_custom_field_content( $post->ID );
129
- }
130
  }
131
 
132
  /**
@@ -996,11 +992,9 @@ function relevanssi_extract_locations( $words, $fulltext ) {
996
  * @return int Number of times the words appear in the text.
997
  */
998
  function relevanssi_count_matches( $words, $complete_text ) {
999
- $count = 0;
1000
- $text = '';
1001
-
1002
- // Add the space in case the match is the last word in the text.
1003
- $lowercase_text = relevanssi_strtolower( $complete_text, 'UTF-8' ) . ' ';
1004
 
1005
  $count_words = count( $words );
1006
  for ( $t = 0; $t < $count_words; $t++ ) {
122
 
123
  // Add the custom field content.
124
  if ( 'on' === get_option( 'relevanssi_excerpt_custom_fields' ) ) {
125
+ $content .= relevanssi_get_custom_field_content( $post->ID );
 
 
 
 
126
  }
127
 
128
  /**
992
  * @return int Number of times the words appear in the text.
993
  */
994
  function relevanssi_count_matches( $words, $complete_text ) {
995
+ $count = 0;
996
+ $lowercase_text = relevanssi_strtolower( $complete_text, 'UTF-8' );
997
+ $text = '';
 
 
998
 
999
  $count_words = count( $words );
1000
  for ( $t = 0; $t < $count_words; $t++ ) {
lib/init.php CHANGED
@@ -43,7 +43,6 @@ add_action( 'edit_attachment', 'relevanssi_insert_edit' );
43
  add_action( 'transition_post_status', 'relevanssi_update_child_posts', 99, 3 );
44
 
45
  // Relevanssi features.
46
- add_filter( 'relevanssi_remove_punctuation', 'remove_accents', 9 );
47
  add_filter( 'relevanssi_remove_punctuation', 'relevanssi_remove_punct' );
48
  add_filter( 'relevanssi_post_ok', 'relevanssi_default_post_ok', 9, 2 );
49
  add_filter( 'relevanssi_query_filter', 'relevanssi_limit_filter' );
43
  add_action( 'transition_post_status', 'relevanssi_update_child_posts', 99, 3 );
44
 
45
  // Relevanssi features.
 
46
  add_filter( 'relevanssi_remove_punctuation', 'relevanssi_remove_punct' );
47
  add_filter( 'relevanssi_post_ok', 'relevanssi_default_post_ok', 9, 2 );
48
  add_filter( 'relevanssi_query_filter', 'relevanssi_limit_filter' );
lib/options.php CHANGED
@@ -80,13 +80,6 @@ function update_relevanssi_options( array $request ) {
80
  update_option( 'relevanssi_show_matches_text', $value );
81
  }
82
  relevanssi_update_intval( $request, 'relevanssi_excerpt_length', true, 10 );
83
-
84
- if ( isset( $request['relevanssi_excerpt_allowable_tags'] ) ) {
85
- $value = $request['relevanssi_excerpt_allowable_tags'];
86
- $value = str_replace( array( ' ', '/' ), '', $value );
87
- $value = implode( '>', array_unique( explode( '>', $value ) ) );
88
- update_option( 'relevanssi_excerpt_allowable_tags', $value );
89
- }
90
  }
91
 
92
  relevanssi_process_weights_and_indexing( $request );
@@ -106,6 +99,7 @@ function update_relevanssi_options( array $request ) {
106
  'relevanssi_default_orderby' => true,
107
  'relevanssi_disable_or_fallback' => true,
108
  'relevanssi_exact_match_bonus' => true,
 
109
  'relevanssi_excerpt_custom_fields' => true,
110
  'relevanssi_excerpt_type' => true,
111
  'relevanssi_excerpts' => true,
80
  update_option( 'relevanssi_show_matches_text', $value );
81
  }
82
  relevanssi_update_intval( $request, 'relevanssi_excerpt_length', true, 10 );
 
 
 
 
 
 
 
83
  }
84
 
85
  relevanssi_process_weights_and_indexing( $request );
99
  'relevanssi_default_orderby' => true,
100
  'relevanssi_disable_or_fallback' => true,
101
  'relevanssi_exact_match_bonus' => true,
102
+ 'relevanssi_excerpt_allowable_tags' => true,
103
  'relevanssi_excerpt_custom_fields' => true,
104
  'relevanssi_excerpt_type' => true,
105
  'relevanssi_excerpts' => true,
lib/phrases.php CHANGED
@@ -48,7 +48,7 @@ function relevanssi_extract_phrases( string $query ) {
48
  $phrase = trim( $phrase );
49
 
50
  // Do not count single-word phrases as phrases.
51
- if ( relevanssi_is_multiple_words( $phrase ) ) {
52
  $phrases[] = $phrase;
53
  }
54
  $pos = $end + 1;
@@ -175,11 +175,10 @@ $custom_fields, string $excerpts ) : array {
175
  $phrase_queries = array();
176
 
177
  foreach ( $phrases as $phrase ) {
178
- $queries = array();
179
- $phrase = $wpdb->esc_like( $phrase );
180
- $phrase = str_replace( array( '‘', '’', "'", '"', '”', '“', '“', '„', '´' ), '_', $phrase );
181
- $title_phrase = $phrase;
182
- $phrase = htmlspecialchars( $phrase );
183
 
184
  /**
185
  * Filters each phrase before it's passed through esc_sql() and used in
@@ -199,7 +198,7 @@ $custom_fields, string $excerpts ) : array {
199
 
200
  $query = "(SELECT ID FROM $wpdb->posts
201
  WHERE (post_content LIKE '%$phrase%'
202
- OR post_title LIKE '%$title_phrase%' $excerpt)
203
  AND post_status IN ($status))";
204
 
205
  $queries[] = array(
48
  $phrase = trim( $phrase );
49
 
50
  // Do not count single-word phrases as phrases.
51
+ if ( ! empty( $phrase ) && count( explode( ' ', $phrase ) ) > 1 ) {
52
  $phrases[] = $phrase;
53
  }
54
  $pos = $end + 1;
175
  $phrase_queries = array();
176
 
177
  foreach ( $phrases as $phrase ) {
178
+ $queries = array();
179
+ $phrase = $wpdb->esc_like( $phrase );
180
+ $phrase = str_replace( array( '‘', '’', "'", '"', '”', '“', '“', '„', '´' ), '_', $phrase );
181
+ $phrase = htmlspecialchars( $phrase );
 
182
 
183
  /**
184
  * Filters each phrase before it's passed through esc_sql() and used in
198
 
199
  $query = "(SELECT ID FROM $wpdb->posts
200
  WHERE (post_content LIKE '%$phrase%'
201
+ OR post_title LIKE '%$phrase%' $excerpt)
202
  AND post_status IN ($status))";
203
 
204
  $queries[] = array(
lib/search-query-restrictions.php CHANGED
@@ -579,14 +579,7 @@ function relevanssi_process_post_status( $post_status ) {
579
  }
580
 
581
  if ( $escaped_post_status ) {
582
- $block_non_post_results = false;
583
  if ( $wp_query->is_admin || $relevanssi_admin_test ) {
584
- $block_non_post_results = true;
585
- }
586
- if ( $wp_query->is_admin && isset( $wp_query->query_vars['action'] ) && 'relevanssi_live_search' === $wp_query->query_vars['action'] ) {
587
- $block_non_post_results = false;
588
- }
589
- if ( $block_non_post_results ) {
590
  $query_restrictions .= " AND ((relevanssi.doc IN (SELECT DISTINCT(posts.ID) FROM $wpdb->posts AS posts
591
  WHERE posts.post_status IN ($escaped_post_status))))";
592
  } else {
579
  }
580
 
581
  if ( $escaped_post_status ) {
 
582
  if ( $wp_query->is_admin || $relevanssi_admin_test ) {
 
 
 
 
 
 
583
  $query_restrictions .= " AND ((relevanssi.doc IN (SELECT DISTINCT(posts.ID) FROM $wpdb->posts AS posts
584
  WHERE posts.post_status IN ($escaped_post_status))))";
585
  } else {
lib/utils.php CHANGED
@@ -698,85 +698,6 @@ function relevanssi_intval( array $request, string $option ) {
698
  return null;
699
  }
700
 
701
- /**
702
- * Returns true if the search is from Relevanssi Live Ajax Search.
703
- *
704
- * Checks if $wp_query->query_vars['action'] is set to "relevanssi_live_search".
705
- *
706
- * @return bool True if the search is from Relevanssi Live Ajax Search, false
707
- * otherwise.
708
- */
709
- function relevanssi_is_live_search() {
710
- global $wp_query;
711
- $relevanssi_live_search = false;
712
- if ( isset( $wp_query->query_vars['action'] ) && 'relevanssi_live_search' === $wp_query->query_vars['action'] ) {
713
- $relevanssi_live_search = true;
714
- }
715
- return $relevanssi_live_search;
716
- }
717
-
718
- /**
719
- * Checks if a string is a multiple-word phrase.
720
- *
721
- * Replaces hyphens, quotes and ampersands with spaces if necessary based on
722
- * the Relevanssi advanced indexing settings.
723
- *
724
- * @param string $string The string to check.
725
- *
726
- * @return boolean True if the string is a multiple-word phrase, false otherwise.
727
- */
728
- function relevanssi_is_multiple_words( string $string ) : bool {
729
- if ( empty( $string ) ) {
730
- return false;
731
- }
732
- $punctuation = get_option( 'relevanssi_punctuation' );
733
- if ( 'replace' === $punctuation['hyphens'] ) {
734
- $string = str_replace(
735
- array(
736
- '-',
737
- '–',
738
- '—',
739
- ),
740
- ' ',
741
- $string
742
- );
743
- }
744
- if ( 'replace' === $punctuation['quotes'] ) {
745
- $string = str_replace(
746
- array(
747
- '&#8217;',
748
- "'",
749
- '’',
750
- '‘',
751
- '”',
752
- '“',
753
- '„',
754
- '´',
755
- '″',
756
- ),
757
- ' ',
758
- $string
759
- );
760
- }
761
- if ( 'replace' === $punctuation['ampersands'] ) {
762
- $string = str_replace(
763
- array(
764
- '&#038;',
765
- '&amp;',
766
- '&',
767
- ),
768
- ' ',
769
- $string
770
- );
771
- }
772
-
773
- if ( count( explode( ' ', $string ) ) > 1 ) {
774
- return true;
775
- }
776
-
777
- return false;
778
- }
779
-
780
  /**
781
  * Launches an asynchronous Ajax action.
782
  *
@@ -1086,10 +1007,9 @@ function relevanssi_strip_all_tags( $content ) : string {
1086
  if ( ! is_string( $content ) ) {
1087
  $content = '';
1088
  }
1089
- $content = preg_replace( '/<!--.*?-->/ums', '', $content );
1090
- $content = preg_replace( '/<[!a-zA-Z\/][^>].*?>/ums', ' ', $content );
1091
-
1092
- return $content ?? '';
1093
  }
1094
 
1095
  /**
@@ -1155,7 +1075,6 @@ function relevanssi_strip_tags( $content ) {
1155
  '/(<\/?hr.*?>)/',
1156
  '/(<\/?li.*?>)/',
1157
  '/(<img.*?>)/',
1158
- '/(<\/td>)/',
1159
  );
1160
 
1161
  $content = preg_replace( $space_tags, '$1 ', $content );
698
  return null;
699
  }
700
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
  /**
702
  * Launches an asynchronous Ajax action.
703
  *
1007
  if ( ! is_string( $content ) ) {
1008
  $content = '';
1009
  }
1010
+ $content = preg_replace( '/<!--.*?-->/ms', '', $content );
1011
+ $content = preg_replace( '/<[!a-zA-Z\/][^>].*?>/ms', ' ', $content );
1012
+ return $content;
 
1013
  }
1014
 
1015
  /**
1075
  '/(<\/?hr.*?>)/',
1076
  '/(<\/?li.*?>)/',
1077
  '/(<img.*?>)/',
 
1078
  );
1079
 
1080
  $content = preg_replace( $space_tags, '$1 ', $content );
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: 6.0
7
  Requires PHP: 7.0
8
- Stable tag: 4.16.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -128,21 +128,6 @@ Each document database is full of useless words. All the little words that appea
128
  * John Calahan for extensive 4.0 beta testing.
129
 
130
  == Changelog ==
131
- = 4.16.0 =
132
- * New feature: Oxygen compatibility has been upgraded to support JSON data from Oxygen 4. This is still in early stages, so feedback from Oxygen users is welcome.
133
- * New feature: New filter hook `relevanssi_oxygen_element` is used to filter Oxygen JSON elements. The earlier `relevanssi_oxygen_section_filters` and `relevanssi_oxygen_section_content` filters are no longer used with Oxygen 4; this hook is the only way to filter Oxygen elements.
134
- * Changed behaviour: Relevanssi now applies `remove_accents()` to all strings. This is because default database collations do not care for accents and having accents may cause missing information in indexing. If you use a database collation that doesn't ignore accents, make sure you disable this filter.
135
- * Minor fix: Relevanssi used `the_category` filter with too few parameters. The missing parameters have been added.
136
- * Minor fix: Stops drafts and pending posts from showing up in Relevanssi Live Ajax Searches.
137
- * Minor fix: Phrases weren't used in some cases where a multiple-word phrase looked like a single-word phrase.
138
- * Minor fix: Prevents fatal errors from `relevanssi_strip_all_tags()`.
139
-
140
- = 4.15.2 =
141
- * New feature: New filter hook `relevanssi_didyoumean_token` lets you filter Did you mean words before correction. You can use this filter hook to exclude words from being corrected.
142
- * Minor fix: Phrase search couldn't find phrases that include an ampersand if they matched the post title. This works now.
143
- * Minor fix: Relevanssi now adds spaces after table cell tags to avoid table cell content sticking together in excerpts.
144
- * Minor fix: The 'Allowable tags in excerpts' function now automatically corrects the entered value to match what Relevanssi expects the value to be.
145
-
146
  = 4.15.1 =
147
  * Changed behaviour: Relevanssi now ignores WordPress metadata custom fields that aren't interesting for Relevanssi indexing.
148
  * Changed behaviour: Both `relevanssi_get_permalink()` and `relevanssi_the_permalink()` now can take post ID or a post object as a parameter and can thus be used outside the Loop.
@@ -161,5 +146,8 @@ Each document database is full of useless words. All the little words that appea
161
  * Minor fix: The Bricks compatibility was improved, Relevanssi now notices changes to Bricks posts more often. Relevanssi also only reads the text from the `_bricks_page_content_2` custom field.
162
 
163
  == Upgrade notice ==
164
- = 4.16.0 =
165
- * Indexing update; please reindex after the upgrade! Oxygen 4 compatibility.
 
 
 
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.9
7
  Requires PHP: 7.0
8
+ Stable tag: 4.15.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
128
  * John Calahan for extensive 4.0 beta testing.
129
 
130
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  = 4.15.1 =
132
  * Changed behaviour: Relevanssi now ignores WordPress metadata custom fields that aren't interesting for Relevanssi indexing.
133
  * Changed behaviour: Both `relevanssi_get_permalink()` and `relevanssi_the_permalink()` now can take post ID or a post object as a parameter and can thus be used outside the Loop.
146
  * Minor fix: The Bricks compatibility was improved, Relevanssi now notices changes to Bricks posts more often. Relevanssi also only reads the text from the `_bricks_page_content_2` custom field.
147
 
148
  == Upgrade notice ==
149
+ = 4.15.1 =
150
+ * Fixes warnings, improves permalink functions and relevanssi_hits_filter.
151
+
152
+ = 4.15.0 =
153
+ * New filter hooks and improved Bricks compatibility.
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.16.0
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
@@ -67,7 +67,7 @@ $relevanssi_variables['database_version'] = 6;
67
  $relevanssi_variables['file'] = __FILE__;
68
  $relevanssi_variables['plugin_dir'] = plugin_dir_path( __FILE__ );
69
  $relevanssi_variables['plugin_basename'] = plugin_basename( __FILE__ );
70
- $relevanssi_variables['plugin_version'] = '4.16.0';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';
13
  * Plugin Name: Relevanssi
14
  * Plugin URI: https://www.relevanssi.com/
15
  * Description: This plugin replaces WordPress search with a relevance-sorting search.
16
+ * Version: 4.15.1
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
67
  $relevanssi_variables['file'] = __FILE__;
68
  $relevanssi_variables['plugin_dir'] = plugin_dir_path( __FILE__ );
69
  $relevanssi_variables['plugin_basename'] = plugin_basename( __FILE__ );
70
+ $relevanssi_variables['plugin_version'] = '4.15.1';
71
 
72
  require_once 'lib/admin-ajax.php';
73
  require_once 'lib/common.php';