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