/**
  * Create the class
  *
  * @param $params
  */
 function __construct($params)
 {
     $this->params = $params;
     // Pass the general options
     $options = w_isset_def($params['options'], array());
     // Set a few values for faster usage
     $options['set_exactonly'] = isset($params['options']['set_exactonly']) ? true : false;
     $options['set_intitle'] = isset($params['options']['set_intitle']) ? true : false;
     $options['set_incontent'] = isset($params['options']['set_incontent']) ? true : false;
     $options['set_incomments'] = isset($params['options']['set_incomments']) ? true : false;
     $options['set_inexcerpt'] = isset($params['options']['set_inexcerpt']) ? true : false;
     $options['set_inposts'] = isset($params['options']['set_inposts']) ? true : false;
     $options['set_inpages'] = isset($params['options']['set_inpages']) ? true : false;
     $options['searchinterms'] = $params['data']['searchinterms'] == 1 ? true : false;
     $options['set_inbpusers'] = isset($params['options']['set_inbpusers']) ? true : false;
     $options['set_inbpgroups'] = isset($params['options']['set_inbpgroups']) ? true : false;
     $options['set_inbpforums'] = isset($params['options']['set_inbpforums']) ? true : false;
     $options['maxresults'] = $params['data']['maxresults'];
     $options['do_group'] = $params['data']['resultstype'] == 'vertical' ? true : false;
     $this->options = $options;
     $this->searchId = $params['id'];
     $this->searchData = $params['data'];
     if (isset($this->searchData['image_options'])) {
         $this->imageSettings = $this->searchData['image_options'];
     }
 }
 function scripts()
 {
     $prereq = 'wpdreams-asljquery';
     $js_source = 'nomin-scoped';
     $performance_options = get_option('asl_performance');
     $load_in_footer = w_isset_def($performance_options['load_in_footer'], 1) == 1 ? true : false;
     wp_register_script('wpdreams-asljquery', ASL_URL . 'js/' . $js_source . '/asljquery.js', array(), ASL_CURR_VER_STRING, $load_in_footer);
     wp_enqueue_script('wpdreams-asljquery');
     wp_register_script('wpdreams-gestures', ASL_URL . 'js/' . $js_source . '/jquery.gestures.js', array($prereq), ASL_CURR_VER_STRING, $load_in_footer);
     wp_enqueue_script('wpdreams-gestures');
     wp_register_script('wpdreams-easing', ASL_URL . 'js/' . $js_source . '/jquery.easing.js', array($prereq), ASL_CURR_VER_STRING, $load_in_footer);
     wp_enqueue_script('wpdreams-easing');
     wp_register_script('wpdreams-mousewheel', ASL_URL . 'js/' . $js_source . '/jquery.mousewheel.js', array($prereq), ASL_CURR_VER_STRING, $load_in_footer);
     wp_enqueue_script('wpdreams-mousewheel');
     wp_register_script('wpdreams-scroll', ASL_URL . 'js/' . $js_source . '/jquery.mCustomScrollbar.js', array($prereq, 'wpdreams-mousewheel'), ASL_CURR_VER_STRING, $load_in_footer);
     wp_enqueue_script('wpdreams-scroll');
     wp_register_script('wpdreams-ajaxsearchlite', ASL_URL . 'js/' . $js_source . '/jquery.ajaxsearchlite.js', array($prereq, "wpdreams-scroll"), ASL_CURR_VER_STRING, $load_in_footer);
     wp_enqueue_script('wpdreams-ajaxsearchlite');
     wp_register_script('wpdreams-asl-wrapper', ASL_URL . 'js/' . $js_source . '/asl_wrapper.js', array($prereq, "wpdreams-ajaxsearchlite"), ASL_CURR_VER_STRING, $load_in_footer);
     wp_enqueue_script('wpdreams-asl-wrapper');
     $ajax_url = admin_url('admin-ajax.php');
     if (w_isset_def($performance_options['use_custom_ajax_handler'], 0) == 1) {
         $ajax_url = ASL_URL . 'ajax_search.php';
     }
     // @deprecated
     wp_localize_script('wpdreams-ajaxsearchlite', 'ajaxsearchlite', array('ajaxurl' => $ajax_url, 'backend_ajaxurl' => admin_url('admin-ajax.php'), 'js_scope' => 'asljQuery'));
     wp_localize_script('wpdreams-ajaxsearchlite', 'ASL', array('ajaxurl' => $ajax_url, 'backend_ajaxurl' => admin_url('admin-ajax.php'), 'js_scope' => 'asljQuery'));
 }
function asl_search_stylesheets()
{
    // Don't print if on the back-end
    if (!is_admin()) {
        $asl_options = get_option('asl_options');
        wp_register_style('wpdreams-asl-basic', ASL_URL . 'css/style.basic.css', array(), ASL_CURR_VER_STRING);
        wp_enqueue_style('wpdreams-asl-basic');
        wp_enqueue_style('wpdreams-ajaxsearchlite', plugins_url('css/style-' . w_isset_def($asl_options['theme'], 'polaroid') . '.css', dirname(__FILE__)), array(), ASL_CURR_VER_STRING);
    }
}
Example #4
0
 function wpdreams_get_stylesheet($dir, $id, $style)
 {
     ob_start();
     include $dir . "style.css.php";
     $out = ob_get_contents();
     ob_end_clean();
     if (isset($style['custom_css_special']) && isset($style['custom_css_selector']) && $style['custom_css_special'] != "") {
         $out .= " " . stripcslashes(str_replace('[instance]', str_replace('THEID', $id, $style['custom_css_selector']), $style['custom_css_special']));
     }
     if (w_isset_def($style['css_compress'], 0) == 1) {
         return wpdreams_css_compress($out);
     } else {
         return $out;
     }
 }
 function wpdreams_asl_shortcode($atts)
 {
     $style = null;
     self::$instanceCount++;
     extract(shortcode_atts(array('id' => 'something'), $atts));
     $style = get_option('asl_options');
     $def_data = get_option('asl_defaults');
     $style = array_merge($def_data, $style);
     $settingsHidden = w_isset_def($style['show_frontend_search_settings'], 1) == 1 ? false : true;
     do_action('asl_layout_before_shortcode', $id);
     $out = "";
     ob_start();
     include ASL_PATH . "includes/views/asl.shortcode.php";
     $out = ob_get_clean();
     do_action('asl_layout_after_shortcode', $id);
     return $out;
 }
Example #6
0
/**
 * This function handles the index table ajax requests
 */
function asp_indextable_admin_ajax()
{
    if (isset($_POST['data'])) {
        if (is_array($_POST['data'])) {
            $options = $_POST['data'];
        } else {
            parse_str($_POST['data'], $options);
        }
    } else {
        print "No post data detected, function terminated.";
        die;
    }
    $it_obj = new asp_indexTable(array('index_title' => $options['it_index_title'], 'index_content' => $options['it_index_content'], 'index_excerpt' => $options['it_index_excerpt'], 'index_tags' => $options['it_index_tags'], 'index_categories' => $options['it_index_categories'], 'post_types' => $options['it_post_types'], 'post_statuses' => $options['it_post_statuses'], 'index_taxonomies' => $options['it_index_taxonomies'], 'index_custom_fields' => $options['it_index_customfields'], 'index_author_name' => $options['it_index_author_name'], 'index_author_bio' => $options['it_index_author_bio'], 'blog_id' => $_POST['blog_id'], 'extend' => w_isset_def($_POST['asp_index_action'], 'new') == 'extend' ? 1 : 0, 'limit' => $options['it_limit'], 'use_stopwords' => $options['it_use_stopwords'], 'stopwords' => $options['it_stopwords'], 'min_word_length' => $options['it_min_word_length'], 'extract_shortcodes' => $options['it_extract_shortcodes'], 'exclude_shortcodes' => $options['it_exclude_shortcodes']));
    if (isset($_POST['asp_index_action'])) {
        switch ($_POST['asp_index_action']) {
            case 'new':
                $ret = $it_obj->newIndex();
                print "New index !!!ASP_INDEX_START!!!";
                print_r(json_encode($ret));
                print "!!!ASP_INDEX_STOP!!!";
                die;
                break;
            case 'extend':
                $ret = $it_obj->extendIndex();
                print "Extend index !!!ASP_INDEX_START!!!";
                print_r(json_encode($ret));
                print "!!!ASP_INDEX_STOP!!!";
                die;
                break;
            case 'switching_blog':
                $ret = $it_obj->extendIndex(true);
                print "Extend index (blog_switch) !!!ASP_INDEX_START!!!";
                print_r(json_encode($ret));
                print "!!!ASP_INDEX_STOP!!!";
                die;
                break;
            case 'delete':
                $it_obj->emptyIndex();
                print "Delete index !!!ASP_INDEX_START!!!1!!!ASP_INDEX_STOP!!!";
                die;
                break;
        }
    }
    // no action set, or other failure
    print "No action !!!ASP_INDEX_START!!!0!!!ASP_INDEX_STOP!!!";
    die;
}
Example #7
0
    echo '<div class="wpdreams_clear"></div>';
}
/***************** SUGGESTED PHRASES ******************/
if (w_isset_def($style['frontend_show_suggestions'], 0) == 1) {
    $s_phrases = str_replace(array('  ,', ' , ', ', ', ' ,'), '</a>, <a href="#">', $style['frontend_suggestions_keywords']);
    ?>
    <p id="asp-try-<?php 
    echo $id;
    ?>
" class="asp-try"><?php 
    echo $style['frontend_suggestions_text'] . ' <a href="#">' . $s_phrases . '</a>';
    ?>
</p><?php 
}
/******************** DATA INCLUDE ********************/
if (!self::$dataPrinted) {
    include 'asp.shortcode.data.php';
    self::$dataPrinted = true;
}
/****************** CUSTOM CSS ECHO *******************/
if (w_isset_def($style['custom_css'], "") != "") {
    ?>
    <style type="text/css">
        <?php 
    echo stripcslashes(base64_decode($style['custom_css']));
    ?>
    </style>
<?php 
}
/******************** SCRIPT INCLUDE ********************/
include 'asp.shortcode.script.php';
Example #8
0
 /**
  * Generates all Ajax Search Pro CSS code
  */
 function asp_generate_the_css()
 {
     global $wpdb;
     $css_arr = array();
     if (isset($wpdb->base_prefix)) {
         $_prefix = $wpdb->base_prefix;
     } else {
         $_prefix = $wpdb->prefix;
     }
     $comp_settings = get_option('asp_compatibility');
     $async_load = w_isset_def($comp_settings['css_async_load'], false);
     $search = $wpdb->get_results("SELECT * FROM " . $_prefix . "ajaxsearchpro", ARRAY_A);
     if (is_array($search) && count($search) > 0) {
         foreach ($search as $s) {
             $s['data'] = json_decode($s['data'], true);
             // $style and $id needed in the include
             $style = $s['data'];
             $id = $s['id'];
             ob_start();
             include ASP_PATH . "/css/style.css.php";
             $out = ob_get_contents();
             $css_arr[$id] = $out;
             ob_end_clean();
         }
         // Too big, disabled...
         //update_option('asp_styles_base64', base64_encode($css));
         $css = implode(" ", $css_arr);
         if ($async_load == 1) {
             foreach ($css_arr as $sid => $c) {
                 wpd_put_file(ASP_CSS_PATH . "/async/search" . $sid . ".css", $c);
             }
         } else {
             wpd_put_file(ASP_CSS_PATH . "/style.instances.css", $css);
         }
         update_option("asp_media_query", asp_gen_rnd_str());
         return $css;
     }
 }
