<?php

/*
Template Name: Property Filter
*/
get_header();
while (have_posts()) {
    the_post();
    global $details, $search;
    $search = array('customdatas' => array(), 'custom_taxonomies' => array());
    $search['customdatas'] = get_post_meta($post->ID, '_est_customdatas', true);
    $search['custom_taxonomies'] = get_post_meta($post->ID, '_est_taxonomies', true);
    $details = get_search_options($search);
    $position = get_post_meta(get_the_ID(), '_est_filter_location', true);
    $class_content = $position == 'left' ? 'push-4' : '';
    $class_filter = $position == 'left' ? 'pull-8' : '';
    ?>

<div class='row mt44'>
	<div class='large-4 small-12 columns <?php 
    echo $class_filter;
    ?>
' id='siteSidebar'>
		<form class='custom inContentSearch' id='filterPageSearch' data-type='<?php 
    echo $filter_type;
    ?>
'>
			<?php 
    $title = get_post_meta($post->ID, '_est_search_title', true);
    if (!empty($title)) {
        ?>
    function widget($args, $instance)
    {
        global $post, $wpdb;
        echo $args['before_widget'];
        echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
        if ($instance['search_page'] == 'default') {
            $action = get_permalink();
        } else {
            $action = get_post_meta($post->ID, '_wp_page_template', true) == 'template-bshListingPage.php' ? '' : get_permalink($instance['search_page']);
        }
        ?>

		<form class='custom inContentSearch' action='<?php 
        echo $action;
        ?>
' method='get'>
			<?php 
        $search = array('customdatas' => array(), 'custom_taxonomies' => array());
        $search['customdatas'] = $instance['est_customdata'];
        $search['custom_taxonomies'] = $instance['est_taxonomies'];
        $details = get_search_options($search);
        est_vertical_search($details);
        $text = $instance['search_button_text'];
        $text = empty($text) ? 'Search' : $text;
        ?>

				<div class='form-row row mt11'>
					<div class='small-12 large-12 columns text-right'>
						<input type='submit' class='button' value='<?php 
        echo $text;
        ?>
'>
					</div>
				</div>

		</form>


		<?php 
        echo $args['after_widget'];
    }