.

Deutsch (de_DE), español (es_ES), français (fr_FR), suomi (fi)

manage_options', 'relevanssi_options_capability' ); ?>

get_results( "SHOW COLUMNS FROM $wpdb->posts" ); wp_cache_set( 'relevanssi_column_list', $column_list ); } $columns = array(); foreach ( $column_list as $column ) { array_push( $columns, $column->Field ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase } $columns = implode( ', ', $columns ); ?>

wp_posts' ); echo esc_html( $columns ); ?>

/>

> >


dog = hound to the synonym list and enable this feature, every time the indexer sees hound in post content or post title, it will index it as hound dog. Thus, the post will be found when searching with either word. This makes it possible to use synonyms with AND searches, but will slow down indexing, especially with large databases and large lists of synonyms. You can use multi-word values, but phrases do not work.', 'relevanssi' ); // phpcs:ignore WordPress.Security.EscapeOutput.UnsafePrintingFunction ?>

>

relevanssi_post_type_additional_content' ); ?>

> ' . esc_html( implode( ', ', $post_types ) ) . '

'; ?>

has_archive', 'relevanssi_indexed_post_type_archives' ); ?>

/>

post_type, $post->post_type ) ) { $api_key = get_network_option( null, 'relevanssi_api_key' ); if ( ! $api_key ) { $api_key = get_option( 'relevanssi_api_key' ); } wp_enqueue_script( 'relevanssi_admin_pdf_js', $plugin_dir_url . 'premium/admin_pdf_scripts.js', array( 'jquery' ), $relevanssi_variables['plugin_version'], true ); wp_localize_script( 'relevanssi_admin_pdf_js', 'admin_pdf_data', array( 'send_pdf_nonce' => wp_create_nonce( 'relevanssi_send_pdf' ), ) ); } wp_enqueue_script( 'relevanssi_metabox_js', $plugin_dir_url . 'premium/admin_metabox_scripts.js', array( 'jquery' ), $relevanssi_variables['plugin_version'], true ); wp_localize_script( 'relevanssi_metabox_js', 'relevanssi_metabox_data', array( 'metabox_nonce' => wp_create_nonce( 'relevanssi_metabox_nonce' ), ) ); wp_enqueue_style( 'relevanssi_metabox_css', $plugin_dir_url . 'premium/metabox_styles.css', array(), $relevanssi_variables['plugin_version'] ); } $nonce = array( 'taxonomy_indexing_nonce' => wp_create_nonce( 'relevanssi_taxonomy_indexing_nonce' ), 'user_indexing_nonce' => wp_create_nonce( 'relevanssi_user_indexing_nonce' ), 'indexing_nonce' => wp_create_nonce( 'relevanssi_indexing_nonce' ), 'post_type_archive_indexing_nonce' => wp_create_nonce( 'relevanssi_post_type_archive_indexing_nonce' ), 'searching_nonce' => wp_create_nonce( 'relevanssi_admin_search_nonce' ), ); wp_localize_script( 'relevanssi_admin_js_premium', 'nonce', $nonce ); } /** * Imports Relevanssi Premium options. * * Takes the options array and does the actual updating of options using * update_options(). * * @param string $options JSON-formatted array. Key has the option name, value * the option value. */ function relevanssi_import_options( $options ) { $unserialized = json_decode( stripslashes( $options ) ); foreach ( $unserialized as $key => $value ) { if ( in_array( $key, array( 'relevanssi_post_type_weights', 'relevanssi_recency_bonus', 'relevanssi_punctuation', 'relevanssi_related_style', 'relevanssi_related_settings', 'relevanssi_synonyms', 'relevanssi_body_stopwords', 'relevanssi_stopwords', 'relevanssi_spamblock', ), true ) ) { // The options are associative arrays that are translated to // objects in JSON and need to be changed back to arrays. $value = (array) $value; } if ( 'relevanssi_redirects' === $key ) { $value = json_decode( wp_json_encode( $value ), true ); } update_option( $key, $value ); } echo "
" . esc_html__( 'Options updated!', 'relevanssi' ) . '
'; } /** * Updates Relevanssi Premium options. * * @global array $relevanssi_variables Relevanssi global variables, used to * access the plugin file name. * * Reads in the options from $_REQUEST and updates the correct options, * depending on which tab has been active. */ function relevanssi_update_premium_options() { global $relevanssi_variables; check_admin_referer( plugin_basename( $relevanssi_variables['file'] ), 'relevanssi_options' ); $request = $_REQUEST; // WPCS: Input var okay. if ( ! isset( $request['tab'] ) ) { $request['tab'] = ''; } relevanssi_update_floatval( $request, 'relevanssi_link_boost', true, '0.75' ); if ( empty( $request['relevanssi_api_key'] ) ) { unset( $request['relevanssi_api_key'] ); } if ( 'overview' === $request['tab'] ) { relevanssi_turn_off_options( $request, array( 'relevanssi_do_not_call_home', 'relevanssi_update_translations', 'relevanssi_hide_post_controls', 'relevanssi_show_post_controls', ) ); } if ( 'indexing' === $request['tab'] ) { relevanssi_turn_off_options( $request, array( 'relevanssi_index_pdf_parent', 'relevanssi_index_post_type_archives', 'relevanssi_index_subscribers', 'relevanssi_index_synonyms', 'relevanssi_index_taxonomies', 'relevanssi_index_users', ) ); } if ( 'attachments' === $request['tab'] ) { relevanssi_turn_off_options( $request, array( 'relevanssi_link_pdf_files', 'relevanssi_read_new_files', 'relevanssi_send_pdf_files', ) ); } if ( 'searching' === $request['tab'] ) { if ( isset( $request['relevanssi_recency_bonus'] ) && isset( $request['relevanssi_recency_days'] ) ) { $relevanssi_recency_bonus = array(); $relevanssi_recency_bonus['bonus'] = floatval( $request['relevanssi_recency_bonus'] ); $relevanssi_recency_bonus['days'] = intval( $request['relevanssi_recency_days'] ); update_option( 'relevanssi_recency_bonus', $relevanssi_recency_bonus ); } if ( ! isset( $request['relevanssi_searchblogs_all'] ) ) { $request['relevanssi_searchblogs_all'] = 'off'; } } if ( 'logging' === $request['tab'] ) { relevanssi_turn_off_options( $request, array( 'relevanssi_click_tracking', 'relevanssi_hide_branding', ) ); relevanssi_update_intval( $request, 'relevanssi_trim_click_logs', true, 180 ); } if ( 'excerpts' === $request['tab'] ) { relevanssi_update_intval( $request, 'relevanssi_max_excerpts', true, 1 ); relevanssi_update_intval( $request, 'relevanssi_trim_click_logs', true, 180 ); } if ( 'related' === $request['tab'] ) { $settings = get_option( 'relevanssi_related_settings', relevanssi_related_default_settings() ); $settings['enabled'] = relevanssi_off_or_on( $request, 'relevanssi_related_enabled' ); $settings['number'] = relevanssi_intval( $request, 'relevanssi_related_number' ); $settings['months'] = relevanssi_intval( $request, 'relevanssi_related_months' ); $settings['nothing'] = relevanssi_legal_value( $request, 'relevanssi_related_nothing', array( 'random', 'random_cat' ), 'nothing' ); $settings['notenough'] = relevanssi_legal_value( $request, 'relevanssi_related_notenough', array( 'random', 'random_cat' ), 'nothing' ); $settings['append'] = relevanssi_implode( $request, 'relevanssi_related_append' ); $settings['post_types'] = ''; if ( isset( $request['relevanssi_related_post_types'] ) && is_array( $request['relevanssi_related_post_types'] ) ) { $settings['post_types'] = implode( ',', $request['relevanssi_related_post_types'] ); if ( false !== stripos( $settings['post_types'], 'matching_post_type' ) ) { $settings['post_types'] = 'matching_post_type'; } } $settings['keyword'] = relevanssi_implode( $request, 'relevanssi_related_keyword' ); $settings['restrict'] = relevanssi_implode( $request, 'relevanssi_related_restrict' ); $settings['cache_for_admins'] = relevanssi_off_or_on( $request, 'relevanssi_related_cache_for_admins' ); update_option( 'relevanssi_related_settings', $settings ); if ( 'off' === $settings['enabled'] ) { relevanssi_flush_related_cache(); } if ( isset( $request['relevanssi_flush_related_cache'] ) && 'off' !== $request['relevanssi_flush_related_cache'] ) { relevanssi_flush_related_cache(); } $style = get_option( 'relevanssi_related_style', relevanssi_related_default_styles() ); $style['width'] = relevanssi_intval( $request, 'relevanssi_related_width' ); $style['excerpts'] = relevanssi_off_or_on( $request, 'relevanssi_related_excerpts' ); $style['titles'] = relevanssi_off_or_on( $request, 'relevanssi_related_titles' ); $style['thumbnails'] = relevanssi_off_or_on( $request, 'relevanssi_related_thumbnails' ); $style['default_thumbnail'] = relevanssi_intval( $request, 'relevanssi_default_thumbnail' ); if ( isset( $request['relevanssi_remove_default_thumbnail'] ) && 'off' !== $request['relevanssi_remove_default_thumbnail'] ) { $style['default_thumbnail'] = 0; } update_option( 'relevanssi_related_style', $style ); } if ( 'spamblock' === $request['tab'] ) { $settings['keywords'] = stripslashes( $request['relevanssi_spamblock_keywords'] ); $settings['regex'] = stripslashes( $request['relevanssi_spamblock_regex'] ); $settings['chinese'] = relevanssi_off_or_on( $request, 'relevanssi_spamblock_chinese' ); $settings['cyrillic'] = relevanssi_off_or_on( $request, 'relevanssi_spamblock_cyrillic' ); $settings['emoji'] = relevanssi_off_or_on( $request, 'relevanssi_spamblock_emoji' ); $settings['bots'] = relevanssi_off_or_on( $request, 'relevanssi_spamblock_bots' ); update_option( 'relevanssi_spamblock', $settings ); } if ( isset( $request['relevanssi_remove_api_key'] ) ) { update_option( 'relevanssi_api_key', '', false ); } relevanssi_update_off_or_on( $request, 'relevanssi_click_tracking', false ); relevanssi_update_off_or_on( $request, 'relevanssi_do_not_call_home', false ); relevanssi_update_off_or_on( $request, 'relevanssi_hide_branding', false ); relevanssi_update_off_or_on( $request, 'relevanssi_hide_post_controls', false ); relevanssi_update_off_or_on( $request, 'relevanssi_index_pdf_parent', false ); relevanssi_update_off_or_on( $request, 'relevanssi_index_post_type_archives', true ); relevanssi_update_off_or_on( $request, 'relevanssi_index_subscribers', false ); relevanssi_update_off_or_on( $request, 'relevanssi_index_synonyms', true ); relevanssi_update_off_or_on( $request, 'relevanssi_index_taxonomies', true ); relevanssi_update_off_or_on( $request, 'relevanssi_index_users', true ); relevanssi_update_off_or_on( $request, 'relevanssi_link_pdf_files', false ); relevanssi_update_off_or_on( $request, 'relevanssi_read_new_files', false ); relevanssi_update_off_or_on( $request, 'relevanssi_searchblogs_all', false ); relevanssi_update_off_or_on( $request, 'relevanssi_send_pdf_files', false ); relevanssi_update_off_or_on( $request, 'relevanssi_show_post_controls', false ); relevanssi_update_off_or_on( $request, 'relevanssi_update_translations', false ); relevanssi_update_sanitized( $request, 'relevanssi_api_key', true ); relevanssi_update_sanitized( $request, 'relevanssi_disable_shortcodes', false ); relevanssi_update_sanitized( $request, 'relevanssi_index_user_fields', false ); relevanssi_update_sanitized( $request, 'relevanssi_internal_links', false ); relevanssi_update_sanitized( $request, 'relevanssi_mysql_columns', false ); relevanssi_update_sanitized( $request, 'relevanssi_searchblogs', false ); relevanssi_update_sanitized( $request, 'relevanssi_thousand_separator', false ); relevanssi_update_legal_value( $request, 'relevanssi_server_location', array( 'us', 'eu' ), 'us', false ); if ( 'redirects' === $request['tab'] ) { $value = relevanssi_process_redirects( $request ); update_option( 'relevanssi_redirects', $value ); } } /** * Adds Relevanssi Premium tabs to Relevanssi settings page. * * @global array $relevanssi_variables Used for the plugin path. * * @param array $tabs The array of tab items. * * @return array The tab array with Premium tabs added. */ function relevanssi_premium_add_tabs( $tabs ) { global $relevanssi_variables; $slugs = wp_list_pluck( $tabs, 'slug' ); $redirects_id = array_search( 'redirects', $slugs, true ); $attachments_id = array_search( 'attachments', $slugs, true ); $tabs[ $redirects_id ] = array( 'slug' => 'redirects', 'name' => __( 'Redirects', 'relevanssi' ), 'require' => dirname( $relevanssi_variables['file'] ) . '/premium/tabs/redirects-tab.php', 'callback' => 'relevanssi_redirects_tab', 'save' => true, ); $tabs[ $attachments_id ] = array( 'slug' => 'attachments', 'name' => __( 'Attachments', 'relevanssi' ), 'require' => dirname( $relevanssi_variables['file'] ) . '/premium/tabs/attachments-tab.php', 'callback' => 'relevanssi_attachments_tab', 'save' => true, ); $tabs[] = array( 'slug' => 'importexport', 'name' => __( 'Import / Export options', 'relevanssi' ), 'require' => dirname( $relevanssi_variables['file'] ) . '/premium/tabs/import-export-tab.php', 'callback' => 'relevanssi_import_export_tab', 'save' => true, ); $tabs[] = array( 'slug' => 'related', 'name' => __( 'Related', 'relevanssi' ), 'require' => dirname( $relevanssi_variables['file'] ) . '/premium/tabs/related-tab.php', 'callback' => 'relevanssi_related_tab', 'save' => true, ); $tabs[] = array( 'slug' => 'spamblock', 'name' => __( 'Spam Block', 'relevanssi' ), 'require' => dirname( $relevanssi_variables['file'] ) . '/premium/tabs/spamblock-tab.php', 'callback' => 'relevanssi_spamblock_tab', 'save' => true, ); $tabs[] = array( 'slug' => 'support', 'name' => __( 'Support', 'relevanssi' ), 'require' => dirname( $relevanssi_variables['file'] ) . '/premium/tabs/support-tab.php', 'callback' => 'relevanssi_support_tab', 'save' => false, ); return $tabs; } /** * Handles the "Reset relevanssi_words" functionality on the debugging tab. */ function relevanssi_form_reset_words() { $text = esc_attr__( 'Reset the option', 'relevanssi' ); $reset = <<

EOH; if ( isset( $_REQUEST['relevanssi_words'] ) ) { wp_verify_nonce( '_relevanssi_nonce', 'relevanssi_how_relevanssi_sees' ); $success = delete_option( 'relevanssi_words' ); if ( $success ) { $reset = '

' . esc_html__( 'Option successfully reset!', 'relevanssi' ) . '

'; } else { $reset = '

' . esc_html__( "Couldn't reset the option, reload the page to try again.", 'relevanssi' ) . '

'; } } $words = get_option( 'relevanssi_words', false ); if ( ! $words ) { $word_text = sprintf( // Translators: %1$s is relevanssi_words. esc_html__( 'The %1$s option doesn\'t exist. You can\'t reset it; it should be regenerated when you search for something.', 'relevanssi' ), 'relevanssi_words' ); } elseif ( isset( $words['words'] ) && isset( $words['expire'] ) ) { $word_count = count( $words['words'] ); $word_text = sprintf( // Translators: %1$s is relevanssi_words, %2$d is the number of words in the option, %3$s is the expiration date of the option. esc_html__( 'The %1$s option has %2$d words in it and the cache expires on %3$s.', 'relevanssi' ), 'relevanssi_words', $word_count, date_i18n( get_option( 'date_format' ), $words['expire'] ) ); } else { $word_text = sprintf( // Translators: %1$s is relevanssi_words. esc_html__( 'The %1$s option is empty.', 'relevanssi' ), 'relevanssi_words' ); } ?>

relevanssi_words. esc_html__( 'If you are having problems with the Did you mean? feature, you can reset the %1$s option that keeps a cache. Next time the Did you mean? suggestions are needed the option is regenerated.', 'relevanssi' ), 'relevanssi_words' ); ?>


' . $message; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Generates a message giving the reason for API key and license problems. * * @return string The message. */ function relevanssi_get_api_key_notification() { global $relevanssi_variables; $api_key = get_network_option( null, 'relevanssi_api_key' ); if ( ! $api_key ) { $api_key = get_option( 'relevanssi_api_key' ); } if ( ! $api_key ) { $url = add_query_arg( 'page', 'relevanssi-premium%2Frelevanssi.php', get_admin_url() . 'options-general.php' ); if ( is_plugin_active_for_network( plugin_basename( $relevanssi_variables['file'] ) ) ) { $url = network_admin_url( 'admin.php?page=relevanssi-premium%2Frelevanssi.php' ); } $message = sprintf( // Translators: %1$s opens the link to the Relevanssi Premium settings page, %3$s opens the link to the Relevanssi Premium license purchase page. %2$s closes the links. esc_html__( "The API key is not set. Please enter your API key in the %1\$sthe Relevanssi settings%2\$s. If you don't have one, %3\$syou can buy a new license here%2\$s.", 'relevanssi' ), '', '', '' ); } else { $message = sprintf( // Translators: %1$s opens the link to the Relevanssi Premium license purchase page. %2$s closes the link. esc_html__( "Your API key is set, but it looks like you don't have a valid license. %1\$sYou can buy a new license here%2\$s.", 'relevanssi' ), '', '' ); } return $message; } /** * Adds the Relevanssi columns to the post list. * * @param array $columns The columns. * @param string $post_type The post type. */ function relevanssi_manage_columns( $columns, $post_type = 'page' ) { $post_types = get_option( 'relevanssi_index_post_types', array() ); if ( ! in_array( $post_type, $post_types, true ) ) { return $columns; } $columns['pinned_keywords'] = __( 'Pinned keywords', 'relevanssi' ); $columns['unpinned_keywords'] = __( 'Excluded keywords', 'relevanssi' ); $columns['pin_for_all'] = __( 'Pin for all searches', 'relevanssi' ); $columns['exclude_post'] = __( 'Exclude post', 'relevanssi' ); $columns['ignore_content'] = __( 'Ignore post content', 'relevanssi' ); return $columns; } /** * Adds the Relevanssi Premium columns to the post list. * * @param array $column The column name. * @param int $post_id The post ID. */ function relevanssi_manage_custom_column( $column, $post_id ) { switch ( $column ) { case 'pinned_keywords': $keywords = get_post_meta( $post_id, '_relevanssi_pin_keywords', true ); if ( ! empty( $keywords ) ) { echo esc_html( $keywords ); } break; case 'unpinned_keywords': $keywords = get_post_meta( $post_id, '_relevanssi_unpin_keywords', true ); if ( ! empty( $keywords ) ) { echo esc_html( $keywords ); } break; case 'pin_for_all': $pin_for_all = get_post_meta( $post_id, '_relevanssi_pin_for_all', true ); if ( ! empty( $pin_for_all ) ) { echo '✓'; } else { echo '✗'; } break; case 'exclude_post': $hide_post = get_post_meta( $post_id, '_relevanssi_hide_post', true ); if ( ! empty( $hide_post ) ) { echo '✓'; } else { echo '✗'; } break; case 'ignore_content': $hide_content = get_post_meta( $post_id, '_relevanssi_hide_content', true ); if ( ! empty( $hide_content ) ) { echo '✓'; } else { echo '✗'; } break; } } /** * Adds the Relevanssi custom fields to the quick edit box. * * @param string $column The column name. */ function relevanssi_quick_edit_custom_box( $column ) { switch ( $column ) { case 'pinned_keywords': ?>