Пример #1
0
function epl_search_pre_get_posts($query)
{
    if (is_admin() || !$query->is_main_query()) {
        return;
    }
    if (epl_is_search()) {
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $query->init();
        $query->set('posts_per_page', get_option('posts_per_page'));
        $query->set('paged', $paged);
        extract($_REQUEST);
        if (isset($property_id)) {
            if (is_numeric($property_id)) {
            } else {
                $query->set('epl_post_title', sanitize_text_field($property_id));
            }
        }
        if (isset($property_agent)) {
            $property_agent = sanitize_title_with_dashes($property_agent);
            if ($property_agent = get_user_by('slug', $property_agent)) {
                $query->set('post_author', $property_agent->ID);
            }
        }
        if (isset($post_type) && !empty($post_type)) {
            $query->set('post_type', $post_type);
        } else {
            $epl_post_types = epl_get_active_post_types();
            if (!empty($epl_post_types)) {
                $epl_post_types = array_keys($epl_post_types);
                $query->set('post_type', $epl_post_types);
            }
        }
        $epl_meta_query = array();
        $epl_search_form_fields = epl_search_widget_fields_frontend($post_type, $property_status);
        foreach ($epl_search_form_fields as $epl_search_form_field) {
            if (isset($epl_search_form_field['query'])) {
                if ($epl_search_form_field['query']['query'] == 'meta') {
                    $this_meta_query = array();
                    if (isset($epl_search_form_field['query']['multiple']) && $epl_search_form_field['query']['multiple'] == true) {
                        if (isset(${$epl_search_form_field['meta_key']}) && !empty(${$epl_search_form_field['meta_key']})) {
                            $this_meta_query['relation'] = isset($epl_search_form_field['query']['relation']) ? $epl_search_form_field['query']['relation'] : 'OR';
                            foreach ($epl_search_form_field['query']['sub_queries'] as $sub_query) {
                                $this_sub_query = array('key' => $sub_query['key'], 'value' => ${$epl_search_form_field['meta_key']}, 'type' => $sub_query['type'], 'compare' => $sub_query['compare']);
                                $this_meta_query[] = $this_sub_query;
                            }
                            $epl_meta_query[] = $this_meta_query;
                        }
                    } else {
                        $query_meta_key = isset($epl_search_form_field['query']['key']) ? $epl_search_form_field['query']['key'] : $epl_search_form_field['meta_key'];
                        if ($query_meta_key == 'property_unique_id' && isset(${$epl_search_form_field['meta_key']}) && !is_numeric(${$epl_search_form_field['meta_key']})) {
                            continue;
                        }
                        if (isset(${$epl_search_form_field['meta_key']}) && !empty(${$epl_search_form_field['meta_key']})) {
                            $this_meta_query = array('key' => $query_meta_key, 'value' => ${$epl_search_form_field['meta_key']});
                            isset($epl_search_form_field['query']['compare']) ? $this_meta_query['compare'] = $epl_search_form_field['query']['compare'] : '';
                            isset($epl_search_form_field['query']['type']) ? $this_meta_query['type'] = $epl_search_form_field['query']['type'] : '';
                            isset($epl_search_form_field['query']['value']) ? $this_meta_query['value'] = $epl_search_form_field['query']['value'] : '';
                            $epl_meta_query[] = $this_meta_query;
                        }
                    }
                }
            }
        }
        if (!empty($epl_meta_query)) {
            $query->set('meta_query', $epl_meta_query);
        }
        $tax_query = array();
        if (isset($property_location) && !empty($property_location)) {
            $tax_query[] = array('taxonomy' => 'location', 'field' => 'id', 'terms' => $property_location);
        }
        if (!empty($tax_query)) {
            $query->set('tax_query', $tax_query);
        }
        $query->parse_query();
    }
}
function epl_search_pre_get_posts($query)
{
    if (is_admin() || !$query->is_main_query()) {
        return;
    }
    if (epl_is_search()) {
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $query->init();
        $query->set('posts_per_page', get_option('posts_per_page'));
        $query->set('paged', $paged);
        extract($_REQUEST);
        if (isset($property_id)) {
            if (is_numeric($property_id)) {
                $query->set('post__in', array(intval($property_id)));
            } else {
                $query->set('epl_post_title', sanitize_text_field($property_id));
            }
        }
        if (isset($post_type) && !empty($post_type)) {
            $query->set('post_type', $post_type);
        } else {
            $epl_post_types = epl_get_active_post_types();
            if (!empty($epl_post_types)) {
                $epl_post_types = array_keys($epl_post_types);
                $query->set('post_type', $epl_post_types);
            }
        }
        $meta_query = array();
        if (isset($property_security_system) && !empty($property_security_system)) {
            $meta_query[] = array('key' => 'property_security_system', 'value' => array('yes', '1'), 'compare' => 'IN');
        }
        if (isset($property_air_conditioning) && !empty($property_air_conditioning)) {
            $meta_query[] = array('key' => 'property_air_conditioning', 'value' => array('yes', '1'), 'compare' => 'IN');
        }
        if (isset($property_pool) && !empty($property_pool)) {
            $meta_query[] = array('key' => 'property_pool', 'value' => array('yes', '1'), 'compare' => 'IN');
        }
        if (isset($property_bedrooms_min) && !empty($property_bedrooms_min)) {
            $meta_query[] = array('key' => 'property_bedrooms', 'value' => $property_bedrooms_min, 'type' => 'numeric', 'compare' => '>=');
        }
        if (isset($property_bedrooms_max) && !empty($property_bedrooms_max)) {
            $meta_query[] = array('key' => 'property_bedrooms', 'value' => $property_bedrooms_max, 'type' => 'numeric', 'compare' => '<=');
        }
        if (isset($property_land_area_min) && !empty($property_land_area_min)) {
            $meta_query[] = array('key' => 'property_land_area', 'value' => $property_land_area_min, 'type' => 'numeric', 'compare' => '>=');
        }
        if (isset($property_land_area_max) && !empty($property_land_area_max)) {
            $meta_query[] = array('key' => 'property_land_area', 'value' => $property_land_area_max, 'type' => 'numeric', 'compare' => '<=');
        }
        if (isset($property_land_area_max) && !empty($property_land_area_max) || isset($property_land_area_min) && !empty($property_land_area_min)) {
            $meta_query[] = array('key' => 'property_land_area_unit', 'value' => $property_land_area_unit);
        }
        if (isset($property_building_area_min) && !empty($property_building_area_min)) {
            $meta_query[] = array('key' => 'property_building_area', 'value' => $property_building_area_min, 'type' => 'numeric', 'compare' => '>=');
        }
        if (isset($property_building_area_max) && !empty($property_building_area_max)) {
            $meta_query[] = array('key' => 'property_building_area', 'value' => $property_building_area_max, 'type' => 'numeric', 'compare' => '<=');
        }
        if (isset($property_building_area_max) && !empty($property_building_area_max) || isset($property_building_area_min) && !empty($property_building_area_min)) {
            $meta_query[] = array('key' => 'property_building_area_unit', 'value' => $property_building_area_unit);
        }
        if (isset($property_bathrooms) && !empty($property_bathrooms)) {
            $meta_query[] = array('key' => 'property_bathrooms', 'value' => $property_bathrooms, 'type' => 'numeric', 'compare' => '>=');
        }
        if (isset($property_rooms) && !empty($property_rooms)) {
            $meta_query[] = array('key' => 'property_rooms', 'value' => $property_rooms, 'type' => 'numeric', 'compare' => '>=');
        }
        if (isset($property_carport) && !empty($property_carport)) {
            $meta_query[] = array('relation' => 'OR', array('key' => 'property_carport', 'value' => $property_carport, 'type' => 'numeric', 'compare' => '>='), array('key' => 'property_garage', 'value' => $property_carport, 'type' => 'numeric', 'compare' => '>='));
        }
        if (isset($property_category) && !empty($property_category)) {
            $meta_query[] = array('key' => 'property_category', 'value' => $property_category, 'compare' => '=');
        }
        if (isset($post_type) && ($post_type == 'rental' || $post_type == 'commercial' || $post_type == 'business' || $post_type == 'holiday_rental' || $post_type == 'commercial_land')) {
            $key = 'property_rent';
        } else {
            $key = 'property_price';
        }
        if (isset($property_price_from) && !empty($property_price_from)) {
            $meta_query[] = array('key' => $key, 'value' => $property_price_from, 'type' => 'numeric', 'compare' => '>=');
        }
        if (isset($property_price_to) && !empty($property_price_to)) {
            $meta_query[] = array('key' => $key, 'value' => $property_price_to, 'type' => 'numeric', 'compare' => '<=');
        }
        if (isset($property_status) && !empty($property_status)) {
            $meta_query[] = array('key' => 'property_status', 'value' => $property_status, 'compare' => '=');
        }
        if (isset($property_address_city) && !empty($property_address_city)) {
            $meta_query[] = array('key' => 'property_address_city', 'value' => $property_address_city, 'compare' => '=');
        }
        if (isset($property_address_state) && !empty($property_address_state)) {
            $meta_query[] = array('key' => 'property_address_state', 'value' => $property_address_state, 'compare' => '=');
        }
        if (isset($property_address_country) && !empty($property_address_country)) {
            $meta_query[] = array('key' => 'property_address_country', 'value' => $property_address_country, 'compare' => '=');
        }
        if (isset($property_address_postal_code) && !empty($property_address_postal_code)) {
            $meta_query[] = array('key' => 'property_address_postal_code', 'value' => $property_address_postal_code, 'compare' => '=');
        }
        if (!empty($meta_query)) {
            $query->set('meta_query', $meta_query);
        }
        $tax_query = array();
        if (isset($property_location) && !empty($property_location)) {
            $tax_query[] = array('taxonomy' => 'location', 'field' => 'id', 'terms' => $property_location);
        }
        if (!empty($tax_query)) {
            $query->set('tax_query', $tax_query);
        }
        $query->parse_query();
    }
}
Пример #3
0
				<div id="primary">
					<div id="content" role="main">
						<?php 
