Esempio n. 1
0
 /**
  * Performs front-end pre-header functionality
  *
  * - This function is not called on admin side.
  * - Loads conditional CSS styles.
  * - Determines if page is single property or property overview.
  *
  * @since 1.11
  */
 public function template_redirect()
 {
     global $post, $property, $wp_query, $wp_properties, $wp_styles, $wpp_query;
     /**
      * HACK.
      * @see self::parse_request();
      * @author peshkov@UD
      */
     if (get_query_var('_fix_to_page_template')) {
         $wp_query->is_single = false;
         $wp_query->is_page = true;
     }
     wp_localize_script('wpp-localization', 'wpp', array('instance' => $this->get_instance()));
     //** Load global wp-property script on all frontend pages */
     wp_enqueue_script('wp-property-global');
     if (apply_filters('wpp::custom_styles', false) === false) {
         //** Possibly load essential styles that are used in widgets */
         wp_enqueue_style('wp-property-frontend');
         //** Possibly load theme specific styles */
         wp_enqueue_style('wp-property-theme-specific');
     }
     if (!isset($wp_properties['configuration']['do_not_enable_text_widget_shortcodes']) || $wp_properties['configuration']['do_not_enable_text_widget_shortcodes'] != 'true') {
         add_filter('widget_text', 'do_shortcode');
     }
     do_action('wpp_template_redirect');
     //** Handle single property page previews */
     if (!empty($wp_query->query_vars['preview']) && $post->post_type == "property" && $post->post_status == "publish") {
         wp_redirect(get_permalink($post->ID));
         die;
     }
     /* (count($wp_query->posts) < 2) added post 1.31.1 release */
     /* to avoid taxonomy archives from being broken by single property pages */
     if (isset($post) && count($wp_query->posts) < 2 && ($post->post_type == "property" || isset($wp_query->is_child_property))) {
         $wp_query->single_property_page = true;
         //** This is a hack and should be done better */
         if (!$post) {
             $post = get_post($wp_query->queried_object_id);
             $wp_query->posts[0] = $post;
             $wp_query->post = $post;
         }
     }
     //** If viewing root property page that is the default dynamic page. */
     if (isset($wp_query->wpp_default_property_page)) {
         $wp_query->is_property_overview = true;
     }
     //** If this is the root page with a manually inserted shortcode, or any page with a PO shortcode */
     if (isset($post) && strpos($post->post_content, "property_overview")) {
         $wp_query->is_property_overview = true;
     }
     //** If this is the root page and the shortcode is automatically inserted */
     if (isset($wp_query->wpp_root_property_page) && $wp_properties['configuration']['automatically_insert_overview'] == 'true') {
         $wp_query->is_property_overview = true;
     }
     //** If search result page, and system not explicitly configured to not include PO on search result page automatically */
     if (isset($wp_query->wpp_search_page) && (!isset($wp_properties['configuration']['do_not_override_search_result_page']) || $wp_properties['configuration']['do_not_override_search_result_page'] != 'true')) {
         $wp_query->is_property_overview = true;
     }
     //** Scripts and styles to load on all overview and single listing pages */
     if (isset($wp_query->single_property_page) || isset($wp_query->is_property_overview)) {
         // Check for and load conditional browser styles
         $conditional_styles = apply_filters('wpp_conditional_style_slugs', array('IE', 'IE 7', 'msie'));
         foreach ($conditional_styles as $type) {
             // Fix slug for URL
             $url_slug = strtolower(str_replace(" ", "_", $type));
             if (file_exists(STYLESHEETPATH . "/wp_properties-{$url_slug}.css")) {
                 wp_register_style('wp-property-frontend-' . $url_slug, get_bloginfo('stylesheet_directory') . "/wp_properties-{$url_slug}.css", array('wp-property-frontend'), '1.13');
             } elseif (file_exists(TEMPLATEPATH . "/wp_properties-{$url_slug}.css")) {
                 wp_register_style('wp-property-frontend-' . $url_slug, get_bloginfo('template_url') . "/wp_properties-{$url_slug}.css", array('wp-property-frontend'), '1.13');
             } elseif (file_exists(WPP_URL . "styles/wp_properties-{$url_slug}.css") && $wp_properties['configuration']['autoload_css'] == 'true') {
                 wp_register_style('wp-property-frontend-' . $url_slug, WPP_URL . "styles/wp_properties-{$url_slug}.css", array('wp-property-frontend'), WPP_Version);
             }
             // Mark every style as conditional
             $wp_styles->add_data('wp-property-frontend-' . $url_slug, 'conditional', $type);
             wp_enqueue_style('wp-property-frontend-' . $url_slug);
         }
     }
     //** Scripts loaded only on single property pages */
     if (isset($wp_query->single_property_page)) {
         WPP_F::console_log('Including scripts for all single property pages.');
         WPP_F::load_assets(array('single'));
         do_action('template_redirect_single_property');
         add_action('wp_head', create_function('', "do_action('wp_head_single_property'); "));
         $property = (array) WPP_F::get_property($post->ID, "load_gallery=true");
         $property_type = !empty($property['property_type']) ? $property['property_type'] : false;
         // Redirect to parent if property type is non-public.
         if (isset($wp_properties['redirect_to_parent']) && is_array($wp_properties['redirect_to_parent']) && in_array($property_type, $wp_properties['redirect_to_parent']) && $property['post_parent']) {
             die(wp_redirect(get_permalink($property['post_parent'])));
         }
         $property = prepare_property_for_display($property);
         //** Make certain variables available to be used within the single listing page */
         $single_page_vars = apply_filters('wpp_property_page_vars', array('property' => $property, 'wp_properties' => $wp_properties));
         //** By merging our extra variables into $wp_query->query_vars they will be extracted in load_template() */
         if (is_array($single_page_vars)) {
             $wp_query->query_vars = array_merge($wp_query->query_vars, $single_page_vars);
         }
     }
     //** Current requests includes a property overview.  PO may be via shortcode, search result, or due to this being the Default Dynamic Property page */
     if (isset($wp_query->is_property_overview)) {
         WPP_F::console_log('Including scripts for all property overview pages.');
         WPP_F::load_assets(array('overview'));
         if (isset($wp_query->wpp_default_property_page)) {
             WPP_F::console_log('Dynamic Default Property page detected, will load custom template.');
         } else {
             WPP_F::console_log('Custom Default Property page detected, property overview content may be rendered via shortcode.');
         }
         //** Make certain variables available to be used within the single listing page */
         $overview_page_vars = apply_filters('wpp_overview_page_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($overview_page_vars)) {
             $wp_query->query_vars = array_merge($wp_query->query_vars, $overview_page_vars);
         }
         do_action('template_redirect_property_overview');
         add_action('wp_head', create_function('', "do_action('wp_head_property_overview'); "));
     }
     do_action('wpp_template_redirect_post_scripts');
 }
