/**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     if (WPSOLR_Global::getOption()->get_search_is_replace_default_wp_search() && WPSOLR_Global::getOption()->get_search_is_use_current_theme_search_template() && WPSOLR_Query_Parameters::is_wp_search()) {
         echo $args['before_widget'];
         $results = WPSOLR_Global::getSolrClient()->display_results(WPSOLR_Global::getQuery());
         echo '<div id="res_facets">' . WPSOLR_UI_Facets::Build(WPSOLR_Data_Facets::get_data(WPSOLR_Global::getQuery()->get_filter_query_fields_group_by_name(), WPSOLR_Global::getOption()->get_facets_to_display(), $results[1]), OptionLocalization::get_options()) . '</div>';
         echo $args['after_widget'];
     }
 }
function return_solr_results()
{
    $final_result = WPSOLR_Global::getSolrClient()->display_results(WPSOLR_Global::getQuery());
    // Add result rows as html
    $res1[] = $final_result[3];
    // Add pagination html
    $total = $final_result[2];
    $number_of_res = WPSOLR_Global::getOption()->get_search_max_nb_results_by_page();
    $paginat_var = '';
    if ($total > $number_of_res) {
        $pages = ceil($total / $number_of_res);
        $paginat_var .= '<ul id="pagination-flickr"class="wdm_ul">';
        for ($k = 1; $k <= $pages; $k++) {
            $paginat_var .= "<li ><a class='paginate' href='javascript:void(0)' id='{$k}'>{$k}</a></li>";
        }
        $paginat_var .= '</ul>';
    }
    $res1[] = $paginat_var;
    // Add results infos html ('showing x to y results out of n')
    $res1[] = $final_result[4];
    // Add facets data
    $res1[] = WPSOLR_UI_Facets::Build(WPSOLR_Data_Facets::get_data(WPSOLR_Global::getQuery()->get_filter_query_fields_group_by_name(), WPSOLR_Global::getOption()->get_facets_to_display(), $final_result[1]), OptionLocalization::get_options());
    // Output Json response to Ajax call
    echo json_encode($res1);
    die;
}
<?php

/**
 * Included file to display admin options
 */
global $license_manager;
WpSolrExtensions::require_once_wpsolr_extension(WpSolrExtensions::OPTION_LOCALIZATION, true);
$options_name = 'wdm_solr_localization_data';
$settings_fields_name = 'solr_localization_options';
// Retrieve all options in database
$options = OptionLocalization::get_options(true);
?>
<div id="localization-options" class="wdm-vertical-tabs-content">
	<form action="options.php" method="POST" id='localization_settings_form'>

		<?php 
settings_fields($settings_fields_name);
$presentation = OptionLocalization::get_presentation_options();
?>

		<div class='wrapper'>
			<h4 class='head_div'>Localization Options</h4>

			<div class="wdm_note">

				In this section, you will configure (localize) all the texts displayed on the front-end forms.<br/>
			</div>

			<div class='wdm_row'>
				<div class='col_left'>
					<?php 