Example #9
0
<?php

/* Prevent direct access */
defined('ABSPATH') or die("You can't access this file directly.");
?>
<form name='options'>
    <?php 
$fields = w_isset_def($style['field_order'], 'general|custom_post_types|custom_fields|categories_terms');
if (strpos($fields, "general") === false) {
    $fields = "general|" . $fields;
}
$field_order = explode('|', $fields);
foreach ($field_order as $field) {
    include "asp.shortcode.{$field}.php";
}
?>
</form>
'>
        <?php 
if (w_isset_def($style['loadingimage_custom'], "") == "" && pathinfo($style['loadingimage'], PATHINFO_EXTENSION) == 'svg') {
    echo file_get_contents(WP_PLUGIN_DIR . '/' . $style['loadingimage']);
}
?>
        <?php 
do_action('asp_layout_in_loading', $id);
?>
    </div>

    <?php 
if ($style['show_close_icon']) {
    ?>
        <div class='proclose<?php 
    echo w_isset_def($style['box_compact_layout'], 0) == 1 ? ' hiddend' : '';
    ?>
'>
            <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
                 y="0px"
                 width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512"
                 xml:space="preserve">
            <polygon id="x-mark-icon"
                     points="438.393,374.595 319.757,255.977 438.378,137.348 374.595,73.607 255.995,192.225 137.375,73.622 73.607,137.352 192.246,255.983 73.622,374.625 137.352,438.393 256.002,319.734 374.652,438.378 "/>
            </svg>
        </div>
    <?php 
}
?>

    <?php 
echo $style['settingsimagepos'];
?>
; /* IE9, no flexbox */
  <?php 
echo $style['settingsbackgroundborder'];
?>
  <?php 
echo $style['settingsboxshadow'];
?>
  cursor: pointer;
  background-size: 100% 100%;
  align-self: flex-end;
}

<?php 
if (w_isset_def($style['settingsimage_custom'], "") != "") {
    ?>
    <?php 
    echo $asp_div_ids1;
    ?>
 .probox .prosettings .innericon,
    <?php 
    echo $asp_div_ids2;
    ?>
 .probox .prosettings .innericon,
    <?php 
    echo $asp_div_ids;
    ?>
 .probox .prosettings .innericon {
      background-image: url("<?php 
    echo $style['settingsimage_custom'];
Example #12
0
function ajaxsearchlite_search()
{
    global $wpdb;
    global $search;
    /*print "in ajaxsearchlite_search();";
      print_r(array()); return;  */
    $s = $_POST['aslp'];
    $s = apply_filters('asl_search_phrase_before_cleaning', $s);
    $s = stripcslashes($s);
    $s = trim($s);
    $s = preg_replace('/\\s+/', ' ', $s);
    $s = apply_filters('asl_search_phrase_after_cleaning', $s);
    $def_data = get_option('asl_defaults');
    $search = array();
    $search['data'] = get_option('asl_options');
    $search['data'] = array_merge($def_data, $search['data']);
    $search['data']['image_options'] = array('show_images' => $search['data']['show_images'], 'image_bg_color' => '#FFFFFF', 'image_transparency' => 1, 'image_crop_location' => w_isset_def($search['data']['image_crop_location'], "c"), 'image_width' => $search['data']['image_width'], 'image_height' => $search['data']['image_height'], 'image_source1' => $search['data']['image_source1'], 'image_source2' => $search['data']['image_source2'], 'image_source3' => $search['data']['image_source3'], 'image_source4' => $search['data']['image_source4'], 'image_source5' => $search['data']['image_source5'], 'image_default' => $search['data']['image_default'], 'image_custom_field' => $search['data']['image_custom_field']);
    // ----------------- Recalculate image width/height ---------------
    switch ($search['data']['resultstype']) {
        case "horizontal":
            /* Same width as height */
            $search['data']['image_options']['image_width'] = wpdreams_width_from_px($search['data']['image_options']['hreswidth']);
            $search['data']['image_options']['image_height'] = wpdreams_width_from_px($search['data']['image_options']['hreswidth']);
            break;
        case "polaroid":
            $search['data']['image_options']['image_width'] = intval($search['data']['preswidth']);
            $search['data']['image_options']['image_height'] = intval($search['data']['preswidth']);
            break;
        case "isotopic":
            $search['data']['image_options']['image_width'] = intval($search['data']['i_item_width'] * 1.5);
            $search['data']['image_options']['image_height'] = intval($search['data']['i_item_height'] * 1.5);
            break;
    }
    if (isset($search['data']['selected-imagesettings'])) {
        $search['data']['settings-imagesettings'] = $search['data']['selected-imagesettings'];
    }
    /*if (isset($search) && $search['data']['exactonly']!=1) {
        $_s = explode(" ", $s);
      }*/
    if (isset($_POST['options'])) {
        parse_str($_POST['options'], $search['options']);
    }
    $blogresults = array();
    $allpageposts = array();
    $pageposts = array();
    do_action('asl_before_search', $s);
    $params = array('data' => $search['data'], 'options' => $search['options']);
    $_posts = new wpdreams_searchContent($params);
    $pageposts = $_posts->search($s);
    $allpageposts = array_merge($allpageposts, $pageposts);
    do_action('asl_after_pagepost_results', $s, $pageposts);
    $allpageposts = apply_filters('asl_pagepost_results', $allpageposts);
    $results = array_merge($allpageposts);
    // Keyword suggestions
    if (count($results) <= 0 && w_isset_def($search['data']['kw_suggestions'], 1) == 1) {
        $keywords = array();
        $types = array();
        $sd = $search['data'];
        if ($sd['searchinposts'] == 1) {
            $types[] = "post";
        }
        if ($sd['searchinpages'] == 1) {
            $types[] = "page";
        }
        if (isset($sd['selected-customtypes']) && count($sd['selected-customtypes']) > 0) {
            $types = array_merge($types, $sd['selected-customtypes']);
        }
        $t = new wpd_keywordSuggest("google", array('maxCount' => w_isset_def($sd['kw_count'], 10), 'maxCharsPerWord' => w_isset_def($sd['kw_length'], 60), 'postTypes' => $types, 'lang' => w_isset_def($sd['kw_google_lang'], "en"), 'overrideUrl' => ''));
        $keywords = $t->getKeywords($s);
        if ($keywords != false) {
            $results['keywords'] = $keywords;
            $results['nores'] = 1;
            $results = apply_filters('asl_only_keyword_results', $results);
        }
    } else {
        if (count($results > 0)) {
            $results = apply_filters('asl_only_non_keyword_results', $results);
        }
    }
    $results = apply_filters('asl_results', $results);
    do_action('asl_after_search', $s, $results);
    // Generate the results here
    $html_results = asl_generate_html_results($results, $search['data']);
    /* Clear output buffer, possible warnings */
    print "!!ASLSTART!!";
    //var_dump($results);die();
    print_r($html_results);
    print "!!ASLEND!!";
    die;
}
?>
,
                'on_typing': <?php 
echo w_isset_def($style['apl_on_typing'], 0);
?>
            },
            compact: {
                enabled: <?php 
echo w_isset_def($style['box_compact_layout'], 0);
?>
,
                width: "<?php 
echo w_isset_def($style['box_compact_width'], "100%");
?>
",
                closeOnMagnifier: <?php 
echo w_isset_def($style['box_compact_close_on_magn'], 1);
?>
,
                closeOnDocument: <?php 
echo w_isset_def($style['box_compact_close_on_document'], 0);
?>
,
                position: "<?php 
echo w_isset_def($style['box_compact_position'], 0);
?>
"
            }
        });
    });
</script>
Example #14
0
function ajaxsearchpro_autocomplete()
{
    global $wpdb;
    $s = trim($_POST['sauto']);
    $s = preg_replace('/\\s+/', ' ', $s);
    do_action('asp_before_autocomplete', $s);
    if (!isset($_POST['asid'])) {
        return "";
    }
    // Set the prefix for multisites
    if (isset($wpdb->base_prefix)) {
        $_prefix = $wpdb->base_prefix;
    } else {
        $_prefix = $wpdb->prefix;
    }
    // Forcing numeric value
    $_POST['asid'] = $_POST['asid'] + 0;
    $search = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $_prefix . "ajaxsearchpro WHERE id=%d", $_POST['asid']), ARRAY_A);
    if (!isset($search['data'])) {
        return;
    }
    $sd = json_decode($search['data'], true);
    $keyword = '';
    $types = array();
    if ($sd['searchinposts'] == 1) {
        $types[] = "post";
    }
    if ($sd['searchinpages'] == 1) {
        $types[] = "page";
    }
    if (isset($sd['selected-customtypes']) && count($sd['selected-customtypes']) > 0) {
        $types = array_merge($types, $sd['selected-customtypes']);
    }
    foreach (w_isset_def($sd['selected-autocomplete_source'], array('google')) as $source) {
        $taxonomy = "";
        // Check if this is a taxonomy
        if (strpos($source, 'xtax_') !== false) {
            $taxonomy = str_replace('xtax_', '', $source);
            $source = "terms";
        }
        $t = new wpd_keywordSuggest($source, array('maxCount' => 10, 'maxCharsPerWord' => w_isset_def($sd['autocomplete_length'], 60), 'postTypes' => $types, 'lang' => $sd['keywordsuggestionslang'], 'overrideUrl' => '', 'taxonomy' => $taxonomy, 'match_start' => true));
        $res = $t->getKeywords($s);
        if (isset($res[0]) && ($keyword = $res[0])) {
            break;
        }
    }
    do_action('asp_after_autocomplete', $s, $keyword);
    print $keyword;
    die;
}
]" value="<?php 
            echo $asp_f_uncoded_items[$key];
            ?>
">
    <?php 
            break;
            ?>
    <?php 
        case "dropdown":
            ?>
        <div class="asp_select_label<?php 
            echo w_isset_def($item->asp_f_dropdown_multi, 'asp_unchecked') == 'asp_checked' ? ' asp_select_multiple' : ' asp_select_single';
            ?>