Esempio n. 2
0
 /**
  * This function takes all your properties and exports it as an XML feed
  *
  * @todo Improve efficiency of function, times out quickly for feeds of 500 properties. memory_limit and set_time_limit should be removed once efficiency is improved
  *
  */
 public function wpp_export_properties()
 {
     global $wp_properties;
     ini_set('memory_limit', -1);
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $starttime = $mtime;
     // Set a new path
     set_include_path(get_include_path() . PATH_SEPARATOR . WPP_Path . 'lib/third-party/XML/');
     // Include our necessary libaries
     require_once 'Serializer.php';
     require_once 'Unserializer.php';
     $api_key = \WPP_F::get_api_key();
     $taxonomies = $wp_properties['taxonomies'];
     // If the API key isn't valid, we quit
     if (!isset($_REQUEST['api']) || $_REQUEST['api'] != $api_key) {
         die(__('Invalid API key.', ud_get_wp_property()->domain));
     }
     if (isset($_REQUEST['limit'])) {
         $per_page = $_REQUEST['limit'];
         $starting_row = 0;
     }
     if (isset($_REQUEST['per_page'])) {
         $per_page = $_REQUEST['per_page'];
     }
     if (isset($_REQUEST['starting_row'])) {
         $starting_row = $_REQUEST['starting_row'];
     }
     if (isset($_REQUEST['property_type'])) {
         $property_type = $_REQUEST['property_type'];
     } else {
         $property_type = 'all';
     }
     if (strtolower($_REQUEST['format']) == 'xml') {
         $xml_format = true;
     } else {
         $xml_format = false;
     }
     $wpp_query['query']['pagi'] = $starting_row . '--' . $per_page;
     $wpp_query['query']['sort_by'] = isset($_REQUEST['sort_by']) ? $_REQUEST['sort_by'] : 'post_date';
     $wpp_query['query']['sort_order'] = isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : 'ASC';
     $wpp_query['query']['property_type'] = $property_type;
     $wpp_query['query'] = apply_filters('wpp::xml::export::query', $wpp_query['query']);
     $wpp_query = \WPP_F::get_properties($wpp_query['query'], true);
     $results = $wpp_query['results'];
     if (count($results) == 0) {
         die(__('No published properties.', ud_get_wp_property()->domain));
     }
     if ($xml_format) {
     } else {
     }
     $properties = array();
     foreach ($results as $count => $id) {
         //** Reserve time on every iteration. */
         set_time_limit(0);
         $property = \WPP_F::get_property($id, "return_object=false&load_parent=false&get_children=false");
         if ($property['post_parent'] && !$property['parent_gpid']) {
             $property['parent_gpid'] = \WPP_F::maybe_set_gpid($property['post_parent']);
         }
         // Unset unnecessary data
         unset($property['comment_count'], $property['post_modified_gmt'], $property['comment_status'], $property['post_password'], $property['guid'], $property['filter'], $property['post_author'], $property['permalink'], $property['ping_status'], $property['post_modified'], $property['post_mime_type']);
         // Set unique site ID
         $property['wpp_unique_id'] = md5($api_key . $property['ID']);
         //** Get taxonomies */
         if ($taxonomies) {
             foreach ($taxonomies as $taxonomy_slug => $taxonomy_data) {
                 if ($these_terms = wp_get_object_terms($property['ID'], $taxonomy_slug, array('fields' => 'names'))) {
                     $property['taxonomies'][$taxonomy_slug] = $these_terms;
                 }
             }
         }
         $fixed_property = array();
         foreach ($property as $meta_key => $meta_value) {
             // Maybe Unserialize
             $meta_value = maybe_unserialize($meta_value);
             if (is_array($meta_value) || is_object($meta_value)) {
                 $fixed_property[$meta_key] = $meta_value;
                 continue;
             }
             $fixed_property[$meta_key] = $meta_value;
         }
         $properties[$id] = $fixed_property;
     }
     $properties = apply_filters('wpp::xml::export::data', $properties);
     if ($xml_format) {
         $result = $this->convert_to_xml($properties, apply_filters('wpp::xml::export::serializer_options', array()));
         /** Deprecated. peshkov@UD
             $result = json_encode( $properties );
             $result = WPP_F::json_to_xml( $result, apply_filters( 'wpp::xml::export::serializer_options', array() ) );
             //*/
         if (!$result) {
             die(__('There is an Error on trying to create XML feed.', ud_get_wp_property()->domain));
         }
         header('Content-type: text/xml');
         header('Content-Disposition: inline; filename="wpp_xml_data.xml"');
     } else {
         $result = json_encode($properties);
         header('Content-type: application/json');
         header('Content-Disposition: inline; filename="wpp_xml_data.json"');
     }
     header("Cache-Control: no-cache");
     header("Pragma: no-cache");
     die($result);
 }
