PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.0.13
Admin Columns v7.0.13
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Value / ExtendedValueLink.php
codepress-admin-columns / classes / Value Last commit date
Extended 3 months ago ExtendedValueLink.php 3 months ago ExtendedValueLinkFactory.php 3 months ago ExtendedValueRegistry.php 3 months ago
ExtendedValueLink.php
103 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\Value;
6
7 final class ExtendedValueLink
8 {
9
10 private string $view;
11
12 private array $attributes;
13
14 /**
15 * @var mixed
16 */
17 private $id;
18
19 private string $label;
20
21 private array $params;
22
23 public function __construct(string $label, $id, string $view, array $attributes = [], array $params = [])
24 {
25 $this->view = $view;
26 $this->attributes = $attributes;
27 $this->id = $id;
28 $this->label = $label;
29 $this->params = $params;
30 }
31
32 protected function with_attribute(string $key, string $value): self
33 {
34 $this->attributes[$key] = $value;
35
36 return new self($this->label, $this->id, $this->view, $this->attributes, $this->params);
37 }
38
39 public function with_params($params): self
40 {
41 return new self($this->label, $this->id, $this->view, $this->attributes, $params);
42 }
43
44 public function with_title(string $title): self
45 {
46 return $this->with_attribute('title', $title);
47 }
48
49 public function with_edit_link(string $edit_link): self
50 {
51 return $this->with_attribute('edit_link', $edit_link);
52 }
53
54 public function with_download_link(string $download_link): self
55 {
56 return $this->with_attribute('download_link', $download_link);
57 }
58
59 public function with_view_link(string $download_link): self
60 {
61 return $this->with_attribute('view_link', $download_link);
62 }
63
64 public function with_class(string $class): self
65 {
66 return $this->with_attribute('class', $class);
67 }
68
69 public function render(): string
70 {
71 $attributes = $this->attributes;
72 $attribute_markup = [];
73
74 if (isset($attributes['title']) && $attributes['title']) {
75 $attribute_markup[] = sprintf('data-modal-title="%s"', esc_attr($attributes['title']));
76 }
77 if (isset($attributes['edit_link']) && $attributes['edit_link']) {
78 $attribute_markup[] = sprintf('data-modal-edit-link="%s"', esc_url($attributes['edit_link']));
79 }
80 if (isset($attributes['download_link']) && $attributes['download_link']) {
81 $attribute_markup[] = sprintf('data-modal-download-link="%s"', esc_url($attributes['download_link']));
82 }
83 if (isset($attributes['view_link']) && $attributes['view_link']) {
84 $attribute_markup[] = sprintf('data-modal-view-link="%s"', esc_url($attributes['view_link']));
85 }
86 if (isset($attributes['class']) && $attributes['class']) {
87 $attribute_markup[] = sprintf('data-modal-class="%s"', esc_attr($attributes['class']));
88 }
89
90 if ( ! empty($this->params)) {
91 $attribute_markup[] = sprintf('data-modal-params="%s"', esc_attr(json_encode($this->params)));
92 }
93
94 $attribute_markup[] = sprintf('data-modal-id="%s"', esc_attr($this->id));
95 $attribute_markup[] = sprintf('data-view="%s"', esc_attr($this->view));
96
97 return sprintf(
98 '<a style="border-bottom: 1px dotted;" data-modal-value %s>%s</a>',
99 implode(' ', $attribute_markup),
100 $this->label
101 );
102 }
103 }