PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 3.1
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v3.1
4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 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.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Admin / SettingsPages / DragDropBuilder / DragDropBuilder.php
wp-user-avatar / src / Admin / SettingsPages / DragDropBuilder Last commit date
Controls 5 years ago Fields 5 years ago DragDropBuilder.php 5 years ago FieldBase.php 5 years ago FieldInterface.php 5 years ago Metabox.php 5 years ago google-web-fonts.txt 5 years ago
DragDropBuilder.php
1530 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages\DragDropBuilder;
4
5 use ProfilePress\Core\Admin\SettingsPages\FormList;
6 use ProfilePress\Core\Classes\ExtensionManager as EM;
7 use ProfilePress\Core\Classes\FormRepository as FR;
8 use ProfilePress\Core\Classes\PROFILEPRESS_sql;
9 use ProfilePress\Core\Themes\DragDrop\AbstractTheme;
10
11 class DragDropBuilder
12 {
13 public $saved_data = [];
14
15 public $form_type;
16
17 public $form_class;
18
19 public $form_id;
20
21 public $meta_box_settings;
22
23 /** @var AbstractTheme */
24 public $theme_class_instance;
25
26 public function __construct()
27 {
28 if ( ! $this->is_drag_drop_page()) return;
29
30 Fields\Init::init();
31
32 $this->form_id = absint($_GET['id']);
33 $this->form_type = sanitize_text_field($_GET['form-type']);
34
35 $this->form_class = FR::get_form_meta($this->form_id, $this->form_type, FR::FORM_CLASS);
36
37 $this->saved_data = apply_filters('ppress_form_builder_saved_data', []);
38
39 add_action('admin_footer', [$this, 'form_fields_json']);
40 add_action('admin_footer', [$this, 'print_template']);
41 add_action('admin_footer', [$this, 'icon_picker_template']);
42
43 add_action('admin_init', [$this, 'save_form']);
44
45 add_action('admin_enqueue_scripts', [$this, 'js_wp_editor_enqueue']);
46 add_action('admin_footer', [$this, 'js_wp_editor']);
47 }
48
49 public function standard_fields()
50 {
51 return apply_filters('ppress_form_builder_standard_fields', []);
52 }
53
54 public function extra_fields()
55 {
56 return apply_filters('ppress_form_builder_extra_fields', []);
57 }
58
59 public function defined_fields($woocommerce_field = false)
60 {
61 if ( ! in_array($this->form_type, [FR::REGISTRATION_TYPE, FR::EDIT_PROFILE_TYPE])) return [];
62
63 $custom_fields = PROFILEPRESS_sql::get_profile_custom_fields();
64
65 $contact_infos = PROFILEPRESS_sql::get_contact_info_fields();
66
67 $fields = [];
68
69 if ($woocommerce_field === false) {
70 foreach ($contact_infos as $field_key => $label) {
71
72 // field key and type are being added to make the key unique for each defined fields array.
73 $tag_name = $this->form_type == FR::REGISTRATION_TYPE ? 'reg' : 'edit-profile';
74 $key = $tag_name . '-cpf-' . $field_key . 'contactinfo';
75 $definedFieldType = 'input';
76
77 $fields[$key] = [
78 'definedFieldKey' => $field_key,
79 'definedFieldType' => $definedFieldType,
80 'fieldTitle' => $label,
81 'label' => $label,
82 'placeholder' => $label,
83 'fieldIcon' => '<span class="dashicons dashicons-portfolio"></span>',
84 ];
85 }
86 }
87
88 foreach ($custom_fields as $custom_field) {
89
90 // field key and type are being added to make the key unique for each defined fields array.
91 $tag_name = $this->form_type == FR::REGISTRATION_TYPE ? 'reg' : 'edit-profile';
92 $key = $tag_name . '-cpf-' . $custom_field['field_key'] . $custom_field['type'];
93 $definedFieldType = $custom_field['type'];
94
95 if ($definedFieldType == 'password') {
96 $definedFieldType = 'password';
97 }
98
99 if (in_array($definedFieldType, ['tel', 'text', 'number', 'email', 'hidden', 'file', 'textarea'])) {
100 $definedFieldType = 'input';
101 }
102
103 if (in_array($definedFieldType, ['country', 'select'])) {
104 $definedFieldType = 'select';
105 }
106
107 $field_key = $custom_field['field_key'];
108
109 if (false == $woocommerce_field && in_array($field_key, ppress_woocommerce_billing_shipping_fields())) continue;
110
111 if ($woocommerce_field !== false) {
112
113 $bucket = 'billing' == $woocommerce_field ? ppress_woocommerce_billing_fields() : ppress_woocommerce_shipping_fields();
114
115 if ( ! in_array($field_key, $bucket)) continue;
116 }
117
118 $title = $custom_field['label_name'];
119
120 $fields[$key] = [
121 'definedFieldKey' => $field_key,
122 'definedFieldType' => $definedFieldType,
123 'fieldTitle' => $title . ($woocommerce_field !== false ? (sprintf(' (WC%s)', 'billing' == $woocommerce_field ? 'BA' : 'SA')) : ''),
124 'fieldBarTitle' => $title,
125 'label' => $title,
126 'placeholder' => $title,
127 'fieldIcon' => '<span class="dashicons dashicons-portfolio"></span>',
128 ];
129 }
130
131 return apply_filters(sprintf('pp_form_builder_defined%s_fields', $woocommerce_field ? "_{$woocommerce_field}" : ''), $fields);
132 }
133
134 public function is_drag_drop_page()
135 {
136 return isset($_GET['view']) && $_GET['view'] == 'drag-drop-builder';
137 }
138
139 public function save_form()
140 {
141 if ( ! current_user_can('manage_options') || ! isset($_POST['pp_form_builder_fields_settings']) || ! ppress_verify_nonce()) return;
142
143 $constants = apply_filters(
144 'ppress_form_builder_metabox_field_as_form_meta',
145 array_values((new \ReflectionClass('ProfilePress\Core\Classes\FormRepository'))->getConstants())
146 );
147
148 $form_settings_meta = [];
149 $metabox_settings = [];
150 foreach ($_POST as $key => $value) {
151 if (in_array($key, ['wp_csa_nonce', 'pp_form_title', 'pp_form_builder_fields_settings', '_wpnonce', '_wp_http_referer'])) continue;
152 if (in_array($key, $constants)) {
153 $form_settings_meta[$key] = trim(stripslashes($value));
154 continue;
155 }
156
157 $metabox_settings[$key] = is_array($value) ? array_map('stripslashes', $value) : trim(stripslashes($value));
158 }
159
160 if (empty($_POST['pp_form_title'])) {
161 add_settings_error(
162 'pp_drag_drop_builder_notice',
163 'form_title_empty',
164 esc_html__('Form title cannot empty')
165 );
166
167 return;
168 }
169
170 FR::update_form(
171 $this->form_id,
172 $this->form_type,
173 sanitize_text_field($_POST['pp_form_title']),
174 array_merge($form_settings_meta, [
175 FR::FORM_BUILDER_FIELDS_SETTINGS => stripslashes($_POST['pp_form_builder_fields_settings']),
176 FR::METABOX_FORM_BUILDER_SETTINGS => $metabox_settings
177 ])
178 );
179
180 add_settings_error(
181 'pp_drag_drop_builder_notice',
182 'changes_saved',
183 esc_html__('Changes saved'),
184 'success'
185 );
186 }
187
188 private function is_custom_field_enabled()
189 {
190 return EM::is_enabled(EM::CUSTOM_FIELDS);
191 }
192
193 public function form_fields_json()
194 {
195 printf(
196 '<script type="text/javascript">
197 var pp_form_builder_standard_fields = %1$s;
198 // extend copies over the new attribute to pp_form_builder_standard_fields
199 // hence the need to duplicate this
200 var old_pp_form_builder_standard_fields = %1$s;
201 var pp_form_builder_extra_fields = %2$s;
202 var pp_form_builder_defined_fields = %3$s;
203 var pp_form_builder_wc_billing_fields = %4$s;
204 var pp_form_builder_wc_shipping_fields = %5$s;
205 var pp_form_builder_combined_fields = _.extend(
206 old_pp_form_builder_standard_fields,
207 pp_form_builder_extra_fields,
208 pp_form_builder_defined_fields,
209 pp_form_builder_wc_billing_fields,
210 pp_form_builder_wc_shipping_fields
211 );
212 var pp_form_builder_fields_settings = %6$s;
213 var pp_form_builder_fields_multiple_addition = %7$s;
214 </script>',
215 json_encode($this->standard_fields()),
216 $this->is_custom_field_enabled() ? json_encode($this->extra_fields()) : '{}',
217 $this->is_custom_field_enabled() ? json_encode($this->defined_fields()) : '{}',
218 $this->is_custom_field_enabled() ? json_encode($this->defined_fields('billing')) : '{}',
219 $this->is_custom_field_enabled() ? json_encode($this->defined_fields('shipping')) : '{}',
220 FR::dnd_form_fields_json($this->form_id, $this->form_type, call_user_func([$this->theme_class_instance, 'default_fields_settings'])),
221 json_encode(apply_filters('ppress_form_builder_fields_multiple_addition', ['profile-cpf', 'pp-custom-html']))
222 );
223 }
224
225 public function icon_picker_template()
226 {
227 $icons = [
228 '3d_rotation',
229 'ac_unit',
230 'access_alarm',
231 'access_alarms',
232 'access_time',
233 'accessibility',
234 'accessible',
235 'account_balance',
236 'account_balance_wallet',
237 'account_box',
238 'account_circle',
239 'adb',
240 'add',
241 'add_a_photo',
242 'add_alarm',
243 'add_alert',
244 'add_box',
245 'add_circle',
246 'add_circle_outline',
247 'add_location',
248 'add_shopping_cart',
249 'add_to_photos',
250 'add_to_queue',
251 'adjust',
252 'airline_seat_flat',
253 'airline_seat_flat_angled',
254 'airline_seat_individual_suite',
255 'airline_seat_legroom_extra',
256 'airline_seat_legroom_normal',
257 'airline_seat_legroom_reduced',
258 'airline_seat_recline_extra',
259 'airline_seat_recline_normal',
260 'airplanemode_active',
261 'airplanemode_inactive',
262 'airplay',
263 'airport_shuttle',
264 'alarm',
265 'alarm_add',
266 'alarm_off',
267 'alarm_on',
268 'album',
269 'all_inclusive',
270 'all_out',
271 'android',
272 'announcement',
273 'apps',
274 'archive',
275 'arrow_back',
276 'arrow_downward',
277 'arrow_drop_down',
278 'arrow_drop_down_circle',
279 'arrow_drop_up',
280 'arrow_forward',
281 'arrow_upward',
282 'art_track',
283 'aspect_ratio',
284 'assessment',
285 'assignment',
286 'assignment_ind',
287 'assignment_late',
288 'assignment_return',
289 'assignment_returned',
290 'assignment_turned_in',
291 'assistant',
292 'assistant_photo',
293 'attach_file',
294 'attach_money',
295 'attachment',
296 'audiotrack',
297 'autorenew',
298 'av_timer',
299 'backspace',
300 'backup',
301 'battery_alert',
302 'battery_charging_full',
303 'battery_full',
304 'battery_std',
305 'battery_unknown',
306 'beach_access',
307 'beenhere',
308 'block',
309 'bluetooth',
310 'bluetooth_audio',
311 'bluetooth_connected',
312 'bluetooth_disabled',
313 'bluetooth_searching',
314 'blur_circular',
315 'blur_linear',
316 'blur_off',
317 'blur_on',
318 'book',
319 'bookmark',
320 'bookmark_border',
321 'border_all',
322 'border_bottom',
323 'border_clear',
324 'border_color',
325 'border_horizontal',
326 'border_inner',
327 'border_left',
328 'border_outer',
329 'border_right',
330 'border_style',
331 'border_top',
332 'border_vertical',
333 'branding_watermark',
334 'brightness_1',
335 'brightness_2',
336 'brightness_3',
337 'brightness_4',
338 'brightness_5',
339 'brightness_6',
340 'brightness_7',
341 'brightness_auto',
342 'brightness_high',
343 'brightness_low',
344 'brightness_medium',
345 'broken_image',
346 'brush',
347 'bubble_chart',
348 'bug_report',
349 'build',
350 'burst_mode',
351 'business',
352 'business_center',
353 'cached',
354 'cake',
355 'call',
356 'call_end',
357 'call_made',
358 'call_merge',
359 'call_missed',
360 'call_missed_outgoing',
361 'call_received',
362 'call_split',
363 'call_to_action',
364 'camera',
365 'camera_alt',
366 'camera_enhance',
367 'camera_front',
368 'camera_rear',
369 'camera_roll',
370 'cancel',
371 'card_giftcard',
372 'card_membership',
373 'card_travel',
374 'casino',
375 'cast',
376 'cast_connected',
377 'center_focus_strong',
378 'center_focus_weak',
379 'change_history',
380 'chat',
381 'chat_bubble',
382 'chat_bubble_outline',
383 'check',
384 'check_box',
385 'check_box_outline_blank',
386 'check_circle',
387 'chevron_left',
388 'chevron_right',
389 'child_care',
390 'child_friendly',
391 'chrome_reader_mode',
392 'class',
393 'clear',
394 'clear_all',
395 'close',
396 'closed_caption',
397 'cloud',
398 'cloud_circle',
399 'cloud_done',
400 'cloud_download',
401 'cloud_off',
402 'cloud_queue',
403 'cloud_upload',
404 'code',
405 'collections',
406 'collections_bookmark',
407 'color_lens',
408 'colorize',
409 'comment',
410 'compare',
411 'compare_arrows',
412 'computer',
413 'confirmation_number',
414 'contact_mail',
415 'contact_phone',
416 'contacts',
417 'content_copy',
418 'content_cut',
419 'content_paste',
420 'control_point',
421 'control_point_duplicate',
422 'copyright',
423 'create',
424 'create_new_folder',
425 'credit_card',
426 'crop',
427 'crop_16_9',
428 'crop_3_2',
429 'crop_5_4',
430 'crop_7_5',
431 'crop_din',
432 'crop_free',
433 'crop_landscape',
434 'crop_original',
435 'crop_portrait',
436 'crop_rotate',
437 'crop_square',
438 'dashboard',
439 'data_usage',
440 'date_range',
441 'dehaze',
442 'delete',
443 'delete_forever',
444 'delete_sweep',
445 'description',
446 'desktop_mac',
447 'desktop_windows',
448 'details',
449 'developer_board',
450 'developer_mode',
451 'device_hub',
452 'devices',
453 'devices_other',
454 'dialer_sip',
455 'dialpad',
456 'directions',
457 'directions_bike',
458 'directions_boat',
459 'directions_bus',
460 'directions_car',
461 'directions_railway',
462 'directions_run',
463 'directions_subway',
464 'directions_transit',
465 'directions_walk',
466 'disc_full',
467 'dns',
468 'do_not_disturb',
469 'do_not_disturb_alt',
470 'do_not_disturb_off',
471 'do_not_disturb_on',
472 'dock',
473 'domain',
474 'done',
475 'done_all',
476 'donut_large',
477 'donut_small',
478 'drafts',
479 'drag_handle',
480 'drive_eta',
481 'dvr',
482 'edit',
483 'edit_location',
484 'eject',
485 'email',
486 'enhanced_encryption',
487 'equalizer',
488 'error',
489 'error_outline',
490 'euro_symbol',
491 'ev_station',
492 'event',
493 'event_available',
494 'event_busy',
495 'event_note',
496 'event_seat',
497 'exit_to_app',
498 'expand_less',
499 'expand_more',
500 'explicit',
501 'explore',
502 'exposure',
503 'exposure_neg_1',
504 'exposure_neg_2',
505 'exposure_plus_1',
506 'exposure_plus_2',
507 'exposure_zero',
508 'extension',
509 'face',
510 'fast_forward',
511 'fast_rewind',
512 'favorite',
513 'favorite_border',
514 'featured_play_list',
515 'featured_video',
516 'feedback',
517 'fiber_dvr',
518 'fiber_manual_record',
519 'fiber_new',
520 'fiber_pin',
521 'fiber_smart_record',
522 'file_download',
523 'file_upload',
524 'filter',
525 'filter_1',
526 'filter_2',
527 'filter_3',
528 'filter_4',
529 'filter_5',
530 'filter_6',
531 'filter_7',
532 'filter_8',
533 'filter_9',
534 'filter_9_plus',
535 'filter_b_and_w',
536 'filter_center_focus',
537 'filter_drama',
538 'filter_frames',
539 'filter_hdr',
540 'filter_list',
541 'filter_none',
542 'filter_tilt_shift',
543 'filter_vintage',
544 'find_in_page',
545 'find_replace',
546 'fingerprint',
547 'first_page',
548 'fitness_center',
549 'flag',
550 'flare',
551 'flash_auto',
552 'flash_off',
553 'flash_on',
554 'flight',
555 'flight_land',
556 'flight_takeoff',
557 'flip',
558 'flip_to_back',
559 'flip_to_front',
560 'folder',
561 'folder_open',
562 'folder_shared',
563 'folder_special',
564 'font_download',
565 'format_align_center',
566 'format_align_justify',
567 'format_align_left',
568 'format_align_right',
569 'format_bold',
570 'format_clear',
571 'format_color_fill',
572 'format_color_reset',
573 'format_color_text',
574 'format_indent_decrease',
575 'format_indent_increase',
576 'format_italic',
577 'format_line_spacing',
578 'format_list_bulleted',
579 'format_list_numbered',
580 'format_paint',
581 'format_quote',
582 'format_shapes',
583 'format_size',
584 'format_strikethrough',
585 'format_textdirection_l_to_r',
586 'format_textdirection_r_to_l',
587 'format_underlined',
588 'forum',
589 'forward',
590 'forward_10',
591 'forward_30',
592 'forward_5',
593 'free_breakfast',
594 'fullscreen',
595 'fullscreen_exit',
596 'functions',
597 'g_translate',
598 'gamepad',
599 'games',
600 'gavel',
601 'gesture',
602 'get_app',
603 'gif',
604 'golf_course',
605 'gps_fixed',
606 'gps_not_fixed',
607 'gps_off',
608 'grade',
609 'gradient',
610 'grain',
611 'graphic_eq',
612 'grid_off',
613 'grid_on',
614 'group',
615 'group_add',
616 'group_work',
617 'hd',
618 'hdr_off',
619 'hdr_on',
620 'hdr_strong',
621 'hdr_weak',
622 'headset',
623 'headset_mic',
624 'healing',
625 'hearing',
626 'help',
627 'help_outline',
628 'high_quality',
629 'highlight',
630 'highlight_off',
631 'history',
632 'home',
633 'hot_tub',
634 'hotel',
635 'hourglass_empty',
636 'hourglass_full',
637 'http',
638 'https',
639 'image',
640 'image_aspect_ratio',
641 'import_contacts',
642 'import_export',
643 'important_devices',
644 'inbox',
645 'indeterminate_check_box',
646 'info',
647 'info_outline',
648 'input',
649 'insert_chart',
650 'insert_comment',
651 'insert_drive_file',
652 'insert_emoticon',
653 'insert_invitation',
654 'insert_link',
655 'insert_photo',
656 'invert_colors',
657 'invert_colors_off',
658 'iso',
659 'keyboard',
660 'keyboard_arrow_down',
661 'keyboard_arrow_left',
662 'keyboard_arrow_right',
663 'keyboard_arrow_up',
664 'keyboard_backspace',
665 'keyboard_capslock',
666 'keyboard_hide',
667 'keyboard_return',
668 'keyboard_tab',
669 'keyboard_voice',
670 'kitchen',
671 'label',
672 'label_outline',
673 'landscape',
674 'language',
675 'laptop',
676 'laptop_chromebook',
677 'laptop_mac',
678 'laptop_windows',
679 'last_page',
680 'launch',
681 'layers',
682 'layers_clear',
683 'leak_add',
684 'leak_remove',
685 'lens',
686 'library_add',
687 'library_books',
688 'library_music',
689 'lightbulb_outline',
690 'line_style',
691 'line_weight',
692 'linear_scale',
693 'link',
694 'linked_camera',
695 'list',
696 'live_help',
697 'live_tv',
698 'local_activity',
699 'local_airport',
700 'local_atm',
701 'local_bar',
702 'local_cafe',
703 'local_car_wash',
704 'local_convenience_store',
705 'local_dining',
706 'local_drink',
707 'local_florist',
708 'local_gas_station',
709 'local_grocery_store',
710 'local_hospital',
711 'local_hotel',
712 'local_laundry_service',
713 'local_library',
714 'local_mall',
715 'local_movies',
716 'local_offer',
717 'local_parking',
718 'local_pharmacy',
719 'local_phone',
720 'local_pizza',
721 'local_play',
722 'local_post_office',
723 'local_printshop',
724 'local_see',
725 'local_shipping',
726 'local_taxi',
727 'location_city',
728 'location_disabled',
729 'location_off',
730 'location_on',
731 'location_searching',
732 'lock',
733 'lock_open',
734 'lock_outline',
735 'looks',
736 'looks_3',
737 'looks_4',
738 'looks_5',
739 'looks_6',
740 'looks_one',
741 'looks_two',
742 'loop',
743 'loupe',
744 'low_priority',
745 'loyalty',
746 'mail',
747 'mail_outline',
748 'map',
749 'markunread',
750 'markunread_mailbox',
751 'memory',
752 'menu',
753 'merge_type',
754 'message',
755 'mic',
756 'mic_none',
757 'mic_off',
758 'mms',
759 'mode_comment',
760 'mode_edit',
761 'monetization_on',
762 'money_off',
763 'monochrome_photos',
764 'mood',
765 'mood_bad',
766 'more',
767 'more_horiz',
768 'more_vert',
769 'motorcycle',
770 'mouse',
771 'move_to_inbox',
772 'movie',
773 'movie_creation',
774 'movie_filter',
775 'multiline_chart',
776 'music_note',
777 'music_video',
778 'my_location',
779 'nature',
780 'nature_people',
781 'navigate_before',
782 'navigate_next',
783 'navigation',
784 'near_me',
785 'network_cell',
786 'network_check',
787 'network_locked',
788 'network_wifi',
789 'new_releases',
790 'next_week',
791 'nfc',
792 'no_encryption',
793 'no_sim',
794 'not_interested',
795 'note',
796 'note_add',
797 'notifications',
798 'notifications_active',
799 'notifications_none',
800 'notifications_off',
801 'notifications_paused',
802 'offline_pin',
803 'ondemand_video',
804 'opacity',
805 'open_in_browser',
806 'open_in_new',
807 'open_with',
808 'pages',
809 'pageview',
810 'palette',
811 'pan_tool',
812 'panorama',
813 'panorama_fish_eye',
814 'panorama_horizontal',
815 'panorama_vertical',
816 'panorama_wide_angle',
817 'party_mode',
818 'pause',
819 'pause_circle_filled',
820 'pause_circle_outline',
821 'payment',
822 'people',
823 'people_outline',
824 'perm_camera_mic',
825 'perm_contact_calendar',
826 'perm_data_setting',
827 'perm_device_information',
828 'perm_identity',
829 'perm_media',
830 'perm_phone_msg',
831 'perm_scan_wifi',
832 'person',
833 'person_add',
834 'person_outline',
835 'person_pin',
836 'person_pin_circle',
837 'personal_video',
838 'pets',
839 'phone',
840 'phone_android',
841 'phone_bluetooth_speaker',
842 'phone_forwarded',
843 'phone_in_talk',
844 'phone_iphone',
845 'phone_locked',
846 'phone_missed',
847 'phone_paused',
848 'phonelink',
849 'phonelink_erase',
850 'phonelink_lock',
851 'phonelink_off',
852 'phonelink_ring',
853 'phonelink_setup',
854 'photo',
855 'photo_album',
856 'photo_camera',
857 'photo_filter',
858 'photo_library',
859 'photo_size_select_actual',
860 'photo_size_select_large',
861 'photo_size_select_small',
862 'picture_as_pdf',
863 'picture_in_picture',
864 'picture_in_picture_alt',
865 'pie_chart',
866 'pie_chart_outlined',
867 'pin_drop',
868 'place',
869 'play_arrow',
870 'play_circle_filled',
871 'play_circle_outline',
872 'play_for_work',
873 'playlist_add',
874 'playlist_add_check',
875 'playlist_play',
876 'plus_one',
877 'poll',
878 'polymer',
879 'pool',
880 'portable_wifi_off',
881 'portrait',
882 'power',
883 'power_input',
884 'power_settings_new',
885 'pregnant_woman',
886 'present_to_all',
887 'print',
888 'priority_high',
889 'public',
890 'publish',
891 'query_builder',
892 'question_answer',
893 'queue',
894 'queue_music',
895 'queue_play_next',
896 'radio',
897 'radio_button_checked',
898 'radio_button_unchecked',
899 'rate_review',
900 'receipt',
901 'recent_actors',
902 'record_voice_over',
903 'redeem',
904 'redo',
905 'refresh',
906 'remove',
907 'remove_circle',
908 'remove_circle_outline',
909 'remove_from_queue',
910 'remove_red_eye',
911 'remove_shopping_cart',
912 'reorder',
913 'repeat',
914 'repeat_one',
915 'replay',
916 'replay_10',
917 'replay_30',
918 'replay_5',
919 'reply',
920 'reply_all',
921 'report',
922 'report_problem',
923 'restaurant',
924 'restaurant_menu',
925 'restore',
926 'restore_page',
927 'ring_volume',
928 'room',
929 'room_service',
930 'rotate_90_degrees_ccw',
931 'rotate_left',
932 'rotate_right',
933 'rounded_corner',
934 'router',
935 'rowing',
936 'rss_feed',
937 'rv_hookup',
938 'satellite',
939 'save',
940 'scanner',
941 'schedule',
942 'school',
943 'screen_lock_landscape',
944 'screen_lock_portrait',
945 'screen_lock_rotation',
946 'screen_rotation',
947 'screen_share',
948 'sd_card',
949 'sd_storage',
950 'search',
951 'security',
952 'select_all',
953 'send',
954 'sentiment_dissatisfied',
955 'sentiment_neutral',
956 'sentiment_satisfied',
957 'sentiment_very_dissatisfied',
958 'sentiment_very_satisfied',
959 'settings',
960 'settings_applications',
961 'settings_backup_restore',
962 'settings_bluetooth',
963 'settings_brightness',
964 'settings_cell',
965 'settings_ethernet',
966 'settings_input_antenna',
967 'settings_input_component',
968 'settings_input_composite',
969 'settings_input_hdmi',
970 'settings_input_svideo',
971 'settings_overscan',
972 'settings_phone',
973 'settings_power',
974 'settings_remote',
975 'settings_system_daydream',
976 'settings_voice',
977 'share',
978 'shop',
979 'shop_two',
980 'shopping_basket',
981 'shopping_cart',
982 'short_text',
983 'show_chart',
984 'shuffle',
985 'signal_cellular_4_bar',
986 'signal_cellular_connected_no_internet_4_bar',
987 'signal_cellular_no_sim',
988 'signal_cellular_null',
989 'signal_cellular_off',
990 'signal_wifi_4_bar',
991 'signal_wifi_4_bar_lock',
992 'signal_wifi_off',
993 'sim_card',
994 'sim_card_alert',
995 'skip_next',
996 'skip_previous',
997 'slideshow',
998 'slow_motion_video',
999 'smartphone',
1000 'smoke_free',
1001 'smoking_rooms',
1002 'sms',
1003 'sms_failed',
1004 'snooze',
1005 'sort',
1006 'sort_by_alpha',
1007 'spa',
1008 'space_bar',
1009 'speaker',
1010 'speaker_group',
1011 'speaker_notes',
1012 'speaker_notes_off',
1013 'speaker_phone',
1014 'spellcheck',
1015 'star',
1016 'star_border',
1017 'star_half',
1018 'stars',
1019 'stay_current_landscape',
1020 'stay_current_portrait',
1021 'stay_primary_landscape',
1022 'stay_primary_portrait',
1023 'stop',
1024 'stop_screen_share',
1025 'storage',
1026 'store',
1027 'store_mall_directory',
1028 'straighten',
1029 'streetview',
1030 'strikethrough_s',
1031 'style',
1032 'subdirectory_arrow_left',
1033 'subdirectory_arrow_right',
1034 'subject',
1035 'subscriptions',
1036 'subtitles',
1037 'subway',
1038 'supervisor_account',
1039 'surround_sound',
1040 'swap_calls',
1041 'swap_horiz',
1042 'swap_vert',
1043 'swap_vertical_circle',
1044 'switch_camera',
1045 'switch_video',
1046 'sync',
1047 'sync_disabled',
1048 'sync_problem',
1049 'system_update',
1050 'system_update_alt',
1051 'tab',
1052 'tab_unselected',
1053 'tablet',
1054 'tablet_android',
1055 'tablet_mac',
1056 'tag_faces',
1057 'tap_and_play',
1058 'terrain',
1059 'text_fields',
1060 'text_format',
1061 'textsms',
1062 'texture',
1063 'theaters',
1064 'thumb_down',
1065 'thumb_up',
1066 'thumbs_up_down',
1067 'time_to_leave',
1068 'timelapse',
1069 'timeline',
1070 'timer',
1071 'timer_10',
1072 'timer_3',
1073 'timer_off',
1074 'title',
1075 'toc',
1076 'today',
1077 'toll',
1078 'tonality',
1079 'touch_app',
1080 'toys',
1081 'track_changes',
1082 'traffic',
1083 'train',
1084 'tram',
1085 'transfer_within_a_station',
1086 'transform',
1087 'translate',
1088 'trending_down',
1089 'trending_flat',
1090 'trending_up',
1091 'tune',
1092 'turned_in',
1093 'turned_in_not',
1094 'tv',
1095 'unarchive',
1096 'undo',
1097 'unfold_less',
1098 'unfold_more',
1099 'update',
1100 'usb',
1101 'verified_user',
1102 'vertical_align_bottom',
1103 'vertical_align_center',
1104 'vertical_align_top',
1105 'vibration',
1106 'video_call',
1107 'video_label',
1108 'video_library',
1109 'videocam',
1110 'videocam_off',
1111 'videogame_asset',
1112 'view_agenda',
1113 'view_array',
1114 'view_carousel',
1115 'view_column',
1116 'view_comfy',
1117 'view_compact',
1118 'view_day',
1119 'view_headline',
1120 'view_list',
1121 'view_module',
1122 'view_quilt',
1123 'view_stream',
1124 'view_week',
1125 'vignette',
1126 'visibility',
1127 'visibility_off',
1128 'voice_chat',
1129 'voicemail',
1130 'volume_down',
1131 'volume_mute',
1132 'volume_off',
1133 'volume_up',
1134 'vpn_key',
1135 'vpn_lock',
1136 'wallpaper',
1137 'warning',
1138 'watch',
1139 'watch_later',
1140 'wb_auto',
1141 'wb_cloudy',
1142 'wb_incandescent',
1143 'wb_iridescent',
1144 'wb_sunny',
1145 'wc',
1146 'web',
1147 'web_asset',
1148 'weekend',
1149 'whatshot',
1150 'widgets',
1151 'wifi',
1152 'wifi_lock',
1153 'wifi_tethering',
1154 'work',
1155 'wrap_text',
1156 'youtube_searched_for',
1157 'zoom_in',
1158 'zoom_out',
1159 'zoom_out_map'
1160 ];
1161 ?>
1162
1163 <script type="text/html" id="tmpl-pp-form-builder-material-icon">
1164 <# if(typeof data.icon !== "undefined" && data.icon !== "") { #>
1165 <i class="pp-form-material-icons">{{data.icon}}</i>
1166 <# } #>
1167 </script>
1168 <?php
1169
1170 printf('<div id="pp-form-material-icon-picker-tmpl-title" style="display:none;"><h2>%s</h2></div>', esc_html__('Select Icon', 'wp-user-avatar'));
1171
1172 echo '<div id="pp-form-material-icon-picker-tmpl" style="text-align: center;display: none">';
1173 ?>
1174 <div class="pp-form-material-icon-wrap" data-material-icon="">
1175 <span class="pp-form-material-icon" style="display: inline-block;"><i class="pp-form-material-icons" style="width: 24px;height: 24px;"></i></span>
1176 </div>
1177 <?php
1178 foreach ($icons as $icon) {
1179 ?>
1180 <div class="pp-form-material-icon-wrap" data-material-icon="<?= $icon ?>">
1181 <i class="pp-form-material-icons"><?= $icon ?></i>
1182 </div>
1183 <?php
1184 }
1185
1186 echo '</div>';
1187 }
1188
1189 public function print_template()
1190 {
1191 $this->sidebar_fields_block_tmpl();
1192 }
1193
1194 public function sidebar_fields_block_tmpl()
1195 {
1196 global $wp_version;
1197
1198 $standard_field_title = esc_html__('Standard Fields', 'wp-user-avatar');
1199 $extra_field_title = esc_html__('Extra Fields', 'wp-user-avatar');
1200
1201 $defined_custom_field_title = esc_html__('Custom Fields', 'wp-user-avatar');
1202 $woo_billing_field_title = esc_html__('WooCommerce Billing Address', 'wp-user-avatar');
1203 $woo_shipping_field_title = esc_html__('WooCommerce Shipping Address', 'wp-user-avatar');
1204
1205 $metabox_btn = '<button type="button" class="handlediv pp-metabox-handle"><span class="toggle-indicator"></span></button>';
1206 ?>
1207 <script type="text/html" id="tmpl-pp-form-builder-sidebar-fields-block">
1208 <# var id = 'pp-form-builder-' + data.fieldsBlockType + '-fields' #>
1209 <# var title = data.fieldsBlockType == 'standard' ? '<?= $standard_field_title; ?>' : ''; #>
1210 <# title = data.fieldsBlockType == 'extra' ? '<?= $extra_field_title; ?>' : title; #>
1211 <# title = data.fieldsBlockType == 'defined' ? '<?= $defined_custom_field_title; ?>' : title; #>
1212 <# title = data.fieldsBlockType == 'wc_billing' ? '<?= $woo_billing_field_title; ?>' : title; #>
1213 <# title = data.fieldsBlockType == 'wc_shipping' ? '<?= $woo_shipping_field_title; ?>' : title; #>
1214 <div class="postbox pp-postbox-wrap closed" id="{{ id }}">
1215 <div class="postbox-header">
1216 <?php if (version_compare($wp_version, '5.5', '<')) echo $metabox_btn; ?>
1217 <h2 class="hndle is-non-sortable">
1218 <span>{{ title }}</span></h2>
1219 <?php if (version_compare($wp_version, '5.5', '>=')) echo $metabox_btn; ?>
1220 </div>
1221 <div class="inside">
1222 <ol class="pp-form-builder-field-type">
1223 <# if(_.isEmpty(data.fields)) { #>
1224 <div>
1225 <?= sprintf(
1226 esc_html__('No custom field available. %sClick here to create one%s.'),
1227 '<a target="_blank" href="' . PPRESS_CUSTOM_FIELDS_SETTINGS_PAGE . '">', '</a>'
1228 ) ?>
1229 </div>
1230 <# } else { #>
1231 <# _.each(data.fields, function(field, key) {#>
1232 <li class="pp-draggable-field">
1233 <a href="#" class="button" data-field-category="{{{data.fieldsBlockType}}}" data-field-type="{{{ key }}}">{{{field.fieldTitle}}}</a>
1234 </li>
1235 <# }); #>
1236 <# } #>
1237 </ol>
1238 </div>
1239 </div>
1240 </script>
1241 <?php
1242 }
1243
1244 public function builder_header()
1245 {
1246 settings_errors('pp_drag_drop_builder_notice');
1247 $title = FR::get_name($this->form_id, $this->form_type);
1248 ?>
1249 <div id="titlediv">
1250 <div id="titlewrap">
1251 <label class="screen-reader-text" id="title-prompt-text" for="title"><?php _e('Enter title here', 'wp-user-avatar'); ?></label>
1252 <input type="text" name="pp_form_title" size="30" value="<?= $title ?>" id="title">
1253 <a class="pp-form-save-changes button button-primary button-large" style="margin: 2px 0 0 10px;text-align: center;" href="#"><?php _e('Save Changes', 'wp-user-avatar'); ?></a>
1254 </div>
1255 </div>
1256 <?php
1257 }
1258
1259 public function sidebar_section()
1260 {
1261 if ( ! $this->is_drag_drop_page()) return '';
1262 ob_start();
1263 ?>
1264 <div id="postbox-container-1" class="postbox-container">
1265 <div id="side-sortables" class="meta-box-sortables">
1266 <div class="pp-form-builder-sidebar-wrap">
1267 <div id="pp-form-builder-sidebar-fields-block"></div>
1268 <div class="pp-builder-action-btn-block">
1269 <a class="pp-form-save-changes button button-primary button-large" style="margin: 0 10px 0 0;vertical-align: middle;" href="#">
1270 <?php _e('Save Changes', 'wp-user-avatar'); ?>
1271 </a>
1272 <a href="<?php echo FormList::delete_url($this->form_id, $this->form_type) ?>" class="pp-form-delete button-link button-link-delete">
1273 <?php _e('Delete Form', 'wp-user-avatar'); ?>
1274 </a>
1275 </div>
1276 </div>
1277 </div>
1278
1279 <div class="pp-form-builder-field-settings-wrap">
1280 <!-- sidebar field settings goes here -->
1281 </div>
1282 </div>
1283 <?php
1284
1285 return ob_get_clean();
1286 }
1287
1288 public function admin_page()
1289 {
1290 $theme_class_instance = FR::forge_class($this->form_id, $this->form_class, $this->form_type);
1291
1292 if ( ! $theme_class_instance) {
1293 wp_safe_redirect(add_query_arg('form-type', $this->form_type, PPRESS_FORMS_SETTINGS_PAGE));
1294 exit;
1295 }
1296
1297 $this->theme_class_instance = $theme_class_instance;
1298
1299 ?>
1300 <div id="post-body-content">
1301 <?php $this->builder_header(); ?>
1302 <div id="pp-form-builder">
1303 <div class="pp-form-builder-body">
1304 <div class="pp-builder-form-content"></div>
1305 </div>
1306 </div>
1307 <input id="pp-form-builder-fields-settings" type="hidden" name="pp_form_builder_fields_settings">
1308 <?= ppress_nonce_field(); ?>
1309 </div>
1310 <?php
1311
1312 $this->meta_box();
1313
1314 do_action('ppress_drag_drop_builder_admin_page');
1315 }
1316
1317 public function registration_settings()
1318 {
1319 $wp_roles = ppress_get_editable_roles();
1320 $wp_roles = array_reduce(array_keys($wp_roles), function ($carry, $item) use ($wp_roles) {
1321 $carry[$item] = $wp_roles[$item]['name'];
1322
1323 return $carry;
1324 }, []);
1325
1326 $registration_metabox_settings = wp_list_sort(
1327 apply_filters('ppress_form_builder_meta_box_registration_settings', [
1328 [
1329 'id' => FR::SUCCESS_MESSAGE,
1330 'type' => 'text',
1331 'label' => esc_html__('Success Message', 'wp-user-avatar'),
1332 'priority' => 5
1333 ],
1334 [
1335 'id' => FR::REGISTRATION_USER_ROLE,
1336 'type' => 'select',
1337 'label' => esc_html__('New User Role', 'wp-user-avatar'),
1338 'description' => esc_html__('Role users registered through this form will be assigned.', 'wp-user-avatar'),
1339 'options' => $wp_roles,
1340 'priority' => 10
1341 ],
1342 [
1343 'id' => FR::DISABLE_USERNAME_REQUIREMENT,
1344 'type' => 'checkbox',
1345 'label' => esc_html__('Username Requirement', 'wp-user-avatar'),
1346 'checkbox_label' => esc_html__('Check to disable username requirement', 'wp-user-avatar'),
1347 'description' => esc_html__('Disable requirement for users to enter a username during registration. Usernames will automatically be generated from their email addresses.', 'wp-user-avatar'),
1348 'priority' => 15
1349 ]
1350 ]),
1351 ['priority' => 'ASC']
1352 );
1353
1354 $registration_metabox_settings['tab_title'] = esc_html__('Registration Settings', 'wp-user-avatar');
1355
1356 add_filter('ppress_form_builder_meta_box_settings', function ($settings) use ($registration_metabox_settings) {
1357 $settings['registration_settings'] = $registration_metabox_settings;
1358
1359 return $settings;
1360 });
1361 }
1362
1363 public function edit_profile_settings()
1364 {
1365 $edit_profile_metabox_settings = wp_list_sort(
1366 apply_filters('ppress_form_builder_meta_box_edit_profile_settings', [
1367 [
1368 'id' => FR::SUCCESS_MESSAGE,
1369 'type' => 'text',
1370 'label' => esc_html__('Success Message', 'wp-user-avatar'),
1371 'priority' => 5
1372 ]
1373 ]),
1374 ['priority' => 'ASC']
1375 );
1376
1377 $edit_profile_metabox_settings['tab_title'] = esc_html__('Edit Profile Settings', 'wp-user-avatar');
1378
1379 add_filter('ppress_form_builder_meta_box_settings', function ($settings) use ($edit_profile_metabox_settings) {
1380 $settings['edit_profile_settings'] = $edit_profile_metabox_settings;
1381
1382 return $settings;
1383 });
1384 }
1385
1386 public function login_settings()
1387 {
1388 $metabox_settings = wp_list_sort(
1389 apply_filters('ppress_form_builder_meta_box_login_settings', [
1390 [
1391 'id' => FR::PASSWORDLESS_LOGIN,
1392 'type' => 'checkbox',
1393 'label' => esc_html__('Passwordless Login', 'wp-user-avatar'),
1394 'checkbox_label' => esc_html__('Check to make this a passwordless login form.', 'wp-user-avatar'),
1395 'priority' => 5
1396 ]
1397 ]),
1398 ['priority' => 'ASC']
1399 );
1400
1401 $metabox_settings['tab_title'] = esc_html__('Login Settings', 'wp-user-avatar');
1402
1403 add_filter('ppress_form_builder_meta_box_settings', function ($settings) use ($metabox_settings) {
1404 $settings['login_settings'] = $metabox_settings;
1405
1406 return $settings;
1407 });
1408 }
1409
1410 public function password_reset_settings()
1411 {
1412 $metabox_settings = wp_list_sort(
1413 apply_filters('ppress_form_builder_meta_box_password_reset_settings', [
1414 [
1415 'id' => FR::SUCCESS_MESSAGE,
1416 'type' => 'text',
1417 'label' => esc_html__('Success Message', 'wp-user-avatar'),
1418 'priority' => 5
1419 ]
1420 ]),
1421 ['priority' => 'ASC']
1422 );
1423
1424 $metabox_settings['tab_title'] = esc_html__('Password Reset Settings', 'wp-user-avatar');
1425
1426 add_filter('ppress_form_builder_meta_box_settings', function ($settings) use ($metabox_settings) {
1427 $settings['password_reset_settings'] = $metabox_settings;
1428
1429 return $settings;
1430 });
1431 }
1432
1433 public function meta_box()
1434 {
1435 $method = str_replace('-', '_', $_GET['form-type']) . '_settings';
1436 if (method_exists($this, $method)) {
1437 $this->$method();
1438 }
1439
1440 $submit_button_metabox_settings = wp_list_sort(
1441 apply_filters('ppress_form_builder_meta_box_submit_button_settings', [
1442 [
1443 'id' => 'submit_button_text',
1444 'type' => 'text',
1445 'label' => esc_html__('Label', 'wp-user-avatar'),
1446 'priority' => 5
1447 ],
1448 [
1449 'id' => 'submit_button_processing_label',
1450 'type' => 'text',
1451 'label' => esc_html__('Processing Label', 'wp-user-avatar'),
1452 'priority' => 10
1453 ]
1454 ]),
1455 ['priority' => 'ASC']
1456 );
1457
1458 $submit_button_metabox_settings['tab_title'] = esc_html__('Submit Button', 'wp-user-avatar');
1459
1460 $appearance_metabox_settings = wp_list_sort(
1461 apply_filters('ppress_form_builder_meta_box_appearance_settings', []),
1462 ['priority' => 'ASC']
1463 );
1464
1465 $appearance_metabox_settings['tab_title'] = esc_html__('Appearance', 'wp-user-avatar');
1466
1467 $colors_metabox_settings = wp_list_sort(
1468 apply_filters('ppress_form_builder_meta_box_colors_settings', []),
1469 ['priority' => 'ASC']
1470 );
1471
1472 $colors_metabox_settings['tab_title'] = esc_html__('Colors', 'wp-user-avatar');
1473
1474 $this->meta_box_settings = apply_filters('ppress_form_builder_meta_box_settings', [
1475 'appearance' => $appearance_metabox_settings,
1476 'colors' => $colors_metabox_settings,
1477 'submit_button' => $submit_button_metabox_settings
1478 ], $this->form_type, $this);
1479
1480 if (in_array($this->form_type, [FR::USER_PROFILE_TYPE, FR::MEMBERS_DIRECTORY_TYPE])) {
1481 unset($this->meta_box_settings['submit_button']);
1482 }
1483
1484 (new Metabox($this->meta_box_settings, $this->theme_class_instance, $this))->build();
1485 }
1486
1487 public function js_wp_editor_enqueue()
1488 {
1489 wp_enqueue_script(
1490 'pp-wp-editor',
1491 PPRESS_ASSETS_URL . '/js/pp-wp-editor.js',
1492 ['jquery'],
1493 false,
1494 true
1495 );
1496
1497 wp_localize_script('pp-wp-editor', 'ppWPEditor_globals', array(
1498 'url' => get_home_url(),
1499 'includes_url' => includes_url(),
1500 'wpeditor_texttab_label' => __('Text', 'wp-user-avatar'),
1501 'wpeditor_visualtab_label' => __('Visual', 'wp-user-avatar'),
1502 'wpeditor_addmedia_label' => __('Add Media', 'wp-user-avatar')
1503 ));
1504 }
1505
1506 public function js_wp_editor()
1507 {
1508 // Enable rich editing for this view (Overrides 'Disable the visual editor when writing' option for current user)
1509 add_filter('user_can_richedit', '__return_true');
1510 wp_enqueue_editor();
1511 wp_enqueue_editor();
1512
1513 if ( ! empty($GLOBALS['post'])) {
1514 wp_enqueue_media(array('post' => $GLOBALS['post']->ID));
1515 } else {
1516 wp_enqueue_media();
1517 }
1518 }
1519
1520 public static function get_instance()
1521 {
1522 static $instance = null;
1523
1524 if (is_null($instance)) {
1525 $instance = new self();
1526 }
1527
1528 return $instance;
1529 }
1530 }