/** * Returns args for search categories dropdown. * * @param string $location (optional) * * @return array */ function cp_get_dropdown_categories_search_args($location = 'bar') { global $cp_options; $defaults = array('show_option_all' => __('All Categories', APP_TD), 'hierarchical' => $cp_options->cat_hierarchy, 'hide_empty' => $cp_options->cat_hide_empty, 'depth' => $cp_options->search_depth, 'show_count' => $cp_options->cat_count, 'pad_counts' => $cp_options->cat_count, 'orderby' => 'name', 'title_li' => '', 'use_desc_for_title' => 1, 'name' => 'scat', 'selected' => cp_get_search_catid(), 'taxonomy' => APP_TAX_CAT); if ($location == 'bar') { $defaults['class'] = 'searchbar'; $defaults['tab_index'] = '2'; } $location = sanitize_title_with_dashes($location); $args = apply_filters('cp_dropdown_search_' . $location . '_args', $defaults); return $args; }
function cp_ad_search_widget() { ?> <div class="recordfromblog"> <form action="<?php bloginfo('url'); ?> /" method="get" id="searchform" class="form_search"> <input name="s" type="text" id="s" class="editbox_search" <?php if (get_search_query()) { echo 'value="' . trim(strip_tags(esc_attr(get_search_query()))) . '"'; } else { ?> value="<?php _e('What are you looking for?', 'appthemes'); ?> " onfocus="if (this.value == '<?php _e('What are you looking for?', 'appthemes'); ?> ') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('What are you looking for?', 'appthemes'); ?> ';}" <?php } ?> /> <?php wp_dropdown_categories('show_option_all=' . __('All Categories', 'appthemes') . '&hierarchical=' . get_option('cp_cat_hierarchy') . '&hide_empty=' . get_option('cp_cat_hide_empty') . '&depth=' . get_option('cp_search_depth') . '&show_count=' . get_option('cp_cat_child_count') . '&orderby=' . get_option('cp_cat_orderby') . '&title_li=&use_desc_for_title=1&name=scat&selected=' . cp_get_search_catid() . '&taxonomy=' . APP_TAX_CAT); ?> <div class="pad5"></div> <input type="submit" class="btn_orange" value="<?php _e('Search', 'appthemes'); ?> " title="<?php _e('Search', 'appthemes'); ?> " id="go" name="sa" /> </form> </div><!-- /recordfromblog --> <?php }
function cp_refine_search_builder($results) { global $wpdb; $cp_min_price = str_replace(',', '', $wpdb->get_var("SELECT min( CAST( meta_value AS UNSIGNED ) ) FROM {$wpdb->postmeta} WHERE meta_key = 'cp_price'")); $cp_max_price = str_replace(',', '', $wpdb->get_var("SELECT max( CAST( meta_value AS UNSIGNED ) ) FROM {$wpdb->postmeta} WHERE meta_key = 'cp_price'")); $thousands = $cp_max_price > 1000 ? true : false; $locarray = array(); ?> <script type="text/javascript"> // <![CDATA[ // toggles the refine search field values jQuery(document).ready(function() { jQuery('div.handle').click(function() { jQuery(this).next('div.element').animate({ height: ['toggle', 'swing'], opacity: 'toggle' }, 200 ); jQuery(this).toggleClass('close', 'open'); return false; }); <?php foreach ($_GET as $field => $val) { ?> jQuery('.<?php echo esc_js($field); ?> div.handle').toggleClass('close', 'open'); jQuery('.<?php echo esc_js($field); ?> div.element').show(); <?php } ?> }); // ]]> </script> <div class="shadowblock_out"> <div class="shadowblock"> <h2 class="dotted"><?php _e('Refine Results', APP_TD); ?> </h2> <ul class="refine"> <form action="<?php if (is_tax(APP_TAX_CAT)) { echo get_term_link(get_query_var('term'), get_query_var('taxonomy')); } else { bloginfo('wpurl'); } ?> " method="get" name="refine-search"> <?php if (!is_tax(APP_TAX_CAT)) { ?> <input type="hidden" name="s" value="<?php echo esc_attr(cp_get_search_term()); ?> " /> <input type="hidden" name="scat" value="<?php echo esc_attr(cp_get_search_catid()); ?> " /> <?php } ?> <?php // grab the price and location fields first and put into a separate array // then remove them from the results array so they don't print out again foreach ($results as $key => $value) { switch ($value->field_name) { case 'cp_city': $locarray[0] = $results[$key]; unset($results[$key]); break; case 'cp_zipcode': $locarray[1] = $results[$key]; unset($results[$key]); break; case 'cp_price': $locarray[2] = $results[$key]; unset($results[$key]); break; case 'cp_country': $locarray[3] = $results[$key]; unset($results[$key]); break; case 'cp_region': $locarray[4] = $results[$key]; unset($results[$key]); break; } } // sort array by key so we get the city/zip code first ksort($locarray); // echo '<pre>'; // print_r($locarray); // echo '</pre><br/><br/>'; // both zip code and city have been checked if (array_key_exists(0, $locarray) && array_key_exists(1, $locarray)) { $flabel = sprintf(__('%s or %s', APP_TD), $locarray[0]->field_label, $locarray[1]->field_label); $fname = 'cp_city_zipcode'; } elseif (array_key_exists(0, $locarray)) { // must be the city only $flabel = $locarray[0]->field_label; $fname = 'cp_city_zipcode'; } elseif (array_key_exists(1, $locarray)) { // must be the zip code only $flabel = $locarray[1]->field_label; $fname = 'cp_city_zipcode'; } $distance_unit = 'mi' == get_option('cp_distance_unit', 'mi') ? __('miles', APP_TD) : __('kilometers', APP_TD); // show the city/zip code field and radius slider bar if (array_key_exists(0, $locarray) || array_key_exists(1, $locarray)) { ?> <script type="text/javascript"> // <![CDATA[ jQuery(document).ready(function() { jQuery('#dist-slider').slider( { range: 'min', min: 0, max: 100, value: <?php echo esc_js(isset($_GET['distance']) ? intval($_GET['distance']) : '50'); ?> , step: 5, slide: function(event, ui) { jQuery('#distance').val(ui.value + ' <?php echo esc_js($distance_unit); ?> '); } }); jQuery('#distance').val(jQuery('#dist-slider').slider('value') + ' <?php echo esc_js($distance_unit); ?> '); }); // ]]> </script> <li class="distance"> <label class="title"><?php echo $flabel; ?> </label> <input name="<?php echo esc_attr($fname); ?> " id="<?php echo esc_attr($fname); ?> " type="text" minlength="2" value="<?php if (isset($_GET[$fname])) { echo esc_attr($_GET[$fname]); } ?> " class="text" /> <div class="clr"></div> <label for="distance" class="title"><?php _e('Radius', APP_TD); ?> :</label> <input type="text" id="distance" name="distance" /> <div id="dist-slider"></div> </li> <?php } // now loop through the other special fields foreach ($locarray as $value) { // show the price field range slider if ($value->field_name == 'cp_price') { $curr_symbol = get_option('cp_curr_symbol', '$'); $cp_curr_symbol_pos = get_option('cp_curr_symbol_pos', 'left'); if (isset($_GET['amount'])) { $amount = explode(' - ', $_GET['amount']); } $amount[0] = empty($amount[0]) ? $cp_min_price : $amount[0]; $amount[1] = empty($amount[1]) ? $cp_max_price : $amount[1]; $amount[0] = str_replace(array(',', $curr_symbol, ' '), '', $amount[0]); $amount[1] = str_replace(array(',', $curr_symbol, ' '), '', $amount[1]); ?> <script type="text/javascript"> // <![CDATA[ jQuery(document).ready(function() { function cp_show_price_slider(min_price, max_price, min_value, max_value, thousands) { min_value = ( (thousands && min_value <= 1000) ? 1000 : ( (!thousands && min_value >= 1000) ? 0 : min_value ) ); max_value = ( (thousands && max_value <= 1000) ? max_price : ( (!thousands && max_value >= 1000) ? 1000 : max_value ) ); jQuery('#slider-range').slider( { range: true, min: ( (thousands) ? 1000 : min_price ), max: ( (thousands) ? max_price : 1000 ), step: 1, values: [ min_value, max_value ], slide: function(event, ui) { <?php switch ($cp_curr_symbol_pos) { case 'left': ?> jQuery('#amount').val('<?php echo $curr_symbol; ?> ' + ui.values[0] + ' - <?php echo $curr_symbol; ?> ' + ui.values[1]);<?php break; case 'left_space': ?> jQuery('#amount').val('<?php echo $curr_symbol; ?> ' + ui.values[0] + ' - <?php echo $curr_symbol; ?> ' + ui.values[1]);<?php break; case 'right': ?> jQuery('#amount').val(ui.values[0] + '<?php echo $curr_symbol; ?> - ' + ui.values[1] + '<?php echo $curr_symbol; ?> ' );<?php break; case 'right_space': ?> jQuery('#amount').val(ui.values[0] + ' <?php echo $curr_symbol; ?> - ' + ui.values[1] + ' <?php echo $curr_symbol; ?> ' );<?php break; } ?> } }); <?php switch ($cp_curr_symbol_pos) { case 'left': ?> jQuery('#amount').val('<?php echo $curr_symbol; ?> ' + jQuery('#slider-range').slider('values', 0) + ' - <?php echo $curr_symbol; ?> ' + jQuery('#slider-range').slider('values', 1));<?php break; case 'left_space': ?> jQuery('#amount').val('<?php echo $curr_symbol; ?> ' + jQuery('#slider-range').slider('values', 0) + ' - <?php echo $curr_symbol; ?> ' + jQuery('#slider-range').slider('values', 1));<?php break; case 'right': ?> jQuery('#amount').val(jQuery('#slider-range').slider('values', 0) + '<?php echo $curr_symbol; ?> - ' + jQuery('#slider-range').slider('values', 1) + '<?php echo $curr_symbol; ?> ');<?php break; case 'right_space': ?> jQuery('#amount').val(jQuery('#slider-range').slider('values', 0) + ' <?php echo $curr_symbol; ?> - ' + jQuery('#slider-range').slider('values', 1) + ' <?php echo $curr_symbol; ?> ');<?php break; } ?> }; jQuery("#thousands").click(function() { thousands = ( jQuery(this).is(":checked") ) ? true : false; cp_show_price_slider(<?php echo esc_js(intval($cp_min_price)); ?> , <?php echo esc_js(intval($cp_max_price)); ?> , <?php echo esc_js(intval($amount[0])); ?> , <?php echo esc_js(intval($amount[1])); ?> , thousands); }); thousands = ( jQuery("#thousands").is(":checked") ) ? true : false; cp_show_price_slider(<?php echo esc_js(intval($cp_min_price)); ?> , <?php echo esc_js(intval($cp_max_price)); ?> , <?php echo esc_js(intval($amount[0])); ?> , <?php echo esc_js(intval($amount[1])); ?> , thousands); }); // ]]> </script> <li class="amount"> <label class="title"><?php echo esc_html(translate($value->field_label, APP_TD)); ?> :</label> <input type="text" id="amount" name="amount" /> <div id="slider-range"></div> <?php if ($thousands) { ?> <label class="title"><?php echo esc_html(__('Show Thousands', APP_TD)); ?> :</label><input type="checkbox" id="thousands" name="thousands" <?php checked(isset($_GET['thousands'])); ?> /> <?php } ?> </li> <?php } if ('cp_region' == $value->field_name || 'cp_country' == $value->field_name) { echo cp_refine_fields($value->field_label, $value->field_name, $value->field_values); } // show the state values // uncomment to include states // if ( $value->field_name == 'cp_state' ) // echo cp_refine_fields( $value->field_label, $value->field_name, $value->field_values ); } // echo '<pre>'; // print_r($results); // echo'</pre>'; foreach ($results as $key => $result) { switch ($result->field_type) { // case 'text box': case 'radio': case 'checkbox': case 'drop-down': echo cp_refine_fields($result->field_label, $result->field_name, $result->field_values); break; } ?> <?php } ?> <div class="pad10"></div> <button class="obtn btn_orange" type="submit" tabindex="1" id="go" value="Go" name="sa"><?php _e('Refine Results ››', APP_TD); ?> </button> <input type="hidden" name="refine_search" value="yes" /> </form> </ul> <div class="clr"></div> </div> </div> <?php }
function cp_refine_search_builder($results) { global $wpdb, $cp_options; $cp_min_price = str_replace(',', '', $wpdb->get_var("SELECT min( CAST( m.meta_value AS UNSIGNED ) ) FROM {$wpdb->postmeta} m INNER JOIN {$wpdb->posts} p ON m.post_id = p.ID WHERE m.meta_key = 'cp_price' AND p.post_status = 'publish'")); $cp_max_price = str_replace(',', '', $wpdb->get_var("SELECT max( CAST( m.meta_value AS UNSIGNED ) ) FROM {$wpdb->postmeta} m INNER JOIN {$wpdb->posts} p ON m.post_id = p.ID WHERE m.meta_key = 'cp_price' AND p.post_status = 'publish'")); $show_precise = $cp_max_price > 1000 ? true : false; $locarray = array(); ?> <script type="text/javascript"> // <![CDATA[ // toggles the refine search field values jQuery(document).ready(function() { jQuery('div.handle').click(function() { jQuery(this).next('div.element').animate({ height: ['toggle', 'swing'], opacity: 'toggle' }, 200 ); jQuery(this).toggleClass('close', 'open'); return false; }); <?php foreach ($_GET as $field => $val) { ?> jQuery('.<?php echo esc_js($field); ?> div.handle').toggleClass('close', 'open'); jQuery('.<?php echo esc_js($field); ?> div.element').show(); <?php } ?> }); // ]]> </script> <div id="refine_widget" class="shadowblock_out"> <div class="shadowblock"> <h2 class="dotted"><?php _e('Refine Results', APP_TD); ?> </h2> <ul class="refine"> <form action="<?php echo home_url('/'); ?> " method="get" name="refine-search"> <?php if (!is_tax(APP_TAX_CAT)) { ?> <input type="hidden" name="s" value="<?php echo esc_attr(cp_get_search_term()); ?> " /> <input type="hidden" name="scat" value="<?php echo esc_attr(cp_get_search_catid()); ?> " /> <?php } else { ?> <input type="hidden" name="<?php echo esc_attr(get_query_var('taxonomy')); ?> " value="<?php echo esc_attr(get_query_var('term')); ?> " /> <?php } ?> <?php // grab the price and location fields first and put into a separate array // then remove them from the results array so they don't print out again foreach ($results as $key => $value) { switch ($value->field_name) { case 'cp_city': $locarray[0] = $results[$key]; unset($results[$key]); break; case 'cp_zipcode': $locarray[1] = $results[$key]; unset($results[$key]); break; case 'cp_price': $locarray[2] = $results[$key]; unset($results[$key]); break; } } // sort array by key so we get the city/zip code first ksort($locarray); // both zip code and city have been checked if (array_key_exists(0, $locarray) && array_key_exists(1, $locarray)) { $flabel = sprintf(__('%1$s or %2$s', APP_TD), $locarray[0]->field_label, $locarray[1]->field_label); $fname = 'cp_city_zipcode'; } elseif (array_key_exists(0, $locarray)) { // must be the city only $flabel = $locarray[0]->field_label; $fname = 'cp_city_zipcode'; } elseif (array_key_exists(1, $locarray)) { // must be the zip code only $flabel = $locarray[1]->field_label; $fname = 'cp_city_zipcode'; } $distance_unit = 'mi' == $cp_options->distance_unit ? __('miles', APP_TD) : __('kilometers', APP_TD); // show the city/zip code field and radius slider bar if (array_key_exists(0, $locarray) || array_key_exists(1, $locarray)) { ?> <script type="text/javascript"> // <![CDATA[ jQuery(document).ready(function() { jQuery('#dist-slider').slider( { range: 'min', min: 0, max: 100, value: <?php echo esc_js(isset($_GET['distance']) ? intval($_GET['distance']) : '50'); ?> , step: 5, slide: function(event, ui) { jQuery('#distance').val(ui.value + ' <?php echo esc_js($distance_unit); ?> '); } }); jQuery('#distance').val(jQuery('#dist-slider').slider('value') + ' <?php echo esc_js($distance_unit); ?> '); }); // ]]> </script> <li class="distance"> <label class="title"><?php echo $flabel; ?> </label> <input name="<?php echo esc_attr($fname); ?> " id="<?php echo esc_attr($fname); ?> " type="text" minlength="2" value="<?php if (isset($_GET[$fname])) { echo esc_attr($_GET[$fname]); } ?> " class="text" /> <div class="clr"></div> <label for="distance" class="title"><?php _e('Radius', APP_TD); ?> :</label> <input type="text" id="distance" name="distance" /> <div id="dist-slider"></div> </li> <?php } // now loop through the other special fields foreach ($locarray as $value) { // show the price field range slider if ($value->field_name == 'cp_price') { $curr_symbol = $cp_options->curr_symbol; if (isset($_GET['amount'])) { $amount = explode(' - ', $_GET['amount']); } else { if (isset($_GET['price_min']) && isset($_GET['price_max'])) { $amount = array($_GET['price_min'], $_GET['price_max']); } } $amount[0] = empty($amount[0]) ? $cp_min_price : $amount[0]; $amount[1] = empty($amount[1]) ? $cp_max_price : $amount[1]; $amount[0] = str_replace(array(',', $curr_symbol, ' '), '', $amount[0]); $amount[1] = str_replace(array(',', $curr_symbol, ' '), '', $amount[1]); if ($cp_options->refine_price_slider) { ?> <script type="text/javascript"> // <![CDATA[ jQuery(document).ready(function() { jQuery("#precise_price").click(function() { precise_price = ( jQuery(this).is(":checked") ) ? true : false; cp_show_price_slider(<?php echo esc_js(intval($cp_min_price)); ?> , <?php echo esc_js(intval($cp_max_price)); ?> , <?php echo esc_js(intval($amount[0])); ?> , <?php echo esc_js(intval($amount[1])); ?> , precise_price); }); precise_price = ( jQuery("#precise_price").is(":checked") ) ? true : false; cp_show_price_slider(<?php echo esc_js(intval($cp_min_price)); ?> , <?php echo esc_js(intval($cp_max_price)); ?> , <?php echo esc_js(intval($amount[0])); ?> , <?php echo esc_js(intval($amount[1])); ?> , precise_price); }); // ]]> </script> <li class="amount"> <label class="title"><?php echo esc_html(translate($value->field_label, APP_TD)); ?> :</label> <input type="text" id="amount" name="amount" /> <div id="slider-range"></div> <?php if ($show_precise) { ?> <label class="title"><?php echo esc_html(__('Precise price', APP_TD)); ?> :</label><input type="checkbox" id="precise_price" name="precise_price" <?php checked(isset($_GET['precise_price'])); ?> /> <?php } ?> </li> <?php } else { ?> <li class="price_min_max"> <label class="title"><?php echo esc_html(translate($value->field_label, APP_TD)); ?> (<?php echo $cp_options->curr_symbol; ?> )</label> <input type="text" class="text" id="price_min" name="price_min" placeholder="<?php _e('from', APP_TD); ?> " value="<?php if (isset($_GET['price_min'])) { echo esc_attr($_GET['price_min']); } ?> " /> – <input type="text" class="text" id="price_max" name="price_max" placeholder="<?php _e('to', APP_TD); ?> " value="<?php if (isset($_GET['price_max'])) { echo esc_attr($_GET['price_max']); } ?> " /> </li> <?php } } } foreach ($results as $key => $result) { if (in_array($result->field_type, array('radio', 'checkbox', 'drop-down', 'text box', 'text area'))) { echo cp_refine_fields($result->field_label, $result->field_name, $result->field_values, $result->field_type); } } ?> <div class="pad10"></div> <button class="obtn btn_orange" type="submit" tabindex="1" id="go" value="Go" name="sa"><?php _e('Refine Results ››', APP_TD); ?> </button> <input type="hidden" name="refine_search" value="yes" /> </form> </ul> <div class="clr"></div> </div> </div> <?php }
?> /> </div> <div class="searchbutcat"> <button class="btn-topsearch" type="submit" tabindex="3" title="<?php _e('Search Ads', 'appthemes'); ?> " id="go" value="search" name="sa"><?php _e('Search Ads', 'appthemes'); ?> </button> <?php wp_dropdown_categories('show_option_all=' . __('All Categories', 'appthemes') . '&hierarchical=' . get_option('cp_cat_hierarchy') . '&hide_empty=' . get_option('cp_cat_hide_empty') . '&depth=' . get_option('cp_search_depth') . '&show_count=' . get_option('cp_cat_child_count') . '&orderby=' . get_option('cp_cat_orderby') . '&title_li=&use_desc_for_title=1&tab_index=2&name=scat&selected=' . cp_get_search_catid() . '&class=searchbar&taxonomy=' . APP_TAX_CAT); ?> </div> </form> </div> <!-- /searchblock --> </div> <!-- /searchblock_out --> </div> <!-- /search-bar --> <?php }
<?php /** * Theme search bar across the header * Only show it on certain pages * * @author AppThemes * @package ClassiPress * */ global $cp_options; ?> <?php if (is_page_template('tpl-ads-home.php') || is_search() || is_404() || is_tax(APP_TAX_CAT) || is_tax(APP_TAX_TAG) || is_singular(APP_POST_TYPE)) { $args = array('show_option_all' => __('All States', APP_TD), 'hierarchical' => $cp_options->cat_hierarchy, 'hide_empty' => $cp_options->cat_hide_empty, 'depth' => $cp_options->search_depth, 'show_count' => $cp_options->cat_count, 'pad_counts' => $cp_options->cat_count, 'orderby' => 'name', 'title_li' => '', 'use_desc_for_title' => 1, 'name' => 'scat', 'tab_index' => '2', 'class' => 'searchbar', 'selected' => cp_get_search_catid(), 'taxonomy' => APP_TAX_CAT); $args = apply_filters('cp_dropdown_search_bar_args', $args); ?> <div id="search-bar"> <div class="searchblock_out"> <div class="searchblock"> <form action="<?php echo home_url('/'); ?> " method="get" id="searchform" class="form_search"> <div class="searchfield">
function cp_ad_search_widget() { global $cp_options; $args = array('show_option_all' => __('All Categories', APP_TD), 'hierarchical' => $cp_options->cat_hierarchy, 'hide_empty' => $cp_options->cat_hide_empty, 'depth' => $cp_options->search_depth, 'show_count' => $cp_options->cat_count, 'pad_counts' => $cp_options->cat_count, 'orderby' => 'name', 'title_li' => '', 'use_desc_for_title' => 1, 'name' => 'scat', 'selected' => cp_get_search_catid(), 'taxonomy' => APP_TAX_CAT); $args = apply_filters('cp_dropdown_search_widget_args', $args); ?> <div class="recordfromblog"> <form action="<?php echo home_url('/'); ?> " method="get" id="searchform" class="form_search"> <input name="s" type="text" id="s" class="editbox_search" <?php if (get_search_query()) { echo 'value="' . trim(strip_tags(esc_attr(get_search_query()))) . '"'; } else { ?> value="<?php _e('What are you looking for?', APP_TD); ?> " onfocus="if (this.value == '<?php _e('What are you looking for?', APP_TD); ?> ') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('What are you looking for?', APP_TD); ?> ';}" <?php } ?> /> <?php wp_dropdown_categories($args); ?> <div class="pad5"></div> <input type="submit" class="btn_orange" value="<?php _e('Search', APP_TD); ?> " title="<?php _e('Search', APP_TD); ?> " id="go" name="sa" /> </form> </div><!-- /recordfromblog --> <?php }