Version Description
- Relevanssi didn't index all posts with one go. It does now.
- and symbols caused problems in indexing; they are now included in the default punctuation removal.
- In some cases excerpt-building could take ages because of autoembed link discovery. Relevanssi now blocks the autoembed procedure in link-building.
- New filter:
relevanssi_custom_field_value
is used to filter custom field values both before indexing and before excerpt-building. Parameters include the field name and the post ID. - Updated filter:
relevanssi_index_custom_fields
now gets a second parameter that contains the post ID.
Download this release
Release Info
Developer | msaari |
Plugin | Relevanssi – A Better Search |
Version | 4.0.3 |
Comparing to | |
See all releases |
Code changes from version 4.0.2 to 4.0.3
- lib/admin_ajax.php +1 -1
- lib/admin_scripts.js +3 -3
- lib/admin_styles.css +0 -5
- lib/common.php +11 -9
- lib/excerpts-highlights.php +26 -1
- lib/indexing.php +6 -5
- lib/init.php +14 -1
- lib/install.php +4 -6
- lib/interface.php +16 -19
- lib/search.php +1 -8
- readme.txt +11 -1
- relevanssi.php +1 -1
lib/admin_ajax.php
CHANGED
@@ -29,7 +29,7 @@ function relevanssi_index_posts_ajax_wrapper() {
|
|
29 |
//$limit = apply_filters('relevanssi_ajax_indexing_limit', 50);
|
30 |
if ($extend) $offset = true;
|
31 |
|
32 |
-
$indexing_response = relevanssi_build_index(
|
33 |
|
34 |
if ($indexing_response['indexing_complete']) {
|
35 |
$response['completed'] = "done";
|
29 |
//$limit = apply_filters('relevanssi_ajax_indexing_limit', 50);
|
30 |
if ($extend) $offset = true;
|
31 |
|
32 |
+
$indexing_response = relevanssi_build_index(true, $verbose, $limit, $is_ajax);
|
33 |
|
34 |
if ($indexing_response['indexing_complete']) {
|
35 |
$response['completed'] = "done";
|
lib/admin_scripts.js
CHANGED
@@ -227,16 +227,16 @@ function process_indexing_step(args) {
|
|
227 |
args.limit = args.limit * 2;
|
228 |
// current limit can be indexed in less than two seconds; double the limit
|
229 |
}
|
230 |
-
if (time_seconds < 5) {
|
231 |
args.limit += 5;
|
232 |
// current limit can be indexed in less than five seconds; up the limit
|
233 |
}
|
234 |
-
if (time_seconds > 20) {
|
235 |
args.limit = Math.round(args.limit / 2);
|
236 |
if (args.limit < 1) args.limit = 1;
|
237 |
// current limit takes more than twenty seconds; halve the limit
|
238 |
}
|
239 |
-
if (time_seconds > 10) {
|
240 |
args.limit -= 5;
|
241 |
if (args.limit < 1) args.limit = 1;
|
242 |
// current limit takes more than ten seconds; reduce the limit
|
227 |
args.limit = args.limit * 2;
|
228 |
// current limit can be indexed in less than two seconds; double the limit
|
229 |
}
|
230 |
+
else if (time_seconds < 5) {
|
231 |
args.limit += 5;
|
232 |
// current limit can be indexed in less than five seconds; up the limit
|
233 |
}
|
234 |
+
else if (time_seconds > 20) {
|
235 |
args.limit = Math.round(args.limit / 2);
|
236 |
if (args.limit < 1) args.limit = 1;
|
237 |
// current limit takes more than twenty seconds; halve the limit
|
238 |
}
|
239 |
+
else if (time_seconds > 10) {
|
240 |
args.limit -= 5;
|
241 |
if (args.limit < 1) args.limit = 1;
|
242 |
// current limit takes more than ten seconds; reduce the limit
|
lib/admin_styles.css
CHANGED
@@ -95,9 +95,4 @@ table.form-table table.widefat th {
|
|
95 |
|
96 |
#relevanssi-timer {
|
97 |
display: none;
|
98 |
-
}
|
99 |
-
|
100 |
-
.relevanssi_ul {
|
101 |
-
list-style-type: square;
|
102 |
-
margin-left: 2em;
|
103 |
}
|
95 |
|
96 |
#relevanssi-timer {
|
97 |
display: none;
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
lib/common.php
CHANGED
@@ -490,13 +490,14 @@ function relevanssi_recognize_phrases($q) {
|
|
490 |
if (count($phrases) > 0) {
|
491 |
foreach ($phrases as $phrase) {
|
492 |
$queries = array();
|
493 |
-
$phrase = str_replace(
|
494 |
-
$phrase = str_replace(
|
495 |
-
$phrase = str_replace(
|
496 |
-
$phrase = str_replace(
|
497 |
-
$phrase = str_replace(
|
498 |
-
$phrase = str_replace(
|
499 |
-
$phrase = str_replace(
|
|
|
500 |
$phrase = $wpdb->esc_like($phrase);
|
501 |
$phrase = esc_sql($phrase);
|
502 |
"on" == get_option("relevanssi_index_excerpt") ? $excerpt = " OR post_excerpt LIKE '%$phrase%'" : $excerpt = "";
|
@@ -622,6 +623,8 @@ function relevanssi_remove_punct($a) {
|
|
622 |
"·" => '',
|
623 |
"…" => '',
|
624 |
"€" => '',
|
|
|
|
|
625 |
"­" => '',
|
626 |
" " => ' ',
|
627 |
'’' => ' ',
|
@@ -1061,7 +1064,6 @@ function relevanssi_permalink($content, $link_post = NULL) {
|
|
1061 |
if (isset($post->link))
|
1062 |
$content = $post->link;
|
1063 |
}
|
1064 |
-
$query = get_search_query();
|
1065 |
return $content;
|
1066 |
}
|
1067 |
|
@@ -1141,4 +1143,4 @@ function relevanssi_get_post($id) {
|
|
1141 |
$post = get_post($id);
|
1142 |
}
|
1143 |
return $post;
|
1144 |
-
}
|
490 |
if (count($phrases) > 0) {
|
491 |
foreach ($phrases as $phrase) {
|
492 |
$queries = array();
|
493 |
+
$phrase = str_replace("‘", '_', $phrase);
|
494 |
+
$phrase = str_replace("’", '_', $phrase);
|
495 |
+
$phrase = str_replace("'", '_', $phrase);
|
496 |
+
$phrase = str_replace('"', '_', $phrase);
|
497 |
+
$phrase = str_replace("”", '_', $phrase);
|
498 |
+
$phrase = str_replace("“", '_', $phrase);
|
499 |
+
$phrase = str_replace("„", '_', $phrase);
|
500 |
+
$phrase = str_replace("´", '_', $phrase);
|
501 |
$phrase = $wpdb->esc_like($phrase);
|
502 |
$phrase = esc_sql($phrase);
|
503 |
"on" == get_option("relevanssi_index_excerpt") ? $excerpt = " OR post_excerpt LIKE '%$phrase%'" : $excerpt = "";
|
623 |
"·" => '',
|
624 |
"…" => '',
|
625 |
"€" => '',
|
626 |
+
"®" => '',
|
627 |
+
"©" => '',
|
628 |
"­" => '',
|
629 |
" " => ' ',
|
630 |
'’' => ' ',
|
1064 |
if (isset($post->link))
|
1065 |
$content = $post->link;
|
1066 |
}
|
|
|
1067 |
return $content;
|
1068 |
}
|
1069 |
|
1143 |
$post = get_post($id);
|
1144 |
}
|
1145 |
return $post;
|
1146 |
+
}
|
lib/excerpts-highlights.php
CHANGED
@@ -33,6 +33,9 @@ function relevanssi_do_excerpt($t_post, $query) {
|
|
33 |
if (get_option('relevanssi_excerpt_custom_fields') === "on") {
|
34 |
$content .= relevanssi_get_custom_field_content($post->ID);
|
35 |
}
|
|
|
|
|
|
|
36 |
$content = apply_filters('the_content', $content);
|
37 |
$content = apply_filters('relevanssi_excerpt_content', $content, $post, $query);
|
38 |
|
@@ -651,11 +654,14 @@ function relevanssi_get_custom_field_content($post_id) {
|
|
651 |
if ($remove_underscore_fields) {
|
652 |
if (substr($field, 0, 1) === '_') continue;
|
653 |
}
|
654 |
-
$values = get_post_meta($post_id, $field, false);
|
655 |
if ("" === $values) continue;
|
656 |
foreach ($values as $value) {
|
657 |
// Quick hack : allow indexing of PODS relationship custom fields // TMV
|
658 |
if (is_array($value) && isset($value['post_title'])) $value = $value['post_title'];
|
|
|
|
|
|
|
659 |
$custom_field_content .= " " . $value;
|
660 |
}
|
661 |
}
|
@@ -672,9 +678,28 @@ function relevanssi_remove_page_builder_shortcodes($content) {
|
|
672 |
'/\[\/?vc.*?\]/',
|
673 |
'/\[\/?mk.*?\]/',
|
674 |
'/\[\/?cs_.*?\]/',
|
|
|
675 |
));
|
676 |
$content = preg_replace($search_array, '', $content);
|
677 |
return $content;
|
678 |
}
|
679 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
?>
|
33 |
if (get_option('relevanssi_excerpt_custom_fields') === "on") {
|
34 |
$content .= relevanssi_get_custom_field_content($post->ID);
|
35 |
}
|
36 |
+
|
37 |
+
relevanssi_kill_autoembed();
|
38 |
+
|
39 |
$content = apply_filters('the_content', $content);
|
40 |
$content = apply_filters('relevanssi_excerpt_content', $content, $post, $query);
|
41 |
|
654 |
if ($remove_underscore_fields) {
|
655 |
if (substr($field, 0, 1) === '_') continue;
|
656 |
}
|
657 |
+
$values = apply_filters('relevanssi_custom_field_value', get_post_meta($post_id, $field, false), $field, $post->ID);
|
658 |
if ("" === $values) continue;
|
659 |
foreach ($values as $value) {
|
660 |
// Quick hack : allow indexing of PODS relationship custom fields // TMV
|
661 |
if (is_array($value) && isset($value['post_title'])) $value = $value['post_title'];
|
662 |
+
|
663 |
+
// Flatten other array data
|
664 |
+
if (is_array($value)) $value = implode(" ", $value);
|
665 |
$custom_field_content .= " " . $value;
|
666 |
}
|
667 |
}
|
678 |
'/\[\/?vc.*?\]/',
|
679 |
'/\[\/?mk.*?\]/',
|
680 |
'/\[\/?cs_.*?\]/',
|
681 |
+
'/\[\/?av_.*?\]/',
|
682 |
));
|
683 |
$content = preg_replace($search_array, '', $content);
|
684 |
return $content;
|
685 |
}
|
686 |
|
687 |
+
/**
|
688 |
+
* Kills the autoembed filter hook on the_content. It's an object hook, so this isn't as simple as doing remove_filter().
|
689 |
+
* This needs to be done, because autoembed can take a very, very long time.
|
690 |
+
*/
|
691 |
+
function relevanssi_kill_autoembed() {
|
692 |
+
global $wp_filter;
|
693 |
+
if (isset($wp_filter['the_content']->callbacks)) {
|
694 |
+
foreach ($wp_filter['the_content']->callbacks as $priority => $bucket) {
|
695 |
+
foreach ($bucket as $key => $value) {
|
696 |
+
if (substr($key, -9) === "autoembed") {
|
697 |
+
unset($wp_filter['the_content']->callbacks[$priority][$key]);
|
698 |
+
}
|
699 |
+
}
|
700 |
+
}
|
701 |
+
|
702 |
+
}
|
703 |
+
}
|
704 |
+
|
705 |
?>
|
lib/indexing.php
CHANGED
@@ -412,8 +412,7 @@ function relevanssi_index_doc($indexpost, $remove_first = false, $custom_fields
|
|
412 |
$custom_fields = get_post_custom_keys($post->ID);
|
413 |
$remove_underscore_fields = true;
|
414 |
}
|
415 |
-
$custom_fields = apply_filters('relevanssi_index_custom_fields', $custom_fields);
|
416 |
-
|
417 |
if (is_array($custom_fields)) {
|
418 |
if ($debug) relevanssi_debug_echo("Custom fields to index: " . implode(", ", $custom_fields));
|
419 |
$custom_fields = array_unique($custom_fields); // no reason to index duplicates
|
@@ -423,9 +422,11 @@ function relevanssi_index_doc($indexpost, $remove_first = false, $custom_fields
|
|
423 |
|
424 |
foreach ($custom_fields as $field) {
|
425 |
if ($remove_underscore_fields) {
|
426 |
-
if (substr($field, 0, 1)
|
427 |
}
|
428 |
-
|
|
|
|
|
429 |
if ("" == $values) continue;
|
430 |
foreach ($values as $value) {
|
431 |
// Quick hack : allow indexing of PODS relationship custom fields // TMV
|
@@ -795,7 +796,7 @@ function relevanssi_insert_edit($post_id) {
|
|
795 |
if ( 'auto-draft' == $post_status ) return;
|
796 |
|
797 |
if ( $post_status == 'inherit' ) {
|
798 |
-
$post_type = $wpdb->get_var( "SELECT post_type FROM $wpdb->posts WHERE ID=$post_id" );
|
799 |
$post_status = $wpdb->get_var( "SELECT p.post_status FROM $wpdb->posts p, $wpdb->posts c WHERE c.ID=$post_id AND c.post_parent=p.ID" );
|
800 |
}
|
801 |
|
412 |
$custom_fields = get_post_custom_keys($post->ID);
|
413 |
$remove_underscore_fields = true;
|
414 |
}
|
415 |
+
$custom_fields = apply_filters('relevanssi_index_custom_fields', $custom_fields, $post->ID);
|
|
|
416 |
if (is_array($custom_fields)) {
|
417 |
if ($debug) relevanssi_debug_echo("Custom fields to index: " . implode(", ", $custom_fields));
|
418 |
$custom_fields = array_unique($custom_fields); // no reason to index duplicates
|
422 |
|
423 |
foreach ($custom_fields as $field) {
|
424 |
if ($remove_underscore_fields) {
|
425 |
+
if ($field !== '_relevanssi_pdf_content' && substr($field, 0, 1) === '_') continue;
|
426 |
}
|
427 |
+
|
428 |
+
$values = apply_filters('relevanssi_custom_field_value', get_post_meta($post->ID, $field, false), $field, $post->ID);
|
429 |
+
|
430 |
if ("" == $values) continue;
|
431 |
foreach ($values as $value) {
|
432 |
// Quick hack : allow indexing of PODS relationship custom fields // TMV
|
796 |
if ( 'auto-draft' == $post_status ) return;
|
797 |
|
798 |
if ( $post_status == 'inherit' ) {
|
799 |
+
// $post_type = $wpdb->get_var( "SELECT post_type FROM $wpdb->posts WHERE ID=$post_id" );
|
800 |
$post_status = $wpdb->get_var( "SELECT p.post_status FROM $wpdb->posts p, $wpdb->posts c WHERE c.ID=$post_id AND c.post_parent=p.ID" );
|
801 |
}
|
802 |
|
lib/init.php
CHANGED
@@ -10,7 +10,7 @@ add_action('wp_insert_post', 'relevanssi_insert_edit', 99, 1 ); // added by lump
|
|
10 |
// BEGIN added by renaissancehack
|
11 |
// *_page and *_post hooks do not trigger on attachments
|
12 |
add_action('delete_attachment', 'relevanssi_delete');
|
13 |
-
add_action('add_attachment', 'relevanssi_publish');
|
14 |
add_action('edit_attachment', 'relevanssi_edit');
|
15 |
// When a post status changes, check child posts that inherit their status from parent
|
16 |
add_action('transition_post_status', 'relevanssi_update_child_posts',99,3);
|
@@ -216,6 +216,19 @@ function relevanssi_create_database_tables($relevanssi_db_version) {
|
|
216 |
|
217 |
dbDelta($sql);
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
update_option('relevanssi_db_version', $relevanssi_db_version);
|
220 |
}
|
221 |
|
10 |
// BEGIN added by renaissancehack
|
11 |
// *_page and *_post hooks do not trigger on attachments
|
12 |
add_action('delete_attachment', 'relevanssi_delete');
|
13 |
+
add_action('add_attachment', 'relevanssi_publish', 12);
|
14 |
add_action('edit_attachment', 'relevanssi_edit');
|
15 |
// When a post status changes, check child posts that inherit their status from parent
|
16 |
add_action('transition_post_status', 'relevanssi_update_child_posts',99,3);
|
216 |
|
217 |
dbDelta($sql);
|
218 |
|
219 |
+
$sql = "SHOW INDEX FROM $relevanssi_log_table";
|
220 |
+
$indices = $wpdb->get_results($sql);
|
221 |
+
|
222 |
+
$query_exists = false;
|
223 |
+
foreach ($indices as $index) {
|
224 |
+
if ($index->Key_name == 'query') $query_exists = true;
|
225 |
+
}
|
226 |
+
|
227 |
+
if (!$query_exists) {
|
228 |
+
$sql = "CREATE INDEX query ON $relevanssi_log_table (query)";
|
229 |
+
$wpdb->query($sql);
|
230 |
+
}
|
231 |
+
|
232 |
update_option('relevanssi_db_version', $relevanssi_db_version);
|
233 |
}
|
234 |
|
lib/install.php
CHANGED
@@ -27,7 +27,7 @@ function relevanssi_install($network_wide = false) {
|
|
27 |
_relevanssi_install();
|
28 |
restore_current_blog();
|
29 |
}
|
30 |
-
|
31 |
} else {
|
32 |
_relevanssi_install();
|
33 |
}
|
@@ -81,14 +81,12 @@ function _relevanssi_install() {
|
|
81 |
add_option('relevanssi_db_version', '0');
|
82 |
add_option('relevanssi_wpml_only_current', 'on');
|
83 |
add_option('relevanssi_polylang_all_languages', 'off');
|
84 |
-
add_option('relevanssi_post_type_weights', '');
|
85 |
-
add_option('relevanssi_index_taxonomies_list', array());
|
86 |
add_option('relevanssi_word_boundaries', 'on');
|
87 |
add_option('relevanssi_default_orderby', 'relevance');
|
88 |
-
add_option('
|
|
|
|
|
89 |
|
90 |
-
if (function_exists('relevanssi_premium_install')) relevanssi_premium_install();
|
91 |
-
|
92 |
do_action('relevanssi_update_options');
|
93 |
|
94 |
relevanssi_create_database_tables($relevanssi_variables['database_version']);
|
27 |
_relevanssi_install();
|
28 |
restore_current_blog();
|
29 |
}
|
30 |
+
|
31 |
} else {
|
32 |
_relevanssi_install();
|
33 |
}
|
81 |
add_option('relevanssi_db_version', '0');
|
82 |
add_option('relevanssi_wpml_only_current', 'on');
|
83 |
add_option('relevanssi_polylang_all_languages', 'off');
|
|
|
|
|
84 |
add_option('relevanssi_word_boundaries', 'on');
|
85 |
add_option('relevanssi_default_orderby', 'relevance');
|
86 |
+
add_option('relevanssi_punctuation', array('quotes' => 'replace', 'hyphens' => 'replace', 'ampersands' => 'replace'));
|
87 |
+
|
88 |
+
if (function_exists('relevanssi_premium_install')) relevanssi_premium_install();
|
89 |
|
|
|
|
|
90 |
do_action('relevanssi_update_options');
|
91 |
|
92 |
relevanssi_create_database_tables($relevanssi_variables['database_version']);
|
lib/interface.php
CHANGED
@@ -1028,6 +1028,7 @@ function relevanssi_options_form() {
|
|
1028 |
$serialize_options['relevanssi_index_pdf_parent'] = get_option('relevanssi_index_pdf_parent');
|
1029 |
|
1030 |
$serialize_options['relevanssi_send_pdf_files'] = get_option('relevanssi_send_pdf_files');
|
|
|
1031 |
$serialize_options['relevanssi_link_pdf_files'] = get_option('relevanssi_link_pdf_files');
|
1032 |
|
1033 |
$serialized_options = json_encode($serialize_options);
|
@@ -1035,15 +1036,9 @@ function relevanssi_options_form() {
|
|
1035 |
|
1036 |
echo "<div class='postbox-container'>";
|
1037 |
|
1038 |
-
$this_page = "?page=
|
1039 |
-
|
1040 |
-
|
1041 |
-
$this_page = "?page=relevanssi-premium/relevanssi.php";
|
1042 |
-
}
|
1043 |
-
else {
|
1044 |
-
echo "<form method='post'>";
|
1045 |
-
}
|
1046 |
-
|
1047 |
wp_nonce_field(plugin_basename($relevanssi_variables['file']), 'relevanssi_options');
|
1048 |
|
1049 |
$display_save_button = true;
|
@@ -1510,12 +1505,12 @@ function relevanssi_options_form() {
|
|
1510 |
<table class="form-table">
|
1511 |
<tr>
|
1512 |
<th scope="row">
|
1513 |
-
<label for='relevanssi_excerpts'><?php _e("Custom search result snippets", "relevanssi");
|
1514 |
</th>
|
1515 |
<td>
|
1516 |
<fieldset>
|
1517 |
-
<legend class="screen-reader-text"><?php _e("Create custom search
|
1518 |
-
<label
|
1519 |
<input type='checkbox' name='relevanssi_excerpts' id='relevanssi_excerpts' <?php echo $excerpts ?> />
|
1520 |
<?php _e("Create custom search result snippets", "relevanssi"); ?>
|
1521 |
</label>
|
@@ -1545,26 +1540,28 @@ function relevanssi_options_form() {
|
|
1545 |
<p class="description"><?php _e("List all tags you want to allow in excerpts. For example: <p><a><strong>.", "relevanssi"); ?></p>
|
1546 |
</td>
|
1547 |
</tr>
|
1548 |
-
<tr id="tr_excerpt_custom_fields" <?php if (empty($excerpts)
|
1549 |
<th scope="row">
|
1550 |
-
<label for='relevanssi_excerpt_custom_fields'><?php _e("Use custom fields for excerpts", "relevanssi");
|
1551 |
</th>
|
1552 |
<td>
|
1553 |
<fieldset>
|
1554 |
<legend class="screen-reader-text"><?php _e("Use custom field content for building excerpts", "relevanssi"); ?></legend>
|
1555 |
-
<label
|
1556 |
<input type='checkbox' name='relevanssi_excerpt_custom_fields' id='relevanssi_excerpt_custom_fields' <?php echo $excerpt_custom_fields ?> <?php if (empty($excerpts) || empty($original_index_fields)) echo "disabled='disabled'"; ?>/>
|
1557 |
<?php _e("Use custom field content for building excerpts", "relevanssi"); ?>
|
1558 |
</label>
|
1559 |
</fieldset>
|
1560 |
-
<p class="description"><?php _e("Use the custom fields setting for indexing for excerpt-making as well. Enabling this option will show custom field content in Relevanssi-generated excerpts.", "relevanssi");
|
|
|
|
|
1561 |
|
1562 |
<p class="description"><?php _e("Current custom field setting", 'relevanssi'); ?>:
|
1563 |
<?php
|
1564 |
if ($original_index_fields === "visible") _e("all visible custom fields", 'relevanssi');
|
1565 |
else if ($original_index_fields === "all") _e("all custom fields", 'relevanssi');
|
1566 |
else if (!empty($original_index_fields)) echo "<code>$original_index_fields</code>";
|
1567 |
-
else _e('None selected', 'relevanssi');
|
1568 |
?></p>
|
1569 |
</td>
|
1570 |
</tr>
|
@@ -1957,7 +1954,7 @@ EOH;
|
|
1957 |
<legend class="screen-reader-text"><?php _e("Index the post excerpt", "relevanssi"); ?></legend>
|
1958 |
<label for='relevanssi_index_excerpt'>
|
1959 |
<input type='checkbox' name='relevanssi_index_excerpt' id='relevanssi_index_excerpt' <?php echo $index_excerpt ?> />
|
1960 |
-
<?php _e("Index the post excerpt") ?>
|
1961 |
</label>
|
1962 |
<p class="description"><?php _e("Relevanssi will find posts by the content in the excerpt.", 'relevanssi'); ?></p>
|
1963 |
<?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
|
@@ -2287,7 +2284,7 @@ function rlv_index_filter($block, $post_id) {
|
|
2287 |
"<li>" . __('Building custom excerpts can be slow. If you are not actually using the excerpts, make sure you disable the option.', 'relevanssi') . "</li>" .
|
2288 |
"<li>" . sprintf(__('Custom snippets require that the search results template uses %s to print out the excerpts.', 'relevanssi'), "<code>the_excerpt()</code>") . "</li>" .
|
2289 |
"<li>" . __("Generally, Relevanssi generates the excerpts from post content. If you want to include custom field content in the excerpt-building, this can be done with a simple setting from the excerpt settings.", "relevanssi") . "</li>" .
|
2290 |
-
"<li>" . sprintf(__("If you want more control over what content Relevanssi uses to create the excerpts, you can use the %s and %s filter hooks to adjust the content.", "relevanssi"), "<code>relevanssi_pre_excerpt_content</code>", "<code>
|
2291 |
"<li>" . sprintf(__("Some shortcode do not work well with Relevanssi excerpt-generation. Relevanssi disables some shortcodes automatically to prevent problems. This can be adjusted with the %s filter hook.", "relevanssi"), "<code>relevanssi_disable_shortcodes_excerpt</code>") . "</li>" .
|
2292 |
"<li>" . sprintf(__("If you want Relevanssi to build excerpts faster and don't mind that they may be less than perfect in quality, add a filter that returns true on hook %s.", "relevanssi"), '<code>relevanssi_optimize_excerpts</code>') .
|
2293 |
"<pre>add_filter('relevanssi_optimize_excerpts', '__return_true');</pre></li>" .
|
1028 |
$serialize_options['relevanssi_index_pdf_parent'] = get_option('relevanssi_index_pdf_parent');
|
1029 |
|
1030 |
$serialize_options['relevanssi_send_pdf_files'] = get_option('relevanssi_send_pdf_files');
|
1031 |
+
$serialize_options['relevanssi_read_new_files'] = get_option('relevanssi_read_new_files');
|
1032 |
$serialize_options['relevanssi_link_pdf_files'] = get_option('relevanssi_link_pdf_files');
|
1033 |
|
1034 |
$serialized_options = json_encode($serialize_options);
|
1036 |
|
1037 |
echo "<div class='postbox-container'>";
|
1038 |
|
1039 |
+
$this_page = "?page=" . plugin_basename($relevanssi_variables['file']);
|
1040 |
+
echo "<form method='post'>";
|
1041 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
1042 |
wp_nonce_field(plugin_basename($relevanssi_variables['file']), 'relevanssi_options');
|
1043 |
|
1044 |
$display_save_button = true;
|
1505 |
<table class="form-table">
|
1506 |
<tr>
|
1507 |
<th scope="row">
|
1508 |
+
<label for='relevanssi_excerpts'><?php _e("Custom search result snippets", "relevanssi"); ?></label>
|
1509 |
</th>
|
1510 |
<td>
|
1511 |
<fieldset>
|
1512 |
+
<legend class="screen-reader-text"><?php _e("Create custom search result snippets", "relevanssi"); ?></legend>
|
1513 |
+
<label >
|
1514 |
<input type='checkbox' name='relevanssi_excerpts' id='relevanssi_excerpts' <?php echo $excerpts ?> />
|
1515 |
<?php _e("Create custom search result snippets", "relevanssi"); ?>
|
1516 |
</label>
|
1540 |
<p class="description"><?php _e("List all tags you want to allow in excerpts. For example: <p><a><strong>.", "relevanssi"); ?></p>
|
1541 |
</td>
|
1542 |
</tr>
|
1543 |
+
<tr id="tr_excerpt_custom_fields" <?php if (empty($excerpts)) echo "class='relevanssi_disabled'"; ?>>
|
1544 |
<th scope="row">
|
1545 |
+
<label for='relevanssi_excerpt_custom_fields'><?php _e("Use custom fields for excerpts", "relevanssi"); ?></label>
|
1546 |
</th>
|
1547 |
<td>
|
1548 |
<fieldset>
|
1549 |
<legend class="screen-reader-text"><?php _e("Use custom field content for building excerpts", "relevanssi"); ?></legend>
|
1550 |
+
<label>
|
1551 |
<input type='checkbox' name='relevanssi_excerpt_custom_fields' id='relevanssi_excerpt_custom_fields' <?php echo $excerpt_custom_fields ?> <?php if (empty($excerpts) || empty($original_index_fields)) echo "disabled='disabled'"; ?>/>
|
1552 |
<?php _e("Use custom field content for building excerpts", "relevanssi"); ?>
|
1553 |
</label>
|
1554 |
</fieldset>
|
1555 |
+
<p class="description"><?php _e("Use the custom fields setting for indexing for excerpt-making as well. Enabling this option will show custom field content in Relevanssi-generated excerpts.", "relevanssi"); ?>
|
1556 |
+
<?php if (RELEVANSSI_PREMIUM) { _e("Enable this option to use PDF content for excerpts.", "relevanssi"); } ?>
|
1557 |
+
</p>
|
1558 |
|
1559 |
<p class="description"><?php _e("Current custom field setting", 'relevanssi'); ?>:
|
1560 |
<?php
|
1561 |
if ($original_index_fields === "visible") _e("all visible custom fields", 'relevanssi');
|
1562 |
else if ($original_index_fields === "all") _e("all custom fields", 'relevanssi');
|
1563 |
else if (!empty($original_index_fields)) echo "<code>$original_index_fields</code>";
|
1564 |
+
else if (RELEVANSSI_PREMIUM) { _e('Just PDF content', 'relevanssi'); } else { _e('None selected', 'relevanssi'); }
|
1565 |
?></p>
|
1566 |
</td>
|
1567 |
</tr>
|
1954 |
<legend class="screen-reader-text"><?php _e("Index the post excerpt", "relevanssi"); ?></legend>
|
1955 |
<label for='relevanssi_index_excerpt'>
|
1956 |
<input type='checkbox' name='relevanssi_index_excerpt' id='relevanssi_index_excerpt' <?php echo $index_excerpt ?> />
|
1957 |
+
<?php _e("Index the post excerpt", "relevanssi") ?>
|
1958 |
</label>
|
1959 |
<p class="description"><?php _e("Relevanssi will find posts by the content in the excerpt.", 'relevanssi'); ?></p>
|
1960 |
<?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
|
2284 |
"<li>" . __('Building custom excerpts can be slow. If you are not actually using the excerpts, make sure you disable the option.', 'relevanssi') . "</li>" .
|
2285 |
"<li>" . sprintf(__('Custom snippets require that the search results template uses %s to print out the excerpts.', 'relevanssi'), "<code>the_excerpt()</code>") . "</li>" .
|
2286 |
"<li>" . __("Generally, Relevanssi generates the excerpts from post content. If you want to include custom field content in the excerpt-building, this can be done with a simple setting from the excerpt settings.", "relevanssi") . "</li>" .
|
2287 |
+
"<li>" . sprintf(__("If you want more control over what content Relevanssi uses to create the excerpts, you can use the %s and %s filter hooks to adjust the content.", "relevanssi"), "<code>relevanssi_pre_excerpt_content</code>", "<code>relevanssi_excerpt_content</code>") . "</li>" .
|
2288 |
"<li>" . sprintf(__("Some shortcode do not work well with Relevanssi excerpt-generation. Relevanssi disables some shortcodes automatically to prevent problems. This can be adjusted with the %s filter hook.", "relevanssi"), "<code>relevanssi_disable_shortcodes_excerpt</code>") . "</li>" .
|
2289 |
"<li>" . sprintf(__("If you want Relevanssi to build excerpts faster and don't mind that they may be less than perfect in quality, add a filter that returns true on hook %s.", "relevanssi"), '<code>relevanssi_optimize_excerpts</code>') .
|
2290 |
"<pre>add_filter('relevanssi_optimize_excerpts', '__return_true');</pre></li>" .
|
lib/search.php
CHANGED
@@ -489,14 +489,7 @@ function relevanssi_search($args) {
|
|
489 |
$term = esc_sql($term);
|
490 |
|
491 |
if (strpos($o_term_cond, 'LIKE') !== false) {
|
492 |
-
|
493 |
-
if (method_exists($wpdb, 'esc_like')) {
|
494 |
-
$term = $wpdb->esc_like($term);
|
495 |
-
}
|
496 |
-
else {
|
497 |
-
// Compatibility for pre-4.0 WordPress
|
498 |
-
$term = like_escape($term);
|
499 |
-
}
|
500 |
}
|
501 |
|
502 |
$term_cond = str_replace('#term#', $term, $o_term_cond);
|
489 |
$term = esc_sql($term);
|
490 |
|
491 |
if (strpos($o_term_cond, 'LIKE') !== false) {
|
492 |
+
$term = $wpdb->esc_like($term);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
}
|
494 |
|
495 |
$term_cond = str_replace('#term#', $term, $o_term_cond);
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: search, relevance, better search
|
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.9.1
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 4.0.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -280,6 +280,13 @@ Each document database is full of useless words. All the little words that appea
|
|
280 |
|
281 |
== Changelog ==
|
282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
= 4.0.2 =
|
284 |
* Removed couple of error notices in the code.
|
285 |
* Improved the support for page builders.
|
@@ -1137,6 +1144,9 @@ Each document database is full of useless words. All the little words that appea
|
|
1137 |
|
1138 |
== Upgrade notice ==
|
1139 |
|
|
|
|
|
|
|
1140 |
= 4.0.2 =
|
1141 |
* Minor bugfixes.
|
1142 |
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.9.1
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 4.0.3
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
280 |
|
281 |
== Changelog ==
|
282 |
|
283 |
+
= 4.0.3 =
|
284 |
+
* Relevanssi didn't index all posts with one go. It does now.
|
285 |
+
* © and ® symbols caused problems in indexing; they are now included in the default punctuation removal.
|
286 |
+
* In some cases excerpt-building could take ages because of autoembed link discovery. Relevanssi now blocks the autoembed procedure in link-building.
|
287 |
+
* New filter: `relevanssi_custom_field_value` is used to filter custom field values both before indexing and before excerpt-building. Parameters include the field name and the post ID.
|
288 |
+
* Updated filter: `relevanssi_index_custom_fields` now gets a second parameter that contains the post ID.
|
289 |
+
|
290 |
= 4.0.2 =
|
291 |
* Removed couple of error notices in the code.
|
292 |
* Improved the support for page builders.
|
1144 |
|
1145 |
== Upgrade notice ==
|
1146 |
|
1147 |
+
= 4.0.3 =
|
1148 |
+
* Small bugfixes, correction to indexing procedure.
|
1149 |
+
|
1150 |
= 4.0.2 =
|
1151 |
* Minor bugfixes.
|
1152 |
|
relevanssi.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Relevanssi
|
4 |
Plugin URI: https://www.relevanssi.com/
|
5 |
Description: This plugin replaces WordPress search with a relevance-sorting search.
|
6 |
-
Version: 4.0.
|
7 |
Author: Mikko Saari
|
8 |
Author URI: http://www.mikkosaari.fi/
|
9 |
Text Domain: relevanssi
|
3 |
Plugin Name: Relevanssi
|
4 |
Plugin URI: https://www.relevanssi.com/
|
5 |
Description: This plugin replaces WordPress search with a relevance-sorting search.
|
6 |
+
Version: 4.0.3
|
7 |
Author: Mikko Saari
|
8 |
Author URI: http://www.mikkosaari.fi/
|
9 |
Text Domain: relevanssi
|