/** * 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; }