/**
  * Handle Bulk Action's request
  *
  */
 public function process_bulk_action()
 {
     global $wpdb;
     try {
         switch ($this->current_action()) {
             case 'unassign':
                 if (empty($_REQUEST['post_ids']) || !is_array($_REQUEST['post_ids'])) {
                     throw new \Exception(sprintf(__('Invalid request: no %s IDs provided.', ud_get_wp_property('domain')), \WPP_F::property_label()));
                 }
                 $post_ids = $_REQUEST['post_ids'];
                 foreach ($post_ids as $post_id) {
                     $post_id = (int) $post_id;
                     if (!$post_id) {
                         throw new \Exception(sprintf(__('Invalid request: incorrect %s IDs provided.', ud_get_wp_property('domain')), \WPP_F::property_label()));
                     }
                     $wpdb->query($wpdb->prepare("\n                  UPDATE {$wpdb->posts}\n                  SET post_parent = '0'\n                  WHERE ID = %d\n                ", $post_id));
                     clean_post_cache($post_id);
                 }
                 $label = count($post_ids) > 1 ? __('Children', ud_get_wp_property('domain')) : __('Child', ud_get_wp_property('domain'));
                 $this->message = sprintf(__('Selected %s have been successfully un-assigned from current %s.', ud_get_wp_property('domain')), $label, \WPP_F::property_label());
                 break;
             default:
                 //** Any custom action can be processed using action hook */
                 do_action('wpp::children_list_table::process_bulk_action', $this->current_action());
                 break;
         }
     } catch (\Exception $e) {
         $this->error = $e->getMessage();
     }
 }
 /**
  * init
  */
 public function __construct()
 {
     $taxonomies = array();
     $_taxonomies = ud_get_wp_property('taxonomies', array());
     if (!empty($_taxonomies) && is_array($_taxonomies)) {
         foreach ($_taxonomies as $k => $v) {
             $taxonomies[$k] = !empty($v['label']) ? $v['label'] : $k;
         }
     }
     $options = array('id' => 'property_terms', 'params' => array('property_id' => array('name' => sprintf(__('%s ID', ud_get_wp_property('domain')), \WPP_F::property_label()), 'description' => sprintf(__('If not empty, result will show particular %s, which ID is set.', ud_get_wp_property('domain')), \WPP_F::property_label()), 'type' => 'text', 'default' => ''), 'taxonomy' => array('name' => __('Taxonomy', ud_get_wp_property()->domain), 'description' => sprintf(__('Renders %s terms of particular taxonomy', ud_get_wp_property('domain')), \WPP_F::property_label()), 'type' => 'select', 'options' => $taxonomies)), 'description' => sprintf(__('Renders %s Terms for specific taxonomy', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property');
     parent::__construct($options);
 }
 /**
  * Init
  */
 public function __construct()
 {
     $attributes = ud_get_wp_property('property_stats', array());
     /*
             $hidden_attributes = ud_get_wp_property( 'hidden_frontend_attributes', array() );
             foreach( $attributes as $k => $v ) {
               if( in_array( $k, $hidden_attributes ) ) {
                 unset( $attributes[$k] );
               }
             }
             //*/
     $options = array('id' => 'property_attributes', 'params' => array('sort_by_groups' => array('name' => __('Sort by groups', ud_get_wp_property()->domain), 'description' => __('Sort attributes by groups or not', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain))), 'display' => array('name' => __('Display', ud_get_wp_property()->domain), 'description' => __('The way of displaying attributes', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('list' => __('Simple List', ud_get_wp_property()->domain), 'dl_list' => __('Definitions List', ud_get_wp_property()->domain), 'plain_list' => __('Plain List', ud_get_wp_property()->domain), 'detail' => __('Detailed List', ud_get_wp_property()->domain))), 'show_true_as_image' => array('name' => __('Show "True" as image', ud_get_wp_property()->domain), 'description' => __('Display boolean attributes like checkbox image.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('false' => __('No', ud_get_wp_property()->domain), 'true' => __('Yes', ud_get_wp_property()->domain))), 'make_link' => array('name' => __('Make link', ud_get_wp_property()->domain), 'description' => __('Make URLs into clickable links', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain))), 'hide_false' => array('name' => __('Hide false', ud_get_wp_property()->domain), 'description' => __('Hide attributes with false value', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('false' => __('No', ud_get_wp_property()->domain), 'true' => __('Yes', ud_get_wp_property()->domain))), 'return_blank' => array('name' => __('Return Blank', ud_get_wp_property()->domain), 'description' => __('Omit blank values or not.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('false' => __('No', ud_get_wp_property()->domain), 'true' => __('Yes', ud_get_wp_property()->domain))), 'include' => array('name' => __('Include', ud_get_wp_property()->domain), 'description' => __('The list of attributes to be included. If no attribute checked, all available attributes will be shown.', ud_get_wp_property()->domain), 'type' => 'multi_checkbox', 'options' => $attributes), 'exclude' => array('name' => __('Exclude', ud_get_wp_property()->domain), 'description' => __('The list of attributes which will not be shown.', ud_get_wp_property()->domain), 'type' => 'multi_checkbox', 'options' => $attributes)), 'description' => sprintf(__('Renders %s Attributes List', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property');
     parent::__construct($options);
 }
 /**
  * Add Contextual help item
  *
  * @param type $data
  *
  * @return string
  * @author korotkov@ud
  */
 static function wpp_contextual_help($data)
 {
     $data['Developer'][] = '<h3>' . __('Developer', ud_get_wp_property()->domain) . '</h3>';
     $data['Developer'][] = '<p>' . __('The <b>slug</b> is automatically created from the title and is used in the back-end.  It is also used for template selection, example: floorplan will look for a template called property-floorplan.php in your theme folder, or default to property.php if nothing is found.', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . __('If <b>Searchable</b> is checked then the property will be loaded for search, and available on the property search widget.', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . __('If <b>Location Matters</b> is checked, then an address field will be displayed for the property, and validated against Google Maps API.  Additionally, the property will be displayed on the SuperMap, if the feature is installed.', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . sprintf(__('<b>Hidden Attributes</b> determine which attributes are not applicable to the given %s type, and will be grayed out in the back-end.', ud_get_wp_property()->domain), WPP_F::property_label()) . '</p>';
     $data['Developer'][] = '<p>' . __('<b>Inheritance</b> determines which attributes should be automatically inherited from the parent property', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . __('Property attributes are meant to be short entries that can be searchable, on the back-end attributes will be displayed as single-line input boxes. On the front-end they are displayed using a definitions list.', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . __('Making an attribute as "searchable" will list it as one of the searchable options in the Property Search widget settings.', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . __('Be advised, attributes added via add_filter() function supercede the settings on this page.', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . __('<b>Search Input:</b> Select and input type and enter comma-separated values that you would like to be used in property search, on the front-end.', ud_get_wp_property()->domain) . '</p>';
     $data['Developer'][] = '<p>' . __('<b>Data Entry:</b> Enter comma-separated values that you would like to use on the back-end when editing properties.', ud_get_wp_property()->domain) . '</p>';
     return $data;
 }
<?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;
示例#6
0
        echo $meta_title;
        ?>
</h2>
          <p><?php 
        echo do_shortcode(html_entity_decode($post->{$meta_slug}));
        ?>
</p>
        <?php 
    }
    ?>
        <?php 
}
?>

        <?php 
if (WPP_F::get_coordinates()) {
    ?>
          <div id="property_map" class="<?php 
    wpp_css('property::property_map');
    ?>
" style="width:100%; height:450px"></div>
        <?php 
}
?>

        <?php 
if ($post->post_parent) {
    ?>
          <a href="<?php 
    echo $post->parent_link;
    ?>
 * Settings passed via shortcode:
 * $properties: either array of properties or false
 * $show_children: default true
 * $thumbnail_size: slug of thumbnail to use for overview page
 * $thumbnail_sizes: array of image dimensions for the thumbnail_size type
 * $fancybox_preview: default loaded from configuration
 * $child_properties_title: default "Floor plans at location:"
 *
 *
 *
 * @version 1.4
 * @author Andy Potanin <*****@*****.**>
 * @package WP-Property
*/
if (have_properties()) {
    $thumbnail_dimentions = WPP_F::get_image_dimensions($wpp_query['thumbnail_size']);
    ?>
 <div class="<?php 
    wpp_css('property_overview::row_view', "wpp_row_view wpp_property_view_result");
    ?>
">
  <div class="<?php 
    wpp_css('property_overview::all_properties', "all-properties");
    ?>
">
  <?php 
    foreach (returned_properties('load_gallery=false') as $property) {
        ?>

    <div class="<?php 
        wpp_css('property_overview::property_div', "property_div {$property['post_type']} clearfix");
示例#8
0
 /**
  * Handle Bulk Action's request
  *
  */
 public function process_bulk_action()
 {
     try {
         switch ($this->current_action()) {
             case 'untrash':
                 if (empty($_REQUEST['post_ids']) || !is_array($_REQUEST['post_ids'])) {
                     throw new \Exception(sprintf(__('Invalid request: no %s IDs provided.', ud_get_wp_property('domain')), \WPP_F::property_label()));
                 }
                 $post_ids = $_REQUEST['post_ids'];
                 foreach ($post_ids as $post_id) {
                     $post_id = (int) $post_id;
                     wp_untrash_post($post_id);
                 }
                 $this->message = sprintf(__('Selected %s have been successfully restored from Trash.', ud_get_wp_property('domain')), \WPP_F::property_label('plural'));
                 break;
             case 'delete':
                 if (empty($_REQUEST['post_ids']) || !is_array($_REQUEST['post_ids'])) {
                     throw new \Exception(sprintf(__('Invalid request: no %s IDs provided.', ud_get_wp_property('domain')), \WPP_F::property_label()));
                 }
                 $post_ids = $_REQUEST['post_ids'];
                 $trashed = 0;
                 $deleted = 0;
                 foreach ($post_ids as $post_id) {
                     $post_id = (int) $post_id;
                     if (get_post_status($post_id) == 'trash') {
                         $deleted++;
                         wp_delete_post($post_id);
                     } else {
                         $trashed++;
                         wp_trash_post($post_id);
                     }
                 }
                 if ($trashed > 0 && $deleted > 0) {
                     $this->message = sprintf(__('Selected %s have been successfully moved to Trash or deleted.', ud_get_wp_property('domain')), \WPP_F::property_label('plural'));
                 } elseif ($trashed > 0) {
                     $this->message = sprintf(__('Selected %s have been successfully moved to Trash.', ud_get_wp_property('domain')), \WPP_F::property_label('plural'));
                 } elseif ($deleted > 0) {
                     $this->message = sprintf(__('Selected %s have been successfully deleted.', ud_get_wp_property('domain')), \WPP_F::property_label('plural'));
                 } else {
                     throw new \Exception(sprintf(__('No one %s was deleted.', ud_get_wp_property('domain')), \WPP_F::property_label()));
                 }
                 break;
             default:
                 //** Any custom action can be processed using action hook */
                 do_action('wpp::all_properties::process_bulk_action', $this->current_action());
                 break;
         }
     } catch (\Exception $e) {
         $this->error = $e->getMessage();
     }
 }
            ?>
">

            <?php 
            foreach ($stats as $stat) {
                if (empty($property[$stat])) {
                    continue;
                }
                ?>
              <li class="<?php 
                echo $stat;
                ?>
">
                <dl>
                  <dt><?php 
                echo empty($wp_properties['property_stats'][$stat]) ? array_key_exists($stat, $label_matches) ? $label_matches[$stat] : WPP_F::de_slug($stat) : $wp_properties['property_stats'][$stat];
                ?>
:</dt>
                  <dd><?php 
                echo $property[$stat];
                ?>
</dd>
                </dl>
              </li>
            <?php 
            }
            ?>
          </ul>
        <?php 
        }
        ?>
 /**
  * Init
  */
 public function __construct()
 {
     parent::__construct('wpp_property_stats', $name = sprintf(__('%1s Attributes', ud_get_wp_property()->domain), \WPP_F::property_label()), array('description' => __('Widget for Single Property page that renders property attributes table.', ud_get_wp_property()->domain)));
 }
 /**
  * Init
  */
 public function __construct()
 {
     $options = array('id' => 'featured_properties', 'params' => array('property_type' => array('name' => sprintf(__('%s Type', ud_get_wp_property()->domain), \WPP_F::property_label()), 'description' => sprintf(__('%s Type', ud_get_wp_property()->domain), \WPP_F::property_label()), 'type' => 'text', 'default' => 'all'), 'type' => array('name' => __('Type', ud_get_wp_property()->domain), 'description' => __('Type', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'class' => array('name' => __('Class', ud_get_wp_property()->domain), 'description' => __('CSS Class', ud_get_wp_property()->domain), 'type' => 'text', 'default' => 'shortcode_featured_properties'), 'per_page' => array('name' => __('Per Page', ud_get_wp_property()->domain), 'description' => __('Items per page', ud_get_wp_property()->domain), 'type' => 'number', 'default' => 6), 'sorter_type' => array('name' => __('Sorter Type', ud_get_wp_property()->domain), 'description' => __('Sorter Type', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('none' => __('None', ud_get_wp_property()->domain), 'buttons' => __('Buttons', ud_get_wp_property()->domain), 'dropdown' => __('Dropdown', ud_get_wp_property()->domain)), 'default' => 'none'), 'show_children' => array('name' => __('Show Children', ud_get_wp_property()->domain), 'description' => __('Show children or not.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'hide_count' => array('name' => __('Hide Count', ud_get_wp_property()->domain), 'description' => __('Hide Count', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'true'), 'fancybox_preview' => array('name' => __('Fancybox Preview', ud_get_wp_property()->domain), 'description' => __('Use fancybox preview.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'bottom_pagination_flag' => array('name' => __('Bottom Pagination', ud_get_wp_property()->domain), 'description' => __('Bottom Pagination.', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false'), 'pagination' => array('name' => __('Pagination', ud_get_wp_property()->domain), 'description' => __('Pagination', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('On', ud_get_wp_property()->domain), 'off' => __('Off', ud_get_wp_property()->domain)), 'default' => 'off'), 'stats' => array('name' => __('Stats', ud_get_wp_property()->domain), 'description' => __('CSV stats', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'thumbnail_size' => array('name' => __('Thumbnail Size', ud_get_wp_property()->domain), 'description' => __('Thumbnail Size.', ud_get_wp_property()->domain), 'type' => 'text', 'default' => 'thumbnail')), 'description' => sprintf(__('Renders Featured %s', ud_get_wp_property()->domain), \WPP_F::property_label('plural')), 'group' => 'WP-Property');
     parent::__construct($options);
 }
示例#12
0
 /**
  * Return RWMB Field for Property Type
  *
  */
 public function get_property_type_field($post)
 {
     $types = ud_get_wp_property('property_types', array());
     if (empty($types)) {
         return false;
     }
     if (count($types) > 1) {
         $types = array_merge(array('' => __('No Selected', ud_get_wp_property()->domain)), $types);
         $field = array('id' => 'property_type', 'name' => sprintf(__('%s Type', ud_get_wp_property()->domain), \WPP_F::property_label()), 'type' => 'select', 'options' => $types);
     } else {
         $field = array('id' => 'property_type', 'type' => 'hidden', 'std' => key($types));
     }
     return $field;
 }
<?php

/**
 * Settings 'Developer' Tab
 * Section 'Attributes'
 */
global $wp_properties;
?>
<div>
  <h3 style="float:left;"><?php 
printf(__('%1s Attributes', ud_get_wp_property()->domain), WPP_F::property_label());
?>
</h3>
  <div class="wpp_property_stat_functions">
    <input type="button" class="wpp_all_advanced_settings button-secondary" action="expand" value="<?php 
_e('Expand all', ud_get_wp_property()->domain);
?>
" />
    <input type="button" class="wpp_all_advanced_settings button-secondary" action="collapse" value="<?php 
_e('Collapse all', ud_get_wp_property()->domain);
?>
" />
    <input type="button" class="sort_stats_by_groups button-secondary" value="<?php 
_e('Sort by Groups', ud_get_wp_property()->domain);
?>
"/>
  </div>
  <div class="clear"></div>
</div>

<table id="wpp_inquiry_attribute_fields" class="wpp_inquiry_attribute_fields ud_ui_dynamic_table widefat" allow_random_slug="true">
<?php

/**
 * Settings 'Developer' Tab
 * Section 'Meta'
 */
global $wp_properties;
?>
<h3><?php 
printf(__('%1s Meta', ud_get_wp_property()->domain), WPP_F::property_label());
?>
</h3>
<p><?php 
_e('Meta is used for descriptions,  on the back-end  meta fields will be displayed as textareas.  On the front-end they will be displayed as individual sections.', ud_get_wp_property()->domain);
?>
</p>
<p><i><?php 
_e('<b>Note!</b> Meta is deprecated from WP-Property 2.0. You can continue using it, however we recommend you to use Attribute with Data Entry \'Textarea\' or \'Text Editor\' instead of new meta fields.', ud_get_wp_property()->domain);
?>
</i></p>

<table id="wpp_inquiry_meta_fields" class="ud_ui_dynamic_table widefat">
  <thead>
  <tr>
    <th class='wpp_draggable_handle'>&nbsp;</th>
    <th class='wpp_attribute_name_col'><?php 
_e('Attribute Name', ud_get_wp_property()->domain);
?>
</th>
    <th class='wpp_attribute_slug_col'><?php 
_e('Attribute Slug', ud_get_wp_property()->domain);
示例#15
0
 /**
  * Creates new property based on existing one (clones).
  *
  * @param $args
  * @return array
  * @throws \Exception
  */
 public function action_wpp_clone_property($args)
 {
     if (empty($args['post_id']) || !is_numeric($args['post_id'])) {
         throw new \Exception(__('Invalid Post ID', ud_get_wp_property('domain')));
     }
     if (get_post_type($args['post_id']) !== 'property') {
         throw new \Exception(sprintf(__('Invalid Post ID. It does not belong to %s.', ud_get_wp_property('domain')), \WPP_F::property_label()));
     }
     $post = get_post($args['post_id'], ARRAY_A);
     /* Clone Property */
     $postmap = array('post_title', 'post_content', 'post_excerpt', 'ping_status', 'comment_status', 'post_type', 'post_status', 'comment_status', 'post_parent');
     $_post = array();
     foreach ($post as $k => $v) {
         if (in_array($k, $postmap)) {
             switch ($k) {
                 case 'post_title':
                     $v .= ' (' . __('Clone', ud_get_wp_property('domain')) . ')';
                 default:
                     $_post[$k] = $v;
                     break;
             }
         }
     }
     $post_id = wp_insert_post($_post);
     /* Clone Property Attributes and Meta */
     if (is_wp_error($post_id) || !$post_id) {
         throw new \Exception(__('Could not create new Post.', ud_get_wp_property('domain')));
     }
     $meta = array_unique(array_merge(array('property_type'), array_keys(ud_get_wp_property('property_stats', array())), array_keys(ud_get_wp_property('property_meta', array()))));
     foreach ($meta as $key) {
         $v = get_post_meta($post['ID'], $key, true);
         add_post_meta($post_id, $key, $v);
     }
     /* Probably add custom actions ( e.g. by Add-on ) */
     do_action('wpp::clone_property::action', $post, $post_id);
     return array('post_id' => $post_id, 'redirect' => admin_url('post.php?post=' . $post_id . '&action=edit'));
 }
            wpp_css('property_overview::button', 'button wpp_edit');
            ?>
" href="<?php 
            echo class_wpp_feps::get_edit_feps_permalink($property['ID'], 'edit');
            ?>
"><?php 
            _e('Edit', ud_get_wp_property()->domain);
            ?>
</a>
              </li>
              <li>
                <a class="<?php 
            wpp_css('property_overview::button', 'button');
            ?>
" href="<?php 
            echo WPP_F::base_url(FEPS_VIEW_PAGE, array('feps' => $property['ID'], 'hash' => $property['wpp::feps::pending_hash'], 'action' => 'remove'));
            ?>
" onclick="return confirm('<?php 
            _e('Are you sure?', ud_get_wp_property()->domain);
            ?>
')"><?php 
            _e('Remove', ud_get_wp_property()->domain);
            ?>
</a>
              </li>
            </ul>
          </li>
          <?php 
        }
        ?>
        </ul>
示例#17
0
 /**
  * It returns specific classes for element.
  * This function is just wrapper.
  * See: WPP_F::get_css_classes();
  *
  * @param type $element [required] It's used for determine which classes should be filtered.
  * It can be set of template and element: "{template}::{element}"
  * @param array $classes [optional] Set of classes
  * @param boolean $return [optional] If false, prints classes. If true returns array of classes
  * @param array $args [optional] Any set of additional arguments which can be needed.
  *
  * @return array|echo
  * @author peshkov@UD
  * @version 0.1
  */
 function wpp_css($element, $classes = false, $return = false, $args = array())
 {
     $args = array_merge((array) $args, array('instance' => 'wpp', 'element' => $element, 'classes' => $classes, 'return' => $return));
     if (is_callable(array('WPP_F', 'get_css_classes'))) {
         return WPP_F::get_css_classes($args);
     }
     return false;
 }
示例#18
0
 /**
  * Init
  */
 public function __construct()
 {
     $options = array('id' => 'property_search', 'params' => array('searchable_attributes' => array('name' => __('Searchable Attributes', ud_get_wp_property()->domain), 'description' => __('CSV attributes list', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'searchable_property_types' => array('name' => sprintf(__('Searchable %s Types', ud_get_wp_property()->domain), \WPP_F::property_label()), 'description' => __('CSV types list', ud_get_wp_property()->domain), 'type' => 'text', 'default' => ''), 'pagination' => array('name' => __('Pagination', ud_get_wp_property()->domain), 'description' => __('Use pagination?', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('Yes', ud_get_wp_property()->domain), 'off' => __('No', ud_get_wp_property()->domain)), 'default' => 'on'), 'group_attributes' => array('name' => __('Group Attributes', ud_get_wp_property()->domain), 'description' => __('Group Attributes?', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('on' => __('Yes', ud_get_wp_property()->domain), 'off' => __('No', ud_get_wp_property()->domain)), 'default' => 'off'), 'per_page' => array('name' => __('Per Page', ud_get_wp_property()->domain), 'description' => __('Items per page', ud_get_wp_property()->domain), 'type' => 'number', 'min' => 1, 'default' => 10), 'strict_search' => array('name' => __('Strict Search', ud_get_wp_property()->domain), 'description' => __('Use strict search', ud_get_wp_property()->domain), 'type' => 'select', 'options' => array('true' => __('Yes', ud_get_wp_property()->domain), 'false' => __('No', ud_get_wp_property()->domain)), 'default' => 'false')), 'description' => sprintf(__('Renders %s Search form', ud_get_wp_property()->domain), \WPP_F::property_label()), 'group' => 'WP-Property');
     parent::__construct($options);
 }
 /**
  * @param string $atts
  * @return string|void
  */
 public function call($atts = "")
 {
     global $post, $wp_query;
     $r = '';
     $atts = wp_parse_args($atts, array('type' => NULL, 'orderby' => NULL, 'groupby' => NULL, 'order' => NULL, 'post_id' => false, 'before_list' => '', 'after_list' => '', 'opening' => '<ul class="attachment-list wpp_attachment_list">', 'closing' => '</ul>', 'before_item' => '<li>', 'after_item' => '</li>', 'show_descriptions' => true, 'include_icon_classes' => true, 'showsize' => false));
     if (isset($atts['post_id']) && is_numeric($atts['post_id'])) {
         $post = get_post($atts['post_id']);
     }
     if (!$post) {
         return;
     }
     if (!empty($atts['type'])) {
         $types = explode(',', str_replace(' ', '', $atts['type']));
     } else {
         $types = array();
     }
     $showsize = $atts['showsize'] == true || $atts['showsize'] == 'true' || $atts['showsize'] == 1 ? true : false;
     $upload_dir = wp_upload_dir();
     $op = clone $post;
     $oq = clone $wp_query;
     foreach (array('before_list', 'after_list', 'opening', 'closing', 'before_item', 'after_item') as $htmlItem) {
         $atts[$htmlItem] = str_replace(array('&lt;', '&gt;', '&quot;'), array('<', '>', '"'), $atts[$htmlItem]);
     }
     $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID);
     if (!empty($atts['orderby'])) {
         $args['orderby'] = $atts['orderby'];
     }
     if (!empty($atts['order'])) {
         $atts['order'] = in_array($atts['order'], array('a', 'asc', 'ascending')) ? 'asc' : 'desc';
         $args['order'] = $atts['order'];
     }
     if (!empty($atts['groupby'])) {
         $args['orderby'] = $atts['groupby'];
     }
     $attachments = get_posts($args);
     if ($attachments) {
         $grouper = $atts['groupby'];
         $test = $attachments;
         $test = array_shift($test);
         if (!property_exists($test, $grouper)) {
             $grouper = 'post_' . $grouper;
         }
         $attlist = array();
         foreach ($attachments as $att) {
             $key = !empty($atts['groupby']) ? $att->{$grouper} : $att->ID;
             $key .= !empty($atts['orderby']) ? $att->{$atts}['orderby'] : '';
             $attlink = wp_get_attachment_url($att->ID);
             if (count($types)) {
                 foreach ($types as $t) {
                     if (substr($attlink, 0 - strlen('.' . $t)) == '.' . $t) {
                         $attlist[$key] = clone $att;
                         $attlist[$key]->attlink = $attlink;
                     }
                 }
             } else {
                 $attlist[$key] = clone $att;
                 $attlist[$key]->attlink = $attlink;
             }
         }
         if ($atts['groupby']) {
             if ($atts['order'] == 'asc') {
                 ksort($attlist);
             } else {
                 krsort($attlist);
             }
         }
     }
     if (count($attlist)) {
         $open = false;
         $r = $atts['before_list'] . $atts['opening'];
         foreach ($attlist as $att) {
             $container_classes = array('attachment_container');
             //** Determine class to display for this file type */
             if ($atts['include_icon_classes']) {
                 switch ($att->post_mime_type) {
                     case 'application/zip':
                         $class = 'zip';
                         break;
                     case 'vnd.ms-excel':
                         $class = 'excel';
                         break;
                     case 'image/jpeg':
                     case 'image/png':
                     case 'image/gif':
                     case 'image/bmp':
                         $class = 'image';
                         break;
                     default:
                         $class = 'default';
                         break;
                 }
             }
             $icon_class = $class ? 'wpp_attachment_icon file-' . $class : false;
             //** Determine if description shuold be displayed, and if it is not empty */
             $echo_description = $atts['show_descriptions'] && !empty($att->post_content) ? ' <span class="attachment_description"> ' . $att->post_content . ' </span> ' : false;
             $echo_title = $att->post_excerpt ? $att->post_excerpt : __('View ', ud_get_wp_property()->domain) . apply_filters('the_title_attribute', $att->post_title);
             if ($icon_class) {
                 $container_classes[] = 'has_icon';
             }
             if (!empty($echo_description)) {
                 $container_classes[] = 'has_description';
             }
             //** Add conditional classes if class is not already passed into container */
             if (!strpos($atts['before_item'], 'class')) {
                 $this_before_item = str_replace('>', ' class="' . implode(' ', $container_classes) . '">', $atts['before_item']);
             }
             $echo_size = $showsize ? ' <span class="attachment-size">' . WPP_F::get_filesize(str_replace($upload_dir['baseurl'], $upload_dir['basedir'], $attlink)) . '</span>' : '';
             if (!isset($current_group)) {
                 $current_group = false;
             }
             if (!empty($atts['groupby']) && $current_group != $att->{$grouper}) {
                 if ($open) {
                     $r .= $atts['closing'] . $atts['after_item'];
                     $open = false;
                 }
                 $r .= $atts['before_item'] . '<h3>' . $att->{$grouper} . '</h3>' . $atts['opening'];
                 $open = true;
                 $current_group = $att->{$grouper};
             }
             $attlink = $att->attlink;
             $r .= $this_before_item . '<a href="' . $attlink . '" title="' . $echo_title . '" class="wpp_attachment ' . $icon_class . '">' . apply_filters('the_title', $att->post_title) . '</a>' . $echo_size . $echo_description . $atts['after_item'];
         }
         if ($open) {
             $r .= $atts['closing'] . $atts['after_item'];
         }
         $r .= $atts['closing'] . $atts['after_list'];
     }
     $wp_query = clone $oq;
     $post = clone $op;
     return $r;
 }
示例#20
0
/**
 * Display latitude and longitude on listing edit page below address field
 *
 * Echos html content to be displayed after location attribute on property edit page
 *
 * @since 1.0
 * @uses WPP_F::get_coordinates() Creates an array from string $args.
 *
 * @param string $listing_id Listing ID must be passed
 */
function wpp_show_coords($listing_id = false)
{
    if (!$listing_id) {
        return;
    }
    // If latitude and logitude meta isn't set, returns false
    $coords = WPP_F::get_coordinates($listing_id);
    echo "<span class='description'>";
    if ($coords) {
        _e("Address was validated by Google Maps.", ud_get_wp_property()->domain);
    } else {
        _e("Address has not yet been validated, should be formatted as: street, city, state, postal code, country. Locations are validated through Google Maps.", ud_get_wp_property()->domain);
    }
    echo "</span>";
}
示例#21
0
 /**
  * Exports all properties to CSV file
  */
 public function maybe_export_properties_to_scv()
 {
     if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpp_export_to_scv' && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'export_properties_to_scv')) {
         // output headers so that the file is downloaded rather than displayed
         header('Content-Type: text/csv; charset=utf-8');
         header('Content-Disposition: attachment; filename=properties.csv');
         $headings = array('ID' => __('ID', ud_get_wp_property('domain')), 'post_title' => __('Title', ud_get_wp_property('domain')), 'post_content' => __('Content', ud_get_wp_property('domain')), 'post_date' => __('Date', ud_get_wp_property('domain')), 'post_modified' => __('Modified Date', ud_get_wp_property('domain')), 'post_parent' => __('Falls Under', ud_get_wp_property('domain')), 'menu_order' => __('Menu Order', ud_get_wp_property('domain')), 'post_author' => __('Author', ud_get_wp_property('domain')), 'property_type_label' => __('Property Type', ud_get_wp_property('domain')));
         $headings = array_merge($headings, (array) ud_get_wp_property('property_stats', array()));
         $headings = array_merge($headings, (array) ud_get_wp_property('property_meta', array()));
         foreach ((array) ud_get_wp_property('geo_type_attributes', array()) as $k) {
             $headings[$k] = \WPP_F::de_slug($k);
         }
         $headings['latitude'] = __('Latitude', ud_get_wp_property('domain'));
         $headings['longitude'] = __('Longitude', ud_get_wp_property('domain'));
         $headings['permalink'] = __('Permalink', ud_get_wp_property('domain'));
         // create a file pointer connected to the output stream
         $output = fopen('php://output', 'w');
         // output the column headings
         fputcsv($output, array_values($headings));
         $ids = \WPP_F::get_properties();
         $keys = array_keys($headings);
         foreach ($ids as $id) {
             $property = Property_Factory::get($id, array('get_children' => 'false', 'load_gallery' => 'false', 'load_thumbnail' => 'true', 'load_parent' => 'false'));
             $data = array();
             foreach ($keys as $k) {
                 $v = isset($property[$k]) ? $property[$k] : '';
                 if (is_array($v)) {
                     $v = implode(',', $v);
                 }
                 switch ($k) {
                     case 'post_content':
                         $v = strip_shortcodes($v);
                         $v = apply_filters('the_content', $v);
                         $v = str_replace(']]>', ']]&gt;', $v);
                         $v = wp_trim_words($v, 55, '...');
                         break;
                     case 'author':
                         $v = get_the_author_meta('display_name', $v);
                         break;
                 }
                 $data[$k] = $v;
             }
             fputcsv($output, $data);
         }
         exit;
     }
 }
?>
"/>
  <a target="_blank" class="button" href="<?php 
echo $export_url;
?>
"><?php 
_e('Open', ud_get_wp_property()->domain);
?>
</a>
  <br/><br/>
  <?php 
_e('You may append the export URL with the following arguments:', ud_get_wp_property()->domain);
?>
  <ul style="margin: 15px 0 0 10px">
    <li><b>limit</b> - number</li>
    <li><b>per_page</b> - number</li>
    <li><b>starting_row</b> - number</li>
    <li><b>sort_order</b> - number</li>
    <li><b>sort_by</b> - number</li>
    <li><b>property_type</b> - string - <?php 
printf(__('Slug for the %s type.', ud_get_wp_property()->domain), \WPP_F::property_label());
?>
</li>
    <li><b>format</b> - string - "xml" <?php 
_e('or', ud_get_wp_property()->domain);
?>
 "json"</li>
  </ul>
  </li>
  </ul>
</div>
    echo isset($wp_properties['configuration']['default_image']['types'][$property_slug]['url']) ? $wp_properties['configuration']['default_image']['types'][$property_slug]['url'] : '';
    ?>
">
          <input type="hidden" name="wpp_settings[configuration][default_image][types][<?php 
    echo $property_slug;
    ?>
][id]" class="input-image-id" value="<?php 
    echo isset($wp_properties['configuration']['default_image']['types'][$property_slug]['id']) ? $wp_properties['configuration']['default_image']['types'][$property_slug]['id'] : '';
    ?>
">
          <div class="image-actions">
            <input type="button" class="button-secondary button-setup-image" value="<?php 
    _e('Setup Image', ud_get_wp_property('domain'));
    ?>
" title="<?php 
    printf(__('If %1$s has no any image, the default one based on %1$s Type will be shown.', ud_get_wp_property('domain')), \WPP_F::property_label());
    ?>
">
          </div>
          <div class="image-wrapper"></div>
        </div>
      </td>

      <td>
        <ul>
          <li>
            <label for="<?php 
    echo $property_slug;
    ?>
_searchable_property_types">
              <input class="slug" id="<?php 
 /**
  * Returns the list of property statuses.
  *
  * @return array
  */
 public function get_post_statuses()
 {
     $all = 0;
     $_attrs = \WPP_F::get_all_attribute_values('post_status');
     $attrs = array();
     if (is_array($_attrs)) {
         foreach ($_attrs as $attr) {
             $count = \WPP_F::get_properties_quantity(array($attr));
             switch ($attr) {
                 case 'publish':
                     $label = __('Published', $this->get('domain'));
                     $all += $count;
                     break;
                 case 'pending':
                     $label = __('Pending', $this->get('domain'));
                     $all += $count;
                     break;
                 case 'trash':
                     $label = __('Trashed', $this->get('domain'));
                     break;
                 case 'auto-draft':
                     $label = __('Auto-Draft', $this->get('domain'));
                     break;
                 default:
                     $label = strtoupper(substr($attr, 0, 1)) . substr($attr, 1, strlen($attr));
                     $all += $count;
             }
             $attrs[$attr] = $label . ' (' . \WPP_F::format_numeric($count) . ')';
         }
     } else {
         return array();
     }
     $attrs['any'] = __('Any', $this->get('domain')) . ' (' . \WPP_F::format_numeric($all) . ')';
     ksort($attrs);
     return $attrs;
 }
示例#25
0
<?php

/**
 * Javascript Localization
 *
 * @version 0.1
 * @since 1.37.3.2
 * @author peshkov@UD
 * @package WP-Property
 */
$l10n = array('clone_property' => sprintf(__('Clone %s', ud_get_wp_property()->domain), WPP_F::property_label()), 'delete' => __('Delete', ud_get_wp_property()->domain), 'show' => __('Show', ud_get_wp_property()->domain), 'hide' => __('Hide', ud_get_wp_property()->domain), 'featured' => __('Featured', ud_get_wp_property()->domain), 'add_to_featured' => __('Add to Featured', ud_get_wp_property()->domain), 'undefined_error' => __('Undefined Error.', ud_get_wp_property()->domain), 'set_property_type_confirmation' => sprintf(__('You are about to set ALL your %s to the selected %s type. Are you sure?', ud_get_wp_property()->domain), WPP_F::property_label('plural'), WPP_F::property_label()), 'processing' => __('Processing...', ud_get_wp_property()->domain), 'geo_attribute_usage' => __('Attention! This attribute (slug) is used by Google Validator and Address Display functionality. It is set automatically and can not be edited on Property Adding/Updating page.', ud_get_wp_property()->domain), 'uploading' => __('Uploading', ud_get_wp_property()->domain), 'drop_file' => __('Drop files here to upload', ud_get_wp_property()->domain), 'upload_images' => __('Upload Image', ud_get_wp_property()->domain), 'cancel' => __('Cancel', ud_get_wp_property()->domain), 'fail' => __('Failed', ud_get_wp_property()->domain), 'dtables' => array('first' => __('First', ud_get_wp_property()->domain), 'previous' => __('Previous', ud_get_wp_property()->domain), 'next' => __('Next', ud_get_wp_property()->domain), 'last' => __('Last', ud_get_wp_property()->domain), 'processing' => __('Processing...', ud_get_wp_property()->domain), 'show_menu_entries' => sprintf(__('Show %s entries', ud_get_wp_property()->domain), '_MENU_'), 'no_m_records_found' => __('No matching records found', ud_get_wp_property()->domain), 'no_data_available' => __('No data available in table', ud_get_wp_property()->domain), 'loading' => __('Loading...', ud_get_wp_property()->domain), 'showing_entries' => sprintf(__('Showing %s to %s of %s entries', ud_get_wp_property()->domain), '_START_', '_END_', '_TOTAL_'), 'showing_entries_null' => sprintf(__('Showing % to % of % entries', ud_get_wp_property()->domain), '0', '0', '0'), 'filtered_from_total' => sprintf(__('(filtered from %s total entries)', ud_get_wp_property()->domain), '_MAX_'), 'search' => __('Search:', ud_get_wp_property()->domain), 'display' => __('Display:', ud_get_wp_property()->domain), 'records' => __('records', ud_get_wp_property()->domain), 'all' => __('All', ud_get_wp_property()->domain)), 'feps' => array('unnamed_form' => __('Unnamed Form', ud_get_wp_property()->domain), 'form_could_not_be_removed_1' => __('Form could not be removed because of some server error.', ud_get_wp_property()->domain), 'form_could_not_be_removed_2' => __('Form could not be removed because form ID is undefined.', ud_get_wp_property()->domain)), 'fbtabs' => array('unnamed_canvas' => __('Unnamed Canvas', ud_get_wp_property()->domain)));
示例#26
0
    ?>
_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>

示例#27
0
 /**
  * Constructor
  * Sets default data.
  *
  *
  * @todo For the love of god, only apply the defaults on installation. - potanin@UD
  * @param bool $args
  */
 public function __construct($args = false)
 {
     global $wp_properties;
     //** STEP 1. Default */
     parent::__construct($args);
     //** STEP 2. */
     $data = array();
     //** This slug will be used to display properties on the front-end.  Most likely overwriten by get_option('wpp_settings'); */
     $data['configuration'] = array('autoload_css' => 'true', 'automatically_insert_overview' => 'true', 'base_slug' => 'property', 'currency_symbol' => '$', 'address_attribute' => 'location', 'google_maps_localization' => 'en', 'display_address_format' => '[city], [state]');
     //** Default setings for [property_overview] shortcode */
     $data['configuration']['property_overview'] = array('thumbnail_size' => 'tiny_thumb', 'fancybox_preview' => 'true', 'display_slideshow' => 'false', 'show_children' => 'true');
     $data['configuration']['single_property_view'] = array('map_image_type' => 'tiny_thumb', 'gm_zoom_level' => '13');
     //** Default setings for admin UI */
     $data['configuration']['admin_ui'] = array('overview_table_thumbnail_size' => 'tiny_thumb');
     $data['default_coords']['latitude'] = '57.7973333';
     $data['default_coords']['longitude'] = '12.0502107';
     //** Geo type attributes are predefined and should not be editable on property adding/updating */
     // @notice All these fields are automatically added as post_meta on revalidation.
     $data['geo_type_attributes'] = array('formatted_address', 'street_number', 'route', 'district', 'city', 'county', 'state', 'state_code', 'country', 'country_code', 'postal_code');
     //** Image URLs. */
     $data['images']['map_icon_shadow'] = WPP_URL . "images/map_icon_shadow.png";
     $data['configuration']['google_maps']['infobox_settings'] = array('show_direction_link' => true, 'show_property_title' => true);
     //** Default attribute label descriptions for the back-end */
     $data['descriptions'] = array('descriptions' => array('property_type' => sprintf(__('The %s type will determine the layout.', ud_get_wp_property()->domain), \WPP_F::property_label()), 'custom_attribute_overview' => __('Customize what appears in search results in the attribute section.  For example: 1bed, 2baths, area varies slightly.', ud_get_wp_property()->domain), 'tagline' => __('Will appear on overview pages and on top of every listing page.', ud_get_wp_property()->domain)));
     $_stored_settings = $this->get();
     //** Merge with default data. */
     $this->set(\UsabilityDynamics\Utility::extend($data, $this->get()));
     // Check if settings have or have been upated. (we determine if configuration is good)
     // @todo Add a better _version_ check.
     if (isset($_stored_settings['_updated']) && isset($_stored_settings['version']) && $_stored_settings['version'] === '2.0.0') {
         return $wp_properties = $this->get();
     }
     // Continue on to load/enforce defaults.
     //** STEP 3. */
     //** Setup default property types to be used. */
     $d = $this->get('property_types', false);
     // Should only be set on install, not added on every request. These literally can not be removed from settings... -potanin@UD
     // It is adding these defaults only if types are empty (install) - korotkov@UD
     if (empty($d) || !is_array($d)) {
         $this->set('property_types', array('building' => __('Building', ud_get_wp_property()->domain), 'floorplan' => __('Floorplan', ud_get_wp_property()->domain), 'single_family_home' => __('Single Family Home', ud_get_wp_property()->domain)));
     }
     //** Setup property types to be used. */
     $d = !$this->get('property_inheritance', false);
     if (!$d || !is_array($d)) {
         $this->set('property_inheritance', array('floorplan' => array('street_number', 'route', 'state', 'postal_code', 'location', 'display_address', 'address_is_formatted')));
     }
     //** Property stats. Can be searchable, displayed as input boxes on editing page. */
     $d = $this->get('property_stats', false);
     if (!$d || !is_array($d)) {
         $this->set('property_stats', array('location' => __('Address', ud_get_wp_property()->domain), 'price' => __('Price', ud_get_wp_property()->domain), 'deposit' => __('Deposit', ud_get_wp_property()->domain), 'area' => __('Area', ud_get_wp_property()->domain), 'phone_number' => __('Phone Number', ud_get_wp_property()->domain)));
     }
     //** Property meta.  Typically not searchable, displayed as textarea on editing page. */
     $d = $this->get('property_meta', false);
     if (!$d || !is_array($d)) {
         $this->set('property_meta', array('lease_terms' => __('Lease Terms', ud_get_wp_property()->domain), 'pet_policy' => __('Pet Policy', ud_get_wp_property()->domain), 'school' => __('School', ud_get_wp_property()->domain), 'tagline' => __('Tagline', ud_get_wp_property()->domain)));
     }
     //** On property editing page - determines which fields to hide for a particular property type */
     $d = $this->get('hidden_attributes', false);
     if (!is_array($d)) {
         $this->set('hidden_attributes', array('floorplan' => array('location', 'parking', 'school'), 'building' => array('price', 'bedrooms', 'bathrooms', 'area', 'deposit'), 'single_family_home' => array('deposit', 'lease_terms', 'pet_policy')));
     }
     //** Determines property types that have addresses. */
     $d = $this->get('location_matters', false);
     if (!is_array($d)) {
         $this->set('location_matters', array('building', 'single_family_home'));
     }
     //** Determine which property types should actually be searchable. */
     $d = $this->get('searchable_property_types', false);
     if (!is_array($d)) {
         $this->set('searchable_property_types', array('floorplan', 'single_family_home'));
     }
     //** Attributes to use in searching. */
     $d = $this->get('searchable_attributes', false);
     if (!is_array($d)) {
         $this->set('searchable_attributes', array('area', 'deposit', 'bedrooms', 'bathrooms', 'city', 'price'));
     }
     //** Convert phrases to searchable values.  Converts string stats into numeric values for searching and filtering. */
     $d = $this->get('search_conversions', false);
     if (!is_array($d)) {
         $this->set('search_conversions', array('bedrooms' => array(__('Studio', ud_get_wp_property()->domain) => '0.5')));
     }
     //** Don't load defaults if settings exist in db */
     $d = $this->get('image_sizes', false);
     if (!is_array($d)) {
         $this->set('image_sizes', array('map_thumb' => array('width' => '75', 'height' => '75'), 'tiny_thumb' => array('width' => '100', 'height' => '100'), 'sidebar_wide' => array('width' => '195', 'height' => '130'), 'slideshow' => array('width' => '640', 'height' => '235')));
     }
     $d = $this->get('configuration.google_maps.infobox_attributes', false);
     if (!is_array($d)) {
         $this->set('configuration.google_maps.infobox_attributes', array('bedrooms', 'bathrooms', 'price'));
     }
     //** STEP 4. */
     $wp_properties = $this->get();
 }
 /**
  * @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;
 }
示例#29
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');
 }
 /**
  * Register Meta Box for taxonomies on Edit Property Page
  *
  * @param $meta_boxes
  * @return array
  */
 public function add_meta_box($meta_boxes)
 {
     if (!is_array($meta_boxes)) {
         $meta_boxes = array();
     }
     $type = false;
     if (isset($_REQUEST['post']) && is_numeric($_REQUEST['post'])) {
         $post_id = $_REQUEST['post'];
         $type = get_post_meta($post_id, 'property_type', true);
     }
     $taxonomies = $this->get('config.taxonomies', array());
     $groups = $this->get('config.groups', array());
     $types = $this->get('config.types', array());
     $hidden = array();
     $inherited = array();
     if ($type) {
         $hidden = $this->get('config.hidden.' . $type, array());
         $inherited = $this->get('config.inherited.' . $type, array());
     }
     $fields = array();
     foreach ($taxonomies as $k => $d) {
         $field = array();
         switch (true) {
             // Hidden
             case in_array($k, $hidden):
                 // Ignore field, since it's hidden.
                 break;
             case in_array($k, $inherited):
                 $field = array('name' => $d['label'], 'id' => $k, 'type' => 'wpp_taxonomy_inherited', 'desc' => sprintf(__('The terms are inherited from Parent %s.', $this->get('domain')), \WPP_F::property_label()), 'options' => array('taxonomy' => $k, 'type' => 'inherited', 'args' => array()));
                 break;
             default:
                 /** Do no add taxonomy field if native meta box is being used for it. */
                 if ($d['show_ui']) {
                     break;
                 }
                 $field = array('name' => $d['label'], 'id' => $k, 'type' => 'taxonomy', 'multiple' => isset($types[$k]) && $types[$k] == 'unique' ? false : true, 'options' => array('taxonomy' => $k, 'type' => isset($d['hierarchical']) && $d['hierarchical'] == true ? 'select_tree' : 'select_advanced', 'args' => array()));
                 break;
         }
         if (!empty($field)) {
             $group = !empty($groups[$k]) ? $groups[$k] : '_general';
             $pushed = false;
             foreach ($meta_boxes as $k => $meta_box) {
                 if ($group == $meta_box['id']) {
                     if (!isset($meta_boxes[$k]['fields']) || !is_array($meta_boxes[$k]['fields'])) {
                         $meta_boxes[$k]['fields'] = array();
                     }
                     array_push($meta_boxes[$k]['fields'], $field);
                     $pushed = true;
                     break;
                 }
             }
             if (!$pushed) {
                 array_push($fields, $field);
             }
         }
     }
     /** It may happen only if we could not find related group. */
     if (!empty($fields)) {
         $taxonomy_box = array('id' => '_terms', 'title' => __('Taxonomies', ud_get_wpp_terms()->domain), 'pages' => array('property'), 'context' => 'advanced', 'priority' => 'low', 'fields' => $fields);
         $_meta_boxes = array();
         $added = false;
         foreach ($meta_boxes as $meta_box) {
             /** We want to add Taxonomies under General Meta Box */
             array_push($_meta_boxes, $meta_box);
             if ($meta_box['id'] == '_general') {
                 array_push($_meta_boxes, $taxonomy_box);
                 $added = true;
             }
         }
         /* In case we did not add meta box, we do it at last. */
         if (!$added) {
             array_push($_meta_boxes, $taxonomy_box);
         }
         $meta_boxes = $_meta_boxes;
     }
     return $meta_boxes;
 }