-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathclass-react.php
More file actions
103 lines (89 loc) · 2.13 KB
/
class-react.php
File metadata and controls
103 lines (89 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Frame UI Component.
*
* @package Cloudinary
*/
namespace Cloudinary\UI\Component;
use Cloudinary\Media\Gallery;
use function Cloudinary\get_plugin_instance;
/**
* Frame Component to render components only.
*
* @package Cloudinary\UI
*/
class React extends Text {
/**
* Holds the components build blueprint.
*
* @var string
*/
protected $blueprint = 'input/|app/|scripts/';
/**
* Holds the component script.
*
* @var array
*/
protected $script;
/**
* Filter the app part structure.
*
* @param array $struct The array structure.
*
* @return array
*/
protected function app( $struct ) {
$struct['attributes']['id'] = 'app_gallery_gallery_config';
$struct['render'] = true;
return $struct;
}
/**
* Filter the input parts structure.
*
* @param array $struct The array structure.
*
* @return array
*/
protected function input( $struct ) {
$struct = parent::input( $struct );
$struct['attributes']['id'] = 'gallery_settings_input';
$struct['attributes']['type'] = 'hidden';
$struct['attributes']['value'] = $this->setting->get_value();
return $struct;
}
/**
* Filter the script parts structure.
*
* @param array $struct The array structure.
*
* @return array
*/
protected function scripts( $struct ) {
$struct['element'] = null;
if ( $this->setting->has_param( 'script' ) ) {
$script_default = array(
'handle' => $this->setting->get_slug(),
'src' => '',
'depts' => array(),
'ver' => $this->setting->get_root_setting()->get_param( 'version' ),
'in_footer' => true,
);
$this->script = wp_parse_args( $this->setting->get_param( 'script' ), $script_default );
wp_enqueue_script( $this->script['slug'], $this->script['src'], $this->script['depts'], $this->script['ver'], $this->script['in_footer'] );
}
return $struct;
}
/**
* Sanitize the value.
*
* @param string $value The value to sanitize.
*
* @return array|bool|null
*/
public function sanitize_value( $value ) {
if ( is_array( $value ) ) {
return $value;
}
return json_decode( $value, true );
}
}