PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.33
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.33
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 / Components / Grid_Figure.php

Grid_Figure.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.33, at Components/Grid_Figure.php

65 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Photonic_Plugin\Components;
4
5 use Photonic_Plugin\Core\Photonic;
6 use Photonic_Plugin\Layouts\Core_Layout;
7 use Photonic_Plugin\Platforms\Base;
8
9 require_once 'Grid_Anchor.php';
10
11 class Grid_Figure implements Printable {
12 public string $id = '';
13 public array $classes = [];
14 public array $data = [];
15 public array $styles = [];
16 public string $video_markup = '';
17 public string $prompter_markup = '';
18 public string $indent = '';
19
20 /**
21 * @var Grid_Anchor $anchor
22 */
23 public Grid_Anchor $anchor;
24
25 public function html(Base $module, Core_Layout $layout, $print = false): string {
26 $classes = esc_attr(implode(' ', $this->classes));
27 $style = '';
28 if (!empty($this->styles)) {
29 $styles = array_map(
30 function (string $key, string $value): string {
31 return $key . ': ' . $value;
32 },
33 array_keys($this->styles),
34 array_values($this->styles)
35 );
36
37 $style = "style='" . implode('; ', $styles) . "'";
38 }
39
40 $data_pieces = array_map(
41 function (string $key, string $value): string {
42 return $key . '="' . $value . '"';
43 },
44 array_keys($this->data),
45 array_values($this->data)
46 );
47 $data_attributes = implode(' ', $data_pieces);
48
49 $id = '';
50 if (!empty($this->id)) {
51 $id = "id='" . esc_attr($this->id) . "'";
52 }
53
54 $ret = "{$this->indent}\t<figure class='$classes' $id $style $data_attributes>\n";
55 $ret .= $this->video_markup;
56 $ret .= $this->anchor->html($module, $layout);
57 $ret .= $this->prompter_markup;
58 $ret .= $this->indent . "\t</figure>\n";
59 if ($print) {
60 echo wp_kses($ret, Photonic::$safe_tags);
61 }
62 return wp_kses($ret, Photonic::$safe_tags);
63 }
64 }
65