Ejemplo n.º 1
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(']]>', ']]>', $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;
     }
 }
            ?>
">

            <?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 
        }
        ?>
Ejemplo n.º 3
0
    /**
     *
     * Renders back-end property search widget tools.
     *
     * @complexity 8
     * @author potanin@UD
     *
     */
    function form($instance)
    {
        global $wp_properties;
        //** Get widget-specific data */
        $title = isset($instance['title']) ? $instance['title'] : false;
        $searchable_attributes = isset($instance['searchable_attributes']) ? $instance['searchable_attributes'] : false;
        $grouped_searchable_attributes = isset($instance['grouped_searchable_attributes']) ? $instance['grouped_searchable_attributes'] : false;
        $use_pagi = isset($instance['use_pagi']) ? $instance['use_pagi'] : false;
        $per_page = isset($instance['per_page']) ? $instance['per_page'] : false;
        $strict_search = isset($instance['strict_search']) ? $instance['strict_search'] : false;
        $sort_by = isset($instance['sort_by']) ? $instance['sort_by'] : false;
        $sort_order = isset($instance['sort_order']) ? $instance['sort_order'] : false;
        $group_attributes = isset($instance['group_attributes']) ? $instance['group_attributes'] : false;
        $searchable_property_types = isset($instance['searchable_property_types']) ? $instance['searchable_property_types'] : false;
        $property_stats = isset($wp_properties['property_stats']) ? $wp_properties['property_stats'] : array();
        //** Get WPP data */
        $all_searchable_property_types = array_unique($wp_properties['searchable_property_types']);
        $all_searchable_attributes = array_unique($wp_properties['searchable_attributes']);
        $groups = isset($wp_properties['property_groups']) ? $wp_properties['property_groups'] : false;
        $main_stats_group = isset($wp_properties['configuration']['main_stats_group']) ? $wp_properties['configuration']['main_stats_group'] : false;
        $error = array();
        if (!is_array($all_searchable_property_types)) {
            $error['no_searchable_types'] = true;
        }
        if (!is_array($all_searchable_property_types)) {
            $error['no_searchable_attributes'] = true;
        }
        /** Set label for list below only */
        if (!isset($property_stats['property_type'])) {
            $property_stats['property_type'] = sprintf(__('%s Type', ud_get_wp_property()->domain), WPP_F::property_label());
        }
        if (is_array($all_searchable_property_types) && count($all_searchable_property_types) > 1) {
            //** Add property type to the beginning of the attribute list, even though it's not a typical attribute */
            array_unshift($all_searchable_attributes, 'property_type');
        }
        //** Find the difference between selected attributes and all attributes, i.e. unselected attributes */
        if (is_array($searchable_attributes) && is_array($all_searchable_attributes)) {
            $unselected_attributes = array_diff($all_searchable_attributes, $searchable_attributes);
            //* Clean searchable attributes: remove unavailable ones */
            foreach ($searchable_attributes as $k => $v) {
                if (!in_array($v, $all_searchable_attributes)) {
                    //* Don't remove hardcoded attributes (property_type,city) */
                    if ($v != 'property_type' && $v != 'city') {
                        unset($searchable_attributes[$k]);
                    }
                }
            }
            // Build new array beginning with selected attributes, in order, follow by all other attributes
            $ungrouped_searchable_attributes = array_merge($searchable_attributes, $unselected_attributes);
        } else {
            $ungrouped_searchable_attributes = $all_searchable_attributes;
        }
        $ungrouped_searchable_attributes = array_unique($ungrouped_searchable_attributes);
        //* Perpare $all_searchable_attributes for using by sort function */
        $temp_attrs = array();
        foreach ($all_searchable_attributes as $slug) {
            $temp_attrs[$slug] = $slug;
        }
        //* Sort stats by groups */
        $stats_by_groups = sort_stats_by_groups($temp_attrs);
        //** If the search widget cannot be created without some data, we bail */
        if (!empty($error)) {
            echo '<p>' . printf(__('No searchable %s types were found.', ud_get_wp_property()->domain), WPP_F::property_label()) . '</p>';
            return;
        }
        ?>

    <ul data-widget_number="<?php 
        echo $this->number;
        ?>
" data-widget="search_properties_widget"
        class="wpp_widget wpp_property_search_wrapper">

      <li class="<?php 
        echo $this->get_field_id('title');
        ?>
">
        <label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', ud_get_wp_property()->domain);
        ?>
          <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
"
                 name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $title;
        ?>
"/>
        </label>
      </li>

      <li class="wpp_property_types">
        <p><?php 
        printf(__('%s types to search:', ud_get_wp_property()->domain), WPP_F::property_label());
        ?>
</p>
        <ul>
          <?php 
        foreach ($all_searchable_property_types as $property_type) {
            ?>
            <li>
              <label
                  for="<?php 
            echo $this->get_field_id('searchable_property_types');
            ?>
_<?php 
            echo $property_type;
            ?>
">
                <input class="wpp_property_types"
                       id="<?php 
            echo $this->get_field_id('searchable_property_types');
            ?>
_<?php 
            echo $property_type;
            ?>
"
                       name="<?php 
            echo $this->get_field_name('searchable_property_types');
            ?>
[]"
                       type="checkbox" <?php 
            if (empty($searchable_property_types)) {
                echo 'checked="checked"';
            }
            ?>
                       value="<?php 
            echo $property_type;
            ?>
" <?php 
            if (is_array($searchable_property_types) && in_array($property_type, $searchable_property_types)) {
                echo " checked ";
            }
            ?>
 />
                <?php 
            echo !empty($wp_properties['property_types'][$property_type]) ? $wp_properties['property_types'][$property_type] : ucwords($property_type);
            ?>
              </label>
            </li>
          <?php 
        }
        ?>
        </ul>
      </li>

      <li class="wpp_attribute_selection">
        <p><?php 
        _e('Select the attributes you want to search.', ud_get_wp_property()->domain);
        ?>
</p>

        <div class="wpp_search_widget_tab wpp_subtle_tabs ">

          <ul class="wpp_section_tabs  tabs">
            <li><a href="#all_atributes_<?php 
        echo $this->id;
        ?>
"><?php 
        _e('All Attributes', ud_get_wp_property()->domain);
        ?>
</a></li>

            <?php 
        if ($stats_by_groups) {
            ?>
              <li><a href="#grouped_attributes_<?php 
            echo $this->id;
            ?>
"><?php 
            _e('Grouped Attributes', ud_get_wp_property()->domain);
            ?>
</a>
              </li>
            <?php 
        }
        ?>
          </ul>

          <div id="all_atributes_<?php 
        echo $this->id;
        ?>
" class="wp-tab-panel wpp_all_attributes">
            <ul class="wpp_sortable_attributes">
              <?php 
        foreach ($ungrouped_searchable_attributes as $attribute) {
            ?>

                <li class="wpp_attribute_wrapper <?php 
            echo $attribute;
            ?>
">
                  <input id="<?php 
            echo $this->get_field_id('searchable_attributes');
            ?>
_<?php 
            echo $attribute;
            ?>
"
                         name="<?php 
            echo $this->get_field_name('searchable_attributes');
            ?>
[]"
                         type="checkbox" <?php 
            if (empty($searchable_attributes)) {
                echo 'checked="checked"';
            }
            ?>
                         value="<?php 
            echo $attribute;
            ?>
" <?php 
            echo is_array($searchable_attributes) && in_array($attribute, $searchable_attributes) ? " checked " : "";
            ?>
 />
                  <label
                      for="<?php 
            echo $this->get_field_id('searchable_attributes');
            ?>
_<?php 
            echo $attribute;
            ?>
"><?php 
            echo apply_filters('wpp::search_attribute::label', empty($property_stats[$attribute]) ? WPP_F::de_slug($attribute) : $property_stats[$attribute], $attribute);
            ?>
</label>
                </li>
              <?php 
        }
        ?>
            </ul>
          </div><?php 
        /* end all (ungrouped) attribute selection */
        ?>

          <?php 
        if ($stats_by_groups) {
            ?>
            <div id="grouped_attributes_<?php 
            echo $this->id;
            ?>
" class="wpp_grouped_attributes_container wp-tab-panel">

              <?php 
            foreach ($stats_by_groups as $gslug => $gstats) {
                ?>
                <?php 
                if ($main_stats_group != $gslug || !key_exists($gslug, $groups)) {
                    ?>
                  <?php 
                    $group_name = key_exists($gslug, $groups) ? $groups[$gslug]['name'] : "<span style=\"color:#8C8989\">" . __('Ungrouped', ud_get_wp_property()->domain) . "</span>";
                    ?>
                  <h2 class="wpp_stats_group"><?php 
                    echo $group_name;
                    ?>
</h2>
                <?php 
                }
                ?>
                <ul>
                  <?php 
                foreach ($gstats as $attribute) {
                    ?>
                    <li>
                      <input
                          id="<?php 
                    echo $this->get_field_id('grouped_searchable_attributes');
                    ?>
_<?php 
                    echo $attribute;
                    ?>
"
                          name="<?php 
                    echo $this->get_field_name('grouped_searchable_attributes');
                    ?>
[]"
                          type="checkbox" <?php 
                    if (empty($grouped_searchable_attributes)) {
                        echo 'checked="checked"';
                    }
                    ?>
                          value="<?php 
                    echo $attribute;
                    ?>
" <?php 
                    echo is_array($grouped_searchable_attributes) && in_array($attribute, $grouped_searchable_attributes) ? " checked " : "";
                    ?>
 />
                      <label
                          for="<?php 
                    echo $this->get_field_id('grouped_searchable_attributes');
                    ?>
_<?php 
                    echo $attribute;
                    ?>
"><?php 
                    echo apply_filters('wpp::search_attribute::label', empty($property_stats[$attribute]) ? WPP_F::de_slug($attribute) : $property_stats[$attribute], $attribute);
                    ?>
</label>
                    </li>
                  <?php 
                }
                ?>
                </ul>
              <?php 
            }
            /* End cycle through $stats_by_groups */
            ?>
            </div>
          <?php 
        }
        ?>

        </div>

      </li>

      <li>

        <?php 
        if ($stats_by_groups) {
            ?>
        <div>
          <input id="<?php 
            echo $this->get_field_id('group_attributes');
            ?>
" class="wpp_toggle_attribute_grouping"
                 type="checkbox" value="true"
                 name="<?php 
            echo $this->get_field_name('group_attributes');
            ?>
" <?php 
            checked($group_attributes, 'true');
            ?>
 />
          <label
              for="<?php 
            echo $this->get_field_id('group_attributes');
            ?>
"><?php 
            _e('Group attributes together.');
            ?>
</label>
        </div>
      </li>
      <?php 
        }
        ?>

      <li>

        <div class="wpp_something_advanced_wrapper" style="margin-top: 10px;">
          <ul>

            <?php 
        if (!empty($wp_properties['sortable_attributes']) && is_array($wp_properties['sortable_attributes'])) {
            ?>
              <li class="wpp_development_advanced_option">
                <div><label
                      for="<?php 
            echo $this->get_field_id('sort_by');
            ?>
"><?php 
            _e('Default Sort Order', ud_get_wp_property()->domain);
            ?>
</label>
                </div>
                <select id="<?php 
            echo $this->get_field_id('sort_by');
            ?>
"
                        name="<?php 
            echo $this->get_field_name('sort_by');
            ?>
">
                  <option></option>
                  <?php 
            foreach ($wp_properties['sortable_attributes'] as $attribute) {
                ?>
                    <option
                        value="<?php 
                echo esc_attr($attribute);
                ?>
"  <?php 
                selected($sort_by, $attribute);
                ?>
 ><?php 
                echo $property_stats[$attribute];
                ?>
</option>
                  <?php 
            }
            ?>
                </select>

                <select id="<?php 
            echo $this->get_field_id('sort_order');
            ?>
"
                        name="<?php 
            echo $this->get_field_name('sort_order');
            ?>
">
                  <option></option>
                  <option value="DESC"  <?php 
            selected($sort_order, 'DESC');
            ?>
 ><?php 
            _e('Descending', ud_get_wp_property()->domain);
            ?>
</option>
                  <option value="ASC"  <?php 
            selected($sort_order, 'ASC');
            ?>
 ><?php 
            _e('Ascending', ud_get_wp_property()->domain);
            ?>
</option>
                </select>

              </li>
            <?php 
        }
        ?>

            <li class="wpp_development_advanced_option">
              <label for="<?php 
        echo $this->get_field_id('use_pagi');
        ?>
">
                <input id="<?php 
        echo $this->get_field_id('use_pagi');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('use_pagi');
        ?>
" type="checkbox"
                       value="on" <?php 
        if ($use_pagi == 'on') {
            echo " checked='checked';";
        }
        ?>
 />
                <?php 
        _e('Use pagination', ud_get_wp_property()->domain);
        ?>
              </label>
            </li>

            <li class="wpp_development_advanced_option">
              <label for="<?php 
        echo $this->get_field_id('strict_search');
        ?>
">
                <input id="<?php 
        echo $this->get_field_id('strict_search');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('strict_search');
        ?>
" type="checkbox"
                       value="on" <?php 
        if ($strict_search == 'on') {
            echo " checked='checked';";
        }
        ?>
 />
                <?php 
        _e('Strict Search', ud_get_wp_property()->domain);
        ?>
              </label>
            </li>

            <li class="wpp_development_advanced_option">
              <label for="<?php 
        echo $this->get_field_id('per_page');
        ?>
"><?php 
        _e('Items per page', ud_get_wp_property()->domain);
        ?>
                <input style="width:30px" id="<?php 
        echo $this->get_field_id('per_page');
        ?>
"
                       name="<?php 
        echo $this->get_field_name('per_page');
        ?>
" type="text"
                       value="<?php 
        echo $per_page;
        ?>
"/>
              </label>
            </li>

            <li>
              <span class="wpp_show_advanced"><?php 
        _e('Toggle Advanced Search Options', ud_get_wp_property()->domain);
        ?>
</span>
            </li>
          </ul>
        </div>
      </li>
    </ul>
  <?php 
    }
