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