当前位置: 首页>>代码示例>>PHP>>正文


PHP Update::posts方法代码示例

本文整理汇总了PHP中Update::posts方法的典型用法代码示例。如果您正苦于以下问题:PHP Update::posts方法的具体用法?PHP Update::posts怎么用?PHP Update::posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Update的用法示例。


在下文中一共展示了Update::posts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: posts

 /**
  * Saves the posts into WordPress
  *
  * @param array|object $post
  */
 public function posts($post)
 {
     /*
      * TODO: If this isn't an array it probably is an error message, need to handle it
      */
     if (is_array($post)) {
         //get post data
         $property_formatted = array();
         //loop through properties found
         foreach ($post as $property) {
             //reassign fields to ones that look good
             $property_formatted['property_price'] = $property['Lp_dol'];
             $property_formatted['mls'] = $property['Ml_num'];
             $property_formatted['address'] = $property['Addr'];
             $property_formatted['bathrooms'] = $property['Bath_tot'];
             $property_formatted['bedrooms'] = $property['Br'];
             $property_formatted['province'] = $property['County'];
             $property_formatted['broker'] = $property['Rltr'];
             $property_formatted['rooms'] = $property['Rms'];
             $property_formatted['rentorsale'] = $property['S_r'];
             $property_formatted['status'] = $property['Status'];
             $property_formatted['postal_code'] = $property['Zip'];
             $property_formatted['city'] = $property['Area'];
             $property_formatted['last_updated_text'] = $property['Timestamp_sql'];
             $property_formatted['last_updated_photos'] = $property['Pix_updt'];
             $property_formatted['description'] = $property['Ad_text'];
             $property_formatted['property_area'] = $property['Sqft'];
             $property_formatted['full_dump'] = $property;
             $update_check = '';
             //This will check for old properties and see if they need to be updated
             $update_check = CheckOld::data($property_formatted['address'], $property_formatted['last_updated_text'], $property_formatted['status']);
             if (is_array($update_check)) {
                 if (isset($update_check['update'])) {
                     $update = new Update($property_formatted['mls'], $update_check['update'], get_post_meta($update_check['update'], 'wptrebs_photos', true));
                     $update->posts($property);
                 } elseif (isset($update_check['new'])) {
                     //set up arguments before entering post to wp
                     $post_args = array('post_title' => $property_formatted['address'], 'post_content' => $property_formatted['description'], 'post_status' => 'publish', 'post_type' => 'property');
                     //insert post and return new post id
                     $posted_property = wp_insert_post($post_args);
                     //add post meta using the new post id and good looking array
                     foreach ($property_formatted as $key => $value) {
                         if (!empty($value)) {
                             add_post_meta($posted_property, $key, $value, true) || update_post_meta($posted_property, $key, $value);
                         }
                     }
                     $photos = $this->feed->photos($property_formatted['mls']);
                     //Get the photos
                     self::photos($photos, $posted_property, $property_formatted['mls']);
                 }
             }
         }
     }
 }
开发者ID:LeapXD,项目名称:wptrebrets,代码行数:59,代码来源:Save.php


注:本文中的Update::posts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。