Example #1
0
    /**
     * Returns a list of properties listed formated in a default html.
     *
     * This function takes the raw properties data returned by the plugin and
     * formats wrapps it in html. The returned html is filterable in multiple
     * ways.
     *
     * The defaults are as follows:
     *     'width' - Default 100. The listing image width. If set to 0,
     *          width is not added.
     *     'height' - Default false. The listing image height. If set to 0,
     *          width is not added.
     *     'placeholder_img' - Defaults to placeholder image. The path to the
     *          listing image that should be use if the listing has no images.
     *     'context' - An execution context for the function. Used when the
     *          filters are created.
     *     'context_var' - Any variable that needs to be passed to the filters
     *          when function is executed.
     *     'limit' - Default is 5. Total number of listings to retrieve. Maximum
     *          set to 50.
     * Defines the following filters:
     * pls_listings_request[_context] - Filters the request parameters.
     * pls_listing[_context] - Filters the individual listing html.
     * pls_listings[_context] - Filters the complete listings list html.
     *
     * @static
     * @param array|string $args Optional. Overrides defaults.
     * @return string The html with the list of properties.
     * @since 0.0.1
     */
    public static function init($args = '')
    {
        $cache = new PLS_Cache('list');
        if ($result = $cache->get($args)) {
            // return $result;
        }
        /** Define the default argument array. */
        $defaults = array('width' => 100, 'height' => 0, 'context' => '', 'context_var' => false, 'featured_option_id' => false, 'limit' => 5, 'sort_type' => 'asc', 'request_params' => '', 'neighborhood_polygons' => false);
        /** Merge the arguments with the defaults. */
        $args = wp_parse_args($args, $defaults);
        /** Extract the arguments after they merged with the defaults. */
        extract($args, EXTR_SKIP);
        // Sanitize the width
        if ($width) {
            $width = absint($width);
        }
        /** Sanitize the height. */
        if ($height) {
            $height = absint($height);
        }
        $request_params = wp_parse_args($args, array('limit' => $limit, 'sort_type' => $sort_type));
        // Filter the request parameters
        $request_params = apply_filters(pls_get_merged_strings(array('pls_listings_request', $context), '_', 'pre', false), $request_params, $context_var);
        // Start off with a placeholder in case the plugin is not active or there is no API key...
        $listings_raw = PLS_Listing_Helper::$default_listing;
        // If plugin is active, grab listings intelligently...
        if (!pls_has_plugin_error()) {
            $listings_raw = false;
            if ($featured_option_id) {
                $listings_raw = PLS_Listing_Helper::get_featured($featured_option_id, $args);
            }
            if ($neighborhood_polygons) {
                $listings_raw = PLS_Plugin_API::get_polygon_listings(array('neighborhood_polygons' => $neighborhood_polygons));
            }
            if ($listings_raw === false || isset($listings_raw['listings']) && empty($listings_raw['listings'])) {
                $listings_raw = PLS_Plugin_API::get_listings($request_params);
            }
        }
        /** Define variable which will contain the html string with the listings. */
        $return = '';
        /** Set the listing image attributes. */
        $listing_img_attr = array();
        if ($width) {
            $listing_img_attr['width'] = $width;
        }
        if ($height) {
            $listing_img_attr['height'] = $height;
        }
        /** Collect the html for each listing. */
        $listings_html = array();
        // filter listings before output
        if (isset($featured_listing_id)) {
            $listings_raw = apply_filters($context . '_partial_get_listings', $listings_raw, $featured_listing_id);
        }
        // For repeated use in the loop...
        $listing_cache = new PLS_Cache('Listing');
        // Curate the listing_data...
        foreach ($listings_raw['listings'] as $listing_data) {
            // Ignore featured listings without images
            if (!empty($args['featured_option_id']) && empty($listing_data['images'])) {
                continue;
            }
            $listing_html = '';
            $cache_id = array('context' => $context, 'featured_option_id' => $featured_option_id, 'listing_id' => $listing_data['id']);
            if ($cached_listing_html = $listing_cache->get($cache_id)) {
                $listing_html = $cached_listing_html;
            }
            if (empty($listing_html)) {
                // Use the placeholder image if the property has no photo
                if (!$listing_data['images']) {
                    $listing_data['images'][0]['url'] = '';
                    $listing_data['images'][0]['order'] = 0;
                }
                // Remove the ID for each image (not needed by theme developers) and add the image HTML
                foreach ($listing_data['images'] as $image) {
                    unset($image['id']);
                    $image['html'] = pls_h_img($image['url'], $listing_data['location']['address'], $listing_img_attr);
                }
                $location = $listing_data['location'];
                $full_address = $location['address'] . ' ' . $location['region'] . ', ' . $location['locality'] . ' ' . $location['postal'];
                ob_start();
                ?>
                <div class="listing-item grid_8 alpha" itemscope itemtype="http://schema.org/Offer">

                  <div class="listing-thumbnail grid_3 alpha">
                    <a href="<?php 
                echo @$listing_data['cur_data']['url'];
                ?>
">

                      <?php 
                $property_images = is_array($listing_data['images']) ? $listing_data['images'] : array();
                usort($property_images, array(__CLASS__, 'order_listing_images'));
                ?>
                      
                      <?php 
                echo PLS_Image::load($property_images[0]['url'], array('resize' => array('w' => 210, 'h' => 140), 'fancybox' => true, 'as_html' => true, 'html' => array('alt' => $listing_data['location']['full_address'], 'itemprop' => 'image')));
                ?>
                    

                    </a>
                  </div>

                  <div class="listing-item-details grid_5 omega">
                    <p class="listing-item-address h4" itemprop="name">
                      <a href="<?php 
                echo PLS_Plugin_API::get_property_url($listing_data['id']);
                ?>
" rel="bookmark" title="<?php 
                echo $listing_data['location']['address'];
                ?>
" itemprop="url">
                        <?php 
                echo $listing_data['location']['address'] . ', ' . $listing_data['location']['locality'] . ' ' . $listing_data['location']['region'] . ' ' . $listing_data['location']['postal'];
                ?>
                      </a>
                    </p>

                    <div class="basic-details">
                      <ul>
                        <?php 
                if (!empty($listing_data['cur_data']['beds'])) {
                    ?>
                          <li class="basic-details-beds p1"><span>Beds:</span> <?php 
                    echo @$listing_data['cur_data']['beds'];
                    ?>
</li>
                        <?php 
                }
                ?>

                        <?php 
                if (!empty($listing_data['cur_data']['baths'])) {
                    ?>
                          <li class="basic-details-baths p1"><span>Baths:</span> <?php 
                    echo @$listing_data['cur_data']['baths'];
                    ?>
</li>
                        <?php 
                }
                ?>

                        <?php 
                if (!empty($listing_data['cur_data']['half_baths'])) {
                    ?>
                          <li class="basic-details-half-baths p1"><span>Half Baths:</span> <?php 
                    echo @$listing_data['cur_data']['half_baths'];
                    ?>
</li>
                        <?php 
                }
                ?>

                        <?php 
                if (!empty($listing_data['cur_data']['price'])) {
                    ?>
                          <li class="basic-details-price p1" itemprop="price"><span>Price:</span> <?php 
                    echo PLS_Format::number($listing_data['cur_data']['price'], array('abbreviate' => false, 'add_currency_sign' => true));
                    ?>
</li>
                        <?php 
                }
                ?>

                        <?php 
                if (!empty($listing_data['cur_data']['sqft'])) {
                    ?>
                          <li class="basic-details-sqft p1"><span>Sqft:</span> <?php 
                    echo PLS_Format::number($listing_data['cur_data']['sqft'], array('abbreviate' => false, 'add_currency_sign' => false));
                    ?>
</li>
                        <?php 
                }
                ?>

                        <?php 
                if (!empty($listing_data['rets']['mls_id'])) {
                    ?>
                          <li class="basic-details-mls p1"><span>MLS ID:</span> <?php 
                    echo @$listing_data['rets']['mls_id'];
                    ?>
</li>
                        <?php 
                }
                ?>
                      </ul>
                    </div>

                    <p class="listing-description p4">
                      <?php 
                echo substr($listing_data['cur_data']['desc'], 0, 300);
                ?>
                    </p>

                  </div>

                  <div class="actions">
                    <a class="more-link" href="<?php 
                echo PLS_Plugin_API::get_property_url($listing_data['id']);
                ?>
" itemprop="url">View Property Details</a>
                    <?php 
                echo PLS_Plugin_API::placester_favorite_link_toggle(array('property_id' => $listing_data['id']));
                ?>
                  </div>

                  <?php 
                PLS_Listing_Helper::get_compliance(array('context' => 'inline_search', 'agent_name' => @$listing_data['rets']['aname'], 'office_name' => @$listing_data['rets']['oname']));
                ?>

                </div>
                <?php 
                // Store the output...
                $listing_html = ob_get_clean();
                // Filter (pls_listing[_context]) the resulting HTML for a single listing
                $listing_html = apply_filters(pls_get_merged_strings(array('pls_listing', $context), '_', 'pre', false), $listing_html, $listing_data, $request_params, $context_var);
                // Cache the result...
                $listing_cache->save($listing_html, PLS_Cache::TTL_LOW);
            }
            // Append the HTML to an array -- this will be passed to the final filter
            $listings_html[] = $listing_html;
            // Merge all the listings HTML
            $return .= $listing_html;
        }
        // Wrap the listings HTML
        $return = pls_h('section', array('class' => "pls-listings pls-listings " . pls_get_merged_strings(array('pls-listing', $context), '-', 'pre', false)), $return);
        // Filter (pls_listings[_context]) the resulting HTML that contains the collection of listings
        $return = apply_filters(pls_get_merged_strings(array('pls_listings', $context), '_', 'pre', false), $return, $listings_raw, $listings_html, $request_params, $context_var);
        $cache->save($return);
        return $return;
    }
