/** * @see WP_Widget::widget */ function widget($args, $instance) { global $post, $wp_properties; if (!isset($post->ID)) { return; } $before_widget = ''; $before_title = ''; $after_title = ''; $after_widget = ''; extract($args); $instance = apply_filters('ChildPropertiesWidget', $instance); $data = array('instance' => $instance, 'before_title' => $before_title, 'after_title' => $after_title, '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'] : '', 'hide_image' => isset($instance['hide_image']) ? $instance['hide_image'] : false, 'stats' => isset($instance['stats']) ? $instance['stats'] : array(), 'address_format' => isset($instance['address_format']) ? $instance['address_format'] : '', 'amount_items' => !empty($instance['amount_items']) ? $instance['amount_items'] : 5, 'sort_by' => isset($instance['sort_by']) ? $instance['sort_by'] : 'date', 'sort_order' => isset($instance['sort_order']) ? $instance['sort_order'] : 'DESC'); if (!empty($data['image_type'])) { $data['image_size'] = WPP_F::image_sizes($data['image_type']); } $data['properties'] = get_posts(array('post_type' => 'property', 'numberposts' => $data['amount_items'], 'post_status' => 'publish', 'post_parent' => $post->ID, 'orderby' => $data['sort_by'], 'order' => $data['sort_order'])); if (count($data['properties']) < 1) { return; } echo $before_widget; $this->get_template('child-properties', $data); echo $after_widget; }
function wpp_get_image_link($attachment_id, $size, $args = array()) { global $wp_properties; if (empty($size) || empty($attachment_id)) { return false; } //** Optional arguments */ $defaults = array('return' => 'string'); extract(wp_parse_args($args, $defaults), EXTR_SKIP); if (isset($wp_properties['configuration']['do_not_automatically_regenerate_thumbnails']) && $wp_properties['configuration']['do_not_automatically_regenerate_thumbnails'] == 'true') { //* If on-the-fly image generation is specifically disabled, we simply return the default URL */ $default_return = wp_get_attachment_image_src($attachment_id, $size, true); $i[0] = $default_return[0]; $i[1] = $default_return[1]; $i[2] = $default_return[2]; } else { //* Do the default action of attempting to regenerate image if needed. */ $uploads_dir = wp_upload_dir(); //** Get image path from meta table (if this doesn't exist, nothing we can do */ if ($_wp_attached_file = get_post_meta($attachment_id, '_wp_attached_file', true)) { $attachment_path = $uploads_dir['basedir'] . '/' . $_wp_attached_file; } else { return false; } //** Get meta of main image (may not exist if XML import) */ $image_meta = wp_get_attachment_metadata($attachment_id); //** Real URL of full image */ $img_url = wp_get_attachment_url($attachment_id); //** Filenme of image */ $img_url_basename = wp_basename($img_url); if (isset($image_meta['sizes'][$size]) && !empty($image_meta['sizes'][$size]['file'])) { //** Image image meta exists, we get the path and URL to the requested image size */ $requested_size_filepath = str_replace($img_url_basename, $image_meta['sizes'][$size]['file'], $attachment_path); $requested_image_url = str_replace($img_url_basename, $image_meta['sizes'][$size]['file'], $img_url); $image_path = $requested_size_filepath; //** Meta is there, now check if file still exists on disk */ if (file_exists($requested_size_filepath)) { $requested_image_exists = true; } } if (isset($requested_image_exists) && $requested_image_exists) { $i[0] = $requested_image_url; } else { //** Image with the current size doesn't exist. Try generate file */ if (WPP_F::generate_image($attachment_id, $size)) { //** Get Image data again */ $image = image_downsize($attachment_id, $size); if (is_array($image)) { $i = $image; } } else { //** Failure because image could not be resized. Return original URL */ $i[0] = $img_url; $image_path = str_replace($uploads_dir['baseurl'], $uploads_dir['basedir'], $img_url); } } } // Must check that $image_path exists, for remotely stored images this will be empty and will cause an an error within getimagesize. if (isset($image_path) && $image_path) { $getimagesize = @getimagesize($image_path); } else { $getimagesize = array('', ''); } //** Get true image dimensions or returned URL */ $i[1] = $getimagesize[0]; $i[2] = $getimagesize[1]; //** Return image data as requested */ if ($i) { switch ($return) { case 'array': if ($i[1] == 0 || $i[2] == 0) { $s = WPP_F::image_sizes($size); $i[1] = $s['width']; $i[2] = $s['height']; } return array('link' => $i[0], 'src' => $i[0], 'url' => $i[0], 'width' => $i[1], 'height' => $i[2]); break; case 'string': default: return $i[0]; break; } } return false; }
?> </th> <th><?php _e('Height', ud_get_wp_property()->domain); ?> </th> <th> </th> </tr> </thead> <tbody> <?php $wpp_image_sizes = $wp_properties['image_sizes']; foreach (array_unique((array) get_intermediate_image_sizes()) as $slug) { $slug = trim($slug); // We return all, including images with zero sizes, to avoid default data overriding what we save $image_dimensions = WPP_F::image_sizes($slug, "return_all=true"); // Skip images w/o dimensions if (!$image_dimensions) { continue; } // Disable if WP not a WPP image size if (!isset($wpp_image_sizes[$slug]) || !is_array($wpp_image_sizes[$slug])) { $disabled = true; } else { $disabled = false; } if (!$disabled) { ?> <tr class="wpp_dynamic_table_row" slug="<?php echo $slug; ?>
/** * @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; }
/** * Widget body * @param array $args * @param array $instance */ function widget($args, $instance) { global $wp_properties, $post, $property; $before_widget = ''; $before_title = ''; $after_title = ''; $after_widget = ''; extract($args); $title = isset($instance['title']) ? $instance['title'] : ''; $image_type = !empty($instance['image_type']) ? $instance['image_type'] : 'thumbnail'; $big_image_type = isset($instance['big_image_type']) ? $instance['big_image_type'] : false; $gallery_count = isset($instance['gallery_count']) ? $instance['gallery_count'] : false; $show_caption = isset($instance['show_caption']) ? $instance['show_caption'] : false; $show_description = isset($instance['show_description']) ? $instance['show_description'] : false; $gallery = isset($post->gallery) ? (array) $post->gallery : (isset($property['gallery']) ? (array) $property['gallery'] : array()); $slideshow_images = !empty($post->slideshow_images) ? $post->slideshow_images : (!empty($property['slideshow_images']) ? $property['slideshow_images'] : false); $slideshow_order = maybe_unserialize($slideshow_images); $gallery_order = maybe_unserialize(!empty($post->gallery_images) ? $post->gallery_images : (!empty($property['gallery_images']) ? $property['gallery_images'] : false)); //** Calculate order of images */ if (is_array($slideshow_order) || is_array($gallery_order)) { $order = array_unique(array_merge((array) $slideshow_order, (array) $gallery_order)); $prepared_gallery_images = array(); //** Get images from the list of images by order */ foreach ($order as $order_id) { foreach ($gallery as $image_slug => $gallery_image_data) { if ($gallery_image_data['attachment_id'] == $order_id) { $prepared_gallery_images[$image_slug] = $gallery_image_data; unset($gallery[$image_slug]); } } } //** Be sure we show ALL property images in gallery */ $gallery = array_merge($prepared_gallery_images, $gallery); } if (!is_array($gallery)) { return NULL; } $thumbnail_dimensions = WPP_F::image_sizes($image_type); //** 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); */ $html[] = $before_widget; $html[] = "<div class='wpp_gallery_widget'>"; if ($title) { $html[] = $before_title . $title . $after_title; } ob_start(); if (is_array($gallery)) { $real_count = 0; foreach ($gallery as $image) { $thumb_image = wpp_get_image_link($image['attachment_id'], $image_type); ?> <div class="sidebar_gallery_item"> <?php if (!empty($big_image_type)) { ?> <?php $big_image = wpp_get_image_link($image['attachment_id'], $big_image_type); ?> <a href="<?php echo $big_image; ?> " class="fancybox_image thumbnail" rel="property_gallery"> <img src="<?php echo $thumb_image; ?> " title="<?php echo esc_attr($image['post_excerpt'] ? $image['post_excerpt'] : $image['post_title'] . ' - ' . $post->post_title); ?> " alt="<?php echo esc_attr($image['post_excerpt'] ? $image['post_excerpt'] : $image['post_title']); ?> " class="wpp_gallery_widget_image size-thumbnail " width="<?php echo $thumbnail_dimensions['width']; ?> " height="<?php echo $thumbnail_dimensions['height']; ?> "/> </a> <?php } else { ?> <img src="<?php echo $thumb_image; ?> " title="<?php echo esc_attr($image['post_excerpt'] ? $image['post_excerpt'] : $image['post_title'] . ' - ' . $post->post_title); ?> " alt="<?php echo esc_attr($image['post_excerpt'] ? $image['post_excerpt'] : $image['post_title']); ?> " class="wpp_gallery_widget_image size-thumbnail " width="<?php echo $thumbnail_dimensions['width']; ?> " height="<?php echo $thumbnail_dimensions['height']; ?> "/> <?php } ?> <?php if ($show_caption == 'on' && !empty($image['post_excerpt'])) { ?> <div class="wpp_image_widget_caption"><?php echo $image['post_excerpt']; ?> </div> <?php } ?> <?php if ($show_description == 'on') { ?> <div class="wpp_image_widget_description"><?php echo $image['post_content']; ?> </div> <?php } ?> </div> <?php $real_count++; if (!empty($gallery_count) && $gallery_count == $real_count) { break; } } } $html['images'] = ob_get_contents(); ob_end_clean(); $html[] = "</div>"; $html[] = $after_widget; $html = apply_filters('wpp_widget_property_gallery', $html, array('args' => $args, 'instance' => $instance, 'post' => $post)); if (!empty($html['images']) && is_array($html)) { echo implode('', $html); } return; }
/** * Displays dropdown of available property size images * * * @since 0.54 * */ public static function image_sizes_dropdown($args = "") { global $wp_properties; $defaults = array('name' => 'wpp_image_sizes', 'selected' => 'none', 'blank_selection_label' => ' - '); extract(wp_parse_args($args, $defaults), EXTR_SKIP); $blank_selection_label = isset($blank_selection_label) ? $blank_selection_label : ' - '; $selected = isset($selected) ? $selected : 'none'; if (empty($id) && !empty($name)) { $id = $name; } $image_array = get_intermediate_image_sizes(); ?> <select id="<?php echo $id; ?> " name="<?php echo $name; ?> "> <option value=""><?php echo $blank_selection_label; ?> </option> <?php foreach ($image_array as $name) { $sizes = WPP_F::image_sizes($name); if (!$sizes) { continue; } ?> <option value='<?php echo $name; ?> ' <?php if ($selected == $name) { echo 'SELECTED'; } ?> > <?php echo $name; ?> : <?php echo $sizes['width']; ?> px by <?php echo $sizes['height']; ?> px </option> <?php } ?> </select> <?php }
/** * Displays property overview * * Performs searching/filtering functions, provides template with $properties file * Retirms html content to be displayed after location attribute on property edit page * * @since 1.081 * * @param string $listing_id Listing ID must be passed * * @return string $result * * @uses WPP_F::get_properties() * */ public static function render($atts = "") { global $wp_properties, $wpp_query, $property, $post, $wp_query; $_property = $property; $wpp_query = array(); $atts = wp_parse_args($atts, array()); \WPP_F::force_script_inclusion('jquery-ui-widget'); \WPP_F::force_script_inclusion('jquery-ui-mouse'); \WPP_F::force_script_inclusion('jquery-ui-slider'); \WPP_F::force_script_inclusion('wpp-jquery-address'); \WPP_F::force_script_inclusion('wpp-jquery-scrollTo'); \WPP_F::force_script_inclusion('wpp-jquery-fancybox'); \WPP_F::force_script_inclusion('wp-property-frontend'); //** Load all queriable attributes **/ foreach (\WPP_F::get_queryable_keys() as $key) { //** This needs to be done because a key has to exist in the $deafult array for shortcode_atts() to load passed value */ $queryable_keys[$key] = false; } //** Allow the shorthand of "type" as long as there is not a custom attribute of "type". If "type" does exist as an attribute, then users need to use the full "property_type" query tag. **/ if (!array_key_exists('type', $queryable_keys) && (is_array($atts) && array_key_exists('type', $atts))) { $atts['property_type'] = $atts['type']; unset($atts['type']); } //** Get ALL allowed attributes that may be passed via shortcode (to include property attributes) */ $defaults['strict_search'] = false; $defaults['show_children'] = isset($wp_properties['configuration']['property_overview']['show_children']) ? $wp_properties['configuration']['property_overview']['show_children'] : 'true'; $defaults['child_properties_title'] = __('Floor plans at location:', ud_get_wp_property()->domain); $defaults['fancybox_preview'] = $wp_properties['configuration']['property_overview']['fancybox_preview']; $defaults['bottom_pagination_flag'] = isset($wp_properties['configuration']['bottom_insert_pagenation']) && $wp_properties['configuration']['bottom_insert_pagenation'] == 'true' ? true : false; $defaults['thumbnail_size'] = $wp_properties['configuration']['property_overview']['thumbnail_size']; $defaults['sort_by_text'] = __('Sort By:', ud_get_wp_property()->domain); $defaults['sort_by'] = 'post_date'; $defaults['sort_order'] = 'DESC'; $defaults['template'] = false; $defaults['ajax_call'] = false; $defaults['disable_wrapper'] = false; $defaults['sorter_type'] = 'buttons'; $defaults['sorter'] = 'on'; $defaults['pagination'] = 'on'; $defaults['pagination_type'] = ud_get_wp_property('configuration.property_overview.pagination_type') ? ud_get_wp_property('configuration.property_overview.pagination_type') : 'slider'; $defaults['hide_count'] = false; $defaults['per_page'] = 10; $defaults['starting_row'] = 0; $defaults['unique_hash'] = rand(10000, 99900); $defaults['detail_button'] = false; $defaults['stats'] = ''; $defaults['class'] = 'wpp_property_overview_shortcode'; $defaults['in_new_window'] = false; $defaults = apply_filters('shortcode_property_overview_allowed_args', $defaults, $atts); //* Determine if we should disable sorter */ if (isset($atts['sorter']) && in_array($atts['sorter'], array('off', 'false'))) { $atts['sorter'] = false; $atts['sorter_type'] = 'none'; } if (!empty($atts['ajax_call'])) { //** If AJAX call then the passed args have all the data we need */ $wpp_query = $atts; //* Fix ajax data. Boolean value false is returned as string 'false'. */ foreach ($wpp_query as $key => $value) { if ($value == 'false') { $wpp_query[$key] = false; } } $wpp_query['ajax_call'] = true; //** Everything stays the same except for sort order and page */ $wpp_query['starting_row'] = ($wpp_query['requested_page'] - 1) * $wpp_query['per_page']; //** Figure out current page */ $wpp_query['current_page'] = $wpp_query['requested_page']; } else { /** Determine if fancybox style is included */ \WPP_F::force_style_inclusion('wpp-jquery-fancybox-css'); //** Merge defaults with passed arguments */ $wpp_query = shortcode_atts($defaults, $atts); $wpp_query['query'] = shortcode_atts($queryable_keys, $atts); //** Handle search */ if (!empty($_REQUEST['wpp_search'])) { $wpp_query['query'] = shortcode_atts($wpp_query['query'], $_REQUEST['wpp_search']); $wpp_query['query'] = \WPP_F::prepare_search_attributes($wpp_query['query']); if (isset($_REQUEST['wpp_search']['sort_by'])) { $wpp_query['sort_by'] = $_REQUEST['wpp_search']['sort_by']; } if (isset($_REQUEST['wpp_search']['sort_order'])) { $wpp_query['sort_order'] = $_REQUEST['wpp_search']['sort_order']; } if (isset($_REQUEST['wpp_search']['pagination'])) { $wpp_query['pagination'] = $_REQUEST['wpp_search']['pagination']; } if (isset($_REQUEST['wpp_search']['per_page'])) { $wpp_query['per_page'] = $_REQUEST['wpp_search']['per_page']; } if (isset($_REQUEST['wpp_search']['strict_search'])) { $wpp_query['strict_search'] = $_REQUEST['wpp_search']['strict_search']; } } } //** Load certain settings into query for get_properties() to use */ $wpp_query['query']['sort_by'] = $wpp_query['sort_by']; $wpp_query['query']['sort_order'] = $wpp_query['sort_order']; $wpp_query['query']['pagi'] = $wpp_query['starting_row'] . '--' . $wpp_query['per_page']; if (!isset($wpp_query['current_page'])) { $wpp_query['current_page'] = $wpp_query['starting_row'] / $wpp_query['per_page'] + 1; } //** Load settings that are not passed via shortcode atts */ $wpp_query['sortable_attrs'] = \WPP_F::get_sortable_keys(); //** Replace dynamic field values */ //** Detect currently property for conditional in-shortcode usage that will be replaced from values */ if (isset($post) && is_object($post)) { $dynamic_fields['post_id'] = isset($post->ID) ? $post->ID : 0; $dynamic_fields['post_parent'] = isset($post->post_parent) ? $post->post_parent : 0; $dynamic_fields['property_type'] = isset($post->property_type) ? $post->property_type : false; $dynamic_fields = apply_filters('shortcode_property_overview_dynamic_fields', $dynamic_fields); if (is_array($dynamic_fields)) { foreach ($wpp_query['query'] as $query_key => $query_value) { if (!empty($dynamic_fields[$query_value])) { $wpp_query['query'][$query_key] = $dynamic_fields[$query_value]; } } } } //** Remove all blank values */ $wpp_query['query'] = array_filter($wpp_query['query']); //echo "<pre>"; print_r( $wpp_query ); echo "</pre>"; //** We add # to value which says that we don't want to use LIKE in SQL query for searching this value. */ $required_strict_search = apply_filters('wpp::required_strict_search', array('wpp_agents')); $ignored_strict_search_field_types = apply_filters('wpp:ignored_strict_search_field_types', array('range_dropdown', 'range_input')); foreach ($wpp_query['query'] as $key => $val) { if (!array_key_exists($key, $defaults) && $key != 'property_type') { //** Be sure that the attribute exists of parameter is required for strict search */ if (in_array($wpp_query['strict_search'], array('true', 'on')) && isset($wp_properties['property_stats'][$key]) || in_array($key, $required_strict_search)) { /** * Ignore specific search attribute fields for strict search. * For example, range values must not be included to strict search. * Also, be sure to ignore list of values */ if (isset($wp_properties['searchable_attr_fields'][$key]) && in_array($wp_properties['searchable_attr_fields'][$key], (array) $ignored_strict_search_field_types) || substr_count($val, ',') || substr_count($val, '–') || substr_count($val, '--')) { continue; } elseif (substr_count($val, '-')) { $_val = explode('-', $val); if (count($_val) == 2 && is_numeric($_val[0]) && is_numeric($_val[1])) { continue; } } $wpp_query['query'][$key] = '#' . trim($val, '#') . '#'; } } } //** Unset this because it gets passed with query (for back-button support) but not used by get_properties() */ unset($wpp_query['query']['per_page']); unset($wpp_query['query']['pagination']); unset($wpp_query['query']['requested_page']); //** Load the results */ $wpp_query['properties'] = \WPP_F::get_properties($wpp_query['query'], true); //** Calculate number of pages */ if ($wpp_query['pagination'] == 'on') { $wpp_query['pages'] = ceil($wpp_query['properties']['total'] / $wpp_query['per_page']); } $property_type = isset($wpp_query['query']['property_type']) ? $wpp_query['query']['property_type'] : false; if (!empty($property_type) && isset($wp_properties['hidden_attributes'][$property_type])) { foreach ((array) $wp_properties['hidden_attributes'][$property_type] as $attr_key) { unset($wpp_query['sortable_attrs'][$attr_key]); } } //** Legacy Support - include variables so old templates still work */ $properties = $wpp_query['properties']['results']; $thumbnail_sizes = \WPP_F::image_sizes($wpp_query['thumbnail_size']); $child_properties_title = $wpp_query['child_properties_title']; $unique = $wpp_query['unique_hash']; $thumbnail_size = $wpp_query['thumbnail_size']; //* Debugger */ if (isset($wp_properties['configuration']['developer_mode']) && $wp_properties['configuration']['developer_mode'] == 'true' && !$wpp_query['ajax_call']) { echo '<script type="text/javascript">console.log( ' . json_encode($wpp_query) . ' ); </script>'; } ob_start(); //** Make certain variables available to be used within the single listing page */ $wpp_overview_shortcode_vars = apply_filters('wpp_overview_shortcode_vars', array('wp_properties' => $wp_properties, 'wpp_query' => $wpp_query)); //** By merging our extra variables into $wp_query->query_vars they will be extracted in load_template() */ if (is_array($wpp_overview_shortcode_vars)) { $wp_query->query_vars = array_merge($wp_query->query_vars, $wpp_overview_shortcode_vars); } $template = $wpp_query['template']; $fancybox_preview = $wpp_query['fancybox_preview']; $show_children = $wpp_query['show_children']; $class = $wpp_query['class']; $stats = $wpp_query['stats']; $in_new_window = !empty($wpp_query['in_new_window']) ? " target=\"_blank\" " : ""; //** Make query_vars available to emulate WP template loading */ extract($wp_query->query_vars, EXTR_SKIP); //** Try find custom template */ $template_found = \WPP_F::get_template_part(array("property-overview-{$template}", "property-overview-" . sanitize_key($property_type), "property-overview"), array(ud_get_wp_property()->path('static/views', 'dir'))); if ($template_found) { include $template_found; } $ob_get_contents = ob_get_contents(); ob_end_clean(); $ob_get_contents = apply_filters('shortcode_property_overview_content', $ob_get_contents, $wpp_query); // Initialize result (content which will be shown) and open wrap (div) with unique id if ($wpp_query['disable_wrapper'] != 'true') { $result['top'] = '<div id="wpp_shortcode_' . $wpp_query['unique_hash'] . '" class="wpp_ui ' . $wpp_query['class'] . '">'; } $result['top_pagination'] = self::draw_pagination(array('type' => $wpp_query['pagination_type'], 'class' => 'wpp_top_pagination', 'sorter_type' => $wpp_query['sorter_type'], 'hide_count' => $wpp_query['hide_count'], 'sort_by_text' => $wpp_query['sort_by_text'])); $result['result'] = $ob_get_contents; if ($wpp_query['bottom_pagination_flag'] == 'true') { $result['bottom_pagination'] = self::draw_pagination(array('type' => $wpp_query['pagination_type'], 'class' => 'wpp_bottom_pagination', 'sorter_type' => $wpp_query['sorter_type'], 'hide_count' => $wpp_query['hide_count'], 'sort_by_text' => $wpp_query['sort_by_text'], 'javascript' => false)); } if ($wpp_query['disable_wrapper'] != 'true') { $result['bottom'] = '</div>'; } $result = apply_filters('wpp_property_overview_render', $result); /* Reset global property to default. */ $property = $_property; if ($wpp_query['ajax_call']) { return json_encode(array('wpp_query' => $wpp_query, 'display' => implode('', $result))); } else { return implode('', $result); } }
/** * @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; }