function my_enqueue()
{
    if (!WPSOLR_Global::getOption()->get_search_is_prevent_loading_front_end_css()) {
        wp_enqueue_style('solr_auto_css', plugins_url('css/bootstrap.min.css', __FILE__));
        wp_enqueue_style('solr_frontend', plugins_url('css/style.css', __FILE__));
    }
    wp_enqueue_script('solr_auto_js1', plugins_url('js/bootstrap-typeahead.js', __FILE__), array('jquery'), false, true);
    // Url utilities to manipulate the url parameters
    wp_enqueue_script('urljs', plugins_url('bower_components/jsurl/url.min.js', __FILE__), array('jquery'), false, true);
    wp_enqueue_script('autocomplete', plugins_url('js/autocomplete_solr.js', __FILE__), array('solr_auto_js1', 'urljs'), false, true);
    wp_localize_script('autocomplete', 'wp_localize_script_autocomplete', array('ajax_url' => admin_url('admin-ajax.php'), 'is_show_url_parameters' => WPSOLR_Global::getOption()->get_search_is_ajax_with_url_parameters(), 'is_url_redirect' => WPSOLR_Global::getOption()->get_search_is_use_current_theme_search_template(), 'SEARCH_PARAMETER_SEARCH' => WPSOLR_Query_Parameters::SEARCH_PARAMETER_SEARCH, 'SEARCH_PARAMETER_Q' => WPSOLR_Query_Parameters::SEARCH_PARAMETER_Q, 'SEARCH_PARAMETER_FQ' => WPSOLR_Query_Parameters::SEARCH_PARAMETER_FQ, 'SEARCH_PARAMETER_SORT' => WPSOLR_Query_Parameters::SEARCH_PARAMETER_SORT, 'SEARCH_PARAMETER_PAGE' => WPSOLR_Query_Parameters::SEARCH_PARAMETER_PAGE, 'SORT_CODE_BY_RELEVANCY_DESC' => WPSolrSearchSolrClient::SORT_CODE_BY_RELEVANCY_DESC));
    /*
     * Infinite scroll: load javascript if option is set.
     */
    if (WPSOLR_Global::getOption()->get_search_is_infinitescroll()) {
        // Get localization options
        $localization_options = OptionLocalization::get_options();
        wp_register_script('infinitescroll', plugins_url('/js/jquery.infinitescroll.js', __FILE__), array('jquery'), '1.0', true);
        wp_enqueue_script('infinitescroll');
        // loadingtext for translation
        // loadimage custom loading image url
        wp_localize_script('infinitescroll', 'wp_localize_script_infinitescroll', array('ajax_url' => admin_url('admin-ajax.php'), 'loadimage' => plugins_url('/images/infinitescroll.gif', __FILE__), 'loadingtext' => OptionLocalization::get_term($localization_options, 'infinitescroll_loading'), 'SEARCH_PARAMETER_Q' => WPSOLR_Query_Parameters::SEARCH_PARAMETER_Q));
    }
}
 /**
  *
  * @param WPSOLR_Query $wpsolr_query
  *
  * @return array Array of html
  */
 public function display_results(WPSOLR_Query $wpsolr_query)
 {
     $output = array();
     $search_result = array();
     // Load options
     $localization_options = OptionLocalization::get_options();
     $resultset = $this->execute_wpsolr_query($wpsolr_query);
     $found = $resultset->getNumFound();
     // No results: try a new query if did you mean is activated
     if ($found === 0 && WPSOLR_Global::getOption()->get_search_is_did_you_mean()) {
         // Add spellcheck to current solarium query
         $spell_check = $this->solarium_query->getSpellcheck();
         $spell_check->setCount(10);
         $spell_check->setCollate(true);
         $spell_check->setExtendedResults(true);
         $spell_check->setCollateExtendedResults(true);
         // Excecute the query modified
         $resultset = $this->execute_solarium_query();
         // Parse spell check results
         $spell_check_results = $resultset->getSpellcheck();
         if ($spell_check_results && !$spell_check_results->getCorrectlySpelled()) {
             $collations = $spell_check_results->getCollations();
             $queryTermsCorrected = $wpsolr_query->get_wpsolr_query();
             // original query
             foreach ($collations as $collation) {
                 foreach ($collation->getCorrections() as $input => $correction) {
                     $queryTermsCorrected = str_replace($input, is_array($correction) ? $correction[0] : $correction, $queryTermsCorrected);
                 }
             }
             if ($queryTermsCorrected != $wpsolr_query->get_wpsolr_query()) {
                 $err_msg = sprintf(OptionLocalization::get_term($localization_options, 'results_header_did_you_mean'), $queryTermsCorrected) . '<br/>';
                 $search_result[] = $err_msg;
                 // Execute query with spelled terms
                 $this->solarium_query->setQuery($queryTermsCorrected);
                 try {
                     $resultset = $this->execute_solarium_query();
                     $found = $resultset->getNumFound();
                 } catch (Exception $e) {
                     // Sometimes, the spelling query returns errors
                     // java.lang.StringIndexOutOfBoundsException: String index out of range: 15\n\tat java.lang.AbstractStringBuilder.charAt(AbstractStringBuilder.java:203)\n\tat
                     // java.lang.StringBuilder.charAt(StringBuilder.java:72)\n\tat org.apache.solr.spelling.SpellCheckCollator.getCollation(SpellCheckCollator.java:164)\n\tat
                     $found = 0;
                 }
             } else {
                 $search_result[] = 0;
             }
         } else {
             $search_result[] = 0;
         }
     } else {
         $search_result[] = 0;
     }
     // Retrieve facets from resultset
     $facets_to_display = WPSOLR_Global::getOption()->get_facets_to_display();
     if (count($facets_to_display)) {
         foreach ($facets_to_display as $facet) {
             $fact = strtolower($facet);
             if (WpSolrSchema::_FIELD_NAME_CATEGORIES === $fact) {
                 $fact = WpSolrSchema::_FIELD_NAME_CATEGORIES_STR;
             }
             $facet_res = $resultset->getFacetSet()->getFacet("{$fact}");
             foreach ($facet_res as $value => $count) {
                 $output[$facet][] = array($value, $count);
             }
         }
         $search_result[] = $output;
     } else {
         $search_result[] = 0;
     }
     $search_result[] = $found;
     $results = array();
     $highlighting = $resultset->getHighlighting();
     $i = 1;
     $cat_arr = array();
     $are_comments_indexed = WPSOLR_Global::getOption()->get_index_are_comments_indexed();
     foreach ($resultset as $document) {
         $id = $document->id;
         $title = $document->title;
         $content = '';
         $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($id));
         $no_comments = $document->numcomments;
         if ($are_comments_indexed) {
             $comments = $document->comments;
         }
         $date = date('m/d/Y', strtotime($document->displaydate));
         if (property_exists($document, 'categories_str')) {
             $cat_arr = $document->categories_str;
         }
         $cat = implode(',', $cat_arr);
         $auth = $document->author;
         $url = get_permalink($id);
         $highlightedDoc = $highlighting->getResult($document->id);
         $cont_no = 0;
         $comm_no = 0;
         if ($highlightedDoc) {
             foreach ($highlightedDoc as $field => $highlight) {
                 if ($field == WpSolrSchema::_FIELD_NAME_TITLE) {
                     $title = implode(' (...) ', $highlight);
                 } else {
                     if ($field == WpSolrSchema::_FIELD_NAME_CONTENT) {
                         $content = implode(' (...) ', $highlight);
                     } else {
                         if ($field == WpSolrSchema::_FIELD_NAME_COMMENTS) {
                             $comments = implode(' (...) ', $highlight);
                             $comm_no = 1;
                         }
                     }
                 }
             }
         }
         $msg = '';
         $msg .= "<div id='res{$i}'><div class='p_title'><a href='{$url}'>{$title}</a></div>";
         $image_fragment = '';
         // Display first image
         if (is_array($image_url) && count($image_url) > 0) {
             $image_fragment .= "<img class='wdm_result_list_thumb' src='{$image_url['0']}' />";
         }
         if (empty($content)) {
             // Set a default value for content if no highlighting returned.
             $post_to_show = get_post($id);
             if (isset($post_to_show)) {
                 // Excerpt first, or content.
                 $content = !empty($post_to_show->post_excerpt) ? $post_to_show->post_excerpt : $post_to_show->post_content;
                 if (isset($ind_opt['is_shortcode_expanded']) && strpos($content, '[solr_search_shortcode]') === false) {
                     // Expand shortcodes which have a plugin active, and are not the search form shortcode (else pb).
                     global $post;
                     $post = $post_to_show;
                     $content = do_shortcode($content);
                 }
                 // Remove shortcodes tags remaining, but not their content.
                 // strip_shortcodes() does nothing, probably because shortcodes from themes are not loaded in admin.
                 // Credit: https://wordpress.org/support/topic/stripping-shortcodes-keeping-the-content.
                 // Modified to enable "/" in attributes
                 $content = preg_replace("~(?:\\[/?)[^\\]]+/?\\]~s", '', $content);
                 # strip shortcodes, keep shortcode content;
                 // Strip HTML and PHP tags
                 $content = strip_tags($content);
                 if (isset($res_opt['highlighting_fragsize']) && is_numeric($res_opt['highlighting_fragsize'])) {
                     // Cut content at the max length defined in options.
                     $content = substr($content, 0, $res_opt['highlighting_fragsize']);
                 }
             }
         }
         // Format content text a little bit
         $content = str_replace('&nbsp;', '', $content);
         $content = str_replace('  ', ' ', $content);
         $content = ucfirst(trim($content));
         $content .= '...';
         //if ( $cont_no == 1 ) {
         if (false) {
             $msg .= "<div class='p_content'>{$image_fragment} {$content} - <a href='{$url}'>Content match</a></div>";
         } else {
             $msg .= "<div class='p_content'>{$image_fragment} {$content}</div>";
         }
         if ($comm_no == 1) {
             $msg .= "<div class='p_comment'>" . $comments . "-<a href='{$url}'>Comment match</a></div>";
         }
         // Groups bloc - Bottom right
         $wpsolr_groups_message = apply_filters(WpSolrFilters::WPSOLR_FILTER_SOLR_RESULTS_DOCUMENT_GROUPS_INFOS, get_current_user_id(), $document);
         if (isset($wpsolr_groups_message)) {
             // Display groups of this user which owns at least one the document capability
             $message = $wpsolr_groups_message['message'];
             $msg .= "<div class='p_misc'>{$message}";
             $msg .= "</div>";
             $msg .= '<br/>';
         }
         // Informative bloc - Bottom right
         $msg .= "<div class='p_misc'>";
         if (WPSOLR_Global::getOption()->get_is_display_author()) {
             $msg .= "<span class='pauthor'>" . sprintf(OptionLocalization::get_term($localization_options, 'results_row_by_author'), $auth) . "</span>";
         }
         if (WPSOLR_Global::getOption()->get_is_display_category()) {
             $msg .= empty($cat) ? "" : "<span class='pcat'>" . sprintf(OptionLocalization::get_term($localization_options, 'results_row_in_category'), $cat) . "</span>";
         }
         if (WPSOLR_Global::getOption()->get_is_display_date()) {
             $msg .= "<span class='pdate'>" . sprintf(OptionLocalization::get_term($localization_options, 'results_row_on_date'), $date) . "</span>";
         }
         if (WPSOLR_Global::getOption()->get_is_display_comments()) {
             $msg .= empty($no_comments) ? "" : "<span class='pcat'>" . sprintf(OptionLocalization::get_term($localization_options, 'results_row_number_comments'), $no_comments) . "</span>";
         }
         $msg .= "</div>";
         // End of snippet bloc
         $msg .= "</div><hr>";
         array_push($results, $msg);
         $i = $i + 1;
     }
     //  $msg.='</div>';
     if (count($results) < 0) {
         $search_result[] = 0;
     } else {
         $search_result[] = $results;
     }
     $fir = $wpsolr_query->get_start() + 1;
     $last = $wpsolr_query->get_start() + $wpsolr_query->get_nb_results_by_page();
     if ($last > $found) {
         $last = $found;
     }
     $search_result[] = "<span class='infor'>" . sprintf(OptionLocalization::get_term($localization_options, 'results_header_pagination_numbers'), $fir, $last, $found) . "</span>";
     return $search_result;
 }