Example #2
0
 /**
  * Slideshow
  * 
  * @param string $args 
  * @param mixed $data 
  * @static
  * @access public
  * @return void
  */
 public static function slideshow($args = '')
 {
     /** Define the default argument array */
     $defaults = array('animation' => 'fade', 'animationSpeed' => 800, 'timer' => true, 'advanceSpeed' => 4000, 'pauseOnHover' => true, 'startClockOnMouseOut' => true, 'startClockOnMouseOutAfter' => 500, 'directionalNav' => true, 'captions' => true, 'captionAnimation' => 'fade', 'captionAnimationSpeed' => 800, 'afterSlideChange' => 'function(){}', 'bullets' => 'false', 'width' => 620, 'height' => 300, 'container_height' => false, 'context' => '', 'context_var' => false, 'featured_option_id' => false, 'allow_user_slides' => false, 'user_slides_header_id' => false, 'listings' => 'limit=5&sort_by=price', 'data' => false, 'post_id' => false, 'post_meta_key' => false, 'fluid' => false);
     $args = wp_parse_args($args, $defaults);
     /** Check cache, return something is there **/
     $cache = new PLS_Cache('slide');
     if ($result = $cache->get($args)) {
         return $result;
     }
     /** Extract all args for easy usage **/
     extract($args, EXTR_SKIP);
     /** If the slideshow data is null or not an array AND the plugin is working, try to fetch the proper data... **/
     if ((!$data || !is_array($data)) && !pls_has_plugin_error()) {
         /** Data assumed to take this form. */
         $data = array('images' => array(), 'links' => array(), 'captions' => array());
         // If the calling theme allows user input, get slideshow config option...
         if ($allow_user_slides && $user_slides_header_id) {
             $slides = pls_get_option($user_slides_header_id, array());
             // Check to see if slides are set to custom, but are empty
             $custom_but_empty = isset($slides[0]) && $slides[0]['type'] == 'custom' && empty($slides[0]['image']);
             // Populate slides when '$custom_but_empty' is true OR when no slides exist...
             if ($custom_but_empty || empty($slides)) {
                 $slides = self::empty_slides_and_add_random_listings();
             }
             foreach ($slides as $index => $slide) {
                 switch ($slide['type']) {
                     case 'listing':
                         unset($slide['html'], $slide['image'], $slide['type'], $slide['link']);
                         // In this case, the slide's remaining key will correspond to it's property ID...
                         $property_id = key($slide);
                         $api_response = PLS_Plugin_API::get_listing_details(array('property_ids' => array($property_id)));
                         if (!empty($api_response['listings']) && $api_response['listings'][0]['id'] === false) {
                             self::$listings_to_delete[] = $property_id;
                         }
                         if ($api_response['total'] == '1') {
                             $listing = $api_response['listings'][0];
                             $first_valid_img_url = null;
                             // Overwrite the placester url with the local url...
                             $listing_url = PLS_Plugin_API::get_property_url($listing['id']);
                             $data['links'][] = $listing_url;
                             // Try to retrieve the image url if order is set...
                             if (is_array($listing['images']) && isset($listing['images'][0]['order'])) {
                                 foreach ($listing['images'] as $key => $image) {
                                     if ($image['order'] == 1) {
                                         $data['images'][$index] = $image['url'];
                                         // break, just in case the listing has more than one '1' in the 'order' param
                                         break;
                                     }
                                     // Record the first valid image URL in case no image has the top order...
                                     if (!isset($first_valid_img_url) && isset($image['url'])) {
                                         $first_valid_img_url = $image['url'];
                                     }
                                 }
                             }
                             // If image still isn't set, use first valid image URL discovered above, or just set to default...
                             if (empty($data['images'][$index])) {
                                 $data['images'][$index] = isset($first_valid_img_url) ? $first_valid_img_url : self::$default_img_url;
                             }
                             $data['type'][] = 'listing';
                             $data['listing'][] = $listing;
                             /** Get the listing caption **/
                             $data['captions'][] = trim(self::render_listing_caption($listing, $index));
                         }
                         break;
                     case 'custom':
                         $is_empty = empty($slide['image']) && empty($slide['link']) && empty($slide['image']) && empty($slide['html']);
                         // Only include a custom slide if it's not entirely empty...
                         if (!$is_empty) {
                             $data['images'][] = $slide['image'];
                             $data['links'][] = $slide['link'];
                             $data['type'][] = 'custom';
                             $data['captions'][] = trim(self::render_custom_caption($slide['html'], $index));
                         }
                         break;
                 }
             }
         } else {
             if (!empty($args['post_id']) && !empty($args['post_meta_key'])) {
                 $api_response = PLS_Listing_Helper::get_featured_from_post($args['post_id'], $args['post_meta_key']);
             } elseif ($featured_option_id) {
                 $api_response = PLS_Listing_Helper::get_featured($featured_option_id);
             }
             if (empty($api_response['listings'])) {
                 $api_response = PLS_Plugin_API::get_listings($listings);
             }
             foreach ($api_response['listings'] as $index => $listing) {
                 if (empty($listing['id'])) {
                     continue;
                 }
                 $listing_url = PLS_Plugin_API::get_property_url($listing['id']);
                 /** Overwrite the placester url with the local url. */
                 $data['links'][] = $listing_url;
                 $data['images'][] = !empty($listing['images']) ? $listing['images'][0]['url'] : self::$default_img_url;
                 $data['listing'][] = $listing;
                 // Get the listing caption
                 $listing_caption = trim(self::render_listing_caption($listing, $index));
                 // Add a filter for a single caption, to be edited via a template
                 $single_caption = apply_filters(pls_get_merged_strings(array('pls_slideshow_single_caption', $context), '_', 'pre', false), $listing_caption, $listing, $context, $context_var, $index);
                 $data['captions'][] = $single_caption;
             }
         }
     }
     /** Filter the data array */
     $data = apply_filters(pls_get_merged_strings(array('pls_slideshow_data', $context), '_', 'pre', false), $data, $context, $context_var);
     /** Create the slideshow */
     $html = array('slides' => '', 'captions' => '');
     if (is_array($data['images'])) {
         foreach ($data['images'] as $index => $slide_src) {
             $extra_attr = array();
             $extra_attr['title'] = '';
             /** Save the caption and the title attribute for the img. */
             if (isset($data['captions'][$index])) {
                 $html['captions'] .= $data['captions'][$index];
                 $extra_attr['title'] = "#caption-{$index}";
             }
             if (isset($data['type'][$index])) {
                 // Get image, but only Dragonfly listing images
                 switch ($data['type'][$index]) {
                     case "listing":
                         $slide_src = PLS_Image::load($slide_src, array('resize' => array('w' => $width, 'h' => $height), 'fancybox' => false, 'as_html' => false));
                         break;
                     case "custom":
                         $slide_src = PLS_Image::load($slide_src, array('allow_resize' => false, 'fancybox' => false, 'as_html' => false));
                         break;
                 }
             }
             /** Create the img element. */
             $slide = pls_h_img($slide_src, false, $extra_attr);
             /** Wrap it in an achor if the anchor exists. */
             if (isset($data['links'][$index])) {
                 $slide = pls_h_a($data['links'][$index], $slide, array('data-caption' => "#caption-{$index}"));
             }
             $html['slides'] .= $slide;
         }
     }
     /** Combine the HTML **/
     $html = pls_h_div($html['slides'], array('id' => 'slider', 'class' => 'orbitSlider')) . $html['captions'];
     /** Filter the HTML array */
     $html = apply_filters(pls_get_merged_strings(array('pls_slideshow_html', $context), '_', 'pre', false), $html, $data, $context, $context_var, $args);
     if (!$container_height) {
         $container_height = $height;
     }
     /** Render the necessary inline CSS... */
     $css_args = array('width' => $width, 'height' => $height, 'container_height' => $container_height);
     $css = self::render_inline_css($css_args);
     /** Render the necessary inline JS... **/
     $args['data'] = is_string($data) ? $data : '';
     // For compatibility...
     $js = self::render_inline_js($args);
     /** Filter inline JS **/
     $js = apply_filters(pls_get_merged_strings(array('pls_slideshow_js', $context), '_', 'pre', false), $js, $html, $data, $context, $context_var);
     /** Filter the final output **/
     $full_slideshow = apply_filters(pls_get_merged_strings(array('pls_slideshow', $context), '_', 'pre', false), $css . $html . $js, $html, $js, $data, $context, $context_var, $args);
     /** Cache rendered slideshow for future retrieval **/
     $cache->save($full_slideshow);
     return $full_slideshow;
 }
    public static function get($args = array())
    {
        // Store this for use in the final output/response...
        $sEcho = isset($_POST['sEcho']) ? $_POST['sEcho'] : 0;
        unset($_POST['sEcho']);
        $context_orig = isset($_POST['context']) ? $_POST['context'] : '';
        unset($_POST['context']);
        // If length is not set for number of listings to return, set it to our Theme Options default
        $_POST['limit'] = isset($_POST['iDisplayLength']) ? $_POST['iDisplayLength'] : pls_get_option('listings_default_list_length');
        unset($_POST['iDisplayLength']);
        $_POST['offset'] = isset($_POST['iDisplayStart']) ? $_POST['iDisplayStart'] : 0;
        unset($_POST['iDisplayStart']);
        $saved_search_lookup = isset($_POST['saved_search_lookup']) ? $_POST['saved_search_lookup'] : null;
        unset($_POST['saved_search_lookup']);
        // Remove this so it doesn't accidentally end up as a superfluous argument of an API call...
        unset($_POST['action']);
        // Handle location edge-case...
        if (!empty($_POST['location']) && !empty($_POST['location']['address']) && empty($_POST['location']['address_match'])) {
            $_POST['location']['address_match'] = 'like';
        }
        // Handle saved search...
        if (!is_null($saved_search_lookup)) {
            // Attempt to retrieve search filters associated with the given saved search lookup ID...
            // NOTE: If no filters exist for the passed ID,
            $filters = PLS_Plugin_API::get_saved_search_filters($saved_search_lookup);
            if (empty($filters) || !is_array($filters)) {
                PLS_Plugin_API::save_search($saved_search_lookup, $_POST);
            } else {
                // For backwards compatibility, handle older fields that are no longer stored as saved search filters...
                $old_field_map = array('sEcho' => false, 'context' => false, 'iDisplayLength' => 'limit', 'iDisplayStart' => 'offset', 'saved_search_lookup' => false, 'action' => false);
                foreach ($old_field_map as $old => $new) {
                    if (isset($filters[$old])) {
                        if ($new !== false) {
                            $filters[$new] = $filters[$old];
                        }
                        unset($filters[$old]);
                    }
                }
                // Swap all existing POST filters for the ones associated with the retrieved saved search...
                $_POST = $filters;
            }
        }
        // Define the default argument array
        $defaults = array('loading_img' => admin_url('images/wpspin_light.gif'), 'image_width' => 100, 'crop_description' => 0, 'sort_type' => pls_get_option('listings_default_sort_type'), 'listings_per_page' => pls_get_option('listings_default_list_length'), 'context' => $context_orig, 'context_var' => NULL, 'append_to_map' => true, 'search_query' => $_POST, 'property_ids' => isset($_POST['property_ids']) ? $_POST['property_ids'] : '', 'allow_id_empty' => false);
        // Resolve function args with default ones (which include any existing POST fields)...
        $merged_args = wp_parse_args($args, $defaults);
        $cache = new PLS_Cache('list');
        if ($cached_response = $cache->get($merged_args)) {
            // This field must match the one passed in with this request...
            $cached_response['sEcho'] = $sEcho;
            echo json_encode($cached_response);
            die;
        }
        // Extract the arguments after they merged with the defaults
        extract($merged_args, EXTR_SKIP);
        // Start off with a placeholder in case the plugin is not active or there is no API key...
        $api_response = PLS_Listing_Helper::$default_listing;
        // If plugin is active, grab listings intelligently...
        if (!pls_has_plugin_error()) {
            // Get the listings list markup and JS
            if (!empty($property_ids) || $allow_id_empty) {
                // Sometimes property_ids are passed in as a flat screen from the JS post object
                if (is_string($property_ids)) {
                    $property_ids = explode(',', $property_ids);
                }
                $api_response = PLS_Plugin_API::get_listing_details(array('property_ids' => $property_ids, 'limit' => $_POST['limit'], 'offset' => $_POST['offset']));
            } elseif (isset($search_query['neighborhood_polygons']) && !empty($search_query['neighborhood_polygons'])) {
                $api_response = PLS_Plugin_API::get_polygon_listings($search_query);
            } else {
                $api_response = PLS_Plugin_API::get_listings($search_query);
            }
        }
        $response = array();
        // Build response for datatables.js
        $listings = array();
        $listings_cache = new PLS_Cache('Listing Thumbnail');
        foreach ($api_response['listings'] as $key => $listing) {
            // Check for cached listing thumbnail...
            $cache_id = array('context' => $context, 'listing_id' => $listing['id']);
            if (!($item_html = $listings_cache->get($cache_id))) {
                // Handle case of zero listing images...
                if (empty($listing['images'])) {
                    $listing['images'][0]['url'] = '';
                }
                ob_start();
                ?>
                    <div class="listing-item grid_8 alpha" itemscope itemtype="http://schema.org/Offer" data-listing="<?php 
                echo $listing['id'];
                ?>
">
                        <div class="listing-thumbnail grid_3 alpha">
                            <?php 
                $property_images = is_array($listing['images']) ? $listing['images'] : array();
                usort($property_images, array(__CLASS__, 'order_images'));
                ?>
                              
                             <a href="<?php 
                echo @$listing['cur_data']['url'];
                ?>
" itemprop="url">
                                <?php 
                echo PLS_Image::load($property_images[0]['url'], array('resize' => array('w' => 210, 'h' => 140), 'fancybox' => true, 'as_html' => true, 'html' => array('alt' => $listing['location']['full_address'], 'itemprop' => 'image', 'placeholder' => PLS_IMG_URL . "/null/listing-300x180.jpg")));
                ?>
                            </a>
                        </div>

                        <div class="listing-item-details grid_5 omega">
                            <header>
                                <p class="listing-item-address h4" itemprop="name">
                                    <a href="<?php 
                echo PLS_Plugin_API::get_property_url($listing['id']);
                ?>
" rel="bookmark" title="<?php 
                echo $listing['location']['address'];
                ?>
" itemprop="url">
                                        <?php 
                echo $listing['location']['address'] . ', ' . $listing['location']['locality'] . ' ' . $listing['location']['region'] . ' ' . $listing['location']['postal'];
                ?>
                                    </a>
                                </p>
                            </header>

                            <div class="basic-details">
                                <ul>
                                  	<?php 
                if (!empty($listing['cur_data']['beds'])) {
                    ?>
                                  		<li class="basic-details-beds p1"><span>Beds:</span> <?php 
                    echo @$listing['cur_data']['beds'];
                    ?>
</li>
                                  	<?php 
                }
                ?>

                                  	<?php 
                if (!empty($listing['cur_data']['baths'])) {
                    ?>
                                  		<li class="basic-details-baths p1"><span>Baths:</span> <?php 
                    echo @$listing['cur_data']['baths'];
                    ?>
</li>
                                  	<?php 
                }
                ?>

                                  	<?php 
                if (!empty($listing['cur_data']['half_baths'])) {
                    ?>
                                  		<li class="basic-details-half-baths p1"><span>Half Baths:</span> <?php 
                    echo @$listing['cur_data']['half_baths'];
                    ?>
</li>
                                  	<?php 
                }
                ?>

                                  	<?php 
                if (!empty($listing['cur_data']['price'])) {
                    ?>
                                  		<li class="basic-details-price p1" itemprop="price"><span>Price:</span> <?php 
                    echo PLS_Format::number($listing['cur_data']['price'], array('abbreviate' => false, 'add_currency_sign' => true));
                    ?>
</li>
                                  	<?php 
                }
                ?>

                                  	<?php 
                if (!empty($listing['cur_data']['sqft'])) {
                    ?>
                                  		<li class="basic-details-sqft p1"><span>Sqft:</span> <?php 
                    echo PLS_Format::number($listing['cur_data']['sqft'], array('abbreviate' => false, 'add_currency_sign' => false));
                    ?>
</li>
                                  	<?php 
                }
                ?>

                                    <?php 
                if (!empty($listing['rets']['mls_id'])) {
                    ?>
                                        <li class="basic-details-mls p1"><span>MLS ID:</span> <?php 
                    echo @$listing['rets']['mls_id'];
                    ?>
</li>
                                    <?php 
                }
                ?>
                                </ul>
                            </div>

                            <p class="listing-description p4" itemprop="description">
                                <?php 
                echo substr($listing['cur_data']['desc'], 0, 300);
                ?>
                            </p>

                        </div>

                        <div class="actions">
                            <a class="more-link" href="<?php 
                echo PLS_Plugin_API::get_property_url($listing['id']);
                ?>
" itemprop="url">View Property Details</a>
                            <?php 
                echo PLS_Plugin_API::placester_favorite_link_toggle(array('property_id' => $listing['id']));
                ?>
                        </div>

                        <?php 
                PLS_Listing_Helper::get_compliance(array('context' => 'inline_search', 'agent_name' => @$listing['rets']['aname'], 'office_name' => @$listing['rets']['oname']));
                ?>
                    </div>
                <?php 
                $item_html = ob_get_clean();
                $item_html = apply_filters(pls_get_merged_strings(array("pls_listings_list_ajax_item_html", $context), '_', 'pre', false), htmlspecialchars_decode($item_html), $listing, $context_var);
                $listings_cache->save($item_html);
            }
            $listings[$key][] = $item_html;
            $listings[$key][] = $listing;
        }
        // Required for datatables.js to function properly...
        $response['sFirst'] = 'Previous';
        $response['sPrevious'] = 'Next';
        $response['sEcho'] = $sEcho;
        $response['aaData'] = $listings;
        $api_total = isset($api_response['total']) ? $api_response['total'] : 0;
        $response['iTotalRecords'] = $api_total;
        $response['iTotalDisplayRecords'] = $api_total;
        $cache->save($response);
        ob_start("ob_gzhandler");
        echo json_encode($response);
        // Wordpress echos out a "0" randomly -- die prevents this...
        die;
    }
 private static function process_default_value_array($empty_values, $context)
 {
     $defaults = array('min_beds' => 'Any', 'max_beds' => 'Any', 'min_baths' => 'Any', 'max_baths' => 'Any', 'bedrooms' => 'Any', 'bathrooms' => 'Any', 'half_baths' => 'Any', 'min_price' => 'Any', 'max_price' => 'Any', 'min_price_rental' => 'All', 'min_price_sales' => 'All', 'max_price_rental' => 'All', 'max_price_sales' => 'All', 'property_type' => 'Any', 'listing_types' => 'Any', 'zoning_types' => 'Any', 'purchase_types' => 'Any', 'available_on' => 'Any', 'cities' => 'All', 'states' => 'All', 'zips' => 'All', 'neighborhoods' => 'All', 'neighborhood_polygons' => 'All', 'county' => 'All', 'min_sqft' => 'All', 'max_sqft' => 'All');
     $empty_values = apply_filters(pls_get_merged_strings(array("pls_listings_search_form_default_values", $context), '_', 'pre', false), $empty_values, $defaults);
     $empty_values = wp_parse_args($empty_values, $defaults);
     return $empty_values;
 }