">
            <select <?php 
            echo w_isset_def($item->asp_f_dropdown_multi, 'asp_unchecked') == 'asp_checked' ? ' multiple name="aspf[' . $item->asp_f_field . '][]"' : 'name="aspf[' . $item->asp_f_field . ']"';
            ?>
 >
            <?php 
            foreach ($item->asp_f_dropdown_value as $dropdown) {
                ?>
                <?php 
                preg_match('/^(.*?)\\|\\|(.*)/', $dropdown, $matches);
                ?>

                <option value="<?php 
                echo $matches[1];
                ?>
"<?php 
                echo strpos('**', $matches[2]) > 0 ? ' selected' : '';
                ?>
Example #16
0
 /**
  * Prints the scripts
  */
 function scripts()
 {
     global $wp_version;
     // ------------ Dequeue some scripts causing issues on the back-end --------------
     wp_dequeue_script('otw-admin-colorpicker');
     wp_dequeue_script('otw-admin-select2');
     wp_dequeue_script('otw-admin-otwpreview');
     wp_dequeue_script('otw-admin-fonts');
     wp_dequeue_script('otw-admin-functions');
     wp_dequeue_script('otw-admin-variables');
     // Fallback on IE<=8
     if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(?i)msie [6-8]/', $_SERVER['HTTP_USER_AGENT'])) {
         // Oh, this is IE 8 or below, abort mission
         return;
     }
     $comp_settings = get_option('asp_compatibility');
     //var_dump($comp_settings);die();
     if ($comp_settings !== false && isset($comp_settings['loadpolaroidjs']) && $comp_settings['loadpolaroidjs'] == 0) {
     } else {
         wp_register_script('wpdreams-modernizr', ASP_URL . 'js/nomin/modernizr.min.js', array(), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-modernizr');
         wp_register_script('wpdreams-classie', ASP_URL . 'js/nomin/classie.js', array(), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-classie');
         wp_register_script('wpdreams-photostack', ASP_URL . 'js/nomin/photostack.js', array(), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-photostack');
     }
     $js_source = w_isset_def($comp_settings['js_source'], 'min-scoped');
     $load_noui = w_isset_def($comp_settings['load_noui_js'], 1);
     $load_isotope = w_isset_def($comp_settings['load_isotope_js'], 1);
     $minify_string = ($load_noui == 1 ? '-noui' : '') . ($load_isotope == 1 ? '-isotope' : '');
     if (ASP_DEBUG) {
         $js_source = 'nomin';
     }
     if ($js_source == 'nomin' || $js_source == 'nomin-scoped') {
         $prereq = "jquery";
         if ($js_source == "nomin-scoped") {
             $prereq = "wpdreams-aspjquery";
             wp_register_script('wpdreams-aspjquery', ASP_URL . 'js/' . $js_source . '/aspjquery.js', array(), ASP_CURR_VER_STRING);
             wp_enqueue_script('wpdreams-aspjquery');
         }
         wp_register_script('wpdreams-gestures', ASP_URL . 'js/' . $js_source . '/jquery.gestures.js', array($prereq), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-gestures');
         wp_register_script('wpdreams-easing', ASP_URL . 'js/' . $js_source . '/jquery.easing.js', array($prereq), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-easing');
         /*wp_register_script('wpdreams-mousewheel', ASP_URL . 'js/' . $js_source . '/jquery.mousewheel.js', array($prereq));
           wp_enqueue_script('wpdreams-mousewheel');*/
         wp_register_script('wpdreams-scroll', ASP_URL . 'js/' . $js_source . '/jquery.mCustomScrollbar.js', array($prereq), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-scroll');
         wp_register_script('wpdreams-highlight', ASP_URL . 'js/' . $js_source . '/jquery.highlight.js', array($prereq), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-highlight');
         if ($load_noui) {
             wp_register_script('wpdreams-nouislider', ASP_URL . 'js/' . $js_source . '/jquery.nouislider.all.js', array($prereq), ASP_CURR_VER_STRING);
             wp_enqueue_script('wpdreams-nouislider');
         }
         if ($load_isotope) {
             wp_register_script('wpdreams-rpp-isotope', ASP_URL . 'js/' . $js_source . '/rpp_isotope.js', array($prereq), ASP_CURR_VER_STRING);
             wp_enqueue_script('wpdreams-rpp-isotope');
         }
         wp_register_script('wpdreams-ajaxsearchpro', ASP_URL . 'js/' . $js_source . '/jquery.ajaxsearchpro.js', array($prereq, "wpdreams-scroll"), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-ajaxsearchpro');
     } else {
         wp_enqueue_script('jquery');
         wp_register_script('wpdreams-ajaxsearchpro', ASP_URL . "js/" . $js_source . "/jquery.ajaxsearchpro" . $minify_string . ".min.js", array(), ASP_CURR_VER_STRING);
         wp_enqueue_script('wpdreams-ajaxsearchpro');
     }
     $ajax_url = admin_url('admin-ajax.php');
     if (w_isset_def($comp_settings['usecustomajaxhandler'], 0) == 1) {
         $ajax_url = ASP_URL . 'ajax_search.php';
     }
     wp_localize_script('wpdreams-ajaxsearchpro', 'ajaxsearchpro', array('ajaxurl' => $ajax_url, 'backend_ajaxurl' => admin_url('admin-ajax.php')));
 }
 /**
  * The search function
  *
  * @return array|string
  */
 protected function do_search()
 {
     global $wpdb;
     global $q_config;
     $options = $this->options;
     $searchData = $this->searchData;
     $parts = array();
     $relevance_parts = array();
     $types = array();
     $post_types = "";
     $s = $this->s;
     // full keyword
     $_s = $this->_s;
     // array of keywords
     $_si = implode('|', $_s);
     // imploded phrase for regexp
     $_si = $_si != '' ? $_si : $s;
     //$kw_logic = w_isset_def($searchData['keyword_logic'], 'or');
     $q_config['language'] = $options['qtranslate_lang'];
     if (isset($wpdb->base_prefix)) {
         $_prefix = $wpdb->base_prefix;
     } else {
         $_prefix = $wpdb->prefix;
     }
     /*------------------------- Statuses ----------------------------*/
     $statuses = array('publish');
     if ($searchData['searchinpending']) {
         $statuses[] = 'pending';
     }
     if ($searchData['searchindrafts']) {
         $statuses[] = 'draft';
     }
     $words = implode('|', $statuses);
     $post_statuses = "(lower({$wpdb->posts}.post_status) REGEXP '{$words}')";
     /*---------------------------------------------------------------*/
     /*----------------------- Gather Types --------------------------*/
     if ($options['set_inposts'] == 1) {
         $types[] = "post";
     }
     if ($options['set_inpages']) {
         $types[] = "page";
     }
     if (isset($options['customset']) && count($options['customset']) > 0) {
         $types = array_merge($types, $options['customset']);
     }
     if (count($types) < 1) {
         return '';
     } else {
         $words = implode('[[:>:]]|[[:<:]]', $types);
         $post_types = "({$wpdb->posts}.post_type REGEXP '[[:<:]]" . $words . "[[:>:]]')";
     }
     /*---------------------------------------------------------------*/
     $is_too_short = false;
     $not_exact_phrase = '';
     $fulltext = wpdreamsFulltext::getInstance();
     foreach ($_s as $_pp) {
         if (strlen($_pp) < $fulltext->getMinWordLength() || !$options['set_exactonly']) {
             $is_too_short = true;
             $not_exact_phrase .= " *" . $_pp . "*";
         } else {
             $not_exact_phrase .= " " . $_pp;
         }
     }
     $not_exact_phrase = trim($not_exact_phrase);
     $exact_phrase = '"' . $s . '"';
     $ful_options = get_option('asp_fulltexto');
     if (w_isset_def($ful_options['dbuseregularwhenshort'], 0) && $is_too_short) {
         return parent::do_search();
     }
     /**
      * Construct the INDEX name to search
      */
     $match_against = '1';
     $relevance = '';
     $fixed_phrase = $options['set_exactonly'] ? $exact_phrase : $not_exact_phrase;
     $boolean_mode = get_option('asp_fulltext_indexed') == 0 || $is_too_short || !$options['set_exactonly'] ? ' IN BOOLEAN MODE' : '';
     $index_name = $options['set_intitle'] ? "{$wpdb->posts}.post_title" : '';
     if ($index_name == '') {
         $index_name .= $options['set_incontent'] ? "{$wpdb->posts}.post_content" : '';
     } else {
         $index_name .= $options['set_incontent'] ? ", {$wpdb->posts}.post_content" : '';
     }
     if ($index_name == '') {
         $index_name .= $options['set_inexcerpt'] ? "{$wpdb->posts}.post_excerpt" : '';
     } else {
         $index_name .= $options['set_inexcerpt'] ? ", {$wpdb->posts}.post_excerpt" : '';
     }
     if ($index_name != '') {
         $match_against = " MATCH(" . $index_name . ") AGAINST ('" . $fixed_phrase . "'" . $boolean_mode . ") ";
     }
     if ($match_against != '1') {
         $relevance = "\r\n          (\r\n           MATCH(" . $index_name . ") AGAINST ('" . $exact_phrase . "'" . $boolean_mode . ") +\r\n           MATCH(" . $index_name . ") AGAINST ('" . $not_exact_phrase . "'" . $boolean_mode . ")\r\n           )\r\n        ";
     }
     // ------------------------ Categories/taxonomies ----------------------
     if (!isset($options['categoryset']) || $options['categoryset'] == "") {
         $options['categoryset'] = array();
     }
     if (!isset($options['termset']) || $options['termset'] == "") {
         $options['termset'] = array();
     }
     $exclude_categories = array();
     $searchData['selected-exsearchincategories'] = w_isset_def($searchData['selected-exsearchincategories'], array());
     $searchData['selected-excludecategories'] = w_isset_def($searchData['selected-excludecategories'], array());
     $_all_cat = get_terms('category', array('fields' => 'ids'));
     $_needed_cat = array_diff($_all_cat, $searchData['selected-exsearchincategories']);
     $_needed_cat = !is_array($_needed_cat) ? array() : $_needed_cat;
     $exclude_categories = array_diff(array_merge($_needed_cat, $searchData['selected-excludecategories']), $options['categoryset']);
     $exclude_terms = array();
     $exclude_showterms = array();
     $searchData['selected-showterms'] = w_isset_def($searchData['selected-showterms'], array());
     $searchData['selected-excludeterms'] = w_isset_def($searchData['selected-excludeterms'], array());
     foreach ($searchData['selected-excludeterms'] as $tax => $terms) {
         $exclude_terms = array_merge($exclude_terms, $terms);
     }
     foreach ($searchData['selected-showterms'] as $tax => $terms) {
         $exclude_showterms = array_merge($exclude_showterms, $terms);
     }
     $exclude_terms = array_diff(array_merge($exclude_terms, $exclude_showterms), $options['termset']);
     $all_terms = array();
     $all_terms = array_merge($exclude_categories, $exclude_terms);
     if (count($all_terms) > 0) {
         $words = '--' . implode('--|--', $all_terms) . '--';
         $term_query = "HAVING (ttid NOT REGEXP '{$words}')";
     }
     // ---------------------------------------------------------------------
     /*------------- Custom Fields with Custom selectors -------------*/
     if (isset($options['aspf']) && isset($options['aspfdata'])) {
         $parts = array();
         foreach ($options['aspfdata'] as $u_data) {
             $data = json_decode(base64_decode($u_data));
             $posted = $options['aspf'][$data->asp_f_field];
             $ll_like = "";
             $rr_like = "";
             $operator = "=";
             if (isset($data->asp_f_operator)) {
                 switch ($data->asp_f_operator) {
                     case 'eq':
                         $operator = "=";
                         break;
                     case 'neq':
                         $operator = "<>";
                         break;
                     case 'lt':
                         $operator = "<";
                         break;
                     case 'gt':
                         $operator = ">";
                         break;
                     case 'elike':
                         $operator = "=";
                         $ll_like = "'";
                         $rr_like = "'";
                         break;
                     case 'like':
                         $operator = "LIKE";
                         $ll_like = "'%";
                         $rr_like = "%'";
                         break;
                     default:
                         $operator = "=";
                         break;
                 }
             }
             //var_dump($data);
             /*if (w_isset_def($searchData['cf_null_values'], 1) == 1) {
                   $cf_key_is_null .= " OR $wpdb->postmeta.meta_key IS NULL";
                   $cf_val_is_null .= " OR $wpdb->postmeta.meta_value IS NULL";
               }*/
             if ($data->asp_f_type == 'range' && isset($posted['lower'])) {
                 $parts[] = " ( ({$wpdb->postmeta}.meta_key='{$data->asp_f_field}') AND\r\n                                     ({$wpdb->postmeta}.meta_value BETWEEN " . $posted['lower'] . " AND " . $posted['upper'] . " ) )";
             } else {
                 if ($data->asp_f_type == 'slider' && isset($posted)) {
                     $parts[] = " ( ({$wpdb->postmeta}.meta_key='{$data->asp_f_field}') AND\r\n                                     ({$wpdb->postmeta}.meta_value {$operator} {$posted}  ) )";
                 } else {
                     if ($data->asp_f_type == 'radio' && isset($posted)) {
                         $parts[] = " ( ({$wpdb->postmeta}.meta_key='{$data->asp_f_field}') AND\r\n                                     ({$wpdb->postmeta}.meta_value {$operator} " . $ll_like . $posted . $rr_like . " ) )";
                     } else {
                         if ($data->asp_f_type == 'dropdown' && isset($posted)) {
                             if (isset($data->asp_f_dropdown_multi) && count($posted) > 0) {
                                 // The AND logic doesn't make any sense
                                 $logic = 'OR';
                                 $values = '';
                                 foreach ($posted as $v) {
                                     if ($values != '') {
                                         $values .= " {$logic} {$wpdb->postmeta}.meta_value {$operator} " . $ll_like . $v . $rr_like;
                                     } else {
                                         $values .= "{$wpdb->postmeta}.meta_value {$operator} " . $ll_like . $v . $rr_like;
                                     }
                                 }
                                 $values = $values == '' ? '0' : $values;
                                 $parts[] = "( ({$wpdb->postmeta}.meta_key='{$data->asp_f_field}') AND ({$values}) )";
                             } else {
                                 $parts[] = "( ({$wpdb->postmeta}.meta_key='{$data->asp_f_field}') AND\r\n                                        ({$wpdb->postmeta}.meta_value {$operator} " . $ll_like . $posted . $rr_like . " ) )";
                             }
                         } else {
                             if ($data->asp_f_type == 'checkboxes' && isset($posted)) {
                                 $logic = $data->asp_f_checkboxes_logic;
                                 $values = '';
                                 foreach ($posted as $v => $vv) {
                                     if ($values != '') {
                                         $values .= " {$logic} {$wpdb->postmeta}.meta_value {$operator} " . $ll_like . $v . $rr_like;
                                     } else {
                                         $values .= "{$wpdb->postmeta}.meta_value {$operator} " . $ll_like . $v . $rr_like;
                                     }
                                 }
                                 $values = $values == '' ? '0' : $values;
                                 $parts[] = "( ({$wpdb->postmeta}.meta_key='{$data->asp_f_field}') AND ({$values}) )";
                             }
                         }
                     }
                 }
             }
         }
         $this->cf_parts = $parts;
     }
     $meta_count = count($this->cf_parts);
     $cf_query = implode(" OR ", $this->cf_parts);
     if ($cf_query == "") {
         $cf_select = "0";
         $cf_having = "";
     } else {
         $cf_select = "\r\n                SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE\r\n                    {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID\r\n                AND\r\n                    ({$cf_query})";
         if (w_isset_def($searchData['cf_logic'], 'AND') == 'AND') {
             $cf_having = "meta_matches >= " . $meta_count;
         } else {
             $cf_having = "meta_matches >= 1";
         }
         if ($term_query != '') {
             $cf_having = " AND " . $cf_having;
         } else {
             $cf_having = "HAVING " . $cf_having;
         }
     }
     /*---------------------------------------------------------------*/
     /*---------------------- Custom Fields --------------------------*/
     if (isset($searchData['selected-customfields'])) {
         $selected_customfields = $searchData['selected-customfields'];
         if (is_array($selected_customfields) && count($selected_customfields) > 0) {
             $words = $options['set_exactonly'] == 1 ? $s : $_si;
             foreach ($selected_customfields as $cfield) {
                 $parts[] = "({$wpdb->postmeta}.meta_key='{$cfield}' AND\r\n                                   lower({$wpdb->postmeta}.meta_value) REGEXP '{$words}')";
             }
         }
     }
     /*---------------------------------------------------------------*/
     /*------------------------ Exclude id's -------------------------*/
     if (isset($searchData['excludeposts']) && $searchData['excludeposts'] != "") {
         $exclude_posts = "{$wpdb->posts}.ID NOT IN (" . $searchData['excludeposts'] . ")";
     } else {
         $exclude_posts = "{$wpdb->posts}.ID NOT IN (-55)";
     }
     /*---------------------------------------------------------------*/
     /*------------------------- Build like --------------------------*/
     $like_query = implode(' OR ', $parts);
     if ($like_query == "") {
         $like_query = "(0)";
     } else {
         $like_query = "({$like_query})";
     }
     /*---------------------------------------------------------------*/
     /*------------------------- WPML filter -------------------------*/
     $wpml_join = "";
     if (defined('ICL_LANGUAGE_CODE') && ICL_LANGUAGE_CODE != '' && w_isset_def($searchData['wpml_compatibility'], 1) == 1) {
         $wpml_join = "RIGHT JOIN " . $wpdb->base_prefix . "icl_translations ON ({$wpdb->posts}.ID = " . $wpdb->base_prefix . "icl_translations.element_id AND " . $wpdb->base_prefix . "icl_translations.language_code = '" . ICL_LANGUAGE_CODE . "')";
     }
     /*---------------------------------------------------------------*/
     $orderby = isset($searchData['selected-orderby']) && $searchData['selected-orderby'] != '' ? $searchData['selected-orderby'] : "post_date DESC";
     $querystr = "\r\n    \t\tSELECT \r\n          {$wpdb->posts}.post_title as title,\r\n          {$wpdb->posts}.ID as id,\r\n          {$wpdb->posts}.post_date as date,               \r\n          {$wpdb->posts}.post_content as content,\r\n          {$wpdb->posts}.post_excerpt as excerpt,\r\n          {$wpdb->users}.user_nicename as author,\r\n          'pagepost' as content_type,\r\n          {$wpdb->posts}.post_type as post_type,\r\n          ({$cf_select}) as meta_matches,\r\n            CASE WHEN " . $_prefix . "ajaxsearchpro_priorities.priority IS NULL\r\n                   THEN 100\r\n                   ELSE " . $_prefix . "ajaxsearchpro_priorities.priority\r\n            END AS priority,\r\n          CONCAT('--', GROUP_CONCAT(DISTINCT {$wpdb->terms}.term_id SEPARATOR '----'), '--') as ttid,\r\n          {$wpdb->posts}.post_type as post_type,";
     if ($searchData['userelevance'] == 1 && $relevance != '') {
         $querystr .= $relevance;
     } else {
         $querystr .= "1 ";
     }
     $querystr .= "\r\n          as relevance\r\n    \t\tFROM {$wpdb->posts}\r\n        LEFT JOIN {$wpdb->postmeta} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID\r\n        LEFT JOIN " . $_prefix . "ajaxsearchpro_priorities ON (" . $_prefix . "ajaxsearchpro_priorities.post_id = {$wpdb->posts}.ID AND " . $_prefix . "ajaxsearchpro_priorities.blog_id = " . get_current_blog_id() . ")\r\n        LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID = {$wpdb->posts}.post_author\r\n        LEFT JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id\r\n        LEFT JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_taxonomy}.term_taxonomy_id = {$wpdb->term_relationships}.term_taxonomy_id\r\n        LEFT JOIN {$wpdb->terms} ON {$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id\r\n        {$wpml_join}\r\n    \t\tWHERE\r\n            {$post_types}\r\n        AND {$post_statuses}\r\n        AND (" . $match_against . " OR (" . $like_query . "))\r\n        AND (" . $exclude_posts . ")\r\n        GROUP BY\r\n          {$wpdb->posts}.ID\r\n          {$term_query}\r\n          {$cf_having}\r\n         ";
     $querystr .= " ORDER BY priority DESC, relevance DESC, " . $wpdb->posts . "." . $orderby . "\r\n        LIMIT " . $searchData['maxresults'];
     $pageposts = $wpdb->get_results($querystr, OBJECT);
     //var_dump($querystr); var_dump($pageposts);die("!!");
     $this->results = $pageposts;
     return $pageposts;
 }
,
    "iitemsHeight": <?php 
echo w_isset_def($style['i_item_height'], 200);
?>
,
    "iishowOverlay": <?php 
echo w_isset_def($style['i_overlay'], 1);
?>
,
    "iiblurOverlay": <?php 
echo w_isset_def($style['i_overlay_blur'], 1);
?>
,
    "iihideContent": <?php 
echo w_isset_def($style['i_hide_content'], 1);
?>
,
    "iianimation": "<?php 
echo w_isset_def($style['i_animation'], 1);
?>
",
    "analytics": <?php 
echo w_isset_def($ana_options['analytics'], 0);
?>
,
    "analyticsString": "<?php 
echo w_isset_def($ana_options['analytics_string'], "");
?>
"
}
</div>
 private function pre_process_results()
 {
     // No results, save some resources
     if (count($this->results) == 0) {
         return array();
     }
     $pageposts = array();
     $options = $this->options;
     $searchId = $this->searchId;
     $searchData = $this->searchData;
     $post_ids = array();
     //$orderby = w_isset_def($searchData['orderby'], "post_date DESC");
     $the_posts = array();
     // Get the post IDs
     foreach ($this->results as $k => $v) {
         $post_ids[$v->blogid][] = $v->id;
     }
     foreach ($post_ids as $blogid => $the_ids) {
         if (isset($options['switch_on_preprocess']) && is_multisite()) {
             switch_to_blog($blogid);
         }
         $args = array('post__in' => $the_ids, 'order_by' => 'post__in', 'posts_per_page' => 1000000, 'post_type' => 'any');
         $get_posts = get_posts($args);
         foreach ($get_posts as $gk => $gv) {
             $get_posts[$gk]->blogid = $blogid;
         }
         $the_posts = array_merge($the_posts, $get_posts);
     }
     if (isset($options['switch_on_preprocess']) && is_multisite()) {
         restore_current_blog();
     }
     // Merge the posts with the raw results to a new array
     foreach ($the_posts as $k => $r) {
         $new_result = new stdClass();
         $new_result->id = w_isset_def($r->ID, null);
         $new_result->blogid = $r->blogid;
         $new_result->title = w_isset_def($r->post_title, null);
         $new_result->post_title = $new_result->title;
         $new_result->content = w_isset_def($r->post_content, null);
         $new_result->excerpt = w_isset_def($r->post_excerpt, null);
         $new_result->image = null;
         if ($searchData['showauthor'] == 1) {
             $post_user = get_user_by("id", $r->post_author);
             if ($post_user !== false) {
                 if (w_isset_def($searchData['author_field'], 'display_name') == "display_name") {
                     $new_result->author = $post_user->data->display_name;
                 } else {
                     $new_result->author = $post_user->data->user_login;
                 }
             } else {
                 $new_result->author = null;
             }
         }
         $new_result->date = w_isset_def($r->post_date, null);
         $new_result->post_date = $new_result->date;
         // Get the relevance and priority values
         $new_result->relevance = (int) $this->raw_results[$new_result->blogid . "x" . $new_result->id]->relevance;
         $new_result->priority = (int) $this->raw_results[$new_result->blogid . "x" . $new_result->id]->priority;
         $new_result->post_type = $this->raw_results[$new_result->blogid . "x" . $new_result->id]->post_type;
         $new_result->content_type = "pagepost";
         $new_result->ttid = $this->raw_results[$new_result->blogid . "x" . $new_result->id]->ttid;
         $pageposts[] = $new_result;
     }
     // Order them once again
     if (count($pageposts) > 0) {
         usort($pageposts, array($this, 'compare_by_primary'));
         /**
          * Let us save some time. There is going to be a user selecting the same sorting
          * for both primary and secondary. Only do secondary if it is different from the primary.
          */
         if ($this->ordering['primary'] != $this->ordering['secondary']) {
             $i = 0;
             foreach ($pageposts as $pk => $pp) {
                 $pageposts[$pk]->primary_order = $i;
                 $i++;
             }
             usort($pageposts, array($this, 'compare_by_secondary'));
         }
     }
     $this->results = $pageposts;
 }
Example #20
0
 /**
  * Generates the user result description based on the advanced description field
  *
  * @param $title string post description
  * @param $id int post id
  * @return string final post description
  */
 protected function adv_desc($desc, $id)
 {
     $descfield = w_isset_def($this->searchData['user_search_advanced_description_field'], '');
     if ($descfield == '') {
         return $desc;
     }
     preg_match_all("/{(.*?)}/", $descfield, $matches);
     if (isset($matches[0]) && isset($matches[1]) && is_array($matches[1])) {
         foreach ($matches[1] as $field) {
             if ($field == 'descriptionfield') {
                 $descfield = str_replace('{descriptionfield}', $desc, $descfield);
             } else {
                 $val = get_user_meta($id, $field, true);
                 $descfield = str_replace('{' . $field . '}', $val, $descfield);
             }
         }
     }
     return $descfield;
 }
 /**
  * The search function
  *
  * @return array|string
  */
 protected function do_search()
 {
     global $wpdb;
     if (isset($wpdb->base_prefix)) {
         $_prefix = $wpdb->base_prefix;
     } else {
         $_prefix = $wpdb->prefix;
     }
     $options = $this->options;
     $searchData = $this->searchData;
     $kw_logic = w_isset_def($searchData['keyword_logic'], 'or');
     $q_config['language'] = $options['qtranslate_lang'];
     $s = $this->s;
     // full keyword
     $_s = $this->_s;
     // array of keywords
     if ($kw_logic == 'orex') {
         $_si = "[[:<:]]" . implode('[[:>:]]|[[:<:]]', $_s) . "[[:>:]]";
     } else {
         $_si = implode('|', $_s);
     }
     // imploded phrase for regexp
     $_si = $_si != '' ? $_si : $s;
     $repliesresults = array();
     $userresults = array();
     $groupresults = array();
     $activityresults = array();
     $words = $options['set_exactonly'] == 1 ? array($s) : $_s;
     $regexp_words = count($_s > 0) ? implode('|', $_s) : $s;
     if (function_exists('bp_core_get_user_domain')) {
         $parts = array();
         $relevance_parts = array();
         /*----------------------- User query ---------------------------*/
         // User query had been replaced with user results..
         /*---------------------------------------------------------------*/
         /*----------------------- Groups query --------------------------*/
         if ($searchData['search_in_bp_groups'] && bp_is_active('groups')) {
             $parts = array();
             $relevance_parts = array();
             /*------------------------- Statuses ----------------------------*/
             $statuses = array();
             if ($searchData['search_in_bp_groups_public'] == 1) {
                 $statuses[] = 'public';
             }
             if ($searchData['search_in_bp_groups_private'] == 1) {
                 $statuses[] = 'private';
             }
             if ($searchData['search_in_bp_groups_hidden'] == 1) {
                 $statuses[] = 'hidden';
             }
             if (count($statuses) < 1) {
                 return '';
             }
             $swords = implode('|', $statuses);
             $group_statuses = "(lower(" . $wpdb->prefix . "bp_groups.status) REGEXP '{$swords}')";
             /*---------------------------------------------------------------*/
             /*------------------------- Title query -------------------------*/
             if ($kw_logic == 'or' || $kw_logic == 'and') {
                 $op = strtoupper($kw_logic);
                 if (count($_s) > 0) {
                     $_like = implode("%' " . $op . " lower(" . $wpdb->prefix . "bp_groups.name) LIKE '%", $words);
                 } else {
                     $_like = $s;
                 }
                 $parts[] = "( lower(" . $wpdb->prefix . "bp_groups.name) LIKE '%" . $_like . "%' )";
             } else {
                 $_like = array();
                 $op = $kw_logic == 'andex' ? 'AND' : 'OR';
                 foreach ($words as $word) {
                     $_like[] = "\r\n                           (lower(" . $wpdb->prefix . "bp_groups.name) LIKE '% " . $word . " %'\r\n                        OR  lower(" . $wpdb->prefix . "bp_groups.name) LIKE '" . $word . " %'\r\n                        OR  lower(" . $wpdb->prefix . "bp_groups.name) LIKE '% " . $word . "'\r\n                        OR  lower(" . $wpdb->prefix . "bp_groups.name) = '" . $word . "')";
                 }
                 $parts[] = "(" . implode(' ' . $op . ' ', $_like) . ")";
             }
             /*$words = $options['set_exactonly'] == 1 ? $s : $_si;
               if ($kw_logic == 'or' || $kw_logic == 'orex') {
                   $parts[] = "(lower(" . $wpdb->prefix . "bp_groups.name) REGEXP '$words')";
               } else {
                   if (count($_s) > 0)
                       $and_like = implode("$r_sign' AND lower(" . $wpdb->prefix . "bp_groups.name) RLIKE '$l_sign", $_s);
                   else
                       $and_like = $s;
                   $parts[] = "lower(" . $wpdb->prefix . "bp_groups.name) RLIKE '$l_sign" . $and_like . "$r_sign'";
               }*/
             $relevance_parts[] = "(case when\r\n                    (lower(" . $wpdb->prefix . "bp_groups.name) REGEXP '{$regexp_words}')\r\n                     then {$searchData['titleweight']} else 0 end)";
             $relevance_parts[] = "(case when\r\n                    (lower(" . $wpdb->prefix . "bp_groups.name) = '{$s}')\r\n                     then {$searchData['etitleweight']} else 0 end)";
             // The first word relevance is higher
             if (count($_s) > 0) {
                 $relevance_parts[] = "(case when\r\n                      (lower(" . $wpdb->prefix . "bp_groups.name) REGEXP '" . $_s[0] . "')\r\n                       then {$searchData['etitleweight']} else 0 end)";
             }
             /*---------------------------------------------------------------*/
             /*---------------------- Description query ----------------------*/
             if ($kw_logic == 'or' || $kw_logic == 'and') {
                 $op = strtoupper($kw_logic);
                 if (count($_s) > 0) {
                     $_like = implode("%' " . $op . " lower(" . $wpdb->prefix . "bp_groups.description) LIKE '%", $words);
                 } else {
                     $_like = $s;
                 }
                 $parts[] = "( lower(" . $wpdb->prefix . "bp_groups.description) LIKE '%" . $_like . "%' )";
             } else {
                 $_like = array();
                 $op = $kw_logic == 'andex' ? 'AND' : 'OR';
                 foreach ($words as $word) {
                     $_like[] = "\r\n                           (lower(" . $wpdb->prefix . "bp_groups.description) LIKE '% " . $word . " %'\r\n                        OR  lower(" . $wpdb->prefix . "bp_groups.description) LIKE '" . $word . " %'\r\n                        OR  lower(" . $wpdb->prefix . "bp_groups.description) LIKE '% " . $word . "'\r\n                        OR  lower(" . $wpdb->prefix . "bp_groups.description) = '" . $word . "')";
                 }
                 $parts[] = "(" . implode(' ' . $op . ' ', $_like) . ")";
             }
             /*if ($kw_logic == 'or' || $kw_logic == 'orex') {
                   $parts[] = "(lower(" . $wpdb->prefix . "bp_groups.description) REGEXP '$words')";
               } else {
                   if (count($_s) > 0)
                       $and_like = implode("$r_sign' AND lower(" . $wpdb->prefix . "bp_groups.description) RLIKE '$l_sign", $_s);
                   else
                       $and_like = $s;
                   $parts[] = "lower(" . $wpdb->prefix . "bp_groups.description) RLIKE '$l_sign" . $and_like . "$r_sign'";
               }*/
             $relevance_parts[] = "(case when\r\n                    (lower(" . $wpdb->prefix . "bp_groups.description) REGEXP '{$regexp_words}')\r\n                     then {$searchData['contentweight']} else 0 end)";
             $relevance_parts[] = "(case when\r\n                    (lower(" . $wpdb->prefix . "bp_groups.description) = '{$s}')\r\n                     then {$searchData['econtentweight']} else 0 end)";
             /*---------------------------------------------------------------*/
             /*------------------------- Build like --------------------------*/
             $like_query = implode(' OR ', $parts);
             if ($like_query == "") {
                 $like_query = "(1)";
             } else {
                 $like_query = "({$like_query})";
             }
             /*---------------------------------------------------------------*/
             /*---------------------- Build relevance ------------------------*/
             $relevance = implode(' + ', $relevance_parts);
             if ($searchData['userelevance'] != 1 || $relevance == "") {
                 $relevance = "(1)";
             } else {
                 $relevance = "({$relevance})";
             }
             /*---------------------------------------------------------------*/
             $querystr = "\r\n             SELECT\r\n               " . $wpdb->prefix . "bp_groups.id as id,\r\n               " . $wpdb->prefix . "bp_groups.name as title,\r\n               " . $wpdb->prefix . "bp_groups.description as content,\r\n               " . $wpdb->prefix . "bp_groups.date_created as date,\r\n               {$wpdb->users}.user_nicename as author,\r\n               'bp_group' as content_type,\r\n               {$relevance} as relevance\r\n             FROM\r\n               " . $wpdb->prefix . "bp_groups\r\n             LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID = " . $wpdb->prefix . "bp_groups.creator_id\r\n             WHERE\r\n                  {$group_statuses}\r\n              AND {$like_query}\r\n              ORDER BY relevance DESC, title ASC";
             $groupresults = $wpdb->get_results($querystr, OBJECT);
             foreach ($groupresults as $k => $v) {
                 $group = new BP_Groups_Group($v->id);
                 $groupresults[$k]->link = bp_get_group_permalink($group);
                 if ($searchData['image_options']['show_images'] == 1) {
                     $avatar_options = array('item_id' => $v->id, 'object' => 'group', 'type' => 'full', 'html' => false);
                     $im = bp_core_fetch_avatar($avatar_options);
                     if ($im != '') {
                         $groupresults[$k]->image = $im;
                     }
                 }
                 if ($groupresults[$k]->content != '') {
                     $groupresults[$k]->content = wd_substr_at_word(strip_tags($groupresults[$k]->content), $searchData['descriptionlength']) . "...";
                 }
             }
         }
         /*---------------------------------------------------------------*/
         /*----------------------- Activity query ------------------------*/
         if ($searchData['search_in_bp_activities'] && bp_is_active('groups')) {
             $parts = array();
             $relevance_parts = array();
             /*---------------------- Description query ----------------------*/
             if ($kw_logic == 'or' || $kw_logic == 'and') {
                 $op = strtoupper($kw_logic);
                 if (count($_s) > 0) {
                     $_like = implode("%' " . $op . " lower(" . $wpdb->prefix . "bp_activity.content) LIKE '%", $words);
                 } else {
                     $_like = $s;
                 }
                 $parts[] = "( lower(" . $wpdb->prefix . "bp_activity.content) LIKE '%" . $_like . "%' )";
             } else {
                 $_like = array();
                 $op = $kw_logic == 'andex' ? 'AND' : 'OR';
                 foreach ($words as $word) {
                     $_like[] = "\r\n                           (lower(" . $wpdb->prefix . "bp_activity.content) LIKE '% " . $word . " %'\r\n                        OR  lower(" . $wpdb->prefix . "bp_activity.content) LIKE '" . $word . " %'\r\n                        OR  lower(" . $wpdb->prefix . "bp_activity.content) LIKE '% " . $word . "'\r\n                        OR  lower(" . $wpdb->prefix . "bp_activity.content) = '" . $word . "')";
                 }
                 $parts[] = "(" . implode(' ' . $op . ' ', $_like) . ")";
             }
             /*$words = $options['set_exactonly'] == 1 ? $s : $_si;
               if ($kw_logic == 'or' || $kw_logic == 'orex') {
                   $parts[] = "(lower(" . $wpdb->prefix . "bp_activity.content) REGEXP '$words')";
               } else {
                   if (count($_s) > 0)
                       $and_like = implode("$r_sign' AND lower(" . $wpdb->prefix . "bp_activity.content) RLIKE '$l_sign", $_s);
                   else
                       $and_like = $s;
                   $parts[] = "lower(" . $wpdb->prefix . "bp_activity.content) RLIKE '$l_sign" . $and_like . "$r_sign'";
               }*/
             $relevance_parts[] = "(case when\r\n                    (lower(" . $wpdb->prefix . "bp_activity.content) REGEXP '{$regexp_words}')\r\n                     then {$searchData['contentweight']} else 0 end)";
             $relevance_parts[] = "(case when\r\n                    (lower(" . $wpdb->prefix . "bp_activity.content) = '{$s}')\r\n                     then {$searchData['econtentweight']} else 0 end)";
             /*---------------------------------------------------------------*/
             /*------------------------- Build like --------------------------*/
             $like_query = implode(' OR ', $parts);
             if ($like_query == "") {
                 $like_query = "(1)";
             } else {
                 $like_query = "({$like_query})";
             }
             /*---------------------------------------------------------------*/
             /*---------------------- Build relevance ------------------------*/
             $relevance = implode(' + ', $relevance_parts);
             if ($searchData['userelevance'] != 1 || $relevance == "") {
                 $relevance = "(1)";
             } else {
                 $relevance = "({$relevance})";
             }
             /*---------------------------------------------------------------*/
             $querystr = "\r\n                 SELECT\r\n                   " . $wpdb->prefix . "bp_activity.id as id,\r\n                   " . $wpdb->prefix . "bp_activity.content as title,\r\n                   " . $wpdb->prefix . "bp_activity.content as content,\r\n                   " . $wpdb->prefix . "bp_activity.date_recorded as date,\r\n                   {$wpdb->users}.user_nicename as author,\r\n                   " . $wpdb->prefix . "bp_activity.user_id as author_id,\r\n                   'bp_activity' as content_type,\r\n                   {$relevance} as relevance\r\n                 FROM\r\n                   " . $wpdb->prefix . "bp_activity\r\n                 LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID = " . $wpdb->prefix . "bp_activity.user_id\r\n                 WHERE\r\n                   (" . $wpdb->prefix . "bp_activity.component = 'activity' AND " . $wpdb->prefix . "bp_activity.is_spam = 0)\r\n                   AND {$like_query}\r\n                   ORDER BY relevance DESC, title ASC";
             $activityresults = $wpdb->get_results($querystr, OBJECT);
             foreach ($activityresults as $k => $v) {
                 $activityresults[$k]->link = bp_activity_get_permalink($v->id);
                 $activityresults[$k]->image = bp_core_fetch_avatar(array('item_id' => $v->author_id, 'html' => false));
             }
         }
         do_action('bbpress_init');
     }
     $this->results = array('repliesresults' => $repliesresults, 'groupresults' => $groupresults, 'activityresults' => $activityresults);
     return $this->results;
 }
 /**
  * Pre-groups the results if grouping is selected
  *
  * @return array of results
  */
 protected function group()
 {
     $pageposts = $this->results;
     $options = $this->options;
     $searchData = $this->searchData;
     $allpageposts = array();
     $s = $this->s;
     $_s = $this->_s;
     if ($options['do_group'] == false) {
         return;
     }
     // Need a suffix to separate blogs
     if (isset($blog)) {
         $_key_suff = "_" . $blog;
     } else {
         $_key_suff = "";
     }
     /* Regrouping */
     // By category
     if ($searchData['groupby'] == 1 && count($pageposts) > 0) {
         $_pageposts = array();
         foreach ($pageposts as $k => $v) {
             if ($v->ttid == "" || $v->post_type != 'post' && $searchData['pageswithcategories'] != 1) {
                 $_pageposts['99999']['data'][] = $v;
                 continue;
             }
             $_term_ids = str_replace('----', ',', $v->ttid);
             $_term_ids = str_replace('--', '', $_term_ids);
             $_term_ids = explode(',', $_term_ids);
             if (count($_term_ids) <= 0) {
                 $_term_ids = array($v->term_id);
             }
             $cat_count = 0;
             foreach ($_term_ids as $_term_id) {
                 $cat_count++;
                 if (w_isset_def($searchData['group_exclude_duplicates'], 0) == 1 && $cat_count > 1) {
                     break;
                 }
                 $cat = get_category($_term_id);
                 if (is_object($cat) && trim($cat->name) != "") {
                     $_pageposts[$_term_id]['data'][] = $v;
                 }
             }
         }
         foreach ($_pageposts as $k => $v) {
             if ($searchData['showpostnumber'] == 1) {
                 $num = " (" . count($_pageposts[$k]['data']) . ")";
             } else {
                 $num = "";
             }
             if ($k != 99999) {
                 $cat = get_category($k);
                 $_pageposts[$k]['name'] = str_replace('%GROUP%', $cat->name, asp_icl_t("Group by header text", $searchData['groupbytext'])) . $num;
             } else {
                 $_pageposts[$k]['name'] = asp_icl_t("Uncategorized group header", $searchData['uncategorizedtext']) . $num;
             }
         }
         $pageposts = null;
         $pageposts['grouped'] = 1;
         $pageposts['items'] = $_pageposts;
         ksort($pageposts['items']);
         if ($_key_suff != "") {
             foreach ($pageposts['items'] as $k => $v) {
                 $pageposts['items'][$k . $_key_suff] = $v;
                 unset($pageposts['items'][$k]);
             }
         }
         // By post type
     } else {
         if ($searchData['groupby'] == 2 && count($pageposts) > 0) {
             foreach ($pageposts as $k => $v) {
                 $_pageposts[$v->post_type]['data'][] = $v;
             }
             foreach ($_pageposts as $k => $v) {
                 if ($searchData['showpostnumber'] == 1) {
                     $num = " (" . count($_pageposts[$k]['data']) . ")";
                 } else {
                     $num = "";
                 }
                 $obj = get_post_type_object($k);
                 $_pageposts[$k]['name'] = str_replace('%GROUP%', $obj->labels->singular_name, asp_icl_t("Group by header text", $searchData['groupbytext'])) . $num;
             }
             $pageposts = null;
             $pageposts['grouped'] = 1;
             $pageposts['items'] = $_pageposts;
             ksort($pageposts['items']);
         }
     }
     if (($searchData['groupby'] == 1 || $searchData['groupby'] == 2) && count($pageposts) > 0 && count($allpageposts) > 0) {
         $allpageposts['items'] = array_merge($allpageposts['items'], $pageposts['items']);
     } else {
         $allpageposts = array_merge($allpageposts, $pageposts);
     }
     $this->results = $allpageposts;
     return $this->results;
 }
 protected function post_process()
 {
     parent::post_process();
     $searchId = $this->searchId;
     $searchData = $this->searchData;
     if (w_isset_def($searchData['attachment_use_image'], 1) == 1) {
         foreach ($this->results as $k => $r) {
             if (strpos($r->post_mime_type, 'image/') !== false && $r->guid != "") {
                 $this->results[$k]->image = $r->guid;
             }
         }
     }
     return $this->results;
 }
Example #24
0
 protected function post_process()
 {
     $pageposts = is_array($this->results) ? $this->results : array();
     $options = $this->options;
     $searchData = $this->searchData;
     $s = $this->s;
     $_s = $this->_s;
     $performance_options = get_option('asl_performance');
     if (is_multisite()) {
         $home_url = network_home_url();
     } else {
         $home_url = home_url();
     }
     foreach ($pageposts as $k => $v) {
         $r =& $pageposts[$k];
         $r->title = w_isset_def($r->title, null);
         $r->content = w_isset_def($r->content, null);
         $r->image = w_isset_def($r->image, null);
         $r->author = w_isset_def($r->author, null);
         $r->date = w_isset_def($r->date, null);
     }
     /* Images, title, desc */
     foreach ($pageposts as $k => $v) {
         // Let's simplify things
         $r =& $pageposts[$k];
         $r->title = apply_filters('asl_result_title_before_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asl_result_content_before_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asl_result_image_before_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asl_result_author_before_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asl_result_date_before_prostproc', $r->date, $r->id);
         $r->link = get_permalink($v->id);
         $image_settings = $searchData['image_options'];
         if ($image_settings['show_images'] != 0) {
             $im = $this->getBFIimage($r);
             if ($im != '' && strpos($im, "mshots/v1") === false && w_isset_def($performance_options['image_cropping'], 0) == 1) {
                 if (w_isset_def($image_settings['image_transparency'], 1) == 1) {
                     $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true);
                 } else {
                     $bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true, 'color' => wpdreams_rgb2hex($image_settings['image_bg_color']));
                 }
                 $r->image = bfi_thumb($im, $bfi_params);
             } else {
                 $r->image = $im;
             }
         }
         if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
             $r->title = get_the_title($r->id);
         } else {
             if ($searchData['titlefield'] == "1") {
                 if (strlen($r->excerpt) >= 200) {
                     $r->title = wd_substr_at_word($r->excerpt, 200);
                 } else {
                     $r->title = $r->excerpt;
                 }
             } else {
                 $mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
                 if (isset($mykey_values[0])) {
                     $r->title = $mykey_values[0];
                 } else {
                     $r->title = get_the_title($r->id);
                 }
             }
         }
         //remove the search shortcodes properly
         add_shortcode('wpdreams_ajaxsearchpro', array($this, 'return_empty_string'));
         add_shortcode('wpdreams_ajaxsearchlite', array($this, 'return_empty_string'));
         if (!isset($searchData['striptagsexclude'])) {
             $searchData['striptagsexclude'] = "<a><span>";
         }
         if (!isset($searchData['descriptionfield']) || $searchData['descriptionfield'] == "0" || is_array($searchData['descriptionfield'])) {
             if (w_isset_def($searchData['strip_shortcodes'], 0) == 1) {
                 $r->content = strip_shortcodes($r->content);
             }
             if (function_exists('qtrans_getLanguage')) {
                 $r->content = apply_filters('the_content', $r->content);
             }
             $_content = strip_tags($r->content);
         } else {
             if ($searchData['descriptionfield'] == "1") {
                 $_content = strip_tags($r->excerpt);
             } else {
                 if ($searchData['descriptionfield'] == "2") {
                     $_content = strip_tags(get_the_title($r->id));
                 } else {
                     $mykey_values = get_post_custom_values($searchData['descriptionfield'], $r->id);
                     if (isset($mykey_values[0])) {
                         $_content = strip_tags($mykey_values[0]);
                     } else {
                         $_content = strip_tags($r->content);
                     }
                 }
             }
         }
         if ($_content == "" && $r->content != '') {
             $_content = $r->content;
         }
         if ($_content != "") {
             $_content = str_replace('[wpdreams_ajaxsearchlite]', "", $_content);
         }
         if ($_content != "") {
             $_content = apply_filters('the_content', $_content);
         }
         // Remove styles and scripts
         $_content = preg_replace(array('#<script(.*?)>(.*?)</script>#is', '#<style(.*?)>(.*?)</style>#is'), '', $_content);
         $_content = strip_tags($_content);
         // Get the words from around the search phrase, or just the description
         if (w_isset_def($searchData['description_context'], 1) == 1 && count($_s) > 0) {
             $_content = $this->context_find($_content, $_s[0], floor($searchData['descriptionlength'] / 6), $searchData['descriptionlength']);
         } else {
             if ($_content != '' && strlen($_content) > $searchData['descriptionlength']) {
                 $_content = wd_substr_at_word($_content, $searchData['descriptionlength']) . "...";
             }
         }
         $_content = wd_closetags($_content);
         $r->content = $_content;
         // -------------------------- Woocommerce Fixes -----------------------------
         // A trick to fix the url
         if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
             $r->title = preg_replace("/(Variation) \\#(\\d+) (of)/si", '', $r->title);
             $wc_prod_var_o = new WC_Product_Variation($r->id);
             $r->link = $wc_prod_var_o->get_permalink();
         }
         // --------------------------------------------------------------------------
         $r->title = apply_filters('asl_result_title_after_prostproc', $r->title, $r->id);
         $r->content = apply_filters('asl_result_content_after_prostproc', $r->content, $r->id);
         $r->image = apply_filters('asl_result_image_after_prostproc', $r->image, $r->id);
         $r->author = apply_filters('asl_result_author_after_prostproc', $r->author, $r->id);
         $r->date = apply_filters('asl_result_date_after_prostproc', $r->date, $r->id);
     }
     /* !Images, title, desc */
     //var_dump($pageposts); die();
     $this->results = $pageposts;
     return $pageposts;
 }
Example #25
0
    function wpdreams_asp_shortcode($atts)
    {
        $style = null;
        // Fallback on IE<=8
        if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(?i)msie [6-8]/', $_SERVER['HTTP_USER_AGENT'])) {
            get_search_form(true);
            return;
        }
        extract(shortcode_atts(array('id' => 'something', 'extra_class' => ''), $atts));
        if (isset($_POST['action']) && $_POST['action'] == "ajaxsearchpro_preview") {
            require_once ASP_PATH . "backend" . DIRECTORY_SEPARATOR . "settings" . DIRECTORY_SEPARATOR . "types.inc.php";
            parse_str($_POST['formdata'], $style);
            $style = wpdreams_parse_params($style);
            ob_start();
            include ASP_PATH . "/css/style.css.php";
            $out = ob_get_contents();
            ob_end_clean();
            //file_put_contents($file, $out, FILE_TEXT);
            ?>
            <div style='display: none;' id="asp_preview_options"><?php 
            echo base64_encode(serialize($style));
            ?>
</div>
            <style>
                @import url('<?php 
            echo plugin_dir_url(__FILE__);
            ?>
../css/style.basic.css?r=<?php 
            echo rand(1, 123123123);
            ?>
');
                <?php 
            echo $out;
            ?>
            </style>
        <?php 
        } else {
            global $wpdb;
            if (isset($wpdb->base_prefix)) {
                $_prefix = $wpdb->base_prefix;
            } else {
                $_prefix = $wpdb->prefix;
            }
            // Visual composer, first selected row, no data, so select the first one
            if ($id == 99999) {
                $search = $wpdb->get_results("SELECT * FROM " . $_prefix . "ajaxsearchpro LIMIT 1", ARRAY_A);
                if (!isset($search[0])) {
                    return "There are no search instances to display. Please create one.";
                }
            } else {
                $search = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $_prefix . "ajaxsearchpro WHERE id=%d", $id), ARRAY_A);
                if (!isset($search[0])) {
                    return "This search form (with id {$id}) does not exist!";
                }
            }
            // Parse the id again for correction
            $id = $search[0]['id'] + 0;
            $wpdreams_ajaxsearchpros[$search[0]['id']] = 1;
            $search[0]['data'] = json_decode($search[0]['data'], true);
            $style = $search[0]['data'];
        }
        // Don't move this above any return statements!
        self::$instanceCount++;
        if (isset(self::$perInstanceCount[$id])) {
            self::$perInstanceCount[$id]++;
        } else {
            self::$perInstanceCount[$id] = 1;
        }
        $def_data = get_option('asp_defaults');
        $style = array_merge($def_data, $style);
        $settingsHidden = w_isset_def($style['show_frontend_search_settings'], 1) != 1 ? true : false;
        $asp_f_items = array();
        if (w_isset_def($style['custom_field_items'], "") != "") {
            $asp_f_items = explode('|', $style['custom_field_items']);
            $asp_f_uncoded_items = $asp_f_items;
            foreach ($asp_f_items as $k => $v) {
                $asp_f_items[$k] = json_decode(base64_decode($v));
                if (isset($asp_f_items[$k]->asp_f_radio_value)) {
                    $asp_f_items[$k]->asp_f_radio_value = preg_split("/\\r\\n|\\r|\\n/", $asp_f_items[$k]->asp_f_radio_value);
                }
                if (isset($asp_f_items[$k]->asp_f_dropdown_value)) {
                    $asp_f_items[$k]->asp_f_dropdown_value = preg_split("/\\r\\n|\\r|\\n/", $asp_f_items[$k]->asp_f_dropdown_value);
                }
                if (isset($asp_f_items[$k]->asp_f_checkboxes_value)) {
                    $asp_f_items[$k]->asp_f_checkboxes_value = preg_split("/\\r\\n|\\r|\\n/", $asp_f_items[$k]->asp_f_checkboxes_value);
                }
            }
        }
        do_action('asp_layout_before_shortcode', $id);
        $out = "";
        ob_start();
        include ASP_PATH . "includes/views/asp.shortcode.php";
        $out = ob_get_clean();
        do_action('asp_layout_after_shortcode', $id);
        return $out;
    }
 if (!isset($style['selected-showterms']) || !is_array($style['selected-showterms'])) {
     $style['selected-showterms'] = array();
 }
 //$_all_term_ids = wpdreams_get_all_term_ids();
 //$_needed_terms = array_diff($_all_term_ids, $style['selected-excludeterms']);
 //$_invisible_terms = array_diff($_needed_terms, $style['selected-showterms']);
 $_close_fieldset = false;
 $_terms = array();
 $visible_terms = array();
 ob_start();
 foreach ($style['selected-showterms'] as $taxonomy => $terms) {
     if (is_array($terms)) {
         $_needed_terms_full = get_terms($taxonomy, array('orderby' => $term_ordering[0], 'order' => $term_ordering[1], 'include' => $terms));
         $_needed_terms_sorted = array();
         $needed_terms_flat = array();
         if (w_isset_def($style['frontend_term_hierarchy'], 1) == 1) {
             wd_sort_terms_hierarchicaly($_needed_terms_full, $_needed_terms_sorted);
             wd_flatten_hierarchical_terms($_needed_terms_sorted, $needed_terms_flat);
         } else {
             $needed_terms_flat = $_needed_terms_full;
         }
         if ($style['showseparatefilterboxes'] != 0) {
             $_x_term = get_taxonomies(array("name" => $taxonomy), "objects");
             //var_dump($_x_term);
             if (isset($_x_term[$taxonomy])) {
                 $_tax_name = $_x_term[$taxonomy]->label;
             }
             ?>
             <fieldset>
             <legend><?php 
             echo asp_icl_t("Taxonomy filter box text", $style['exsearchintaxonomiestext']) . " " . $_tax_name;
Example #27
0
                return $instance1 . ", " . $instance2 . " {";
            } else {
                return $instance1 . " " . $instance2;
            }
        }
    }
}
// Load the corresponding CSS3 loader
$asp_loader_css_full = file_get_contents(ASP_CSS_PATH . "style.loaders.css");
$asp_loader_css = wd_get_inner_substring($asp_loader_css_full, "/*[general]*/");
$asp_loader_css .= " " . wd_get_inner_substring($asp_loader_css_full, "/*[" . w_isset_def($style['loader_image'], "simple-circle") . "]*/");
$asp_loader_css = str_replace("#fff", $style['loadingimage_color'], $asp_loader_css);
// Load the required CSS3 animation
$asp_anim_css_full = file_get_contents(ASP_CSS_PATH . "animations.css");
$asp_anim_css = wd_get_inner_substring($asp_anim_css_full, "/*[" . w_isset_def($style['res_items_animation'], "fadeInDown") . "]*/");
$asp_anim_css_mob = wd_get_inner_substring($asp_anim_css_full, "/*[" . w_isset_def($style['res_items_animation_m'], "voidanim") . "]*/");
if ($asp_anim_css != $asp_anim_css_mob) {
    $asp_anim_css .= " " . $asp_anim_css_mob;
}
// Do some stuff with the base CSS if the compatibility level is Maximum
if ($use_strong_compatibility == true) {
    $base_css = file_get_contents(ASP_PATH . "/css/style.basic.css");
    $css_helper = new aspCSSCompatibilityReplace($id);
    $base_css = preg_replace_callback("/^div\\.ajaxsearchpro\\[id(.*?[ ]*,)/im", array($css_helper, "callback"), $base_css);
    $css_helper = new aspCSSCompatibilityReplace($id, true);
    $base_css = preg_replace_callback("/^div\\.ajaxsearchpro\\[id(.*?)[ ]*\\{/im", array($css_helper, "callback"), $base_css);
}
$css_helper = new aspCSSCompatibilityReplace($id);
$asp_loader_css = preg_replace_callback("/^div\\[id(.*?[ ]*,)/im", array($css_helper, "callback"), $asp_loader_css);
$css_helper = new aspCSSCompatibilityReplace($id, true);
$asp_loader_css = preg_replace_callback("/^div\\[id(.*?)[ ]*\\{/im", array($css_helper, "callback"), $asp_loader_css);
Example #28
0
 /**
  * Prints the scripts
  */
 function scripts()
 {
     global $wp_version;
     // ------------ Dequeue some scripts causing issues on the back-end --------------
     wp_dequeue_script('otw-admin-colorpicker');
     wp_dequeue_script('otw-admin-select2');
     wp_dequeue_script('otw-admin-otwpreview');
     wp_dequeue_script('otw-admin-fonts');
     wp_dequeue_script('otw-admin-functions');
     wp_dequeue_script('otw-admin-variables');
     // Fallback on IE<=8
     if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(?i)msie [6-8]/', $_SERVER['HTTP_USER_AGENT'])) {
         // Oh, this is IE 8 or below, abort mission
         return;
     }
     $comp_settings = get_option('asp_compatibility');
     $load_in_footer = w_isset_def($comp_settings['load_in_footer'], 1) == 1 ? true : false;
     $css_async_load = w_isset_def($comp_settings['css_async_load'], 0) == 1 ? true : false;
     if ($comp_settings !== false && isset($comp_settings['loadpolaroidjs']) && $comp_settings['loadpolaroidjs'] == 0) {
     } else {
         wp_register_script('wpdreams-photostack', ASP_URL . 'js/nomin/photostack.js', array("jquery"), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-photostack');
     }
     $js_source = w_isset_def($comp_settings['js_source'], 'min-scoped');
     $load_noui = w_isset_def($comp_settings['load_noui_js'], 1);
     $load_isotope = w_isset_def($comp_settings['load_isotope_js'], 1);
     $minify_string = ($load_noui == 1 ? '-noui' : '') . ($load_isotope == 1 ? '-isotope' : '');
     if (ASP_DEBUG) {
         $js_source = 'nomin';
     }
     if ($css_async_load) {
         wp_register_script('wd-asp-async-loader', ASP_URL . 'js/nomin/async.css.js', array("jquery"), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wd-asp-async-loader');
     }
     if ($js_source == 'nomin' || $js_source == 'nomin-scoped') {
         $prereq = "jquery";
         if ($js_source == "nomin-scoped") {
             $prereq = "wpdreams-aspjquery";
             wp_register_script('wpdreams-aspjquery', ASP_URL . 'js/' . $js_source . '/aspjquery.js', array(), ASP_CURR_VER_STRING, $load_in_footer);
             wp_enqueue_script('wpdreams-aspjquery');
         }
         wp_register_script('wpdreams-gestures', ASP_URL . 'js/' . $js_source . '/jquery.gestures.js', array($prereq), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-gestures');
         wp_register_script('wpdreams-easing', ASP_URL . 'js/' . $js_source . '/jquery.easing.js', array($prereq), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-easing');
         /*wp_register_script('wpdreams-mousewheel', ASP_URL . 'js/' . $js_source . '/jquery.mousewheel.js', array($prereq));
           wp_enqueue_script('wpdreams-mousewheel');*/
         wp_register_script('wpdreams-scroll', ASP_URL . 'js/' . $js_source . '/jquery.mCustomScrollbar.js', array($prereq), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-scroll');
         wp_register_script('wpdreams-highlight', ASP_URL . 'js/' . $js_source . '/jquery.highlight.js', array($prereq), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-highlight');
         if ($load_noui) {
             wp_register_script('wpdreams-nouislider', ASP_URL . 'js/' . $js_source . '/jquery.nouislider.all.js', array($prereq), ASP_CURR_VER_STRING, $load_in_footer);
             wp_enqueue_script('wpdreams-nouislider');
         }
         if ($load_isotope) {
             wp_register_script('wpdreams-rpp-isotope', ASP_URL . 'js/' . $js_source . '/rpp_isotope.js', array($prereq), ASP_CURR_VER_STRING, $load_in_footer);
             wp_enqueue_script('wpdreams-rpp-isotope');
         }
         wp_register_script('wpdreams-ajaxsearchpro', ASP_URL . 'js/' . $js_source . '/jquery.ajaxsearchpro.js', array($prereq, "wpdreams-scroll"), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-ajaxsearchpro');
         wp_register_script('wpdreams-ajaxsearchpro-widgets', ASP_URL . 'js/' . $js_source . '/asp_widgets.js', array($prereq, "wpdreams-ajaxsearchpro"), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-ajaxsearchpro-widgets');
         wp_register_script('wpdreams-ajaxsearchpro-wrapper', ASP_URL . 'js/' . $js_source . '/asp_wrapper.js', array($prereq, "wpdreams-ajaxsearchpro"), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-ajaxsearchpro-wrapper');
     } else {
         wp_enqueue_script('jquery');
         wp_register_script('wpdreams-ajaxsearchpro', ASP_URL . "js/" . $js_source . "/jquery.ajaxsearchpro" . $minify_string . ".min.js", array(), ASP_CURR_VER_STRING, $load_in_footer);
         wp_enqueue_script('wpdreams-ajaxsearchpro');
     }
     $ajax_url = admin_url('admin-ajax.php');
     if (w_isset_def($comp_settings['usecustomajaxhandler'], 0) == 1) {
         $ajax_url = ASP_URL . 'ajax_search.php';
     }
     if (ASP_DEBUG < 1 && strpos(w_isset_def($comp_settings['js_source'], 'min-scoped'), "scoped") !== false) {
         $scope = "aspjQuery";
     } else {
         $scope = "jQuery";
     }
     /**
      * This stays here for a bit, let customers transition smoothly
      *
      * @deprecated since version 4.5.3
      */
     wp_localize_script('wpdreams-ajaxsearchpro', 'ajaxsearchpro', array('ajaxurl' => $ajax_url, 'backend_ajaxurl' => admin_url('admin-ajax.php'), 'js_scope' => $scope));
     // The new variable is ASP
     wp_localize_script('wpdreams-ajaxsearchpro', 'ASP', array('ajaxurl' => $ajax_url, 'backend_ajaxurl' => admin_url('admin-ajax.php'), 'js_scope' => $scope, 'asp_url' => ASP_URL, 'media_query' => get_option("asp_media_query", "defn")));
 }
                <?php 
                //$counter++;
            }
            if ($style['showseparatefilterboxes'] != 0) {
                ?>
                </div>
                </fieldset>
            <?php 
            }
        }
    }
    $term_content = ob_get_clean();
}
?>
<fieldset<?php 
echo trim($cat_content) == '' || count(w_isset_def($needed_cat_flat, array())) <= 0 ? ' class="hiddend"' : '';
?>
>
    <?php 
if ($style['exsearchincategoriestext'] != "") {
    ?>
        <legend><?php 
    echo asp_icl_t("Categories filter box text", $style['exsearchincategoriestext']);
    ?>
</legend>
        <?php 
    echo $cat_content;
    ?>
    <?php 
}
?>
"
               name="customset[]" checked="checked"/>
        <label for="<?php 
    echo $id;
    ?>
customset_<?php 
    echo $id . $i;
    ?>
"></label>
    </div>
    <div class="label hiddend"></div>
<?php 
    $i++;
}
$cpt_content = ob_get_clean();
$cpt_label = w_isset_def($style['custom_types_label'], 'Filter by Custom Post Type');
?>
<fieldset class="asp_sett_scroll<?php 
echo count($style['selected-showcustomtypes']) > 0 ? '' : ' hiddend';
?>
">
    <?php 
if ($cpt_label != '') {
    ?>
    <legend><?php 
    echo asp_icl_t("Custom post types label", $cpt_label);
    ?>
</legend>
    <?php 
}
?>