コード例 #1
0
ファイル: slider_properties.php プロジェクト: dongchpp/BIPHP
 public function widget($args, $instance)
 {
     global $post;
     extract($args);
     $posts = array();
     $parts = explode(',', $instance['properties']);
     foreach ($parts as $part) {
         $posts[] = trim($part);
     }
     $args = array('post__in' => $posts, 'post_type' => 'property', 'posts_per_page' => -1);
     $price_from = array();
     $price_from_parts = explode("\n", aviators_settings_get_value('properties', 'filter', 'from'));
     foreach ($price_from_parts as $price) {
         $price_from[] = trim($price);
     }
     $price_to = array();
     $price_to_parts = explode("\n", aviators_settings_get_value('properties', 'filter', 'to'));
     foreach ($price_to_parts as $price) {
         $price_to[] = trim($price);
     }
     echo View::render('properties/slider-large.twig', array('id' => $this->id, 'properties' => _aviators_properties_prepare(new WP_Query($args)), 'price_to' => $price_to, 'price_from' => $price_from, 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
 }
コード例 #2
0
ファイル: utils.php プロジェクト: dongchpp/BIPHP
function aviators_properties_filter($return_query = FALSE, $use_pager = TRUE)
{
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $wp_query = new WP_Query();
    $properties = array('post_type' => 'property', 'posts_per_page' => -1, 'tax_query' => array(), 'meta_query' => array(), 'order_by' => 'published');
    if ($use_pager) {
        $properties['posts_per_page'] = aviators_settings_get_value('properties', 'properties', 'per_page');
        $properties['paged'] = $paged;
    }
    if (!empty($_GET['filter_order'])) {
        $properties['order'] = $_GET['filter_order'];
    } else {
        $properties['order'] = 'DESC';
    }
    $default_sort = aviators_settings_get_value('properties', 'properties', 'default_sort');
    if (isset($_GET['filter_sort_by'])) {
        $default_sort = $_GET['filter_sort_by'];
    }
    switch ($default_sort) {
        case 'price':
            $properties['orderby'] = 'meta_value_num';
            $properties['meta_key'] = '_property_price';
            break;
        case 'beds':
            $properties['orderby'] = 'meta_value_num';
            $properties['meta_key'] = '_property_bedrooms';
            break;
        case 'baths':
            $properties['orderby'] = 'meta_value_num';
            $properties['meta_key'] = '_property_bathrooms';
            break;
        case 'date':
            $properties['orderby'] = 'date';
            break;
        default:
            $properties['orderby'] = 'title';
    }
    if (!empty($_GET['filter_location'])) {
        $properties['tax_query'][] = array('taxonomy' => 'locations', 'field' => 'id', 'terms' => $_GET['filter_location'], 'operator' => 'IN');
    }
    if (!empty($_GET['filter_sublocation'])) {
        $properties['tax_query'][] = array('taxonomy' => 'locations', 'field' => 'id', 'terms' => $_GET['filter_sublocation'], 'operator' => 'IN');
    }
    if (!empty($_GET['filter_sub_sublocation'])) {
        $properties['tax_query'][] = array('taxonomy' => 'locations', 'field' => 'id', 'terms' => $_GET['filter_sub_sublocation'], 'operator' => 'IN');
    }
    if (!empty($_GET['filter_property_id'])) {
        if (strlen($_GET['filter_property_id']) >= 2) {
            $properties['meta_query'][] = array('key' => '_property_id', 'value' => $_GET['filter_property_id'], 'compare' => 'LIKE');
        }
    }
    if (!empty($_GET['filter_type'])) {
        if (is_array($_GET['filter_type']) && count($_GET['filter_type']) > 0) {
            $terms = array();
            foreach ($_GET['filter_type'] as $type) {
                $terms[] = $type;
            }
            $properties['tax_query'][] = array('taxonomy' => 'property_types', 'field' => 'id', 'terms' => $terms, 'operator' => 'IN');
        } else {
            $properties['tax_query'][] = array('taxonomy' => 'property_types', 'field' => 'id', 'terms' => $_GET['filter_type'], 'operator' => 'IN');
        }
    }
    if (!empty($_GET['filter_bedrooms'])) {
        $properties['meta_query'][] = array('key' => '_property_bedrooms', 'value' => $_GET['filter_bedrooms'], 'compare' => '>=', 'type' => 'numeric');
    }
    if (!empty($_GET['filter_bathrooms'])) {
        $properties['meta_query'][] = array('key' => '_property_bathrooms', 'value' => $_GET['filter_bathrooms'], 'compare' => '>=', 'type' => 'numeric');
    }
    if (!empty($_GET['filter_contract_type'])) {
        $properties['tax_query'][] = array('taxonomy' => 'property_contracts', 'field' => 'id', 'terms' => $_GET['filter_contract_type'], 'operator' => 'IN');
    }
    // Area
    if (!empty($_GET['filter_area_from']) && !empty($_GET['filter_area_to'])) {
        $properties['meta_query'][] = array('key' => '_property_area', 'value' => array($_GET['filter_area_from'], $_GET['filter_area_to']), 'type' => 'numeric', 'compare' => 'BETWEEN');
    } elseif (!empty($_GET['filter_area_from'])) {
        $properties['meta_query'][] = array('key' => '_property_area', 'value' => $_GET['filter_area_from'], 'type' => 'numeric', 'compare' => '>=');
    } elseif (!empty($_GET['filter_area_to'])) {
        $properties['meta_query'][] = array('key' => '_property_area', 'value' => $_GET['filter_area_to'], 'type' => 'numeric', 'compare' => '<=');
    }
    // Price
    if (!empty($_GET['filter_price_from']) && !empty($_GET['filter_price_to'])) {
        $properties['meta_query'][] = array('key' => '_property_price', 'value' => array($_GET['filter_price_from'], $_GET['filter_price_to']), 'type' => 'numeric', 'compare' => 'BETWEEN');
    } elseif (!empty($_GET['filter_price_from'])) {
        $properties['meta_query'][] = array('key' => '_property_price', 'value' => $_GET['filter_price_from'], 'type' => 'numeric', 'compare' => '>=');
    } elseif (!empty($_GET['filter_price_to'])) {
        $properties['meta_query'][] = array('key' => '_property_price', 'value' => $_GET['filter_price_to'], 'type' => 'numeric', 'compare' => '<=');
    }
    $wp_query->query($properties);
    if ($return_query) {
        return $wp_query;
    }
    return _aviators_properties_prepare($wp_query);
}
コード例 #3
0
ファイル: general_properties.php プロジェクト: dongchpp/BIPHP
 public function widget($args, $instance)
 {
     extract($args);
     $count = isset($instance['count']) ? $instance['count'] : 3;
     $display = isset($instance['display']) ? $instance['display'] : 'sidebar';
     $query_args = array('post_type' => 'property', 'posts_per_page' => $count);
     if ($instance['random']) {
         $query_args['orderby'] = 'rand';
     } else {
         if (isset($instance['property_types'])) {
             $query_args['tax_query'][] = array('taxonomy' => 'property_types', 'field' => 'id', 'operator' => 'IN', 'terms' => $instance['property_types']);
         }
         if (isset($instance['locations'])) {
             $query_args['tax_query'][] = array('taxonomy' => 'locations', 'field' => 'id', 'operator' => 'IN', 'terms' => $instance['locations']);
         }
         if (isset($instance['property_contracts'])) {
             $query_args['tax_query'][] = array('taxonomy' => 'property_contracts', 'field' => 'id', 'operator' => 'IN', 'terms' => $instance['property_contracts']);
         }
     }
     if (!empty($instance['shuffle']) && $instance['shuffle']) {
         $args['orderby'] = 'rand';
     }
     $query = new WP_Query($query_args);
     $properties = _aviators_properties_prepare($query);
     echo View::render('properties/widget-general.twig', array('title' => apply_filters('widget_title', $instance['title']), 'count' => $count, 'properties' => $properties, 'display' => $display, 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
 }
コード例 #4
0
<?php

global $wp_query;
$term = $wp_query->queried_object;
$content = get_term_field('description', $term->term_id, $term->taxonomy);
echo View::render('archive-property.twig', array('title' => $term->name, 'content' => $content, 'wp_query' => $wp_query, 'properties' => _aviators_properties_prepare($wp_query)));