static function create_from_index_indice($index_indice) { // Build Solarium config from the default indexing Solr index WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_INDEXES, true); $options_indexes = new OptionIndexes(); $solarium_config = $options_indexes->build_solarium_config($index_indice, null, self::DEFAULT_SOLR_TIMEOUT_IN_SECOND); return new self($solarium_config); }
public function __construct($solr_index_indice = null, $language_code = null) { // Load active extensions $this->wpsolr_extensions = new WpSolrExtensions(); $path = plugin_dir_path(__FILE__) . '../../vendor/autoload.php'; require_once $path; // Load options $this->solr_indexing_options = get_option('wdm_solr_form_data'); // Build Solarium config from the default indexing Solr index WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_INDEXES, true); $options_indexes = new OptionIndexes(); $config = $options_indexes->build_solarium_config($solr_index_indice, $language_code, self::DEFAULT_SOLR_TIMEOUT_IN_SECOND); $this->index_indice = $solr_index_indice; $this->solarium_client = new Solarium\Client($config); }
<?php /** * Included file to display admin options */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_LICENSES, true); // Options name $option_name = OptionLicenses::get_option_name(WpSolrExtensions::OPTION_LICENSES); // Options object $license_manager = new OptionLicenses(); ?> <script> jQuery(document).on("click", "#<?php echo OptionLicenses::AJAX_VERIFY_LICENCE; ?> , #<?php echo OptionLicenses::AJAX_ACTIVATE_LICENCE; ?> , #<?php echo OptionLicenses::AJAX_DEACTIVATE_LICENCE; ?> ", function (e) { // Remember this for ajax var current = this; // Show progress var button_clicked = jQuery(this); var button_form = button_clicked.parents('.wpsolr_form_license'); var buttonText = button_clicked.val(); // Remmember button text
<?php /** * Included file to display admin options */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_TYPES, true); $extension_options_name = 'wdm_solr_extension_types_data'; $settings_fields_name = 'solr_extension_types_options'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_TYPES); $plugin_name = "Types"; $plugin_link = "https://wordpress.org/plugins/types/"; $plugin_version = "(>= 1.8.10)"; if ($is_plugin_active) { $ml_plugin = PluginTypes::create(); } ?> <div id="extension_groups-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_groups_settings_form'> <?php settings_fields('solr_extension_types_options'); $extension_options = get_option($extension_options_name, array('is_extension_active' => '0')); ?> <div class='wrapper'> <h4 class='head_div'><?php echo $plugin_name; ?> plugin Options</h4>
*/ $is_submit_form_logout = isset($_POST['submit-form-logout']); if ($is_submit_form_logout) { // Clear the managed service token $managed_solr_server->set_service_option('token', ''); } /* * Form signin ? */ $is_submit_form_signin = isset($_POST['submit-form-signin']); $form_data = WpSolrExtensions::extract_form_data($is_submit_form_signin, array('email' => array('default_value' => wp_get_current_user()->user_email, 'is_email' => true), 'password' => array('default_value' => '', 'can_be_empty' => false))); if ($is_submit_form_signin) { if (!$form_data['is_error']) { $result_object = $managed_solr_server->call_rest_signin($form_data['email']['value'], $form_data['password']['value']); if (OptionManagedSolrServer::is_response_ok($result_object)) { $token = OptionManagedSolrServer::get_response_result($result_object, 'token'); $managed_solr_server->set_service_option('token', $token); } } } // Display a signin form if ('' != $managed_solr_server->get_service_option('token')) { WpSolrExtensions::require_with(WpSolrExtensions::get_option_template_file(WpSolrExtensions::OPTION_MANAGED_SOLR_SERVERS, 'template-my-accounts.php'), array('form_data' => $form_data, 'managed_solr_server' => $managed_solr_server, 'option_name' => $option_name)); } else { WpSolrExtensions::require_with(WpSolrExtensions::get_option_template_file(WpSolrExtensions::OPTION_MANAGED_SOLR_SERVERS, 'template-signin-form.php'), array('form_data' => $form_data, 'managed_solr_server' => $managed_solr_server, 'option_name' => $option_name)); } break; } ?>
<?php // Load WPML class for inheritance WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_WPML, true); /** * Class PluginPolylang * * Manage Polylang plugin * @link https://polylang.wordpress.com/documentation/ */ class PluginPolylang extends PluginWpml { const _PLUGIN_NAME_IN_MESSAGES = 'Polylang'; /* * Polylang database constants */ const TABLE_TERM_RELATION_SHIPS = "term_relationships"; // Polylang options const _OPTIONS_NAME = 'wdm_solr_extension_polylang_data'; /** * Factory * * @return PluginWpml */ static function create() { return new self(); } /* * Constructor * Subscribe to actions
<?php /** * Included file to display admin options */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_S2MEMBER, true); PluginS2Member::update_custom_field_capabilities(PluginS2Member::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES); $extension_options_name = 'wdm_solr_extension_s2member_data'; $settings_fields_name = 'solr_extension_s2member_options'; $array_extension_options = get_option($extension_options_name); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_S2MEMBER); $is_plugin_custom_field_for_indexing = PluginS2Member::get_custom_field_capabilities(PluginS2Member::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES); $custom_field_for_indexing_name = PluginS2Member::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES; $plugin_name = "s2member"; ?> <div id="extension_s2member-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_s2member_settings_form'> <?php settings_fields($settings_fields_name); $solr_extension_s2member_options = get_option($extension_options_name, array('is_extension_active' => '0', 'is_users_without_capabilities_see_all_results' => '0', 'is_result_without_capabilities_seen_by_all_users' => '0', 'message_user_without_capabilities_shown_no_results' => '', 'message_result_capability_matches_user_group' => '')); ?> <div class='wrapper'> <h4 class='head_div'>s2Member plugin Options</h4> <div class="wdm_note"> In this section, you will configure how to restrict Solr search with levels and capabilities.<br/>
<?php /** * Included file to display admin options */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_QTRANSLATEX, true); WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_INDEXES, true); $extension_options_name = 'wdm_solr_extension_qtranslatex_data'; $settings_fields_name = 'solr_extension_qtranslatex_options'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_QTRANSLATEX); $plugin_name = "qTranslate X"; $plugin_link = "https://wordpress.org/plugins/qtranslate-x/"; $plugin_version = ""; if ($is_plugin_active) { $ml_plugin = PluginQTranslateX::create(); } ?> <?php include_once WpSolrExtensions::get_option_file(WpSolrExtensions::EXTENSION_WPML, 'template.inc.php');
<?php /** * Included file to display admin options */ global $license_manager; WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_WOOCOMMERCE, true); $extension_options_name = 'wdm_solr_extension_woocommerce_data'; $settings_fields_name = 'solr_extension_woocommerce_options'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_WOOCOMMERCE); $plugin_name = "WooCommerce"; $plugin_link = "https://wordpress.org/plugins/woocommerce/"; $plugin_version = "(>= 2.4.10)"; if ($is_plugin_active) { $ml_plugin = PluginWooCommerce::create(); } ?> <div id="extension_groups-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_groups_settings_form'> <?php settings_fields('solr_extension_woocommerce_options'); $extension_options = get_option($extension_options_name, array('is_extension_active' => '0')); ?> <div class='wrapper'> <h4 class='head_div'><?php echo $plugin_name; ?> plugin Options</h4>
<?php /** * Included file to display admin options */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_WPML, true); WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_INDEXES, true); $extension_options_name = 'wdm_solr_extension_wpml_data'; $settings_fields_name = 'solr_extension_wpml_options'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_WPML); $plugin_name = "WPML"; $plugin_link = "https://wpml.org/"; $plugin_version = "(WPML Multilingual CMS > 3.1.6)"; $ml_plugin = PluginWpml::create(); ?> <?php include_once 'template.inc.php';
<?php /** * Included file to display admin options */ global $license_manager; WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_EMBED_ANY_DOCUMENT, true); $extension_options_name = WPSOLR_Option::OPTION_EMBED_ANY_DOCUMENT; $settings_fields_name = 'extension_embed_any_document_opt'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_EMBED_ANY_DOCUMENT); $plugin_name = "Embed Any Document"; $plugin_link = "https://wordpress.org/plugins/embed-any-document/"; $plugin_version = "(>= 2.2.5)"; ?> <div id="extension_groups-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_groups_settings_form'> <?php settings_fields('extension_embed_any_document_opt'); $extension_options = get_option($extension_options_name, array('is_extension_active' => '0')); ?> <div class='wrapper'> <h4 class='head_div'><?php echo $plugin_name; ?> plugin Options</h4> <div class="wdm_note">
<?php include dirname(__FILE__) . '/classes/solr/wpsolr-index-solr-client.php'; include dirname(__FILE__) . '/classes/solr/wpsolr-search-solr-client.php'; include dirname(__FILE__) . '/classes/ui/WPSOLR_Data_facets.php'; // Load localization class WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_LOCALIZATION, true); WpSolrExtensions::load(); function solr_format_date($thedate) { $datere = '/(\\d{4}-\\d{2}-\\d{2})\\s(\\d{2}:\\d{2}:\\d{2})/'; $replstr = '${1}T${2}Z'; return preg_replace($datere, $replstr, $thedate); } function fun_search_indexed_data() { $ad_url = admin_url(); // Retrieve search form page url $get_page_info = WPSolrSearchSolrClient::get_search_page(); $url = get_permalink($get_page_info->ID); // Filter the search page url. Used for multi-language search forms. $url = apply_filters(WpSolrFilters::WPSOLR_FILTER_SEARCH_PAGE_URL, $url, $get_page_info->ID); // Load localization options $localization_options = OptionLocalization::get_options(); $wdm_typehead_request_handler = 'wdm_return_solr_rows'; echo "<div class='cls_search' style='width:100%'> <form action='{$url}' method='get' class='search-frm' >"; echo '<input type="hidden" value="' . $wdm_typehead_request_handler . '" id="path_to_fold">'; echo '<input type="hidden" value="' . $ad_url . '" id="path_to_admin">'; echo '<input type="hidden" value="' . WPSOLR_Global::getQuery()->get_wpsolr_query() . '" id="search_opt">'; $ajax_nonce = wp_create_nonce("nonce_for_autocomplete"); echo $form = '
$subtabs['new_index'] = count($option_object->get_indexes()) > 0 ? $license_manager->show_premium_link(OptionLicenses::LICENSE_PACKAGE_CORE, 'Configure another index', false) : 'Configure your first index'; // Create subtabs on the left side $subtab = wpsolr_admin_sub_tabs($subtabs); ?> <div id="solr-results-options" class="wdm-vertical-tabs-content"> <?php $is_new_index = false; if ('new_index' === $subtab) { $is_new_index = true; $subtab = $option_object->generate_uuid(); $option_data['solr_indexes'][$subtab] = array(); if (!$option_object->has_index_type_temporary()) { // No temporary index yet: display the form to create one. WpSolrExtensions::require_with(WpSolrExtensions::get_option_template_file(WpSolrExtensions::OPTION_MANAGED_SOLR_SERVERS, 'template-temporary-account-form.php'), array('managed_solr_service_id' => $form_data['managed_solr_service_id']['value'], 'response_error' => isset($response_object) && !OptionManagedSolrServer::is_response_ok($response_object) ? OptionManagedSolrServer::get_response_error_message($response_object) : '', 'google_recaptcha_site_key' => isset($google_recaptcha_site_key) ? $google_recaptcha_site_key : '', 'google_recaptcha_token' => isset($google_recaptcha_token) ? $google_recaptcha_token : '', 'total_nb_indexes' => $option_object->get_nb_indexes())); } } else { // Verify that current subtab is a Solr index indice. if (!$option_object->has_index($subtab)) { // Use the first subtab element $subtab = key($subtabs); } } ?> <form action="options.php" method="POST" id='settings_conf_form'> <?php settings_fields($option_name);
<?php /** * Included file to display admin options */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_GROUPS, true); PluginGroups::update_custom_field_capabilities(PluginGroups::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES); $array_extension_options = get_option('wdm_solr_extension_groups_data'); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_GROUPS); $is_plugin_custom_field_for_indexing = PluginGroups::get_custom_field_capabilities(PluginGroups::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES); $custom_field_for_indexing_name = PluginGroups::CUSTOM_FIELD_NAME_STORING_POST_CAPABILITIES; $plugin_name = "Groups"; ?> <div id="extension_groups-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_groups_settings_form'> <?php settings_fields('solr_extension_groups_options'); $solr_extension_groups_options = get_option('wdm_solr_extension_groups_data', array('is_extension_active' => '0', 'is_users_without_groups_see_all_results' => '0', 'is_result_without_capabilities_seen_by_all_users' => '0', 'message_user_without_groups_shown_no_results' => '', 'message_result_capability_matches_user_group' => '')); ?> <div class='wrapper'> <h4 class='head_div'>Groups plugin Options</h4> <div class="wdm_note"> In this section, you will configure how to restrict Solr search with groups and capabilities.<br/> <?php if (!$is_plugin_active) {
function wpsolr_admin_tabs($current = 'solr_indexes') { // Get default search solr index indice WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_INDEXES, true); $option_indexes = new OptionIndexes(); $default_search_solr_index = $option_indexes->get_default_search_solr_index(); $nb_indexes = count($option_indexes->get_indexes()); $are_there_indexes = $nb_indexes > 0; $tabs = array(); $tabs['solr_indexes'] = $are_there_indexes ? '1. Define your Solr Indexes' : '1. Define your Solr Index'; if ($are_there_indexes) { $tabs['solr_option'] = sprintf("2. Define your search with '%s'", !isset($default_search_solr_index) ? $are_there_indexes ? "<span class='text_error'>No index selected</span>" : '' : $option_indexes->get_index_name($default_search_solr_index)); $tabs['solr_plugins'] = '3. Define which plugins to work with'; $tabs['solr_operations'] = '4. Send your data'; } echo '<div id="icon-themes" class="icon32"><br></div>'; echo '<h2 class="nav-tab-wrapper">'; foreach ($tabs as $tab => $name) { $class = $tab == $current ? ' nav-tab-active' : ''; echo "<a class='nav-tab{$class}' href='admin.php?page=solr_settings&tab={$tab}'>{$name}</a>"; } echo '</h2>'; }
<?php /** * Included file to display admin options */ global $license_manager; WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_BBPRESS, true); $extension_options_name = 'wdm_solr_extension_bbpress_data'; $settings_fields_name = 'solr_extension_bbpress_options'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_BBPRESS); $plugin_name = "bbPress"; $plugin_link = "https://wordpress.org/plugins/bbpress/"; $plugin_version = "(>= 2.5.10)"; ?> <div id="extension_groups-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_groups_settings_form'> <?php settings_fields('solr_extension_bbpress_options'); $extension_options = get_option($extension_options_name, array('is_extension_active' => '0')); ?> <div class='wrapper'> <h4 class='head_div'><?php echo $plugin_name; ?> plugin Options</h4> <div class="wdm_note">
value="Logout from <?php echo $managed_solr_server->get_label(); ?> "/> </form> </div> </h4> <?php // Add menu items for all the managed Solr accounts $subtabs = array(); $result_object = $managed_solr_server->call_rest_list_accounts(); if (OptionManagedSolrServer::is_response_ok($result_object)) { foreach ($managed_solr_server->get_response_results($result_object) as $result) { $subtabs[$managed_solr_server->get_id() . ':' . $result->uuid] = $result->label; } } // Display menu $subtab = wpsolr_admin_sub_tabs($subtabs); // Display account detail if account appears in parameters $subtab_exploded = explode(':', $subtab); if (count($subtab_exploded) >= 2) { $account_uuid = $subtab_exploded[1]; $subtab_exploded = explode(':', $subtab); WpSolrExtensions::require_with(WpSolrExtensions::get_option_template_file(WpSolrExtensions::OPTION_MANAGED_SOLR_SERVERS, 'template-my-account-indexes.php'), array('managed_solr_server' => $managed_solr_server, 'account_uuid' => $account_uuid)); } ?> </div> </div>
function my_register_activation_hook() { /* * Migrate old data on plugin update */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_INDEXES, true); $option_object = new OptionIndexes(); $option_object->migrate_data_from_v4_9(); }
<?php /** * Included file to display admin options */ global $license_manager; WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_PDF_EMBEDDER, true); $extension_options_name = WPSOLR_Option::OPTION_PDF_EMBEDDER; $settings_fields_name = 'extension_pdf_embedder_opt'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_PDF_EMBEDDER); $plugin_name = "PDF Embedder"; $plugin_link = "https://wordpress.org/plugins/pdf-embedder/"; $plugin_version = "(>= 2.7.3)"; ?> <div id="extension_groups-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_groups_settings_form'> <?php settings_fields($settings_fields_name); $extension_options = get_option($extension_options_name, array('is_extension_active' => '0')); ?> <div class='wrapper'> <h4 class='head_div'><?php echo $plugin_name; ?> plugin Options</h4> <div class="wdm_note">
<?php // Load class for inheritance WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_EMBED_ANY_DOCUMENT, true); /** * Class PluginGoogleDocEmbedder * * Manage Google Doc Embedder plugin * @link https://wordpress.org/plugins/google-document-embedder/ */ class PluginGoogleDocEmbedder extends PluginEmbedAnyDocument { const EMBEDDOC_SHORTCODE = 'gview'; const EMBEDDOC_SHORTCODE_ATTRIBUTE_URL = 'file'; protected function set_is_do_embed_documents() { $this->is_do_embed_documents = WPSOLR_Global::getOption()->get_google_doc_embedder_is_do_embed_documents(); } }
function wpsolr_activate() { if (!is_multisite()) { /** * Mark licenses */ WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_LICENSES, true); OptionLicenses::upgrade_licenses(); } }
<?php include WPSOLR_PLUGIN_DIR . '/classes/solr/wpsolr-index-solr-client.php'; include WPSOLR_PLUGIN_DIR . '/classes/solr/wpsolr-search-solr-client.php'; include WPSOLR_PLUGIN_DIR . '/classes/ui/WPSOLR_Data_facets.php'; // Load localization class WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_LOCALIZATION, true); //WpSolrExtensions::load(); function solr_format_date($thedate) { $datere = '/(\\d{4}-\\d{2}-\\d{2})\\s(\\d{2}:\\d{2}:\\d{2})/'; $replstr = '${1}T${2}Z'; return preg_replace($datere, $replstr, $thedate); } function fun_search_indexed_data() { $ad_url = admin_url(); // Retrieve search form page url $get_page_info = WPSolrSearchSolrClient::get_search_page(); $url = get_permalink($get_page_info->ID); // Filter the search page url. Used for multi-language search forms. $url = apply_filters(WpSolrFilters::WPSOLR_FILTER_SEARCH_PAGE_URL, $url, $get_page_info->ID); // Load localization options $localization_options = OptionLocalization::get_options(); $wdm_typehead_request_handler = !empty($_GET['nofacet']) ? 'wdm_return_solr_rows' : 'wdm_return_facet_solr_rows'; echo "<div class='cls_search' style='width:100%'> <form action='{$url}' method='get' class='search-frm' >"; echo '<input type="hidden" value="' . $wdm_typehead_request_handler . '" id="path_to_fold">'; echo '<input type="hidden" value="' . $ad_url . '" id="path_to_admin">'; echo '<input type="hidden" value="' . WPSOLR_Global::getQuery()->get_wpsolr_query() . '" id="search_opt">'; $ajax_nonce = wp_create_nonce("nonce_for_autocomplete"); echo $form = '
<?php /** * Included file to display admin options */ global $license_manager; WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::EXTENSION_GOOGLE_DOC_EMBEDDER, true); $extension_options_name = WPSOLR_Option::OPTION_GOOGLE_DOC_EMBEDDER; $settings_fields_name = 'extension_google_doc_embedder_opt'; $options = get_option($extension_options_name, array('is_extension_active' => '0')); $is_plugin_active = WpSolrExtensions::is_plugin_active(WpSolrExtensions::EXTENSION_GOOGLE_DOC_EMBEDDER); $plugin_name = "Google Doc Embedder"; $plugin_link = "https://wordpress.org/plugins/google-document-embedder/"; $plugin_version = "(>= 2.6)"; ?> <div id="extension_groups-options" class="wdm-vertical-tabs-content"> <form action="options.php" method="POST" id='extension_groups_settings_form'> <?php settings_fields($settings_fields_name); $extension_options = get_option($extension_options_name, array('is_extension_active' => '0')); ?> <div class='wrapper'> <h4 class='head_div'><?php echo $plugin_name; ?> plugin Options</h4> <div class="wdm_note">