<?php

/**
 * Template Child Properties Widget
 *
 *
 */
global $wp_properties;
echo "<div class='wpp_child_properties_widget'>";
if ($title) {
    echo $before_title . $title . $after_title;
}
foreach ($properties as $property) {
    $this_property = WPP_F::get_property($property->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 apartment_entry clearfix"
       style="<?php 
    echo $width ? 'width: ' . ($width + 5) . 'px;' : '';
    ?>
">
    <?php 
    if ($hide_image !== 'on') {
        ?>
      <?php 
        if (!empty($image)) {
            ?>
        <a class="sidebar_property_thumbnail thumbnail" href="<?php 
            echo $this_property->permalink;
 /**
  * @param string $atts
  * @return string|void
  */
 public function call($atts = "")
 {
     global $post, $property;
     $this_property = $property;
     if (empty($this_property) && $post->post_type == 'property') {
         $this_property = $post;
     }
     $this_property = (array) $this_property;
     if (!$atts) {
         $atts = array();
     }
     $defaults = array('property_id' => $this_property['ID'], 'attribute' => '', 'before' => '', 'after' => '', 'if_empty' => '', 'do_not_format' => '', 'make_terms_links' => 'false', 'separator' => ' ', 'strip_tags' => '');
     $args = array_merge($defaults, $atts);
     if (empty($args['attribute'])) {
         return false;
     }
     $attribute = $args['attribute'];
     if ($args['property_id'] != $this_property['ID']) {
         $this_property = WPP_F::get_property($args['property_id']);
         if ($args['do_not_format'] != "true") {
             $this_property = prepare_property_for_display($this_property);
         }
     }
     if (taxonomy_exists($attribute) && is_object_in_taxonomy('property', $attribute)) {
         foreach (wp_get_object_terms($this_property['ID'], $attribute) as $term_data) {
             if ($args['make_terms_links'] == 'true') {
                 $terms[] = '<a class="wpp_term_link" href="' . get_term_link($term_data, $attribute) . '"><span class="wpp_term">' . $term_data->name . '</span></a>';
             } else {
                 $terms[] = '<span class="wpp_term">' . $term_data->name . '</span>';
             }
         }
         if (isset($terms) && is_array($terms) && !empty($terms)) {
             $value = implode($args['separator'], $terms);
         }
     }
     //** Try to get value using get get_attribute() function */
     if (!isset($value) || !$value && function_exists('get_attribute')) {
         $value = get_attribute($attribute, array('return' => 'true', 'property_object' => $this_property));
     }
     if (!empty($args['before'])) {
         $return['before'] = html_entity_decode($args['before']);
     }
     $return['value'] = apply_filters('wpp_property_attribute_shortcode', $value, $this_property);
     if ($args['strip_tags'] == "true" && !empty($return['value'])) {
         $return['value'] = strip_tags($return['value']);
     }
     if (!empty($args['after'])) {
         $return['after'] = html_entity_decode($args['after']);
     }
     //** When no value is found */
     if (empty($return['value'])) {
         if (!empty($args['if_empty'])) {
             return $args['if_empty'];
         } else {
             return false;
         }
     }
     if (is_array($return)) {
         return implode('', $return);
     }
     return false;
 }
Esempio n. 5
0
 /**
  * Runs all filters through property variables
  *
  * Main function for preparing the property object to be displayed on the front-end.
  * Same args are applied to main object, and child objects that are loade. So if gallery is not loaded for parent, it will not be loaded for children.
  *
  * Called in the_post() via WPP_F::the_post()
  *
  * @todo There is an issue with quotes being converted to &quot; and not working well when value has a shortcode.
  * @since 1.4
  *
  */
 function prepare_property_for_display($property, $args = false)
 {
     global $wp_properties;
     if (empty($property)) {
         return;
     }
     $_args = is_array($args) ? http_build_query($args) : (string) $args;
     /* Used to apply different filters depending on where the attribute is displayed. i.e. google_map_infobox  */
     $attribute_scope = !empty($args['scope']) ? $args['scope'] : false;
     $return_type = is_object($property) ? 'object' : 'array';
     if (is_numeric($property)) {
         $property_id = $property;
     } elseif (is_object($property)) {
         $property = (array) $property;
         $property_id = $property['ID'];
     } elseif (is_array($property)) {
         $property_id = $property['ID'];
     }
     //** Check if this function has already been done */
     if (is_array($property) && isset($property['system']['prepared_for_display'])) {
         return $property;
     }
     //** Load property from cache, or function, if not passed */
     if (!is_array($property)) {
         if ($cache_property = wp_cache_get(md5('display_' . $property_id . $_args))) {
             return $cache_property;
         }
         //** Cache not found, load property */
         $property = (array) WPP_F::get_property($property_id, $args);
     }
     // Go through children properties
     if (isset($property['children']) && is_array($property['children'])) {
         foreach ($property['children'] as $child => $child_data) {
             $property['children'][$child] = prepare_property_for_display($child_data, $args);
         }
     }
     $attributes = ud_get_wp_property('property_stats', array());
     foreach ($property as $meta_key => $attribute_value) {
         //** Only execute shortcodes for defined property attributes to prevent different issues */
         if (!array_key_exists($meta_key, (array) $attributes)) {
             continue;
         }
         //** Only executed shortcodes if the value isn't an array */
         if (!is_array($attribute_value)) {
             if (!empty($args['do_not_execute_shortcodes']) && $args['do_not_execute_shortcodes'] == 'true' || $meta_key == 'post_content') {
                 continue;
             }
             //** Determine if the current attribute is address and set it as display address */
             if ($meta_key == $wp_properties['configuration']['address_attribute'] && !empty($property['display_address'])) {
                 $attribute_value = $property['display_address'];
             }
             $attribute_value = do_shortcode(html_entity_decode($attribute_value));
             $attribute_value = str_replace("\n", "", nl2br($attribute_value));
         }
         $attribute_value = apply_filters("wpp::attribute::display", $attribute_value, $meta_key);
         $property[$meta_key] = apply_filters("wpp_stat_filter_{$meta_key}", $attribute_value, $attribute_scope);
     }
     $property['system']['prepared_for_display'] = true;
     wp_cache_add(md5('display_' . $property_id . $_args), $property);
     if ($return_type == 'object') {
         return (object) $property;
     } else {
         return $property;
     }
 }
Esempio n. 6
0
/**
 * Updates numeric and currency attribute of parent property on child property saving.
 * Sets attribute's value based on children values ( sets aggregated value ).
 *
 * * Tries to figure out which attributes can be handled as a "range". (legacy-logic)
 * * Iterates over all children of the parent and writes any computed ranges directly to parents meta.
 *
 * @param integer $post_id
 * @used WPP_F::save_property();
 * @author peshkov@UD
 * @return null
 */
function wpp_save_property_aggregated_data($post_id)
{
    global $wpdb, $wp_properties;
    if (empty($_REQUEST['parent_id'])) {
        return null;
    }
    //** Get all children */
    $children = $wpdb->get_col($wpdb->prepare("\n    SELECT ID\n      FROM {$wpdb->posts}\n        WHERE  post_type = 'property'\n        AND post_status = 'publish'\n        AND post_parent = %s\n          ORDER BY menu_order ASC\n  ", $_REQUEST['parent_id']));
    if (count($children) > 0) {
        $range = array();
        //** Cycle through children and get necessary variables */
        foreach ($children as $child_id) {
            $child_object = WPP_F::get_property($child_id, "load_parent=false");
            //** Exclude variables from searchable attributes (to prevent ranges) */
            $excluded_attributes = $wp_properties['geo_type_attributes'];
            $excluded_attributes[] = $wp_properties['configuration']['address_attribute'];
            foreach ($wp_properties['searchable_attributes'] as $searchable_attribute) {
                $attribute_data = UsabilityDynamics\WPP\Attributes::get_attribute_data($searchable_attribute);
                if (!empty($attribute_data['numeric']) || !empty($attribute_data['currency'])) {
                    if (!empty($child_object[$searchable_attribute]) && !in_array($searchable_attribute, $excluded_attributes)) {
                        if (!isset($range[$searchable_attribute])) {
                            $range[$searchable_attribute] = array();
                        }
                        $range[$searchable_attribute][] = $child_object[$searchable_attribute];
                    }
                }
            }
        }
        foreach ($range as $range_attribute => $range_values) {
            //* Cycle through all values of this range (attribute), and fix any ranges that use dashes */
            foreach ($range_values as $key => $single_value) {
                //* Remove dollar signs */
                $single_value = str_replace("\$", '', $single_value);
                //* Fix ranges */
                if (strpos($single_value, '&ndash;')) {
                    $split = explode('&ndash;', $single_value);
                    foreach ($split as $new_single_value) {
                        if (!empty($new_single_value)) {
                            array_push($range_values, trim($new_single_value));
                        }
                    }
                    //* Unset original value with dash */
                    unset($range_values[$key]);
                }
            }
            $average = isset($wp_properties['configuration']['show_aggregated_value_as_average']) ? $wp_properties['configuration']['show_aggregated_value_as_average'] : false;
            $val = @array_sum($range_values);
            $val = is_numeric($val) && $val > 0 ? $average == 'true' ? ceil($val / count($range_values)) : $val : 0;
            update_post_meta($_REQUEST['parent_id'], $range_attribute, $val);
        }
    }
}
    ?>
_slider"></div>
    </div>
  <?php 
}
?>
  </div>
</div>

<div id="content" class="<?php 
wpp_css('property_search::content', "page type-page hentry");
?>
" >
  <div style="width: 890px; float: left;">
    <?php 
$searchable_properties = WPP_F::get_searchable_properties();
if ($searchable_properties) {
    foreach ($searchable_properties as $property_id) {
        $property = WPP_F::get_property($property_id);
        // 1. Try template in theme folder
        $template_found = WPP_F::get_template_part(array("property-search-block"), array(WPP_Templates));
        if ($template_found) {
            include $template_found;
        }
    }
}
?>
  </div>
</div>

Esempio n. 8
0
 /**
  *
  * @author peshkov@UD
  * @since 1.38
  */
 public static function feps_post_created($post_id, $args = array())
 {
     global $wp_post_statuses;
     $notification = self::_notification_template();
     $_property = WPP_F::get_property($post_id, array('get_children' => 'false'));
     $user_id = $_property['post_author'];
     $user = get_user_by('id', $user_id);
     $notification['trigger_action'] = 'pending_property_added';
     $notification['user'] = $user;
     $notification['subject'] = __('Submission Received', ud_get_wp_property()->domain);
     $notification['message'] = sprintf(__('Hello.%1$s%1$sYour %2$s has been received.%1$s%1$sYou can view it using this URL:%1$s[pending_url]', ud_get_wp_property()->domain), PHP_EOL, WPP_F::property_label('singular'));
     $notification['crm_log_message'] = sprintf(__('User submitted %1$s ([property_title]) using FEPS.', ud_get_wp_property()->domain), WPP_F::property_label('singular'));
     $notification['data']['notification_type'] = __('Submission Received', ud_get_wp_property()->domain);
     $notification['data']['display_name'] = $user->data->display_name;
     $notification['data']['user_email'] = $user->data->user_email;
     $notification['data']['site_url'] = site_url();
     $notification['data']['pending_url'] = class_wpp_feps::get_feps_permalink($_property, false);
     $notification['data']['title'] = $notification['data']['property_title'] = $_property['post_title'];
     $notification['data']['status'] = @$wp_post_statuses[$_property['post_status']]->label;
     $notification = WPP_F::array_merge_recursive_distinct($notification, $args);
     self::_send_notification($notification);
 }
    /**
     * @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;
    }
Esempio n. 10
0
    /**
     * 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);
        }
    }
Esempio n. 11
0
 /**
  * Get advanced details about an image (mostly for troubleshooting)
  *
  * @todo add some sort of light validating that the the passed item here is in fact an image
  *
  */
 public static function get_property_image_data($requested_id)
 {
     global $wpdb;
     if (empty($requested_id)) {
         return false;
     }
     ob_start();
     if (is_numeric($requested_id)) {
         $post_type = $wpdb->get_var("SELECT post_type FROM {$wpdb->posts} WHERE ID = '{$requested_id}'");
     } else {
         //** Try and image search */
         $image_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_title LIKE '%{$requested_id}%' ");
         if ($image_id) {
             $post_type = 'image';
             $requested_id = $image_id;
         }
     }
     if ($post_type == 'property') {
         //** Get Property Images */
         $property = WPP_F::get_property($requested_id);
         echo 'Requested Property: ' . $property['post_title'];
         $data = get_children(array('post_parent' => $requested_id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC'));
         echo "\nProperty has: " . count($data) . ' images.';
         foreach ($data as $img) {
             $image_data['ID'] = $img->ID;
             $image_data['post_title'] = $img->post_title;
             $img_meta = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id = '{$img->ID}'");
             foreach ($img_meta as $i_m) {
                 $image_data[$i_m->meta_key] = maybe_unserialize($i_m->meta_value);
             }
             print_r($image_data);
         }
     } else {
         $data = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE ID = '{$requested_id}'");
         $image_meta = $wpdb->get_results("SELECT meta_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id = '{$requested_id}'");
         foreach ($image_meta as $m_data) {
             print_r($m_data->meta_id);
             echo "<br />";
             print_r($m_data->meta_key);
             echo "<br />";
             print_r(maybe_unserialize($m_data->meta_value));
         }
     }
     $return_data = ob_get_contents();
     ob_end_clean();
     return $return_data;
 }
    /**
     * @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;
    }