Ejemplo n.º 4
0
    function draw_property_search_form($args = false)
    {
        global $wp_properties;
        WPP_F::force_script_inclusion('wpp-jquery-number-format');
        $args = wp_parse_args($args, array('search_attributes' => false, 'searchable_property_types' => false, 'use_pagination' => 'on', 'per_page' => '10', 'group_attributes' => false, 'strict_search' => false, 'instance_id' => false, 'sort_order' => false, 'cache' => true));
        if (empty($args['search_attributes']) && isset($args['searchable_attributes'])) {
            $args['search_attributes'] = $args['searchable_attributes'];
        }
        extract($args, EXTR_SKIP);
        $search_values = array();
        $property_type_flag = false;
        //** Bail if no search attributes passed */
        if (!is_array($args['search_attributes'])) {
            return;
        }
        $property_stats = $wp_properties['property_stats'];
        if (!isset($property_stats['property_type'])) {
            $property_stats['property_type'] = sprintf(__('%s Type', ud_get_wp_property()->domain), WPP_F::property_label());
        }
        //** Load search values for attributes (from cache, or generate) */
        if (!empty($search_attributes) && !empty($searchable_property_types)) {
            $search_values = WPP_F::get_search_values($search_attributes, $searchable_property_types, $args['cache'], $args['instance_id']);
        }
        //** This looks clumsy - potanin@UD */
        if (array_key_exists('property_type', array_fill_keys($search_attributes, 1)) && is_array($searchable_property_types) && count($searchable_property_types) > 1) {
            $spt = array_fill_keys($searchable_property_types, 1);
            if (!empty($wp_properties['property_types'])) {
                foreach ($wp_properties['property_types'] as $key => $value) {
                    if (array_key_exists($key, $spt)) {
                        $search_values['property_type'][$key] = $value;
                    }
                }
                if (isset($search_values['property_type']) && count($search_values['property_type']) <= 1) {
                    unset($search_values['property_type']);
                }
            }
        }
        ?>

    <form action="<?php 
        echo WPP_F::base_url($wp_properties['configuration']['base_slug']);
        ?>
" method="post" class="wpp_shortcode_search_form">
      <?php 
        do_action("draw_property_search_form", $args);
        ?>
      <?php 
        if ($sort_order) {
            ?>
        <input type="hidden" name="wpp_search[sort_order]" value="<?php 
            echo $sort_order;
            ?>
"/>
      <?php 
        }
        ?>
      <?php 
        if (!empty($sort_by)) {
            ?>
        <input type="hidden" name="wpp_search[sort_by]" value="<?php 
            echo $sort_by;
            ?>
"/>
      <?php 
        }
        ?>
      <?php 
        if (!empty($use_pagination)) {
            ?>
        <input type="hidden" name="wpp_search[pagination]" value="<?php 
            echo $use_pagination;
            ?>
"/>
      <?php 
        }
        ?>
      <?php 
        if (!empty($per_page)) {
            ?>
        <input type="hidden" name="wpp_search[per_page]" value="<?php 
            echo $per_page;
            ?>
"/>
      <?php 
        }
        ?>
      <?php 
        if (!empty($strict_search)) {
            ?>
        <input type="hidden" name="wpp_search[strict_search]" value="<?php 
            echo $strict_search;
            ?>
"/>
      <?php 
        }
        ?>
      <?php 
        //** If no property_type passed in search_attributes, we get defaults */
        if (is_array($searchable_property_types) && !array_key_exists('property_type', array_fill_keys($search_attributes, 1))) {
            echo '<input type="hidden" name="wpp_search[property_type]" value="' . implode(',', $searchable_property_types) . '" />';
        }
        ?>
      <ul class="wpp_search_elements">
    <?php 
        if (isset($group_attributes) && $group_attributes) {
            //** Get group data */
            $groups = $wp_properties['property_groups'];
            $_search_attributes = array();
            foreach ($search_attributes as $attr) {
                $_search_attributes[$attr] = $attr;
            }
            $search_groups = sort_stats_by_groups($_search_attributes);
            unset($_search_attributes);
        } else {
            //** Create an ad-hoc group */
            $search_groups['ungrouped'] = $search_attributes;
        }
        $main_stats_group = isset($wp_properties['configuration']['main_stats_group']) ? $wp_properties['configuration']['main_stats_group'] : false;
        $count = 0;
        foreach ($search_groups as $this_group => $search_attributes) {
            $count++;
            if ($this_group == 'ungrouped' || $this_group === 0 || $this_group == $main_stats_group) {
                $is_a_group = false;
                $this_group = 'not_a_group';
            } else {
                $is_a_group = true;
            }
            ?>
      <li class="wpp_search_group wpp_group_<?php 
            echo $this_group;
            ?>
">
      <?php 
            if ($is_a_group) {
                ?>
        <span class="wpp_search_group_title wpp_group_<?php 
                echo $this_group;
                ?>
_title"><?php 
                echo $groups[$this_group]['name'];
                ?>
</span>
      <?php 
            } elseif ($group_attributes && $count == count($search_groups)) {
                ?>
        <span class="wpp_search_group_title" style="height:1px;line-height:1px;">&nbsp;</span>
      <?php 
            }
            ?>
        <ul class="wpp_search_group wpp_group_<?php 
            echo $this_group;
            ?>
">
      <?php 
            //** Begin Group Attributes */
            foreach ($search_attributes as $attrib) {
                //** Override search values if they are set in the developer tab */
                if (!empty($wp_properties['predefined_search_values'][$attrib])) {
                    $maybe_search_values = explode(',', $wp_properties['predefined_search_values'][$attrib]);
                    if (is_array($maybe_search_values)) {
                        $using_predefined_values = true;
                        $search_values[$attrib] = $maybe_search_values;
                    } else {
                        $using_predefined_values = true;
                    }
                }
                //** Don't display search attributes that have no values */
                if (!apply_filters('wpp::show_search_field_with_no_values', isset($search_values[$attrib]), $attrib)) {
                    continue;
                }
                $label = apply_filters('wpp::search_attribute::label', empty($property_stats[$attrib]) ? WPP_F::de_slug($attrib) : $property_stats[$attrib], $attrib);
                ?>
        <li class="wpp_search_form_element seach_attribute_<?php 
                echo $attrib;
                ?>
  wpp_search_attribute_type_<?php 
                echo isset($wp_properties['searchable_attr_fields'][$attrib]) ? $wp_properties['searchable_attr_fields'][$attrib] : $attrib;
                ?>
 <?php 
                echo !empty($wp_properties['searchable_attr_fields'][$attrib]) && $wp_properties['searchable_attr_fields'][$attrib] == 'checkbox' ? 'wpp-checkbox-el' : '';
                echo !empty($wp_properties['searchable_attr_fields'][$attrib]) && ($wp_properties['searchable_attr_fields'][$attrib] == 'multi_checkbox' && count($search_values[$attrib]) == 1) || isset($wp_properties['searchable_attr_fields'][$attrib]) && $wp_properties['searchable_attr_fields'][$attrib] == 'checkbox' ? ' single_checkbox' : '';
                ?>
">
          <?php 
                $random_element_id = 'wpp_search_element_' . rand(1000, 9999);
                ?>

          <label for="<?php 
                echo $random_element_id;
                ?>
" class="wpp_search_label wpp_search_label_<?php 
                echo $attrib;
                ?>
"><?php 
                echo $label;
                ?>
<span class="wpp_search_post_label_colon">:</span></label>

          <div class="wpp_search_attribute_wrap">
            <?php 
                $value = isset($_REQUEST['wpp_search'][$attrib]) ? $_REQUEST['wpp_search'][$attrib] : '';
                ob_start();
                wpp_render_search_input(array('attrib' => $attrib, 'random_element_id' => $random_element_id, 'search_values' => $search_values, 'value' => $value));
                $this_field = ob_get_contents();
                ob_end_clean();
                echo apply_filters('wpp_search_form_field_' . $attrib, $this_field, $attrib, $label, $value, isset($wp_properties['searchable_attr_fields'][$attrib]) ? $wp_properties['searchable_attr_fields'][$attrib] : false, $random_element_id);
                ?>
          </div>
          <div class="clear"></div>
          </li>
      <?php 
            }
            //** End Group Attributes */
            ?>
      </ul>
      <div class="clear"></div>
      </li>
    <?php 
        }
        ?>
        <li class="wpp_search_form_element submit"><input type="submit" class="wpp_search_button submit btn btn-large" value="<?php 
        _e('Search', ud_get_wp_property()->domain);
        ?>
"/></li>
    </ul>
    </form>
  <?php 
    }
