本文整理汇总了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']);
}
}
}
}
}