public function save()
 {
     global $wpdb, $bp;
     $this->id = apply_filters('bp_portfolio_data_id_before_save', $this->id, $this->id);
     $this->author_id = apply_filters('bp_portfolio_data_author_id_before_save', $this->author_id, $this->id);
     $this->title = apply_filters('bp_portfolio_data_title_before_save', $this->title, $this->id);
     $this->description = apply_filters('bp_portfolio_data_description_before_save', $this->description, $this->id);
     $this->url = apply_filters('bp_portfolio_data_url_before_save', $this->url, $this->id);
     $this->screenshot = apply_filters('bp_portfolio_data_screenshot_before_save', $this->screenshot, $this->id);
     $this->created_at = apply_filters('bp_portfolio_data_created_at_before_save', $this->created_at, $this->id);
     $this->updated_at = apply_filters('bp_portfolio_data_updated_at_before_save', $this->updated_at, $this->id);
     $this->tags = apply_filters('bp_portfolio_data_tags_before_save', $this->tags, $this->id);
     do_action('bp_portfolio_data_before_save', $this);
     if ($this->id) {
         $wp_update_post_args = array('ID' => $this->id, 'post_author' => $this->author_id, 'post_title' => $this->title, 'post_content' => $this->description);
         // We update the existing item if a new screenshot is sent
         if (is_array($this->screenshot)) {
             $attach_id = fileupload_process($this->screenshot);
             $wp_update_post_args['post_parent'] = $attach_id;
         }
         $result = wp_update_post($wp_update_post_args);
         // Update post metas
         if ($result) {
             update_post_meta($result, 'bp_portfolio_url', $this->url);
         }
     } else {
         // We insert a new item
         $attach_id = fileupload_process($this->screenshot);
         $wp_insert_post_args = array('post_status' => 'publish', 'post_type' => 'portfolio', 'post_author' => $this->author_id, 'post_title' => $this->title, 'post_content' => $this->description, 'post_parent' => $attach_id);
         $result = wp_insert_post($wp_insert_post_args);
         // Insert post metas
         if ($result) {
             update_post_meta($result, 'bp_portfolio_url', $this->url);
         }
     }
     do_action('bp_portfolio_data_after_save', $this);
     return $result;
 }
Пример #2
0
function wpestate_me_upload()
{
    $file = array('name' => $_FILES['aaiu_upload_file']['name'], 'type' => $_FILES['aaiu_upload_file']['type'], 'tmp_name' => $_FILES['aaiu_upload_file']['tmp_name'], 'error' => $_FILES['aaiu_upload_file']['error'], 'size' => $_FILES['aaiu_upload_file']['size']);
    $file = fileupload_process($file);
}