Ejemplo n.º 5
0
 /**
  * Returns attribute information.
  *
  * Checks $wp_properties and returns a concise array of array-specific settings and attributes
  *
  * @todo Consider putting this into settings action, or somewhere, so it its only ran once, or adding caching
  * @version 1.17.3
  * @param bool $attribute
  * @return
  */
 public static function get_attribute_data($attribute = false)
 {
     $wp_properties = ud_get_wp_property()->get();
     if (!$attribute) {
         return;
     }
     if (wp_cache_get($attribute, 'wpp_attribute_data')) {
         return wp_cache_get($attribute, 'wpp_attribute_data');
     }
     $post_table_keys = array('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count');
     $ui_class = array($attribute);
     if (in_array($attribute, $post_table_keys)) {
         $return['storage_type'] = 'post_table';
     }
     $return['slug'] = $attribute;
     if ($attribute == 'property_type') {
         $return['storage_type'] = 'meta_key';
         $return['label'] = sprintf(__('%s Type', ud_get_wp_property('domain')), \WPP_F::property_label());
     }
     if (isset($wp_properties['property_stats'][$attribute])) {
         $return['is_stat'] = 'true';
         $return['storage_type'] = 'meta_key';
         $return['label'] = $wp_properties['property_stats'][$attribute];
     }
     if (isset($wp_properties['property_meta'][$attribute])) {
         $return['is_meta'] = 'true';
         $return['storage_type'] = 'meta_key';
         $return['label'] = $wp_properties['property_meta'][$attribute];
         $return['input_type'] = 'textarea';
         $return['data_input_type'] = 'textarea';
     }
     if (isset($wp_properties['searchable_attr_fields'][$attribute])) {
         $return['input_type'] = $wp_properties['searchable_attr_fields'][$attribute];
         $ui_class[] = $return['input_type'];
     }
     if (isset($wp_properties['admin_attr_fields'][$attribute])) {
         $return['data_input_type'] = $wp_properties['admin_attr_fields'][$attribute];
         $ui_class[] = $return['data_input_type'];
     }
     if (isset($wp_properties['configuration']['address_attribute']) && $wp_properties['configuration']['address_attribute'] == $attribute) {
         $return['is_address_attribute'] = 'true';
         $ui_class[] = 'address_attribute';
     }
     if (isset($wp_properties['property_inheritance']) && is_array($wp_properties['property_inheritance'])) {
         foreach ($wp_properties['property_inheritance'] as $property_type => $type_data) {
             if (in_array($attribute, $type_data)) {
                 $return['inheritance'][] = $property_type;
             }
         }
     }
     if (isset($wp_properties['predefined_values'][$attribute])) {
         $return['predefined_values'] = $wp_properties['predefined_values'][$attribute];
     }
     if (isset($wp_properties['predefined_search_values'][$attribute])) {
         $return['predefined_search_values'] = $wp_properties['predefined_search_values'][$attribute];
     }
     if (isset($wp_properties['sortable_attributes']) && in_array($attribute, (array) $wp_properties['sortable_attributes'])) {
         $return['sortable'] = true;
         $ui_class[] = 'sortable';
     }
     if (isset($wp_properties['hidden_frontend_attributes']) && in_array($attribute, (array) $wp_properties['hidden_frontend_attributes'])) {
         $return['hidden_frontend_attribute'] = true;
         $ui_class[] = 'fe_hidden';
     }
     if (isset($wp_properties['currency_attributes']) && in_array($attribute, (array) $wp_properties['currency_attributes'])) {
         $return['currency'] = true;
         $ui_class[] = 'currency';
     }
     if (isset($wp_properties['numeric_attributes']) && in_array($attribute, (array) $wp_properties['numeric_attributes'])) {
         $return['numeric'] = true;
         $ui_class[] = 'numeric';
     }
     if (isset($wp_properties['searchable_attributes']) && in_array($attribute, (array) $wp_properties['searchable_attributes'])) {
         $return['searchable'] = true;
         $ui_class[] = 'searchable';
     }
     if (empty($return['title'])) {
         $return['title'] = \WPP_F::de_slug($return['slug']);
     }
     $return['ui_class'] = implode(' wpp_', $ui_class);
     $multiple_attributes = ud_get_wp_property('attributes.multiple', array());
     $return['multiple'] = false;
     if (isset($return['data_input_type']) && in_array($return['data_input_type'], (array) $multiple_attributes)) {
         $return['multiple'] = true;
     }
     $return = apply_filters('wpp_attribute_data', $return);
     wp_cache_add($attribute, $return, 'wpp_attribute_data');
     return $return;
 }