Relevanssi – A Better Search - Version 4.0.8

Version Description

  • Fixed cases where Relevanssi added an ellipsis even if the excerpt was from the start of the post.
  • Highlighting now works with numeric search strings.
  • Improved highlighting for accented words. Thanks to Paul Ryan.
  • A surplus comma at the end of post exclusion setting won't break the search anymore.
  • Fixed instructions for adjusting the throttle limit.
Download this release

Release Info

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

Code changes from version 4.0.7 to 4.0.8

lib/admin-ajax.php CHANGED
@@ -40,7 +40,6 @@ function relevanssi_index_posts_ajax_wrapper() {
40
  $limit = absint( $_POST['limit'] );
41
  $extend = strval( $_POST['extend'] );
42
 
43
- $extend = false;
44
  if ( 'true' === $extend ) {
45
  $extend = true;
46
  }
40
  $limit = absint( $_POST['limit'] );
41
  $extend = strval( $_POST['extend'] );
42
 
 
43
  if ( 'true' === $extend ) {
44
  $extend = true;
45
  }
lib/admin_scripts.js CHANGED
@@ -120,7 +120,6 @@ jQuery(document).ready(function($){
120
  $("#relevanssi_word_boundaries").attr('disabled', !this.checked);
121
  $("#relevanssi_show_matches").attr('disabled', !this.checked);
122
  $("#relevanssi_show_matches_text").attr('disabled', !this.checked);
123
- $("#relevanssi_highlight_docs_external").attr('disabled', !this.checked);
124
  });
125
 
126
  $("#relevanssi_searchblogs_all").click(function() {
@@ -167,6 +166,7 @@ jQuery(document).ready(function($) {
167
  'total_seconds' : 0,
168
  'limit' : 10,
169
  'extend' : true,
 
170
  };
171
  process_indexing_step(args);
172
  }
120
  $("#relevanssi_word_boundaries").attr('disabled', !this.checked);
121
  $("#relevanssi_show_matches").attr('disabled', !this.checked);
122
  $("#relevanssi_show_matches_text").attr('disabled', !this.checked);
 
123
  });
124
 
125
  $("#relevanssi_searchblogs_all").click(function() {
166
  'total_seconds' : 0,
167
  'limit' : 10,
168
  'extend' : true,
169
+ 'security' : nonce.indexing_nonce,
170
  };
171
  process_indexing_step(args);
172
  }
lib/common.php CHANGED
@@ -978,7 +978,7 @@ function relevanssi_get_custom_fields() {
978
  /**
979
  * Trims multibyte strings.
980
  *
981
- * Removes the 194+160 non-breakable spaces and removes whitespace.
982
  *
983
  * @param string $string The source string.
984
  *
@@ -986,10 +986,25 @@ function relevanssi_get_custom_fields() {
986
  */
987
  function relevanssi_mb_trim( $string ) {
988
  $string = str_replace( chr( 194 ) . chr( 160 ), '', $string );
 
989
  $string = preg_replace( '/(^\s+)|(\s+$)/us', '', $string );
990
  return $string;
991
  }
992
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
993
  /**
994
  * Removes punctuation from a string.
995
  *
@@ -1027,7 +1042,7 @@ function relevanssi_remove_punct( $a ) {
1027
  }
1028
 
1029
  $quote_replacement = ' ';
1030
- if ( isset( $punct_options['quote'] ) && 'remove' === $punct_options['quote'] ) {
1031
  $quote_replacement = '';
1032
  }
1033
 
@@ -1056,9 +1071,9 @@ function relevanssi_remove_punct( $a ) {
1056
  '©' => '',
1057
  '­' => '',
1058
  ' ' => ' ',
1059
- '’' => ' ',
1060
  chr( 194 ) . chr( 160 ) => ' ',
1061
  '×' => ' ',
 
1062
  "'" => $quote_replacement,
1063
  '’' => $quote_replacement,
1064
  '‘' => $quote_replacement,
@@ -1475,6 +1490,9 @@ function relevanssi_add_synonyms( $query ) {
1475
  $key = strval( trim( $parts[0] ) );
1476
  $value = trim( $parts[1] );
1477
 
 
 
 
1478
  $synonyms[ $key ][ $value ] = true;
1479
  }
1480
 
@@ -1488,19 +1506,24 @@ function relevanssi_add_synonyms( $query ) {
1488
 
1489
  foreach ( $terms as $term ) {
1490
  $term = trim( $term );
1491
- if ( in_array( strval( $term ), array_keys( $synonyms ), true ) ) { // Strval(), otherwise numbers cause problems.
 
 
 
1492
  if ( isset( $synonyms[ strval( $term ) ] ) ) { // Necessary, otherwise terms like "02" can cause problems.
1493
  $new_terms = array_merge( $new_terms, array_keys( $synonyms[ strval( $term ) ] ) );
1494
  }
1495
  }
1496
  }
1497
  if ( count( $new_terms ) > 0 ) {
 
1498
  foreach ( $new_terms as $new_term ) {
1499
  $query .= " $new_term";
1500
  }
1501
  }
1502
  }
1503
  }
 
1504
  return $query;
1505
  }
1506
 
@@ -1779,7 +1802,9 @@ function relevanssi_permalink( $link, $link_post = null ) {
1779
  if ( is_object( $post ) && property_exists( $post, 'relevanssi_link' ) ) {
1780
  $link = $post->relevanssi_link;
1781
  }
1782
- $link = relevanssi_add_highlight( $link );
 
 
1783
  return $link;
1784
  }
1785
 
@@ -2017,6 +2042,10 @@ function relevanssi_sanitize_hex_color( $color ) {
2017
  return '';
2018
  }
2019
 
 
 
 
 
2020
  // 3 or 6 hex digits, or the empty string.
2021
  if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
2022
  return $color;
978
  /**
979
  * Trims multibyte strings.
980
  *
981
+ * Removes the 194+160 non-breakable spaces, removes null bytes and removes whitespace.
982
  *
983
  * @param string $string The source string.
984
  *
986
  */
987
  function relevanssi_mb_trim( $string ) {
988
  $string = str_replace( chr( 194 ) . chr( 160 ), '', $string );
989
+ $string = str_replace( "\0", '', $string );
990
  $string = preg_replace( '/(^\s+)|(\s+$)/us', '', $string );
991
  return $string;
992
  }
993
 
994
+ /**
995
+ * Wraps the relevanssi_mb_trim() function so that it can be used as a callback for
996
+ * array_walk().
997
+ *
998
+ * @since 2.1.4
999
+ *
1000
+ * @see relevanssi_mb_trim.
1001
+ *
1002
+ * @param string $string String to trim.
1003
+ */
1004
+ function relevanssi_array_walk_trim( &$string ) {
1005
+ $string = relevanssi_mb_trim( $string );
1006
+ }
1007
+
1008
  /**
1009
  * Removes punctuation from a string.
1010
  *
1042
  }
1043
 
1044
  $quote_replacement = ' ';
1045
+ if ( isset( $punct_options['quotes'] ) && 'remove' === $punct_options['quotes'] ) {
1046
  $quote_replacement = '';
1047
  }
1048
 
1071
  '©' => '',
1072
  '­' => '',
1073
  ' ' => ' ',
 
1074
  chr( 194 ) . chr( 160 ) => ' ',
1075
  '×' => ' ',
1076
+ '’' => $quote_replacement,
1077
  "'" => $quote_replacement,
1078
  '’' => $quote_replacement,
1079
  '‘' => $quote_replacement,
1490
  $key = strval( trim( $parts[0] ) );
1491
  $value = trim( $parts[1] );
1492
 
1493
+ if ( is_numeric( $key ) ) {
1494
+ $key = " $key";
1495
+ }
1496
  $synonyms[ $key ][ $value ] = true;
1497
  }
1498
 
1506
 
1507
  foreach ( $terms as $term ) {
1508
  $term = trim( $term );
1509
+ if ( is_numeric( $term ) ) {
1510
+ $term = " $term";
1511
+ }
1512
+ if ( in_array( $term, array_keys( $synonyms ), true ) ) { // Strval(), otherwise numbers cause problems.
1513
  if ( isset( $synonyms[ strval( $term ) ] ) ) { // Necessary, otherwise terms like "02" can cause problems.
1514
  $new_terms = array_merge( $new_terms, array_keys( $synonyms[ strval( $term ) ] ) );
1515
  }
1516
  }
1517
  }
1518
  if ( count( $new_terms ) > 0 ) {
1519
+ $new_terms = array_unique( $new_terms );
1520
  foreach ( $new_terms as $new_term ) {
1521
  $query .= " $new_term";
1522
  }
1523
  }
1524
  }
1525
  }
1526
+
1527
  return $query;
1528
  }
1529
 
1802
  if ( is_object( $post ) && property_exists( $post, 'relevanssi_link' ) ) {
1803
  $link = $post->relevanssi_link;
1804
  }
1805
+ if ( is_search() ) {
1806
+ $link = relevanssi_add_highlight( $link );
1807
+ }
1808
  return $link;
1809
  }
1810
 
2042
  return '';
2043
  }
2044
 
2045
+ if ( '#' !== substr( $color, 0, 1 ) ) {
2046
+ $color = '#' . $color;
2047
+ }
2048
+
2049
  // 3 or 6 hex digits, or the empty string.
2050
  if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
2051
  return $color;
lib/excerpts-highlights.php CHANGED
@@ -278,28 +278,31 @@ function relevanssi_create_excerpt( $content, $terms, $query ) {
278
  * takes slices.
279
  */
280
  $words = array_filter( explode( ' ', $content ) );
281
- $i = 0;
282
  $tries = 0;
283
  $count_words = count( $words );
284
- while ( $i < $count_words ) {
285
- if ( $i + $excerpt_length > $count_words ) {
286
- $i = $count_words - $excerpt_length;
287
- if ( $i < 0 ) {
288
- $i = 0;
289
  }
290
  }
291
 
292
- $excerpt_slice = array_slice( $words, $i, $excerpt_length );
293
  $excerpt_slice = ' ' . implode( ' ', $excerpt_slice );
294
 
295
  $term_hits = 0;
296
  $count_matches = relevanssi_count_matches( array_keys( $terms ), $excerpt_slice );
297
- if ( $count_matches > 0 ) {
298
- $tries++;
299
- }
300
  if ( $count_matches > 0 && $count_matches > $best_excerpt_term_hits ) {
301
  $best_excerpt_term_hits = $count_matches;
302
  $excerpt = $excerpt_slice;
 
 
 
 
 
 
303
  }
304
 
305
  /**
@@ -318,7 +321,7 @@ function relevanssi_create_excerpt( $content, $terms, $query ) {
318
  }
319
  }
320
 
321
- $i += $excerpt_length;
322
  }
323
 
324
  if ( '' === $excerpt ) {
@@ -461,6 +464,7 @@ function relevanssi_highlight_terms( $content, $query, $in_docs = false ) {
461
 
462
  $remove_stopwords = true;
463
  $terms = array_keys( relevanssi_tokenize( $query, $remove_stopwords, $min_word_length ) );
 
464
 
465
  if ( is_array( $query ) ) {
466
  $query = implode( ' ', $query );
@@ -787,8 +791,8 @@ function relevanssi_count_matches( $words, $complete_text ) {
787
 
788
  $count_words = count( $words );
789
  for ( $t = 0; $t < $count_words; $t++ ) {
790
- $word_slice = relevanssi_strtolower( $words[ $t ], 'UTF-8' );
791
- $lines = explode( $word_slice, $lowercase_text );
792
  if ( count( $lines ) > 1 ) {
793
  $count_lines = count( $lines );
794
  for ( $tt = 0; $tt < $count_lines; $tt++ ) {
@@ -1043,6 +1047,8 @@ function relevanssi_remove_page_builder_shortcodes( $content ) {
1043
  '/\[\/?fusion_.*?\]/',
1044
  // Max Mega Menu doesn't work in excerpts.
1045
  '/\[maxmegamenu.*?\]/',
 
 
1046
  ));
1047
  $content = preg_replace( $search_array, '', $content );
1048
  return $content;
278
  * takes slices.
279
  */
280
  $words = array_filter( explode( ' ', $content ) );
281
+ $offset = 0;
282
  $tries = 0;
283
  $count_words = count( $words );
284
+ while ( $offset < $count_words ) {
285
+ if ( $offset + $excerpt_length > $count_words ) {
286
+ $offset = $count_words - $excerpt_length;
287
+ if ( $offset < 0 ) {
288
+ $offset = 0;
289
  }
290
  }
291
 
292
+ $excerpt_slice = array_slice( $words, $offset, $excerpt_length );
293
  $excerpt_slice = ' ' . implode( ' ', $excerpt_slice );
294
 
295
  $term_hits = 0;
296
  $count_matches = relevanssi_count_matches( array_keys( $terms ), $excerpt_slice );
 
 
 
297
  if ( $count_matches > 0 && $count_matches > $best_excerpt_term_hits ) {
298
  $best_excerpt_term_hits = $count_matches;
299
  $excerpt = $excerpt_slice;
300
+ if ( 0 === $offset ) {
301
+ $start = true;
302
+ }
303
+ }
304
+ if ( $count_matches > 0 ) {
305
+ $tries++;
306
  }
307
 
308
  /**
321
  }
322
  }
323
 
324
+ $offset += $excerpt_length;
325
  }
326
 
327
  if ( '' === $excerpt ) {
464
 
465
  $remove_stopwords = true;
466
  $terms = array_keys( relevanssi_tokenize( $query, $remove_stopwords, $min_word_length ) );
467
+ array_walk( $terms, 'relevanssi_array_walk_trim' ); // Numeric search terms begin with a space.
468
 
469
  if ( is_array( $query ) ) {
470
  $query = implode( ' ', $query );
791
 
792
  $count_words = count( $words );
793
  for ( $t = 0; $t < $count_words; $t++ ) {
794
+ $word_slice = relevanssi_strtolower( relevanssi_add_accent_variations( $words[ $t ] ), 'UTF-8' );
795
+ $lines = preg_split( "/$word_slice/", $lowercase_text );
796
  if ( count( $lines ) > 1 ) {
797
  $count_lines = count( $lines );
798
  for ( $tt = 0; $tt < $count_lines; $tt++ ) {
1047
  '/\[\/?fusion_.*?\]/',
1048
  // Max Mega Menu doesn't work in excerpts.
1049
  '/\[maxmegamenu.*?\]/',
1050
+ // All-in-one Events Calendar shortcode doesn't look good.
1051
+ '/\[ai1ec.*?\]/',
1052
  ));
1053
  $content = preg_replace( $search_array, '', $content );
1054
  return $content;
lib/indexing.php CHANGED
@@ -725,7 +725,6 @@ function relevanssi_index_doc( $index_post, $remove_first = false, $custom_field
725
  * @param object $post The full post object.
726
  */
727
  $filtered_title = apply_filters( 'relevanssi_post_title_before_tokenize', $post->post_title, $post );
728
-
729
  /** This filter is documented in wp-includes/post-template.php */
730
  $filtered_title = apply_filters( 'the_title', $filtered_title, $post->ID );
731
  /**
@@ -734,6 +733,7 @@ function relevanssi_index_doc( $index_post, $remove_first = false, $custom_field
734
  * @param boolean If true, remove stopwords. Default true.
735
  */
736
  $title_tokens = relevanssi_tokenize( $filtered_title, apply_filters( 'relevanssi_remove_stopwords_in_titles', true ), $min_word_length );
 
737
  if ( $debug ) {
738
  relevanssi_debug_echo( "\tTitle, tokenized: " . implode( ' ', array_keys( $titles ) ) );
739
  }
@@ -856,6 +856,7 @@ function relevanssi_index_doc( $index_post, $remove_first = false, $custom_field
856
  remove_shortcode( 'edd_register' );
857
  remove_shortcode( 'swpm_protected' ); // Simple Membership Partially Protected content.
858
  remove_shortcode( 'gravityform' ); // Gravity Forms.
 
859
 
860
  $post_before_shortcode = $post;
861
  $contents = do_shortcode( $contents );
725
  * @param object $post The full post object.
726
  */
727
  $filtered_title = apply_filters( 'relevanssi_post_title_before_tokenize', $post->post_title, $post );
 
728
  /** This filter is documented in wp-includes/post-template.php */
729
  $filtered_title = apply_filters( 'the_title', $filtered_title, $post->ID );
730
  /**
733
  * @param boolean If true, remove stopwords. Default true.
734
  */
735
  $title_tokens = relevanssi_tokenize( $filtered_title, apply_filters( 'relevanssi_remove_stopwords_in_titles', true ), $min_word_length );
736
+
737
  if ( $debug ) {
738
  relevanssi_debug_echo( "\tTitle, tokenized: " . implode( ' ', array_keys( $titles ) ) );
739
  }
856
  remove_shortcode( 'edd_register' );
857
  remove_shortcode( 'swpm_protected' ); // Simple Membership Partially Protected content.
858
  remove_shortcode( 'gravityform' ); // Gravity Forms.
859
+ remove_shortcode( 'sdm_latest_downloads' ); // SDM Simple Download Monitor.
860
 
861
  $post_before_shortcode = $post;
862
  $contents = do_shortcode( $contents );
lib/init.php CHANGED
@@ -54,6 +54,7 @@ add_filter( 'relevanssi_search_ok', 'relevanssi_acf_relationship_fields' );
54
  // Permalink handling.
55
  add_filter( 'the_permalink', 'relevanssi_permalink' );
56
  add_filter( 'post_link', 'relevanssi_permalink' );
 
57
  add_filter( 'relevanssi_permalink', 'relevanssi_permalink' );
58
 
59
  global $relevanssi_variables;
54
  // Permalink handling.
55
  add_filter( 'the_permalink', 'relevanssi_permalink' );
56
  add_filter( 'post_link', 'relevanssi_permalink' );
57
+ add_filter( 'page_link', 'relevanssi_permalink' );
58
  add_filter( 'relevanssi_permalink', 'relevanssi_permalink' );
59
 
60
  global $relevanssi_variables;
lib/install.php CHANGED
@@ -89,7 +89,6 @@ function _relevanssi_install() {
89
  add_option( 'relevanssi_highlight', 'strong' );
90
  add_option( 'relevanssi_highlight_comments', 'off' );
91
  add_option( 'relevanssi_highlight_docs', 'off' );
92
- add_option( 'relevanssi_highlight_docs_external', 'off' );
93
  add_option( 'relevanssi_hilite_title', '' );
94
  add_option( 'relevanssi_implicit_operator', 'OR' );
95
  add_option( 'relevanssi_index_author', '' );
89
  add_option( 'relevanssi_highlight', 'strong' );
90
  add_option( 'relevanssi_highlight_comments', 'off' );
91
  add_option( 'relevanssi_highlight_docs', 'off' );
 
92
  add_option( 'relevanssi_hilite_title', '' );
93
  add_option( 'relevanssi_implicit_operator', 'OR' );
94
  add_option( 'relevanssi_index_author', '' );
lib/interface.php CHANGED
@@ -479,141 +479,6 @@ function relevanssi_truncate_logs( $verbose = true ) {
479
  return $result;
480
  }
481
 
482
- /**
483
- * Adds a stopword to the list of stopwords.
484
- *
485
- * @global object $wpdb The WP database interface.
486
- *
487
- * @param string $term The stopword that is added.
488
- * @param boolean $verbose If true, print out notice. If false, be silent. Default
489
- * true.
490
- *
491
- * @return boolean True, if success; false otherwise.
492
- */
493
- function relevanssi_add_stopword( $term, $verbose = true ) {
494
- global $wpdb;
495
- if ( empty( $term ) ) {
496
- return;
497
- }
498
-
499
- $n = 0;
500
- $s = 0;
501
-
502
- $terms = explode( ',', $term );
503
- if ( count( $terms ) > 1 ) {
504
- foreach ( $terms as $term ) {
505
- $n++;
506
- $term = trim( $term );
507
- $success = relevanssi_add_single_stopword( $term );
508
- if ( $success ) {
509
- $s++;
510
- }
511
- }
512
- if ( $verbose ) {
513
- // translators: %1$d is the successful entries, %2$d is the total entries.
514
- printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( 'Successfully added %1$d/%2$d terms to stopwords!', 'relevanssi' ), intval( $s ), intval( $n ) ) );
515
- }
516
- } else {
517
- // Add to stopwords.
518
- $success = relevanssi_add_single_stopword( $term );
519
-
520
- $term = stripslashes( $term );
521
- $term = esc_html( $term );
522
- if ( $verbose ) {
523
- if ( $success ) {
524
- // Translators: %s is the stopword.
525
- printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( "Term '%s' added to stopwords!", 'relevanssi' ), esc_html( stripslashes( $term ) ) ) );
526
- } else {
527
- // Translators: %s is the stopword.
528
- printf( esc_html__( "<div id='message' class='updated fade'><p>Couldn't add term '%s' to stopwords!</p></div>", 'relevanssi' ), esc_html( stripslashes( $term ) ) );
529
- }
530
- }
531
- }
532
-
533
- return $success;
534
- }
535
-
536
- /**
537
- * Adds a single stopword to the stopword table.
538
- *
539
- * @global object $wpdb The WP database interface.
540
- * @global array $relevanssi_variables The global Relevanssi variables.
541
- *
542
- * @param string $term The term to add.
543
- *
544
- * @return boolean True if success, false if not.
545
- */
546
- function relevanssi_add_single_stopword( $term ) {
547
- global $wpdb, $relevanssi_variables;
548
- if ( empty( $term ) ) {
549
- return false;
550
- }
551
-
552
- $term = stripslashes( $term );
553
- $term = esc_sql( $wpdb->esc_like( $term ) );
554
-
555
- $success = $wpdb->query( $wpdb->prepare( 'INSERT INTO ' . $relevanssi_variables['stopword_table'] . ' (stopword) VALUES (%s)', $term ) ); // WPCS: unprepared SQL ok, Relevanssi table name.
556
-
557
- if ( $success ) {
558
- // Remove from index.
559
- $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE term=%s', $term ) ); // WPCS: unprepared SQL ok, Relevanssi table name.
560
- return true;
561
- } else {
562
- return false;
563
- }
564
- }
565
-
566
- /**
567
- * Removes all stopwords.
568
- *
569
- * Truncates the wp_relevanssi_stopwords database table.
570
- *
571
- * @global object $wpdb The WP database interface.
572
- * @global array $relevanssi_variables The global Relevanssi variables.
573
- */
574
- function relevanssi_remove_all_stopwords() {
575
- global $wpdb, $relevanssi_variables;
576
-
577
- $success = $wpdb->query( 'TRUNCATE ' . $relevanssi_variables['stopword_table'] ); // WPCS: unprepared SQL ok, Relevanssi table name.
578
-
579
- if ( $success ) {
580
- printf( "<div id='message' class='updated fade'><p>%s</p></div>", esc_html__( 'All stopwords removed! Remember to re-index.', 'relevanssi' ) );
581
- } else {
582
- printf( "<div id='message' class='updated fade'><p>%s</p></div>", esc_html__( "There was a problem, and stopwords couldn't be removed.", 'relevanssi' ) );
583
- }
584
- }
585
-
586
- /**
587
- * Removes a single stopword.
588
- *
589
- * @global object $wpdb The WP database interface.
590
- * @global array $relevanssi_variables The global Relevanssi variables.
591
- *
592
- * @param string $term The stopword to remove.
593
- * @param boolean $verbose If true, print out a notice. Default true.
594
- *
595
- * @return boolean True if success, false if not.
596
- */
597
- function relevanssi_remove_stopword( $term, $verbose = true ) {
598
- global $wpdb, $relevanssi_variables;
599
-
600
- $success = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $relevanssi_variables['stopword_table'] . ' WHERE stopword=%s', $term ) ); // WPCS: unprepared SQL ok, Relevanssi table name.
601
-
602
- if ( $success ) {
603
- if ( $verbose ) {
604
- // Translators: %s is the stopword.
605
- printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( "Term '%s' removed from stopwords! Re-index to get it back to index.", 'relevanssi' ), esc_html( stripslashes( $term ) ) ) );
606
- }
607
- return true;
608
- } else {
609
- if ( $verbose ) {
610
- // Translators: %s is the stopword.
611
- printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( "Couldn't remove term '%s' from stopwords!", 'relevanssi' ), esc_html( stripslashes( $term ) ) ) );
612
- }
613
- return false;
614
- }
615
- }
616
-
617
  /**
618
  * Displays the list of most common words in the index.
619
  *
@@ -887,58 +752,25 @@ function relevanssi_options_form() {
887
  wp_enqueue_script( 'dashboard' );
888
  wp_print_scripts( 'dashboard' );
889
 
890
- $serialize_options = array();
891
-
892
- $content_boost = get_option( 'relevanssi_content_boost' );
893
- $title_boost = get_option( 'relevanssi_title_boost' );
894
- $comment_boost = get_option( 'relevanssi_comment_boost' );
895
- $admin_search = get_option( 'relevanssi_admin_search' );
896
- $index_limit = get_option( 'relevanssi_index_limit' );
897
  $excerpts = get_option( 'relevanssi_excerpts' );
898
  $excerpt_length = get_option( 'relevanssi_excerpt_length' );
899
  $excerpt_type = get_option( 'relevanssi_excerpt_type' );
900
  $excerpt_allowable_tags = get_option( 'relevanssi_excerpt_allowable_tags' );
901
  $excerpt_custom_fields = get_option( 'relevanssi_excerpt_custom_fields' );
902
- $log_queries = get_option( 'relevanssi_log_queries' );
903
- $log_queries_with_ip = get_option( 'relevanssi_log_queries_with_ip' );
904
- $trim_logs = get_option( 'relevanssi_trim_logs' );
905
- $hide_branding = get_option( 'relevanssi_hide_branding' );
906
  $highlight = get_option( 'relevanssi_highlight' );
907
- $index_fields = get_option( 'relevanssi_index_fields' );
908
  $txt_col = get_option( 'relevanssi_txt_col' );
909
  $bg_col = get_option( 'relevanssi_bg_col' );
910
  $css = get_option( 'relevanssi_css' );
911
  $class = get_option( 'relevanssi_class' );
912
- $cat = get_option( 'relevanssi_cat' );
913
- $excat = get_option( 'relevanssi_excat' );
914
- $fuzzy = get_option( 'relevanssi_fuzzy' );
915
- $implicit = get_option( 'relevanssi_implicit_operator' );
916
- $expand_shortcodes = get_option( 'relevanssi_expand_shortcodes' );
917
- $disable_or_fallback = get_option( 'relevanssi_disable_or_fallback' );
918
- $throttle = get_option( 'relevanssi_throttle' );
919
- $throttle_limit = get_option( 'relevanssi_throttle_limit' );
920
- $omit_from_logs = get_option( 'relevanssi_omit_from_logs' );
921
  $synonyms = get_option( 'relevanssi_synonyms' );
922
- $exclude_posts = get_option( 'relevanssi_exclude_posts' );
923
  $highlight_title = get_option( 'relevanssi_hilite_title' );
924
  $index_comments = get_option( 'relevanssi_index_comments' );
925
  $highlight_docs = get_option( 'relevanssi_highlight_docs' );
926
  $highlight_coms = get_option( 'relevanssi_highlight_comments' );
927
- $respect_exclude = get_option( 'relevanssi_respect_exclude' );
928
- $min_word_length = get_option( 'relevanssi_min_word_length' );
929
- $index_author = get_option( 'relevanssi_index_author' );
930
- $index_excerpt = get_option( 'relevanssi_index_excerpt' );
931
  $show_matches = get_option( 'relevanssi_show_matches' );
932
  $show_matches_text = get_option( 'relevanssi_show_matches_text' );
933
- $wpml_only_current = get_option( 'relevanssi_wpml_only_current' );
934
- $polylang_allow_all = get_option( 'relevanssi_polylang_all_languages' );
935
  $word_boundaries = get_option( 'relevanssi_word_boundaries' );
936
- $post_type_weights = get_option( 'relevanssi_post_type_weights' );
937
- $index_post_types = get_option( 'relevanssi_index_post_types' );
938
- $index_taxonomies_list = get_option( 'relevanssi_index_taxonomies_list' );
939
- $orderby = get_option( 'relevanssi_default_orderby' );
940
  $punctuation = get_option( 'relevanssi_punctuation' );
941
- $exact_match_bonus = get_option( 'relevanssi_exact_match_bonus' );
942
 
943
  if ( '#' !== substr( $txt_col, 0, 1 ) ) {
944
  $txt_col = '#' . $txt_col;
@@ -949,90 +781,15 @@ function relevanssi_options_form() {
949
  }
950
  $bg_col = relevanssi_sanitize_hex_color( $bg_col );
951
 
952
- if ( empty( $index_post_types ) ) {
953
- $index_post_types = array();
954
- }
955
- if ( empty( $index_taxonomies_list ) ) {
956
- $index_taxonomies_list = array();
957
- }
958
-
959
- $serialize_options['relevanssi_content_boost'] = $content_boost;
960
- $serialize_options['relevanssi_title_boost'] = $title_boost;
961
- $serialize_options['relevanssi_comment_boost'] = $comment_boost;
962
- $serialize_options['relevanssi_admin_search'] = $admin_search;
963
- $serialize_options['relevanssi_index_limit'] = $index_limit;
964
- $serialize_options['relevanssi_excerpts'] = $excerpts;
965
- $serialize_options['relevanssi_excerpt_length'] = $excerpt_length;
966
- $serialize_options['relevanssi_excerpt_type'] = $excerpt_type;
967
- $serialize_options['relevanssi_excerpt_allowable_tags'] = $excerpt_allowable_tags;
968
- $serialize_options['relevanssi_excerpt_custom_fields'] = $excerpt_custom_fields;
969
- $serialize_options['relevanssi_log_queries'] = $log_queries;
970
- $serialize_options['relevanssi_log_queries_with_ip'] = $log_queries_with_ip;
971
- $serialize_options['relevanssi_trim_logs'] = $trim_logs;
972
- $serialize_options['relevanssi_hide_branding'] = $hide_branding;
973
- $serialize_options['relevanssi_highlight'] = $highlight;
974
- $serialize_options['relevanssi_index_fields'] = $index_fields;
975
- $serialize_options['relevanssi_txt_col'] = $txt_col;
976
- $serialize_options['relevanssi_bg_col'] = $bg_col;
977
- $serialize_options['relevanssi_css'] = $css;
978
- $serialize_options['relevanssi_class'] = $class;
979
- $serialize_options['relevanssi_cat'] = $cat;
980
- $serialize_options['relevanssi_excat'] = $excat;
981
- $serialize_options['relevanssi_fuzzy'] = $fuzzy;
982
- $serialize_options['relevanssi_implicit_operator'] = $implicit;
983
- $serialize_options['relevanssi_expand_shortcodes'] = $expand_shortcodes;
984
- $serialize_options['relevanssi_disable_or_fallback'] = $disable_or_fallback;
985
- $serialize_options['relevanssi_throttle'] = $throttle;
986
- $serialize_options['relevanssi_throttle_limit'] = $throttle_limit;
987
- $serialize_options['relevanssi_omit_from_logs'] = $omit_from_logs;
988
- $serialize_options['relevanssi_synonyms'] = $synonyms;
989
- $serialize_options['relevanssi_exclude_posts'] = $exclude_posts;
990
- $serialize_options['relevanssi_hilite_title'] = $highlight_title;
991
- $serialize_options['relevanssi_index_comments'] = $index_comments;
992
- $serialize_options['relevanssi_highlight_docs'] = $highlight_docs;
993
- $serialize_options['relevanssi_highlight_comments'] = $highlight_coms;
994
- $serialize_options['relevanssi_respect_exclude'] = $respect_exclude;
995
- $serialize_options['relevanssi_min_word_length'] = $min_word_length;
996
- $serialize_options['relevanssi_index_author'] = $index_author;
997
- $serialize_options['relevanssi_index_excerpt'] = $index_excerpt;
998
- $serialize_options['relevanssi_show_matches'] = $show_matches;
999
- $serialize_options['relevanssi_show_matches_text'] = $show_matches_text;
1000
- $serialize_options['relevanssi_wpml_only_current'] = $wpml_only_current;
1001
- $serialize_options['relevanssi_polylang_all_languages'] = $polylang_allow_all;
1002
- $serialize_options['relevanssi_word_boundaries'] = $word_boundaries;
1003
- $serialize_options['relevanssi_post_type_weights'] = $post_type_weights;
1004
- $serialize_options['relevanssi_index_post_types'] = $index_post_types;
1005
- $serialize_options['relevanssi_index_taxonomies_list'] = $index_taxonomies_list;
1006
- $serialize_options['relevanssi_default_orderby'] = $orderby;
1007
- $serialize_options['relevanssi_punctuation'] = $punctuation;
1008
- $serialize_options['relevanssi_exact_match_bonus'] = $exact_match_bonus;
1009
-
1010
- $admin_search = relevanssi_check( $admin_search );
1011
  $excerpts = relevanssi_check( $excerpts );
1012
  $excerpt_custom_fields = relevanssi_check( $excerpt_custom_fields );
1013
- $log_queries = relevanssi_check( $log_queries );
1014
- $log_queries_with_ip = relevanssi_check( $log_queries_with_ip );
1015
- $hide_branding = relevanssi_check( $hide_branding );
1016
- $expand_shortcodes = relevanssi_check( $expand_shortcodes );
1017
- $disable_or_fallback = relevanssi_check( $disable_or_fallback );
1018
- $throttle = relevanssi_check( $throttle );
1019
  $highlight_title = relevanssi_check( $highlight_title );
1020
  $highlight_docs = relevanssi_check( $highlight_docs );
1021
  $highlight_coms = relevanssi_check( $highlight_coms );
1022
- $respect_exclude = relevanssi_check( $respect_exclude );
1023
- $index_author = relevanssi_check( $index_author );
1024
- $index_excerpt = relevanssi_check( $index_excerpt );
1025
  $show_matches = relevanssi_check( $show_matches );
1026
- $wpml_only_current = relevanssi_check( $wpml_only_current );
1027
- $polylang_allow_all = relevanssi_check( $polylang_allow_all );
1028
  $word_boundaries = relevanssi_check( $word_boundaries );
1029
- $exact_match_bonus = relevanssi_check( $exact_match_bonus );
1030
-
1031
  $excerpt_chars = relevanssi_select( $excerpt_type, 'chars' );
1032
  $excerpt_words = relevanssi_select( $excerpt_type, 'words' );
1033
- $fuzzy_sometimes = relevanssi_select( $fuzzy, 'sometimes' );
1034
- $fuzzy_always = relevanssi_select( $fuzzy, 'always' );
1035
- $fuzzy_never = relevanssi_select( $fuzzy, 'never' );
1036
  $highlight_none = relevanssi_select( $highlight, 'no' );
1037
  $highlight_mark = relevanssi_select( $highlight, 'mark' );
1038
  $highlight_em = relevanssi_select( $highlight, 'em' );
@@ -1041,13 +798,6 @@ function relevanssi_options_form() {
1041
  $highlight_bgcol = relevanssi_select( $highlight, 'bgcol' );
1042
  $highlight_style = relevanssi_select( $highlight, 'style' );
1043
  $highlight_class = relevanssi_select( $highlight, 'class' );
1044
- $implicit_and = relevanssi_select( $implicit, 'AND' );
1045
- $implicit_or = relevanssi_select( $implicit, 'OR' );
1046
- $index_comments_all = relevanssi_select( $index_comments, 'all' );
1047
- $index_comments_normal = relevanssi_select( $index_comments, 'normal' );
1048
- $index_comments_none = relevanssi_select( $index_comments, 'none' );
1049
- $orderby_relevance = relevanssi_select( $orderby, 'relevance' );
1050
- $orderby_date = relevanssi_select( $orderby, 'post_date' );
1051
 
1052
  $show_matches_text = stripslashes( $show_matches_text );
1053
 
@@ -1069,130 +819,22 @@ function relevanssi_options_form() {
1069
  $class_display = '';
1070
  }
1071
 
1072
- $orfallback_visibility = 'screen-reader-text';
1073
- if ( 'AND' === $implicit ) {
1074
- $orfallback_visibility = '';
1075
- }
1076
-
1077
- $fields_select_all = '';
1078
- $fields_select_none = '';
1079
- $fields_select_some = 'selected';
1080
- $fields_select_visible = '';
1081
- $original_index_fields = $index_fields;
1082
-
1083
- if ( empty( $index_fields ) ) {
1084
- $fields_select_none = 'selected';
1085
- $fields_select_some = '';
1086
- }
1087
- if ( 'all' === $index_fields ) {
1088
- $fields_select_all = 'selected';
1089
- $fields_select_some = '';
1090
- $index_fields = '';
1091
- }
1092
- if ( 'visible' === $index_fields ) {
1093
- $fields_select_visible = 'selected';
1094
- $fields_select_some = '';
1095
- $index_fields = '';
1096
- }
1097
-
1098
  if ( isset( $synonyms ) ) {
1099
  $synonyms = str_replace( ';', "\n", $synonyms );
1100
  } else {
1101
  $synonyms = '';
1102
  }
1103
 
1104
- if ( ! isset( $punctuation['quotes'] ) ) {
1105
- $punctuation['quotes'] = 'replace';
1106
- }
1107
- if ( ! isset( $punctuation['decimals'] ) ) {
1108
- $punctuation['decimals'] = 'remove';
1109
- }
1110
- if ( ! isset( $punctuation['ampersands'] ) ) {
1111
- $punctuation['ampersands'] = 'replace';
1112
- }
1113
- if ( ! isset( $punctuation['hyphens'] ) ) {
1114
- $punctuation['hyphens'] = 'replace';
1115
- }
1116
- $punct_quotes_replace = relevanssi_select( $punctuation['quotes'], 'replace' );
1117
- $punct_quotes_remove = relevanssi_select( $punctuation['quotes'], 'remove' );
1118
- $punct_decimals_replace = relevanssi_select( $punctuation['decimals'], 'replace' );
1119
- $punct_decimals_remove = relevanssi_select( $punctuation['decimals'], 'remove' );
1120
- $punct_decimals_keep = relevanssi_select( $punctuation['decimals'], 'keep' );
1121
- $punct_ampersands_replace = relevanssi_select( $punctuation['ampersands'], 'replace' );
1122
- $punct_ampersands_remove = relevanssi_select( $punctuation['ampersands'], 'remove' );
1123
- $punct_ampersands_keep = relevanssi_select( $punctuation['ampersands'], 'keep' );
1124
- $punct_hyphens_replace = relevanssi_select( $punctuation['hyphens'], 'replace' );
1125
- $punct_hyphens_remove = relevanssi_select( $punctuation['hyphens'], 'remove' );
1126
- $punct_hyphens_keep = relevanssi_select( $punctuation['hyphens'], 'keep' );
1127
-
1128
  if ( RELEVANSSI_PREMIUM ) {
1129
- $api_key = get_option( 'relevanssi_api_key' );
1130
- $link_boost = get_option( 'relevanssi_link_boost' );
1131
- $internal_links = get_option( 'relevanssi_internal_links' );
1132
- $highlight_docs_ext = get_option( 'relevanssi_highlight_docs_external' );
1133
- $thousand_separator = get_option( 'relevanssi_thousand_separator' );
1134
- $disable_shortcodes = get_option( 'relevanssi_disable_shortcodes' );
1135
- $index_users = get_option( 'relevanssi_index_users' );
1136
- $index_user_fields = get_option( 'relevanssi_index_user_fields' );
1137
- $index_subscribers = get_option( 'relevanssi_index_subscribers' );
1138
- $index_synonyms = get_option( 'relevanssi_index_synonyms' );
1139
- $index_taxonomies = get_option( 'relevanssi_index_taxonomies' );
1140
- $index_terms = get_option( 'relevanssi_index_terms' );
1141
- $hide_post_controls = get_option( 'relevanssi_hide_post_controls' );
1142
- $show_post_controls = get_option( 'relevanssi_show_post_controls' );
1143
- $recency_bonus_array = get_option( 'relevanssi_recency_bonus' );
1144
- $searchblogs = get_option( 'relevanssi_searchblogs' );
1145
- $searchblogs_all = get_option( 'relevanssi_searchblogs_all' );
1146
- $mysql_columns = get_option( 'relevanssi_mysql_columns' );
1147
- $index_pdf_parent = get_option( 'relevanssi_index_pdf_parent' );
1148
- $server_location = get_option( 'relevanssi_server_location' );
1149
-
1150
- if ( empty( $index_terms ) ) {
1151
- $index_terms = array();
1152
- }
1153
 
1154
- $serialize_options['relevanssi_link_boost'] = $link_boost;
1155
- $serialize_options['relevanssi_api_key'] = $api_key;
1156
- $serialize_options['relevanssi_internal_links'] = $internal_links;
1157
- $serialize_options['relevanssi_highlight_docs_external'] = $highlight_docs_ext;
1158
- $serialize_options['relevanssi_thousand_separator'] = $thousand_separator;
1159
- $serialize_options['relevanssi_disable_shortcodes'] = $disable_shortcodes;
1160
- $serialize_options['relevanssi_index_users'] = $index_users;
1161
- $serialize_options['relevanssi_index_user_fields'] = $index_user_fields;
1162
- $serialize_options['relevanssi_index_subscribers'] = $index_subscribers;
1163
- $serialize_options['relevanssi_index_synonyms'] = $index_synonyms;
1164
- $serialize_options['relevanssi_index_taxonomies'] = $index_taxonomies;
1165
- $serialize_options['relevanssi_index_terms'] = $index_terms;
1166
- $serialize_options['relevanssi_hide_post_controls'] = $hide_post_controls;
1167
- $serialize_options['relevanssi_show_post_controls'] = $show_post_controls;
1168
- $serialize_options['recency_bonus'] = $recency_bonus_array;
1169
- $serialize_options['relevanssi_searchblogs'] = $searchblogs;
1170
- $serialize_options['relevanssi_searchblogs_all'] = $searchblogs_all;
1171
- $serialize_options['relevanssi_mysql_columns'] = $mysql_columns;
1172
- $serialize_options['relevanssi_index_pdf_parent'] = $index_pdf_parent;
1173
- $serialize_options['relevanssi_server_location'] = get_option( 'relevanssi_server_location' );
1174
- $serialize_options['relevanssi_send_pdf_files'] = get_option( 'relevanssi_send_pdf_files' );
1175
- $serialize_options['relevanssi_read_new_files'] = get_option( 'relevanssi_read_new_files' );
1176
- $serialize_options['relevanssi_link_pdf_files'] = get_option( 'relevanssi_link_pdf_files' );
1177
-
1178
- $highlight_docs_ext = relevanssi_check( $highlight_docs_ext );
1179
- $index_users = relevanssi_check( $index_users );
1180
- $index_subscribers = relevanssi_check( $index_subscribers );
1181
- $index_synonyms = relevanssi_check( $index_synonyms );
1182
- $index_taxonomies = relevanssi_check( $index_taxonomies );
1183
  $hide_post_controls = relevanssi_check( $hide_post_controls );
1184
  $show_post_controls = relevanssi_check( $show_post_controls );
1185
- $searchblogs_all = relevanssi_check( $searchblogs_all );
1186
- $index_pdf_parent = relevanssi_check( $index_pdf_parent );
1187
-
1188
- $internal_links_strip = relevanssi_select( $internal_links, 'strip' );
1189
- $internal_links_nostrip = relevanssi_select( $internal_links, 'nostrip' );
1190
- $internal_links_noindex = relevanssi_select( $internal_links, 'noindex' );
1191
-
1192
- $recency_bonus = $recency_bonus_array['bonus'];
1193
- $recency_bonus_days = $recency_bonus_array['days'];
1194
-
1195
- $serialized_options = wp_json_encode( $serialize_options );
1196
  }
1197
 
1198
  echo "<div class='postbox-container'>";
@@ -1325,418 +967,21 @@ if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
1325
 
1326
  <?php endif; // Active tab: basic. ?>
1327
 
1328
- <?php if ( 'logging' === $active_tab ) : ?>
1329
-
1330
- <table class="form-table">
1331
- <tr>
1332
- <th scope="row">
1333
- <label for='relevanssi_log_queries'><?php esc_html_e( 'Enable logs', 'relevanssi' ); ?></label>
1334
- </th>
1335
- <td>
1336
- <fieldset>
1337
- <legend class="screen-reader-text"><?php esc_html_e( 'Keep a log of user queries.', 'relevanssi' ); ?></legend>
1338
- <label for='relevanssi_log_queries'>
1339
- <input type='checkbox' name='relevanssi_log_queries' id='relevanssi_log_queries' <?php echo esc_html( $log_queries ); ?> />
1340
- <?php esc_html_e( 'Keep a log of user queries.', 'relevanssi' ); ?>
1341
- </label>
1342
- </fieldset>
1343
- <p class="description">
1344
- <?php
1345
- global $wpdb;
1346
- // Translators: %1$s is the name of the "User searches" page, %2$s is the name of the database table.
1347
- printf( esc_html__( "If enabled, Relevanssi will log user queries. The logs can be examined under '%1\$s' on the Dashboard admin menu and are stored in the %2\$s database table.", 'relevanssi' ),
1348
- esc_html__( 'User searches', 'relevanssi' ), esc_html( $wpdb->prefix . 'relevanssi_log' ) );
1349
- ?>
1350
- </p>
1351
- </td>
1352
- </tr>
1353
- <tr>
1354
- <th scope="row">
1355
- <label for='relevanssi_log_queries_with_ip'><?php esc_html_e( 'Log user IP', 'relevanssi' ); ?></label>
1356
- </th>
1357
- <td>
1358
- <fieldset>
1359
- <legend class="screen-reader-text"><?php esc_html_e( "Log the user's IP with the queries.", 'relevanssi' ); ?></legend>
1360
- <label for='relevanssi_log_queries_with_ip'>
1361
- <input type='checkbox' name='relevanssi_log_queries_with_ip' id='relevanssi_log_queries_with_ip' <?php echo esc_html( $log_queries_with_ip ); ?> />
1362
- <?php esc_html_e( "Log the user's IP with the queries.", 'relevanssi' ); ?>
1363
- </label>
1364
- </fieldset>
1365
- <p class="description"><?php esc_html_e( "If enabled, Relevanssi will log user's IP adress with the queries. Note that this may be illegal where you live, and in EU will create a person registry that falls under the GDPR.", 'relevanssi' ); ?></p>
1366
- </td>
1367
- </tr>
1368
- <tr>
1369
- <th scope="row">
1370
- <label for='relevanssi_omit_from_logs'><?php esc_html_e( 'Exclude users', 'relevanssi' ); ?></label>
1371
- </th>
1372
- <td>
1373
- <input type='text' name='relevanssi_omit_from_logs' id='relevanssi_omit_from_logs' size='60' value='<?php echo esc_attr( $omit_from_logs ); ?>' />
1374
- <p class="description"><?php esc_html_e( 'Comma-separated list of numeric user IDs or user login names that will not be logged.', 'relevanssi' ); ?></p>
1375
- </td>
1376
- </tr>
1377
- <?php
1378
- if ( function_exists( 'relevanssi_form_hide_branding' ) ) {
1379
- relevanssi_form_hide_branding( $hide_branding );
1380
- }
1381
- ?>
1382
- <tr>
1383
- <th scope="row">
1384
- <label for='relevanssi_trim_logs'><?php esc_html_e( 'Trim logs', 'relevanssi' ); ?></label>
1385
- </th>
1386
- <td>
1387
- <input type='number' name='relevanssi_trim_logs' id='relevanssi_trim_logs' value='<?php echo esc_attr( $trim_logs ); ?>' />
1388
- <?php esc_html_e( 'How many days of logs to keep in the database.', 'relevanssi' ); ?>
1389
- <?php // Translators: %d is the setting for no trim (probably 0). ?>
1390
- <p class="description"><?php printf( esc_html__( ' Set to %d for no trimming.', 'relevanssi' ), 0 ); ?></p>
1391
- </td>
1392
- </tr>
1393
-
1394
- </table>
1395
-
1396
- <?php endif; // Active tag: logging. ?>
1397
-
1398
  <?php
1399
- if ( 'searching' === $active_tab ) :
1400
- $docs_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT doc) FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc != -1' ); // WPCS: unprepared SQL ok, Relevanssi table name.
1401
- ?>
1402
-
1403
- <table class="form-table">
1404
- <tr>
1405
- <th scope="row">
1406
- <label for='relevanssi_implicit_operator'><?php esc_html_e( 'Default operator', 'relevanssi' ); ?></label>
1407
- </th>
1408
- <td>
1409
- <select name='relevanssi_implicit_operator' id='relevanssi_implicit_operator'>
1410
- <option value='AND' <?php echo esc_html( $implicit_and ); ?>><?php esc_html_e( 'AND - require all terms', 'relevanssi' ); ?></option>
1411
- <option value='OR' <?php echo esc_html( $implicit_or ); ?>><?php esc_html_e( 'OR - any term present is enough', 'relevanssi' ); ?></option>
1412
- </select>
1413
- <p class="description"><?php esc_html_e( 'This setting determines the default operator for the search.', 'relevanssi' ); ?></p>
1414
- <?php
1415
- if ( RELEVANSSI_PREMIUM ) {
1416
- // Translators: %1$s is the name of the 'operator' query variable, %2$s is an example url.
1417
- echo "<p class='description'>" . sprintf( esc_html__( 'You can override this setting with the %1$s query parameter, like this: %2$s', 'relevanssi' ), '<code>operator</code>', 'http://www.example.com/?s=term&amp;operator=or' ) . '</p>';
1418
  }
1419
- ?>
1420
- </td>
1421
- </tr>
1422
- <tr id="orfallback" class='<?php echo esc_attr( $orfallback_visibility ); ?>'>
1423
- <th scope="row">
1424
- <label for='relevanssi_disable_or_fallback'><?php esc_html_e( 'Fallback to OR', 'relevanssi' ); ?></label>
1425
- </th>
1426
- <td>
1427
- <fieldset>
1428
- <legend class="screen-reader-text"><?php esc_html_e( 'Disable the OR fallback.', 'relevanssi' ); ?></legend>
1429
- <label for='relevanssi_disable_or_fallback'>
1430
- <input type='checkbox' name='relevanssi_disable_or_fallback' id='relevanssi_disable_or_fallback' <?php echo esc_html( $disable_or_fallback ); ?> />
1431
- <?php esc_html_e( 'Disable the OR fallback.', 'relevanssi' ); ?>
1432
- </label>
1433
- </fieldset>
1434
- <p class="description"><?php esc_html_e( 'By default, if AND search fails to find any results, Relevanssi will switch the operator to OR and run the search again. You can prevent that by checking this option.', 'relevanssi' ); ?></p>
1435
- </td>
1436
- </tr>
1437
- <tr>
1438
- <th scope="row">
1439
- <label for='relevanssi_default_orderby'><?php esc_html_e( 'Default order', 'relevanssi' ); ?></label>
1440
- </th>
1441
- <td>
1442
- <select name='relevanssi_default_orderby' id='relevanssi_default_orderby'>
1443
- <option value='relevance' <?php echo esc_html( $orderby_relevance ); ?>><?php esc_html_e( 'Relevance (highly recommended)', 'relevanssi' ); ?></option>
1444
- <option value='post_date' <?php echo esc_html( $orderby_date ); ?>><?php esc_html_e( 'Post date', 'relevanssi' ); ?></option>
1445
- </select>
1446
- <?php // Translators: name of the query variable. ?>
1447
- <p class="description"><?php printf( esc_html__( 'If you want to override this or use multi-layered ordering (eg. first order by relevance, but sort ties by post title), you can use the %s query variable. See Help for more information.', 'relevanssi' ), '<code>orderby</code>' ); ?></p>
1448
- <?php if ( RELEVANSSI_PREMIUM ) { ?>
1449
- <p class="description"><?php esc_html_e( ' If you want date-based results, see the recent post bonus in the Weights section.', 'relevanssi' ); ?></p>
1450
- <?php } // End if ( RELEVANSSI_PREMIUM ). ?>
1451
- </td>
1452
- </tr>
1453
- <tr>
1454
- <th scope="row">
1455
- <label for='relevanssi_fuzzy'><?php esc_html_e( 'Keyword matching', 'relevanssi' ); ?></label>
1456
- </th>
1457
- <td>
1458
- <select name='relevanssi_fuzzy' id='relevanssi_fuzzy'>
1459
- <option value='never' <?php echo esc_html( $fuzzy_never ); ?>><?php esc_html_e( 'Whole words', 'relevanssi' ); ?></option>
1460
- <option value='always' <?php echo esc_html( $fuzzy_always ); ?>><?php esc_html_e( 'Partial words', 'relevanssi' ); ?></option>
1461
- <option value='sometimes' <?php echo esc_html( $fuzzy_sometimes ); ?>><?php esc_html_e( 'Partial words if no hits for whole words', 'relevanssi' ); ?></option>
1462
- </select>
1463
- <p class="description"><?php esc_html_e( 'Whole words means Relevanssi only finds posts that include the whole search term.', 'relevanssi' ); ?></p>
1464
- <p class="description"><?php esc_html_e( "Partial words also includes cases where the word in the index begins or ends with the search term (searching for 'ana' will match 'anaconda' or 'banana', but not 'banal'). See Help, if you want to make Relevanssi match also inside words.", 'relevanssi' ); ?></p>
1465
- </td>
1466
- </tr>
1467
- <tr>
1468
- <th scope="row">
1469
- <?php esc_html_e( 'Weights', 'relevanssi' ); ?>
1470
- </th>
1471
- <td>
1472
- <p class="description"><?php esc_html_e( 'All the weights in the table are multipliers. To increase the weight of an element, use a higher number. To make an element less significant, use a number lower than 1.', 'relevanssi' ); ?></p>
1473
- <table class="relevanssi-weights-table">
1474
- <thead>
1475
- <tr>
1476
- <th><?php esc_html_e( 'Element', 'relevanssi' ); ?></th>
1477
- <th class="col-2"><?php esc_html_e( 'Weight', 'relevanssi' ); ?></th>
1478
- </tr>
1479
- </thead>
1480
- <tr>
1481
- <td>
1482
- <?php esc_html_e( 'Content', 'relevanssi' ); ?>
1483
- </td>
1484
- <td class="col-2">
1485
- <input type='text' name='relevanssi_content_boost' id='relevanssi_content_boost' size='4' value='<?php echo esc_attr( $content_boost ); ?>' />
1486
- </td>
1487
- </tr>
1488
- <tr>
1489
- <td>
1490
- <?php esc_html_e( 'Titles', 'relevanssi' ); ?>
1491
- </td>
1492
- <td class="col-2">
1493
- <input type='text' name='relevanssi_title_boost' id='relevanssi_title_boost' size='4' value='<?php echo esc_attr( $title_boost ); ?>' />
1494
- </td>
1495
- </tr>
1496
- <?php
1497
- if ( function_exists( 'relevanssi_form_link_weight' ) ) {
1498
- relevanssi_form_link_weight( $link_boost );
1499
- }
1500
- ?>
1501
- <tr>
1502
- <td>
1503
- <?php esc_html_e( 'Comment text', 'relevanssi' ); ?>
1504
- </td>
1505
- <td class="col-2">
1506
- <input type='text' name='relevanssi_comment_boost' id='relevanssi_comment_boost' size='4' value='<?php echo esc_attr( $comment_boost ); ?>' />
1507
- </td>
1508
- </tr>
1509
- <?php
1510
- if ( function_exists( 'relevanssi_form_post_type_weights' ) ) {
1511
- relevanssi_form_post_type_weights( $post_type_weights );
1512
- }
1513
- if ( function_exists( 'relevanssi_form_taxonomy_weights' ) ) {
1514
- relevanssi_form_taxonomy_weights( $post_type_weights );
1515
- } elseif ( function_exists( 'relevanssi_form_tag_weight' ) ) {
1516
- relevanssi_form_tag_weight( $post_type_weights );
1517
- }
1518
- if ( function_exists( 'relevanssi_form_recency_weight' ) ) {
1519
- relevanssi_form_recency_weight( $recency_bonus );
1520
- }
1521
- ?>
1522
- </table>
1523
- </td>
1524
- </tr>
1525
- <?php
1526
- if ( function_exists( 'relevanssi_form_recency_cutoff' ) ) {
1527
- relevanssi_form_recency_cutoff( $recency_bonus_days );
1528
  }
1529
  ?>
1530
- <tr>
1531
- <th scope="row">
1532
- <label for='relevanssi_exact_match_bonus'><?php esc_html_e( 'Boost exact matches', 'relevanssi' ); ?></label>
1533
- </th>
1534
- <td>
1535
- <fieldset>
1536
- <legend class="screen-reader-text"><?php esc_html_e( 'Give boost to exact matches.', 'relevanssi' ); ?></legend>
1537
- <label for='relevanssi_exact_match_bonus'>
1538
- <input type='checkbox' name='relevanssi_exact_match_bonus' id='relevanssi_exact_match_bonus' <?php echo esc_html( $exact_match_bonus ); ?> />
1539
- <?php esc_html_e( 'Give boost to exact matches.', 'relevanssi' ); ?>
1540
- </label>
1541
- </fieldset>
1542
- <?php // Translators: %s is the name of the filter hook. ?>
1543
- <p class="description"><?php printf( esc_html__( 'If you enable this option, matches where the search query appears in title or content as a phrase will get a weight boost. To adjust the boost, you can use the %s filter hook. See Help for more details.', 'relevanssi' ), '<code>relevanssi_exact_match_bonus</code>' ); ?></p>
1544
- </td>
1545
- </tr>
1546
- <?php
1547
- if ( function_exists( 'icl_object_id' ) && ! function_exists( 'pll_get_post' ) ) {
1548
- ?>
1549
- <tr>
1550
- <th scope="row">
1551
- <label for='relevanssi_wpml_only_current'><?php esc_html_e( 'WPML', 'relevanssi' ); ?></label>
1552
- </th>
1553
- <td>
1554
- <fieldset>
1555
- <legend class="screen-reader-text"><?php esc_html_e( 'Limit results to current language.', 'relevanssi' ); ?></legend>
1556
- <label for='relevanssi_wpml_only_current'>
1557
- <input type='checkbox' name='relevanssi_wpml_only_current' id='relevanssi_wpml_only_current' <?php echo esc_html( $wpml_only_current ); ?> />
1558
- <?php esc_html_e( 'Limit results to current language.', 'relevanssi' ); ?>
1559
- </label>
1560
- </fieldset>
1561
- <p class="description"><?php esc_html_e( 'Enabling this option will restrict the results to the currently active language. If the option is disabled, results will include posts in all languages.', 'relevanssi' ); ?></p>
1562
- </td>
1563
- </tr>
1564
- <?php } // WPML. ?>
1565
- <?php if ( function_exists( 'pll_get_post' ) ) { ?>
1566
- <tr>
1567
- <th scope="row">
1568
- <label for='relevanssi_polylang_all_languages'><?php esc_html_e( 'Polylang', 'relevanssi' ); ?></label>
1569
- </th>
1570
- <td>
1571
- <fieldset>
1572
- <legend class="screen-reader-text"><?php esc_html_e( 'Allow results from all languages.', 'relevanssi' ); ?></legend>
1573
- <label for='relevanssi_polylang_all_languages'>
1574
- <input type='checkbox' name='relevanssi_polylang_all_languages' id='relevanssi_polylang_all_languages' <?php echo esc_html( $polylang_allow_all ); ?> />
1575
- <?php esc_html_e( 'Allow results from all languages.', 'relevanssi' ); ?>
1576
- </label>
1577
- </fieldset>
1578
- <p class="description"><?php esc_html_e( 'By default Polylang restricts the search to the current language. Enabling this option will lift this restriction.', 'relevanssi' ); ?></p>
1579
- </td>
1580
- </tr>
1581
- <?php } // Polylang. ?>
1582
- <tr>
1583
- <th scope="row">
1584
- <label for='relevanssi_admin_search'><?php esc_html_e( 'Admin search', 'relevanssi' ); ?></label>
1585
- </th>
1586
- <td>
1587
- <fieldset>
1588
- <legend class="screen-reader-text"><?php esc_html_e( 'Use Relevanssi for admin searches.', 'relevanssi' ); ?></legend>
1589
- <label for='relevanssi_admin_search'>
1590
- <input type='checkbox' name='relevanssi_admin_search' id='relevanssi_admin_search' <?php echo esc_html( $admin_search ); ?> />
1591
- <?php esc_html_e( 'Use Relevanssi for admin searches.', 'relevanssi' ); ?>
1592
- </label>
1593
- </fieldset>
1594
- <p class="description"><?php esc_html_e( "If checked, Relevanssi will be used for searches in the admin interface. The page search doesn't use Relevanssi, because WordPress works like that.", 'relevanssi' ); ?></p>
1595
- </td>
1596
- </tr>
1597
- <tr>
1598
- <th scope="row">
1599
- <?php // Translators: %s is 'exclude_from_search'. ?>
1600
- <label for='relevanssi_respect_exclude'><?php printf( esc_html__( 'Respect %s', 'relevanssi' ), 'exclude_from_search' ); ?></label>
1601
- </th>
1602
- <td>
1603
- <fieldset>
1604
- <legend class="screen-reader-text"><?php esc_html_e( 'Respect exclude_from_search for custom post types', 'relevanssi' ); ?></legend>
1605
- <label for='relevanssi_respect_exclude'>
1606
- <input type='checkbox' name='relevanssi_respect_exclude' id='relevanssi_respect_exclude' <?php echo esc_html( $respect_exclude ); ?> />
1607
- <?php // Translators: %s is 'exclude_from_search'. ?>
1608
- <?php printf( esc_html__( 'Respect %s for custom post types', 'relevanssi' ), '<code>exclude_from_search</code>' ); ?>
1609
- </label>
1610
- <p class="description"><?php esc_html_e( "If checked, Relevanssi won't display posts of custom post types that have 'exclude_from_search' set to true.", 'relevanssi' ); ?></p>
1611
- <?php
1612
- if ( ! empty( $respect_exclude ) ) {
1613
- $pt_1 = get_post_types( array( 'exclude_from_search' => '1' ) );
1614
- $pt_2 = get_post_types( array( 'exclude_from_search' => true ) );
1615
 
1616
- $private_types = array_merge( $pt_1, $pt_2 );
1617
- $problem_post_types = array_intersect( $index_post_types, $private_types );
1618
- if ( ! empty( $problem_post_types ) ) {
1619
- ?>
1620
- <p class="description important">
1621
- <?php
1622
- esc_html_e( "You probably should uncheck this option, because you've set Relevanssi to index the following non-public post types:", 'relevanssi' );
1623
- echo ' ' . esc_html( implode( ', ', $problem_post_types ) );
1624
- ?>
1625
- </p>
1626
- <?php
1627
- }
1628
- }
1629
- ?>
1630
- </fieldset>
1631
- </td>
1632
- </tr>
1633
- <tr>
1634
- <th scope="row">
1635
- <label for='relevanssi_throttle'><?php esc_html_e( 'Throttle searches', 'relevanssi' ); ?></label>
1636
- </th>
1637
- <td id="throttlesearches">
1638
- <div id="throttle_disabled"
1639
- <?php
1640
- if ( ! $orderby_date ) {
1641
- echo "class='screen-reader-text'";
1642
- }
1643
- ?>
1644
- >
1645
- <p class="description"><?php esc_html_e( 'Throttling the search does not work when sorting the posts by date.', 'relevanssi' ); ?></p>
1646
- </div>
1647
- <div id="throttle_enabled"
1648
- <?php
1649
- if ( ! $orderby_relevance ) {
1650
- echo "class='screen-reader-text'";
1651
- }
1652
- ?>
1653
- >
1654
- <fieldset>
1655
- <legend class="screen-reader-text"><?php esc_html_e( 'Throttle searches.', 'relevanssi' ); ?></legend>
1656
- <label for='relevanssi_throttle'>
1657
- <input type='checkbox' name='relevanssi_throttle' id='relevanssi_throttle' <?php echo esc_html( $throttle ); ?> />
1658
- <?php esc_html_e( 'Throttle searches.', 'relevanssi' ); ?>
1659
- </label>
1660
- </fieldset>
1661
- <?php if ( $docs_count < 1000 ) { ?>
1662
- <p class="description important"><?php esc_html_e( "Your database is so small that you don't need to enable this.", 'relevanssi' ); ?></p>
1663
- <?php } ?>
1664
- <p class="description"><?php esc_html_e( 'If this option is checked, Relevanssi will limit search results to at most 500 results per term. This will improve performance, but may cause some relevant documents to go unfound. See Help for more details.', 'relevanssi' ); ?></p>
1665
- </div>
1666
- </td>
1667
- </tr>
1668
- <tr>
1669
- <th scope="row">
1670
- <label for='relevanssi_cat'><?php esc_html_e( 'Category restriction', 'relevanssi' ); ?></label>
1671
- </th>
1672
- <td>
1673
- <div class="categorydiv" style="max-width: 400px">
1674
- <div class="tabs-panel">
1675
- <ul id="categorychecklist">
1676
- <?php
1677
- $selected_cats = explode( ',', $cat );
1678
- $walker = get_relevanssi_taxonomy_walker();
1679
- $walker->name = 'relevanssi_cat';
1680
- wp_terms_checklist( 0, array(
1681
- 'taxonomy' => 'category',
1682
- 'selected_cats' => $selected_cats,
1683
- 'walker' => $walker,
1684
- ));
1685
- ?>
1686
- </ul>
1687
- <input type="hidden" name="relevanssi_cat_active" value="1" />
1688
- </div>
1689
- </div>
1690
- <p class="description"><?php esc_html_e( 'You can restrict search results to a category for all searches. For restricting on a per-search basis and more options (eg. tag restrictions), see Help.', 'relevanssi' ); ?></p>
1691
- </td>
1692
- </tr>
1693
- <tr>
1694
- <th scope="row">
1695
- <label for='relevanssi_excat'><?php esc_html_e( 'Category exclusion', 'relevanssi' ); ?></label>
1696
- </th>
1697
- <td>
1698
- <div class="categorydiv" style="max-width: 400px">
1699
- <div class="tabs-panel">
1700
- <ul id="categorychecklist">
1701
- <?php
1702
- $selected_cats = explode( ',', $excat );
1703
- $walker = get_relevanssi_taxonomy_walker();
1704
- $walker->name = 'relevanssi_excat';
1705
- wp_terms_checklist( 0, array(
1706
- 'taxonomy' => 'category',
1707
- 'selected_cats' => $selected_cats,
1708
- 'walker' => $walker,
1709
- ));
1710
- ?>
1711
- </ul>
1712
- <input type="hidden" name="relevanssi_excat_active" value="1" />
1713
- </div>
1714
- </div>
1715
- <p class="description"><?php esc_html_e( 'Posts in these categories are not included in search results. To exclude the posts completely from the index, see Help.', 'relevanssi' ); ?></p>
1716
- </td>
1717
- </tr>
1718
- <tr>
1719
- <th scope="row">
1720
- <label for='relevanssi_expst'><?php esc_html_e( 'Post exclusion', 'relevanssi' ); ?>
1721
- </th>
1722
- <td>
1723
- <input type='text' name='relevanssi_expst' id='relevanssi_expst' size='60' value='<?php echo esc_attr( $exclude_posts ); ?>' />
1724
- <p class="description"><?php esc_html_e( "Enter a comma-separated list of post or page ID's to exclude those pages from the search results.", 'relevanssi' ); ?></p>
1725
- <?php if ( RELEVANSSI_PREMIUM ) { ?>
1726
- <p class="description"><?php esc_html_e( "With Relevanssi Premium, it's better to use the check box on post edit pages. That will remove the posts completely from the index, and will work with multisite searches unlike this setting.", 'relevanssi' ); ?></p>
1727
- <?php } ?>
1728
- </td>
1729
- </tr>
1730
  <?php
1731
- if ( function_exists( 'relevanssi_form_searchblogs_setting' ) ) {
1732
- relevanssi_form_searchblogs_setting( $searchblogs_all, $searchblogs );
1733
- }
1734
  ?>
1735
- </table>
1736
-
1737
- <?php endif; // Active tab: searching. ?>
1738
-
1739
- <?php if ( 'excerpts' === $active_tab ) : ?>
1740
 
1741
  <h2 id="excerpts"><?php esc_html_e( 'Custom excerpts/snippets', 'relevanssi' ); ?></h2>
1742
 
@@ -1824,7 +1069,7 @@ if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
1824
  <label>
1825
  <input type='checkbox' name='relevanssi_excerpt_custom_fields' id='relevanssi_excerpt_custom_fields' <?php echo esc_html( $excerpt_custom_fields ); ?>
1826
  <?php
1827
- if ( empty( $excerpts ) || empty( $original_index_fields ) ) {
1828
  echo "disabled='disabled'";
1829
  }
1830
  ?>
@@ -1842,12 +1087,12 @@ if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
1842
 
1843
  <p class="description"><?php esc_html_e( 'Current custom field setting', 'relevanssi' ); ?>:
1844
  <?php
1845
- if ( 'visible' === $original_index_fields ) {
1846
  esc_html_e( 'all visible custom fields', 'relevanssi' );
1847
- } elseif ( 'all' === $original_index_fields ) {
1848
  esc_html_e( 'all custom fields', 'relevanssi' );
1849
- } elseif ( ! empty( $original_index_fields ) ) {
1850
- printf( '<code>%s</code>', esc_html( $original_index_fields ) );
1851
  } elseif ( RELEVANSSI_PREMIUM ) {
1852
  esc_html_e( 'Just PDF content', 'relevanssi' );
1853
  } else {
@@ -1996,11 +1241,6 @@ if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
1996
  <p class="description"><?php printf( esc_html__( 'Highlights hits when user opens the post from search results. This requires an extra parameter (%s) to the links from the search results pages, which Relevanssi should add automatically.', 'relevanssi' ), '<code>highlight</code>' ); ?></p>
1997
  </td>
1998
  </tr>
1999
- <?php
2000
- if ( function_exists( 'relevanssi_form_highlight_external' ) ) {
2001
- relevanssi_form_highlight_external( $highlight_docs_ext, $excerpts );
2002
- }
2003
- ?>
2004
  <tr>
2005
  <th scope="row">
2006
  <label for='relevanssi_highlight_comments'><?php esc_html_e( 'Highlight in comments', 'relevanssi' ); ?></label>
@@ -2094,403 +1334,18 @@ if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
2094
 
2095
  <?php endif; // Active tab: excerpts & highlights. ?>
2096
 
2097
- <?php if ( 'indexing' === $active_tab ) : ?>
2098
-
2099
- <?php
2100
-
2101
- $docs_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT doc) FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc != -1' ); // WPCS: unprepared SQL ok, Relevanssi table name.
2102
- $terms_count = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $relevanssi_variables['relevanssi_table'] ); // WPCS: unprepared SQL ok, Relevanssi table name.
2103
- $biggest_doc = $wpdb->get_var( 'SELECT doc FROM ' . $relevanssi_variables['relevanssi_table'] . ' ORDER BY doc DESC LIMIT 1' ); // WPCS: unprepared SQL ok, Relevanssi table name.
2104
-
2105
- if ( RELEVANSSI_PREMIUM ) {
2106
- $user_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE type = 'user'" ); // WPCS: unprepared SQL ok, Relevanssi table name.
2107
- $taxterm_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE (type != 'post' AND type != 'attachment' AND type != 'user')" ); // WPCS: unprepared SQL ok, Relevanssi table name.
2108
- }
2109
-
2110
- ?>
2111
- <div id="indexing_tab">
2112
-
2113
- <table class="form-table">
2114
- <tr>
2115
- <th scope="row">
2116
- <input type='submit' name='submit' value='<?php esc_attr_e( 'Save the options', 'relevanssi' ); ?>' class='button button-primary' /><br /><br />
2117
- <input type="button" id="build_index" name="index" value="<?php esc_attr_e( 'Build the index', 'relevanssi' ); ?>" class='button-primary' /><br /><br />
2118
- <input type="button" id="continue_indexing" name="continue" value="<?php esc_attr_e( 'Index unindexed posts', 'relevanssi' ); ?>" class='button-primary' />
2119
- </th>
2120
- <td>
2121
- <div id='indexing_button_instructions'>
2122
- <?php // Translators: %s is "Build the index". ?>
2123
- <p class="description"><?php printf( esc_html__( '%s empties the existing index and rebuilds it from scratch.', 'relevanssi' ), '<strong>' . esc_html__( 'Build the index', 'relevanssi' ) . '</strong>' ); ?></p>
2124
- <?php // Translators: %s is "Build the index". ?>
2125
- <p class="description"><?php printf( esc_html__( "%s doesn't empty the index and only indexes those posts that are not indexed. You can use it if you have to interrupt building the index.", 'relevanssi' ), '<strong>' . esc_html__( 'Index unindexed posts', 'relevanssi' ) . '</strong>' ); ?>
2126
- <?php
2127
- if ( RELEVANSSI_PREMIUM ) {
2128
- esc_html_e( "This doesn't index any taxonomy terms or users.", 'relevanssi' );
2129
- }
2130
- ?>
2131
- </p>
2132
- </div>
2133
- <div id='relevanssi-note' style='display: none'></div>
2134
- <div id='relevanssi-progress' class='rpi-progress'><div class="rpi-indicator"></div></div>
2135
- <div id='relevanssi-timer'><?php esc_html_e( 'Time elapsed', 'relevanssi' ); ?>: <span id="relevanssi_elapsed">0:00:00</span> | <?php esc_html_e( 'Time remaining', 'relevanssi' ); ?>: <span id="relevanssi_estimated"><?php esc_html_e( 'some time', 'relevanssi' ); ?></span></div>
2136
- <textarea id='results' rows='10' cols='80'></textarea>
2137
- <div id='relevanssi-indexing-instructions' style='display: none'><?php esc_html_e( "Indexing should respond quickly. If nothing happens in couple of minutes, it's probably stuck. The most common reasons for indexing issues are incompatible shortcodes, so try disabling the shortcode expansion setting and try again. Also, if you've just updated Relevanssi, doing a hard refresh in your browser will make sure your browser is not trying to use an outdated version of the Relevanssi scripts.", 'relevanssi' ); ?></div>
2138
- </td>
2139
- </tr>
2140
- <tr>
2141
- <th scope="row"><?php esc_html_e( 'State of the index', 'relevanssi' ); ?></td>
2142
- <td id="stateoftheindex"><p><?php echo esc_html( $docs_count ); ?> <?php echo esc_html( _n( 'document in the index.', 'documents in the index.', $docs_count, 'relevanssi' ) ); ?>
2143
- <?php if ( RELEVANSSI_PREMIUM ) : ?>
2144
- <br /><?php echo esc_html( $user_count ); ?> <?php echo esc_html( _n( 'user in the index.', 'users in the index.', $user_count, 'relevanssi' ) ); ?><br />
2145
- <?php echo esc_html( $taxterm_count ); ?> <?php echo esc_html( _n( 'taxonomy term in the index.', 'taxonomy terms in the index.', $taxterm_count, 'relevanssi' ) ); ?>
2146
- <?php endif; ?>
2147
- </p>
2148
- <p><?php echo esc_html( $terms_count ); ?> <?php echo esc_html( _n( 'term in the index.', 'terms in the index.', $terms_count, 'relevanssi' ) ); ?><br />
2149
- <?php echo esc_html( $biggest_doc ); ?> <?php esc_html_e( 'is the highest post ID indexed.', 'relevanssi' ); ?></p>
2150
- </td>
2151
- </tr>
2152
- </table>
2153
-
2154
- <?php
2155
- if ( count( $index_post_types ) < 2 ) {
2156
- printf( '<p><strong>%s</strong></p>', esc_html__( "WARNING: You've chosen no post types to index. Nothing will be indexed. Choose some post types to index.", 'relevanssi' ) );
2157
- }
2158
- ?>
2159
-
2160
- <h2 id="indexing"><?php esc_html_e( 'Indexing options', 'relevanssi' ); ?></h2>
2161
-
2162
- <p><?php esc_html_e( 'Any changes to the settings on this page require reindexing before they take effect.', 'relevanssi' ); ?></p>
2163
-
2164
- <table class="form-table">
2165
- <tr>
2166
- <th scope="row"><?php esc_html_e( 'Post types', 'relevanssi' ); ?></th>
2167
- <td>
2168
-
2169
- <table class="widefat" id="index_post_types_table">
2170
- <thead>
2171
- <tr>
2172
- <th><?php esc_html_e( 'Type', 'relevanssi' ); ?></th>
2173
- <th><?php esc_html_e( 'Index', 'relevanssi' ); ?></th>
2174
- <th><?php esc_html_e( 'Excluded from search?', 'relevanssi' ); ?></th>
2175
- </tr>
2176
- </thead>
2177
- <?php
2178
- $pt_1 = get_post_types( array( 'exclude_from_search' => '0' ) );
2179
- $pt_2 = get_post_types( array( 'exclude_from_search' => false ) );
2180
- $public_types = array_merge( $pt_1, $pt_2 );
2181
- $post_types = get_post_types();
2182
- foreach ( $post_types as $type ) {
2183
- if ( in_array( $type, array( 'nav_menu_item', 'revision' ), true ) ) {
2184
- continue;
2185
- }
2186
- $checked = '';
2187
- if ( in_array( $type, $index_post_types, true ) ) {
2188
- $checked = 'checked="checked"';
2189
- }
2190
- $label = sprintf( '%s', $type );
2191
- $excluded_from_search = __( 'yes', 'relevanssi' );
2192
- if ( in_array( $type, $public_types, true ) ) {
2193
- $excluded_from_search = __( 'no', 'relevanssi' );
2194
- }
2195
- $name_id = 'relevanssi_index_type_' . $type;
2196
- printf( '<tr><td>%1$s</td><td><input type="checkbox" name="%2$s" id="%2$s" %3$s /></td><td>%4$s</td></tr>',
2197
- esc_html( $label ), esc_attr( $name_id ), esc_html( $checked ), esc_html( $excluded_from_search ) );
2198
- }
2199
- ?>
2200
- <tr style="display:none">
2201
- <td>
2202
- Helpful little control field
2203
- </td>
2204
- <td>
2205
- <input type='checkbox' name='relevanssi_index_type_bogus' id='relevanssi_index_type_bogus' checked="checked" />
2206
- </td>
2207
- <td>
2208
- This is our little secret, just for you and me
2209
- </td>
2210
- </tr>
2211
- </table>
2212
- <?php // Translators: %1$s is 'attachment', %2$s opens the link, %3$s closes it. ?>
2213
- <p class="description"><?php printf( esc_html__( '%1$s includes all attachment types. If you want to index only some attachments, see %2$sControlling attachment types in the Knowledge base%3$s.', 'relevanssi' ), '<code>attachment</code>', '<a href="https://www.relevanssi.com/knowledge-base/controlling-attachment-types-index/">', '</a>' ); ?></p>
2214
- </td>
2215
- </tr>
2216
-
2217
- <tr>
2218
- <th scope="row">
2219
- <?php esc_html_e( 'Taxonomies', 'relevanssi' ); ?>
2220
- </th>
2221
- <td>
2222
-
2223
- <table class="widefat" id="custom_taxonomies_table">
2224
- <thead>
2225
- <tr>
2226
- <th><?php esc_html_e( 'Taxonomy', 'relevanssi' ); ?></th>
2227
- <th><?php esc_html_e( 'Index', 'relevanssi' ); ?></th>
2228
- <th><?php esc_html_e( 'Public?', 'relevanssi' ); ?></th>
2229
- </tr>
2230
- </thead>
2231
-
2232
- <?php
2233
- $taxos = get_taxonomies( '', 'objects' );
2234
- foreach ( $taxos as $taxonomy ) {
2235
- if ( in_array( $taxonomy->name, array( 'nav_menu', 'link_category' ), true ) ) {
2236
- continue;
2237
- }
2238
- $checked = '';
2239
- if ( in_array( $taxonomy->name, $index_taxonomies_list, true ) ) {
2240
- $checked = 'checked="checked"';
2241
- }
2242
- $label = sprintf( '%s', $taxonomy->name );
2243
- $public = __( 'no', 'relevanssi' );
2244
- if ( $taxonomy->public ) {
2245
- $public = __( 'yes', 'relevanssi' );
2246
- }
2247
- $name_id = 'relevanssi_index_taxonomy_' . $taxonomy->name;
2248
- printf( '<tr><td>%1$s</td><td><input type="checkbox" name="%2$s" id="%2$s" %3$s /></td><td>%4$s</td></tr>',
2249
- esc_html( $label ), esc_attr( $name_id ), esc_html( $checked ), esc_html( $public ) );
2250
- }
2251
- ?>
2252
- </table>
2253
-
2254
- <p class="description"><?php esc_html_e( 'If you check a taxonomy here, the terms for that taxonomy are indexed with the posts. If you for example choose "post_tag", searching for a tag will find all posts that have the tag.', 'relevanssi' ); ?>
2255
-
2256
- </td>
2257
- </tr>
2258
-
2259
- <tr>
2260
- <th scope="row">
2261
- <label for='relevanssi_index_comments'><?php esc_html_e( 'Comments', 'relevanssi' ); ?></label>
2262
- </th>
2263
- <td>
2264
- <select name='relevanssi_index_comments' id='relevanssi_index_comments'>
2265
- <option value='none' <?php echo esc_html( $index_comments_none ); ?>><?php esc_html_e( 'none', 'relevanssi' ); ?></option>
2266
- <option value='normal' <?php echo esc_html( $index_comments_normal ); ?>><?php esc_html_e( 'comments', 'relevanssi' ); ?></option>
2267
- <option value='all' <?php echo esc_html( $index_comments_all ); ?>><?php esc_html_e( 'comments and pingbacks', 'relevanssi' ); ?></option>
2268
- </select>
2269
- <p class="description"><?php esc_html_e( 'If you choose to index comments, you can choose if you want to index just comments, or everything including comments and track- and pingbacks.', 'relevanssi' ); ?></p>
2270
- </td>
2271
- </tr>
2272
-
2273
- <tr>
2274
- <th scope="row">
2275
- <label for='relevanssi_index_fields'><?php esc_html_e( 'Custom fields', 'relevanssi' ); ?></label>
2276
- </th>
2277
- <td>
2278
- <select name='relevanssi_index_fields_select' id='relevanssi_index_fields_select'>
2279
- <option value='none' <?php echo esc_html( $fields_select_none ); ?>><?php esc_html_e( 'none', 'relevanssi' ); ?></option>
2280
- <option value='all' <?php echo esc_html( $fields_select_all ); ?>><?php esc_html_e( 'all', 'relevanssi' ); ?></option>
2281
- <option value='visible' <?php echo esc_html( $fields_select_visible ); ?>><?php esc_html_e( 'visible', 'relevanssi' ); ?></option>
2282
- <option value='some' <?php echo esc_html( $fields_select_some ); ?>><?php esc_html_e( 'some', 'relevanssi' ); ?></option>
2283
- </select>
2284
- <p class="description">
2285
- <?php
2286
- esc_html_e( "'All' indexes all custom fields for posts.", 'relevanssi' );
2287
- echo '<br/>';
2288
- esc_html_e( "'Visible' only includes the custom fields that are visible in the user interface (with names that don't start with an underscore).", 'relevanssi' );
2289
- echo '<br/>';
2290
- esc_html_e( "'Some' lets you choose individual custom fields to index.", 'relevanssi' );
2291
- ?>
2292
- </p>
2293
- <div id="index_field_input"
2294
- <?php
2295
- if ( empty( $fields_select_some ) ) {
2296
- echo 'style="display: none"';
2297
- }
2298
- ?>
2299
- >
2300
- <input type='text' name='relevanssi_index_fields' id='relevanssi_index_fields' size='60' value='<?php echo esc_attr( $index_fields ); ?>' />
2301
- <p class="description"><?php esc_html_e( "Enter a comma-separated list of custom fields to include in the index. With Relevanssi Premium, you can also use 'fieldname_%_subfieldname' notation for ACF repeater fields.", 'relevanssi' ); ?></p>
2302
- <p class="description"><?php esc_html_e( "You can use 'relevanssi_index_custom_fields' filter hook to adjust which custom fields are indexed.", 'relevanssi' ); ?></p>
2303
- </div>
2304
- <?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
2305
- <?php // Translators: %1$s is the 'some' option and %2$s is '_sku'. ?>
2306
- <p class="description"><?php printf( esc_html__( 'If you want the SKU included, choose %1$s and enter %2$s. Also see the contextual help for more details.', 'relevanssi' ), esc_html( "'" . __( 'some', 'relevanssi' ) . "'" ), '<code>_sku</code>' ); ?></p>
2307
- <?php endif; ?>
2308
- </td>
2309
- </tr>
2310
-
2311
- <tr>
2312
- <th scope="row">
2313
- <label for='relevanssi_index_author'><?php esc_html_e( 'Author display names', 'relevanssi' ); ?></label>
2314
- </th>
2315
- <td>
2316
- <fieldset>
2317
- <legend class="screen-reader-text"><?php esc_html_e( 'Index the post author display name', 'relevanssi' ); ?></legend>
2318
- <label for='relevanssi_index_author'>
2319
- <input type='checkbox' name='relevanssi_index_author' id='relevanssi_index_author' <?php echo esc_html( $index_author ); ?> />
2320
- <?php esc_html_e( 'Index the post author display name', 'relevanssi' ); ?>
2321
- </label>
2322
- <p class="description"><?php esc_html_e( 'Searching for the post author display name will return posts by that author.', 'relevanssi' ); ?></p>
2323
- </fieldset>
2324
- </td>
2325
- </tr>
2326
-
2327
- <tr>
2328
- <th scope="row">
2329
- <label for='relevanssi_index_excerpt'><?php esc_html_e( 'Excerpts', 'relevanssi' ); ?></label>
2330
- </th>
2331
- <td>
2332
- <fieldset>
2333
- <legend class="screen-reader-text"><?php esc_html_e( 'Index the post excerpt', 'relevanssi' ); ?></legend>
2334
- <label for='relevanssi_index_excerpt'>
2335
- <input type='checkbox' name='relevanssi_index_excerpt' id='relevanssi_index_excerpt' <?php echo esc_html( $index_excerpt ); ?> />
2336
- <?php esc_html_e( 'Index the post excerpt', 'relevanssi' ); ?>
2337
- </label>
2338
- <p class="description"><?php esc_html_e( 'Relevanssi will find posts by the content in the excerpt.', 'relevanssi' ); ?></p>
2339
- <?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
2340
- <p class="description"><?php esc_html_e( "WooCommerce stores the product short description in the excerpt, so it's a good idea to index excerpts.", 'relevanssi' ); ?></p>
2341
- <?php endif; ?>
2342
- </fieldset>
2343
- </td>
2344
- </tr>
2345
-
2346
- </table>
2347
-
2348
- <h2><?php esc_html_e( 'Shortcodes', 'relevanssi' ); ?></h2>
2349
-
2350
- <table class="form-table">
2351
- <tr>
2352
- <th scope="row">
2353
- <label for='relevanssi_expand_shortcodes'><?php esc_html_e( 'Expand shortcodes', 'relevanssi' ); ?></label>
2354
- </th>
2355
- <td>
2356
- <fieldset>
2357
- <legend class="screen-reader-text"><?php esc_html_e( 'Index the post excerpt', 'relevanssi' ); ?></legend>
2358
- <label for='relevanssi_expand_shortcodes'>
2359
- <input type='checkbox' name='relevanssi_expand_shortcodes' id='relevanssi_expand_shortcodes' <?php echo esc_html( $expand_shortcodes ); ?> />
2360
- <?php esc_html_e( 'Expand shortcodes when indexing', 'relevanssi' ); ?>
2361
- </label>
2362
- <?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
2363
- <p class="description important"><?php esc_html_e( "WooCommerce has shortcodes that don't work well with Relevanssi. With WooCommerce, make sure the option is disabled.", 'relevanssi' ); ?></p>
2364
- <?php endif; ?>
2365
- <p class="description"><?php esc_html_e( 'If checked, Relevanssi will expand shortcodes in post content before indexing. Otherwise shortcodes will be stripped.', 'relevanssi' ); ?></p>
2366
- <p class="description"><?php esc_html_e( 'If you use shortcodes to include dynamic content, Relevanssi will not keep the index updated, the index will reflect the status of the shortcode content at the moment of indexing.', 'relevanssi' ); ?></p>
2367
- </fieldset>
2368
- </td>
2369
- </tr>
2370
-
2371
- <?php
2372
- if ( function_exists( 'relevanssi_form_disable_shortcodes' ) ) {
2373
- relevanssi_form_disable_shortcodes( $disable_shortcodes );
2374
- }
2375
- ?>
2376
-
2377
- </table>
2378
-
2379
  <?php
2380
- if ( function_exists( 'relevanssi_form_index_users' ) ) {
2381
- relevanssi_form_index_users( $index_users, $index_subscribers, $index_user_fields );
2382
- }
2383
- if ( function_exists( 'relevanssi_form_index_synonyms' ) ) {
2384
- relevanssi_form_index_synonyms( $index_synonyms );
2385
- }
2386
- if ( function_exists( 'relevanssi_form_index_taxonomies' ) ) {
2387
- relevanssi_form_index_taxonomies( $index_taxonomies, $index_terms );
2388
- }
2389
- if ( function_exists( 'relevanssi_form_index_pdf_parent' ) ) {
2390
- relevanssi_form_index_pdf_parent( $index_pdf_parent, $index_post_types );
2391
- }
2392
- ?>
2393
-
2394
- <h2><?php esc_html_e( 'Advanced indexing settings', 'relevanssi' ); ?></h2>
2395
-
2396
- <p><button type="button" id="show_advanced_indexing"><?php esc_html_e( 'Show advanced settings', 'relevanssi' ); ?></button></p>
2397
-
2398
- <table class="form-table screen-reader-text" id="advanced_indexing">
2399
- <tr>
2400
- <th scope="row">
2401
- <label for='relevanssi_min_word_length'><?php esc_html_e( 'Minimum word length', 'relevanssi' ); ?></label>
2402
- </th>
2403
- <td>
2404
- <input type='number' name='relevanssi_min_word_length' id='relevanssi_min_word_length' value='<?php echo esc_attr( $min_word_length ); ?>' />
2405
- <p class="description"><?php esc_html_e( 'Words shorter than this many letters will not be indexed.', 'relevanssi' ); ?></p>
2406
- <?php // Translators: %1$s is 'relevanssi_block_one_letter_searches' and %2$s is 'false'. ?>
2407
- <p class="description"><?php printf( esc_html__( 'To enable one-letter searches, you need to add a filter function on the filter hook %1$s that returns %2$s.', 'relevanssi' ), '<code>relevanssi_block_one_letter_searches</code>', '<code>false</code>' ); ?></p>
2408
- </td>
2409
- </tr>
2410
- <tr>
2411
- <th scope="row"><?php esc_html_e( 'Punctuation control', 'relevanssi' ); ?></th>
2412
- <td><p class="description"><?php esc_html_e( 'Here you can adjust how the punctuation is controlled. For more information, see help. Remember that any changes here require reindexing, otherwise searches will fail to find posts they should.', 'relevanssi' ); ?></p></td>
2413
- </tr>
2414
- <tr>
2415
- <th scope="row">
2416
- <label for='relevanssi_punct_hyphens'><?php esc_html_e( 'Hyphens and dashes', 'relevanssi' ); ?></label>
2417
- </th>
2418
- <td>
2419
- <select name='relevanssi_punct_hyphens' id='relevanssi_punct_hyphens'>
2420
- <option value='keep' <?php echo esc_html( $punct_hyphens_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
2421
- <option value='replace' <?php echo esc_html( $punct_hyphens_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
2422
- <option value='remove' <?php echo esc_html( $punct_hyphens_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
2423
- </select>
2424
- <p class="description"><?php esc_html_e( 'How Relevanssi should handle hyphens and dashes (en and em dashes)? Replacing with spaces is generally the best option, but in some cases removing completely is the best option. Keeping them is rarely the best option.', 'relevanssi' ); ?></p>
2425
-
2426
- </td>
2427
- </tr>
2428
- <tr>
2429
- <th scope="row">
2430
- <label for='relevanssi_punct_quotes'><?php esc_html_e( 'Apostrophes and quotes', 'relevanssi' ); ?></label>
2431
- </th>
2432
- <td>
2433
- <select name='relevanssi_punct_quotes' id='relevanssi_punct_quotes'>
2434
- <option value='replace' <?php echo esc_html( $punct_quotes_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
2435
- <option value='remove' <?php echo esc_html( $punct_quotes_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
2436
- </select>
2437
- <p class="description"><?php esc_html_e( "How Relevanssi should handle apostrophes and quotes? It's not possible to keep them; that would lead to problems. Default behaviour is to replace with spaces, but sometimes removing makes sense.", 'relevanssi' ); ?></p>
2438
-
2439
- </td>
2440
- </tr>
2441
- <tr>
2442
- <th scope="row">
2443
- <label for='relevanssi_punct_ampersands'><?php esc_html_e( 'Ampersands', 'relevanssi' ); ?></label>
2444
- </th>
2445
- <td>
2446
- <select name='relevanssi_punct_ampersands' id='relevanssi_punct_ampersands'>
2447
- <option value='keep' <?php echo esc_html( $punct_ampersands_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
2448
- <option value='replace' <?php echo esc_html( $punct_ampersands_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
2449
- <option value='remove' <?php echo esc_html( $punct_ampersands_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
2450
- </select>
2451
- <p class="description"><?php esc_html_e( 'How Relevanssi should handle ampersands? Replacing with spaces is generally the best option, but if you talk a lot about D&amp;D, for example, keeping the ampersands is useful.', 'relevanssi' ); ?></p>
2452
-
2453
- </td>
2454
- </tr>
2455
- <tr>
2456
- <th scope="row">
2457
- <label for='relevanssi_punct_decimals'><?php esc_html_e( 'Decimal separators', 'relevanssi' ); ?></label>
2458
- </th>
2459
- <td>
2460
- <select name='relevanssi_punct_decimals' id='relevanssi_punct_decimals'>
2461
- <option value='keep' <?php echo esc_html( $punct_decimals_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
2462
- <option value='replace' <?php echo esc_html( $punct_decimals_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
2463
- <option value='remove' <?php echo esc_html( $punct_decimals_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
2464
- </select>
2465
- <p class="description"><?php esc_html_e( 'How Relevanssi should handle periods between decimals? Replacing with spaces is the default option, but that often leads to the numbers being removed completely. If you need to search decimal numbers a lot, keep the periods.', 'relevanssi' ); ?></p>
2466
-
2467
- </td>
2468
- </tr>
2469
- <?php
2470
- if ( function_exists( 'relevanssi_form_thousands_separator' ) ) {
2471
- relevanssi_form_thousands_separator( $thousand_separator );
2472
- }
2473
- if ( function_exists( 'relevanssi_form_mysql_columns' ) ) {
2474
- relevanssi_form_mysql_columns( $mysql_columns );
2475
- }
2476
- if ( function_exists( 'relevanssi_form_internal_links' ) ) {
2477
- relevanssi_form_internal_links( $internal_links_noindex, $internal_links_strip, $internal_links_nostrip );
2478
  }
2479
  ?>
2480
 
2481
- </table>
2482
-
2483
- <p><button type="button" style="display: none" id="hide_advanced_indexing"><?php esc_html_e( 'Hide advanced settings', 'relevanssi' ); ?></button></p>
2484
-
2485
- </div> <?php // End #indexing_tab. ?>
2486
-
2487
- <?php endif; // Active tab: indexing. ?>
2488
-
2489
  <?php if ( 'attachments' === $active_tab ) : ?>
2490
 
2491
  <?php
2492
  if ( function_exists( 'relevanssi_form_attachments' ) ) {
2493
- relevanssi_form_attachments( $index_post_types, $index_pdf_parent );
2494
  } else {
2495
  $display_save_button = false;
2496
  ?>
@@ -2521,11 +1376,11 @@ if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
2521
  <br />
2522
  <textarea name='relevanssi_synonyms' id='relevanssi_synonyms' rows='9' cols='60'><?php echo esc_textarea( htmlspecialchars( $synonyms ) ); ?></textarea>
2523
 
2524
- <p class="description"><?php esc_html_e( 'The format here is <code>key = value</code>. If you add <code>dog = hound</code> to the list of synonyms, searches for <code>dog</code> automatically become a search for <code>dog hound</code> and will thus match to posts that include either <code>dog</code> or <code>hound</code>. This only works in OR searches: in AND searches the synonyms only restrict the search, as now the search only finds posts that contain <strong>both</strong> <code>dog</code> and <code>hound</code>.', 'relevanssi' ); ?></p>
2525
 
2526
- <p class="description"><?php esc_html_e( 'The synonyms are one direction only. If you want both directions, add the synonym again, reversed: <code>hound = dog</code>.', 'relevanssi' ); ?></p>
2527
 
2528
- <p class="description"><?php esc_html_e( "It's possible to use phrases for the value, but not for the key. <code>dog = \"great dane\"</code> works, but <code>\"great dane\" = dog</code> doesn't.", 'relevanssi' ); ?></p>
2529
 
2530
  <?php if ( RELEVANSSI_PREMIUM ) : ?>
2531
  <p class="description"><?php esc_html_e( 'If you want to use synonyms in AND searches, enable synonym indexing on the Indexing tab.', 'relevanssi' ); ?></p>
@@ -2563,7 +1418,7 @@ if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
2563
 
2564
  <?php
2565
  if ( function_exists( 'relevanssi_form_importexport' ) ) {
2566
- relevanssi_form_importexport( $serialized_options );
2567
  }
2568
  ?>
2569
 
@@ -2669,8 +1524,8 @@ function rlv_partial_inside_words( $query ) {
2669
  return "(term LIKE \'%#term#%\')";
2670
  }</pre></li>' .
2671
  // Translators: %s is 'relevanssi_throttle_limit'.
2672
- '<li>' . sprintf( __( 'In order to adjust the throttle limit, you can use the %s filter hook.', 'relevanssi' ), '<code>relevanssi_throttle_limit</code>' ) .
2673
- '<pre>add_filter("relevanssi_throttle_limit", function( $limit ) { return 200; } );</pre>' .
2674
  '<li>' . __( "It's not usually necessary to adjust the limit from 500, but in some cases performance gains can be achieved by setting a lower limit. We don't suggest going under 200, as low values will make the results worse.", 'relevanssi' ) . '</li>' .
2675
  '</ul>',
2676
  ));
@@ -2833,35 +1688,38 @@ function relevanssi_add_admin_scripts( $hook ) {
2833
  wp_enqueue_style( 'relevanssi_admin_css', $plugin_dir_url . 'lib/admin_styles.css' );
2834
 
2835
  $localizations = array(
2836
- 'confirm' => __( 'Click OK to copy Relevanssi options to all subsites', 'relevanssi' ),
2837
- 'confirm_stopwords' => __( 'Are you sure you want to remove all stopwords?', 'relevanssi' ),
2838
- 'truncating_index' => __( 'Wiping out the index...', 'relevanssi' ),
2839
- 'done' => __( 'Done.', 'relevanssi' ),
2840
- 'indexing_users' => __( 'Indexing users...', 'relevanssi' ),
2841
- 'indexing_taxonomies' => __( 'Indexing the following taxonomies:', 'relevanssi' ),
2842
- 'counting_posts' => __( 'Counting posts...', 'relevanssi' ),
2843
- 'counting_terms' => __( 'Counting taxonomy terms...', 'relevanssi' ),
2844
- 'counting_users' => __( 'Counting users...', 'relevanssi' ),
2845
- 'posts_found' => __( 'posts found.', 'relevanssi' ),
2846
- 'terms_found' => __( 'taxonomy terms found.', 'relevanssi' ),
2847
- 'users_found' => __( 'users found.', 'relevanssi' ),
2848
- 'taxonomy_disabled' => __( 'Taxonomy term indexing is disabled.', 'relevanssi' ),
2849
- 'user_disabled' => __( 'User indexing is disabled.', 'relevanssi' ),
2850
- 'indexing_complete' => __( 'Indexing complete.', 'relevanssi' ),
2851
- 'excluded_posts' => __( 'posts excluded.', 'relevanssi' ),
2852
- 'options_changed' => __( 'Settings have changed, please save the options before indexing.', 'relevanssi' ),
2853
- 'reload_state' => __( 'Reload the page to refresh the state of the index.', 'relevanssi' ),
2854
- 'pdf_reset_confirm' => __( 'Are you sure you want to delete all attachment content from the index?', 'relevanssi' ),
2855
- 'pdf_reset_done' => __( 'Relevanssi attachment data wiped clean.', 'relevanssi' ),
2856
- 'hour' => __( 'hour', 'relevanssi' ),
2857
- 'hours' => __( 'hours', 'relevanssi' ),
2858
- 'about' => __( 'about', 'relevanssi' ),
2859
- 'sixty_min' => __( 'about an hour', 'relevanssi' ),
2860
- 'ninety_min' => __( 'about an hour and a half', 'relevanssi' ),
2861
- 'minute' => __( 'minute', 'relevanssi' ),
2862
- 'minutes' => __( 'minutes', 'relevanssi' ),
2863
- 'underminute' => __( 'less than a minute', 'relevanssi' ),
2864
- 'notimeremaining' => __( "we're done!", 'relevanssi' ),
 
 
 
2865
  );
2866
 
2867
  wp_localize_script( 'relevanssi_admin_js', 'relevanssi', $localizations );
@@ -2876,10 +1734,10 @@ function relevanssi_add_admin_scripts( $hook ) {
2876
 
2877
  /**
2878
  * Prints out the form fields for tag and category weights.
2879
- *
2880
- * @param array $taxonomy_weights The taxonomy weights.
2881
  */
