public function controls() { $found = array(); if (class_exists('Envira_Gallery')) { $envira_galleries = Envira_Gallery::get_instance()->get_galleries(); if (is_array($envira_galleries)) { foreach ($envira_galleries as $eg) { $found[] = array('value' => $eg['id'], 'label' => $eg['config']['title']); } } } if (empty($found)) { $found[] = array('value' => 'none', 'label' => __('No Galleries Available', csl18n()), 'disabled' => true); } $this->addControl('source_id', 'select', __('Select Gallery', csl18n()), __('Choose from Envira Gallery elements that have already been created.', csl18n()), $found[0]['value'], array('choices' => $found)); }
/** * Retrieves the image data for a given Envira Gallery ID * * @param array $dynamic_data Existing Dynamic Data Array * @param int $id Envira Gallery ID * @param array $data Slider Configuration * @return bool|array Array of data on success, false on failure */ public function get_envira_images($dynamic_data, $id, $data) { // Return false if Envira is not available. if (!class_exists('Envira_Gallery')) { return false; } // Get Envira Gallery ID $envira_id = explode('-', $id); $id = $envira_id[1]; // Get Envira Gallery $envira_gallery = Envira_Gallery::get_instance(); $gallery_data = apply_filters('soliloquy_dynamic_get_envira_image_data', $envira_gallery->get_gallery($id), $id); if (!$gallery_data) { return false; } if (!isset($gallery_data['gallery'])) { return false; } $image_data = array(); // Loop through the gallery images and prepare the data foreach ((array) $gallery_data['gallery'] as $attachment_id => $image) { $image_data[$attachment_id] = $image; unset($image_data[$attachment_id]['status'], $image_data[$attachment_id]['thumb']); } return apply_filters('soliloquy_dynamic_envira_images', $image_data, $gallery_data, $id, $data); }