/**
  *
  * Extends get_post by dumping all metadata into array
  *
  * @param $id
  * @param string $args
  *
  * @return bool|mixed|object|stdClass|void
  */
 function get_property($id, $args = "")
 {
     return \UsabilityDynamics\WPP\Property_Factory::get($id, $args);
 }
Example #2
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;
     }
 }
 /**
  * Load property information into an array or an object
  * Deprecated since 2.1.1
  *
  * @param mix ID or post object
  * @param array $args
  * @return mix array or object
  */
 public static function get_property($id, $args = array())
 {
     return \UsabilityDynamics\WPP\Property_Factory::get($id, $args);
 }