2882
- function relevanssi_form_tag_weight( $taxonomy_weights ) {
 
 
2883
  $tag_value = 1;
2884
  if ( isset( $taxonomy_weights['post_tag'] ) ) {
2885
  $tag_value = $taxonomy_weights['post_tag'];
479
  return $result;
480
  }
481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
  /**
483
  * Displays the list of most common words in the index.
484
  *
752
  wp_enqueue_script( 'dashboard' );
753
  wp_print_scripts( 'dashboard' );
754
 
 
 
 
 
 
 
 
755
  $excerpts = get_option( 'relevanssi_excerpts' );
756
  $excerpt_length = get_option( 'relevanssi_excerpt_length' );
757
  $excerpt_type = get_option( 'relevanssi_excerpt_type' );
758
  $excerpt_allowable_tags = get_option( 'relevanssi_excerpt_allowable_tags' );
759
  $excerpt_custom_fields = get_option( 'relevanssi_excerpt_custom_fields' );
 
 
 
 
760
  $highlight = get_option( 'relevanssi_highlight' );
 
761
  $txt_col = get_option( 'relevanssi_txt_col' );
762
  $bg_col = get_option( 'relevanssi_bg_col' );
763
  $css = get_option( 'relevanssi_css' );
764
  $class = get_option( 'relevanssi_class' );
 
 
 
 
 
 
 
 
 
765
  $synonyms = get_option( 'relevanssi_synonyms' );
 
766
  $highlight_title = get_option( 'relevanssi_hilite_title' );
767
  $index_comments = get_option( 'relevanssi_index_comments' );
768
  $highlight_docs = get_option( 'relevanssi_highlight_docs' );
769
  $highlight_coms = get_option( 'relevanssi_highlight_comments' );
 
 
 
 
770
  $show_matches = get_option( 'relevanssi_show_matches' );
771
  $show_matches_text = get_option( 'relevanssi_show_matches_text' );
 
 
772
  $word_boundaries = get_option( 'relevanssi_word_boundaries' );
 
 
 
 
773
  $punctuation = get_option( 'relevanssi_punctuation' );
 
774
 
775
  if ( '#' !== substr( $txt_col, 0, 1 ) ) {
776
  $txt_col = '#' . $txt_col;
781
  }
782
  $bg_col = relevanssi_sanitize_hex_color( $bg_col );
783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
784
  $excerpts = relevanssi_check( $excerpts );
785
  $excerpt_custom_fields = relevanssi_check( $excerpt_custom_fields );
 
 
 
 
 
 
786
  $highlight_title = relevanssi_check( $highlight_title );
787
  $highlight_docs = relevanssi_check( $highlight_docs );
788
  $highlight_coms = relevanssi_check( $highlight_coms );
 
 
 
789
  $show_matches = relevanssi_check( $show_matches );
 
 
790
  $word_boundaries = relevanssi_check( $word_boundaries );
 
 
791
  $excerpt_chars = relevanssi_select( $excerpt_type, 'chars' );
792
  $excerpt_words = relevanssi_select( $excerpt_type, 'words' );
 
 
 
793
  $highlight_none = relevanssi_select( $highlight, 'no' );
794
  $highlight_mark = relevanssi_select( $highlight, 'mark' );
795
  $highlight_em = relevanssi_select( $highlight, 'em' );
798
  $highlight_bgcol = relevanssi_select( $highlight, 'bgcol' );
799
  $highlight_style = relevanssi_select( $highlight, 'style' );
800
  $highlight_class = relevanssi_select( $highlight, 'class' );
 
 
 
 
 
 
 
801
 
802
  $show_matches_text = stripslashes( $show_matches_text );
803
 
819
  $class_display = '';
820
  }
821
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
822
  if ( isset( $synonyms ) ) {
823
  $synonyms = str_replace( ';', "\n", $synonyms );
824
  } else {
825
  $synonyms = '';
826
  }
827
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
828
  if ( RELEVANSSI_PREMIUM ) {
829
+ $api_key = get_option( 'relevanssi_api_key' );
830
+ $disable_shortcodes = get_option( 'relevanssi_disable_shortcodes' );
831
+ $hide_post_controls = get_option( 'relevanssi_hide_post_controls' );
832
+ $server_location = get_option( 'relevanssi_server_location' );
833
+ $show_post_controls = get_option( 'relevanssi_show_post_controls' );
834
+ $thousand_separator = get_option( 'relevanssi_thousand_separator' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
835
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
  $hide_post_controls = relevanssi_check( $hide_post_controls );
837
  $show_post_controls = relevanssi_check( $show_post_controls );
 
 
 
 
 
 
 
 
 
 
 
838
  }
839
 
840
  echo "<div class='postbox-container'>";
967
 
968
  <?php endif; // Active tab: basic. ?>
969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
970
  <?php
971
+ if ( 'logging' === $active_tab ) {
972
+ require_once 'tabs/logging-tab.php';
973
+ relevanssi_logging_tab();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
974
  }
975
+ if ( 'searching' === $active_tab ) {
976
+ require_once 'tabs/searching-tab.php';
977
+ relevanssi_searching_tab();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
978
  }
979
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
980
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
981
  <?php
982
+ if ( 'excerpts' === $active_tab ) :
983
+ $index_fields = get_option( 'relevanssi_index_fields' );
 
984
  ?>
 
 
 
 
 
985
 
986
  <h2 id="excerpts"><?php esc_html_e( 'Custom excerpts/snippets', 'relevanssi' ); ?></h2>
987
 
1069
  <label>
1070
  <input type='checkbox' name='relevanssi_excerpt_custom_fields' id='relevanssi_excerpt_custom_fields' <?php echo esc_html( $excerpt_custom_fields ); ?>
1071
  <?php
1072
+ if ( empty( $excerpts ) || empty( $index_fields ) ) {
1073
  echo "disabled='disabled'";
1074
  }
1075
  ?>
1087
 
1088
  <p class="description"><?php esc_html_e( 'Current custom field setting', 'relevanssi' ); ?>:
1089
  <?php
1090
+ if ( 'visible' === $index_fields ) {
1091
  esc_html_e( 'all visible custom fields', 'relevanssi' );
1092
+ } elseif ( 'all' === $index_fields ) {
1093
  esc_html_e( 'all custom fields', 'relevanssi' );
1094
+ } elseif ( ! empty( $index_fields ) ) {
1095
+ printf( '<code>%s</code>', esc_html( $index_fields ) );
1096
  } elseif ( RELEVANSSI_PREMIUM ) {
1097
  esc_html_e( 'Just PDF content', 'relevanssi' );
1098
  } else {
1241
  <p class="description"><?php printf( esc_html__( 'Highlights hits when user opens the post from search results. This requires an extra parameter (%s) to the links from the search results pages, which Relevanssi should add automatically.', 'relevanssi' ), '<code>highlight</code>' ); ?></p>
1242
  </td>
1243
  </tr>
 
 
 
 
 
1244
  <tr>
1245
  <th scope="row">
1246
  <label for='relevanssi_highlight_comments'><?php esc_html_e( 'Highlight in comments', 'relevanssi' ); ?></label>
1334
 
1335
  <?php endif; // Active tab: excerpts & highlights. ?>
1336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1337
  <?php
1338
+ if ( 'indexing' === $active_tab ) {
1339
+ require_once 'tabs/indexing-tab.php';
1340
+ relevanssi_indexing_tab();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1341
  }
1342
  ?>
1343
 
 
 
 
 
 
 
 
 
1344
  <?php if ( 'attachments' === $active_tab ) : ?>
1345
 
1346
  <?php
1347
  if ( function_exists( 'relevanssi_form_attachments' ) ) {
1348
+ relevanssi_form_attachments();
1349
  } else {
1350
  $display_save_button = false;
1351
  ?>
1376
  <br />
1377
  <textarea name='relevanssi_synonyms' id='relevanssi_synonyms' rows='9' cols='60'><?php echo esc_textarea( htmlspecialchars( $synonyms ) ); ?></textarea>
1378
 
1379
+ <p class="description"><?php _e( 'The format here is <code>key = value</code>. If you add <code>dog = hound</code> to the list of synonyms, searches for <code>dog</code> automatically become a search for <code>dog hound</code> and will thus match to posts that include either <code>dog</code> or <code>hound</code>. This only works in OR searches: in AND searches the synonyms only restrict the search, as now the search only finds posts that contain <strong>both</strong> <code>dog</code> and <code>hound</code>.', 'relevanssi' ); // WPCS: XSS ok. ?></p>
1380
 
1381
+ <p class="description"><?php _e( 'The synonyms are one direction only. If you want both directions, add the synonym again, reversed: <code>hound = dog</code>.', 'relevanssi' ); // WPCS: XSS ok. ?></p>
1382
 
1383
+ <p class="description"><?php _e( "It's possible to use phrases for the value, but not for the key. <code>dog = \"great dane\"</code> works, but <code>\"great dane\" = dog</code> doesn't.", 'relevanssi' ); // WPCS: XSS ok. ?></p>
1384
 
1385
  <?php if ( RELEVANSSI_PREMIUM ) : ?>
1386
  <p class="description"><?php esc_html_e( 'If you want to use synonyms in AND searches, enable synonym indexing on the Indexing tab.', 'relevanssi' ); ?></p>
1418
 
1419
  <?php
1420
  if ( function_exists( 'relevanssi_form_importexport' ) ) {
1421
+ relevanssi_form_importexport();
1422
  }
1423
  ?>
1424
 
1524
  return "(term LIKE \'%#term#%\')";
1525
  }</pre></li>' .
1526
  // Translators: %s is 'relevanssi_throttle_limit'.
1527
+ '<li>' . sprintf( __( 'In order to adjust the throttle limit, you can use the %s filter hook.', 'relevanssi' ), '<code>pre_option_relevanssi_throttle_limit</code>' ) .
1528
+ '<pre>add_filter( \'pre_option_relevanssi_throttle_limit\', function( $limit ) { return 200; } );</pre>' .
1529
  '<li>' . __( "It's not usually necessary to adjust the limit from 500, but in some cases performance gains can be achieved by setting a lower limit. We don't suggest going under 200, as low values will make the results worse.", 'relevanssi' ) . '</li>' .
1530
  '</ul>',
1531
  ));
1688
  wp_enqueue_style( 'relevanssi_admin_css', $plugin_dir_url . 'lib/admin_styles.css' );
1689
 
1690
  $localizations = array(
1691
+ 'confirm' => __( 'Click OK to copy Relevanssi options to all subsites', 'relevanssi' ),
1692
+ 'confirm_stopwords' => __( 'Are you sure you want to remove all stopwords?', 'relevanssi' ),
1693
+ 'truncating_index' => __( 'Wiping out the index...', 'relevanssi' ),
1694
+ 'done' => __( 'Done.', 'relevanssi' ),
1695
+ 'indexing_users' => __( 'Indexing users...', 'relevanssi' ),
1696
+ 'indexing_taxonomies' => __( 'Indexing the following taxonomies:', 'relevanssi' ),
1697
+ 'indexing_attachments' => __( 'Indexing attachments...', 'relevanssi' ),
1698
+ 'counting_posts' => __( 'Counting posts...', 'relevanssi' ),
1699
+ 'counting_terms' => __( 'Counting taxonomy terms...', 'relevanssi' ),
1700
+ 'counting_users' => __( 'Counting users...', 'relevanssi' ),
1701
+ 'counting_attachments' => __( 'Counting attachments...', 'relevanssi' ),
1702
+ 'posts_found' => __( 'posts found.', 'relevanssi' ),
1703
+ 'terms_found' => __( 'taxonomy terms found.', 'relevanssi' ),
1704
+ 'users_found' => __( 'users found.', 'relevanssi' ),
1705
+ 'attachments_found' => __( 'attachments found.', 'relevanssi' ),
1706
+ 'taxonomy_disabled' => __( 'Taxonomy term indexing is disabled.', 'relevanssi' ),
1707
+ 'user_disabled' => __( 'User indexing is disabled.', 'relevanssi' ),
1708
+ 'indexing_complete' => __( 'Indexing complete.', 'relevanssi' ),
1709
+ 'excluded_posts' => __( 'posts excluded.', 'relevanssi' ),
1710
+ 'options_changed' => __( 'Settings have changed, please save the options before indexing.', 'relevanssi' ),
1711
+ 'reload_state' => __( 'Reload the page to refresh the state of the index.', 'relevanssi' ),
1712
+ 'pdf_reset_confirm' => __( 'Are you sure you want to delete all attachment content from the index?', 'relevanssi' ),
1713
+ 'pdf_reset_done' => __( 'Relevanssi attachment data wiped clean.', 'relevanssi' ),
1714
+ 'hour' => __( 'hour', 'relevanssi' ),
1715
+ 'hours' => __( 'hours', 'relevanssi' ),
1716
+ 'about' => __( 'about', 'relevanssi' ),
1717
+ 'sixty_min' => __( 'about an hour', 'relevanssi' ),
1718
+ 'ninety_min' => __( 'about an hour and a half', 'relevanssi' ),
1719
+ 'minute' => __( 'minute', 'relevanssi' ),
1720
+ 'minutes' => __( 'minutes', 'relevanssi' ),
1721
+ 'underminute' => __( 'less than a minute', 'relevanssi' ),
1722
+ 'notimeremaining' => __( "we're done!", 'relevanssi' ),
1723
  );
1724
 
1725
  wp_localize_script( 'relevanssi_admin_js', 'relevanssi', $localizations );
1734
 
1735
  /**
1736
  * Prints out the form fields for tag and category weights.
 
 
1737
  */
1738
+ function relevanssi_form_tag_weight() {
1739
+ $taxonomy_weights = get_option( 'relevanssi_post_type_weights' );
1740
+
1741
  $tag_value = 1;
1742
  if ( isset( $taxonomy_weights['post_tag'] ) ) {
1743
  $tag_value = $taxonomy_weights['post_tag'];
lib/search.php CHANGED
@@ -345,7 +345,7 @@ function relevanssi_search( $args ) {
345
  if ( ! empty( $expost ) ) {
346
  $excluded_post_ids = explode( ',', $expost );
347
  foreach ( $excluded_post_ids as $excluded_post_id ) {
348
- $exid = intval( trim( $excluded_post_id, ' -' ) );
349
  $posts_to_exclude .= " AND relevanssi.doc != $excluded_post_id";
350
  // Clean: escaped.
351
  }
@@ -611,36 +611,60 @@ function relevanssi_search( $args ) {
611
  $link_boost = floatval( get_option( 'relevanssi_link_boost' ) );
612
  $comment_boost = floatval( get_option( 'relevanssi_comment_boost' ) );
613
 
 
 
 
 
 
 
 
 
 
614
  $include_these_posts = array();
 
615
 
616
  do {
617
  foreach ( $terms as $term ) {
618
- $term = trim( $term ); // Numeric search terms will start with a space.
 
 
 
 
 
 
619
  /**
620
- * Allows the use of one letter search terms.
621
  *
622
- * Return false to allow one letter searches.
623
  *
624
- * @param boolean True, if search term is one letter long and will be blocked.
625
  */
626
- if ( apply_filters( 'relevanssi_block_one_letter_searches', relevanssi_strlen( $term ) < 2 ) ) {
627
- continue;
628
- }
629
- $term = esc_sql( $term );
630
 
631
- if ( false !== strpos( $o_term_cond, 'LIKE' ) ) {
632
- $term = $wpdb->esc_like( $term );
 
 
 
 
 
 
 
 
633
  }
634
 
635
- $term_cond = str_replace( '#term#', $term, $o_term_cond );
 
636
 
637
- $tag = $relevanssi_variables['post_type_weight_defaults']['post_tag'];
638
- $cat = $relevanssi_variables['post_type_weight_defaults']['category'];
639
- if ( ! empty( $post_type_weights['post_tag'] ) ) {
640
- $tag = $post_type_weights['post_tag'];
641
- }
642
- if ( ! empty( $post_type_weights['category'] ) ) {
643
- $cat = $post_type_weights['category'];
 
 
644
  }
645
 
646
  $query = "SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * $title_boost +
@@ -660,7 +684,6 @@ function relevanssi_search( $args ) {
660
  */
661
  $query = apply_filters( 'relevanssi_query_filter', $query );
662
  $matches = $wpdb->get_results( $query ); // WPCS: unprepared SQL ok, the query is thoroughly escaped.
663
-
664
  if ( count( $matches ) < 1 ) {
665
  continue;
666
  } else {
@@ -673,7 +696,7 @@ function relevanssi_search( $args ) {
673
  }
674
  $existing_ids = implode( ',', $existing_ids );
675
  $query = "SELECT relevanssi.*, relevanssi.title * $title_boost +
676
- relevanssi.content + relevanssi.comment * $comment_boost +
677
  relevanssi.tag * $tag + relevanssi.link * $link_boost +
678
  relevanssi.author + relevanssi.category * $cat + relevanssi.excerpt +
679
  relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
@@ -690,30 +713,6 @@ function relevanssi_search( $args ) {
690
 
691
  $total_hits += count( $matches );
692
 
693
- $query = "SELECT COUNT(DISTINCT(relevanssi.doc)) FROM $relevanssi_table AS relevanssi
694
- $query_join WHERE $term_cond $query_restrictions";
695
- // Clean: $query_restrictions is escaped, $term_cond is escaped.
696
- /**
697
- * Filters the DF query.
698
- *
699
- * This query is used to calculate the df for the tf * idf calculations.
700
- *
701
- * @param string MySQL query to filter.
702
- */
703
- $query = apply_filters( 'relevanssi_df_query_filter', $query );
704
-
705
- $df = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
706
-
707
- if ( $df < 1 && 'sometimes' === $fuzzy ) {
708
- $query = "SELECT COUNT(DISTINCT(relevanssi.doc)) FROM $relevanssi_table AS relevanssi
709
- $query_join WHERE (relevanssi.term LIKE '$term%'
710
- OR relevanssi.term_reverse LIKE CONCAT(REVERSE('$term), %')) $query_restrictions";
711
- // Clean: $query_restrictions is escaped, $term is escaped.
712
- /** Documented in lib/search.php. */
713
- $query = apply_filters( 'relevanssi_df_query_filter', $query );
714
- $df = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
715
- }
716
-
717
  $idf = log( $doc_count + 1 / ( 1 + $df ) );
718
  $idf = $idf * $idf; // Adjustment to increase the value of IDF.
719
  if ( $idf < 1 ) {
@@ -854,7 +853,6 @@ function relevanssi_search( $args ) {
854
  * @param int The post ID.
855
  */
856
  $post_ok = apply_filters( 'relevanssi_post_ok', $post_ok, $match->doc );
857
-
858
  if ( $post_ok ) {
859
  $doc_terms[ $match->doc ][ $term ] = true; // Count how many terms are matched to a doc.
860
  if ( ! isset( $doc_weight[ $match->doc ] ) ) {
@@ -2103,3 +2101,38 @@ function relevanssi_process_tax_query_row( $row, $is_sub_row, $global_relation,
2103
 
2104
  return array( $query_restrictions, $term_tax_ids, $not_term_tax_ids, $and_term_tax_ids );
2105
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  if ( ! empty( $expost ) ) {
346
  $excluded_post_ids = explode( ',', $expost );
347
  foreach ( $excluded_post_ids as $excluded_post_id ) {
348
+ $excluded_post_id = intval( trim( $excluded_post_id, ' -' ) );
349
  $posts_to_exclude .= " AND relevanssi.doc != $excluded_post_id";
350
  // Clean: escaped.
351
  }
611
  $link_boost = floatval( get_option( 'relevanssi_link_boost' ) );
612
  $comment_boost = floatval( get_option( 'relevanssi_comment_boost' ) );
613
 
614
+ $tag = $relevanssi_variables['post_type_weight_defaults']['post_tag'];
615
+ $cat = $relevanssi_variables['post_type_weight_defaults']['category'];
616
+ if ( ! empty( $post_type_weights['post_tag'] ) ) {
617
+ $tag = $post_type_weights['post_tag'];
618
+ }
619
+ if ( ! empty( $post_type_weights['category'] ) ) {
620
+ $cat = $post_type_weights['category'];
621
+ }
622
+
623
  $include_these_posts = array();
624
+ $df_counts = array();
625
 
626
  do {
627
  foreach ( $terms as $term ) {
628
+ $term_cond = relevanssi_generate_term_cond( $term, $o_term_cond );
629
+ if ( null === $term_cond ) {
630
+ continue;
631
+ }
632
+ $query = "SELECT COUNT(DISTINCT(relevanssi.doc)) FROM $relevanssi_table AS relevanssi
633
+ $query_join WHERE $term_cond $query_restrictions";
634
+ // Clean: $query_restrictions is escaped, $term_cond is escaped.
635
  /**
636
+ * Filters the DF query.
637
  *
638
+ * This query is used to calculate the df for the tf * idf calculations.
639
  *
640
+ * @param string MySQL query to filter.
641
  */
642
+ $query = apply_filters( 'relevanssi_df_query_filter', $query );
 
 
 
643
 
644
+ $df = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
645
+
646
+ if ( $df < 1 && 'sometimes' === $fuzzy ) {
647
+ $query = "SELECT COUNT(DISTINCT(relevanssi.doc)) FROM $relevanssi_table AS relevanssi
648
+ $query_join WHERE (relevanssi.term LIKE '$term%'
649
+ OR relevanssi.term_reverse LIKE CONCAT(REVERSE('$term'), '%')) $query_restrictions";
650
+ // Clean: $query_restrictions is escaped, $term is escaped.
651
+ /** Documented in lib/search.php. */
652
+ $query = apply_filters( 'relevanssi_df_query_filter', $query );
653
+ $df = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok.
654
  }
655
 
656
+ $df_counts[ $term ] = $df;
657
+ }
658
 
659
+ // Sort the terms in ascending DF order, so that rarest terms are searched
660
+ // for first. This is to make sure the throttle doesn't cut off posts with
661
+ // rare search terms.
662
+ asort( $df_counts );
663
+
664
+ foreach ( $df_counts as $term => $df ) {
665
+ $term_cond = relevanssi_generate_term_cond( $term, $o_term_cond );
666
+ if ( null === $term_cond ) {
667
+ continue;
668
  }
669
 
670
  $query = "SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * $title_boost +
684
  */
685
  $query = apply_filters( 'relevanssi_query_filter', $query );
686
  $matches = $wpdb->get_results( $query ); // WPCS: unprepared SQL ok, the query is thoroughly escaped.
 
687
  if ( count( $matches ) < 1 ) {
688
  continue;
689
  } else {
696
  }
697
  $existing_ids = implode( ',', $existing_ids );
698
  $query = "SELECT relevanssi.*, relevanssi.title * $title_boost +
699
+ relevanssi.content * $content_boost + relevanssi.comment * $comment_boost +
700
  relevanssi.tag * $tag + relevanssi.link * $link_boost +
701
  relevanssi.author + relevanssi.category * $cat + relevanssi.excerpt +
702
  relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
713
 
714
  $total_hits += count( $matches );
715
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
716
  $idf = log( $doc_count + 1 / ( 1 + $df ) );
717
  $idf = $idf * $idf; // Adjustment to increase the value of IDF.
718
  if ( $idf < 1 ) {
853
  * @param int The post ID.
854
  */
855
  $post_ok = apply_filters( 'relevanssi_post_ok', $post_ok, $match->doc );
 
856
  if ( $post_ok ) {
857
  $doc_terms[ $match->doc ][ $term ] = true; // Count how many terms are matched to a doc.
858
  if ( ! isset( $doc_weight[ $match->doc ] ) ) {
2101
 
2102
  return array( $query_restrictions, $term_tax_ids, $not_term_tax_ids, $and_term_tax_ids );
2103
  }
2104
+
2105
+ /**
2106
+ * Generates the WHERE condition for terms.
2107
+ *
2108
+ * Trims the term, escapes it and places it in the template.
2109
+ *
2110
+ * @param string $term The search term.
2111
+ * @param string $o_term_cond The search condition template.
2112
+ *
2113
+ * @return string The template with the term in place.
2114
+ */
2115
+ function relevanssi_generate_term_cond( $term, $o_term_cond ) {
2116
+ global $wpdb;
2117
+
2118
+ $term = trim( $term ); // Numeric search terms will start with a space.
2119
+ /**
2120
+ * Allows the use of one letter search terms.
2121
+ *
2122
+ * Return false to allow one letter searches.
2123
+ *
2124
+ * @param boolean True, if search term is one letter long and will be blocked.
2125
+ */
2126
+ if ( apply_filters( 'relevanssi_block_one_letter_searches', relevanssi_strlen( $term ) < 2 ) ) {
2127
+ return null;
2128
+ }
2129
+ $term = esc_sql( $term );
2130
+
2131
+ if ( false !== strpos( $o_term_cond, 'LIKE' ) ) {
2132
+ $term = $wpdb->esc_like( $term );
2133
+ }
2134
+
2135
+ $term_cond = str_replace( '#term#', $term, $o_term_cond );
2136
+
2137
+ return $term_cond;
2138
+ }
lib/stopwords.php CHANGED
@@ -63,3 +63,138 @@ function relevanssi_fetch_stopwords() {
63
 
64
  return $relevanssi_variables['stopword_list'];
65
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  return $relevanssi_variables['stopword_list'];
65
  }
66
+
67
+ /**
68
+ * Adds a stopword to the list of stopwords.
69
+ *
70
+ * @global object $wpdb The WP database interface.
71
+ *
72
+ * @param string $term The stopword that is added.
73
+ * @param boolean $verbose If true, print out notice. If false, be silent. Default
74
+ * true.
75
+ *
76
+ * @return boolean True, if success; false otherwise.
77
+ */
78
+ function relevanssi_add_stopword( $term, $verbose = true ) {
79
+ global $wpdb;
80
+ if ( empty( $term ) ) {
81
+ return;
82
+ }
83
+
84
+ $n = 0;
85
+ $s = 0;
86
+
87
+ $terms = explode( ',', $term );
88
+ if ( count( $terms ) > 1 ) {
89
+ foreach ( $terms as $term ) {
90
+ $n++;
91
+ $term = trim( $term );
92
+ $success = relevanssi_add_single_stopword( $term );
93
+ if ( $success ) {
94
+ $s++;
95
+ }
96
+ }
97
+ if ( $verbose ) {
98
+ // translators: %1$d is the successful entries, %2$d is the total entries.
99
+ printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( 'Successfully added %1$d/%2$d terms to stopwords!', 'relevanssi' ), intval( $s ), intval( $n ) ) );
100
+ }
101
+ } else {
102
+ // Add to stopwords.
103
+ $success = relevanssi_add_single_stopword( $term );
104
+
105
+ $term = stripslashes( $term );
106
+ $term = esc_html( $term );
107
+ if ( $verbose ) {
108
+ if ( $success ) {
109
+ // Translators: %s is the stopword.
110
+ printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( "Term '%s' added to stopwords!", 'relevanssi' ), esc_html( stripslashes( $term ) ) ) );
111
+ } else {
112
+ // Translators: %s is the stopword.
113
+ printf( esc_html__( "<div id='message' class='updated fade'><p>Couldn't add term '%s' to stopwords!</p></div>", 'relevanssi' ), esc_html( stripslashes( $term ) ) );
114
+ }
115
+ }
116
+ }
117
+
118
+ return $success;
119
+ }
120
+
121
+ /**
122
+ * Adds a single stopword to the stopword table.
123
+ *
124
+ * @global object $wpdb The WP database interface.
125
+ * @global array $relevanssi_variables The global Relevanssi variables.
126
+ *
127
+ * @param string $term The term to add.
128
+ *
129
+ * @return boolean True if success, false if not.
130
+ */
131
+ function relevanssi_add_single_stopword( $term ) {
132
+ global $wpdb, $relevanssi_variables;
133
+ if ( empty( $term ) ) {
134
+ return false;
135
+ }
136
+
137
+ $term = stripslashes( $term );
138
+ $term = esc_sql( $wpdb->esc_like( $term ) );
139
+
140
+ $success = $wpdb->query( $wpdb->prepare( 'INSERT INTO ' . $relevanssi_variables['stopword_table'] . ' (stopword) VALUES (%s)', $term ) ); // WPCS: unprepared SQL ok, Relevanssi table name.
141
+
142
+ if ( $success ) {
143
+ // Remove from index.
144
+ $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE term=%s', $term ) ); // WPCS: unprepared SQL ok, Relevanssi table name.
145
+ return true;
146
+ } else {
147
+ return false;
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Removes all stopwords.
153
+ *
154
+ * Truncates the wp_relevanssi_stopwords database table.
155
+ *
156
+ * @global object $wpdb The WP database interface.
157
+ * @global array $relevanssi_variables The global Relevanssi variables.
158
+ */
159
+ function relevanssi_remove_all_stopwords() {
160
+ global $wpdb, $relevanssi_variables;
161
+
162
+ $success = $wpdb->query( 'TRUNCATE ' . $relevanssi_variables['stopword_table'] ); // WPCS: unprepared SQL ok, Relevanssi table name.
163
+
164
+ if ( $success ) {
165
+ printf( "<div id='message' class='updated fade'><p>%s</p></div>", esc_html__( 'All stopwords removed! Remember to re-index.', 'relevanssi' ) );
166
+ } else {
167
+ printf( "<div id='message' class='updated fade'><p>%s</p></div>", esc_html__( "There was a problem, and stopwords couldn't be removed.", 'relevanssi' ) );
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Removes a single stopword.
173
+ *
174
+ * @global object $wpdb The WP database interface.
175
+ * @global array $relevanssi_variables The global Relevanssi variables.
176
+ *
177
+ * @param string $term The stopword to remove.
178
+ * @param boolean $verbose If true, print out a notice. Default true.
179
+ *
180
+ * @return boolean True if success, false if not.
181
+ */
182
+ function relevanssi_remove_stopword( $term, $verbose = true ) {
183
+ global $wpdb, $relevanssi_variables;
184
+
185
+ $success = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $relevanssi_variables['stopword_table'] . ' WHERE stopword=%s', $term ) ); // WPCS: unprepared SQL ok, Relevanssi table name.
186
+
187
+ if ( $success ) {
188
+ if ( $verbose ) {
189
+ // Translators: %s is the stopword.
190
+ printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( "Term '%s' removed from stopwords! Re-index to get it back to index.", 'relevanssi' ), esc_html( stripslashes( $term ) ) ) );
191
+ }
192
+ return true;
193
+ } else {
194
+ if ( $verbose ) {
195
+ // Translators: %s is the stopword.
196
+ printf( "<div id='message' class='updated fade'><p>%s</p></div>", sprintf( esc_html__( "Couldn't remove term '%s' from stopwords!", 'relevanssi' ), esc_html( stripslashes( $term ) ) ) );
197
+ }
198
+ return false;
199
+ }
200
+ }
lib/tabs/indexing-tab.php ADDED
@@ -0,0 +1,477 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * /lib/tabs/indexing-tab.php
4
+ *
5
+ * Prints out the Indexing tab in Relevanssi settings.
6
+ *
7
+ * @package Relevanssi
8
+ * @author Mikko Saari
9
+ * @license https://wordpress.org/about/gpl/ GNU General Public License
10
+ * @see https://www.relevanssi.com/
11
+ */
12
+
13
+ /**
14
+ * Prints out the indexing tab in Relevanssi settings.
15
+ *
16
+ * @global $wpdb The WordPress database interface.
17
+ * @global $relevanssi_variables The global Relevanssi variables array.
18
+ */
19
+ function relevanssi_indexing_tab() {
20
+ global $wpdb, $relevanssi_variables;
21
+
22
+ $index_post_types = get_option( 'relevanssi_index_post_types' );
23
+ $index_taxonomies_list = get_option( 'relevanssi_index_taxonomies_list' );
24
+ $index_comments = get_option( 'relevanssi_index_comments' );
25
+ $index_fields = get_option( 'relevanssi_index_fields' );
26
+ $index_author = get_option( 'relevanssi_index_author' );
27
+ $index_excerpt = get_option( 'relevanssi_index_excerpt' );
28
+ $expand_shortcodes = get_option( 'relevanssi_expand_shortcodes' );
29
+ $punctuation = get_option( 'relevanssi_punctuation' );
30
+ $min_word_length = get_option( 'relevanssi_min_word_length' );
31
+
32
+ if ( empty( $index_post_types ) ) {
33
+ $index_post_types = array();
34
+ }
35
+ if ( empty( $index_taxonomies_list ) ) {
36
+ $index_taxonomies_list = array();
37
+ }
38
+
39
+ $expand_shortcodes = relevanssi_check( $expand_shortcodes );
40
+ $index_author = relevanssi_check( $index_author );
41
+ $index_excerpt = relevanssi_check( $index_excerpt );
42
+ $index_comments_all = relevanssi_select( $index_comments, 'all' );
43
+ $index_comments_normal = relevanssi_select( $index_comments, 'normal' );
44
+ $index_comments_none = relevanssi_select( $index_comments, 'none' );
45
+
46
+ $fields_select_all = '';
47
+ $fields_select_none = '';
48
+ $fields_select_some = 'selected';
49
+ $fields_select_visible = '';
50
+ $original_index_fields = $index_fields;
51
+
52
+ if ( empty( $index_fields ) ) {
53
+ $fields_select_none = 'selected';
54
+ $fields_select_some = '';
55
+ }
56
+ if ( 'all' === $index_fields ) {
57
+ $fields_select_all = 'selected';
58
+ $fields_select_some = '';
59
+ $index_fields = '';
60
+ }
61
+ if ( 'visible' === $index_fields ) {
62
+ $fields_select_visible = 'selected';
63
+ $fields_select_some = '';
64
+ $index_fields = '';
65
+ }
66
+
67
+ if ( ! isset( $punctuation['quotes'] ) ) {
68
+ $punctuation['quotes'] = 'replace';
69
+ }
70
+ if ( ! isset( $punctuation['decimals'] ) ) {
71
+ $punctuation['decimals'] = 'remove';
72
+ }
73
+ if ( ! isset( $punctuation['ampersands'] ) ) {
74
+ $punctuation['ampersands'] = 'replace';
75
+ }
76
+ if ( ! isset( $punctuation['hyphens'] ) ) {
77
+ $punctuation['hyphens'] = 'replace';
78
+ }
79
+ $punct_quotes_replace = relevanssi_select( $punctuation['quotes'], 'replace' );
80
+ $punct_quotes_remove = relevanssi_select( $punctuation['quotes'], 'remove' );
81
+ $punct_decimals_replace = relevanssi_select( $punctuation['decimals'], 'replace' );
82
+ $punct_decimals_remove = relevanssi_select( $punctuation['decimals'], 'remove' );
83
+ $punct_decimals_keep = relevanssi_select( $punctuation['decimals'], 'keep' );
84
+ $punct_ampersands_replace = relevanssi_select( $punctuation['ampersands'], 'replace' );
85
+ $punct_ampersands_remove = relevanssi_select( $punctuation['ampersands'], 'remove' );
86
+ $punct_ampersands_keep = relevanssi_select( $punctuation['ampersands'], 'keep' );
87
+ $punct_hyphens_replace = relevanssi_select( $punctuation['hyphens'], 'replace' );
88
+ $punct_hyphens_remove = relevanssi_select( $punctuation['hyphens'], 'remove' );
89
+ $punct_hyphens_keep = relevanssi_select( $punctuation['hyphens'], 'keep' );
90
+
91
+ $docs_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT doc) FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc != -1' ); // WPCS: unprepared SQL ok, Relevanssi table name.
92
+ $terms_count = $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $relevanssi_variables['relevanssi_table'] ); // WPCS: unprepared SQL ok, Relevanssi table name.
93
+ $lowest_doc = $wpdb->get_var( 'SELECT doc FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc > 0 ORDER BY doc ASC LIMIT 1' ); // WPCS: unprepared SQL ok, Relevanssi table name.
94
+
95
+ if ( RELEVANSSI_PREMIUM ) {
96
+ $user_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE type = 'user'" ); // WPCS: unprepared SQL ok, Relevanssi table name.
97
+ $taxterm_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT item) FROM ' . $relevanssi_variables['relevanssi_table'] . " WHERE (type != 'post' AND type != 'attachment' AND type != 'user')" ); // WPCS: unprepared SQL ok, Relevanssi table name.
98
+ }
99
+
100
+ ?>
101
+ <div id="indexing_tab">
102
+
103
+ <table class="form-table">
104
+ <tr>
105
+ <th scope="row">
106
+ <input type='submit' name='submit' value='<?php esc_attr_e( 'Save the options', 'relevanssi' ); ?>' class='button button-primary' /><br /><br />
107
+ <input type="button" id="build_index" name="index" value="<?php esc_attr_e( 'Build the index', 'relevanssi' ); ?>" class='button-primary' /><br /><br />
108
+ <input type="button" id="continue_indexing" name="continue" value="<?php esc_attr_e( 'Index unindexed posts', 'relevanssi' ); ?>" class='button-primary' />
109
+ </th>
110
+ <td>
111
+ <div id='indexing_button_instructions'>
112
+ <?php // Translators: %s is "Build the index". ?>
113
+ <p class="description"><?php printf( esc_html__( '%s empties the existing index and rebuilds it from scratch.', 'relevanssi' ), '<strong>' . esc_html__( 'Build the index', 'relevanssi' ) . '</strong>' ); ?></p>
114
+ <?php // Translators: %s is "Build the index". ?>
115
+ <p class="description"><?php printf( esc_html__( "%s doesn't empty the index and only indexes those posts that are not indexed. You can use it if you have to interrupt building the index.", 'relevanssi' ), '<strong>' . esc_html__( 'Index unindexed posts', 'relevanssi' ) . '</strong>' ); ?>
116
+ <?php
117
+ if ( RELEVANSSI_PREMIUM ) {
118
+ esc_html_e( "This doesn't index any taxonomy terms or users.", 'relevanssi' );
119
+ }
120
+ ?>
121
+ </p>
122
+ </div>
123
+ <div id='relevanssi-note' style='display: none'></div>
124
+ <div id='relevanssi-progress' class='rpi-progress'><div class="rpi-indicator"></div></div>
125
+ <div id='relevanssi-timer'><?php esc_html_e( 'Time elapsed', 'relevanssi' ); ?>: <span id="relevanssi_elapsed">0:00:00</span> | <?php esc_html_e( 'Time remaining', 'relevanssi' ); ?>: <span id="relevanssi_estimated"><?php esc_html_e( 'some time', 'relevanssi' ); ?></span></div>
126
+ <textarea id='results' rows='10' cols='80'></textarea>
127
+ <div id='relevanssi-indexing-instructions' style='display: none'><?php esc_html_e( "Indexing should respond quickly. If nothing happens in couple of minutes, it's probably stuck. The most common reasons for indexing issues are incompatible shortcodes, so try disabling the shortcode expansion setting and try again. Also, if you've just updated Relevanssi, doing a hard refresh in your browser will make sure your browser is not trying to use an outdated version of the Relevanssi scripts.", 'relevanssi' ); ?></div>
128
+ </td>
129
+ </tr>
130
+ <tr>
131
+ <th scope="row"><?php esc_html_e( 'State of the index', 'relevanssi' ); ?></td>
132
+ <td id="stateoftheindex"><p><?php echo esc_html( $docs_count ); ?> <?php echo esc_html( _n( 'document in the index.', 'documents in the index.', $docs_count, 'relevanssi' ) ); ?>
133
+ <?php if ( RELEVANSSI_PREMIUM ) : ?>
134
+ <br /><?php echo esc_html( $user_count ); ?> <?php echo esc_html( _n( 'user in the index.', 'users in the index.', $user_count, 'relevanssi' ) ); ?><br />
135
+ <?php echo esc_html( $taxterm_count ); ?> <?php echo esc_html( _n( 'taxonomy term in the index.', 'taxonomy terms in the index.', $taxterm_count, 'relevanssi' ) ); ?>
136
+ <?php endif; ?>
137
+ </p>
138
+ <p><?php echo esc_html( $terms_count ); ?> <?php echo esc_html( _n( 'term in the index.', 'terms in the index.', $terms_count, 'relevanssi' ) ); ?><br />
139
+ <?php echo esc_html( $lowest_doc ); ?> <?php esc_html_e( 'is the lowest post ID indexed.', 'relevanssi' ); ?></p>
140
+ </td>
141
+ </tr>
142
+ </table>
143
+
144
+ <?php
145
+ if ( count( $index_post_types ) < 2 ) {
146
+ printf( '<p><strong>%s</strong></p>', esc_html__( "WARNING: You've chosen no post types to index. Nothing will be indexed. Choose some post types to index.", 'relevanssi' ) );
147
+ }
148
+ ?>
149
+
150
+ <h2 id="indexing"><?php esc_html_e( 'Indexing options', 'relevanssi' ); ?></h2>
151
+
152
+ <p><?php esc_html_e( 'Any changes to the settings on this page require reindexing before they take effect.', 'relevanssi' ); ?></p>
153
+
154
+ <table class="form-table">
155
+ <tr>
156
+ <th scope="row"><?php esc_html_e( 'Post types', 'relevanssi' ); ?></th>
157
+ <td>
158
+
159
+ <table class="widefat" id="index_post_types_table">
160
+ <thead>
161
+ <tr>
162
+ <th><?php esc_html_e( 'Type', 'relevanssi' ); ?></th>
163
+ <th><?php esc_html_e( 'Index', 'relevanssi' ); ?></th>
164
+ <th><?php esc_html_e( 'Excluded from search?', 'relevanssi' ); ?></th>
165
+ </tr>
166
+ </thead>
167
+ <?php
168
+ $pt_1 = get_post_types( array( 'exclude_from_search' => '0' ) );
169
+ $pt_2 = get_post_types( array( 'exclude_from_search' => false ) );
170
+ $public_types = array_merge( $pt_1, $pt_2 );
171
+ $post_types = get_post_types();
172
+ foreach ( $post_types as $type ) {
173
+ if ( in_array( $type, array( 'nav_menu_item', 'revision' ), true ) ) {
174
+ continue;
175
+ }
176
+ $checked = '';
177
+ if ( in_array( $type, $index_post_types, true ) ) {
178
+ $checked = 'checked="checked"';
179
+ }
180
+ $label = sprintf( '%s', $type );
181
+ $excluded_from_search = __( 'yes', 'relevanssi' );
182
+ if ( in_array( $type, $public_types, true ) ) {
183
+ $excluded_from_search = __( 'no', 'relevanssi' );
184
+ }
185
+ $name_id = 'relevanssi_index_type_' . $type;
186
+ printf( '<tr><td>%1$s</td><td><input type="checkbox" name="%2$s" id="%2$s" %3$s /></td><td>%4$s</td></tr>',
187
+ esc_html( $label ), esc_attr( $name_id ), esc_html( $checked ), esc_html( $excluded_from_search ) );
188
+ }
189
+ ?>
190
+ <tr style="display:none">
191
+ <td>
192
+ Helpful little control field
193
+ </td>
194
+ <td>
195
+ <input type='checkbox' name='relevanssi_index_type_bogus' id='relevanssi_index_type_bogus' checked="checked" />
196
+ </td>
197
+ <td>
198
+ This is our little secret, just for you and me
199
+ </td>
200
+ </tr>
201
+ </table>
202
+ <?php // Translators: %1$s is 'attachment', %2$s opens the link, %3$s closes it. ?>
203
+ <p class="description"><?php printf( esc_html__( '%1$s includes all attachment types. If you want to index only some attachments, see %2$sControlling attachment types in the Knowledge base%3$s.', 'relevanssi' ), '<code>attachment</code>', '<a href="https://www.relevanssi.com/knowledge-base/controlling-attachment-types-index/">', '</a>' ); ?></p>
204
+ </td>
205
+ </tr>
206
+
207
+ <tr>
208
+ <th scope="row">
209
+ <?php esc_html_e( 'Taxonomies', 'relevanssi' ); ?>
210
+ </th>
211
+ <td>
212
+
213
+ <table class="widefat" id="custom_taxonomies_table">
214
+ <thead>
215
+ <tr>
216
+ <th><?php esc_html_e( 'Taxonomy', 'relevanssi' ); ?></th>
217
+ <th><?php esc_html_e( 'Index', 'relevanssi' ); ?></th>
218
+ <th><?php esc_html_e( 'Public?', 'relevanssi' ); ?></th>
219
+ </tr>
220
+ </thead>
221
+
222
+ <?php
223
+ $taxos = get_taxonomies( '', 'objects' );
224
+ foreach ( $taxos as $taxonomy ) {
225
+ if ( in_array( $taxonomy->name, array( 'nav_menu', 'link_category' ), true ) ) {
226
+ continue;
227
+ }
228
+ $checked = '';
229
+ if ( in_array( $taxonomy->name, $index_taxonomies_list, true ) ) {
230
+ $checked = 'checked="checked"';
231
+ }
232
+ $label = sprintf( '%s', $taxonomy->name );
233
+ $public = __( 'no', 'relevanssi' );
234
+ if ( $taxonomy->public ) {
235
+ $public = __( 'yes', 'relevanssi' );
236
+ }
237
+ $name_id = 'relevanssi_index_taxonomy_' . $taxonomy->name;
238
+ printf( '<tr><td>%1$s</td><td><input type="checkbox" name="%2$s" id="%2$s" %3$s /></td><td>%4$s</td></tr>',
239
+ esc_html( $label ), esc_attr( $name_id ), esc_html( $checked ), esc_html( $public ) );
240
+ }
241
+ ?>
242
+ </table>
243
+
244
+ <p class="description"><?php esc_html_e( 'If you check a taxonomy here, the terms for that taxonomy are indexed with the posts. If you for example choose "post_tag", searching for a tag will find all posts that have the tag.', 'relevanssi' ); ?>
245
+
246
+ </td>
247
+ </tr>
248
+
249
+ <tr>
250
+ <th scope="row">
251
+ <label for='relevanssi_index_comments'><?php esc_html_e( 'Comments', 'relevanssi' ); ?></label>
252
+ </th>
253
+ <td>
254
+ <select name='relevanssi_index_comments' id='relevanssi_index_comments'>
255
+ <option value='none' <?php echo esc_html( $index_comments_none ); ?>><?php esc_html_e( 'none', 'relevanssi' ); ?></option>
256
+ <option value='normal' <?php echo esc_html( $index_comments_normal ); ?>><?php esc_html_e( 'comments', 'relevanssi' ); ?></option>
257
+ <option value='all' <?php echo esc_html( $index_comments_all ); ?>><?php esc_html_e( 'comments and pingbacks', 'relevanssi' ); ?></option>
258
+ </select>
259
+ <p class="description"><?php esc_html_e( 'If you choose to index comments, you can choose if you want to index just comments, or everything including comments and track- and pingbacks.', 'relevanssi' ); ?></p>
260
+ </td>
261
+ </tr>
262
+
263
+ <tr>
264
+ <th scope="row">
265
+ <label for='relevanssi_index_fields'><?php esc_html_e( 'Custom fields', 'relevanssi' ); ?></label>
266
+ </th>
267
+ <td>
268
+ <select name='relevanssi_index_fields_select' id='relevanssi_index_fields_select'>
269
+ <option value='none' <?php echo esc_html( $fields_select_none ); ?>><?php esc_html_e( 'none', 'relevanssi' ); ?></option>
270
+ <option value='all' <?php echo esc_html( $fields_select_all ); ?>><?php esc_html_e( 'all', 'relevanssi' ); ?></option>
271
+ <option value='visible' <?php echo esc_html( $fields_select_visible ); ?>><?php esc_html_e( 'visible', 'relevanssi' ); ?></option>
272
+ <option value='some' <?php echo esc_html( $fields_select_some ); ?>><?php esc_html_e( 'some', 'relevanssi' ); ?></option>
273
+ </select>
274
+ <p class="description">
275
+ <?php
276
+ esc_html_e( "'All' indexes all custom fields for posts.", 'relevanssi' );
277
+ echo '<br/>';
278
+ esc_html_e( "'Visible' only includes the custom fields that are visible in the user interface (with names that don't start with an underscore).", 'relevanssi' );
279
+ echo '<br/>';
280
+ esc_html_e( "'Some' lets you choose individual custom fields to index.", 'relevanssi' );
281
+ ?>
282
+ </p>
283
+ <div id="index_field_input"
284
+ <?php
285
+ if ( empty( $fields_select_some ) ) {
286
+ echo 'style="display: none"';
287
+ }
288
+ ?>
289
+ >
290
+ <input type='text' name='relevanssi_index_fields' id='relevanssi_index_fields' size='60' value='<?php echo esc_attr( $index_fields ); ?>' />
291
+ <p class="description"><?php esc_html_e( "Enter a comma-separated list of custom fields to include in the index. With Relevanssi Premium, you can also use 'fieldname_%_subfieldname' notation for ACF repeater fields.", 'relevanssi' ); ?></p>
292
+ <p class="description"><?php esc_html_e( "You can use 'relevanssi_index_custom_fields' filter hook to adjust which custom fields are indexed.", 'relevanssi' ); ?></p>
293
+ </div>
294
+ <?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
295
+ <?php // Translators: %1$s is the 'some' option and %2$s is '_sku'. ?>
296
+ <p class="description"><?php printf( esc_html__( 'If you want the SKU included, choose %1$s and enter %2$s. Also see the contextual help for more details.', 'relevanssi' ), esc_html( "'" . __( 'some', 'relevanssi' ) . "'" ), '<code>_sku</code>' ); ?></p>
297
+ <?php endif; ?>
298
+ </td>
299
+ </tr>
300
+
301
+ <tr>
302
+ <th scope="row">
303
+ <label for='relevanssi_index_author'><?php esc_html_e( 'Author display names', 'relevanssi' ); ?></label>
304
+ </th>
305
+ <td>
306
+ <fieldset>
307
+ <legend class="screen-reader-text"><?php esc_html_e( 'Index the post author display name', 'relevanssi' ); ?></legend>
308
+ <label for='relevanssi_index_author'>
309
+ <input type='checkbox' name='relevanssi_index_author' id='relevanssi_index_author' <?php echo esc_html( $index_author ); ?> />
310
+ <?php esc_html_e( 'Index the post author display name', 'relevanssi' ); ?>
311
+ </label>
312
+ <p class="description"><?php esc_html_e( 'Searching for the post author display name will return posts by that author.', 'relevanssi' ); ?></p>
313
+ </fieldset>
314
+ </td>
315
+ </tr>
316
+
317
+ <tr>
318
+ <th scope="row">
319
+ <label for='relevanssi_index_excerpt'><?php esc_html_e( 'Excerpts', 'relevanssi' ); ?></label>
320
+ </th>
321
+ <td>
322
+ <fieldset>
323
+ <legend class="screen-reader-text"><?php esc_html_e( 'Index the post excerpt', 'relevanssi' ); ?></legend>
324
+ <label for='relevanssi_index_excerpt'>
325
+ <input type='checkbox' name='relevanssi_index_excerpt' id='relevanssi_index_excerpt' <?php echo esc_html( $index_excerpt ); ?> />
326
+ <?php esc_html_e( 'Index the post excerpt', 'relevanssi' ); ?>
327
+ </label>
328
+ <p class="description"><?php esc_html_e( 'Relevanssi will find posts by the content in the excerpt.', 'relevanssi' ); ?></p>
329
+ <?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
330
+ <p class="description"><?php esc_html_e( "WooCommerce stores the product short description in the excerpt, so it's a good idea to index excerpts.", 'relevanssi' ); ?></p>
331
+ <?php endif; ?>
332
+ </fieldset>
333
+ </td>
334
+ </tr>
335
+
336
+ </table>
337
+
338
+ <h2><?php esc_html_e( 'Shortcodes', 'relevanssi' ); ?></h2>
339
+
340
+ <table class="form-table">
341
+ <tr>
342
+ <th scope="row">
343
+ <label for='relevanssi_expand_shortcodes'><?php esc_html_e( 'Expand shortcodes', 'relevanssi' ); ?></label>
344
+ </th>
345
+ <td>
346
+ <fieldset>
347
+ <legend class="screen-reader-text"><?php esc_html_e( 'Index the post excerpt', 'relevanssi' ); ?></legend>
348
+ <label for='relevanssi_expand_shortcodes'>
349
+ <input type='checkbox' name='relevanssi_expand_shortcodes' id='relevanssi_expand_shortcodes' <?php echo esc_html( $expand_shortcodes ); ?> />
350
+ <?php esc_html_e( 'Expand shortcodes when indexing', 'relevanssi' ); ?>
351
+ </label>
352
+ <?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
353
+ <p class="description important"><?php esc_html_e( "WooCommerce has shortcodes that don't work well with Relevanssi. With WooCommerce, make sure the option is disabled.", 'relevanssi' ); ?></p>
354
+ <?php endif; ?>
355
+ <p class="description"><?php esc_html_e( 'If checked, Relevanssi will expand shortcodes in post content before indexing. Otherwise shortcodes will be stripped.', 'relevanssi' ); ?></p>
356
+ <p class="description"><?php esc_html_e( 'If you use shortcodes to include dynamic content, Relevanssi will not keep the index updated, the index will reflect the status of the shortcode content at the moment of indexing.', 'relevanssi' ); ?></p>
357
+ </fieldset>
358
+ </td>
359
+ </tr>
360
+
361
+ <?php
362
+ if ( function_exists( 'relevanssi_form_disable_shortcodes' ) ) {
363
+ relevanssi_form_disable_shortcodes();
364
+ }
365
+ ?>
366
+
367
+ </table>
368
+
369
+ <?php
370
+ if ( function_exists( 'relevanssi_form_index_users' ) ) {
371
+ relevanssi_form_index_users();
372
+ }
373
+ if ( function_exists( 'relevanssi_form_index_synonyms' ) ) {
374
+ relevanssi_form_index_synonyms();
375
+ }
376
+ if ( function_exists( 'relevanssi_form_index_taxonomies' ) ) {
377
+ relevanssi_form_index_taxonomies();
378
+ }
379
+ if ( function_exists( 'relevanssi_form_index_pdf_parent' ) ) {
380
+ relevanssi_form_index_pdf_parent();
381
+ }
382
+ ?>
383
+
384
+ <h2><?php esc_html_e( 'Advanced indexing settings', 'relevanssi' ); ?></h2>
385
+
386
+ <p><button type="button" id="show_advanced_indexing"><?php esc_html_e( 'Show advanced settings', 'relevanssi' ); ?></button></p>
387
+
388
+ <table class="form-table screen-reader-text" id="advanced_indexing">
389
+ <tr>
390
+ <th scope="row">
391
+ <label for='relevanssi_min_word_length'><?php esc_html_e( 'Minimum word length', 'relevanssi' ); ?></label>
392
+ </th>
393
+ <td>
394
+ <input type='number' name='relevanssi_min_word_length' id='relevanssi_min_word_length' value='<?php echo esc_attr( $min_word_length ); ?>' />
395
+ <p class="description"><?php esc_html_e( 'Words shorter than this many letters will not be indexed.', 'relevanssi' ); ?></p>
396
+ <?php // Translators: %1$s is 'relevanssi_block_one_letter_searches' and %2$s is 'false'. ?>
397
+ <p class="description"><?php printf( esc_html__( 'To enable one-letter searches, you need to add a filter function on the filter hook %1$s that returns %2$s.', 'relevanssi' ), '<code>relevanssi_block_one_letter_searches</code>', '<code>false</code>' ); ?></p>
398
+ </td>
399
+ </tr>
400
+ <tr>
401
+ <th scope="row"><?php esc_html_e( 'Punctuation control', 'relevanssi' ); ?></th>
402
+ <td><p class="description"><?php esc_html_e( 'Here you can adjust how the punctuation is controlled. For more information, see help. Remember that any changes here require reindexing, otherwise searches will fail to find posts they should.', 'relevanssi' ); ?></p></td>
403
+ </tr>
404
+ <tr>
405
+ <th scope="row">
406
+ <label for='relevanssi_punct_hyphens'><?php esc_html_e( 'Hyphens and dashes', 'relevanssi' ); ?></label>
407
+ </th>
408
+ <td>
409
+ <select name='relevanssi_punct_hyphens' id='relevanssi_punct_hyphens'>
410
+ <option value='keep' <?php echo esc_html( $punct_hyphens_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
411
+ <option value='replace' <?php echo esc_html( $punct_hyphens_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
412
+ <option value='remove' <?php echo esc_html( $punct_hyphens_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
413
+ </select>
414
+ <p class="description"><?php esc_html_e( 'How Relevanssi should handle hyphens and dashes (en and em dashes)? Replacing with spaces is generally the best option, but in some cases removing completely is the best option. Keeping them is rarely the best option.', 'relevanssi' ); ?></p>
415
+
416
+ </td>
417
+ </tr>
418
+ <tr>
419
+ <th scope="row">
420
+ <label for='relevanssi_punct_quotes'><?php esc_html_e( 'Apostrophes and quotes', 'relevanssi' ); ?></label>
421
+ </th>
422
+ <td>
423
+ <select name='relevanssi_punct_quotes' id='relevanssi_punct_quotes'>
424
+ <option value='replace' <?php echo esc_html( $punct_quotes_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
425
+ <option value='remove' <?php echo esc_html( $punct_quotes_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
426
+ </select>
427
+ <p class="description"><?php esc_html_e( "How Relevanssi should handle apostrophes and quotes? It's not possible to keep them; that would lead to problems. Default behaviour is to replace with spaces, but sometimes removing makes sense.", 'relevanssi' ); ?></p>
428
+
429
+ </td>
430
+ </tr>
431
+ <tr>
432
+ <th scope="row">
433
+ <label for='relevanssi_punct_ampersands'><?php esc_html_e( 'Ampersands', 'relevanssi' ); ?></label>
434
+ </th>
435
+ <td>
436
+ <select name='relevanssi_punct_ampersands' id='relevanssi_punct_ampersands'>
437
+ <option value='keep' <?php echo esc_html( $punct_ampersands_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
438
+ <option value='replace' <?php echo esc_html( $punct_ampersands_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
439
+ <option value='remove' <?php echo esc_html( $punct_ampersands_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
440
+ </select>
441
+ <p class="description"><?php esc_html_e( 'How Relevanssi should handle ampersands? Replacing with spaces is generally the best option, but if you talk a lot about D&amp;D, for example, keeping the ampersands is useful.', 'relevanssi' ); ?></p>
442
+
443
+ </td>
444
+ </tr>
445
+ <tr>
446
+ <th scope="row">
447
+ <label for='relevanssi_punct_decimals'><?php esc_html_e( 'Decimal separators', 'relevanssi' ); ?></label>
448
+ </th>
449
+ <td>
450
+ <select name='relevanssi_punct_decimals' id='relevanssi_punct_decimals'>
451
+ <option value='keep' <?php echo esc_html( $punct_decimals_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
452
+ <option value='replace' <?php echo esc_html( $punct_decimals_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
453
+ <option value='remove' <?php echo esc_html( $punct_decimals_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
454
+ </select>
455
+ <p class="description"><?php esc_html_e( 'How Relevanssi should handle periods between decimals? Replacing with spaces is the default option, but that often leads to the numbers being removed completely. If you need to search decimal numbers a lot, keep the periods.', 'relevanssi' ); ?></p>
456
+
457
+ </td>
458
+ </tr>
459
+ <?php
460
+ if ( function_exists( 'relevanssi_form_thousands_separator' ) ) {
461
+ relevanssi_form_thousands_separator();
462
+ }
463
+ if ( function_exists( 'relevanssi_form_mysql_columns' ) ) {
464
+ relevanssi_form_mysql_columns();
465
+ }
466
+ if ( function_exists( 'relevanssi_form_internal_links' ) ) {
467
+ relevanssi_form_internal_links();
468
+ }
469
+ ?>
470
+
471
+ </table>
472
+
473
+ <p><button type="button" style="display: none" id="hide_advanced_indexing"><?php esc_html_e( 'Hide advanced settings', 'relevanssi' ); ?></button></p>
474
+
475
+ </div>
476
+ <?php
477
+ }
lib/tabs/logging-tab.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * /lib/tabs/logging-tab.php
4
+ *
5
+ * Prints out the Logging tab in Relevanssi settings.
6
+ *
7
+ * @package Relevanssi
8
+ * @author Mikko Saari
9
+ * @license https://wordpress.org/about/gpl/ GNU General Public License
10
+ * @see https://www.relevanssi.com/
11
+ */
12
+
13
+ /**
14
+ * Prints out the logging tab in Relevanssi settings.
15
+ *
16
+ * @global $wpdb The WordPress database interface.
17
+ * @global $relevanssi_variables The global Relevanssi variables array.
18
+ */
19
+ function relevanssi_logging_tab() {
20
+ global $wpdb, $relevanssi_variables;
21
+
22
+ $log_queries = get_option( 'relevanssi_log_queries' );
23
+ $log_queries = relevanssi_check( $log_queries );
24
+ $log_queries_with_ip = get_option( 'relevanssi_log_queries_with_ip' );
25
+ $log_queries_with_ip = relevanssi_check( $log_queries_with_ip );
26
+ $omit_from_logs = get_option( 'relevanssi_omit_from_logs' );
27
+ $trim_logs = get_option( 'relevanssi_trim_logs' );
28
+
29
+ ?>
30
+ <table class="form-table">
31
+ <tr>
32
+ <th scope="row">
33
+ <label for='relevanssi_log_queries'><?php esc_html_e( 'Enable logs', 'relevanssi' ); ?></label>
34
+ </th>
35
+ <td>
36
+ <fieldset>
37
+ <legend class="screen-reader-text"><?php esc_html_e( 'Keep a log of user queries.', 'relevanssi' ); ?></legend>
38
+ <label for='relevanssi_log_queries'>
39
+ <input type='checkbox' name='relevanssi_log_queries' id='relevanssi_log_queries' <?php echo esc_html( $log_queries ); ?> />
40
+ <?php esc_html_e( 'Keep a log of user queries.', 'relevanssi' ); ?>
41
+ </label>
42
+ </fieldset>
43
+ <p class="description">
44
+ <?php
45
+ // Translators: %1$s is the name of the "User searches" page, %2$s is the name of the database table.
46
+ printf( esc_html__( "If enabled, Relevanssi will log user queries. The logs can be examined under '%1\$s' on the Dashboard admin menu and are stored in the %2\$s database table.", 'relevanssi' ),
47
+ esc_html__( 'User searches', 'relevanssi' ), esc_html( $wpdb->prefix . 'relevanssi_log' ) );
48
+ ?>
49
+ </p>
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <th scope="row">
54
+ <label for='relevanssi_log_queries_with_ip'><?php esc_html_e( 'Log user IP', 'relevanssi' ); ?></label>
55
+ </th>
56
+ <td>
57
+ <fieldset>
58
+ <legend class="screen-reader-text"><?php esc_html_e( "Log the user's IP with the queries.", 'relevanssi' ); ?></legend>
59
+ <label for='relevanssi_log_queries_with_ip'>
60
+ <input type='checkbox' name='relevanssi_log_queries_with_ip' id='relevanssi_log_queries_with_ip' <?php echo esc_html( $log_queries_with_ip ); ?> />
61
+ <?php esc_html_e( "Log the user's IP with the queries.", 'relevanssi' ); ?>
62
+ </label>
63
+ </fieldset>
64
+ <p class="description"><?php esc_html_e( "If enabled, Relevanssi will log user's IP adress with the queries. Note that this may be illegal where you live, and in EU will create a person registry that falls under the GDPR.", 'relevanssi' ); ?></p>
65
+ </td>
66
+ </tr>
67
+ <tr>
68
+ <th scope="row">
69
+ <label for='relevanssi_omit_from_logs'><?php esc_html_e( 'Exclude users', 'relevanssi' ); ?></label>
70
+ </th>
71
+ <td>
72
+ <input type='text' name='relevanssi_omit_from_logs' id='relevanssi_omit_from_logs' size='60' value='<?php echo esc_attr( $omit_from_logs ); ?>' />
73
+ <p class="description"><?php esc_html_e( 'Comma-separated list of numeric user IDs or user login names that will not be logged.', 'relevanssi' ); ?></p>
74
+ </td>
75
+ </tr>
76
+ <?php
77
+ if ( function_exists( 'relevanssi_form_hide_branding' ) ) {
78
+ relevanssi_form_hide_branding();
79
+ }
80
+ ?>
81
+ <tr>
82
+ <th scope="row">
83
+ <label for='relevanssi_trim_logs'><?php esc_html_e( 'Trim logs', 'relevanssi' ); ?></label>
84
+ </th>
85
+ <td>
86
+ <input type='number' name='relevanssi_trim_logs' id='relevanssi_trim_logs' value='<?php echo esc_attr( $trim_logs ); ?>' />
87
+ <?php esc_html_e( 'How many days of logs to keep in the database.', 'relevanssi' ); ?>
88
+ <?php // Translators: %d is the setting for no trim (probably 0). ?>
89
+ <p class="description"><?php printf( esc_html__( ' Set to %d for no trimming.', 'relevanssi' ), 0 ); ?></p>
90
+ </td>
91
+ </tr>
92
+
93
+ </table>
94
+ <?php
95
+ }
lib/tabs/searching-tab.php ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * /lib/tabs/searching-tab.php
4
+ *
5
+ * Prints out the Searching tab in Relevanssi settings.
6
+ *
7
+ * @package Relevanssi
8
+ * @author Mikko Saari
9
+ * @license https://wordpress.org/about/gpl/ GNU General Public License
10
+ * @see https://www.relevanssi.com/
11
+ */
12
+
13
+ /**
14
+ * Prints out the searching tab in Relevanssi settings.
15
+ *
16
+ * @global $wpdb The WordPress database interface.
17
+ * @global $relevanssi_variables The global Relevanssi variables array.
18
+ */
19
+ function relevanssi_searching_tab() {
20
+ global $wpdb, $relevanssi_variables;
21
+
22
+ $implicit = get_option( 'relevanssi_implicit_operator' );
23
+ $orderby = get_option( 'relevanssi_default_orderby' );
24
+ $fuzzy = get_option( 'relevanssi_fuzzy' );
25
+ $content_boost = get_option( 'relevanssi_content_boost' );
26
+ $title_boost = get_option( 'relevanssi_title_boost' );
27
+ $comment_boost = get_option( 'relevanssi_comment_boost' );
28
+ $exact_match_bonus = get_option( 'relevanssi_exact_match_bonus' );
29
+ $wpml_only_current = get_option( 'relevanssi_wpml_only_current' );
30
+ $polylang_allow_all = get_option( 'relevanssi_polylang_all_languages' );
31
+ $admin_search = get_option( 'relevanssi_admin_search' );
32
+ $disable_or_fallback = get_option( 'relevanssi_disable_or_fallback' );
33
+ $throttle = get_option( 'relevanssi_throttle' );
34
+ $respect_exclude = get_option( 'relevanssi_respect_exclude' );
35
+ $cat = get_option( 'relevanssi_cat' );
36
+ $excat = get_option( 'relevanssi_excat' );
37
+ $exclude_posts = get_option( 'relevanssi_exclude_posts' );
38
+ $index_post_types = get_option( 'relevanssi_index_post_types' );
39
+
40
+ $throttle = relevanssi_check( $throttle );
41
+ $respect_exclude = relevanssi_check( $respect_exclude );
42
+ $admin_search = relevanssi_check( $admin_search );
43
+ $wpml_only_current = relevanssi_check( $wpml_only_current );
44
+ $polylang_allow_all = relevanssi_check( $polylang_allow_all );
45
+ $exact_match_bonus = relevanssi_check( $exact_match_bonus );
46
+ $disable_or_fallback = relevanssi_check( $disable_or_fallback );
47
+ $implicit_and = relevanssi_select( $implicit, 'AND' );
48
+ $implicit_or = relevanssi_select( $implicit, 'OR' );
49
+ $orderby_relevance = relevanssi_select( $orderby, 'relevance' );
50
+ $orderby_date = relevanssi_select( $orderby, 'post_date' );
51
+ $fuzzy_sometimes = relevanssi_select( $fuzzy, 'sometimes' );
52
+ $fuzzy_always = relevanssi_select( $fuzzy, 'always' );
53
+ $fuzzy_never = relevanssi_select( $fuzzy, 'never' );
54
+
55
+ $orfallback_visibility = 'screen-reader-text';
56
+ if ( 'AND' === $implicit ) {
57
+ $orfallback_visibility = '';
58
+ }
59
+
60
+ $docs_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT doc) FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc != -1' ); // WPCS: unprepared SQL ok, Relevanssi table name.
61
+ ?>
62
+
63
+ <table class="form-table">
64
+ <tr>
65
+ <th scope="row">
66
+ <label for='relevanssi_implicit_operator'><?php esc_html_e( 'Default operator', 'relevanssi' ); ?></label>
67
+ </th>
68
+ <td>
69
+ <select name='relevanssi_implicit_operator' id='relevanssi_implicit_operator'>
70
+ <option value='AND' <?php echo esc_html( $implicit_and ); ?>><?php esc_html_e( 'AND - require all terms', 'relevanssi' ); ?></option>
71
+ <option value='OR' <?php echo esc_html( $implicit_or ); ?>><?php esc_html_e( 'OR - any term present is enough', 'relevanssi' ); ?></option>
72
+ </select>
73
+ <p class="description"><?php esc_html_e( 'This setting determines the default operator for the search.', 'relevanssi' ); ?></p>
74
+ <?php
75
+ if ( RELEVANSSI_PREMIUM ) {
76
+ // Translators: %1$s is the name of the 'operator' query variable, %2$s is an example url.
77
+ echo "<p class='description'>" . sprintf( esc_html__( 'You can override this setting with the %1$s query parameter, like this: %2$s', 'relevanssi' ), '<code>operator</code>', 'http://www.example.com/?s=term&amp;operator=or' ) . '</p>';
78
+ }
79
+ ?>
80
+ </td>
81
+ </tr>
82
+ <tr id="orfallback" class='<?php echo esc_attr( $orfallback_visibility ); ?>'>
83
+ <th scope="row">
84
+ <label for='relevanssi_disable_or_fallback'><?php esc_html_e( 'Fallback to OR', 'relevanssi' ); ?></label>
85
+ </th>
86
+ <td>
87
+ <fieldset>
88
+ <legend class="screen-reader-text"><?php esc_html_e( 'Disable the OR fallback.', 'relevanssi' ); ?></legend>
89
+ <label for='relevanssi_disable_or_fallback'>
90
+ <input type='checkbox' name='relevanssi_disable_or_fallback' id='relevanssi_disable_or_fallback' <?php echo esc_html( $disable_or_fallback ); ?> />
91
+ <?php esc_html_e( 'Disable the OR fallback.', 'relevanssi' ); ?>
92
+ </label>
93
+ </fieldset>
94
+ <p class="description"><?php esc_html_e( 'By default, if AND search fails to find any results, Relevanssi will switch the operator to OR and run the search again. You can prevent that by checking this option.', 'relevanssi' ); ?></p>
95
+ </td>
96
+ </tr>
97
+ <tr>
98
+ <th scope="row">
99
+ <label for='relevanssi_default_orderby'><?php esc_html_e( 'Default order', 'relevanssi' ); ?></label>
100
+ </th>
101
+ <td>
102
+ <select name='relevanssi_default_orderby' id='relevanssi_default_orderby'>
103
+ <option value='relevance' <?php echo esc_html( $orderby_relevance ); ?>><?php esc_html_e( 'Relevance (highly recommended)', 'relevanssi' ); ?></option>
104
+ <option value='post_date' <?php echo esc_html( $orderby_date ); ?>><?php esc_html_e( 'Post date', 'relevanssi' ); ?></option>
105
+ </select>
106
+ <?php // Translators: name of the query variable. ?>
107
+ <p class="description"><?php printf( esc_html__( 'If you want to override this or use multi-layered ordering (eg. first order by relevance, but sort ties by post title), you can use the %s query variable. See Help for more information.', 'relevanssi' ), '<code>orderby</code>' ); ?></p>
108
+ <?php if ( RELEVANSSI_PREMIUM ) { ?>
109
+ <p class="description"><?php esc_html_e( ' If you want date-based results, see the recent post bonus in the Weights section.', 'relevanssi' ); ?></p>
110
+ <?php } // End if ( RELEVANSSI_PREMIUM ). ?>
111
+ </td>
112
+ </tr>
113
+ <tr>
114
+ <th scope="row">
115
+ <label for='relevanssi_fuzzy'><?php esc_html_e( 'Keyword matching', 'relevanssi' ); ?></label>
116
+ </th>
117
+ <td>
118
+ <select name='relevanssi_fuzzy' id='relevanssi_fuzzy'>
119
+ <option value='never' <?php echo esc_html( $fuzzy_never ); ?>><?php esc_html_e( 'Whole words', 'relevanssi' ); ?></option>
120
+ <option value='always' <?php echo esc_html( $fuzzy_always ); ?>><?php esc_html_e( 'Partial words', 'relevanssi' ); ?></option>
121
+ <option value='sometimes' <?php echo esc_html( $fuzzy_sometimes ); ?>><?php esc_html_e( 'Partial words if no hits for whole words', 'relevanssi' ); ?></option>
122
+ </select>
123
+ <p class="description"><?php esc_html_e( 'Whole words means Relevanssi only finds posts that include the whole search term.', 'relevanssi' ); ?></p>
124
+ <p class="description"><?php esc_html_e( "Partial words also includes cases where the word in the index begins or ends with the search term (searching for 'ana' will match 'anaconda' or 'banana', but not 'banal'). See Help, if you want to make Relevanssi match also inside words.", 'relevanssi' ); ?></p>
125
+ </td>
126
+ </tr>
127
+ <tr>
128
+ <th scope="row">
129
+ <?php esc_html_e( 'Weights', 'relevanssi' ); ?>
130
+ </th>
131
+ <td>
132
+ <p class="description"><?php esc_html_e( 'All the weights in the table are multipliers. To increase the weight of an element, use a higher number. To make an element less significant, use a number lower than 1.', 'relevanssi' ); ?></p>
133
+ <table class="relevanssi-weights-table">
134
+ <thead>
135
+ <tr>
136
+ <th><?php esc_html_e( 'Element', 'relevanssi' ); ?></th>
137
+ <th class="col-2"><?php esc_html_e( 'Weight', 'relevanssi' ); ?></th>
138
+ </tr>
139
+ </thead>
140
+ <tr>
141
+ <td>
142
+ <?php esc_html_e( 'Content', 'relevanssi' ); ?>
143
+ </td>
144
+ <td class="col-2">
145
+ <input type='text' name='relevanssi_content_boost' id='relevanssi_content_boost' size='4' value='<?php echo esc_attr( $content_boost ); ?>' />
146
+ </td>
147
+ </tr>
148
+ <tr>
149
+ <td>
150
+ <?php esc_html_e( 'Titles', 'relevanssi' ); ?>
151
+ </td>
152
+ <td class="col-2">
153
+ <input type='text' name='relevanssi_title_boost' id='relevanssi_title_boost' size='4' value='<?php echo esc_attr( $title_boost ); ?>' />
154
+ </td>
155
+ </tr>
156
+ <?php
157
+ if ( function_exists( 'relevanssi_form_link_weight' ) ) {
158
+ relevanssi_form_link_weight();
159
+ }
160
+ ?>
161
+ <tr>
162
+ <td>
163
+ <?php esc_html_e( 'Comment text', 'relevanssi' ); ?>
164
+ </td>
165
+ <td class="col-2">
166
+ <input type='text' name='relevanssi_comment_boost' id='relevanssi_comment_boost' size='4' value='<?php echo esc_attr( $comment_boost ); ?>' />
167
+ </td>
168
+ </tr>
169
+ <?php
170
+ if ( function_exists( 'relevanssi_form_post_type_weights' ) ) {
171
+ relevanssi_form_post_type_weights();
172
+ }
173
+ if ( function_exists( 'relevanssi_form_taxonomy_weights' ) ) {
174
+ relevanssi_form_taxonomy_weights();
175
+ } elseif ( function_exists( 'relevanssi_form_tag_weight' ) ) {
176
+ relevanssi_form_tag_weight();
177
+ }
178
+ if ( function_exists( 'relevanssi_form_recency_weight' ) ) {
179
+ relevanssi_form_recency_weight();
180
+ }
181
+ ?>
182
+ </table>
183
+ </td>
184
+ </tr>
185
+ <?php
186
+ if ( function_exists( 'relevanssi_form_recency_cutoff' ) ) {
187
+ relevanssi_form_recency_cutoff();
188
+ }
189
+ ?>
190
+ <tr>
191
+ <th scope="row">
192
+ <label for='relevanssi_exact_match_bonus'><?php esc_html_e( 'Boost exact matches', 'relevanssi' ); ?></label>
193
+ </th>
194
+ <td>
195
+ <fieldset>
196
+ <legend class="screen-reader-text"><?php esc_html_e( 'Give boost to exact matches.', 'relevanssi' ); ?></legend>
197
+ <label for='relevanssi_exact_match_bonus'>
198
+ <input type='checkbox' name='relevanssi_exact_match_bonus' id='relevanssi_exact_match_bonus' <?php echo esc_html( $exact_match_bonus ); ?> />
199
+ <?php esc_html_e( 'Give boost to exact matches.', 'relevanssi' ); ?>
200
+ </label>
201
+ </fieldset>
202
+ <?php // Translators: %s is the name of the filter hook. ?>
203
+ <p class="description"><?php printf( esc_html__( 'If you enable this option, matches where the search query appears in title or content as a phrase will get a weight boost. To adjust the boost, you can use the %s filter hook. See Help for more details.', 'relevanssi' ), '<code>relevanssi_exact_match_bonus</code>' ); ?></p>
204
+ </td>
205
+ </tr>
206
+ <?php
207
+ if ( function_exists( 'icl_object_id' ) && ! function_exists( 'pll_get_post' ) ) {
208
+ ?>
209
+ <tr>
210
+ <th scope="row">
211
+ <label for='relevanssi_wpml_only_current'><?php esc_html_e( 'WPML', 'relevanssi' ); ?></label>
212
+ </th>
213
+ <td>
214
+ <fieldset>
215
+ <legend class="screen-reader-text"><?php esc_html_e( 'Limit results to current language.', 'relevanssi' ); ?></legend>
216
+ <label for='relevanssi_wpml_only_current'>
217
+ <input type='checkbox' name='relevanssi_wpml_only_current' id='relevanssi_wpml_only_current' <?php echo esc_html( $wpml_only_current ); ?> />
218
+ <?php esc_html_e( 'Limit results to current language.', 'relevanssi' ); ?>
219
+ </label>
220
+ </fieldset>
221
+ <p class="description"><?php esc_html_e( 'Enabling this option will restrict the results to the currently active language. If the option is disabled, results will include posts in all languages.', 'relevanssi' ); ?></p>
222
+ </td>
223
+ </tr>
224
+ <?php } // WPML. ?>
225
+ <?php if ( function_exists( 'pll_get_post' ) ) { ?>
226
+ <tr>
227
+ <th scope="row">
228
+ <label for='relevanssi_polylang_all_languages'><?php esc_html_e( 'Polylang', 'relevanssi' ); ?></label>
229
+ </th>
230
+ <td>
231
+ <fieldset>
232
+ <legend class="screen-reader-text"><?php esc_html_e( 'Allow results from all languages.', 'relevanssi' ); ?></legend>
233
+ <label for='relevanssi_polylang_all_languages'>
234
+ <input type='checkbox' name='relevanssi_polylang_all_languages' id='relevanssi_polylang_all_languages' <?php echo esc_html( $polylang_allow_all ); ?> />
235
+ <?php esc_html_e( 'Allow results from all languages.', 'relevanssi' ); ?>
236
+ </label>
237
+ </fieldset>
238
+ <p class="description"><?php esc_html_e( 'By default Polylang restricts the search to the current language. Enabling this option will lift this restriction.', 'relevanssi' ); ?></p>
239
+ </td>
240
+ </tr>
241
+ <?php } // Polylang. ?>
242
+ <tr>
243
+ <th scope="row">
244
+ <label for='relevanssi_admin_search'><?php esc_html_e( 'Admin search', 'relevanssi' ); ?></label>
245
+ </th>
246
+ <td>
247
+ <fieldset>
248
+ <legend class="screen-reader-text"><?php esc_html_e( 'Use Relevanssi for admin searches.', 'relevanssi' ); ?></legend>
249
+ <label for='relevanssi_admin_search'>
250
+ <input type='checkbox' name='relevanssi_admin_search' id='relevanssi_admin_search' <?php echo esc_html( $admin_search ); ?> />
251
+ <?php esc_html_e( 'Use Relevanssi for admin searches.', 'relevanssi' ); ?>
252
+ </label>
253
+ </fieldset>
254
+ <p class="description"><?php esc_html_e( "If checked, Relevanssi will be used for searches in the admin interface. The page search doesn't use Relevanssi, because WordPress works like that.", 'relevanssi' ); ?></p>
255
+ </td>
256
+ </tr>
257
+ <tr>
258
+ <th scope="row">
259
+ <?php // Translators: %s is 'exclude_from_search'. ?>
260
+ <label for='relevanssi_respect_exclude'><?php printf( esc_html__( 'Respect %s', 'relevanssi' ), 'exclude_from_search' ); ?></label>
261
+ </th>
262
+ <td>
263
+ <fieldset>
264
+ <legend class="screen-reader-text"><?php esc_html_e( 'Respect exclude_from_search for custom post types', 'relevanssi' ); ?></legend>
265
+ <label for='relevanssi_respect_exclude'>
266
+ <input type='checkbox' name='relevanssi_respect_exclude' id='relevanssi_respect_exclude' <?php echo esc_html( $respect_exclude ); ?> />
267
+ <?php // Translators: %s is 'exclude_from_search'. ?>
268
+ <?php printf( esc_html__( 'Respect %s for custom post types', 'relevanssi' ), '<code>exclude_from_search</code>' ); ?>
269
+ </label>
270
+ <p class="description"><?php esc_html_e( "If checked, Relevanssi won't display posts of custom post types that have 'exclude_from_search' set to true.", 'relevanssi' ); ?></p>
271
+ <?php
272
+ if ( ! empty( $respect_exclude ) ) {
273
+ $pt_1 = get_post_types( array( 'exclude_from_search' => '1' ) );
274
+ $pt_2 = get_post_types( array( 'exclude_from_search' => true ) );
275
+
276
+ $private_types = array_merge( $pt_1, $pt_2 );
277
+ $problem_post_types = array_intersect( $index_post_types, $private_types );
278
+ if ( ! empty( $problem_post_types ) ) {
279
+ ?>
280
+ <p class="description important">
281
+ <?php
282
+ esc_html_e( "You probably should uncheck this option, because you've set Relevanssi to index the following non-public post types:", 'relevanssi' );
283
+ echo ' ' . esc_html( implode( ', ', $problem_post_types ) );
284
+ ?>
285
+ </p>
286
+ <?php
287
+ }
288
+ }
289
+ ?>
290
+ </fieldset>
291
+ </td>
292
+ </tr>
293
+ <tr>
294
+ <th scope="row">
295
+ <label for='relevanssi_throttle'><?php esc_html_e( 'Throttle searches', 'relevanssi' ); ?></label>
296
+ </th>
297
+ <td id="throttlesearches">
298
+ <div id="throttle_disabled"
299
+ <?php
300
+ if ( ! $orderby_date ) {
301
+ echo "class='screen-reader-text'";
302
+ }
303
+ ?>
304
+ >
305
+ <p class="description"><?php esc_html_e( 'Throttling the search does not work when sorting the posts by date.', 'relevanssi' ); ?></p>
306
+ </div>
307
+ <div id="throttle_enabled"
308
+ <?php
309
+ if ( ! $orderby_relevance ) {
310
+ echo "class='screen-reader-text'";
311
+ }
312
+ ?>
313
+ >
314
+ <fieldset>
315
+ <legend class="screen-reader-text"><?php esc_html_e( 'Throttle searches.', 'relevanssi' ); ?></legend>
316
+ <label for='relevanssi_throttle'>
317
+ <input type='checkbox' name='relevanssi_throttle' id='relevanssi_throttle' <?php echo esc_html( $throttle ); ?> />
318
+ <?php esc_html_e( 'Throttle searches.', 'relevanssi' ); ?>
319
+ </label>
320
+ </fieldset>
321
+ <?php if ( $docs_count < 1000 ) { ?>
322
+ <p class="description important"><?php esc_html_e( "Your database is so small that you don't need to enable this.", 'relevanssi' ); ?></p>
323
+ <?php } ?>
324
+ <p class="description"><?php esc_html_e( 'If this option is checked, Relevanssi will limit search results to at most 500 results per term. This will improve performance, but may cause some relevant documents to go unfound. See Help for more details.', 'relevanssi' ); ?></p>
325
+ </div>
326
+ </td>
327
+ </tr>
328
+ <tr>
329
+ <th scope="row">
330
+ <label for='relevanssi_cat'><?php esc_html_e( 'Category restriction', 'relevanssi' ); ?></label>
331
+ </th>
332
+ <td>
333
+ <div class="categorydiv" style="max-width: 400px">
334
+ <div class="tabs-panel">
335
+ <ul id="categorychecklist">
336
+ <?php
337
+ $selected_cats = explode( ',', $cat );
338
+ $walker = get_relevanssi_taxonomy_walker();
339
+ $walker->name = 'relevanssi_cat';
340
+ wp_terms_checklist( 0, array(
341
+ 'taxonomy' => 'category',
342
+ 'selected_cats' => $selected_cats,
343
+ 'walker' => $walker,
344
+ ));
345
+ ?>
346
+ </ul>
347
+ <input type="hidden" name="relevanssi_cat_active" value="1" />
348
+ </div>
349
+ </div>
350
+ <p class="description"><?php esc_html_e( 'You can restrict search results to a category for all searches. For restricting on a per-search basis and more options (eg. tag restrictions), see Help.', 'relevanssi' ); ?></p>
351
+ </td>
352
+ </tr>
353
+ <tr>
354
+ <th scope="row">
355
+ <label for='relevanssi_excat'><?php esc_html_e( 'Category exclusion', 'relevanssi' ); ?></label>
356
+ </th>
357
+ <td>
358
+ <div class="categorydiv" style="max-width: 400px">
359
+ <div class="tabs-panel">
360
+ <ul id="categorychecklist">
361
+ <?php
362
+ $selected_cats = explode( ',', $excat );
363
+ $walker = get_relevanssi_taxonomy_walker();
364
+ $walker->name = 'relevanssi_excat';
365
+ wp_terms_checklist( 0, array(
366
+ 'taxonomy' => 'category',
367
+ 'selected_cats' => $selected_cats,
368
+ 'walker' => $walker,
369
+ ));
370
+ ?>
371
+ </ul>
372
+ <input type="hidden" name="relevanssi_excat_active" value="1" />
373
+ </div>
374
+ </div>
375
+ <p class="description"><?php esc_html_e( 'Posts in these categories are not included in search results. To exclude the posts completely from the index, see Help.', 'relevanssi' ); ?></p>
376
+ </td>
377
+ </tr>
378
+ <tr>
379
+ <th scope="row">
380
+ <label for='relevanssi_expst'><?php esc_html_e( 'Post exclusion', 'relevanssi' ); ?>
381
+ </th>
382
+ <td>
383
+ <input type='text' name='relevanssi_expst' id='relevanssi_expst' size='60' value='<?php echo esc_attr( $exclude_posts ); ?>' />
384
+ <p class="description"><?php esc_html_e( "Enter a comma-separated list of post or page ID's to exclude those pages from the search results.", 'relevanssi' ); ?></p>
385
+ <?php if ( RELEVANSSI_PREMIUM ) { ?>
386
+ <p class="description"><?php esc_html_e( "With Relevanssi Premium, it's better to use the check box on post edit pages. That will remove the posts completely from the index, and will work with multisite searches unlike this setting.", 'relevanssi' ); ?></p>
387
+ <?php } ?>
388
+ </td>
389
+ </tr>
390
+ <?php
391
+ if ( function_exists( 'relevanssi_form_searchblogs_setting' ) ) {
392
+ relevanssi_form_searchblogs_setting();
393
+ }
394
+ ?>
395
+ </table>
396
+
397
+ <?php
398
+ }
lib/uninstall.php CHANGED
@@ -75,7 +75,6 @@ function relevanssi_uninstall_free() {
75
  delete_option( 'relevanssi_fuzzy' );
76
  delete_option( 'relevanssi_hide_branding' );
77
  delete_option( 'relevanssi_highlight_comments' );
78
- delete_option( 'relevanssi_highlight_docs_external' );
79
  delete_option( 'relevanssi_highlight_docs' );
80
  delete_option( 'relevanssi_highlight' );
81
  delete_option( 'relevanssi_hilite_title' );
@@ -126,6 +125,7 @@ function relevanssi_uninstall_free() {
126
  delete_option( 'relevanssi_include_tags' );
127
  delete_option( 'relevanssi_custom_taxonomies' );
128
  delete_option( 'relevanssi_taxonomies_to_index' );
 
129
 
130
  relevanssi_drop_database_tables();
131
  }
75
  delete_option( 'relevanssi_fuzzy' );
76
  delete_option( 'relevanssi_hide_branding' );
77
  delete_option( 'relevanssi_highlight_comments' );
 
78
  delete_option( 'relevanssi_highlight_docs' );
79
  delete_option( 'relevanssi_highlight' );
80
  delete_option( 'relevanssi_hilite_title' );
125
  delete_option( 'relevanssi_include_tags' );
126
  delete_option( 'relevanssi_custom_taxonomies' );
127
  delete_option( 'relevanssi_taxonomies_to_index' );
128
+ delete_option( 'relevanssi_highlight_docs_external' );
129
 
130
  relevanssi_drop_database_tables();
131
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: search, relevance, better search
5
  Requires at least: 4.0
6
  Tested up to: 5.0
7
  Requires PHP: 5.6
8
- Stable tag: 4.0.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -28,6 +28,7 @@ Do note that using Relevanssi may require large amounts (hundreds of megabytes)
28
  * Highlight search terms in the documents when user clicks through search results.
29
  * Search comments, tags, categories and custom fields.
30
  * Multisite friendly.
 
31
 
32
  = Advanced features =
33
  * Adjust the weighting for titles, tags and comments.
@@ -129,6 +130,13 @@ Each document database is full of useless words. All the little words that appea
129
 
130
  == Changelog ==
131
 
 
 
 
 
 
 
 
132
  = 4.0.7 =
133
  * Recent post bonus is now applied to searches.
134
  * Exact term setting can now be disabled.
@@ -153,6 +161,9 @@ Each document database is full of useless words. All the little words that appea
153
 
154
  == Upgrade notice ==
155
 
 
 
 
156
  = 4.0.7 =
157
  * Small bug fixes.
158
 
5
  Requires at least: 4.0
6
  Tested up to: 5.0
7
  Requires PHP: 5.6
8
+ Stable tag: 4.0.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
28
  * Highlight search terms in the documents when user clicks through search results.
29
  * Search comments, tags, categories and custom fields.
30
  * Multisite friendly.
31
+ * bbPress support.
32
 
33
  = Advanced features =
34
  * Adjust the weighting for titles, tags and comments.
130
 
131
  == Changelog ==
132
 
133
+ = 4.0.8 =
134
+ * Fixed cases where Relevanssi added an ellipsis even if the excerpt was from the start of the post.
135
+ * Highlighting now works with numeric search strings.
136
+ * Improved highlighting for accented words. Thanks to Paul Ryan.
137
+ * A surplus comma at the end of post exclusion setting won't break the search anymore.
138
+ * Fixed instructions for adjusting the throttle limit.
139
+
140
  = 4.0.7 =
141
  * Recent post bonus is now applied to searches.
142
  * Exact term setting can now be disabled.
161
 
162
  == Upgrade notice ==
163
 
164
+ = 4.0.8 =
165
+ * Improvements to highlighting and excerpts.
166
+
167
  = 4.0.7 =
168
  * Small bug fixes.
169
 
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.0.7
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
@@ -67,4 +67,4 @@ require_once 'lib/search.php';
67
  require_once 'lib/excerpts-highlights.php';
68
  require_once 'lib/shortcodes.php';
69
  require_once 'lib/common.php';
70
- require_once 'lib/admin-ajax.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.0.8
17
  * Author: Mikko Saari
18
  * Author URI: http://www.mikkosaari.fi/
19
  * Text Domain: relevanssi
67
  require_once 'lib/excerpts-highlights.php';
68
  require_once 'lib/shortcodes.php';
69
  require_once 'lib/common.php';
70
+ require_once 'lib/admin-ajax.php';