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