PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.1
JetFormBuilder — Dynamic Blocks Form Builder v3.4.1
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / framework / vue-ui / cherry-x-vue-ui.php
jetformbuilder / modules / framework / vue-ui Last commit date
assets 2 years ago components 2 years ago cherry-x-vue-ui.php 2 years ago
cherry-x-vue-ui.php
248 lines
1 <?php
2 /**
3 * Vue.js based Interface Builder module
4 *
5 * Version: 1.4.10
6 */
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 if ( ! class_exists( 'CX_Vue_UI' ) ) {
14
15 /**
16 * Class Cherry Interface Builder.
17 *
18 * @since 1.0.0
19 */
20 class CX_Vue_UI {
21
22 /**
23 * Module directory path.
24 *
25 * @since 1.0.0
26 * @access protected
27 * @var srting.
28 */
29 protected $path;
30
31 /**
32 * Module directory URL.
33 *
34 * @since 1.0.0
35 * @access protected
36 * @var srting.
37 */
38 protected $url;
39
40 /**
41 * Current instance templates path.
42 *
43 * @since 1.4.3
44 * @access protected
45 * @var srting.
46 */
47 public static $templates_path;
48
49 /**
50 * Module version
51 *
52 * @var string
53 */
54 protected $version = '1.4.10';
55
56 /**
57 * [$assets_enqueued description]
58 * @var boolean
59 */
60 protected $assets_enqueued = false;
61
62 /**
63 * CX_Vue_UI constructor.
64 *
65 * @since 1.0.0
66 * @access public
67 * @return void
68 */
69 public function __construct( array $args = array() ) {
70
71 $this->path = ! empty( $args['path'] ) ? $args['path'] : false;
72 $this->url = ! empty( $args['url'] ) ? $args['url'] : false;
73
74 if ( ! $this->path || ! $this->url ) {
75 wp_die(
76 'CX_Vue_UI not initialized. Module URL and Path should be passed into constructor',
77 'CX_Vue_UI Error'
78 );
79 }
80
81 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
82
83 }
84
85 /**
86 * Enqueue builder assets
87 *
88 * @return void
89 */
90 public function enqueue_assets() {
91
92 if ( $this->assets_enqueued ) {
93 return;
94 }
95
96 wp_enqueue_media();
97
98 $suffix = '.min';
99
100 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
101 $suffix = '';
102 }
103
104 wp_register_script(
105 'cx-vue',
106 $this->url . 'assets/js/vue' . $suffix . '.js',
107 array(),
108 '2.6.11',
109 true
110 );
111
112 wp_register_script(
113 'cx-vue-components',
114 $this->url . 'assets/js/cx-vue-ui-components.js',
115 array(),
116 $this->version,
117 true
118 );
119
120 wp_enqueue_script(
121 'cx-vue-ui',
122 $this->url . 'assets/js/cx-vue-ui.js',
123 array( 'cx-vue', 'cx-vue-components' ),
124 $this->version,
125 true
126 );
127
128 add_action( 'admin_footer', array( $this, 'print_templates' ), 0 );
129
130 $this->assets_enqueued = true;
131
132 }
133
134 /**
135 * Enqueue builder assets
136 *
137 * @return void
138 */
139 public function enqueue_assets_components() {
140
141 if ( $this->assets_enqueued ) {
142 return;
143 }
144
145 wp_enqueue_media();
146
147 $suffix = '.min';
148
149 if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
150 $suffix = '';
151 }
152
153 wp_enqueue_script(
154 'cx-vue-ui-components',
155 $this->url . 'assets/js/cx-vue-ui-components.js',
156 array(),
157 $this->version,
158 true
159 );
160
161 add_action( 'admin_footer', array( $this, 'print_templates' ), 0 );
162
163 $this->assets_enqueued = true;
164
165 }
166
167 /**
168 * Returns registered components list
169 *
170 * @return array
171 */
172 public function components_list() {
173 return apply_filters( 'cx-vue-ui/components-list', array(
174
175 // Layout elements
176 'title',
177 'collapse',
178 'component-wrapper',
179 'button',
180 'repeater',
181 'repeater-item',
182 'popup',
183 'list-table',
184 'list-table-heading',
185 'list-table-item',
186 'tabs',
187 'tabs-panel',
188 'pagination',
189 'notice',
190
191 // Form elements
192 'input',
193 'time',
194 'textarea',
195 'switcher',
196 'iconpicker',
197 'select',
198 'f-select',
199 'checkbox',
200 'radio',
201 'colorpicker',
202 'wp-media',
203 'dimensions',
204 ) );
205 }
206
207 /**
208 * Print components templates
209 *
210 * @return void
211 */
212 public function print_templates() {
213
214 $path = $this->path . 'components/*.php';
215 $whitelisted = $this->components_list();
216
217 foreach ( glob( $path ) as $file ) {
218
219 $slug = basename( $file, '.php' );
220
221 if ( ! in_array( $slug, $whitelisted ) ) {
222 continue;
223 }
224
225 ob_start();
226
227 if ( self::$templates_path && file_exists( self::$templates_path . basename( $file ) ) ) {
228 include self::$templates_path . basename( $file );
229 } else {
230 include $file;
231 }
232
233 $template = ob_get_clean();
234
235 printf(
236 '<script type="text/x-template" id="%2$s">%1$s</script>',
237 $template,
238 'cx-vui-' . $slug
239 );
240
241 }
242
243 }
244
245 }
246
247 }
248