} ?> <ul class="wpp_widget_attribute_list"> <?php if (is_array($stats)) { ?> <?php foreach ($stats as $stat) { ?> <?php if (!isset($this_property->{$stat})) { continue; } switch (true) { case !empty($wp_properties['configuration']['address_attribute']) && $wp_properties['configuration']['address_attribute'] == $stat: $content = wpp_format_address_attribute($this_property->{$stat}, $this_property, $address_format); break; case $stat == 'property_type': $content = nl2br(apply_filters("wpp_stat_filter_property_type_label", $this_property->property_type_label)); break; default: $content = nl2br(apply_filters("wpp_stat_filter_{$stat}", $this_property->{$stat})); break; } if (empty($content)) { continue; } ?> <li class="<?php echo $stat; ?>
/** * Widget body * * @param array $args * @param array $instance */ function widget($args, $instance) { global $post, $wp_properties, $property; $before_widget = ''; $before_title = ''; $after_title = ''; $after_widget = ''; extract($args); $instance = apply_filters('OtherPropertiesWidget', $instance); $title = isset($instance['title']) ? $instance['title'] : ''; $show_title = isset($instance['show_title']) ? $instance['show_title'] : false; $image_type = isset($instance['image_type']) ? $instance['image_type'] : false; $hide_image = isset($instance['hide_image']) ? $instance['hide_image'] : false; $stats = isset($instance['stats']) ? $instance['stats'] : false; $address_format = isset($instance['address_format']) ? $instance['address_format'] : ''; $amount_items = !empty($instance['amount_items']) ? $instance['amount_items'] : 0; $show_properties_of_type = isset($instance['show_properties_of_type']) ? $instance['show_properties_of_type'] : false; $shuffle_order = isset($instance['shuffle_order']) ? $instance['shuffle_order'] : false; if (!isset($post->ID) || $post->post_parent == 0 && $show_properties_of_type != 'on') { return; } $this_property = (array) $property; if ($post->post_parent) { $properties = get_posts(array('numberposts' => $amount_items, 'post_type' => 'property', 'post_status' => 'publish', 'post_parent' => $post->post_parent, 'exclude' => $post->ID)); } else { $properties = WPP_F::get_properties("property_type={$this_property['property_type']}&pagi=0--{$amount_items}"); } if (empty($properties)) { return; } $html[] = $before_widget; $html[] = "<div class='wpp_other_properties_widget'>"; if ($title) { $html[] = $before_title . $title . $after_title; } if ($shuffle_order == 'on') { shuffle($properties); } ob_start(); foreach ($properties as $single) { $property_id = is_object($single) ? $single->ID : $single; $this_property = WPP_F::get_property($property_id, 'return_object=true'); $this_property = prepare_property_for_display($this_property); $image = isset($this_property->featured_image) && !empty($image_type) ? wpp_get_image_link($this_property->featured_image, $image_type, array('return' => 'array')) : false; ?> <div class="property_widget_block apartment_entry clearfix" style="<?php echo !empty($image['width']) ? 'width: ' . ($image['width'] + 5) . 'px;' : ''; ?> "> <?php if ($hide_image !== 'on' && !empty($image)) { ?> <a class="sidebar_property_thumbnail thumbnail" href="<?php echo $this_property->permalink; ?> "> <img width="<?php echo $image['width']; ?> " height="<?php echo $image['height']; ?> " src="<?php echo $image['link']; ?> " alt=""/> </a> <?php } ?> <?php if ($show_title == 'on') { ?> <p class="title"><a href="<?php echo $this_property->permalink; ?> "><?php echo $this_property->post_title; ?> </a></p> <?php } ?> <ul class="wpp_widget_attribute_list"> <?php if (is_array($stats)) { foreach ($stats as $stat) { if (!isset($this_property->{$stat})) { continue; } switch (true) { case !empty($wp_properties['configuration']['address_attribute']) && $wp_properties['configuration']['address_attribute'] == $stat: $content = wpp_format_address_attribute($this_property->{$stat}, $this_property, $address_format); break; case $stat == 'property_type': $content = nl2br(apply_filters("wpp_stat_filter_property_type_label", $this_property->property_type_label)); break; default: $content = nl2br(apply_filters("wpp_stat_filter_{$stat}", $this_property->{$stat})); break; } if (empty($content)) { continue; } ?> <li class="<?php echo $stat; ?> "> <span class="attribute"><?php echo $wp_properties['property_stats'][$stat]; ?> :</span> <span class="value"><?php echo $content; ?> </span> </li> <?php } } ?> </ul> <?php if ($instance['enable_more'] == 'on') { echo '<p class="more"><a href="' . $this_property->permalink . '" class="btn btn-info">' . __('More', ud_get_wp_property()->domain) . '</a></p>'; } ?> </div> <?php unset($this_property); } $html['widget_content'] = ob_get_contents(); ob_end_clean(); if ($instance['enable_view_all'] == 'on') { $html[] = '<p class="view-all"><a href="' . site_url() . '/' . $wp_properties['configuration']['base_slug'] . '" class="btn btn-large">' . __('View All', ud_get_wp_property()->domain) . '</a></p>'; } $html[] = '</div>'; $html[] = $after_widget; if (!empty($html['widget_content'])) { echo implode('', $html); } }
/** * @see WP_Widget::widget */ function widget($args, $instance) { global $wp_properties; $before_widget = ''; $before_title = ''; $after_title = ''; $after_widget = ''; extract($args); $instance = apply_filters('LatestPropertiesWidget', $instance); $title = isset($instance['title']) ? $instance['title'] : ''; $stats = isset($instance['stats']) ? $instance['stats'] : array(); $image_type = !empty($instance['image_type']) ? $instance['image_type'] : ''; $hide_image = isset($instance['hide_image']) ? $instance['hide_image'] : false; $show_title = isset($instance['show_title']) ? $instance['show_title'] : false; $address_format = isset($instance['address_format']) ? $instance['address_format'] : ''; $property_stats = isset($wp_properties['property_stats']) ? $wp_properties['property_stats'] : array(); if (!empty($image_type)) { $image_size = WPP_F::image_sizes($image_type); } if (!isset($property_stats['property_type'])) { $property_stats['property_type'] = sprintf(__('%s Type', ud_get_wp_property()->domain), WPP_F::property_label()); } $arg = array('post_type' => 'property', 'numberposts' => !empty($instance['amount_items']) ? $instance['amount_items'] : 5, 'post_status' => 'publish', 'post_parent' => null, 'order' => 'DESC', 'orderby' => 'post_date'); $postslist = get_posts($arg); echo $before_widget; echo "<div class='wpp_latest_properties_widget'>"; if ($title) { echo $before_title . $title . $after_title; } foreach ($postslist as $post) { $this_property = WPP_F::get_property($post->ID, 'return_object=true'); $image = isset($this_property->featured_image) ? wpp_get_image_link($this_property->featured_image, $image_type, array('return' => 'array')) : false; $width = !empty($image_size['width']) ? $image_size['width'] : (!empty($image['width']) ? $image['width'] : ''); $height = !empty($image_size['height']) ? $image_size['height'] : (!empty($image['height']) ? $image['height'] : ''); ?> <div class="property_widget_block latest_entry clearfix" style="<?php echo $width ? 'width: ' . ($width + 5) . 'px;' : ''; ?> "> <?php if ($hide_image !== 'on') { ?> <?php if (!empty($image)) { ?> <a class="sidebar_property_thumbnail latest_property_thumbnail thumbnail" href="<?php echo $this_property->permalink; ?> "> <img width="<?php echo $image['width']; ?> " height="<?php echo $image['height']; ?> " src="<?php echo $image['url']; ?> " alt="<?php echo sprintf(__('%s at %s for %s', ud_get_wp_property()->domain), $this_property->post_title, $this_property->location, $this_property->price); ?> "/> </a> <?php } else { ?> <div class="wpp_no_image" style="width:<?php echo $width; ?> px;height:<?php echo $height; ?> px;"></div> <?php } ?> <?php } if ($show_title == 'on') { echo '<p class="title"><a href="' . $this_property->permalink . '">' . $post->post_title . '</a></p>'; } echo '<ul class="wpp_widget_attribute_list">'; if (is_array($stats)) { foreach ($stats as $stat) { if (!isset($this_property->{$stat})) { continue; } switch (true) { case !empty($wp_properties['configuration']['address_attribute']) && $wp_properties['configuration']['address_attribute'] == $stat: $content = wpp_format_address_attribute($this_property->{$stat}, $this_property, $address_format); break; case $stat == 'property_type': $content = nl2br(apply_filters("wpp_stat_filter_property_type_label", $this_property->property_type_label)); break; default: $content = nl2br(apply_filters("wpp_stat_filter_{$stat}", $this_property->{$stat})); break; } if (empty($content)) { continue; } echo '<li class="' . $stat . '"><span class="attribute">' . $property_stats[$stat] . ':</span> <span class="value">' . $content . '</span></li>'; } } echo '</ul>'; if (isset($instance['enable_more']) && $instance['enable_more'] == 'on') { echo '<p class="more"><a href="' . $this_property->permalink . '" class="btn btn-info">' . __('More', ud_get_wp_property()->domain) . '</a></p>'; } ?> </div> <?php unset($this_property); } if (isset($instance['enable_view_all']) && $instance['enable_view_all'] == 'on') { echo '<p class="view-all"><a href="' . site_url() . '/' . $wp_properties['configuration']['base_slug'] . '" class="btn btn-large">' . __('View All', ud_get_wp_property()->domain) . '</a></p>'; } echo '<div class="clear"></div>'; echo '</div>'; echo $after_widget; }
/** * @see WP_Widget::widget * */ function widget($args, $instance) { global $wp_properties; $before_widget = ''; $before_title = ''; $after_title = ''; $after_widget = ''; extract($args); $title = apply_filters('widget_title', !empty($instance['title']) ? $instance['title'] : ''); $instance = apply_filters('FeaturedPropertiesWidget', $instance); $show_title = isset($instance['show_title']) ? $instance['show_title'] : false; $image_type = isset($instance['image_type']) ? $instance['image_type'] : false; $amount_items = isset($instance['amount_items']) ? $instance['amount_items'] : false; $stats = isset($instance['stats']) ? $instance['stats'] : false; $address_format = isset($instance['address_format']) ? $instance['address_format'] : false; $hide_image = isset($instance['hide_image']) ? $instance['hide_image'] : false; $amount_items = isset($instance['amount_items']) ? $instance['amount_items'] : false; $random_items = isset($instance['random_items']) ? $instance['random_items'] : false; $property_stats = isset($wp_properties['property_stats']) ? $wp_properties['property_stats'] : array(); if (empty($address_format)) { $address_format = "[street_number] [street_name], [city], [state]"; } if (!$image_type) { $image_type = ''; } else { $image_size = WPP_F::image_sizes($image_type); } if (!isset($property_stats['property_type'])) { $property_stats['property_type'] = sprintf(__('%s Type', ud_get_wp_property()->domain), WPP_F::property_label()); } $random_sort = $random_items == 1 ? '&sort_by=random' : ''; $all_featured = WPP_F::get_properties("featured=true&property_type=all&pagi=0--{$amount_items}{$random_sort}"); /** Bail out if no children */ if (!$all_featured) { return; } //** The current widget can be used on the page twice. So ID of the current DOM element (widget) has to be unique */ /* //Removed since this will cause problems with jQuery Tabs in Denali. $before_widget = preg_replace('/id="([^\s]*)"/', 'id="$1_'.rand().'"', $before_widget); //*/ echo $before_widget; echo "<div class='wpp_featured_properties_widget'>"; if ($title) { echo $before_title . $title . $after_title; } $count = 0; foreach ($all_featured as $featured) { if ($amount_items == $count) { continue; } $count++; $this_property = WPP_F::get_property($featured, 'return_object=true'); if (!empty($this_property->featured_image)) { $image = wpp_get_image_link($this_property->featured_image, $image_type, array('return' => 'array')); $width = !empty($image_size['width']) ? $image_size['width'] : (!empty($image['width']) ? $image['width'] : ''); $height = !empty($image_size['height']) ? $image_size['height'] : (!empty($image['height']) ? $image['height'] : ''); } ?> <div class="property_widget_block clearfix" style="<?php echo $width ? 'width: ' . ($width + 5) . 'px;' : ''; ?> min-height: <?php echo $height; ?> px;"> <?php if ($hide_image !== 'on') { ?> <?php if (!empty($image)) { ?> <a class="sidebar_property_thumbnail thumbnail" href="<?php echo $this_property->permalink; ?> "> <img width="<?php echo $image['width']; ?> " height="<?php echo $image['height']; ?> " src="<?php echo $image['link']; ?> " alt=""/></a> <?php } else { ?> <div class="wpp_no_image" style="width:<?php echo $width; ?> px;height:<?php echo $height; ?> px;"></div> <?php } ?> <?php } ?> <?php if ($show_title == 'on') { ?> <p class="title"><a href="<?php echo $this_property->permalink; ?> "><?php echo $this_property->post_title; ?> </a></p> <?php } ?> <ul class="wpp_widget_attribute_list"> <?php if (is_array($stats)) { ?> <?php foreach ($stats as $stat) { if (!isset($this_property->{$stat})) { continue; } switch (true) { case !empty($wp_properties['configuration']['address_attribute']) && $wp_properties['configuration']['address_attribute'] == $stat: $content = wpp_format_address_attribute($this_property->{$stat}, $this_property, $address_format); break; case $stat == 'property_type': $content = nl2br(apply_filters("wpp_stat_filter_property_type_label", $this_property->property_type_label)); break; default: $content = nl2br(apply_filters("wpp_stat_filter_{$stat}", $this_property->{$stat})); break; } if (empty($content)) { continue; } ?> <li class="<?php echo $stat; ?> "><span class='attribute'><?php echo $property_stats[$stat]; ?> :</span> <span class='value'><?php echo $content; ?> </span></li> <?php } ?> <?php } ?> </ul> <?php if (isset($instance['enable_more']) && $instance['enable_more'] == 'on') { ?> <p class="more"><a href="<?php echo $this_property->permalink; ?> " class="btn btn-info"><?php _e('More', ud_get_wp_property()->domain); ?> </a></p> <?php } ?> </div> <?php unset($this_property); } if (isset($instance['enable_view_all']) && $instance['enable_view_all'] == 'on') { echo '<p class="view-all"><a href="' . site_url() . '/' . $wp_properties['configuration']['base_slug'] . '" class="btn btn-large">' . __('View All', ud_get_wp_property()->domain) . '</a></p>'; } echo '<div class="clear"></div>'; echo '</div>'; echo $after_widget; }