PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / form-builder / integrations / edit-profile-approved-by-admin.php

edit-profile-approved-by-admin.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at form-builder/integrations/edit-profile-approved-by-admin.php

110 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Edit Profile Approved by Admin ↔ Form Builder bridge.
4 *
5 * Injects `edit-profile-approved-by-admin` into field blocks and mirrors it to
6 * extraAttributes. Key already round-trips via optional_addon_properties.
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) exit;
10
11 // Loaded by wppb_fb_load_addon_integrations(); do not include directly.
12
13 /**
14 * Field-type labels that do NOT get the approval attribute.
15 * Mirrors the classic exclude list in assets/js/main.js#updateEditProfileApproval.
16 * Use this during registry build — do not call supported_field_types() then (empty registry).
17 *
18 * @return string[]
19 */
20 function wppb_in_epaa_fb_excluded_field_types() {
21 return array(
22 // Headings and structural defaults
23 'Default - Name (Heading)',
24 'Default - Contact Info (Heading)',
25 'Default - About Yourself (Heading)',
26 'Heading',
27 'HTML',
28 // Credentials and identity defaults the user can't change-via-approval
29 'Default - Username',
30 'Default - Password',
31 'Default - Repeat Password',
32 'Default - Display name publicly as',
33 // Field types that aren't editable values
34 'Checkbox (Terms and Conditions)',
35 'Input (Hidden)',
36 'Repeater',
37 'Validation',
38 'Honeypot',
39 // GDPR / consent
40 'GDPR Checkbox',
41 'GDPR Delete Button',
42 'GDPR Communication Preferences',
43 // Anti-bot challenges
44 'reCAPTCHA',
45 'Turnstile',
46 // Subscription / commerce widgets
47 'Subscription Plans',
48 'MailChimp Subscribe',
49 'Campaign Monitor Subscribe',
50 'MailPoet Subscribe',
51 'WooCommerce Customer Billing Address',
52 'WooCommerce Customer Shipping Address',
53 );
54 }
55
56 /**
57 * Field types that get the approval attribute (registry minus exclude list).
58 * Call only after registry construction; during build invert the exclude list instead.
59 *
60 * @return string[]
61 */
62 function wppb_in_epaa_fb_supported_field_types() {
63 if ( ! class_exists( 'WPPB_FB_Field_Registry' ) ) return array();
64
65 $all_types = array_keys( WPPB_FB_Field_Registry::all() );
66
67 /**
68 * Filter the EPAA-supported field-type list.
69 *
70 * @param string[] $supported Field-type labels supported by EPAA in the form builder.
71 */
72 return apply_filters(
73 'wppb_in_epaa_fb_supported_field_types',
74 array_values( array_diff( $all_types, wppb_in_epaa_fb_excluded_field_types() ) )
75 );
76 }
77
78 /**
79 * Inject `edit-profile-approved-by-admin`. Default '' matches legacy (absent = not required).
80 */
81 add_filter( 'wppb_fb_block_attributes', 'wppb_in_epaa_fb_inject_block_attributes', 10, 3 );
82 function wppb_in_epaa_fb_inject_block_attributes( $attributes, $field_type, $context ) {
83 if ( in_array( $field_type, wppb_in_epaa_fb_excluded_field_types(), true ) ) {
84 return $attributes;
85 }
86 if ( ! isset( $attributes['edit-profile-approved-by-admin'] ) ) {
87 $attributes['edit-profile-approved-by-admin'] = array( 'type' => 'string', 'default' => '' );
88 }
89 return $attributes;
90 }
91
92 /**
93 * Publish the editor extraAttributes mirror for the approval key.
94 */
95 add_action( 'wppb_fb_enqueue_editor_assets_late', 'wppb_in_epaa_fb_enqueue_editor_payload' );
96 function wppb_in_epaa_fb_enqueue_editor_payload() {
97 $supported_types = wppb_in_epaa_fb_supported_field_types();
98 if ( empty( $supported_types ) ) return;
99
100 $schema = array(
101 'edit-profile-approved-by-admin' => array( 'type' => 'string', 'default' => '' ),
102 );
103 $extra_attrs = array();
104 foreach ( $supported_types as $field_type ) {
105 $extra_attrs[ $field_type ] = $schema;
106 }
107
108 wppb_fb_extra_attributes_inline_script( $extra_attrs );
109 }
110