PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 2.43
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v2.43
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 / Grid.php

Grid.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 2.43, at Layouts/Grid.php

553 lines 23.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\Layouts\Features\Can_Use_Lightbox;
5 use Photonic_Plugin\Modules\Core;
6
7 require_once('Level_One_Gallery.php');
8 require_once('Level_Two_Gallery.php');
9
10 require_once('Features/Can_Use_Lightbox.php');
11
12 class Grid extends Core_Layout implements Level_One_Gallery, Level_Two_Gallery {
13 use Can_Use_Lightbox;
14
15 private static $instance = null;
16
17 public static function get_instance() {
18 if (self::$instance == null) {
19 self::$instance = new Grid();
20 }
21 return self::$instance;
22 }
23
24 /**
25 * Generates the HTML for the lowest level gallery, i.e. the photos. This is used for both, in-page and popup displays.
26 * The code for the random layouts is handled in JS, but just the HTML markers for it are provided here.
27 *
28 * @param $photos
29 * @param array $options
30 * @param $short_code
31 * @param $module Core
32 * @return string
33 */
34 function generate_level_1_gallery($photos, $options, $short_code, $module) {
35 $module->push_to_stack('Generate level 1 gallery');
36
37 $lightbox = self::get_lightbox();
38
39 $layout = $short_code['layout'];
40 $columns = !empty($short_code['columns']) && ($layout !== 'random' && $layout !== 'mosaic') ? $short_code['columns'] : 'auto';
41 $display = !empty($short_code['display']) ? $short_code['display'] : 'in-page';
42 $more = !empty($short_code['more']) ? esc_attr($short_code['more']) : '';
43 $more = (empty($more) && !empty($short_code['photo_more'])) ? esc_attr($short_code['photo_more']) : $more;
44 $panel = !empty($short_code['panel']) ? $short_code['panel'] : '';
45
46 $title_position = empty($short_code['title_position']) ? $options['title_position'] : $short_code['title_position'];
47 $row_constraints = isset($options['row_constraints']) && is_array($options['row_constraints']) ? $options['row_constraints'] : [];
48 $sizes = isset($options['sizes']) && is_array($options['sizes']) ? $options['sizes'] : [];
49 $type = !empty($options['type']) ? $options['type'] : 'photo';
50 $parent = !empty($options['parent']) ? $options['parent'] : 'stream';
51 $pagination = isset($options['level_2_meta']) && is_array($options['level_2_meta']) ? $options['level_2_meta'] : [];
52 $indent = !isset($options['indent']) ? "\t" : $options['indent'];
53
54 list($container_id, $container_end) = $this->get_container_details($short_code, $module);
55
56 $non_standard = $layout == 'random' || $layout == 'masonry' || $layout == 'mosaic';
57
58 $col_class = '';
59 if (absint($columns)) {
60 $col_class = 'photonic-gallery-'.$columns.'c';
61 }
62
63 if ($col_class == '' && $row_constraints['constraint-type'] == 'padding') {
64 $col_class = 'photonic-pad-photos';
65 }
66 else if ($col_class == '') {
67 $col_class = 'photonic-gallery-'.$row_constraints['count'].'c';
68 }
69 $col_class .= ' photonic-level-1 photonic-thumb photonic-thumb-'.$layout;
70
71 $link_attributes = $lightbox->get_gallery_attributes($panel, $module);
72 $link_attributes_text = $this->get_text_from_link_attributes($link_attributes);
73
74 $effect = $this->get_thumbnail_effect($short_code, $layout, $title_position);
75 $ul_class = "class='title-display-$title_position photonic-level-1-container ".($non_standard ? 'photonic-'.$layout.'-layout' : 'photonic-standard-layout')." photonic-thumbnail-effect-$effect'";
76 if ($display == 'popup') {
77 $ul_class = "class='slideshow-grid-panel lib-{$this->library} photonic-level-1-container title-display-$title_position'";
78 }
79
80 $ret = '';
81 if (!$non_standard && $display != 'popup') {
82 $container_tag = 'ul';
83 $element_tag = 'li';
84 }
85 else {
86 $container_tag = 'div';
87 $element_tag = 'div';
88 }
89
90 list($pagination_data, $pagination, $columns_data) = $this->get_gallery_data_attributes($short_code, $module, $pagination, $columns);
91
92 $start_with = "$indent<$container_tag $container_id $ul_class $pagination_data $columns_data>\n";
93 $ret .= $start_with;
94
95 global $photonic_external_links_in_new_tab;
96 if (!empty($photonic_external_links_in_new_tab)) {
97 $target = " target='_blank' ";
98 }
99 else {
100 $target = '';
101 }
102
103 $counter = 0;
104 $thumbnail_class = " class='$layout' ";
105
106 $element_start = "$indent\t<".$element_tag.' class="photonic-'.$module->provider.'-image photonic-'.$module->provider.'-'.$type.' '.$col_class.'">'."\n";
107
108 $default_lightbox_text = apply_filters('photonic_default_lightbox_text', esc_attr__('View', 'photonic'));
109 foreach ($photos as $photo) {
110 $counter++;
111
112 $thumb = ($non_standard && $display == 'in-page') ? (isset($photo['tile_image']) ? $photo['tile_image'] : $photo['main_image']) : $photo['thumbnail'];
113 $orig = empty($photo['video']) ? $photo['main_image'] : $photo['video'];
114 // $orig = $photo['main_image'];
115 $url = isset($photo['main_page']) ? $photo['main_page'] : '';
116 $title = esc_attr($photo['title']);
117 $description = esc_attr($photo['description']);
118 $alt = esc_attr($photo['alt_title']);
119 $orig = $this->library == 'none' ? $url : $orig;
120
121 $title = empty($title) ? ((empty($alt) && $module->link_lightbox_title && $this->library != 'thickbox') ? $default_lightbox_text : $alt) : $title;
122 $ret .= $element_start;
123
124 $deep_value = 'gallery[photonic-'.$module->provider.'-'.$parent.'-'.(empty($panel) ? $module->gallery_index : $panel).']/'.(empty($photo['id']) ? $counter : $photo['id']).'/';
125 $deep_link = ' data-photonic-deep="'.$deep_value.'" ';
126
127 $buy = '';
128 if (!empty($photo['buy_link']) && $module->show_buy_link) {
129 $buy = ' data-photonic-buy="'.$photo['buy_link'].'" ';
130 }
131
132 $style = [];
133 if (!empty($sizes['thumb-width'])) $style[] = 'width:'.$sizes['thumb-width'].'px';
134 if (!empty($sizes['thumb-height'])) $style[] = 'height:'.$sizes['thumb-height'].'px';
135 if (!empty($style)) $style = 'style="'.implode(';', $style).'"'; else $style = '';
136 if ($module->link_lightbox_title && $this->library != 'thickbox' && !empty($url)) {
137 $title_link_start = esc_attr("<a href='$url' $target>");
138 $title_link_end = esc_attr("</a>");
139 }
140 else {
141 $title_link_start = '';
142 $title_link_end = '';
143 }
144
145 if (!empty($short_code['caption']) && ($short_code['caption'] == 'desc' || ($short_code['caption'] == 'title-desc' && empty($title)) || ($short_code['caption'] == 'desc-title' && !empty($description)))) {
146 $title = $description;
147 }
148 else if (empty($short_code['caption']) || (($short_code['caption'] == 'desc-title' && empty($title)) || $short_code['caption'] == 'none')) {
149 $title = '';
150 }
151
152 if (!empty($title)) {
153 $title_markup = $title_link_start.esc_attr($title).$title_link_end;
154 $title_markup = apply_filters('photonic_lightbox_title_markup', $title_markup);
155 }
156 else {
157 $title_markup = '';
158 }
159
160 if ($module->link_lightbox_title && $this->library != 'thickbox' && !empty($photo['buy_link']) && $module->show_buy_link) {
161 $buy_link = esc_attr('<a class="photonic-buy-link" href="'.$photo['buy_link'].'" target="_blank" title="'.__('Buy', 'photonic').'"><div class="icon-buy"></div></a>');
162 $title_markup .= $buy_link;
163 }
164
165 $shown_title = '';
166 if (in_array($title_position, ['below', 'hover-slideup-show', 'hover-slidedown-show', 'slideup-stick']) && !empty($title)) {
167 $shown_title = '<div class="photonic-title-info"><div class="photonic-photo-title photonic-title">'.wp_specialchars_decode($title, ENT_QUOTES).'</div></div>';
168 }
169
170 $photo_data = ['title' => $title_markup, 'deep' => $deep_value, 'raw_title' => $title, 'href' => $orig];
171 if (!empty($photo['download'])) {
172 $photo_data['download'] = $photo['download'];
173 }
174 if (!empty($photo['video'])) {
175 $photo_data['video'] = $photo['video'];
176 }
177 else {
178 $photo_data['image'] = $photo['main_image'];
179 }
180 $photo_data['provider'] = $module->provider;
181 $photo_data['gallery_index'] = $module->gallery_index;
182 $photo_data['id'] = $photo['id'];
183
184 $lb_specific_data = $lightbox->get_photo_attributes($photo_data, $module);
185 if (!empty($photo['video'])) {
186 $lb_specific_data .= ' data-photonic-media-type="video" ';
187 }
188 else {
189 $lb_specific_data .= ' data-photonic-media-type="image" ';
190 }
191 if (!empty($photo['video']) && $this->library == 'lightgallery') {
192 $video_id = $module->provider.'-'.$module->gallery_index.'-'.$photo['id'];
193 $ret .= $indent."\t\t".'<div style="display:none;" id="photonic-video-'.$video_id.'">'."\n";
194 $ret .= $indent."\t\t\t".'<video class="lg-video-object lg-html5 photonic" controls preload="none">'."\n";
195 $ret .= $indent."\t\t\t\t".'<source src="'.$photo['video'].'" type="'.(!empty($photo['mime']) ? $photo['mime']: 'video/mp4').'">'."\n";
196 $ret .= $indent."\t\t\t\t".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."\n";
197 $ret .= $indent."\t\t\t".'</video>'."\n";
198 $ret .= $indent."\t\t".'</div>'."\n";
199
200 $orig = ''; // href should be blank
201 }
202 else if (!empty($photo['video']) && (in_array($this->library, ['colorbox', 'fancybox', 'fancybox2', 'magnific', 'photoswipe', 'swipebox',])
203 || (in_array($this->library, ['fancybox3']) && in_array($module->provider, ['flickr', 'google']))
204 )) {
205 $video_id = $module->provider.'-'.$module->gallery_index.'-'.$photo['id'];
206 $ret .= $indent."\t\t".'<div class="photonic-html5-external" id="photonic-video-'.$video_id.'">'."\n";
207 $ret .= $indent."\t\t\t".'<video class="photonic" controls preload="none">'."\n";
208 $ret .= $indent."\t\t\t\t".'<source src="'.$photo['video'].'" type="'.(!empty($photo['mime']) ? $photo['mime']: 'video/mp4').'">'."\n";
209 $ret .= $indent."\t\t\t\t".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."\n";
210 $ret .= $indent."\t\t\t".'</video>'."\n";
211 $ret .= $indent."\t\t".'</div>'."\n";
212
213 $orig = '#photonic-video-'.$video_id;
214 }
215
216 if ($this->library == 'magnific') {
217 $magnific = !empty($photo['video']) ? 'mfp-inline' : 'mfp-image';
218 $link_attributes['class']['magnific'] = $magnific;
219 $link_attributes_text = $this->get_text_from_link_attributes($link_attributes);
220 }
221
222 if ($title_position == 'tooltip') {
223 $tooltip = 'data-photonic-tooltip="'.esc_attr($title).'" ';
224 }
225 else {
226 $tooltip = '';
227 }
228 $ret .= $indent."\t\t".'<a '.$link_attributes_text.' href="'.$orig.'" title="'.($title_position != 'none' ? esc_attr($title) : '').'" data-title="'.$title_markup.'" '.$tooltip.' '.$lb_specific_data.' '.$target.$deep_link.$buy.">\n";
229 $ret .= $indent."\t\t\t".'<img alt="'.$alt.'" src="'.$thumb.'" '.$style.$thumbnail_class." loading='eager'/>\n";
230 $ret .= $indent."\t\t\t".$shown_title."\n";
231 $ret .= $indent."\t\t"."</a>\n";
232 $ret .= $indent."\t"."</$element_tag>\n";
233 }
234
235 $ret = trim($ret);
236 if ($ret != $start_with) {
237 $trailing = strlen($element_tag) + 3;
238 if (substr($ret, -$trailing) != "</$element_tag>" && $short_code['popup'] == 'show' && !$non_standard) {
239 $ret .= "\n$indent</$element_tag><!-- last $element_tag.photonic-pad-photos -->";
240 }
241
242 $ret .= "\n$indent</$container_tag> <!-- ./photonic-level-1-container -->\n";
243 $ret .= "<span id='$container_end'></span>";
244
245 if (!empty($pagination) && isset($pagination['end']) && isset($pagination['total']) && $pagination['total'] > $pagination['end']) {
246 $ret .= !empty($more) ? "<a href='#' class='photonic-more-button photonic-more-dynamic'>$more</a>\n" : '';
247 }
248 }
249 else {
250 $ret = '';
251 }
252
253 if (is_archive() || is_home()) {
254 global $photonic_archive_thumbs;
255 if (!empty($photonic_archive_thumbs) && $counter < $photonic_archive_thumbs) {
256 $module->is_more_required = false;
257 }
258 }
259
260 $module->pop_from_stack();
261 return $ret;
262 }
263
264 /**
265 * Generates the HTML for a group of level-2 items, i.e. Photosets (Albums) and Galleries for Flickr, Albums for Google Photos,
266 * Albums for SmugMug, and Photosets (Galleries and Collections) for Zenfolio. No concept of albums
267 * exists in native WP and Instagram.
268 *
269 * @param $objects
270 * @param $options
271 * @param $short_code
272 * @param $module Core
273 * @return string
274 */
275 function generate_level_2_gallery($objects, $options, $short_code, $module) {
276 $module->push_to_stack('Generate Level 2 Gallery');
277 $row_constraints = isset($options['row_constraints']) && is_array($options['row_constraints']) ? $options['row_constraints'] : [];
278 $type = $options['type'];
279 $singular_type = $options['singular_type'];
280 $title_position = empty($short_code['title_position']) ? $options['title_position'] : $short_code['title_position'];
281 $level_1_count_display = $options['level_1_count_display'];
282 $indent = !isset($options['indent']) ? '' : $options['indent'];
283 $provider = $module->provider;
284
285 $columns = $short_code['columns'];
286 $layout = !isset($short_code['layout']) ? 'square' : $short_code['layout'];
287 $popup = ' data-photonic-popup="'.$short_code['popup'].'"';
288
289 $non_standard = $layout == 'random' || $layout == 'masonry' || $layout == 'mosaic';
290 $effect = $this->get_thumbnail_effect($short_code, $layout, $title_position);
291 $ul_class = "class='title-display-$title_position photonic-level-2-container ".($non_standard ? 'photonic-'.$layout.'-layout' : 'photonic-standard-layout')." photonic-thumbnail-effect-$effect'";
292
293 list($container_id, $container_end) = $this->get_container_details($short_code, $module);
294
295 $pagination = isset($options['pagination']) && is_array($options['pagination']) ? $options['pagination'] : [];
296 $more = !empty($short_code['more']) ? esc_attr($short_code['more']) : '';
297
298 list($pagination_data, $pagination, $columns_data) = $this->get_gallery_data_attributes($short_code, $module, $pagination, $columns);
299
300 $ret = "\n$indent<ul $container_id $ul_class $pagination_data $columns_data>";
301 if ($non_standard) {
302 $ret = "\n$indent<div $container_id $ul_class $pagination_data $columns_data>";
303 }
304
305 if ($columns != 'auto') {
306 $col_class = 'photonic-gallery-'.$columns.'c';
307 }
308 else if ($row_constraints['constraint-type'] == 'padding') {
309 $col_class = 'photonic-pad-'.$type;
310 }
311 else {
312 $col_class = 'photonic-gallery-'.$row_constraints['count'].'c';
313 }
314
315 $col_class .= ' photonic-level-2 photonic-thumb';
316
317 $counter = 0;
318 foreach ($objects as $object) {
319 $data_attributes = isset($object['data_attributes']) && is_array($object['data_attributes']) ? $object['data_attributes'] : [];
320 $data_attributes['provider'] = $provider;
321 $data_attributes['singular'] = $singular_type;
322
323 $data_array = [];
324 foreach ($data_attributes as $attr => $value) {
325 $data_array[] = 'data-photonic-'.$attr.'="'.$value.'"';
326 }
327 $data_array = implode(' ', $data_array);
328
329
330 $id = empty($object['id_1']) ? '' : $object['id_1'].'-';
331 $id = $id.$module->gallery_index;
332 $id = empty($object['id_2']) ? $id : ($id.'-'.$object['id_2']);
333 $title = esc_attr($object['title']);
334 $image = "<img src='".(($non_standard && isset($object['tile_image'])) ? $object['tile_image'] : $object['thumbnail'])."' alt='".$title."' class='$layout' loading='eager'/>";
335 $additional_classes = !empty($object['classes']) ? implode(' ', $object['classes']) : '';
336 $realm_class = '';
337 if (!empty($object['classes'])) {
338 foreach ($object['classes'] as $class) {
339 if (stripos($class, 'photonic-'.$provider.'-realm') !== FALSE) {
340 $realm_class = $class;
341 }
342 }
343 }
344 if ($title_position == 'tooltip') {
345 $tooltip = "data-photonic-tooltip='".esc_attr($title)."' ";
346 }
347 else {
348 $tooltip = '';
349 }
350
351 if (empty($object['gallery_url'])) {
352 $anchor = "\n{$indent}\t\t<a href='{$object['main_page']}' class='photonic-{$provider}-{$singular_type}-thumb photonic-level-2-thumb $additional_classes' id='photonic-{$provider}-$singular_type-thumb-$id' title='".($title_position != 'none' ? esc_attr($title) : '')."' data-title='".$title."' $tooltip $data_array$popup>\n$indent\t\t\t".$image;
353 }
354 else {
355 $anchor = "\n{$indent}\t\t<a href='{$object['gallery_url']}' class='photonic-{$provider}-{$singular_type}-thumb photonic-level-2-thumb gallery-page $additional_classes' id='photonic-{$provider}-$singular_type-thumb-$id' title='".($title_position != 'none' ? esc_attr($title) : '')."' data-title='".$title."' $tooltip $data_array$popup>\n$indent\t\t\t".$image;
356 }
357 $text = '';
358 if (in_array($title_position, ['below', 'hover-slideup-show', 'hover-slidedown-show', 'slideup-stick'])) {
359 $text = "\n{$indent}\t\t\t<div class='photonic-title-info'>\n{$indent}\t\t\t\t<div class='photonic-$singular_type-title photonic-title'>".$title."";
360 if (!$level_1_count_display && !empty($object['counter'])) {
361 $text .= '<span class="photonic-title-photo-count photonic-'.$singular_type.'-photo-count">'.sprintf(esc_html__('%s photos', 'photonic'), $object['counter']).'</span>';
362 }
363 }
364 if ($text != '') {
365 $text .= "</div>\n{$indent}\t\t\t</div>";
366 }
367
368 $anchor .= $text."\n{$indent}\t\t</a>";
369 $password_prompt = '';
370 if (!empty($object['passworded'])) {
371 $prompt_title = esc_attr__('Protected Content', 'photonic');
372 $prompt_submit = esc_attr__('Access', 'photonic');
373 $password_type = " type='password' ";
374 $prompt_type = 'password';
375 $prompt_text = esc_attr__('This album is password-protected. Please provide a valid password.', 'photonic');
376 if (in_array("photonic-$provider-passworded-authkey", $object['classes'])) {
377 $prompt_text = esc_attr__('This album is protected. Please provide a valid authorization key.', 'photonic');
378 }
379 else if (in_array("photonic-$provider-passworded-link", $object['classes'])) {
380 $prompt_text = esc_attr__('This album is protected. Please provide the short-link for it.', 'photonic');
381 $password_type = '';
382 $prompt_type = 'link';
383 }
384
385 $password_prompt = "
386 <div class='photonic-password-prompter $realm_class' id='photonic-{$provider}-$singular_type-prompter-$id' title='$prompt_title' data-photonic-prompt='$prompt_type'>
387 <div class='photonic-password-prompter-content'>
388 <div class='photonic-prompt-head'>
389 <h3>
390 <span class='title'>$prompt_title</span>
391 <button class='close'>&times;</button>
392 </h3>
393 </div>
394 <div class='photonic-prompt-body'>
395 <p>$prompt_text</p>
396 <input $password_type name='photonic-{$provider}-password' />
397 <button class='photonic-{$provider}-submit photonic-password-submit confirm'>$prompt_submit</button>
398 </div>
399 </div>
400 </div>";
401 }
402
403 if ($non_standard) {
404 $ret .= "\n$indent\t<div class='photonic-{$provider}-image photonic-{$provider}-$singular_type-thumb $col_class' id='photonic-{$provider}-$singular_type-$id'>{$anchor}{$password_prompt}\n$indent\t</div>";
405 }
406 else {
407 $ret .= "\n$indent\t<li class='photonic-{$provider}-image photonic-{$provider}-$singular_type-thumb $col_class' id='photonic-{$provider}-$singular_type-$id'>{$anchor}{$password_prompt}\n$indent\t</li>";
408 }
409 $counter++;
410 }
411
412 if ($ret != "\n$indent<ul $container_id $ul_class $pagination_data $columns_data>" && !$non_standard) {
413 $ret .= "\n$indent</ul>\n";
414 }
415 else if ($non_standard) {
416 $ret .= "\n$indent</div>\n";
417 }
418 else {
419 $ret = '';
420 }
421
422 if (!empty($ret)) {
423 $ret .= "<span id='$container_end'></span>";
424 if (!empty($pagination) && isset($pagination['end']) && isset($pagination['total']) && $pagination['total'] > $pagination['end']) {
425 $ret .= !empty($more) ? "<a href='#' class='photonic-more-button photonic-more-dynamic'>$more</a>\n" : '';
426 }
427 }
428
429 if (is_archive() || is_home()) {
430 global $photonic_archive_thumbs;
431 if (!empty($photonic_archive_thumbs) && $counter < $photonic_archive_thumbs) {
432 $module->is_more_required = false;
433 }
434 }
435
436 $module->pop_from_stack();
437 return $ret;
438 }
439
440 /**
441 * @param $short_code
442 * @param $module
443 * @return array
444 */
445 private function get_container_details($short_code, $module) {
446 if ($short_code['display'] != 'popup') {
447 $container_id = "id='photonic-{$module->provider}-stream-{$module->gallery_index}-container'";
448 $container_end = "photonic-{$module->provider}-stream-{$module->gallery_index}-container-end";
449 } else {
450 $container_id = "id='photonic-{$module->provider}-panel-" . $short_code['panel'] . "-container'";
451 $container_end = "photonic-{$module->provider}-panel-{$short_code['panel']}-container-end";
452 }
453 return [$container_id, $container_end];
454 }
455
456 /**
457 * @param array $link_attributes
458 * @return string
459 */
460 private function get_text_from_link_attributes($link_attributes) {
461 $class = '';
462 $rel = '';
463 $specific = '';
464 if (!empty($link_attributes['class'])) {
465 $class = " class='".implode(' ', array_values($link_attributes['class']))."' ";
466 }
467
468 if (!empty($link_attributes['rel'])) {
469 $rel = " rel='".implode(' ', $link_attributes['rel'])."' ";
470 }
471
472 if (!empty($link_attributes['specific'])) {
473 foreach ($link_attributes['specific'] as $key => $val) {
474 $specific .= $key.'="'.implode(' ', $val).'" ';
475 }
476 }
477 return $class.$rel.$specific;
478 }
479
480 /**
481 * @param $short_code
482 * @param $module
483 * @param $pagination
484 * @param $columns
485 * @return array
486 */
487 private function get_gallery_data_attributes($short_code, $module, $pagination, $columns) {
488 $pagination_data = '';
489 if (!empty($pagination)) {
490 $pagination_data = [];
491 // Should have total, start, end, per-page
492 foreach ($pagination as $meta => $value) {
493 $pagination_data[] = 'data-photonic-stream-' . $meta . '="' . $value . '"';
494 }
495
496 $pagination_data = implode(' ', $pagination_data);
497 if (empty($pagination['provider'])) {
498 $pagination_data .= ' data-photonic-stream-provider="' . $module->provider . '"';
499 }
500 }
501
502 $to_be_glued = '';
503 if (!empty($short_code)) {
504 $to_be_glued = [];
505 foreach ($short_code as $name => $value) {
506 if (is_scalar($value)) {
507 $to_be_glued[] = $name . '=' . $value;
508 }
509 }
510 if (!empty($pagination['next-token'])) {
511 $to_be_glued[] = 'next_token=' . $pagination['next-token'];
512 }
513 $to_be_glued = implode('&', $to_be_glued);
514 $to_be_glued = esc_attr($to_be_glued);
515 }
516
517 $pagination_data .= ' data-photonic-stream-query="' . $to_be_glued . '"';
518 $columns_data = ' data-photonic-gallery-columns="' . $columns . '"';
519 return [$pagination_data, $pagination, $columns_data];
520 }
521
522 /**
523 * Returns the thumbnail effect that should be used for a gallery. Not all effects can be used by all types of layouts.
524 *
525 * @param $short_code
526 * @param $layout
527 * @param $title_position
528 * @return string
529 */
530 private function get_thumbnail_effect($short_code, $layout, $title_position) {
531 if (!empty($short_code['thumbnail_effect'])) {
532 $effect = $short_code['thumbnail_effect'];
533 }
534 else {
535 global $photonic_standard_thumbnail_effect, $photonic_justified_thumbnail_effect, $photonic_mosaic_thumbnail_effect, $photonic_masonry_thumbnail_effect;
536 $effect = $layout == 'mosaic' ? $photonic_mosaic_thumbnail_effect :
537 ($layout == 'masonry' ? $photonic_masonry_thumbnail_effect :
538 ($layout == 'random' ? $photonic_justified_thumbnail_effect :
539 $photonic_standard_thumbnail_effect));
540 }
541
542 if ($layout == 'circle' && $effect != 'opacity') { // "Zoom" doesn't work for circle
543 $thumbnail_effect = 'none';
544 }
545 else if (($layout == 'square' || $layout == 'launch' || $layout == 'masonry') && $title_position == 'below') { // For these combinations, Zoom doesn't work
546 $thumbnail_effect = 'none';
547 }
548 else {
549 $thumbnail_effect = $effect;
550 }
551 return apply_filters('photonic_thumbnail_effect', $thumbnail_effect, $short_code, $layout, $title_position);
552 }
553 }