/** * Outputs and filters the widget. * * The widget connects to the plugin using the framework plugin api class. * If the class returns false, this means that either the plugin is * missing, either the it has no API key set. * * @since 0.0.1 */ public function widget($args, $instance) { list($args, $instance) = self::process_defaults($args, $instance); /** Extract the arguments into separate variables. */ extract($args, EXTR_SKIP); /* Output the theme's $before_widget wrapper. */ echo $before_widget; /* If a title was input by the user, display it. */ $widget_title = ''; if (!empty($instance['title']) && !pls_has_plugin_error()) { $widget_title = $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title; } /** Get the list of listings using the partial. */ $listings_args = array('limit' => $instance['number'], 'width' => $instance['width'], 'height' => $instance['height'], 'placeholder_img' => $instance['placeholder'], 'crop_description' => 1, 'context' => 'widget', 'context_var' => $widget_id, 'featured_option_id' => $featured_option_id); /** If field is empty, remove it so that the function's defaults can be used. */ if (empty($instance['placeholder'])) { unset($listings_args['placeholder_img']); } // set context so filter can customize the layout $listings_args['context'] = 'get_listings_widget'; // pls_dump($listings_args); $widget_body = PLS_Partials::get_listings($listings_args); /** Apply a filter on the whole widget */ echo apply_filters('pls_widget_listings', $widget_title . $widget_body, $widget_title, $before_title, $after_title, $widget_body, $instance, $widget_id, $listings_args); /* Close the theme's widget wrapper. */ echo $after_widget; }
*/ ?> <section id="slideshow" class="slider-wrapper theme-default"> <?php echo PLS_Slideshow::slideshow(array('animation' => 'fade', 'animationSpeed' => 1000, 'pauseOnHover' => true, 'advanceSpeed' => 4000, 'startClockOnMouseOut' => true, 'startClockOnMouseOutAfter' => 1000, 'directionalNav' => true, 'captions' => true, 'captionAnimation' => 'fade', 'captionAnimationSpeed' => 800, 'afterSlideChange' => 'function(){}', 'width' => 623, 'height' => 300, 'context' => 'home', 'featured_option_id' => 'slideshow-featured-listings', 'listings' => 'limit=5&is_featured=true&sort_by=price')); ?> <script type="text/javascript"> // Hack to alter bullets styling for formerly BP 1.0 themes -- need to do this more intelligently... jQuery(window).load(function () { jQuery('.orbit-bullets').css('margin-top', '-90px'); }); </script> <div class="clr"></div> </section> <section id="listing"> <h3><?php _e('New Listings', 'tampa'); ?> </h3> <?php echo PLS_Partials::get_listings("limit=5&featured_option_id=custom-featured-listings&context=home"); ?> <?php PLS_Listing_Helper::get_compliance(array('context' => 'search', 'agent_name' => false, 'office_name' => false)); ?> </section>
public static function get($args = array()) { $cache = new PLS_Cache('nbh'); if ($result = $cache->get($args)) { return $result; } extract(self::process_args($args), EXTR_SKIP); $subject = array(); if ($street) { $subject += array('taxonomy' => 'street', 'term' => $street, 'api_field' => 'address'); } elseif ($neighborhood) { $subject += array('taxonomy' => 'neighborhood', 'term' => $neighborhood, 'api_field' => 'neighborhood'); } elseif ($zip) { $subject += array('taxonomy' => 'zip', 'term' => $zip, 'api_field' => 'postal'); } elseif ($city) { $subject += array('taxonomy' => 'city', 'term' => $city, 'api_field' => 'locality'); } elseif ($state) { $subject += array('taxonomy' => 'state', 'term' => $state, 'api_field' => 'region'); } $term = get_term_by('slug', $subject['term'], $subject['taxonomy'], ARRAY_A); $custom_data = array(); foreach (self::$custom_meta as $meta) { $custom_data[$meta['id']] = get_tax_meta($term['term_id'], $meta['id']); } $term = wp_parse_args($term, $custom_data); $term['api_field'] = $subject['api_field']; //if there's a polygon, use that to get listings. Otherwise, use the name of the neighborhood $polygon = PLS_Plugin_API::get_taxonomies_by_slug($subject['term']); if (is_array($polygon) && !empty($polygon[0])) { $polygon[0]['neighborhood_polygons'] = $polygon[0]['name']; $listings_raw = PLS_Plugin_API::get_polygon_listings($polygon[0]); $term['listings'] = PLS_Partials::get_listings("limit=5&context=home&neighborhood_polygons=" . $polygon[0]['name']); } else { $listings_raw = PLS_Plugin_API::get_listings("location[" . $term['api_field'] . "]=" . $term['name']); $term['listings'] = PLS_Partials::get_listings("limit=5&context=home&request_params=location[" . $term['api_field'] . "]=" . $term['name']); } $term['areas'] = array('locality' => array(), 'postal' => array(), 'neighborhood' => array(), 'address' => array()); $locality_tree = array('city' => array('postal', 'neighborhood', 'address'), 'zip' => array('neighborhood', 'address'), 'neighborhood' => array('address'), 'street' => array()); $term['listings_raw'] = $listings_raw['listings']; //assemble all the photos $api_translations = array('locality' => 'city', 'neighborhood' => 'neighborhood', 'postal' => 'zip', 'address' => 'street'); $term['listing_photos'] = array(); $count = 0; if (isset($listings_raw['listings'])) { foreach ($listings_raw['listings'] as $key => $listing) { if (!empty($listing['images'])) { foreach ($listing['images'] as $image) { if ($count > $image_limit) { break; } $term['listing_photos'][] = array('full_address' => $listing['location']['full_address'], 'image_url' => $image['url'], 'listing_url' => $listing['cur_data']['url']); $count++; } } if (isset($locality_tree[$subject['taxonomy']])) { foreach ($locality_tree[$subject['taxonomy']] as $locality) { $link = array('name' => $listing['location'][$locality], 'permalink' => get_term_link($listing['location'][$locality], $api_translations[$locality])); if (is_string($link['permalink'])) { $term['areas'][$locality][] = $link; } } } } } $term['polygon'] = PLS_Plugin_API::get_polygon_detail(array('tax' => $term['api_field'], 'slug' => $subject['term'])); $cache->save($term); return $term; }