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