/**
  * Insert post and postmeta using `RSCSV_Import_Post_Helper` class.
  *
  * @param array $post
  * @param array $meta
  * @param array $terms
  * @param string $thumbnail The uri or path of thumbnail image.
  * @param bool $is_update
  * @return RSCSV_Import_Post_Helper
  */
 public function save_post($post, $meta, $terms, $thumbnail, $is_update)
 {
     // Separate the post tags from $post array
     if (isset($post['post_tags']) && !empty($post['post_tags'])) {
         $post_tags = $post['post_tags'];
         unset($post['post_tags']);
     }
     // Special handling of attachments
     if (!empty($thumbnail) && $post['post_type'] == 'attachment') {
         $post['media_file'] = $thumbnail;
         $thumbnail = null;
     }
     // Add or update the post
     if ($is_update) {
         $h = RSCSV_Import_Post_Helper::getByID($post['ID']);
         $h->update($post);
     } else {
         $h = RSCSV_Import_Post_Helper::add($post);
     }
     // Set post tags
     if (isset($post_tags)) {
         $h->setPostTags($post_tags);
     }
     // Set meta data
     $h->setMeta($meta);
     // Set terms
     foreach ($terms as $key => $value) {
         $h->setObjectTerms($key, $value);
     }
     // Add thumbnail
     if ($thumbnail) {
         $h->addThumbnail($thumbnail);
     }
     return $h;
 }
 /**
  * Add a post
  *
  * @param (array) $data An associative array of the post data
  * @return (RSCSV_Import_Post_Helper)
  */
 public static function add($data)
 {
     $object = new RSCSV_Import_Post_Helper();
     if ($data['post_type'] == 'attachment') {
         $post_id = $object->addMediaFile($data['media_file'], $data);
     } else {
         $post_id = wp_insert_post($data, true);
     }
     if (is_wp_error($post_id)) {
         $object->addError($post_id->get_error_code(), $post_id->get_error_message());
     } else {
         $object->setPost($post_id);
     }
     return $object;
 }