PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 2.41
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v2.41
3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 2.44 All 141 releases
photonic / Layouts / Core_Layout.php

Core_Layout.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 2.41, at Layouts/Core_Layout.php

68 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Photonic_Plugin\Layouts;
3
4 use Photonic_Plugin\Modules\Core;
5
6 /**
7 * Layout Manager to generate the grid layouts and the "Justified Grid" layout, all of which use the same markup. The Justified Grid layout is
8 * modified by JS on the front-end, however the base markup for it is similar to the square and circular thumbnails layout.
9 *
10 * All other layout managers extend this, and might implement their own versions of generate_level_1_gallery and generate_level_2_gallery
11 *
12 */
13 abstract class Core_Layout {
14 protected $library;
15
16 protected function __construct() {
17 global $photonic_slideshow_library, $photonic_custom_lightbox;
18 if ($photonic_slideshow_library != 'custom') {
19 $this->library = $photonic_slideshow_library;
20 }
21 else {
22 $this->library = $photonic_custom_lightbox;
23 }
24 }
25
26 /**
27 * Generates the markup for a single photo.
28 *
29 * @param $data array Pertinent pieces of information about the photo - the source (src), the photo page (href), title and caption
30 * @param $module Core The object calling this. A CSS class is created in the header, photonic-single-<code>$module->provider</code>-photo-header
31 * @return string
32 */
33 function generate_single_photo_markup($data, $module) {
34 $module->push_to_stack('Generate single photo markup');
35 $ret = '';
36 $photo = array_merge(
37 ['src' => '', 'href' => '', 'title' => '', 'caption' => ''],
38 $data
39 );
40
41 if (empty($photo['src'])) {
42 $module->pop_from_stack();
43 return $ret;
44 }
45
46 global $photonic_external_links_in_new_tab;
47 if (!empty($photo['title'])) {
48 $ret .= "\t".'<h3 class="photonic-single-photo-header photonic-single-'.$module->provider.'-photo-header">'.$photo['title']."</h3>\n";
49 }
50
51 $img = '<img src="'.$photo['src'].'" alt="'.esc_attr(empty($photo['caption']) ? $photo['title'] : $photo['caption']).'" loading="eager"/>';
52 if (!empty($photo['href'])) {
53 $img = '<a href="'.esc_url($photo['href']).'" title="'.esc_attr(empty($photo['caption']) ? $photo['title'] : $photo['caption']).'" '.
54 (!empty($photonic_external_links_in_new_tab) ? ' target="_blank" ' : '').'>'.$img.'</a>';
55 }
56
57 if (!empty($photo['caption'])) {
58 $ret .= "\t".'<div class="wp-caption">'."\n\t\t".$img."\n\t\t".'<div class="wp-caption-text">'.$photo['caption']."</div>\n\t</div><!-- .wp-caption -->\n";
59 }
60 else {
61 $ret .= $img;
62 }
63
64 $module->pop_from_stack();
65 return $ret;
66 }
67 }
68