PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.0.5
JetFormBuilder — Dynamic Blocks Form Builder v2.0.5
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 / includes / admin / editor.php
jetformbuilder / includes / admin Last commit date
buttons 4 years ago exceptions 4 years ago notices 4 years ago pages 4 years ago single-pages 4 years ago table-views 4 years ago tabs-handlers 4 years ago vui-boxes 4 years ago admin-page-interface.php 4 years ago admin-page-trait.php 4 years ago editor.php 4 years ago table-advanced-record-prepare-trait.php 4 years ago table-record-prepare-trait.php 4 years ago
editor.php
436 lines
1 <?php
2
3 namespace Jet_Form_Builder\Admin;
4
5 use Jet_Form_Builder\Actions\Condition_Manager;
6 use Jet_Form_Builder\Admin\Tabs_Handlers\Tab_Handler_Manager;
7 use Jet_Form_Builder\Classes\Http\Utm_Url;
8 use Jet_Form_Builder\Classes\Tools;
9 use Jet_Form_Builder\Gateways\Gateway_Manager;
10 use Jet_Form_Builder\Plugin;
11
12 /**
13 * Form editor class
14 * Thanks Tom J Nowell for initial editor idea and inspiration!
15 */
16
17 // If this file is called directly, abort.
18 if ( ! defined( 'WPINC' ) ) {
19 die;
20 }
21
22 /**
23 * Define Editor class
24 */
25 class Editor {
26
27 const EDITOR_HANDLE = 'jet-form-builder-editor';
28 const EDITOR_PACKAGE_HANDLE = 'jet-form-builder-editor-package';
29
30 public function __construct() {
31 add_action( 'enqueue_block_editor_assets', array( $this, 'admin_assets' ) );
32 }
33
34 /**
35 * Register admin assets
36 *
37 * @return void [type] [description]
38 */
39 public function admin_assets() {
40 if ( jet_form_builder()->post_type->is_form_editor ) {
41 $this->enqueue_assets();
42 } else {
43 $this->enqueue_form_assets();
44 }
45 }
46
47 /**
48 * Returns taxonomies list for the config
49 *
50 * @return [type] [description]
51 */
52 public function get_taxonomies_list() {
53
54 $taxonomies = get_taxonomies( array(), 'objects' );
55
56 $result = array();
57
58 foreach ( $taxonomies as $tax ) {
59 $result[] = array(
60 'value' => $tax->name,
61 'label' => sprintf( '%1$s (%2$s)', $tax->label, $tax->name ),
62 );
63 }
64
65 return $result;
66
67 }
68
69 public function get_preset_config() {
70 return apply_filters(
71 'jet-form-builder/editor/preset-config',
72 array(
73 'global_fields' => array(
74 array(
75 'name' => 'from',
76 'label' => __( 'Source:', 'jet-form-builder' ),
77 'type' => 'select',
78 'options' => Tools::with_placeholder(
79 array(
80 array(
81 'value' => 'post',
82 'label' => __( 'Post', 'jet-form-builder' ),
83 ),
84 array(
85 'value' => 'user',
86 'label' => __( 'User', 'jet-form-builder' ),
87 ),
88 array(
89 'value' => 'query_var',
90 'label' => __( 'URL Query Variable', 'jet-form-builder' ),
91 ),
92 )
93 ),
94 ),
95 array(
96 'name' => 'post_from',
97 'label' => __( 'Get post ID from:', 'jet-form-builder' ),
98 'type' => 'select',
99 'options' => Tools::with_placeholder(
100 array(
101 array(
102 'value' => 'current_post',
103 'label' => __( 'Current post', 'jet-form-builder' ),
104 ),
105 array(
106 'value' => 'query_var',
107 'label' => __( 'URL Query Variable', 'jet-form-builder' ),
108 ),
109 )
110 ),
111 'condition' => array(
112 'field' => 'from',
113 'value' => 'post',
114 ),
115 ),
116 array(
117 'name' => 'user_from',
118 'label' => __( 'Get user ID from:', 'jet-form-builder' ),
119 'type' => 'select',
120 'options' => Tools::with_placeholder(
121 array(
122 array(
123 'value' => 'current_user',
124 'label' => __( 'Current user', 'jet-form-builder' ),
125 ),
126 array(
127 'value' => 'query_var',
128 'label' => __( 'URL Query Variable', 'jet-form-builder' ),
129 ),
130 )
131 ),
132 'condition' => array(
133 'field' => 'from',
134 'value' => 'user',
135 ),
136 ),
137 array(
138 'name' => 'query_var',
139 'label' => __( 'Query variable name:', 'jet-form-builder' ),
140 'type' => 'text',
141 'custom_condition' => 'query_var',
142 'position' => 'dynamic',
143 ),
144 ),
145 'map_fields' => array(
146 array(
147 'name' => 'key',
148 'label' => __( 'Query variable key', 'jet-form-builder' ),
149 'type' => 'text',
150 'position' => 'general',
151 'parent_condition' => array(
152 'field' => 'from',
153 'value' => 'query_var',
154 ),
155 ),
156 array(
157 'name' => 'prop',
158 'label' => __( 'Post property', 'jet-form-builder' ),
159 'type' => 'select',
160 'options' => Tools::with_placeholder(
161 array(
162 array(
163 'value' => 'ID',
164 'label' => __( 'Post ID', 'jet-form-builder' ),
165 ),
166 array(
167 'value' => 'post_title',
168 'label' => __( 'Post Title', 'jet-form-builder' ),
169 ),
170 array(
171 'value' => 'post_content',
172 'label' => __( 'Post Content', 'jet-form-builder' ),
173 ),
174 array(
175 'value' => 'post_status',
176 'label' => __( 'Post Status', 'jet-form-builder' ),
177 ),
178 array(
179 'value' => 'post_author',
180 'label' => __( 'Post Author', 'jet-form-builder' ),
181 ),
182 array(
183 'value' => 'post_excerpt',
184 'label' => __( 'Post Excerpt', 'jet-form-builder' ),
185 ),
186 array(
187 'value' => 'post_date',
188 'label' => __( 'Post Date', 'jet-form-builder' ),
189 ),
190 array(
191 'value' => 'post_date_gmt',
192 'label' => __( 'Post Date GMT', 'jet-form-builder' ),
193 ),
194 array(
195 'value' => 'post_thumb',
196 'label' => __( 'Post Thumbnail', 'jet-form-builder' ),
197 ),
198 array(
199 'value' => 'post_meta',
200 'label' => __( 'Post Meta', 'jet-form-builder' ),
201 ),
202 array(
203 'value' => 'post_terms',
204 'label' => __( 'Post Terms', 'jet-form-builder' ),
205 ),
206 )
207 ),
208 'parent_condition' => array(
209 'field' => 'from',
210 'value' => 'post',
211 ),
212 ),
213 array(
214 'name' => 'key',
215 'label' => __( 'Taxonomy', 'jet-form-builder' ),
216 'type' => 'select',
217 'options' => Tools::with_placeholder( $this->get_taxonomies_list() ),
218 'parent_condition' => array(
219 'field' => 'from',
220 'value' => 'post',
221 ),
222 'condition' => array(
223 'field' => 'prop',
224 'value' => 'post_terms',
225 ),
226 ),
227 array(
228 'name' => 'key',
229 'label' => __( 'Meta field key', 'jet-form-builder' ),
230 'type' => 'text',
231 'parent_condition' => array(
232 'field' => 'from',
233 'value' => 'post',
234 ),
235 'condition' => array(
236 'field' => 'prop',
237 'value' => 'post_meta',
238 ),
239 ),
240 array(
241 'name' => 'prop',
242 'label' => __( 'User field', 'jet-form-builder' ),
243 'type' => 'select',
244 'options' => Tools::with_placeholder(
245 array(
246 array(
247 'value' => 'ID',
248 'label' => __( 'User ID', 'jet-form-builder' ),
249 ),
250 array(
251 'value' => 'user_login',
252 'label' => __( 'User Login', 'jet-form-builder' ),
253 ),
254 array(
255 'value' => 'user_email',
256 'label' => __( 'Email', 'jet-form-builder' ),
257 ),
258 array(
259 'value' => 'password',
260 'label' => __( 'Password', 'jet-form-builder' ),
261 ),
262 array(
263 'value' => 'first_name',
264 'label' => __( 'First Name', 'jet-form-builder' ),
265 ),
266 array(
267 'value' => 'last_name',
268 'label' => __( 'Last Name', 'jet-form-builder' ),
269 ),
270 array(
271 'value' => 'user_url',
272 'label' => __( 'User URL', 'jet-form-builder' ),
273 ),
274 array(
275 'value' => 'user_meta',
276 'label' => __( 'User Meta', 'jet-form-builder' ),
277 ),
278 )
279 ),
280 'parent_condition' => array(
281 'field' => 'from',
282 'value' => 'user',
283 ),
284 ),
285 array(
286 'name' => 'key',
287 'label' => __( 'Meta field key', 'jet-form-builder' ),
288 'type' => 'text',
289 'parent_condition' => array(
290 'field' => 'from',
291 'value' => 'user',
292 ),
293 'condition' => array(
294 'field' => 'prop',
295 'value' => 'user_meta',
296 ),
297 ),
298 ),
299 )
300 );
301 }
302
303 /**
304 * Enqueue editor assets
305 *
306 * @return void
307 */
308 public function enqueue_assets() {
309 do_action( 'jet-form-builder/editor-package/before', $this, self::EDITOR_PACKAGE_HANDLE );
310
311 wp_enqueue_script(
312 self::EDITOR_PACKAGE_HANDLE,
313 JET_FORM_BUILDER_URL . 'assets/js/package.js',
314 array(
315 'wp-editor',
316 'wp-core-data',
317 'wp-data',
318 'wp-block-library',
319 'wp-format-library',
320 'wp-api-fetch',
321 ),
322 JET_FORM_BUILDER_VERSION,
323 true
324 );
325
326 wp_set_script_translations(
327 self::EDITOR_PACKAGE_HANDLE,
328 'jet-form-builder',
329 Plugin::instance()->plugin_dir( 'languages' )
330 );
331
332 do_action( 'jet-form-builder/editor-assets/before', $this, self::EDITOR_HANDLE );
333
334 wp_enqueue_script(
335 self::EDITOR_HANDLE,
336 JET_FORM_BUILDER_URL . 'assets/js/editor.js',
337 array(),
338 JET_FORM_BUILDER_VERSION,
339 true
340 );
341
342 wp_enqueue_style(
343 self::EDITOR_HANDLE,
344 JET_FORM_BUILDER_URL . 'assets/css/editor.css',
345 array(
346 'media',
347 'l10n',
348 'buttons',
349 'wp-edit-blocks',
350 'wp-editor',
351 ),
352 JET_FORM_BUILDER_VERSION,
353 'all'
354 );
355
356 $conditions_settings = ( new Condition_Manager() )->get_settings();
357
358 $utm = new Utm_Url( 'wp-admin/editor-jet-form' );
359 $addons = JET_FORM_BUILDER_SITE . '/addons/';
360 $pricing = JET_FORM_BUILDER_SITE . '/pricing/';
361
362 wp_localize_script(
363 self::EDITOR_PACKAGE_HANDLE,
364 'JetFormEditorData',
365 array(
366 'presetConfig' => $this->get_preset_config(),
367 'messagesDefault' => Plugin::instance()->post_type->get_messages_default(),
368 'gateways' => Gateway_Manager::instance()->editor_data(),
369 'helpForRepeaters' => $this->get_help_for_repeaters(),
370 'global_settings' => Tab_Handler_Manager::instance()->all(),
371 'jetEngineVersion' => Tools::get_jet_engine_version(),
372 'actionConditionSettings' => $conditions_settings,
373 'argumentsSource' => Tools::get_form_settings_options(),
374 'utmLinks' => array(
375 'allProActions' => $utm->set_campaign( 'pro-actions' )->add_query( $addons ),
376 'limitResponses' => $utm->set_campaign( 'responses-pricing' )->add_query( $pricing ),
377 'scheduleForm' => $utm->set_campaign( 'schedule-pricing' )->add_query( $pricing ),
378 ),
379 'isActivePro' => jet_form_builder()->addons_manager->is_active(),
380 )
381 );
382
383 do_action( 'jet-form-builder/editor-assets/after', $this, self::EDITOR_HANDLE );
384 }
385
386 private function get_help_for_repeaters() {
387 return array(
388 'conditional_block' => array(
389 'label' => __( 'With many conditions for the block, they are checked with the AND operator', 'jet-form-builder' ),
390 ),
391 'conditional_block_or' => array(
392 'label' => __( 'With many conditions for the block, they are checked with the OR operator', 'jet-form-builder' ),
393 ),
394 'conditional_action' => array(
395 'label' => __( 'With many conditions for the action, they are checked with the AND operator', 'jet-form-builder' ),
396 ),
397 'conditional_action_or' => array(
398 'label' => __( 'With many conditions for the action, they are checked with the OR operator', 'jet-form-builder' ),
399 ),
400 );
401 }
402
403 public function enqueue_form_assets() {
404
405 $handle = 'jet-form-builder/form';
406
407 do_action( 'jet-form-builder/other-editor-assets/before', $this, $handle );
408
409 wp_register_script(
410 $handle,
411 JET_FORM_BUILDER_URL . 'assets/js/form-block.js',
412 array(
413 'wp-editor',
414 'wp-core-data',
415 'wp-data',
416 'wp-block-library',
417 'wp-format-library',
418 'wp-api-fetch',
419 ),
420 JET_FORM_BUILDER_VERSION,
421 true
422 );
423
424 wp_register_style(
425 'jet-form-builder-others',
426 Plugin::instance()->plugin_url( 'assets/css/frontend.css' ),
427 array(),
428 Plugin::instance()->get_version()
429 );
430
431 do_action( 'jet-form-builder/other-editor-assets/after', $this, $handle );
432
433 }
434
435 }
436