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; }
public function render_settings_metabox($post) { $album = $this->get_album($post); $available_templates = foogallery_album_templates(); $album_template = foogallery_default_album_template(); if (!empty($album->album_template)) { $album_template = $album->album_template; } if (false === $album_template) { $album_template = $available_templates[0]['slug']; } $hide_help = 'on' == foogallery_get_setting('hide_gallery_template_help'); ?> <table class="foogallery-album-metabox-settings"> <tbody> <tr class="gallery_template_field gallery_template_field_selector"> <th> <label for="FooGallerySettings_AlbumTemplate"><?php _e('Album Template', 'foogallery'); ?> </label> </th> <td> <select id="FooGallerySettings_AlbumTemplate" name="<?php echo FOOGALLERY_ALBUM_META_TEMPLATE; ?> "> <?php foreach ($available_templates as $template) { $selected = $album_template === $template['slug'] ? 'selected' : ''; echo "<option {$selected} value=\"{$template['slug']}\">{$template['name']}</option>"; } ?> </select> <br /> <small><?php _e('The album template that will be used when the album is output to the frontend.', 'foogallery'); ?> </small> </td> </tr> <?php foreach ($available_templates as $template) { $field_visibility = $album_template !== $template['slug'] ? 'style="display:none"' : ''; $section = ''; $fields = isset($template['fields']) ? $template['fields'] : array(); foreach ($fields as $field) { //allow for the field to be altered by extensions. $field = apply_filters('foogallery_alter_gallery_template_field', $field, $album); $class = "gallery_template_field gallery_template_field-{$template['slug']} gallery_template_field-{$template['slug']}-{$field['id']}"; if (isset($field['section']) && $field['section'] !== $section) { $section = $field['section']; ?> <tr class="<?php echo $class; ?> " <?php echo $field_visibility; ?> > <td colspan="2"><h4><?php echo $section; ?> </h4></td> </tr> <?php } if (isset($field['type']) && 'help' == $field['type'] && $hide_help) { continue; //skip help if the 'hide help' setting is turned on } ?> <tr class="<?php echo $class; ?> " <?php echo $field_visibility; ?> > <?php if (isset($field['type']) && 'help' == $field['type']) { ?> <td colspan="2"> <div class="foogallery-help"> <?php echo $field['desc']; ?> </div> </td> <?php } else { ?> <th> <label for="FooGallerySettings_<?php echo $template['slug'] . '_' . $field['id']; ?> "><?php echo $field['title']; ?> </label> </th> <td> <?php do_action('foogallery_render_gallery_template_field', $field, $album, $template); ?> </td> <?php } ?> </tr> <?php } } ?> </tbody> </table> <?php }