/** * Parse the URL to get the used page. * * @since 1.0.0 * * @uses "caldera_magic_tag-post" filter * * @param array $params * * @return string|array */ public function permalink($params) { if (class_exists('FooGallery') && is_string($params) && strpos($params, '?foogallery')) { $url = parse_url($params); if (isset($url['query'])) { parse_str($url['query']); if (isset($foogallery)) { $foo = \FooGallery::get_by_slug($foogallery); $usages = $foo->find_usages(); if (is_array($usages) && isset($usages[0])) { return esc_url(get_permalink($usages[0]->ID)); } } } } return $params; }
<?php /** * FooGallery default responsive album template */ global $current_foogallery_album; global $current_foogallery_album_arguments; $gallery = foogallery_album_get_current_gallery(); $no_images_text = foogallery_album_template_setting('no_images_text', false); $single_image_text = foogallery_album_template_setting('single_image_text', false); $images_text = foogallery_album_template_setting('images_text', false); $alignment = foogallery_album_template_setting('alignment', 'alignment-left'); $foogallery = false; if (!empty($gallery)) { $foogallery = FooGallery::get_by_slug($gallery); //check to see if the gallery belongs to the album if (!$current_foogallery_album->includes_gallery($foogallery->ID)) { $foogallery = false; } } if (false !== $foogallery) { $album_url = foogallery_album_remove_gallery_from_link(); echo '<div id="' . $current_foogallery_album->slug . '" class="foogallery-album-header">'; echo '<p><a href="' . $album_url . '">' . foogallery_album_template_setting('back_to_album_text', '« back to album') . '</a></p>'; echo '<h2>' . $foogallery->name . '</h2>'; echo '</div>'; echo do_shortcode('[foogallery id="' . $foogallery->ID . '"]'); } else { $title_bg = foogallery_album_template_setting('title_bg', '#ffffff'); $title_font_color = foogallery_album_template_setting('title_font_color', '#000000'); $args = foogallery_album_template_setting('thumbnail_dimensions', array());
/** * load the gallery based on either the id or slug, passed in via arguments * * @param $args array Arguments passed in from the shortcode * * @return bool|FooGallery The gallery object we want to render */ function find_gallery($args) { $id = intval($this->get_arg($args, 'id'), 0); if ($id > 0) { //load gallery by ID return FooGallery::get_by_id($id); } else { //take into account the cases where id is passed in via the 'gallery' attribute $gallery = $this->get_arg($args, 'gallery', 0); if (intval($gallery) > 0) { //we have an id, so load return FooGallery::get_by_id(intval($gallery)); } //we are dealing with a slug return FooGallery::get_by_slug($gallery); } }