function import() { //create an empty foogallery album $foogallery_album_args = array('post_title' => $this->foogallery_album_title, 'post_type' => FOOGALLERY_CPT_ALBUM, 'post_status' => 'publish'); $this->foogallery_album_id = wp_insert_post($foogallery_album_args); //set a default gallery template add_post_meta($this->foogallery_album_id, FOOGALLERY_ALBUM_META_TEMPLATE, foogallery_default_album_template(), true); $nextgen = new FooGallery_NextGen_Helper(); //link all galleries that can be linked $album = $nextgen->get_album($this->nextgen_album_id); $galleries = $nextgen->nextgen_unserialize($album->sortorder); $gallery_ids = array(); foreach ($galleries as $gallery_id) { $gallery_progress = $nextgen->get_import_progress($gallery_id); if ($gallery_progress->is_completed()) { $gallery_ids[] = $gallery_progress->foogallery_id; $this->galleries_count++; } } //link all galleries to the foogallery album add_post_meta($this->foogallery_album_id, FOOGALLERY_ALBUM_META_GALLERIES, $gallery_ids); $this->status = self::PROGRESS_COMPLETED; }