Version Description
- 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.
- 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. - 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.
Download this release
Release Info
Developer | msaari |
Plugin | Relevanssi – A Better Search |
Version | 4.7.2.1 |
Comparing to | |
See all releases |
Code changes from version 4.7.2 to 4.7.2.1
- lib/common.php +189 -42
- lib/init.php +16 -1
- lib/search.php +10 -0
- readme.txt +9 -53
- relevanssi.php +2 -2
lib/common.php
CHANGED
@@ -361,9 +361,15 @@ function relevanssi_extract_phrases( $query ) {
|
|
361 |
|
362 |
$phrases = array();
|
363 |
while ( false !== $pos ) {
|
364 |
-
$
|
365 |
-
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
if ( false === $end ) {
|
368 |
// Just one " in the query.
|
369 |
$pos = $end;
|
@@ -376,7 +382,7 @@ function relevanssi_extract_phrases( $query ) {
|
|
376 |
if ( ! empty( $phrase ) && count( explode( ' ', $phrase ) ) > 1 ) {
|
377 |
$phrases[] = $phrase;
|
378 |
}
|
379 |
-
$pos = $end;
|
380 |
}
|
381 |
|
382 |
return $phrases;
|
@@ -385,34 +391,117 @@ function relevanssi_extract_phrases( $query ) {
|
|
385 |
/**
|
386 |
* Generates the MySQL code for restricting the search to phrase hits.
|
387 |
*
|
388 |
-
* This function uses relevanssi_extract_phrases() to figure out the phrases in
|
389 |
-
* search query, then generates MySQL queries to restrict the search to the
|
390 |
-
* containing those phrases in the title, content, taxonomy terms or meta
|
|
|
391 |
*
|
392 |
-
* @global
|
393 |
*
|
394 |
* @param string $search_query The search query.
|
395 |
* @param string $operator The search operator (AND or OR).
|
396 |
*
|
397 |
-
* @return string $queries If not phrase hits are found, an empty string;
|
398 |
-
* MySQL queries to restrict the search.
|
399 |
*/
|
400 |
function relevanssi_recognize_phrases( $search_query, $operator = 'AND' ) {
|
401 |
-
global $
|
402 |
|
403 |
$phrases = relevanssi_extract_phrases( $search_query );
|
404 |
-
$status = relevanssi_valid_status_array();
|
405 |
-
|
406 |
-
// Add "inherit" to the list of allowed statuses to include attachments.
|
407 |
-
if ( ! strstr( $status, 'inherit' ) ) {
|
408 |
-
$status .= ",'inherit'";
|
409 |
-
}
|
410 |
|
411 |
$all_queries = array();
|
412 |
if ( 0 === count( $phrases ) ) {
|
413 |
return $all_queries;
|
414 |
}
|
415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
$phrase_queries = array();
|
417 |
|
418 |
foreach ( $phrases as $phrase ) {
|
@@ -429,8 +518,8 @@ function relevanssi_recognize_phrases( $search_query, $operator = 'AND' ) {
|
|
429 |
$phrase = esc_sql( $phrase );
|
430 |
|
431 |
$excerpt = '';
|
432 |
-
if ( 'on' ===
|
433 |
-
$excerpt = "
|
434 |
}
|
435 |
|
436 |
$query = "(SELECT ID FROM $wpdb->posts
|
@@ -439,7 +528,6 @@ function relevanssi_recognize_phrases( $search_query, $operator = 'AND' ) {
|
|
439 |
|
440 |
$queries[] = $query;
|
441 |
|
442 |
-
$taxonomies = get_option( 'relevanssi_index_taxonomies_list', array() );
|
443 |
if ( $taxonomies ) {
|
444 |
$taxonomies_escaped = implode( "','", array_map( 'esc_sql', $taxonomies ) );
|
445 |
$taxonomies_sql = "AND s.taxonomy IN ('$taxonomies_escaped')";
|
@@ -452,14 +540,20 @@ function relevanssi_recognize_phrases( $search_query, $operator = 'AND' ) {
|
|
452 |
$queries[] = $query;
|
453 |
}
|
454 |
|
455 |
-
$custom_fields = relevanssi_get_custom_fields();
|
456 |
if ( $custom_fields ) {
|
457 |
$keys = '';
|
458 |
|
459 |
if ( is_array( $custom_fields ) ) {
|
460 |
array_push( $custom_fields, '_relevanssi_pdf_content' );
|
461 |
-
$custom_fields_escaped = implode(
|
462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
}
|
464 |
|
465 |
if ( 'visible' === $custom_fields ) {
|
@@ -488,7 +582,7 @@ function relevanssi_recognize_phrases( $search_query, $operator = 'AND' ) {
|
|
488 |
}
|
489 |
}
|
490 |
|
491 |
-
if ( 'on' ===
|
492 |
$query = "(SELECT parent.ID
|
493 |
FROM $wpdb->posts AS p, $wpdb->postmeta AS m, $wpdb->posts AS parent
|
494 |
WHERE p.ID = m.post_id
|
@@ -500,26 +594,10 @@ function relevanssi_recognize_phrases( $search_query, $operator = 'AND' ) {
|
|
500 |
$queries[] = $query;
|
501 |
}
|
502 |
|
503 |
-
$queries = implode( ' OR relevanssi.doc IN ', $queries );
|
504 |
-
$queries = "(relevanssi.doc IN $queries)";
|
505 |
-
$all_queries[] = $queries;
|
506 |
-
|
507 |
$phrase_queries[ $phrase ] = $queries;
|
508 |
}
|
509 |
|
510 |
-
|
511 |
-
if ( 'AND' !== $operator && 'OR' !== $operator ) {
|
512 |
-
$operator = 'AND';
|
513 |
-
}
|
514 |
-
|
515 |
-
if ( ! empty( $all_queries ) ) {
|
516 |
-
$all_queries = ' AND ( ' . implode( ' ' . $operator . ' ', $all_queries ) . ' ) ';
|
517 |
-
}
|
518 |
-
|
519 |
-
return array(
|
520 |
-
'and' => $all_queries,
|
521 |
-
'or' => $phrase_queries,
|
522 |
-
);
|
523 |
}
|
524 |
|
525 |
/**
|
@@ -739,7 +817,6 @@ function relevanssi_remove_punct( $a ) {
|
|
739 |
return $a;
|
740 |
}
|
741 |
|
742 |
-
|
743 |
/**
|
744 |
* Prevents the default search from running.
|
745 |
*
|
@@ -756,6 +833,19 @@ function relevanssi_remove_punct( $a ) {
|
|
756 |
*/
|
757 |
function relevanssi_prevent_default_request( $request, $query ) {
|
758 |
if ( $query->is_search ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
759 |
if ( in_array( $query->query_vars['post_type'], array( 'topic', 'reply' ), true ) ) {
|
760 |
// This is a BBPress search; do not meddle.
|
761 |
return $request;
|
@@ -1973,3 +2063,60 @@ function relevanssi_block_on_admin_searches( $allow, $query ) {
|
|
1973 |
}
|
1974 |
return $allow;
|
1975 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
|
362 |
$phrases = array();
|
363 |
while ( false !== $pos ) {
|
364 |
+
if ( $pos + 2 > relevanssi_strlen( $normalized_query ) ) {
|
365 |
+
$pos = false;
|
366 |
+
continue;
|
367 |
+
}
|
368 |
+
$start = call_user_func( $strpos_function, $normalized_query, '"', $pos );
|
369 |
+
$end = false;
|
370 |
+
if ( false !== $start ) {
|
371 |
+
$end = call_user_func( $strpos_function, $normalized_query, '"', $start + 2 );
|
372 |
+
}
|
373 |
if ( false === $end ) {
|
374 |
// Just one " in the query.
|
375 |
$pos = $end;
|
382 |
if ( ! empty( $phrase ) && count( explode( ' ', $phrase ) ) > 1 ) {
|
383 |
$phrases[] = $phrase;
|
384 |
}
|
385 |
+
$pos = $end + 1;
|
386 |
}
|
387 |
|
388 |
return $phrases;
|
391 |
/**
|
392 |
* Generates the MySQL code for restricting the search to phrase hits.
|
393 |
*
|
394 |
+
* This function uses relevanssi_extract_phrases() to figure out the phrases in
|
395 |
+
* the search query, then generates MySQL queries to restrict the search to the
|
396 |
+
* posts containing those phrases in the title, content, taxonomy terms or meta
|
397 |
+
* fields.
|
398 |
*
|
399 |
+
* @global array $relevanssi_variables The global Relevanssi variables.
|
400 |
*
|
401 |
* @param string $search_query The search query.
|
402 |
* @param string $operator The search operator (AND or OR).
|
403 |
*
|
404 |
+
* @return string $queries If not phrase hits are found, an empty string;
|
405 |
+
* otherwise MySQL queries to restrict the search.
|
406 |
*/
|
407 |
function relevanssi_recognize_phrases( $search_query, $operator = 'AND' ) {
|
408 |
+
global $relevanssi_variables;
|
409 |
|
410 |
$phrases = relevanssi_extract_phrases( $search_query );
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
|
412 |
$all_queries = array();
|
413 |
if ( 0 === count( $phrases ) ) {
|
414 |
return $all_queries;
|
415 |
}
|
416 |
|
417 |
+
$taxonomies = get_option( 'relevanssi_index_taxonomies_list', array() );
|
418 |
+
$custom_fields = relevanssi_get_custom_fields();
|
419 |
+
$excerpts = get_option( 'relevanssi_index_excerpt', 'off' );
|
420 |
+
$index_pdf_parent = get_option( 'relevanssi_index_pdf_parent' );
|
421 |
+
|
422 |
+
$phrase_queries = array();
|
423 |
+
$queries = array();
|
424 |
+
|
425 |
+
if (
|
426 |
+
isset( $relevanssi_variables['phrase_targets'] ) &&
|
427 |
+
is_array( $relevanssi_variables['phrase_targets'] )
|
428 |
+
) {
|
429 |
+
$non_targeted_phrases = array();
|
430 |
+
foreach ( $phrases as $phrase ) {
|
431 |
+
if (
|
432 |
+
isset( $relevanssi_variables['phrase_targets'][ $phrase ] ) &&
|
433 |
+
function_exists( 'relevanssi_targeted_phrases' )
|
434 |
+
) {
|
435 |
+
$queries = relevanssi_targeted_phrases( $phrase );
|
436 |
+
} else {
|
437 |
+
$non_targeted_phrases[] = $phrase;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
$phrases = $non_targeted_phrases;
|
441 |
+
}
|
442 |
+
|
443 |
+
$queries = array_merge(
|
444 |
+
$queries,
|
445 |
+
relevanssi_generate_phrase_queries(
|
446 |
+
$phrases,
|
447 |
+
$taxonomies,
|
448 |
+
$custom_fields,
|
449 |
+
$excerpts,
|
450 |
+
$index_pdf_parent
|
451 |
+
)
|
452 |
+
);
|
453 |
+
|
454 |
+
$phrase_queries = array();
|
455 |
+
|
456 |
+
foreach ( $queries as $phrase => $p_queries ) {
|
457 |
+
$p_queries = implode( ' OR relevanssi.doc IN ', $p_queries );
|
458 |
+
$p_queries = "(relevanssi.doc IN $p_queries)";
|
459 |
+
$all_queries[] = $p_queries;
|
460 |
+
|
461 |
+
$phrase_queries[ $phrase ] = $p_queries;
|
462 |
+
}
|
463 |
+
|
464 |
+
$operator = strtoupper( $operator );
|
465 |
+
if ( 'AND' !== $operator && 'OR' !== $operator ) {
|
466 |
+
$operator = 'AND';
|
467 |
+
}
|
468 |
+
|
469 |
+
if ( ! empty( $all_queries ) ) {
|
470 |
+
$all_queries = ' AND ( ' . implode( ' ' . $operator . ' ', $all_queries ) . ' ) ';
|
471 |
+
}
|
472 |
+
|
473 |
+
return array(
|
474 |
+
'and' => $all_queries,
|
475 |
+
'or' => $phrase_queries,
|
476 |
+
);
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Generates the phrase queries from phrases.
|
481 |
+
*
|
482 |
+
* Takes in phrases and a bunch of parameters and generates the MySQL queries
|
483 |
+
* that restrict the main search query to only posts that have the phrase.
|
484 |
+
*
|
485 |
+
* @param array $phrases A list of phrases to handle.
|
486 |
+
* @param array $taxonomies An array of taxonomy names to use.
|
487 |
+
* @param array $custom_fields A list of custom field names to use.
|
488 |
+
* @param string $excerpts If 'on', include excerpts.
|
489 |
+
* @param string $index_pdf_parent If 'on', include PDF parent.
|
490 |
+
*
|
491 |
+
* @global object $wpdb The WordPress database interface.
|
492 |
+
*
|
493 |
+
* @return array An array of queries sorted by phrase.
|
494 |
+
*/
|
495 |
+
function relevanssi_generate_phrase_queries( $phrases, $taxonomies, $custom_fields, $excerpts, $index_pdf_parent ) {
|
496 |
+
global $wpdb;
|
497 |
+
|
498 |
+
$status = relevanssi_valid_status_array();
|
499 |
+
|
500 |
+
// Add "inherit" to the list of allowed statuses to include attachments.
|
501 |
+
if ( ! strstr( $status, 'inherit' ) ) {
|
502 |
+
$status .= ",'inherit'";
|
503 |
+
}
|
504 |
+
|
505 |
$phrase_queries = array();
|
506 |
|
507 |
foreach ( $phrases as $phrase ) {
|
518 |
$phrase = esc_sql( $phrase );
|
519 |
|
520 |
$excerpt = '';
|
521 |
+
if ( 'on' === $excerpts ) {
|
522 |
+
$excerpt = "OR post_excerpt LIKE '%$phrase%'";
|
523 |
}
|
524 |
|
525 |
$query = "(SELECT ID FROM $wpdb->posts
|
528 |
|
529 |
$queries[] = $query;
|
530 |
|
|
|
531 |
if ( $taxonomies ) {
|
532 |
$taxonomies_escaped = implode( "','", array_map( 'esc_sql', $taxonomies ) );
|
533 |
$taxonomies_sql = "AND s.taxonomy IN ('$taxonomies_escaped')";
|
540 |
$queries[] = $query;
|
541 |
}
|
542 |
|
|
|
543 |
if ( $custom_fields ) {
|
544 |
$keys = '';
|
545 |
|
546 |
if ( is_array( $custom_fields ) ) {
|
547 |
array_push( $custom_fields, '_relevanssi_pdf_content' );
|
548 |
+
$custom_fields_escaped = implode(
|
549 |
+
"','",
|
550 |
+
array_map(
|
551 |
+
'esc_sql',
|
552 |
+
$custom_fields
|
553 |
+
)
|
554 |
+
);
|
555 |
+
|
556 |
+
$keys = "AND m.meta_key IN ('$custom_fields_escaped')";
|
557 |
}
|
558 |
|
559 |
if ( 'visible' === $custom_fields ) {
|
582 |
}
|
583 |
}
|
584 |
|
585 |
+
if ( 'on' === $index_pdf_parent ) {
|
586 |
$query = "(SELECT parent.ID
|
587 |
FROM $wpdb->posts AS p, $wpdb->postmeta AS m, $wpdb->posts AS parent
|
588 |
WHERE p.ID = m.post_id
|
594 |
$queries[] = $query;
|
595 |
}
|
596 |
|
|
|
|
|
|
|
|
|
597 |
$phrase_queries[ $phrase ] = $queries;
|
598 |
}
|
599 |
|
600 |
+
return $phrase_queries;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
}
|
602 |
|
603 |
/**
|
817 |
return $a;
|
818 |
}
|
819 |
|
|
|
820 |
/**
|
821 |
* Prevents the default search from running.
|
822 |
*
|
833 |
*/
|
834 |
function relevanssi_prevent_default_request( $request, $query ) {
|
835 |
if ( $query->is_search ) {
|
836 |
+
$indexed_post_types = array_flip(
|
837 |
+
get_option( 'relevanssi_index_post_types', array() )
|
838 |
+
);
|
839 |
+
$images_indexed = get_option( 'relevanssi_index_image_files', 'off' );
|
840 |
+
if ( false === isset( $indexed_post_types['attachment'] ) || 'off' === $images_indexed ) {
|
841 |
+
if ( isset( $query->query_vars['post_type'] ) && isset( $query->query_vars['post_status'] ) ) {
|
842 |
+
if ( 'attachment' === $query->query_vars['post_type'] && 'inherit,private' === $query->query_vars['post_status'] ) {
|
843 |
+
// This is a media library search; do not meddle.
|
844 |
+
return $request;
|
845 |
+
}
|
846 |
+
}
|
847 |
+
}
|
848 |
+
|
849 |
if ( in_array( $query->query_vars['post_type'], array( 'topic', 'reply' ), true ) ) {
|
850 |
// This is a BBPress search; do not meddle.
|
851 |
return $request;
|
2063 |
}
|
2064 |
return $allow;
|
2065 |
}
|
2066 |
+
|
2067 |
+
/**
|
2068 |
+
* Checks if user has relevanssi_indexing_restriction filter functions in use.
|
2069 |
+
*
|
2070 |
+
* Temporary check for the changes in the relevanssi_indexing_restriction filter
|
2071 |
+
* in 2.8/4.7. Remove eventually. The function runs all non-Relevanssi filters
|
2072 |
+
* on relevanssi_indexing_restriction and reports all that return a string.
|
2073 |
+
*
|
2074 |
+
* @see relevanssi_init()
|
2075 |
+
*
|
2076 |
+
* @return string The notice, if there's something to complain about, empty
|
2077 |
+
* string otherwise.
|
2078 |
+
*/
|
2079 |
+
function relevanssi_check_indexing_restriction() {
|
2080 |
+
$notice = '';
|
2081 |
+
if ( has_filter( 'relevanssi_indexing_restriction' ) ) {
|
2082 |
+
global $wp_filter;
|
2083 |
+
$callbacks = array_flip(
|
2084 |
+
array_keys(
|
2085 |
+
array_merge(
|
2086 |
+
[],
|
2087 |
+
...$wp_filter['relevanssi_indexing_restriction']->callbacks
|
2088 |
+
)
|
2089 |
+
)
|
2090 |
+
);
|
2091 |
+
if ( isset( $callbacks['relevanssi_yoast_exclude'] ) ) {
|
2092 |
+
unset( $callbacks['relevanssi_yoast_exclude'] );
|
2093 |
+
}
|
2094 |
+
if ( isset( $callbacks['relevanssi_seopress_exclude'] ) ) {
|
2095 |
+
unset( $callbacks['relevanssi_seopress_exclude'] );
|
2096 |
+
}
|
2097 |
+
if ( isset( $callbacks['relevanssi_woocommerce_restriction'] ) ) {
|
2098 |
+
unset( $callbacks['relevanssi_woocommerce_restriction'] );
|
2099 |
+
}
|
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 |
+
}
|
2107 |
+
}
|
2108 |
+
if ( $returns_string ) {
|
2109 |
+
$list_of_callbacks = implode( ', ', $returns_string );
|
2110 |
+
$notice = <<<EOH
|
2111 |
+
<div id="relevanssi-indexing_restriction-warning" class="notice notice-warn">
|
2112 |
+
<p>The filter hook <code>relevanssi_indexing_restriction</code> was changed
|
2113 |
+
recently. <a href="https://www.relevanssi.com/knowledge-base/controlling-attachment-types-index/">More
|
2114 |
+
information can be found here</a>. You're using the filter, so make sure your
|
2115 |
+
filter functions have been updated. Check these functions that return wrong
|
2116 |
+
format: $list_of_callbacks.</p></div>
|
2117 |
+
EOH;
|
2118 |
+
}
|
2119 |
+
}
|
2120 |
+
}
|
2121 |
+
return $notice;
|
2122 |
+
}
|
lib/init.php
CHANGED
@@ -78,11 +78,26 @@ function relevanssi_init() {
|
|
78 |
$on_relevanssi_page = false;
|
79 |
if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
80 |
$page = sanitize_file_name( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
|
81 |
-
|
|
|
82 |
$on_relevanssi_page = true;
|
83 |
}
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
if ( 'done' !== get_option( 'relevanssi_indexed' ) ) {
|
87 |
if ( 'options-general.php' === $pagenow && $on_relevanssi_page ) {
|
88 |
add_action(
|
78 |
$on_relevanssi_page = false;
|
79 |
if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
|
80 |
$page = sanitize_file_name( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
|
81 |
+
$base = sanitize_file_name( wp_unslash( plugin_basename( $relevanssi_variables['file'] ) ) );
|
82 |
+
if ( $base === $page ) {
|
83 |
$on_relevanssi_page = true;
|
84 |
}
|
85 |
}
|
86 |
|
87 |
+
$restriction_notice = relevanssi_check_indexing_restriction();
|
88 |
+
if ( $restriction_notice ) {
|
89 |
+
if ( 'options-general.php' === $pagenow && $on_relevanssi_page ) {
|
90 |
+
if ( 'indexing' === $_GET['tab'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
91 |
+
add_action(
|
92 |
+
'admin_notices',
|
93 |
+
function() use ( $restriction_notice ) {
|
94 |
+
echo $restriction_notice; // phpcs:ignore WordPress.Security.EscapeOutput
|
95 |
+
}
|
96 |
+
);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
if ( 'done' !== get_option( 'relevanssi_indexed' ) ) {
|
102 |
if ( 'options-general.php' === $pagenow && $on_relevanssi_page ) {
|
103 |
add_action(
|
lib/search.php
CHANGED
@@ -50,6 +50,16 @@ function relevanssi_query( $posts, $query = false ) {
|
|
50 |
$search_ok = false; // No search term.
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
/**
|
54 |
* Filters whether Relevanssi search can be run or not.
|
55 |
*
|
50 |
$search_ok = false; // No search term.
|
51 |
}
|
52 |
|
53 |
+
$indexed_post_types = array_flip(
|
54 |
+
get_option( 'relevanssi_index_post_types', array() )
|
55 |
+
);
|
56 |
+
$images_indexed = get_option( 'relevanssi_index_image_files', 'off' );
|
57 |
+
if ( $search_ok && ( false === isset( $indexed_post_types['attachment'] ) || 'off' === $images_indexed ) ) {
|
58 |
+
if ( 'attachment' === $query->query_vars['post_type'] && 'inherit,private' === $query->query_vars['post_status'] ) {
|
59 |
+
$search_ok = false;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
/**
|
64 |
* Filters whether Relevanssi search can be run or not.
|
65 |
*
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ 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
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -113,18 +113,6 @@ 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 |
-
= 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,6 +121,11 @@ Each document database is full of useless words. All the little words that appea
|
|
133 |
* John Calahan for extensive 4.0 beta testing.
|
134 |
|
135 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
136 |
= 4.7.2 =
|
137 |
* 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.
|
138 |
* 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.
|
@@ -149,35 +142,10 @@ Each document database is full of useless words. All the little words that appea
|
|
149 |
* 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.
|
150 |
* Minor fix: Improves handling of emoji in indexing. If the database supports emoji, they are allowed, otherwise they are encoded.
|
151 |
|
152 |
-
= 4.6.0 =
|
153 |
-
* 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.
|
154 |
-
* Minor fix: User Access Manager showed drafts in search results for all users. This is now fixed.
|
155 |
-
|
156 |
-
= 4.5.0 =
|
157 |
-
* New feature: New filter hook `relevanssi_disable_stopwords` can be used to disable stopwords completely. Just add a filter function that returns `true`.
|
158 |
-
* 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.
|
159 |
-
* 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()`.
|
160 |
-
* 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.
|
161 |
-
* Minor fix: Searching for regex special characters (for example parentheses, brackets) caused problems in excerpts.
|
162 |
-
* Minor fix: Improvements in handling highlighting for words with apostrophes.
|
163 |
-
* Minor fix: Disregard hanging commas at the end of post exclusion settings.
|
164 |
-
* Minor fix: Sometimes excerpts wouldn't have an ellipsis in the beginning even though they should.
|
165 |
-
|
166 |
-
= 4.4.1 =
|
167 |
-
* Major fix: Returns the missing stopwords.
|
168 |
-
|
169 |
-
= 4.4.0 =
|
170 |
-
* New feature: It's now possible to exclude image attachments from the index with a simple setting on the indexing settings page.
|
171 |
-
* 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.
|
172 |
-
* 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.
|
173 |
-
* 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.
|
174 |
-
* 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.
|
175 |
-
* 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.
|
176 |
-
* 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.
|
177 |
-
* Minor fix: Untokenized search terms are used for building excerpts, which makes highlighting in excerpts work better.
|
178 |
-
* Minor fix: Indexing did not adjust the number of posts indexed at one go like it should.
|
179 |
-
|
180 |
== Upgrade notice ==
|
|
|
|
|
|
|
181 |
= 4.7.2 =
|
182 |
* Improved backwards compatibility for the `relevanssi_indexing_restriction` filter hook change, better Media Library support.
|
183 |
|
@@ -186,15 +154,3 @@ Each document database is full of useless words. All the little words that appea
|
|
186 |
|
187 |
= 4.7.0 =
|
188 |
* The `relevanssi_indexing_restriction` filter hook has been changed, stopwords are handled in a different way in excerpts.
|
189 |
-
|
190 |
-
= 4.6.0 =
|
191 |
-
* Changes how phrases work in OR search and fixes a User Access Manager issue.
|
192 |
-
|
193 |
-
= 4.5.0 =
|
194 |
-
* Bug fixes and improvements to stopword management.
|
195 |
-
|
196 |
-
= 4.4.1 =
|
197 |
-
* Fixes missing stopwords problem in 4.4.0.
|
198 |
-
|
199 |
-
= 4.4.0 =
|
200 |
-
* Changes in relevanssi_page_builder_shortcodes filter hook, page builder indexing and image attachments.
|
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 |
= 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 |
* 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.
|
131 |
* 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.
|
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.
|
151 |
|
154 |
|
155 |
= 4.7.0 =
|
156 |
* The `relevanssi_indexing_restriction` filter hook has been changed, stopwords are handled in a different way in excerpts.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.7.2
|
17 |
* Author: Mikko Saari
|
18 |
* Author URI: http://www.mikkosaari.fi/
|
19 |
* Text Domain: relevanssi
|
@@ -65,7 +65,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';
|
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.7.2.1
|
17 |
* Author: Mikko Saari
|
18 |
* Author URI: http://www.mikkosaari.fi/
|
19 |
* Text Domain: relevanssi
|
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';
|