PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.36
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.36
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_Anchor.php

Grid_Anchor.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.36, at Components/Grid_Anchor.php

62 lines 1.7 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_Figure.php';
10
11 class Grid_Anchor implements Printable {
12 public string $href = '';
13 public string $id = '';
14 public array $classes = [];
15 public array $rel = [];
16 public string $title = '';
17 public array $data = [];
18 public string $figcaption = '';
19
20 public string $indent = '';
21
22 /**
23 * @var Grid_Image $image
24 */
25 public $image;
26
27 public function html(Base $module, Core_Layout $layout, bool $print = false): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
28 $data_pieces = array_map(
29 function (string $key, string $value): string {
30 return $key . '="' . $value . '"';
31 },
32 array_keys($this->data),
33 array_values($this->data)
34 );
35 $data_attributes = implode(' ', $data_pieces); // includes target='_blank', if needed
36
37 $classes = esc_attr(implode(' ', $this->classes));
38
39 $rel = '';
40 if (!empty($this->rel)) {
41 $rel = "rel='" . esc_attr(implode(' ', $this->rel)) . "'";
42 }
43
44 $id = '';
45 if (!empty($this->id)) {
46 $id = "id='" . esc_attr($this->id) . "'";
47 }
48
49 $ret = "{$this->indent}\t\t<a href='{$this->href}' title='{$this->title}' $rel class='$classes' $id $data_attributes>\n";
50 $ret .= $this->indent . "\t\t\t" . $this->image->html($module, $layout) . "\n";
51 if (!empty($this->figcaption)) {
52 $ret .= $this->indent . "\t\t\t" . $this->figcaption . "\n";
53 }
54 $ret .= "{$this->indent}\t\t</a>\n";
55
56 if ($print) {
57 echo wp_kses($ret, Photonic::$safe_tags);
58 }
59 return wp_kses($ret, Photonic::$safe_tags);
60 }
61 }
62