PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.1.4
Admin Columns v7.1.4
7.1.4 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 / Setting / Control / Input / OptionFactory.php
codepress-admin-columns / classes / Setting / Control / Input Last commit date
Custom.php 4 days ago Number.php 4 days ago Open.php 4 days ago OpenFactory.php 4 days ago Option.php 4 days ago OptionFactory.php 4 days ago
OptionFactory.php
117 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\Setting\Control\Input;
6
7 use AC\Setting\AttributeCollection;
8 use AC\Setting\Control\OptionCollection;
9 use AC\Setting\Control\OptionCollectionFactory\ToggleOptionCollection;
10 use AC\Setting\Type\Attribute;
11
12 final class OptionFactory
13 {
14 public static function create_select(
15 string $name,
16 OptionCollection $options,
17 $default = null,
18 ?string $placeholder = null,
19 ?bool $multiple = null,
20 ?AttributeCollection $attributes = null
21 ): Option {
22 return new Option(
23 $name,
24 'select',
25 $options,
26 $default,
27 $placeholder,
28 $multiple,
29 $attributes
30 );
31 }
32
33 public static function create_select_remote(
34 string $name,
35 string $handler,
36 $default = null,
37 array $data = [],
38 ?string $placeholder = null,
39 ?bool $multiple = null,
40 ?AttributeCollection $attributes = null
41 ): Option {
42 if (null === $attributes) {
43 $attributes = new AttributeCollection();
44 }
45
46 $attributes->add(
47 new Attribute(
48 'data-handler',
49 $handler
50 )
51 );
52
53 $default_params = '{}';
54 $params = $default_params;
55
56 if ($data) {
57 $params = json_encode($data) ?: $default_params;
58 }
59
60 $attributes->add(
61 new Attribute(
62 'data-params',
63 $params
64 )
65 );
66
67 return new Option(
68 $name,
69 'select_remote',
70 new OptionCollection(),
71 $default,
72 $placeholder,
73 $multiple,
74 $attributes
75 );
76 }
77
78 public static function create_radio(
79 string $name,
80 OptionCollection $options,
81 ?string $default = null,
82 ?AttributeCollection $attributes = null
83 ): Option {
84 return new Option(
85 $name,
86 'radio',
87 $options,
88 $default,
89 null,
90 null,
91 $attributes
92 );
93 }
94
95 public static function create_toggle(
96 string $name,
97 ?OptionCollection $options = null,
98 ?string $default = null,
99 ?AttributeCollection $attributes = null
100 ): Option {
101 if (null === $options) {
102 $options = (new ToggleOptionCollection())->create();
103 }
104
105 return new Option(
106 $name,
107 'toggle',
108 $options,
109 $default,
110 null,
111 null,
112 $attributes
113 );
114 }
115
116 }
117