plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 15:33:26 -04:00
parent 3751a5a1a6
commit e4e274a9a7
2674 changed files with 0 additions and 507851 deletions

View File

@@ -1,24 +0,0 @@
<?php
/**
* /lib/tabs/attachments-tab.php
*
* Prints out the Attachments tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the attachments tab in Relevanssi settings.
*/
function relevanssi_attachments_tab() {
?>
<h2><?php esc_html_e( 'Indexing attachment content', 'relevanssi' ); ?></h2>
<p><?php esc_html_e( 'With Relevanssi Premium, you can index the text contents of attachments (PDFs, Word documents, Open Office documents and many other types). The contents of the attachments are processed on an external service, which makes the feature reliable and light on your own server performance.', 'relevanssi' ); ?></p>
<?php // Translators: %1$s starts the link, %2$s closes it. ?>
<p><?php printf( esc_html__( 'In order to access this and many other delightful Premium features, %1$sbuy Relevanssi Premium here%2$s.', 'relevanssi' ), '<a href="https://www.relevanssi.com/buy-premium/">', '</a>' ); ?></p>
<?php
}

View File

@@ -1,166 +0,0 @@
<?php
/**
* /lib/tabs/debugging-tab.php
*
* Prints out the Debugging tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the debugging tab in Relevanssi settings.
*/
function relevanssi_debugging_tab() {
$how_relevanssi_sees = '';
$db_post_view = '';
$current_post_id = 0;
$current_db_post_id = 0;
$selected = 'post';
if ( isset( $_REQUEST['post_id'] ) ) {
wp_verify_nonce( '_relevanssi_nonce', 'relevanssi_how_relevanssi_sees' );
$type = 'post';
if ( isset( $_REQUEST['type'] ) ) {
if ( 'term' === $_REQUEST['type'] ) {
$type = 'term';
$selected = 'term';
}
if ( 'user' === $_REQUEST['type'] ) {
$type = 'user';
$selected = 'user';
}
}
if ( intval( $_REQUEST['post_id'] ) > 0 ) {
$current_post_id = intval( $_REQUEST['post_id'] );
$how_relevanssi_sees = relevanssi_generate_how_relevanssi_sees(
intval( $current_post_id ),
true,
$type
);
}
}
if ( isset( $_REQUEST['db_post_id'] ) ) {
wp_verify_nonce( '_relevanssi_nonce', 'relevanssi_how_relevanssi_sees' );
if ( intval( $_REQUEST['db_post_id'] ) > 0 ) {
$current_db_post_id = intval( $_REQUEST['db_post_id'] );
$db_post_view = relevanssi_generate_db_post_view( $current_db_post_id );
}
}
wp_nonce_field( 'relevanssi_how_relevanssi_sees', '_relevanssi_nonce', true, true );
?>
<h2><?php esc_html_e( 'Debugging', 'relevanssi' ); ?></h2>
<p><?php esc_html_e( 'In order to figure out problems with indexing posts, you can test how Relevanssi sees the post by entering the post ID number in the field below.', 'relevanssi' ); ?></p>
<?php
if ( RELEVANSSI_PREMIUM ) {
?>
<p><?php esc_html_e( 'You can also check user profiles and taxonomy terms by choosing the type from the dropdown.', 'relevanssi' ); ?></p>
<?php
}
if ( ! RELEVANSSI_PREMIUM ) {
// Translators: %1$s starts the link, %2$s closes it.
printf( '<p>' . esc_html__( 'In Relevanssi Premium, you can find this feature for each post on the post edit page. %1$sBuy Relevanssi Premium here%2$s.', 'relevanssi' ) . '</p>', '<a href="https://www.relevanssi.com/buy-premium/">', '</a>' );
}
?>
<p><label for="post_id"><?php esc_html_e( 'The ID', 'relevanssi' ); ?></label>:
<input type="text" name="post_id" id="post_id"
<?php
if ( $current_post_id > 0 ) {
echo 'value="' . esc_attr( $current_post_id ) . '"';
}
?>
/>
<?php
if ( RELEVANSSI_PREMIUM ) {
?>
<select name="type">
<option value="post"
<?php if ( 'post' === $selected ) { ?>
selected="selected"
<?php } ?>><?php esc_html_e( 'Post', 'relevanssi' ); ?></option>
<option value="term"
<?php if ( 'term' === $selected ) { ?>
selected="selected"
<?php } ?>><?php esc_html_e( 'Taxonomy term', 'relevanssi' ); ?></option>
<option value="user"
<?php if ( 'user' === $selected ) { ?>
selected="selected"
<?php } ?>><?php esc_html_e( 'User', 'relevanssi' ); ?></option>
</select>
<?php
}
?>
</p>
<p>
<input
type='submit' name='submit'
value='<?php esc_attr_e( 'Check the post', 'relevanssi' ); ?>'
class='button button-primary' />
</p>
<?php echo $how_relevanssi_sees; // phpcs:ignore WordPress.Security.EscapeOutput ?>
<h2><?php esc_html_e( 'What does the post look like in the database?', 'relevanssi' ); ?></h2>
<p><?php esc_html_e( "This feature will show you how the post looks like in the database. It can sometimes be very helpful for debugging why a post isn't indexed the way you expect it to be.", 'relevanssi' ); ?></p>
<p><label for="db_post_id"><?php esc_html_e( 'The ID', 'relevanssi' ); ?></label>:
<input type="text" name="db_post_id" id="db_post_id"
<?php
if ( $current_db_post_id > 0 ) {
echo 'value="' . esc_attr( $current_db_post_id ) . '"';
}
?>
/>
</p>
<p>
<input
type='submit' name='submit'
value='<?php esc_attr_e( 'Check the post', 'relevanssi' ); ?>'
class='button button-primary' />
</p>
<?php echo $db_post_view; // phpcs:ignore WordPress.Security.EscapeOutput ?>
<h2><?php esc_html_e( 'Debugging information', 'relevanssi' ); ?></h2>
<?php
global $wpdb;
$max_allowed_packet = $wpdb->get_var( 'SELECT @@global.max_allowed_packet' );
$max_allowed_packet = round( $max_allowed_packet / 1024 / 1024, 2 );
echo '<p>max_allowed_packet: ' . $max_allowed_packet . 'M</p>'; // phpcs:ignore WordPress.Security.EscapeOutput
$indexing_query = relevanssi_generate_indexing_query(
relevanssi_valid_status_array(),
false,
relevanssi_post_type_restriction(),
'LIMIT 0'
);
?>
<p><?php esc_html_e( 'Indexing query', 'relevanssi' ); ?>:</p>
<?php
echo '<code>' . $indexing_query . '</code>'; // phpcs:ignore WordPress.Security.EscapeOutput
?>
<?php do_action( 'relevanssi_debugging_tab' ); ?>
<h2><?php esc_html_e( 'Debugging mode', 'relevanssi' ); ?></h2>
<?php
$enable_debugging_mode = relevanssi_check( get_option( 'relevanssi_debugging_mode' ) );
?>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Enable the debugging mode.', 'relevanssi' ); ?></legend>
<label for='relevanssi_debugging_mode'>
<input type='checkbox' name='relevanssi_debugging_mode' id='relevanssi_debugging_mode' <?php echo esc_html( $enable_debugging_mode ); ?> />
<?php esc_html_e( 'Enable the debugging mode.', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( "Relevanssi support may ask you to enable the debugging mode. When you check this box, it's possible to see debugging information from the front-end.", 'relevanssi' ); ?></p>
</fieldset>
<?php
}

View File

@@ -1,457 +0,0 @@
<?php
/**
* /lib/tabs/excerpts-tab.php
*
* Prints out the Excerpts tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the excerpts tab in Relevanssi settings.
*/
function relevanssi_excerpts_tab() {
$excerpts = get_option( 'relevanssi_excerpts' );
$excerpt_length = get_option( 'relevanssi_excerpt_length' );
$excerpt_type = get_option( 'relevanssi_excerpt_type' );
$excerpt_allowable_tags = get_option( 'relevanssi_excerpt_allowable_tags' );
$excerpt_custom_fields = get_option( 'relevanssi_excerpt_custom_fields' );
$excerpt_specific_fields = get_option( 'relevanssi_excerpt_specific_fields' );
$highlight = get_option( 'relevanssi_highlight' );
$txt_col = get_option( 'relevanssi_txt_col' );
$bg_col = get_option( 'relevanssi_bg_col' );
$css = get_option( 'relevanssi_css' );
$class = get_option( 'relevanssi_class' );
$highlight_title = get_option( 'relevanssi_hilite_title' );
$highlight_docs = get_option( 'relevanssi_highlight_docs' );
$highlight_coms = get_option( 'relevanssi_highlight_comments' );
$show_matches = get_option( 'relevanssi_show_matches' );
$show_matches_text = get_option( 'relevanssi_show_matches_text' );
$index_fields = get_option( 'relevanssi_index_fields' );
$expand_highlights = get_option( 'relevanssi_expand_highlights' );
if ( '#' !== substr( $txt_col, 0, 1 ) ) {
$txt_col = '#' . $txt_col;
}
$txt_col = relevanssi_sanitize_hex_color( $txt_col );
if ( '#' !== substr( $bg_col, 0, 1 ) ) {
$bg_col = '#' . $bg_col;
}
$bg_col = relevanssi_sanitize_hex_color( $bg_col );
$show_matches_text = stripslashes( $show_matches_text );
$excerpts = relevanssi_check( $excerpts );
$excerpt_custom_fields = relevanssi_check( $excerpt_custom_fields );
$excerpt_specific_fields = relevanssi_check( $excerpt_specific_fields );
$highlight_title = relevanssi_check( $highlight_title );
$highlight_docs = relevanssi_check( $highlight_docs );
$highlight_coms = relevanssi_check( $highlight_coms );
$show_matches = relevanssi_check( $show_matches );
$expand_highlights = relevanssi_check( $expand_highlights );
$excerpt_chars = relevanssi_select( $excerpt_type, 'chars' );
$excerpt_words = relevanssi_select( $excerpt_type, 'words' );
$highlight_none = relevanssi_select( $highlight, 'no' );
$highlight_mark = relevanssi_select( $highlight, 'mark' );
$highlight_em = relevanssi_select( $highlight, 'em' );
$highlight_strong = relevanssi_select( $highlight, 'strong' );
$highlight_col = relevanssi_select( $highlight, 'col' );
$highlight_bgcol = relevanssi_select( $highlight, 'bgcol' );
$highlight_style = relevanssi_select( $highlight, 'css' );
$highlight_class = relevanssi_select( $highlight, 'class' );
$txt_col_display = 'screen-reader-text';
$bg_col_display = 'screen-reader-text';
$css_display = 'screen-reader-text';
$class_display = 'screen-reader-text';
if ( 'col' === $highlight ) {
$txt_col_display = '';
}
if ( 'bgcol' === $highlight ) {
$bg_col_display = '';
}
if ( 'css' === $highlight ) {
$css_display = '';
}
if ( 'class' === $highlight ) {
$class_display = '';
}
?>
<h2 id="excerpts"><?php esc_html_e( 'Custom excerpts/snippets', 'relevanssi' ); ?></h2>
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<?php esc_html_e( 'Custom search result snippets', 'relevanssi' ); ?>
</th>
<td>
<label >
<input type='checkbox' name='relevanssi_excerpts' id='relevanssi_excerpts' <?php echo esc_html( $excerpts ); ?> />
<?php esc_html_e( 'Create custom search result snippets', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'Only enable this if you actually use the custom excerpts.', 'relevanssi' ); ?></p>
<?php
$theme = wp_get_theme();
$template = $theme->get( 'Template' );
if ( 'divi' === strtolower( $template ) ) :
?>
<?php // Translators: %1$s opens the link, %2$s closes it. ?>
<p class="important"><?php printf( esc_html__( 'Looks like you are using Divi. In order to use custom excerpts with Divi, you need to make some changes to your templates. %1$sSee instructions here%2$s.', 'relevanssi' ), '<a href="https://www.relevanssi.com/knowledge-base/divi-page-builder-and-cleaner-excerpts/">', '</a>' ); ?></p>
<?php endif; ?>
</td>
</tr>
<tr id="tr_excerpt_length"
<?php
if ( empty( $excerpts ) ) {
echo "class='relevanssi_disabled'";
}
?>
>
<th scope="row">
<label for='relevanssi_excerpt_length'><?php esc_html_e( 'Length of the snippet', 'relevanssi' ); ?></label>
</th>
<td>
<input type='text' name='relevanssi_excerpt_length' id='relevanssi_excerpt_length' size='4' value='<?php echo esc_attr( $excerpt_length ); ?>'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<label for="relevanssi_excerpt_type" class="screen-reader-text"><?php esc_html_e( 'Excerpt length type', 'relevanssi' ); ?></label>
<select name='relevanssi_excerpt_type' id='relevanssi_excerpt_type'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
>
<option value='chars' <?php echo esc_html( $excerpt_chars ); ?>><?php esc_html_e( 'characters', 'relevanssi' ); ?></option>
<option value='words' <?php echo esc_html( $excerpt_words ); ?>><?php esc_html_e( 'words', 'relevanssi' ); ?></option>
</select>
<p class="description"><?php esc_html_e( "Using words is much faster than characters. Don't use characters, unless you have a really good reason and your posts are short.", 'relevanssi' ); ?></p>
</td>
</tr>
<?php
if ( function_exists( 'relevanssi_form_max_excerpts' ) ) {
relevanssi_form_max_excerpts( $excerpts );
}
?>
<tr id="tr_excerpt_allowable_tags"
<?php
if ( empty( $excerpts ) ) {
echo "class='relevanssi_disabled'";
}
?>
>
<th scope="row">
<label for='relevanssi_excerpt_allowable_tags'><?php esc_html_e( 'Allowable tags in excerpts', 'relevanssi' ); ?></label>
</th>
<td>
<input type='text' name='relevanssi_excerpt_allowable_tags' id='relevanssi_excerpt_allowable_tags' size='60' value='<?php echo esc_attr( $excerpt_allowable_tags ); ?>'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<p class="description"><?php esc_html_e( 'List all tags you want to allow in excerpts. For example: &lt;p&gt;&lt;a&gt;&lt;strong&gt;.', 'relevanssi' ); ?></p>
</td>
</tr>
<tr id="tr_excerpt_custom_fields"
<?php
if ( empty( $excerpts ) ) {
echo "class='relevanssi_disabled'";
}
?>
>
<th scope="row">
<?php esc_html_e( 'Use custom fields for excerpts', 'relevanssi' ); ?>
</th>
<td>
<label>
<input type='checkbox' name='relevanssi_excerpt_custom_fields' id='relevanssi_excerpt_custom_fields' <?php echo esc_html( $excerpt_custom_fields ); ?>
<?php
if ( empty( $excerpts ) || empty( $index_fields ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php esc_html_e( 'Use custom field content for building excerpts', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'Use the custom fields setting for indexing for excerpt-making as well. Enabling this option will show custom field content in Relevanssi-generated excerpts.', 'relevanssi' ); ?>
<?php
if ( RELEVANSSI_PREMIUM ) {
esc_html_e( 'Enable this option to use PDF content for excerpts.', 'relevanssi' );
}
?>
</p>
<p><label>
<input type='checkbox' name='relevanssi_excerpt_specific_fields' id='relevanssi_excerpt_specific_fields' <?php echo esc_html( $excerpt_specific_fields ); ?>
<?php
if ( empty( $excerpts ) || empty( $index_fields ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php esc_html_e( 'Create custom field specific excerpts', 'relevanssi' ); ?>
</label></p>
<p class="description"><?php esc_html_e( 'The default method of adding custom field content to excerpts cannot tell which custom fields is the source of the excerpts. Using custom field specific excerpts is slower, but you can tell which custom field was the source of the excerpt.', 'relevanssi' ); ?>
<p class="description"><?php esc_html_e( 'Current custom field setting', 'relevanssi' ); ?>:
<?php
if ( 'visible' === $index_fields ) {
esc_html_e( 'all visible custom fields', 'relevanssi' );
} elseif ( 'all' === $index_fields ) {
esc_html_e( 'all custom fields', 'relevanssi' );
} elseif ( ! empty( $index_fields ) ) {
printf( '<code>%s</code>', esc_html( $index_fields ) );
} elseif ( RELEVANSSI_PREMIUM ) {
esc_html_e( 'Just PDF content', 'relevanssi' );
} else {
esc_html_e( 'None selected', 'relevanssi' );
}
?>
</p>
</td>
</tr>
<?php if ( 'visible' === $index_fields || 'all' === $index_fields ) : ?>
<tr>
<th scope="row">
<?php esc_html_e( 'List custom fields', 'relevanssi' ); ?>
</th>
<td>
<button type="button" class="button button-primary" id="list_custom_fields"><?php esc_html_e( 'List custom fields', 'relevanssi' ); ?></button>
<p class="description"><?php esc_html_e( 'Click the button above to see the list of indexed custom fields.', 'relevanssi' ); ?></p>
<div id="relevanssi_custom_field_list"></div>
<?php if ( class_exists( 'acf', false ) ) : ?>
<p class="description"><?php esc_html_e( 'Fields excluded from ACF settings and with filter functions are included here.', 'relevanssi' ); ?></p>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
</table>
<h2><?php esc_html_e( 'Search hit highlighting', 'relevanssi' ); ?></h2>
<table id="relevanssi_highlighting" class="form-table
<?php
if ( empty( $excerpts ) ) {
echo 'relevanssi_disabled';
}
?>
" role="presentation">
<tr>
<th scope="row">
<label for='relevanssi_highlight'><?php esc_html_e( 'Highlight type', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_highlight' id='relevanssi_highlight'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
>
<option value='no' <?php echo esc_html( $highlight_none ); ?>><?php esc_html_e( 'No highlighting', 'relevanssi' ); ?></option>
<option value='mark' <?php echo esc_html( $highlight_mark ); ?>>&lt;mark&gt;</option>
<option value='em' <?php echo esc_html( $highlight_em ); ?>>&lt;em&gt;</option>
<option value='strong' <?php echo esc_html( $highlight_strong ); ?>>&lt;strong&gt;</option>
<option value='col' <?php echo esc_html( $highlight_col ); ?>><?php esc_html_e( 'Text color', 'relevanssi' ); ?></option>
<option value='bgcol' <?php echo esc_html( $highlight_bgcol ); ?>><?php esc_html_e( 'Background color', 'relevanssi' ); ?></option>
<option value='css' <?php echo esc_html( $highlight_style ); ?>><?php esc_html_e( 'CSS Style', 'relevanssi' ); ?></option>
<option value='class' <?php echo esc_html( $highlight_class ); ?>><?php esc_html_e( 'CSS Class', 'relevanssi' ); ?></option>
</select>
<p class="description"><?php esc_html_e( 'Requires custom snippets to work.', 'relevanssi' ); ?></p>
</td>
</tr>
<tr id="tr_relevanssi_txt_col" class='<?php echo esc_attr( $txt_col_display ); ?>'>
<th scope="row">
<?php esc_html_e( 'Text color', 'relevanssi' ); ?>
</th>
<td>
<input type='text' name='relevanssi_txt_col' id='relevanssi_txt_col' size='7' class="color-field" data-default-color="#ff0000" value='<?php echo esc_attr( $txt_col ); ?>'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
</td>
</tr>
<tr id="tr_relevanssi_bg_col" class=' <?php echo esc_attr( $bg_col_display ); ?>'>
<th scope="row">
<?php esc_html_e( 'Background color', 'relevanssi' ); ?>
</th>
<td>
<input type='text' name='relevanssi_bg_col' id='relevanssi_bg_col' size='7' class="color-field" data-default-color="#ffaf75" value='<?php echo esc_attr( $bg_col ); ?>'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
</td>
</tr>
<tr id="tr_relevanssi_css" class=' <?php echo esc_attr( $css_display ); ?>'>
<th scope="row">
<label for='relevanssi_css'><?php esc_html_e( 'CSS style for highlights', 'relevanssi' ); ?></label>
</th>
<td>
<input type='text' name='relevanssi_css' id='relevanssi_css' size='60' value='<?php echo esc_attr( $css ); ?>'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php // Translators: %s is a <span> tag. ?>
<p class="description"><?php printf( esc_html__( 'The highlights will be wrapped in a %s with this CSS in the style parameter.', 'relevanssi' ), '&lt;span&gt;' ); ?></p>
</td>
</tr>
<tr id="tr_relevanssi_class" class=' <?php echo esc_attr( $class_display ); ?>'>
<th scope="row">
<label for='relevanssi_class'><?php esc_html_e( 'CSS class for highlights', 'relevanssi' ); ?></label>
</th>
<td>
<input type='text' name='relevanssi_class' id='relevanssi_class' size='60' value='<?php echo esc_attr( $class ); ?>'
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php // Translators: %s is a <span> tag. ?>
<p class="description"><?php printf( esc_html__( 'The highlights will be wrapped in a %s with this class.', 'relevanssi' ), '&lt;span&gt;' ); ?></p>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Highlight in titles', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_hilite_title'>
<input type='checkbox' name='relevanssi_hilite_title' id='relevanssi_hilite_title' <?php echo esc_html( $highlight_title ); ?>
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php esc_html_e( 'Highlight query terms in titles', 'relevanssi' ); ?>
</label>
<?php // Translators: %1$s is 'the_title()', %2$s is 'relevanssi_the_title()'. ?>
<p class="description"><?php printf( esc_html__( 'Highlights in titles require changes to the search results template. You need to replace %1$s in the search results template with %2$s. For more information, see the contextual help.', 'relevanssi' ), '<code>the_title()</code>', '<code>relevanssi_the_title()</code>' ); ?></p>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Highlight in documents', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_highlight_docs'>
<input type='checkbox' name='relevanssi_highlight_docs' id='relevanssi_highlight_docs' <?php echo esc_html( $highlight_docs ); ?>
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php esc_html_e( 'Highlight query terms in documents', 'relevanssi' ); ?>
</label>
<?php // Translators: %s is 'highlight'. ?>
<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>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Highlight in comments', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_highlight_comments'>
<input type='checkbox' name='relevanssi_highlight_comments' id='relevanssi_highlight_comments' <?php echo esc_html( $highlight_coms ); ?>
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php esc_html_e( 'Highlight query terms in comments', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'Highlights hits in comments when user opens the post from search results.', 'relevanssi' ); ?></p>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Expand highlights', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_expand_highlights'>
<input type='checkbox' name='relevanssi_expand_highlights' id='relevanssi_expand_highlights' <?php echo esc_html( $expand_highlights ); ?>
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php esc_html_e( 'Expand highlights to cover full words', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'When a highlight matches part of the word, if this option is enabled, the highlight will be expanded to highlight the whole word.', 'relevanssi' ); ?></p>
</td>
</tr>
</table>
<h2><?php esc_html_e( 'Breakdown of search results', 'relevanssi' ); ?></h2>
<table id="relevanssi_breakdown" class="form-table
<?php
if ( empty( $excerpts ) ) {
echo 'relevanssi_disabled';
}
?>
" role="presentation">
<tr>
<th scope="row">
<?php esc_html_e( 'Breakdown of search hits in excerpts', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_show_matches'>
<input type='checkbox' name='relevanssi_show_matches' id='relevanssi_show_matches' <?php echo esc_html( $show_matches ); ?>
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
/>
<?php esc_html_e( 'Show the breakdown of search hits in the excerpts.', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'Requires custom snippets to work.', 'relevanssi' ); ?></p>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_show_matches_text'><?php esc_html_e( 'The breakdown format', 'relevanssi' ); ?></label>
</th>
<td>
<textarea name='relevanssi_show_matches_text' id='relevanssi_show_matches_text' cols="80" rows="4"
<?php
if ( empty( $excerpts ) ) {
echo "disabled='disabled'";
}
?>
><?php echo esc_attr( $show_matches_text ); ?></textarea>
<p class="description"><?php esc_html_e( 'Use %body%, %title%, %categories%, %tags%, %taxonomies%, %comments%, %customfields%, %author%, %excerpt% and %mysqlcolumns% to display the number of hits (in different parts of the post), %total% for total hits, %score% to display the document weight and %terms% to show how many hits each search term got.', 'relevanssi' ); /* phpcs:ignore WordPress.WP.I18n */ ?></p>
</td>
</tr>
</table>
<?php
}

View File

@@ -1,545 +0,0 @@
<?php
/**
* /lib/tabs/indexing-tab.php
*
* Prints out the Indexing tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the indexing tab in Relevanssi settings.
*
* @global $wpdb The WordPress database interface.
* @global $relevanssi_variables The global Relevanssi variables array.
*/
function relevanssi_indexing_tab() {
global $wpdb, $relevanssi_variables;
$index_post_types = get_option( 'relevanssi_index_post_types', array() );
$index_taxonomies_list = get_option( 'relevanssi_index_taxonomies_list' );
$index_comments = get_option( 'relevanssi_index_comments' );
$index_fields = get_option( 'relevanssi_index_fields' );
$index_author = get_option( 'relevanssi_index_author' );
$index_excerpt = get_option( 'relevanssi_index_excerpt' );
$index_image_files = get_option( 'relevanssi_index_image_files' );
$expand_shortcodes = get_option( 'relevanssi_expand_shortcodes' );
$punctuation = get_option( 'relevanssi_punctuation' );
$min_word_length = get_option( 'relevanssi_min_word_length' );
if ( empty( $index_post_types ) ) {
$index_post_types = array();
}
if ( empty( $index_taxonomies_list ) ) {
$index_taxonomies_list = array();
}
$expand_shortcodes = relevanssi_check( $expand_shortcodes );
$index_author = relevanssi_check( $index_author );
$index_excerpt = relevanssi_check( $index_excerpt );
$index_image_files = relevanssi_check( $index_image_files );
$index_comments_all = relevanssi_select( $index_comments, 'all' );
$index_comments_normal = relevanssi_select( $index_comments, 'normal' );
$index_comments_none = relevanssi_select( $index_comments, 'none' );
$fields_select_all = '';
$fields_select_none = '';
$fields_select_some = 'selected';
$fields_select_visible = '';
if ( empty( $index_fields ) ) {
$fields_select_none = 'selected';
$fields_select_some = '';
}
if ( 'all' === $index_fields ) {
$fields_select_all = 'selected';
$fields_select_some = '';
$index_fields = '';
}
if ( 'visible' === $index_fields ) {
$fields_select_visible = 'selected';
$fields_select_some = '';
$index_fields = '';
}
if ( ! isset( $punctuation['quotes'] ) ) {
$punctuation['quotes'] = 'replace';
}
if ( ! isset( $punctuation['decimals'] ) ) {
$punctuation['decimals'] = 'remove';
}
if ( ! isset( $punctuation['ampersands'] ) ) {
$punctuation['ampersands'] = 'replace';
}
if ( ! isset( $punctuation['hyphens'] ) ) {
$punctuation['hyphens'] = 'replace';
}
$punct_quotes_replace = relevanssi_select( $punctuation['quotes'], 'replace' );
$punct_quotes_remove = relevanssi_select( $punctuation['quotes'], 'remove' );
$punct_decimals_replace = relevanssi_select( $punctuation['decimals'], 'replace' );
$punct_decimals_remove = relevanssi_select( $punctuation['decimals'], 'remove' );
$punct_decimals_keep = relevanssi_select( $punctuation['decimals'], 'keep' );
$punct_ampersands_replace = relevanssi_select( $punctuation['ampersands'], 'replace' );
$punct_ampersands_remove = relevanssi_select( $punctuation['ampersands'], 'remove' );
$punct_ampersands_keep = relevanssi_select( $punctuation['ampersands'], 'keep' );
$punct_hyphens_replace = relevanssi_select( $punctuation['hyphens'], 'replace' );
$punct_hyphens_remove = relevanssi_select( $punctuation['hyphens'], 'remove' );
$punct_hyphens_keep = relevanssi_select( $punctuation['hyphens'], 'keep' );
$docs_count = get_option( 'relevanssi_doc_count', 0 );
$terms_count = get_option( 'relevanssi_terms_count', 0 );
$lowest_doc = $wpdb->get_var( 'SELECT doc FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc > 0 ORDER BY doc ASC LIMIT 1' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
if ( null === $lowest_doc ) {
// The database table is empty or doesn't exist.
$lowest_doc = 0;
relevanssi_create_database_tables( 0 );
}
if ( RELEVANSSI_PREMIUM ) {
$user_count = get_option( 'relevanssi_user_count', 0 );
$taxterm_count = get_option( 'relevanssi_taxterm_count', 0 );
}
$this_page = '?page=' . plugin_basename( $relevanssi_variables['file'] );
$update_url = wp_nonce_url( $this_page . '&tab=indexing&update_counts=1', 'update_counts' );
?>
<div id="indexing_tab">
<table class="form-table" role="presentation">
<tr>
<td scope="row">
<input type='submit' name='submit' value='<?php esc_attr_e( 'Save the options', 'relevanssi' ); ?>' class='button button-primary' /><br /><br />
<input type="button" id="build_index" name="index" value="<?php esc_attr_e( 'Build the index', 'relevanssi' ); ?>" class='button-primary' /><br /><br />
<input type="button" id="continue_indexing" name="continue" value="<?php esc_attr_e( 'Index unindexed posts', 'relevanssi' ); ?>" class='button-primary' />
</td>
<td>
<div id='indexing_button_instructions'>
<?php // Translators: %s is "Build the index". ?>
<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>
<?php // Translators: %s is "Build the index". ?>
<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>' ); ?>
<?php
if ( RELEVANSSI_PREMIUM ) {
esc_html_e( "This doesn't index any taxonomy terms or users.", 'relevanssi' );
}
?>
</p>
</div>
<div id='relevanssi-note' style='display: none'></div>
<div id='relevanssi-progress' class='rpi-progress'><div class="rpi-indicator"></div></div>
<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>
<label for="results" class="screen-reader-text"><?php esc_html_e( 'Results', 'relevanssi' ); ?></label><textarea id='results' rows='10' cols='80'></textarea>
<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>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'State of the index', 'relevanssi' ); ?></th>
<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' ) ); ?>
<?php if ( RELEVANSSI_PREMIUM ) : ?>
<br /><?php echo esc_html( $user_count ); ?> <?php echo esc_html( _n( 'user in the index.', 'users in the index.', $user_count, 'relevanssi' ) ); ?><br />
<?php echo esc_html( $taxterm_count ); ?> <?php echo esc_html( _n( 'taxonomy term in the index.', 'taxonomy terms in the index.', $taxterm_count, 'relevanssi' ) ); ?>
<?php endif; ?>
</p>
<p><?php echo esc_html( $terms_count ); ?> <?php echo esc_html( _n( 'term in the index.', 'terms in the index.', $terms_count, 'relevanssi' ) ); ?><br />
<?php echo esc_html( $lowest_doc ); ?> <?php esc_html_e( 'is the lowest post ID indexed.', 'relevanssi' ); ?></p>
<?php /* Translators: %1$s opens the a tag, %2$s closes it. */ ?>
<p class="description">(<?php printf( esc_html__( 'These values may be inaccurate. If you need exact values, %1$supdate the counts%2$s', 'relevanssi' ), '<a href="' . esc_attr( $update_url ) . '">', '</a>' ); ?>.)</p>
</td>
</tr>
</table>
<?php
if ( count( $index_post_types ) < 2 ) {
$index_users = get_option( 'relevanssi_index_users', 'off' );
$index_taxonomies = get_option( 'relevanssi_index_taxonomies', 'off' );
if ( 'off' === $index_users && 'off' === $index_taxonomies ) {
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' ) );
}
}
?>
<h2 id="indexing"><?php esc_html_e( 'Indexing options', 'relevanssi' ); ?></h2>
<p><?php esc_html_e( 'Any changes to the settings on this page require reindexing before they take effect.', 'relevanssi' ); ?></p>
<table class="form-table" role="presentation">
<tr>
<th scope="row"><?php esc_html_e( 'Post types', 'relevanssi' ); ?></th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Post types to index', 'relevanssi' ); ?></legend>
<table class="widefat" id="index_post_types_table">
<thead>
<tr>
<th><?php esc_html_e( 'Type', 'relevanssi' ); ?></th>
<th><?php esc_html_e( 'Index', 'relevanssi' ); ?></th>
<th><?php esc_html_e( 'Excluded from search?', 'relevanssi' ); ?></th>
</tr>
</thead>
<?php
$pt_1 = get_post_types( array( 'exclude_from_search' => '0' ) );
$pt_2 = get_post_types( array( 'exclude_from_search' => false ) );
$public_types = array_merge( $pt_1, $pt_2 );
$post_types = get_post_types();
foreach ( $post_types as $type ) {
if ( in_array( $type, relevanssi_get_forbidden_post_types(), true ) ) {
continue;
}
$checked = '';
if ( in_array( $type, $index_post_types, true ) ) {
$checked = 'checked="checked"';
}
// Translators: %s is the post type name.
$screen_reader_label = sprintf( __( 'Index post type %s', 'relevanssi' ), $type );
$label = $type;
$excluded_from_search = __( 'yes', 'relevanssi' );
// Translators: %s is the post type name.
$screen_reader_exclude = sprintf( __( 'Post type %s is excluded from search', 'relevanssi' ), $type );
if ( in_array( $type, $public_types, true ) ) {
$excluded_from_search = __( 'no', 'relevanssi' );
// Translators: %s is the post type name.
$screen_reader_exclude = sprintf( __( 'Post type %s can be searched', 'relevanssi' ), $type );
}
$name_id = 'relevanssi_index_type_' . $type;
printf(
'<tr>
<th scope="row"><label class="screen-reader-text" for="%3$s">%1$s</label> %2$s</th>
<td><input type="checkbox" name="%3$s" id="%3$s" %4$s /></td>
<td><span aria-hidden="true">%5$s</span><span class="screen-reader-text">%6$s</span></td>
</tr>',
esc_html( $screen_reader_label ),
esc_html( $label ),
esc_attr( $name_id ),
esc_html( $checked ),
esc_html( $excluded_from_search ),
esc_html( $screen_reader_exclude )
);
}
?>
<tr style="display:none">
<td>
<label for="relevanssi_index_type_bogus">Helper control field to make sure settings are saved if no post types are selected.</label>
</td>
<td>
<input type='checkbox' name='relevanssi_index_type_bogus' id='relevanssi_index_type_bogus' checked="checked" />
</td>
<td>
This is our little secret, just for you and me
</td>
</tr>
</table>
</fieldset>
<p class="description"><?php esc_html_e( "If you want to index a post type that's marked 'Excluded from search', you can do that without worrying about it but you need to uncheck the 'Respect exclude_from_search' setting from the Searching tab.", 'relevanssi' ); ?></p>
</td>
</tr>
<tr id="row_index_image_files"
<?php
if ( ! in_array( 'attachment', $index_post_types, true ) ) {
echo 'style="display: none"';
}
?>
>
<th scope="row">
<?php esc_html_e( 'Index image files', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_index_image_files'>
<input type='checkbox' name='relevanssi_index_image_files' id='relevanssi_index_image_files' <?php echo esc_attr( $index_image_files ); ?> />
<?php esc_html_e( 'Index image attachments', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'If this option is enabled, Relevanssi will include image attachments in the index. If the option is disabled, only other attachment types are included.', 'relevanssi' ); ?></p>
<?php // Translators: %1$s opens the link, %2$s closes it. ?>
<p class="description"><?php printf( esc_html__( 'For more detailed control over the attachment type indexing, see %1$sControlling attachment types in the Knowledge base%2$s.', 'relevanssi' ), '<a href="https://www.relevanssi.com/knowledge-base/controlling-attachment-types-index/">', '</a>' ); ?></p>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Taxonomies', 'relevanssi' ); ?>
</th>
<td>
<table class="widefat" id="custom_taxonomies_table">
<thead>
<tr>
<th><?php esc_html_e( 'Taxonomy', 'relevanssi' ); ?></th>
<th><?php esc_html_e( 'Index', 'relevanssi' ); ?></th>
<th><?php esc_html_e( 'Public?', 'relevanssi' ); ?></th>
</tr>
</thead>
<?php
$taxos = get_taxonomies( '', 'objects' );
foreach ( $taxos as $taxonomy ) {
if ( in_array( $taxonomy->name, relevanssi_get_forbidden_taxonomies(), true ) ) {
continue;
}
$checked = '';
if ( in_array( $taxonomy->name, $index_taxonomies_list, true ) ) {
$checked = 'checked="checked"';
}
// Translators: %s is the taxonomy name.
$screen_reader_label = sprintf( __( 'Index taxonomy %s', 'relevanssi' ), $taxonomy->name );
$public = __( 'no', 'relevanssi' );
// Translators: %s is the taxonomy name.
$screen_reader_public = sprintf( __( 'Taxonomy %s is not public', 'relevanssi' ), $taxonomy->name );
if ( $taxonomy->public ) {
$public = __( 'yes', 'relevanssi' );
// Translators: %s is the taxonomy name.
$screen_reader_public = sprintf( __( 'Taxonomy %s is public', 'relevanssi' ), $taxonomy->name );
}
$name_id = 'relevanssi_index_taxonomy_' . $taxonomy->name;
printf(
'<tr>
<th scope="row"><label class="screen-reader-text" for="%3$s">%1$s</label> %2$s</th>
<td><input type="checkbox" name="%3$s" id="%3$s" %4$s /></td>
<td><span aria-hidden="true">%5$s</span><span class="screen-reader-text">%6$s</span></td>
</tr>',
esc_html( $screen_reader_label ),
esc_html( $taxonomy->name ),
esc_attr( $name_id ),
esc_html( $checked ),
esc_html( $public ),
esc_html( $screen_reader_public )
);
}
?>
</table>
<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' ); ?>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_index_comments'><?php esc_html_e( 'Comments', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_index_comments' id='relevanssi_index_comments'>
<option value='none' <?php echo esc_html( $index_comments_none ); ?>><?php esc_html_e( 'none', 'relevanssi' ); ?></option>
<option value='normal' <?php echo esc_html( $index_comments_normal ); ?>><?php esc_html_e( 'comments', 'relevanssi' ); ?></option>
<option value='all' <?php echo esc_html( $index_comments_all ); ?>><?php esc_html_e( 'comments and pingbacks', 'relevanssi' ); ?></option>
</select>
<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>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_index_fields_select'><?php esc_html_e( 'Custom fields', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_index_fields_select' id='relevanssi_index_fields_select'>
<option value='none' <?php echo esc_html( $fields_select_none ); ?>><?php esc_html_e( 'none', 'relevanssi' ); ?></option>
<option value='all' <?php echo esc_html( $fields_select_all ); ?>><?php esc_html_e( 'all', 'relevanssi' ); ?></option>
<option value='visible' <?php echo esc_html( $fields_select_visible ); ?>><?php esc_html_e( 'visible', 'relevanssi' ); ?></option>
<option value='some' <?php echo esc_html( $fields_select_some ); ?>><?php esc_html_e( 'some', 'relevanssi' ); ?></option>
</select>
<p class="description">
<?php
esc_html_e( "'All' indexes all custom fields for posts.", 'relevanssi' );
echo '<br/>';
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' );
echo '<br/>';
esc_html_e( "'Some' lets you choose individual custom fields to index.", 'relevanssi' );
?>
</p>
<?php
if ( class_exists( 'acf' ) && $fields_select_all ) {
echo "<p class='description important'>";
esc_html_e( 'Advanced Custom Fields has lots of invisible custom fields with meta data. Selecting "all" will include lots of garbage in the index and excerpts. "Visible" is usually a better option with ACF.' );
echo '</p>';
}
?>
<div id="index_field_input"
<?php
if ( empty( $fields_select_some ) ) {
echo 'style="display: none"';
}
?>
>
<label for="relevanssi_index_fields" class="screen-reader-text"><?php esc_html_e( 'Custom fields to index', 'relevanssi' ); ?></label>
<input type='text' name='relevanssi_index_fields' id='relevanssi_index_fields' size='60' value='<?php echo esc_attr( $index_fields ); ?>' />
<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>
<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>
</div>
<?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
<?php // Translators: %1$s is the 'some' option and %2$s is '_sku'. ?>
<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>
<?php endif; ?>
</td>
</tr>
<?php if ( 'selected' === $fields_select_all || 'selected' === $fields_select_visible ) : ?>
<tr>
<th scope="row">
<?php esc_html_e( 'List custom fields', 'relevanssi' ); ?>
</th>
<td>
<button type="button" class="button button-primary" id="list_custom_fields"><?php esc_html_e( 'List custom fields', 'relevanssi' ); ?></button>
<p class="description"><?php esc_html_e( 'Click the button above to see the list of indexed custom fields.', 'relevanssi' ); ?></p>
<div id="relevanssi_custom_field_list"></div>
<?php if ( class_exists( 'acf', false ) ) : ?>
<p class="description"><?php esc_html_e( 'Fields excluded from ACF settings and with filter functions are included here.', 'relevanssi' ); ?></p>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
<tr>
<th scope="row">
<?php esc_html_e( 'Author display names', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_index_author'>
<input type='checkbox' name='relevanssi_index_author' id='relevanssi_index_author' <?php echo esc_html( $index_author ); ?> />
<?php esc_html_e( 'Index the post author display name', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'Searching for the post author display name will return posts by that author.', 'relevanssi' ); ?></p>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Excerpts', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_index_excerpt'>
<input type='checkbox' name='relevanssi_index_excerpt' id='relevanssi_index_excerpt' <?php echo esc_html( $index_excerpt ); ?> />
<?php esc_html_e( 'Index the post excerpt', 'relevanssi' ); ?>
</label>
<p class="description"><?php esc_html_e( 'Relevanssi will find posts by the content in the excerpt.', 'relevanssi' ); ?></p>
<?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
<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>
<?php endif; ?>
</td>
</tr>
</table>
<h2><?php esc_html_e( 'Shortcodes', 'relevanssi' ); ?></h2>
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<?php esc_html_e( 'Expand shortcodes', 'relevanssi' ); ?>
</th>
<td>
<label for='relevanssi_expand_shortcodes'>
<input type='checkbox' name='relevanssi_expand_shortcodes' id='relevanssi_expand_shortcodes' <?php echo esc_html( $expand_shortcodes ); ?> />
<?php esc_html_e( 'Expand shortcodes when indexing', 'relevanssi' ); ?>
</label>
<?php if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) : ?>
<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>
<?php endif; ?>
<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>
<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>
</td>
</tr>
<?php
do_action( 'relevanssi_indexing_tab_shortcodes' );
?>
</table>
<?php
do_action( 'relevanssi_indexing_tab' );
?>
<h2><?php esc_html_e( 'Advanced indexing settings', 'relevanssi' ); ?></h2>
<p><button type="button" id="show_advanced_indexing"><?php esc_html_e( 'Show advanced settings', 'relevanssi' ); ?></button></p>
<table class="form-table screen-reader-text" id="advanced_indexing" role="presentation">
<tr>
<th scope="row">
<label for='relevanssi_min_word_length'><?php esc_html_e( 'Minimum word length', 'relevanssi' ); ?></label>
</th>
<td>
<input type='number' name='relevanssi_min_word_length' id='relevanssi_min_word_length' value='<?php echo esc_attr( $min_word_length ); ?>' />
<p class="description"><?php esc_html_e( 'Words shorter than this many letters will not be indexed.', 'relevanssi' ); ?></p>
<?php // Translators: %1$s is 'relevanssi_block_one_letter_searches' and %2$s is 'false'. ?>
<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>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Punctuation control', 'relevanssi' ); ?></th>
<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>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_punct_hyphens'><?php esc_html_e( 'Hyphens and dashes', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_punct_hyphens' id='relevanssi_punct_hyphens'>
<option value='keep' <?php echo esc_html( $punct_hyphens_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
<option value='replace' <?php echo esc_html( $punct_hyphens_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
<option value='remove' <?php echo esc_html( $punct_hyphens_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
</select>
<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>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_punct_quotes'><?php esc_html_e( 'Apostrophes and quotes', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_punct_quotes' id='relevanssi_punct_quotes'>
<option value='replace' <?php echo esc_html( $punct_quotes_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
<option value='remove' <?php echo esc_html( $punct_quotes_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
</select>
<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>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_punct_ampersands'><?php esc_html_e( 'Ampersands', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_punct_ampersands' id='relevanssi_punct_ampersands'>
<option value='keep' <?php echo esc_html( $punct_ampersands_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
<option value='replace' <?php echo esc_html( $punct_ampersands_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
<option value='remove' <?php echo esc_html( $punct_ampersands_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
</select>
<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>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_punct_decimals'><?php esc_html_e( 'Decimal separators', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_punct_decimals' id='relevanssi_punct_decimals'>
<option value='keep' <?php echo esc_html( $punct_decimals_keep ); ?>><?php esc_html_e( 'Keep', 'relevanssi' ); ?></option>
<option value='replace' <?php echo esc_html( $punct_decimals_replace ); ?>><?php esc_html_e( 'Replace with spaces', 'relevanssi' ); ?></option>
<option value='remove' <?php echo esc_html( $punct_decimals_remove ); ?>><?php esc_html_e( 'Remove', 'relevanssi' ); ?></option>
</select>
<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>
</td>
</tr>
<?php
do_action( 'relevanssi_indexing_tab_advanced' );
?>
</table>
<p><button type="button" style="display: none" id="hide_advanced_indexing"><?php esc_html_e( 'Hide advanced settings', 'relevanssi' ); ?></button></p>
</div>
<?php
}

View File

@@ -1,128 +0,0 @@
<?php
/**
* /lib/tabs/logging-tab.php
*
* Prints out the Logging tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the logging tab in Relevanssi settings.
*
* @global $wpdb The WordPress database interface.
*/
function relevanssi_logging_tab() {
global $wpdb;
$log_queries = get_option( 'relevanssi_log_queries' );
$log_queries = relevanssi_check( $log_queries );
$log_queries_with_ip = get_option( 'relevanssi_log_queries_with_ip' );
$log_queries_with_ip = relevanssi_check( $log_queries_with_ip );
$omit_from_logs = get_option( 'relevanssi_omit_from_logs' );
$trim_logs = get_option( 'relevanssi_trim_logs' );
wp_nonce_field( 'relevanssi_export_logs', '_relevanssi_export_nonce', true, true );
?>
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<?php esc_html_e( 'Enable logs', 'relevanssi' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Keep a log of user queries.', 'relevanssi' ); ?></legend>
<label for='relevanssi_log_queries'>
<input type='checkbox' name='relevanssi_log_queries' id='relevanssi_log_queries' <?php echo esc_html( $log_queries ); ?> />
<?php esc_html_e( 'Keep a log of user queries.', 'relevanssi' ); ?>
</label>
</fieldset>
<p class="description">
<?php
// Translators: %1$s is the name of the "User searches" page, %2$s is the name of the database table.
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' ),
esc_html__( 'User searches', 'relevanssi' ),
esc_html( $wpdb->prefix . 'relevanssi_log' )
);
?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Log user IP', 'relevanssi' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( "Log the user's IP with the queries.", 'relevanssi' ); ?></legend>
<label for='relevanssi_log_queries_with_ip'>
<input type='checkbox' name='relevanssi_log_queries_with_ip' id='relevanssi_log_queries_with_ip' <?php echo esc_html( $log_queries_with_ip ); ?> />
<?php esc_html_e( "Log the user's IP with the queries.", 'relevanssi' ); ?>
</label>
</fieldset>
<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>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_omit_from_logs'><?php esc_html_e( 'Exclude users', 'relevanssi' ); ?></label>
</th>
<td>
<input type='text' name='relevanssi_omit_from_logs' id='relevanssi_omit_from_logs' size='60' value='<?php echo esc_attr( $omit_from_logs ); ?>' />
<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>
</td>
</tr>
<?php
if ( function_exists( 'relevanssi_form_hide_branding' ) ) {
relevanssi_form_hide_branding();
}
?>
<tr>
<th scope="row">
<label for='relevanssi_trim_logs'><?php esc_html_e( 'Trim logs', 'relevanssi' ); ?></label>
</th>
<td>
<input type='number' name='relevanssi_trim_logs' id='relevanssi_trim_logs' value='<?php echo esc_attr( $trim_logs ); ?>' />
<?php esc_html_e( 'How many days of logs to keep in the database.', 'relevanssi' ); ?>
<?php
if ( '0' === $trim_logs ) {
echo '<p class="description">';
esc_html_e( "Big log database table will eventually start to slow down the search, so it's a good idea to use some level of automatic log trimming.", 'relevanssi' );
echo '</p>';
} else {
echo '<p class="description">';
// Translators: %d is the setting for no trim (probably 0).
printf( esc_html__( 'Set to %d for no trimming.', 'relevanssi' ), 0 );
echo '</p>';
}
?>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Export logs', 'relevanssi' ); ?>
</th>
<td>
<?php submit_button( __( 'Export the log as a CSV file', 'relevanssi' ), 'secondary', 'relevanssi_export' ); ?>
<p class="description"><?php esc_html_e( 'Push the button to export the search log as a CSV file.', 'relevanssi' ); ?></p>
</td>
</tr>
</table>
<?php
if ( function_exists( 'relevanssi_click_tracking_interface' ) ) {
relevanssi_click_tracking_interface();
} else {
?>
<h3><?php esc_html_e( 'Click tracking', 'relevanssi' ); ?></h3>
<p><?php esc_html_e( 'Relevanssi Premium has a click tracking feature where you can track which posts are clicked from the search results. That way you can tell what is your most interesting content and how the search is actually used to access posts.', 'relevanssi' ); ?></p>
<?php
}
}

View File

@@ -1,131 +0,0 @@
<?php
/**
* /lib/tabs/overview-tab.php
*
* Prints out the Overview tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the overview tab in Relevanssi settings.
*
* @global array $relevanssi_variables The global Relevanssi variables array.
*/
function relevanssi_overview_tab() {
global $relevanssi_variables;
$this_page = '?page=' . plugin_basename( $relevanssi_variables['file'] );
?>
<h2><?php esc_html_e( 'Welcome to Relevanssi!', 'relevanssi' ); ?></h2>
<table class="form-table" role="presentation">
<?php
if ( ! is_plugin_active_for_network( plugin_basename( $relevanssi_variables['file'] ) ) && function_exists( 'relevanssi_form_api_key' ) ) {
relevanssi_form_api_key();
}
if ( function_exists( 'relevanssi_form_hide_post_controls' ) ) {
relevanssi_form_hide_post_controls();
}
if ( function_exists( 'relevanssi_form_do_not_call_home' ) ) {
relevanssi_form_do_not_call_home();
}
if ( function_exists( 'relevanssi_form_update_translations' ) ) {
relevanssi_form_update_translations();
}
?>
<tr>
<th scope="row"><?php esc_html_e( 'Getting started', 'relevanssi' ); ?></th>
<td>
<p><?php esc_html_e( "You've already installed Relevanssi. That's a great first step towards good search experience!", 'relevanssi' ); ?></p>
<ol>
<?php if ( 'done' !== get_option( 'relevanssi_indexed' ) ) : ?>
<?php // Translators: %1$s opens the link, %2$s is the anchor text, %3$s closes the link. ?>
<li><p><?php printf( esc_html__( 'Now, you need an index. Head over to the %1$s%2$s%3$s tab to set up the basic indexing options and to build the index.', 'relevanssi' ), "<a href='" . esc_attr( $this_page ) . "&amp;tab=indexing'>", esc_html__( 'Indexing', 'relevanssi' ), '</a>' ); ?></p>
<p><?php esc_html_e( 'You need to check at least the following options:', 'relevanssi' ); ?><br />
&ndash; <?php esc_html_e( 'Make sure the post types you want to include in the index are indexed.', 'relevanssi' ); ?><br />
<?php // Translators: %s is '_sku'. ?>
&ndash; <?php printf( esc_html__( 'Do you use custom fields to store content you want included? If so, add those too. WooCommerce user? You probably want to include %s.', 'relevanssi' ), '<code>_sku</code>' ); ?></p>
<p><?php esc_html_e( "Then just save the options and build the index. First time you have to do it manually, but after that, it's fully automatic: all changes are reflected in the index without reindexing. (That said, it's a good idea to rebuild the index once a year.)", 'relevanssi' ); ?></p>
</li>
<?php else : ?>
<li><p><?php esc_html_e( 'Great, you already have an index!', 'relevanssi' ); ?></p></li>
<?php endif; ?>
<li>
<?php // Translators: %1$s opens the link, %2$s is the anchor text, %3$s closes the link. ?>
<p><?php printf( esc_html__( 'On the %1$s%2$s%3$s tab, choose whether you want the default operator to be AND (less results, but more precise) or OR (more results, less precise).', 'relevanssi' ), "<a href='" . esc_attr( $this_page ) . "&amp;tab=searching'>", esc_html__( 'Searching', 'relevanssi' ), '</a>' ); ?></p>
</li>
<li>
<?php // Translators: %1$s opens the link, %2$s is the anchor text, %3$s closes the link. ?>
<p><?php printf( esc_html__( 'The next step is the %1$s%2$s%3$s tab, where you can enable the custom excerpts that show the relevant part of post in the search results pages.', 'relevanssi' ), "<a href='" . esc_attr( $this_page ) . "&amp;tab=excerpts'>", esc_html__( 'Excerpts and highlights', 'relevanssi' ), '</a>' ); ?></p>
<p><?php esc_html_e( 'There are couple of options related to that, so if you want highlighting in the results, you can adjust the styles for that to suit the look of your site.', 'relevanssi' ); ?></p>
</li>
<li>
<p><?php esc_html_e( "That's about it! Now you should have Relevanssi up and running. The rest of the options is mostly fine-tuning.", 'relevanssi' ); ?></p>
</li>
</ol>
<p><?php esc_html_e( "Relevanssi doesn't have a separate search widget. Instead, Relevanssi uses the default search widget. Any standard search form will do!", 'relevanssi' ); ?></p>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Relevanssi Live Ajax Search', 'relevanssi' ); ?></th>
<td>
<?php // Translators: %1$s opens the link, %2$s closes it. ?>
<p><?php printf( esc_html__( 'If you want a live search results, you can use the Relevanssi Live Ajax Search plugin. %1$sYou can find it in the plugin repository%2$s. It will make your search forms show instant results, powered by Relevanssi.', 'relevanssi' ), "<a href='https://wordpress.org/plugins/relevanssi-live-ajax-search/'>", '</a>' ); ?></p>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Privacy and GDPR compliance', 'relevanssi' ); ?></th>
<td>
<?php // Translators: %1$s and %3$s open the links, %2$s closes them. ?>
<p><?php printf( esc_html__( '%1$sGDPR Compliance at Relevanssi knowledge base%2$s explains how using Relevanssi affects the GDPR compliance and the privacy policies of your site. Relevanssi also supports the %3$sprivacy policy tool%2$s and the WordPress user data export and erase tools.', 'relevanssi' ), "<a href='https://www.relevanssi.com/knowledge-base/gdpr-compliance/'>", '</a>', "<a href='privacy.php'>" ); ?></p>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'For more information', 'relevanssi' ); ?></th>
<td>
<p><?php esc_html_e( "Relevanssi uses the WordPress contextual help. Click 'Help' on the top right corner for more information on many Relevanssi topics.", 'relevanssi' ); ?></p>
<?php // Translators: %1$s opens the link, %2$s closes the link. ?>
<p><?php printf( esc_html__( '%1$sRelevanssi knowledge base%2$s has lots of information about advanced Relevanssi use, including plenty of code samples.', 'relevanssi' ), "<a href='https://www.relevanssi.com/knowledge-base/'>", '</a>' ); ?></p>
</td>
</tr>
<tr>
<th scope="row"><?php esc_html_e( 'Do you like Relevanssi?', 'relevanssi' ); ?></th>
<td>
<p><?php esc_html_e( 'If you do, the best way to show your appreciation is to spread the word and perhaps give us a good review on WordPress.org.', 'relevanssi' ); ?></p>
<?php // Translators: %1$s opens the link, %2$s closes the link. ?>
<p><?php printf( esc_html__( 'If you like Relevanssi, leaving a five-star review on WordPress.org will help others discover Relevanssi. %1$sYou can add your review here%2$s.', 'relevanssi' ), "<a href='https://wordpress.org/support/plugin/relevanssi/reviews/#new-post'>", '</a>' ); ?></p>
</td>
</tr>
<?php if ( ! RELEVANSSI_PREMIUM ) { ?>
<tr>
<th scope="row">
<?php esc_html_e( 'Buy Relevanssi Premium', 'relevanssi' ); ?>
</th>
<td>
<p><a href="https://www.relevanssi.com/buy-premium"><?php esc_html_e( 'Buy Relevanssi Premium now', 'relevanssi' ); ?></a>
<?php // Translators: %1$s is the coupon code, %2$s is the year it expires. ?>
<?php printf( esc_html__( 'use coupon code %1$s for 20%% discount (valid at least until the end of %2$s)', 'relevanssi' ), '<strong>FREE2024</strong>', '2024' ); ?></p>
<p><?php esc_html_e( 'Here are some improvements Relevanssi Premium offers:', 'relevanssi' ); ?></p>
<ul class="relevanssi_ul">
<li><?php esc_html_e( 'PDF content indexing', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'A Related posts feature', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Index and search user profile pages', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Index and search taxonomy term pages', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Multisite searches across many subsites', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'WP CLI commands', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Adjust weights separately for each post type and taxonomy', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Internal link anchors can be search terms for the target posts', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Index and search any columns in the wp_posts database', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Hide Relevanssi branding from the User Searches page on a client installation', 'relevanssi' ); ?></li>
<li><?php esc_html_e( 'Redirect search queries to custom URLs', 'relevanssi' ); ?></li>
</ul>
</td>
</tr>
<?php } // End if ( ! RELEVANSSI_PREMIUM ). ?>
</table>
<?php
}

View File

@@ -1,24 +0,0 @@
<?php
/**
* /lib/tabs/redirects-tab.php
*
* Prints out the Redirects tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the redirects tab in Relevanssi settings.
*/
function relevanssi_redirects_tab() {
?>
<h2><?php esc_html_e( 'Redirects', 'relevanssi' ); ?></h2>
<p><?php esc_html_e( 'With Relevanssi Premium, you can set up redirects. These are keywords that automatically redirect the user to certain page, without going through the usual search process. For example, you could set it up so that all searches for "job" automatically lead to your "Careers" page.', 'relevanssi' ); ?></p>
<?php // Translators: %1$s starts the link, %2$s closes it. ?>
<p><?php printf( esc_html__( 'In order to access this and many other delightful Premium features, %1$sbuy Relevanssi Premium here%2$s.', 'relevanssi' ), '<a href="https://www.relevanssi.com/buy-premium/">', '</a>' ); ?></p>
<?php
}

View File

@@ -1,97 +0,0 @@
<?php
/**
* /lib/tabs/search-tab.php
*
* Prints out the search tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the search tab in Relevanssi settings.
*/
function relevanssi_search_tab() {
?>
<p><?php esc_html_e( 'You can use this search to perform Relevanssi searches without any restrictions from WordPress. You can search all post types here.', 'relevanssi' ); ?></p>
<form action="" method="get">
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<label for='s'><?php esc_html_e( 'Search terms', 'relevanssi' ); ?></label>
</th>
<td>
<input type='text' name='s' id='s' size='60' />
</td>
</tr>
<tr>
<th scope="row">
<label for='post_types'><?php esc_html_e( 'Post type', 'relevanssi' ); ?></label>
</th>
<td>
<select name='post_types' id='post_types'>
<option value="any"><?php esc_html_e( 'Any', 'relevanssi' ); ?></option>
<?php
echo implode(
' ',
array_map( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
function ( $post_type ) {
$pt = get_post_type_object( $post_type );
if ( $pt ) {
$post_type_value = esc_attr( $post_type );
$post_type_name = esc_html( $pt->labels->singular_name );
return "<option value='{$post_type_value}'>{$post_type_name}</option>";
}
return null;
},
get_option( 'relevanssi_index_post_types', array() )
)
);
if ( 'on' === get_option( 'relevanssi_index_users' ) ) {
?>
<option value='user'><?php esc_html_e( 'Users', 'relevanssi' ); ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<th scope="row">
<label for='posts_per_page'><?php esc_html_e( 'Posts per page', 'relevanssi' ); ?></label>
</th>
<td>
<select name='posts_per_page' id='posts_per_page'>
<option value='0'><?php esc_html_e( 'All', 'relevanssi' ); ?></option>
<option>10</option>
<option>50</option>
<option>100</option>
</select>
</td>
</tr>
<tr>
<th scope="row">
<label for='args'><?php esc_html_e( 'Search parameters', 'relevanssi' ); ?></label>
</th>
<td>
<input type='text' name='args' id='args' size='60' />
<?php // Translators: example query string. ?>
<p class='description'><?php printf( esc_html__( 'Use query parameter formatting here, the same that would appear on search page results URL. For example %s.', 'relevanssi' ), '<code>posts_per_page=10&post_types=page&from=2018-01-01</code>' ); ?></p>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type='submit' name='search' id='search' value='<?php echo esc_html_x( 'Search', 'button action', 'relevanssi' ); ?>' class='button' />
</td>
</tr>
</table>
</form>
<div id='results'></div>
<?php
}

View File

@@ -1,412 +0,0 @@
<?php
/**
* /lib/tabs/searching-tab.php
*
* Prints out the Searching tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the searching tab in Relevanssi settings.
*
* @global $wpdb The WordPress database interface.
* @global $relevanssi_variables The global Relevanssi variables array.
*/
function relevanssi_searching_tab() {
global $wpdb, $relevanssi_variables;
$implicit = get_option( 'relevanssi_implicit_operator' );
$orderby = get_option( 'relevanssi_default_orderby' );
$fuzzy = get_option( 'relevanssi_fuzzy' );
$content_boost = get_option( 'relevanssi_content_boost' );
$title_boost = get_option( 'relevanssi_title_boost' );
$comment_boost = get_option( 'relevanssi_comment_boost' );
$exact_match_bonus = get_option( 'relevanssi_exact_match_bonus' );
$wpml_only_current = get_option( 'relevanssi_wpml_only_current' );
$polylang_allow_all = get_option( 'relevanssi_polylang_all_languages' );
$admin_search = get_option( 'relevanssi_admin_search' );
$disable_or_fallback = get_option( 'relevanssi_disable_or_fallback' );
$throttle = get_option( 'relevanssi_throttle' );
$respect_exclude = get_option( 'relevanssi_respect_exclude' );
$cat = get_option( 'relevanssi_cat' );
$excat = get_option( 'relevanssi_excat' );
$exclude_posts = get_option( 'relevanssi_exclude_posts' );
$index_post_types = get_option( 'relevanssi_index_post_types', array() );
$index_users = get_option( 'relevanssi_index_users' );
$index_terms = get_option( 'relevanssi_index_taxonomies' );
$throttle = relevanssi_check( $throttle );
$respect_exclude = relevanssi_check( $respect_exclude );
$admin_search = relevanssi_check( $admin_search );
$wpml_only_current = relevanssi_check( $wpml_only_current );
$polylang_allow_all = relevanssi_check( $polylang_allow_all );
$exact_match_bonus = relevanssi_check( $exact_match_bonus );
$disable_or_fallback = relevanssi_check( $disable_or_fallback );
$implicit_and = relevanssi_select( $implicit, 'AND' );
$implicit_or = relevanssi_select( $implicit, 'OR' );
$orderby_relevance = relevanssi_select( $orderby, 'relevance' );
$orderby_date = relevanssi_select( $orderby, 'post_date' );
$fuzzy_sometimes = relevanssi_select( $fuzzy, 'sometimes' );
$fuzzy_always = relevanssi_select( $fuzzy, 'always' );
$fuzzy_never = relevanssi_select( $fuzzy, 'never' );
$orfallback_visibility = 'screen-reader-text';
if ( 'AND' === $implicit ) {
$orfallback_visibility = '';
}
if ( ! $throttle ) {
$docs_count = get_transient( 'relevanssi_docs_count' );
if ( ! $docs_count ) {
$docs_count = $wpdb->get_var( 'SELECT COUNT(DISTINCT doc) FROM ' . $relevanssi_variables['relevanssi_table'] . ' WHERE doc != -1' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared
set_transient( 'relevanssi_docs_count', $docs_count, WEEK_IN_SECONDS );
}
} else {
$docs_count = null;
}
?>
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<label for='relevanssi_implicit_operator'><?php esc_html_e( 'Default operator', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_implicit_operator' id='relevanssi_implicit_operator'>
<option value='AND' <?php echo esc_html( $implicit_and ); ?>><?php esc_html_e( 'AND - require all terms', 'relevanssi' ); ?></option>
<option value='OR' <?php echo esc_html( $implicit_or ); ?>><?php esc_html_e( 'OR - any term present is enough', 'relevanssi' ); ?></option>
</select>
<p class="description"><?php esc_html_e( 'This setting determines the default operator for the search.', 'relevanssi' ); ?></p>
<?php
if ( RELEVANSSI_PREMIUM ) {
// Translators: %1$s is the name of the 'operator' query variable, %2$s is an example url.
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>';
}
?>
</td>
</tr>
<tr id="orfallback" class='<?php echo esc_attr( $orfallback_visibility ); ?>'>
<th scope="row">
<?php esc_html_e( 'Fallback to OR', 'relevanssi' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Disable the OR fallback.', 'relevanssi' ); ?></legend>
<label for='relevanssi_disable_or_fallback'>
<input type='checkbox' name='relevanssi_disable_or_fallback' id='relevanssi_disable_or_fallback' <?php echo esc_html( $disable_or_fallback ); ?> />
<?php esc_html_e( 'Disable the OR fallback.', 'relevanssi' ); ?>
</label>
</fieldset>
<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>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_default_orderby'><?php esc_html_e( 'Default order', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_default_orderby' id='relevanssi_default_orderby'>
<option value='relevance' <?php echo esc_html( $orderby_relevance ); ?>><?php esc_html_e( 'Relevance (highly recommended)', 'relevanssi' ); ?></option>
<option value='post_date' <?php echo esc_html( $orderby_date ); ?>><?php esc_html_e( 'Post date', 'relevanssi' ); ?></option>
</select>
<?php // Translators: name of the query variable. ?>
<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>
<?php if ( RELEVANSSI_PREMIUM ) { ?>
<p class="description"><?php esc_html_e( 'If you want date-based results, see the recent post bonus in the Weights section.', 'relevanssi' ); ?></p>
<?php } // End if ( RELEVANSSI_PREMIUM ). ?>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_fuzzy'><?php esc_html_e( 'Keyword matching', 'relevanssi' ); ?></label>
</th>
<td>
<select name='relevanssi_fuzzy' id='relevanssi_fuzzy'>
<option value='never' <?php echo esc_html( $fuzzy_never ); ?>><?php esc_html_e( 'Whole words', 'relevanssi' ); ?></option>
<option value='always' <?php echo esc_html( $fuzzy_always ); ?>><?php esc_html_e( 'Partial words', 'relevanssi' ); ?></option>
<option value='sometimes' <?php echo esc_html( $fuzzy_sometimes ); ?>><?php esc_html_e( 'Partial words if no hits for whole words', 'relevanssi' ); ?></option>
</select>
<?php if ( $fuzzy_sometimes ) : ?>
<?php // Translators: %1$s is the "partial words if no hits" option and %2$s is the "partial words" option. ?>
<p class="description important"><?php printf( esc_html__( 'Choosing the "%1$s" option may lead to unexpected results. Most of the time the "%2$s" option is the better choice.', 'relevanssi' ), esc_html__( 'Partial words if not hits for whole words', 'relevanssi' ), esc_html__( 'Partial words', 'relevanssi' ) ); ?></p>
<?php endif; ?>
<p class="description"><?php esc_html_e( 'Whole words means Relevanssi only finds posts that include the whole search term.', 'relevanssi' ); ?></p>
<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>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Weights', 'relevanssi' ); ?>
</th>
<td>
<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>
<table class="relevanssi-weights-table">
<thead>
<tr>
<th><?php esc_html_e( 'Element', 'relevanssi' ); ?></th>
<th class="col-2"><?php esc_html_e( 'Weight', 'relevanssi' ); ?></th>
</tr>
</thead>
<tr>
<td>
<label for="relevanssi_content_boost"><?php esc_html_e( 'Content', 'relevanssi' ); ?></label>
</td>
<td class="col-2">
<input type='text' name='relevanssi_content_boost' id='relevanssi_content_boost' size='4' value='<?php echo esc_attr( $content_boost ); ?>' />
</td>
</tr>
<tr>
<td>
<label for="relevanssi_title_boost"><?php esc_html_e( 'Titles', 'relevanssi' ); ?></label>
</td>
<td class="col-2">
<input type='text' name='relevanssi_title_boost' id='relevanssi_title_boost' size='4' value='<?php echo esc_attr( $title_boost ); ?>' />
</td>
</tr>
<?php
if ( function_exists( 'relevanssi_form_link_weight' ) ) {
relevanssi_form_link_weight();
}
?>
<tr>
<td>
<label for="relevanssi_comment_boost"><?php esc_html_e( 'Comment text', 'relevanssi' ); ?></label>
</td>
<td class="col-2">
<input type='text' name='relevanssi_comment_boost' id='relevanssi_comment_boost' size='4' value='<?php echo esc_attr( $comment_boost ); ?>' />
</td>
</tr>
<?php
if ( function_exists( 'relevanssi_form_post_type_weights' ) ) {
relevanssi_form_post_type_weights();
}
if ( function_exists( 'relevanssi_form_taxonomy_weights' ) ) {
relevanssi_form_taxonomy_weights();
} elseif ( function_exists( 'relevanssi_form_tag_weight' ) ) {
relevanssi_form_tag_weight();
}
if ( function_exists( 'relevanssi_form_recency_weight' ) ) {
relevanssi_form_recency_weight();
}
?>
</table>
</td>
</tr>
<?php
if ( function_exists( 'relevanssi_form_recency_cutoff' ) ) {
relevanssi_form_recency_cutoff();
}
?>
<tr>
<th scope="row">
<?php esc_html_e( 'Boost exact matches', 'relevanssi' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Give boost to exact matches.', 'relevanssi' ); ?></legend>
<label for='relevanssi_exact_match_bonus'>
<input type='checkbox' name='relevanssi_exact_match_bonus' id='relevanssi_exact_match_bonus' <?php echo esc_html( $exact_match_bonus ); ?> />
<?php esc_html_e( 'Give boost to exact matches.', 'relevanssi' ); ?>
</label>
</fieldset>
<?php // Translators: %s is the name of the filter hook. ?>
<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>
</td>
</tr>
<?php
if ( function_exists( 'icl_object_id' ) && ! function_exists( 'pll_get_post' ) ) {
?>
<tr>
<th scope="row">
<?php esc_html_e( 'WPML', 'relevanssi' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Limit results to current language.', 'relevanssi' ); ?></legend>
<label for='relevanssi_wpml_only_current'>
<input type='checkbox' name='relevanssi_wpml_only_current' id='relevanssi_wpml_only_current' <?php echo esc_html( $wpml_only_current ); ?> />
<?php esc_html_e( 'Limit results to current language.', 'relevanssi' ); ?>
</label>
</fieldset>
<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>
</td>
</tr>
<?php } // WPML. ?>
<?php if ( function_exists( 'pll_get_post' ) ) { ?>
<tr>
<th scope="row">
<?php esc_html_e( 'Polylang', 'relevanssi' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Allow results from all languages.', 'relevanssi' ); ?></legend>
<label for='relevanssi_polylang_all_languages'>
<input type='checkbox' name='relevanssi_polylang_all_languages' id='relevanssi_polylang_all_languages' <?php echo esc_html( $polylang_allow_all ); ?> />
<?php esc_html_e( 'Allow results from all languages.', 'relevanssi' ); ?>
</label>
</fieldset>
<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>
</td>
</tr>
<?php } // Polylang. ?>
<tr>
<th scope="row">
<?php esc_html_e( 'Admin search', 'relevanssi' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Use Relevanssi for admin searches.', 'relevanssi' ); ?></legend>
<label for='relevanssi_admin_search'>
<input type='checkbox' name='relevanssi_admin_search' id='relevanssi_admin_search' <?php echo esc_html( $admin_search ); ?> />
<?php esc_html_e( 'Use Relevanssi for admin searches.', 'relevanssi' ); ?>
</label>
</fieldset>
<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>
</td>
</tr>
<tr>
<th scope="row">
<?php // Translators: %s is 'exclude_from_search'. ?>
<?php printf( esc_html__( 'Respect %s', 'relevanssi' ), 'exclude_from_search' ); ?>
</th>
<td>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Respect exclude_from_search for custom post types', 'relevanssi' ); ?></legend>
<label for='relevanssi_respect_exclude'>
<input type='checkbox' name='relevanssi_respect_exclude' id='relevanssi_respect_exclude' <?php echo esc_html( $respect_exclude ); ?> />
<?php // Translators: %s is 'exclude_from_search'. ?>
<?php printf( esc_html__( 'Respect %s for custom post types', 'relevanssi' ), '<code>exclude_from_search</code>' ); ?>
</label>
<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>
<?php
if ( ! empty( $respect_exclude ) ) {
$pt_1 = get_post_types( array( 'exclude_from_search' => '1' ) );
$pt_2 = get_post_types( array( 'exclude_from_search' => true ) );
$private_types = array_merge( $pt_1, $pt_2 );
$problem_post_types = array_intersect( $index_post_types, $private_types );
if ( ! empty( $problem_post_types ) ) {
?>
<p class="description important">
<?php
esc_html_e( "You probably should uncheck this option, because you've set Relevanssi to index the following non-public post types:", 'relevanssi' );
echo ' ' . esc_html( implode( ', ', $problem_post_types ) );
?>
</p>
<?php
}
}
?>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Throttle searches', 'relevanssi' ); ?>
</th>
<td id="throttlesearches">
<div id="throttle_enabled">
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Throttle searches.', 'relevanssi' ); ?></legend>
<label for='relevanssi_throttle'>
<input type='checkbox' name='relevanssi_throttle' id='relevanssi_throttle' <?php echo esc_html( $throttle ); ?> />
<?php esc_html_e( 'Throttle searches.', 'relevanssi' ); ?>
</label>
</fieldset>
<?php if ( $docs_count && $docs_count < 1000 ) { ?>
<p class="description important"><?php esc_html_e( "Your database is so small that you don't need to enable this.", 'relevanssi' ); ?></p>
<?php } ?>
<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>
<?php if ( 'post_date' === $orderby && ( 'on' === $index_users || 'on' === $index_terms ) ) { ?>
<p class="important"><?php esc_html_e( 'You have the default ordering set to post date and have enabled user or taxonomy term indexing. If you enable the throttle, the search results will only include posts. Users and taxonomy terms will be excluded. Either keep the throttle disabled or set the post ordering to relevance.', 'relevanssi' ); ?></p>
<?php } ?>
</div>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Category restriction', 'relevanssi' ); ?>
</th>
<td>
<div class="categorydiv" style="max-width: 400px">
<div class="tabs-panel">
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Category restriction', 'relevanssi' ); ?></legend>
<ul id="category_inclusion_checklist">
<?php
$selected_cats = explode( ',', $cat );
$walker = get_relevanssi_taxonomy_walker();
$walker->name = 'relevanssi_cat';
wp_terms_checklist(
0,
array(
'taxonomy' => 'category',
'selected_cats' => $selected_cats,
'walker' => $walker,
)
);
?>
</ul>
</fieldset>
<input type="hidden" name="relevanssi_cat_active" value="1" />
</div>
</div>
<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>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Category exclusion', 'relevanssi' ); ?>
</th>
<td>
<div class="categorydiv" style="max-width: 400px">
<div class="tabs-panel">
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Category exclusion', 'relevanssi' ); ?></legend>
<ul id="category_exclusion_checklist">
<?php
$selected_cats = explode( ',', $excat );
$walker = get_relevanssi_taxonomy_walker();
$walker->name = 'relevanssi_excat';
wp_terms_checklist(
0,
array(
'taxonomy' => 'category',
'selected_cats' => $selected_cats,
'walker' => $walker,
)
);
?>
</ul>
<input type="hidden" name="relevanssi_excat_active" value="1" />
</fieldset>
</div>
</div>
<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>
</td>
</tr>
<tr>
<th scope="row">
<label for='relevanssi_exclude_posts'><?php esc_html_e( 'Post exclusion', 'relevanssi' ); ?>
</th>
<td>
<input type='text' name='relevanssi_exclude_posts' id='relevanssi_exclude_posts' size='60' value='<?php echo esc_attr( $exclude_posts ); ?>' />
<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>
<?php if ( RELEVANSSI_PREMIUM ) { ?>
<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>
<?php } ?>
</td>
</tr>
<?php
if ( function_exists( 'relevanssi_form_searchblogs_setting' ) ) {
relevanssi_form_searchblogs_setting();
}
?>
</table>
<?php
}

View File

@@ -1,149 +0,0 @@
<?php
/**
* /lib/tabs/stopwords-tab.php
*
* Prints out the Stopwords tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the stopwords tab in Relevanssi settings.
*/
function relevanssi_stopwords_tab() {
if ( class_exists( 'Polylang', false ) && ! relevanssi_get_current_language() ) {
relevanssi_polylang_all_languages_stopwords();
return;
}
?>
<h3 id="stopwords"><?php esc_html_e( 'Stopwords', 'relevanssi' ); ?></h3>
<?php
relevanssi_show_stopwords();
?>
<h3 id="bodystopwords"><?php esc_html_e( 'Content stopwords', 'relevanssi' ); ?></h3>
<?php
if ( function_exists( 'relevanssi_show_body_stopwords' ) ) {
relevanssi_show_body_stopwords();
} else {
printf(
'<p>%s</p>',
esc_html__(
'Content stopwords are a premium feature where you can set stopwords that only apply to the post content. Those stopwords will still be indexed if they appear in post titles, tags, categories, custom fields or other parts of the post. To use content stopwords, you need Relevanssi Premium.',
'relevanssi'
)
);
}
/**
* Filters whether the common words list is displayed or not.
*
* The list of 25 most common words is displayed by default, but if the
* index is big, displaying the list can take a long time. This filter can
* be used to turn the list off.
*
* @param boolean If true, show the list; if false, don't show it.
*/
if ( apply_filters( 'relevanssi_display_common_words', true ) ) {
relevanssi_common_words( 25 );
}
}
/**
* Displays a list of stopwords.
*
* Displays the list of stopwords and gives the controls for adding new
* stopwords.
*/
function relevanssi_show_stopwords() {
printf(
'<p>%s</p>',
esc_html__(
'Enter a word here to add it to the list of stopwords. The word will automatically be removed from the index, so re-indexing is not necessary. You can enter many words at the same time, separate words with commas.',
'relevanssi'
)
);
?>
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<label for="addstopword"><p><?php esc_html_e( 'Stopword(s) to add', 'relevanssi' ); ?>
</th>
<td>
<textarea name="addstopword" id="addstopword" rows="2" cols="80"></textarea>
<p><input type="submit" value="<?php esc_attr_e( 'Add', 'relevanssi' ); ?>" class='button' /></p>
</td>
</tr>
</table>
<p><?php esc_html_e( "Here's a list of stopwords in the database. Click a word to remove it from stopwords. Removing stopwords won't automatically return them to index, so you need to re-index all posts after removing stopwords to get those words back to index.", 'relevanssi' ); ?></p>
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<?php esc_html_e( 'Current stopwords', 'relevanssi' ); ?>
</th>
<td>
<ul>
<?php
$stopwords = array_map( 'stripslashes', relevanssi_fetch_stopwords() );
sort( $stopwords );
$exportlist = htmlspecialchars( implode( ', ', $stopwords ) );
array_walk(
$stopwords,
function ( $term ) {
printf( '<li style="display: inline;"><input type="submit" name="removestopword" value="%s"/></li>', esc_attr( $term ) );
}
);
?>
</ul>
<p>
<input
type="submit"
id="removeallstopwords"
name="removeallstopwords"
value="<?php esc_attr_e( 'Remove all stopwords', 'relevanssi' ); ?>"
class='button'
/>
<input
type="submit"
id="repopulatestopwords"
name="repopulatestopwords"
value="<?php esc_attr_e( 'Add default stopwords', 'relevanssi' ); ?>"
class='button'
/>
</p>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Exportable list of stopwords', 'relevanssi' ); ?>
</th>
<td>
<label for="stopwords" class="screen-reader-text"><?php esc_html_e( 'Exportable list of stopwords', 'relevanssi' ); ?></label>
<textarea name="stopwords" id="stopwords" rows="2" cols="80"><?php echo esc_textarea( $exportlist ); ?></textarea>
<p class="description"><?php esc_html_e( 'You can copy the list of stopwords here if you want to back up the list, copy it to a different blog or otherwise need the list.', 'relevanssi' ); ?></p>
</td>
</tr>
</table>
<?php
}
/**
* Displays an error message when Polylang is in all languages mode.
*/
function relevanssi_polylang_all_languages_stopwords() {
?>
<h3 id="stopwords"><?php esc_html_e( 'Stopwords', 'relevanssi' ); ?></h3>
<p class="description"><?php esc_html_e( 'You are using Polylang and are in "Show all languages" mode. Please select a language before adjusting the stopword settings.', 'relevanssi' ); ?></p>
<?php
}

View File

@@ -1,102 +0,0 @@
<?php
/**
* /lib/tabs/synonyms-tab.php
*
* Prints out the Synonyms tab in Relevanssi settings.
*
* @package Relevanssi
* @author Mikko Saari
* @license https://wordpress.org/about/gpl/ GNU General Public License
* @see https://www.relevanssi.com/
*/
/**
* Prints out the synonyms tab in Relevanssi settings.
*/
function relevanssi_synonyms_tab() {
$current_language = relevanssi_get_current_language();
if ( class_exists( 'Polylang', false ) && ! pll_current_language() ) {
relevanssi_polylang_all_languages_synonyms();
return;
}
$synonyms_array = get_option( 'relevanssi_synonyms', array() );
$synonyms = isset( $synonyms_array[ $current_language ] ) ? $synonyms_array[ $current_language ] : '';
if ( isset( $synonyms ) ) {
$synonyms = str_replace( ';', "\n", $synonyms );
} else {
$synonyms = '';
}
$synonyms_disabled = false;
$operator = get_option( 'relevanssi_implicit_operator' );
if ( 'AND' === $operator ) {
$index_synonyms = get_option( 'relevanssi_index_synonyms', false );
if ( 'on' !== $index_synonyms ) {
$synonyms_disabled = true;
}
}
?>
<h3 id="synonyms"><?php esc_html_e( 'Synonyms', 'relevanssi' ); ?></h3>
<table class="form-table" role="presentation">
<tr
<?php
if ( $synonyms_disabled ) {
echo "class='relevanssi_disabled'";
}
?>
>
<?php if ( $synonyms_disabled ) : ?>
<tr>
<th scope="row">
<p class="important"><?php esc_html_e( 'No synonyms!', 'relevanssi' ); ?></p>
</th>
<td>
<p class="important"><?php esc_html_e( 'Synonyms are disabled because the searching operator is set to AND. Enable OR searching to use the synonyms.', 'relevanssi' ); ?></p>
<?php if ( RELEVANSSI_PREMIUM ) : ?>
<p class="description"><?php esc_html_e( "If you want to use synonyms in AND searches, enable synonym indexing on the Indexing tab. Also, any changes to the synonyms won't take effect until you rebuild the index.", 'relevanssi' ); ?></p>
<?php else : ?>
<p class="description"><?php esc_html_e( 'Relevanssi Premium has a feature that allows you to include the synonyms in the indexing. This makes it possible to use synonyms in AND searches.', 'relevanssi' ); ?></p>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
<th scope="row">
<label for="relevanssi_synonyms"><?php esc_html_e( 'Synonyms', 'relevanssi' ); ?></label>
</th>
<td>
<p class="description"><?php esc_html_e( 'Add synonyms here to make the searches find better results. If you notice your users frequently misspelling a product name, or for other reasons use many names for one thing, adding synonyms will make the results better.', 'relevanssi' ); ?></p>
<p class="description"><?php esc_html_e( "Do not go overboard, though, as too many synonyms can make the search confusing: users understand if a search query doesn't match everything, but they get confused if the searches match to unexpected things.", 'relevanssi' ); ?></p>
<br />
<textarea name='relevanssi_synonyms' id='relevanssi_synonyms' rows='9' cols='60'
<?php
if ( $synonyms_disabled ) {
echo 'disabled';
}
?>
><?php echo esc_textarea( $synonyms ); ?></textarea>
<p class="description"><?php _e( 'The format here is <code>key = value</code>. If you add <code>dog = hound</code> to the list of synonyms, searches for <code>dog</code> automatically become a search for <code>dog hound</code> and will thus match to posts that include either <code>dog</code> or <code>hound</code>. This only works in OR searches: in AND searches the synonyms only restrict the search, as now the search only finds posts that contain <strong>both</strong> <code>dog</code> and <code>hound</code>.', 'relevanssi' ); // phpcs:ignore WordPress.Security.EscapeOutput.UnsafePrintingFunction ?></p>
<p class="description"><?php _e( 'The synonyms are one direction only. If you want both directions, add the synonym again, reversed: <code>hound = dog</code>.', 'relevanssi' ); // phpcs:ignore WordPress.Security.EscapeOutput.UnsafePrintingFunction ?></p>
<p class="description"><?php _e( "It's possible to use phrases for the value, but not for the key. <code>dog = \"great dane\"</code> works, but <code>\"great dane\" = dog</code> doesn't.", 'relevanssi' ); // phpcs:ignore WordPress.Security.EscapeOutput.UnsafePrintingFunction ?></p>
</td>
</tr>
</table>
<?php
}
/**
* Displays an error message when Polylang is in all languages mode.
*/
function relevanssi_polylang_all_languages_synonyms() {
?>
<h3 id="synonyms"><?php esc_html_e( 'Synonyms', 'relevanssi' ); ?></h3>
<p class="description"><?php esc_html_e( 'You are using Polylang and are in "Show all languages" mode. Please select a language before adjusting the synonym settings.', 'relevanssi' ); ?></p>
<?php
}