if (have_posts()) {
    ?>
							<div class="loop">
								<div class="loop-header">
									<h4 class="loop-title">
										<?php 
    the_post();
    if (is_tax() && function_exists('epl_is_search') && false == epl_is_search()) {
        // Tag Archive
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        $title = sprintf(__('Property in %s', 'epl'), $term->name);
    } else {
        if (function_exists('epl_is_search') && epl_is_search()) {
            // Search Result
            $title = __('Search Result', 'epl');
        } else {
            if (function_exists('is_post_type_archive') && is_post_type_archive() && function_exists('post_type_archive_title')) {
                // Post Type Archive
                $title = post_type_archive_title('', false);
            } else {
                // Default catchall just in case
                $title = __('Listing', 'epl');
            }
        }
    }
    if (is_paged()) {
        printf('%s &ndash; Page %d', $title, get_query_var('paged'));
    } else {
Пример #4
0
function render_content()
{
    if (have_posts()) {
        ?>
		<div class="loop">
			<div class="loop-header">
				<h4 class="loop-title">
					<?php 
        the_post();
        if (is_tax() && function_exists('epl_is_search') && false == epl_is_search()) {
            // Tag Archive
            $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
            $title = sprintf(__('Property in %s', 'epl'), $term->name);
        } else {
            if (function_exists('epl_is_search') && epl_is_search()) {
                // Search Result
                $title = __('Search Result', 'epl');
            } else {
                if (function_exists('is_post_type_archive') && is_post_type_archive() && function_exists('post_type_archive_title')) {
                    // Post Type Archive
                    $title = post_type_archive_title('', false);
                } else {
                    // Default catchall just in case
                    $title = __('Listing', 'epl');
                }
            }
        }
        if (is_paged()) {
            printf('%s &ndash; Page %d', $title, get_query_var('paged'));
        } else {
            echo $title;
        }
        rewind_posts();
        ?>
				</h4>
			</div>

			<div class="loop-content">
				<?php 
        do_action('epl_property_loop_start');
        ?>
				<?php 
        while (have_posts()) {
            // The Loop
            the_post();
            do_action('epl_property_blog');
        }
        // end of one post
        ?>
				<?php 
        do_action('epl_property_loop_end');
        ?>
			</div>
			
			<div class="loop-footer">
				<!-- Previous/Next page navigation -->
				<div class="loop-utility clearfix">
					<?php 
        do_action('epl_pagination');
        ?>
				</div>
			</div>
		</div>
		<?php 
    } else {
        //do_action( 'builder_template_show_not_found' );
        ?>
<div class="hentry">
			<div class="entry-header clearfix">
				<h3 class="entry-title"><?php 
        apply_filters('epl_property_search_not_found_title', _e('Listing not Found', 'epl'));
        ?>
</h3>
			</div>
			
			<div class="entry-content clearfix">
				<p><?php 
        apply_filters('epl_property_search_not_found_message', _e('Listing not found, expand your search criteria and try again.', 'epl'));
        ?>
</p>
			</div>
		</div><?php 
    }
}
Пример #5
0
function cmo_get_custom_title()
{
    if (is_404()) {
        esc_html_e("404", 'cumulo');
    } else {
        if (is_search()) {
            echo __("Search", 'cumulo') . ": " . get_search_query();
        } else {
            if (is_attachment()) {
                esc_html_e("Attachment", 'cumulo');
            } else {
                if (is_author()) {
                    echo __("Author", 'cumulo') . ": " . get_query_var('author_name');
                } else {
                    if (is_tax('portfolio_category')) {
                        single_cat_title("Portfolio Category: ", true);
                    } else {
                        if (is_tax('portfolio_tags')) {
                            single_cat_title("Portfolio Tag: ", true);
                        } else {
                            if (is_post_type_archive('cmo_portfolio')) {
                                esc_html_e("Portfolio", 'cumulo');
                            } else {
                                if (is_category()) {
                                    single_cat_title("Category: ", true);
                                } else {
                                    if (is_tag()) {
                                        single_cat_title("Tag: ", true);
                                    } else {
                                        if (is_year() || is_month() || is_day()) {
                                            echo __("Archive", 'cumulo') . ": ";
                                            the_archive_title();
                                        } else {
                                            if (is_date()) {
                                                echo __("Date", 'cumulo');
                                            } else {
                                                if (is_archive()) {
                                                    if (class_exists("WOOCOMMERCE") && is_shop()) {
                                                        echo __("Shop", 'cumulo');
                                                    } else {
                                                        if (function_exists("is_epl_post_archive") && is_epl_post_archive()) {
                                                            /* copied from easy-property-listing archive page */
                                                            if (is_tax() && function_exists('epl_is_search') && false == epl_is_search()) {
                                                                // Tag Archive
                                                                $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
                                                                $title = sprintf(__('Property in %s', 'epl'), $term->name);
                                                            } else {
                                                                if (function_exists('epl_is_search') && epl_is_search()) {
                                                                    // Search Result
                                                                    $title = __('Search Result', 'epl');
                                                                } else {
                                                                    if (function_exists('is_post_type_archive') && is_post_type_archive() && function_exists('post_type_archive_title')) {
                                                                        // Post Type Archive
                                                                        $title = post_type_archive_title('', false);
                                                                    } else {
                                                                        // Default catchall just in case
                                                                        $title = __('Listing', 'epl');
                                                                    }
                                                                }
                                                            }
                                                            if (is_paged()) {
                                                                printf('%s &ndash; Page %d', $title, get_query_var('paged'));
                                                            } else {
                                                                echo $title;
                                                            }
                                                        } else {
                                                            the_archive_title();
                                                        }
                                                    }
                                                } else {
                                                    echo the_title();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
function render_content()
{
    if (have_posts()) {
        ?>
		<div class="loop archive-listings">
			
			<div class="loop-header">
				<h4 class="loop-title">
					<?php 
        the_post();
        if (is_tax() && function_exists('epl_is_search') && false == epl_is_search()) {
            // Tag Archive
            $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
            $title = sprintf(__('Property in %s', 'epl'), $term->name);
        } else {
            if (function_exists('epl_is_search') && epl_is_search()) {
                // Search Result
                if (function_exists('is_post_type_archive') && is_post_type_archive()) {
                    if (is_post_type_archive('property')) {
                        $title = __('Search Results', 'epl');
                    } elseif (is_post_type_archive('rental')) {
                        $title = __('Properties for Lease', 'epl');
                    } else {
                        $title = __('Search Results', 'epl');
                    }
                } else {
                    $title = __('Search Results', 'epl');
                }
            } else {
                if (function_exists('is_post_type_archive') && is_post_type_archive() && function_exists('post_type_archive_title')) {
                    // Post Type Archive
                    $title = post_type_archive_title('', false);
                } else {
                    // Default catchall just in case
                    $title = __('Listing', 'epl');
                }
            }
        }
        if (is_paged()) {
            printf('%s &ndash; Page %d', $title, get_query_var('paged'));
        } else {
            echo 'Matching ', $title;
        }
        rewind_posts();
        ?>
				</h4>
			</div>

			<div class="loop-content">
				<?php 
        // do_action( 'epl_property_loop_start' );
        ?>
				
				<?php 
        do_action('rec_archive_map');
        ?>
				
				<div class="rec-epl-property-grid">
					<?php 
        while (have_posts()) {
            // The Loop
            the_post();
            do_action('epl_property_blog');
        }
        // end of one post
        ?>
				</div>
				<?php 
        do_action('epl_property_loop_end');
        ?>
			</div>
			
			<div class="loop-footer">
				<!-- Previous/Next page navigation -->
				<div class="loop-utility clearfix">
					<?php 
        do_action('epl_pagination');
        ?>
				</div>
			</div>
		</div>
		<?php 
    } else {
        //do_action( 'builder_template_show_not_found' );
        ?>
<div class="hentry">
			<div class="entry-header clearfix">
				<h3 class="entry-title"><?php 
        _e('Listing not Found', 'epl');
        ?>
</h3>
			</div>
			
			<div style="text-align:center;" class="entry-content clearfix">
				<p><?php 
        _e('Unfortunately no properties match your search requirements, please expand your search criteria and try again.', 'epl');
        ?>
</p>
			</div>
		</div><?php 
    }
}