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
← All changes | admin/general-settings.php +792 -279 3.9.64.0.3 View file →
@@ -8,9 +8,8 @@
8 8 $wppb_module_settings = get_option('wppb_module_settings');
9 9
10 10 $settings_pages['pages'] = array(
11 11 'profile-builder-general-settings' => __( 'General Settings', 'profile-builder' ),
12 - 'profile-builder-admin-bar-settings' => __( 'Admin Bar', 'profile-builder' ),
13 12 'profile-builder-content_restriction' => __( 'Content Restriction', 'profile-builder' ),
14 13 'profile-builder-private-website' => __( 'Private Website', 'profile-builder' ),
15 14 'profile-builder-toolbox-settings' => __( 'Advanced Settings', 'profile-builder' ),
16 15 );
@@ -24,16 +23,11 @@
24 23
25 24 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['shortcodes'] = __( 'Shortcodes', 'profile-builder' );
26 25 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['admin'] = __( 'Admin', 'profile-builder' );
27 26
28 - //add tab for 2FA
29 - if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists(WPPB_PAID_PLUGIN_DIR . '/features/two-factor-authentication/class-two-factor-authentication.php')) {
30 - $settings_pages['pages']['profile-builder-two-factor-authentication'] = __( 'Two-Factor Authentication', 'profile-builder' );
31 - }
32 -
33 27 //add sub-pages here for email customizer
34 28 if( file_exists( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' ) ){
35 -
29 +
36 30 $settings_pages['pages']['user-email-customizer'] = __( 'Email Customizer', 'profile-builder' );
37 31 $settings_pages['sub-pages']['user-email-customizer']['user-email-customizer'] = __( 'User Emails', 'profile-builder' );
38 32 $settings_pages['sub-pages']['user-email-customizer']['admin-email-customizer'] = __( 'Administrator Emails', 'profile-builder' );
39 33
@@ -52,9 +46,9 @@
52 46 * Function that generates the html for the tabs and subtabs on the settings page
53 47 */
54 48 function wppb_generate_settings_tabs(){
55 49 ?>
56 - <nav class="nav-tab-wrapper">
50 + <nav class="nav-tab-wrapper cozmoslabs-nav-tab-wrapper">
57 51 <?php
58 52 $pages = wppb_get_settings_pages();
59 53
60 54 $active_tab = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
@@ -79,9 +73,9 @@
79 73
80 74 if( !empty( $pages['sub-pages'] ) ) {
81 75 foreach ($pages['sub-pages'] as $parent_slug => $subpages) {
82 76 if (array_key_exists( sanitize_text_field( $active_subpage ), $subpages)) {
83 - echo '<ul class="wppb-subtabs subsubsub">';
77 + echo '<ul class="wppb-subtabs subsubsub cozmoslabs-nav-sub-tab-wrapper">';
84 78 foreach ($subpages as $subpage_slug => $subpage_name) {
85 79 echo '<li><a href="' . esc_url( admin_url( add_query_arg(array('page' => $subpage_slug), 'admin.php') ) ) . '" class="nav-sub-tab ' . ($active_subpage == $subpage_slug ? 'current' : '') . '">' . esc_html( $subpage_name ) . '</a></li>';
86 80 }
87 81 echo '</ul>';
@@ -91,9 +85,9 @@
91 85
92 86 if( !empty( $pages['sub-tabs'] ) ) {
93 87 foreach ($pages['sub-tabs'] as $parent_slug => $tabs) {
94 88 if ( $active_subpage == $parent_slug) {
95 - echo '<ul class="wppb-subtabs subsubsub">';
89 + echo '<ul class="wppb-subtabs subsubsub cozmoslabs-nav-sub-tab-wrapper">';
96 90 //determine the active tab, if no tab present then default to the first one
97 91 if( isset($_GET['tab']) )
98 92 $active_tab = sanitize_text_field( $_GET['tab'] );
99 93 else {
@@ -122,9 +116,9 @@
122 116 add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 );
123 117
124 118
125 119 function wppb_generate_default_settings_defaults(){
126 - add_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'automaticallyLogIn' => 'No', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'usernameemail', 'rolesEditor' => 'no', 'conditional_fields_ajax' => 'no', 'formsDesign' => 'form-style-default' ) );
120 + add_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'automaticallyLogIn' => 'No', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'usernameemail', 'rolesEditor' => 'no', 'conditional_fields_ajax' => 'no', 'formsDesign' => 'form-style-default', 'hide_admin_bar_for' => '' ) );
127 121 }
128 122
129 123
130 124 /**
@@ -136,293 +130,724 @@
136 130 */
137 131 function wppb_general_settings_content() {
138 132 wppb_generate_default_settings_defaults();
139 133 ?>
140 - <div class="wrap wppb-wrap">
141 - <h2>
142 - <?php esc_html_e( 'Profile Builder Settings', 'profile-builder' ); ?>
143 - <a href="https://www.cozmoslabs.com/docs/profile-builder-2/general-settings/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>
144 - </h2>
134 + <div class="wrap wppb-wrap cozmoslabs-wrap">
145 135
136 + <h1></h1>
137 + <!-- WordPress Notices are added after the h1 tag -->
138 +
139 + <div class="cozmoslabs-page-header">
140 + <div class="cozmoslabs-section-title">
141 +
142 + <h2 class="cozmoslabs-page-title">
143 + <?php esc_html_e( 'Profile Builder Settings', 'profile-builder' ); ?>
144 + <a href="https://www.cozmoslabs.com/docs/profile-builder/general-settings/?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>
145 + </h2>
146 +
147 + </div>
148 + </div>
149 +
146 150 <?php settings_errors(); ?>
147 151
148 - <?php wppb_generate_settings_tabs() ?>
152 + <?php wppb_generate_settings_tabs(); ?>
149 153
150 - <form method="post" action="options.php#general-settings">
151 - <?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?>
152 - <?php settings_fields( 'wppb_general_settings' ); ?>
154 + <?php wppb_load_necessary_scripts(); ?>
153 155
154 - <table class="form-table">
156 + <div class="cozmoslabs-settings-container">
155 157
156 - <?php
157 - if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/form-designs/form-designs.php' ) ){
158 - ?>
159 - <tr id="form_desings">
160 - <th scope="row" colspan="2">
161 - <?php esc_html_e( "Select Form Design:", "profile-builder" ); ?>
162 - <?php echo wppb_render_forms_design_selector(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
163 - </th>
164 - <td style="padding: 0; margin: 0;">
165 - <input type="hidden" id="wppb-active-form-design" name="wppb_general_settings[formsDesign]" value="<?php echo ( !empty( $wppb_generalSettings['formsDesign'] ) ? esc_html( $wppb_generalSettings['formsDesign'] ) : 'form-style-default' ) ?>" class="wppb-select">
166 - </td>
167 - </tr>
168 - <?php } ?>
158 + <?php if ( !is_multisite() && defined( 'WPPB_PAID_PLUGIN_DIR' ) && defined( 'PROFILE_BUILDER_PAID_VERSION' ) ) : ?>
159 + <div class="cozmoslabs-form-subsection-wrapper" id="wppb-register-version">
160 + <?php wppb_add_register_version_form(); ?>
161 + </div>
162 + <?php endif; ?>
169 163
170 - <?php
171 - if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
172 - ?>
173 - <tr id="form_desings_showcase">
174 - <th scope="row" colspan="2">
175 - <?php esc_html_e( "Have a look at the new Profile Builder - Form Styles:", "profile-builder" ); ?>
176 - <?php echo wppb_display_form_designs_preview(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
177 - <p><?php printf( esc_html__( 'You can now beautify your forms using new Styles. Enable Form Designs by upgrading to %1$sBasic or PRO versions%2$s.', 'profile-builder' ),'<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=general-settings-link&utm_campaign=PBFree">', '</a>' )?></p>
178 - </th>
164 + <form method="post" action="options.php#general-settings">
165 + <?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?>
166 + <?php settings_fields( 'wppb_general_settings' ); ?>
179 167
180 - </tr>
181 - <?php } ?>
168 + <div class="cozmoslabs-settings">
182 169
183 - <tr>
184 - <th scope="row">
185 - <?php esc_html_e( 'Automatically Log In:', 'profile-builder' );?>
186 - </th>
187 - <td>
188 - <select name="wppb_general_settings[automaticallyLogIn]" class="wppb-select" id="wppb_settings_automatically_log_in" onchange="wppb_display_page_select(this.value)">
189 - <option value="Yes" <?php if ( !empty( $wppb_generalSettings['automaticallyLogIn'] ) && $wppb_generalSettings['automaticallyLogIn'] === 'Yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option>
190 - <option value="No" <?php if ( empty( $wppb_generalSettings['automaticallyLogIn'] ) || ( !empty( $wppb_generalSettings['automaticallyLogIn'] ) && $wppb_generalSettings['automaticallyLogIn'] === 'No' ) ) echo 'selected'; ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option>
191 - </select>
192 - <ul>
193 - <li class="description"><?php esc_html_e( 'Select "Yes" to automatically log in new users after successful registration.', 'profile-builder' ); ?></li>
194 - </ul>
195 - </td>
196 - </tr>
170 + <?php if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/form-designs.php' ) ) : ?>
171 + <div class="cozmoslabs-form-subsection-wrapper" id="wppb-form_desings">
172 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Design & User Experience', 'profile-builder' ); ?></h4>
173 + <p class="cozmoslabs-description" style="margin-bottom: 5px;"><?php esc_html_e( 'Choose a style that better suits your website.', 'profile-builder' ); ?></p>
174 + <p class="cozmoslabs-description"><?php esc_html_e( 'The default style is there to let you customize the CSS and in general will receive the look and feel from your own theme’s styling.', 'profile-builder' ); ?></p>
197 175
198 - <tr>
199 - <th scope="row">
200 - <?php esc_html_e( '"Email Confirmation" Activated:', 'profile-builder' );?>
201 - </th>
202 - <td>
203 - <select name="wppb_general_settings[emailConfirmation]" class="wppb-select" id="wppb_settings_email_confirmation" onchange="wppb_display_page_select(this.value)">
204 - <option value="yes" <?php if ( !empty( $wppb_generalSettings['emailConfirmation'] ) && $wppb_generalSettings['emailConfirmation'] === 'yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option>
205 - <option value="no" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) || ( !empty( $wppb_generalSettings['emailConfirmation'] ) && $wppb_generalSettings['emailConfirmation'] === 'no' ) ) echo 'selected'; ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option>
206 - </select>
207 - <ul>
208 - <li class="description"><?php esc_html_e( 'This works with front-end forms only. Recommended to redirect WP default registration to a Profile Builder one using "Custom Redirects" module.', 'profile-builder' ); ?></li>
209 - <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) { ?>
210 - <li class="description dynamic1"><?php printf( esc_html__( 'You can find a list of unconfirmed email addresses %1$sUsers > All Users > Email Confirmation%2$s.', 'profile-builder' ), '<a href="'. esc_url( get_bloginfo( 'url' ) ).'/wp-admin/users.php?page=unconfirmed_emails">', '</a>' )?></li>
211 - <?php } ?>
212 - </ul>
213 - </td>
214 - </tr>
176 + <div class="cozmoslabs-form-field-wrapper">
177 + <?php echo wppb_render_forms_design_selector(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
178 + </div>
179 + </div>
180 + <?php endif; ?>
215 181
216 - <tr id="wppb-settings-activation-page">
217 - <th scope="row">
218 - <?php esc_html_e( '"Email Confirmation" Landing Page:', 'profile-builder' ); ?>
219 - </th>
220 - <td>
221 - <select name="wppb_general_settings[activationLandingPage]" class="wppb-select">
222 - <option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option>
223 - <optgroup label="<?php esc_html_e( 'Existing Pages', 'profile-builder' ); ?>">
224 - <?php
225 - $pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) );
182 + <div class="cozmoslabs-form-subsection-wrapper">
183 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Optimize The login and Registration flow for your members', 'profile-builder' ); ?></h4>
226 184
227 - foreach ( $pages as $key => $value ){
228 - echo '<option value="'.esc_attr( $value->ID ).'"';
229 - if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
230 - echo ' selected';
185 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
186 + <label class="cozmoslabs-form-field-label" for="wppb_settings_automatically_log_in"><?php esc_html_e('Automatically Log In', 'profile-builder'); ?></label>
231 187
232 - echo '>' . esc_html( $value->post_title ) . '</option>';
233 - }
234 - ?>
235 - </optgroup>
236 - </select>
237 - <p class="description">
238 - <?php esc_html_e( 'Specify the page where the users will be directed when confirming the email account. This page can differ from the register page(s) and can be changed at any time. If none selected, a simple confirmation page will be displayed for the user.', 'profile-builder' ); ?>
239 - </p>
240 - </td>
241 - </tr>
188 + <div class="cozmoslabs-toggle-container">
189 + <input type="checkbox" name="wppb_general_settings[automaticallyLogIn]" id="wppb_settings_automatically_log_in" value="Yes" <?php echo (!empty($wppb_generalSettings['automaticallyLogIn']) && $wppb_generalSettings['automaticallyLogIn'] === 'Yes') ? 'checked' : ''; ?> >
190 + <label class="cozmoslabs-toggle-track" for="wppb_settings_automatically_log_in"></label>
191 + </div>
242 192
193 + <div class="cozmoslabs-toggle-description">
194 + <label for="wppb_settings_automatically_log_in" class="cozmoslabs-description"><?php esc_html_e( 'Enable to automatically log in new users after successful registration.', 'profile-builder' ); ?></label>
195 + </div>
196 + </div>
243 197
244 - <?php
245 - if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){
246 - ?>
247 - <tr>
248 - <th scope="row">
249 - <?php esc_html_e( '"Admin Approval" Activated:', 'profile-builder' ); ?>
250 - </th>
251 - <td>
252 - <select id="adminApprovalSelect" name="wppb_general_settings[adminApproval]" class="wppb-select" onchange="wppb_display_page_select_aa(this.value)">
253 - <option value="yes" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option>
254 - <option value="no" <?php if( empty( $wppb_generalSettings['adminApproval'] ) || ( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'no' ) ) echo 'selected'; ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option>
255 - </select>
256 - <ul>
257 - <li class="description dynamic2"><?php printf( esc_html__( 'You can find a list of users at %1$sUsers > All Users > Admin Approval%2$s.', 'profile-builder' ), '<a href="'. esc_url( get_bloginfo( 'url' ) ).'/wp-admin/users.php?page=admin_approval&orderby=registered&order=desc">', '</a>' )?></li>
258 - <ul>
259 - </td>
260 - </tr>
198 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
199 + <label class="cozmoslabs-form-field-label" for="wppb_settings_email_confirmation"><?php esc_html_e('Email Confirmation', 'profile-builder'); ?></label>
261 200
262 - <tr class="dynamic2">
263 - <th scope="row">
264 - <?php esc_html_e( '"Admin Approval" on User Role:', 'profile-builder' ); ?>
265 - </th>
266 - <td>
267 - <div id="wrap">
268 - <?php
269 - $wppb_userRoles = wppb_adminApproval_onUserRole();
270 201
271 - if( ! empty( $wppb_userRoles ) ) {
272 - foreach( $wppb_userRoles as $role => $role_name ) {
273 - echo '<label><input type="checkbox" id="adminApprovalOnUserRoleCheckbox" name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-checkboxes" value="' . esc_attr( $role ) . '"';
274 - if( ! empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) && in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
275 - if( empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
276 - echo '>';
277 - echo esc_html( $role_name ) . '</label><br>';
278 - }
279 - }
280 - ?>
281 - </div>
282 - <ul>
283 - <li class="description"><?php printf( esc_html__( 'Select on what user roles to activate Admin Approval.', 'profile-builder' ) ) ?></li>
284 - <ul>
285 - </td>
286 - </tr>
202 + <div class="cozmoslabs-toggle-container">
287 203
288 - <?php } ?>
204 + <input type="checkbox" name="wppb_general_settings[emailConfirmation]" id="wppb_settings_email_confirmation" value="yes" <?php echo (!empty($wppb_generalSettings['emailConfirmation']) && $wppb_generalSettings['emailConfirmation'] === 'yes') ? 'checked' : ''; ?> >
205 + <label class="cozmoslabs-toggle-track" for="wppb_settings_email_confirmation"></label>
289 206
290 - <?php
291 - if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) {
292 - ?>
293 - <tr>
294 - <th scope="row">
295 - <?php esc_html_e( '"Roles Editor" Activated:', 'profile-builder' ); ?>
296 - </th>
297 - <td>
298 - <select id="rolesEditorSelect" name="wppb_general_settings[rolesEditor]" class="wppb-select" onchange="wppb_display_page_select_re(this.value)">
299 - <option value="no" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'no' ) echo 'selected'; ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option>
300 - <option value="yes" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option>
301 - </select>
302 - <ul>
303 - <li class="description dynamic3"><?php printf( esc_html__( 'You can add / edit user roles at %1$sUsers > Roles Editor%2$s.', 'profile-builder' ), '<a href="'. esc_url( get_bloginfo( 'url' ) ).'/wp-admin/edit.php?post_type=wppb-roles-editor">', '</a>' )?></li>
304 - <ul>
305 - </td>
306 - </tr>
307 - <?php } ?>
207 + </div>
208 + <div class="cozmoslabs-toggle-description">
209 + <label for="wppb_settings_email_confirmation" class="cozmoslabs-description"><?php esc_html_e( 'This works with front-end forms only. Recommended to redirect WP default registration to a Profile Builder one using "Custom Redirects" module.', 'profile-builder' ); ?></label>
210 + </div>
308 211
309 - <?php
310 - if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
311 - ?>
312 - <tr>
313 - <th scope="row">
314 - <?php esc_html_e( '"Admin Approval" Feature:', 'profile-builder' ); ?>
315 - </th>
316 - <td>
317 - <p><em> <?php printf( esc_html__( 'You decide who is a user on your website. Get notified via email or approve multiple users at once from the WordPress UI. Enable Admin Approval by upgrading to %1$sBasic or PRO versions%2$s.', 'profile-builder' ),'<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=general-settings-link&utm_campaign=PBFree">', '</a>' )?></em></p>
318 - </td>
319 - </tr>
320 - <?php } ?>
212 + <p class="cozmoslabs-description cozmoslabs-description-space-left" id="unconfirmed-user-emails"><?php printf( esc_html__( 'You can find a list of unconfirmed email addresses %1$sUsers > All Users > Email Confirmation%2$s.', 'profile-builder' ), '<a href="'. esc_url( get_bloginfo( 'url' ) ).'/wp-admin/users.php?page=unconfirmed_emails">', '</a>' )?></p>
213 + </div>
321 214
322 - <tr>
323 - <th scope="row">
324 - <?php esc_html_e( 'Allow Users to Log in With:', 'profile-builder' ); ?>
325 - </th>
326 - <td>
327 - <select name="wppb_general_settings[loginWith]" class="wppb-select">
328 - <option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php esc_html_e( 'Username and Email', 'profile-builder' ); ?></option>
329 - <option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php esc_html_e( 'Username', 'profile-builder' ); ?></option>
330 - <option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php esc_html_e( 'Email', 'profile-builder' ); ?></option>
331 - </select>
332 - <ul>
333 - <li class="description"><?php esc_html_e( '"Username and Email" - users can Log In with either their Username or their Email.', 'profile-builder' ); ?></li>
334 - <li class="description"><?php esc_html_e( '"Username" - users can only Log In with their Username. Both the Username and Email fields will be shown in the front-end forms.', 'profile-builder' ); ?></li>
335 - <li class="description"><?php esc_html_e( '"Email" - users can only Log In with their Email. The Username field will be hidden in the front-end forms and Usernames will be automatically generated based on the Emails.', 'profile-builder' ); ?></li>
336 - </ul>
337 - </td>
338 - </tr>
215 + <div class="cozmoslabs-form-field-wrapper" id="wppb-settings-activation-page">
216 + <label class="cozmoslabs-form-field-label" for="wppb_settings_email_confirmation_page"><?php esc_html_e('Email Confirmation Page', 'profile-builder'); ?></label>
339 217
340 - <tr>
341 - <th scope="row">
342 - <?php esc_html_e( 'Minimum Password Length:', 'profile-builder' ); ?>
343 - </th>
344 - <td>
345 - <input type="text" name="wppb_general_settings[minimum_password_length]" class="wppb-text" value="<?php if( !empty( $wppb_generalSettings['minimum_password_length'] ) ) echo esc_attr( $wppb_generalSettings['minimum_password_length'] ); ?>"/>
346 - <ul>
347 - <li class="description"><?php esc_html_e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profile-builder' ); ?> </li>
348 - </ul>
349 - </td>
350 - </tr>
218 + <select name="wppb_general_settings[activationLandingPage]" class="wppb-select" id="wppb_settings_email_confirmation_page">
219 + <option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option>
220 + <optgroup label="<?php esc_html_e( 'Existing Pages', 'profile-builder' ); ?>">
221 + <?php
222 + $pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) );
351 223
352 - <tr>
353 - <th scope="row">
354 - <?php esc_html_e( 'Minimum Password Strength:', 'profile-builder' ); ?>
355 - </th>
356 - <td>
357 - <select name="wppb_general_settings[minimum_password_strength]" class="wppb-select">
358 - <option value=""><?php esc_html_e( 'Disabled', 'profile-builder' ); ?></option>
359 - <option value="short" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'short' ) echo 'selected'; ?>><?php esc_html_e( 'Very weak', 'profile-builder' ); ?></option>
360 - <option value="bad" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'bad' ) echo 'selected'; ?>><?php esc_html_e( 'Weak', 'profile-builder' ); ?></option>
361 - <option value="good" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'good' ) echo 'selected'; ?>><?php esc_html_e( 'Medium', 'profile-builder' ); ?></option>
362 - <option value="strong" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'strong' ) echo 'selected'; ?>><?php esc_html_e( 'Strong', 'profile-builder' ); ?></option>
363 - </select>
364 - </td>
365 - </tr>
224 + foreach ( $pages as $key => $value ){
225 + echo '<option value="'.esc_attr( $value->ID ).'"';
226 + if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
227 + echo ' selected';
366 228
367 - <tr>
368 - <th scope="row">
369 - <?php esc_html_e( 'Select Recover Password Page:', 'profile-builder' ); ?>
370 - </th>
371 - <td>
372 - <select name="wppb_general_settings[lost_password_page]" class="wppb-select">
373 - <option value=""> <?php esc_html_e( 'None', 'profile-builder' ); ?></option>
229 + echo '>' . esc_html( $value->post_title ) . '</option>';
230 + }
231 + ?>
232 + </optgroup>
233 + </select>
234 +
235 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Specify the page where the users will be directed when confirming the email account. This page can differ from the register page(s) and can be changed at any time.', 'profile-builder' ); ?></p>
236 + </div>
237 +
374 238 <?php
375 - $args = array(
376 - 'post_type' => 'page',
377 - 'post_status' => 'publish',
378 - 'numberposts' => -1,
379 - 'orderby' => 'name',
380 - 'order' => 'ASC'
381 - );
382 - $pages = get_posts( $args );
239 + if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
240 + ?>
383 241
384 - foreach ( $pages as $key => $value ){
385 - echo '<option value="'.esc_attr( $value->guid ).'"';
386 - if ( isset( $wppb_generalSettings['lost_password_page'] ) && $wppb_generalSettings['lost_password_page'] == $value->guid )
387 - echo ' selected';
242 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
243 + <label class="cozmoslabs-form-field-label"><?php esc_html_e('Admin Approval', 'profile-builder'); ?></label>
388 244
389 - echo '>' . esc_html( $value->post_title ) . '</option>';
390 - }
245 + <p class="cozmoslabs-description cozmoslabs-description-align-right cozmoslabs-description-upsell">
246 + <?php echo esc_html__( 'You decide who is a user on your website. Get notified via email or approve multiple users at once from the WordPress UI.', 'profile-builder' ); ?><br>
247 + <?php printf( esc_html__( 'Enable Admin Approval by upgrading to %1$sBasic or PRO versions%2$s.', 'profile-builder' ),'<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-general-settings&utm_medium=client-site&utm_campaign=pb-admin-approval#pricing">', '</a>' )?>
248 + </p>
249 + </div>
391 250
392 - ?>
251 + <?php } ?>
393 252
394 - </select>
395 253
396 - <ul>
397 - <li class="description"><?php printf( esc_html__( 'Select the page which contains the %1$s[wppb-recover-password]%2$s shortcode.', 'profile-builder' ), '<strong>','</strong>' ) ?> </li>
398 - </ul>
254 + <?php
255 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){
256 + ?>
399 257
400 - </td>
401 - </tr>
258 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
259 + <label class="cozmoslabs-form-field-label" for="adminApprovalSelect"><?php esc_html_e('Admin Approval', 'profile-builder'); ?></label>
402 260
403 - <tr>
404 - <th scope="row">
405 - <?php esc_html_e( "Load Profile Builder's own CSS file in the front-end:", "profile-builder" ); ?>
406 - </th>
407 - <td>
408 - <label><input type="checkbox" name="wppb_general_settings[extraFieldsLayout]"<?php echo ( ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ? ' checked' : '' ); ?> value="default" class="wppb-select"><?php esc_html_e( 'Yes', 'profile-builder' ); ?></label>
409 - <ul>
410 - <li class="description"><?php printf( esc_html__( 'You can find the default file here: %1$s', 'profile-builder' ), '<a href="'.dirname( plugin_dir_url( __FILE__ ) ).'/assets/css/style-front-end.css" target="_blank">'.dirname( dirname( plugin_basename( __FILE__ ) ) ).'\assets\css\style-front-end.css</a>' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></li>
411 - </ul>
412 - </td>
413 - </tr>
261 + <div class="cozmoslabs-toggle-container">
262 + <input type="checkbox" name="wppb_general_settings[adminApproval]" id="adminApprovalSelect" value="yes" <?php echo (!empty($wppb_generalSettings['adminApproval']) && $wppb_generalSettings['adminApproval'] === 'yes') ? 'checked' : ''; ?> >
263 + <label class="cozmoslabs-toggle-track" for="adminApprovalSelect"></label>
264 + </div>
414 265
415 - <?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
416 - </table>
266 + <div class="cozmoslabs-toggle-description">
267 + <label for="adminApprovalSelect" class="cozmoslabs-description wppb-aa-details"><?php esc_html_e( 'Each user that registers on the website will be given a Pending status and will need to be approved or unapproved by the admin before he/she can login.', 'profile-builder' ); ?></label>
268 + </div>
417 269
270 + <p class="cozmoslabs-description cozmoslabs-description-space-left wppb-aa-user-list"><?php printf( esc_html__( 'You can find a list of users at %1$sUsers > All Users > Admin Approval%2$s.', 'profile-builder' ), '<a href="'. esc_url( get_bloginfo( 'url' ) ).'/wp-admin/users.php?page=admin_approval&orderby=registered&order=desc">', '</a>' )?></p>
271 + </div>
418 272
273 + <div class="cozmoslabs-form-field-wrapper wppb-aa-user-list">
274 + <label class="cozmoslabs-form-field-label" for="adminApprovalOnUserRoleSelect"><?php esc_html_e('Admin Approval User Role', 'profile-builder'); ?></label>
419 275
420 - <input type="hidden" name="action" value="update" />
421 - <p class="submit"><input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'profile-builder' ); ?>" /></p>
422 - </form>
423 -</div>
276 + <select name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-select wppb-select2" multiple>
277 + <?php
278 + $wppb_userRoles = wppb_adminApproval_onUserRole();
424 279
280 + if( ! empty( $wppb_userRoles ) ) {
281 + foreach( $wppb_userRoles as $role => $role_name ) {
282 +
283 + echo '<option value="' . esc_attr( $role ) . '"' . (( !empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) && in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) || empty( $wppb_generalSettings['adminApprovalOnUserRole']) ? ' selected' : '') . '>' . esc_html( $role_name ) . '</option>';
284 +
285 + }
286 + }
287 + ?>
288 + </select>
289 + </div>
290 +
291 + <?php } ?>
292 +
293 + <div class="cozmoslabs-form-field-wrapper">
294 + <label class="cozmoslabs-form-field-label" for="loginWithSelect"><?php esc_html_e( 'Allow Users to Log in With:', 'profile-builder' ); ?></label>
295 +
296 + <select name="wppb_general_settings[loginWith]" class="wppb-select" id="loginWithSelect">
297 + <option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php esc_html_e( 'Username and Email', 'profile-builder' ); ?></option>
298 + <option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php esc_html_e( 'Username', 'profile-builder' ); ?></option>
299 + <option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php esc_html_e( 'Email', 'profile-builder' ); ?></option>
300 + </select>
301 +
302 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Choose what the user will be logging in with.', 'profile-builder' ); ?></p>
303 + </div>
304 +
305 + </div>
306 +
307 + <div class="cozmoslabs-form-subsection-wrapper">
308 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Security', 'profile-builder' ); ?></h4>
309 +
310 + <div class="cozmoslabs-form-field-wrapper">
311 + <label class="cozmoslabs-form-field-label" for="minimumPasswordLength"><?php esc_html_e( 'Minimum Password Length', 'profile-builder' ); ?></label>
312 + <input type="text" name="wppb_general_settings[minimum_password_length]" class="wppb-text" id="minimumPasswordLength" value="<?php if( !empty( $wppb_generalSettings['minimum_password_length'] ) ) echo esc_attr( $wppb_generalSettings['minimum_password_length'] ); ?>"/>
313 +
314 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profile-builder' ); ?></p>
315 + </div>
316 +
317 +
318 + <div class="cozmoslabs-form-field-wrapper">
319 + <label class="cozmoslabs-form-field-label" for="minimumPasswordStrength"><?php esc_html_e( 'Minimum Password Strength', 'profile-builder' ); ?></label>
320 +
321 + <select name="wppb_general_settings[minimum_password_strength]" class="wppb-select" id="minimumPasswordStrength">
322 + <option value=""><?php esc_html_e( 'Disabled', 'profile-builder' ); ?></option>
323 + <option value="short" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'short' ) echo 'selected'; ?>><?php esc_html_e( 'Very weak', 'profile-builder' ); ?></option>
324 + <option value="bad" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'bad' ) echo 'selected'; ?>><?php esc_html_e( 'Weak', 'profile-builder' ); ?></option>
325 + <option value="good" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'good' ) echo 'selected'; ?>><?php esc_html_e( 'Medium', 'profile-builder' ); ?></option>
326 + <option value="strong" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'strong' ) echo 'selected'; ?>><?php esc_html_e( 'Strong', 'profile-builder' ); ?></option>
327 + </select>
328 +
329 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'A stronger password strength will probably force the user to not reuse passwords from other websites.', 'profile-builder' ); ?></p>
330 + </div>
331 +
332 +
333 + <div class="cozmoslabs-form-field-wrapper">
334 + <label class="cozmoslabs-form-field-label" for="lostPasswordPage"><?php esc_html_e( 'Password Recovery Page', 'profile-builder' ); ?></label>
335 +
336 + <select name="wppb_general_settings[lost_password_page]" class="wppb-select" id="lostPasswordPage">
337 + <option value=""> <?php esc_html_e( 'None', 'profile-builder' ); ?></option>
338 + <?php
339 + $args = array(
340 + 'post_type' => 'page',
341 + 'post_status' => 'publish',
342 + 'numberposts' => -1,
343 + 'orderby' => 'name',
344 + 'order' => 'ASC'
345 + );
346 + $pages = get_posts( $args );
347 +
348 + foreach ( $pages as $key => $value ){
349 + echo '<option value="'.esc_attr( $value->guid ).'"';
350 + if ( isset( $wppb_generalSettings['lost_password_page'] ) && $wppb_generalSettings['lost_password_page'] == $value->guid )
351 + echo ' selected';
352 +
353 + echo '>' . esc_html( $value->post_title ) . '</option>';
354 + }
355 + ?>
356 + </select>
357 +
358 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Select the page which contains the "[wppb-recover-password]" shortcode.', 'profile-builder' ); ?></p>
359 + </div>
360 + </div>
361 +
362 + <?php if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/two-factor-authentication/class-two-factor-authentication.php' ) ) : ?>
363 + <div class="cozmoslabs-form-subsection-wrapper">
364 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Two-Factor Authentication', 'profile-builder' ); ?></h4>
365 +
366 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
367 + <?php
368 + $wppb_two_factor_authentication_settings = get_option( 'wppb_two_factor_authentication_settings', 'not_found' );
369 +
370 + $enabled = 'no';
371 + if ( $wppb_two_factor_authentication_settings !== 'not_found' && is_array( $wppb_two_factor_authentication_settings ) && isset( $wppb_two_factor_authentication_settings['enabled'] ) ) {
372 + $enabled = $wppb_two_factor_authentication_settings['enabled'];
373 + }
374 + ?>
375 +
376 + <label class="cozmoslabs-form-field-label" for="wppb-auth-enable"><?php esc_html_e('Two-Factor Authentication', 'profile-builder'); ?></label>
377 +
378 + <div class="cozmoslabs-toggle-container">
379 + <input type="checkbox" name="wppb_two_factor_authentication_settings[enabled]" id="wppb-auth-enable" value="yes" <?php echo ($enabled === 'yes') ? 'checked' : ''; ?> >
380 + <label class="cozmoslabs-toggle-track" for="wppb-auth-enable"></label>
381 + </div>
382 +
383 + <?php
384 + $current_user = wp_get_current_user();
385 + ?>
386 +
387 + <script type="text/javascript">
388 + jQuery(document).ready(function($) {
389 + // Handle 2FA enable toggle
390 + $('#wppb-auth-enable').on('change', function() {
391 + if ($(this).is(':checked')) {
392 + $('#wppb-auth-roles-selector').show();
393 + $('#wppb-force-2fa-enable').closest('.cozmoslabs-form-field-wrapper').show();
394 + $('#wppb-2fa-require-totp-profile-edit').show();
395 + if ($('#wppb-force-2fa-enable').is(':checked')) {
396 + $('#wppb-force-2fa-roles-selector').show();
397 + $('#wppb-force-2fa-grace-period').show();
398 + $('#wppb-force-2fa-edit-profile-page-selector').show();
399 +
400 + }
401 + } else {
402 + $('#wppb-auth-roles-selector').hide();
403 + $('#wppb-force-2fa-enable').closest('.cozmoslabs-form-field-wrapper').hide();
404 + $('#wppb-force-2fa-roles-selector').hide();
405 + $('#wppb-force-2fa-grace-period').hide();
406 + $('#wppb-force-2fa-edit-profile-page-selector').hide();
407 +
408 + $('#wppb-2fa-require-totp-profile-edit').hide();
409 + }
410 + });
411 +
412 + // Handle force 2FA enable toggle
413 + $('#wppb-force-2fa-enable').on('change', function() {
414 + if ($(this).is(':checked')) {
415 + $('#wppb-force-2fa-roles-selector').show();
416 + $('#wppb-force-2fa-grace-period').show();
417 + $('#wppb-force-2fa-edit-profile-page-selector').show();
418 +
419 + } else {
420 + $('#wppb-force-2fa-roles-selector').hide();
421 + $('#wppb-force-2fa-grace-period').hide();
422 + $('#wppb-force-2fa-edit-profile-page-selector').hide();
423 +
424 + }
425 + });
426 +
427 + // Handle changes to "Enable Authenticator For" roles
428 + $('#wppb-auth-enable-roles').on('change', function() {
429 + updateForce2FARolesDropdown();
430 + });
431 +
432 + // Function to update the Force 2FA roles dropdown based on enabled roles
433 + function updateForce2FARolesDropdown() {
434 + var enabledRoles = $('#wppb-auth-enable-roles').val() || [];
435 + var force2FARolesSelect = $('#wppb-force-2fa-roles');
436 + var currentlySelected = force2FARolesSelect.val() || [];
437 +
438 + // Clear current options
439 + force2FARolesSelect.empty();
440 +
441 + // Get all available roles from the original select
442 + var allRoleOptions = $('#wppb-auth-enable-roles option');
443 +
444 + // If '*' (all roles) is selected, show all roles
445 + if (enabledRoles.indexOf('*') !== -1) {
446 + allRoleOptions.each(function() {
447 + var roleValue = $(this).val();
448 + if (roleValue !== '*') { // Skip the "ALL ROLES" option
449 + var option = $('<option></option>')
450 + .attr('value', roleValue)
451 + .text($(this).text());
452 + if (currentlySelected.indexOf(roleValue) !== -1) {
453 + option.prop('selected', true);
454 + }
455 + force2FARolesSelect.append(option);
456 + }
457 + });
458 + } else {
459 + // Only show roles that are specifically enabled for 2FA
460 + enabledRoles.forEach(function(roleKey) {
461 + allRoleOptions.each(function() {
462 + if ($(this).val() === roleKey) {
463 + var option = $('<option></option>')
464 + .attr('value', roleKey)
465 + .text($(this).text());
466 + if (currentlySelected.indexOf(roleKey) !== -1) {
467 + option.prop('selected', true);
468 + }
469 + force2FARolesSelect.append(option);
470 + }
471 + });
472 + });
473 + }
474 +
475 + // Trigger select2 update
476 + force2FARolesSelect.trigger('change');
477 + }
478 +
479 + // Initial state
480 + $('#wppb-auth-enable').trigger('change');
481 + updateForce2FARolesDropdown();
482 +
483 + // Force 2FA Confirmation Logic
484 + var currentUserRoles = <?php echo json_encode( $current_user->roles ); ?>;
485 + var currentUser2FAEnabled = <?php echo ( get_user_option( 'wppb_auth_enabled', $current_user->ID ) === 'enabled' ) ? 'true' : 'false'; ?>;
486 +
487 + // Store initial state
488 + var initialForce2FAEnabled = $('#wppb-force-2fa-enable').is(':checked');
489 + var initialMain2FAEnabled = $('#wppb-auth-enable').is(':checked');
490 + var initialSelectedRoles = $('#wppb-force-2fa-roles').val() || [];
491 + initialSelectedRoles.sort();
492 +
493 + // Create Modal
494 + $('body').append(
495 + '<div id="wppb-force-2fa-modal" style="display:none; position:fixed; z-index:10000; left:0; top:0; width:100%; height:100%; overflow:auto; background-color:rgba(0,0,0,0.4);">' +
496 + '<div style="background-color:#fefefe; margin:15% auto; padding:20px; border:1px solid #888; width:500px; max-width:90%; border-radius:4px; box-shadow:0 4px 6px rgba(0,0,0,0.1);">' +
497 + '<h3 style="margin-top:0;">' + <?php echo json_encode( esc_html__( 'Confirm Two-Factor Authentication Enforcement', 'profile-builder' ) ); ?> + '</h3>' +
498 + '<div id="wppb-force-2fa-message"></div>' +
499 + '<div style="margin-top:20px; text-align:right;">' +
500 + '<button type="button" id="wppb-force-2fa-cancel" class="button">' + <?php echo json_encode( esc_html__( 'Cancel', 'profile-builder' ) ); ?> + '</button> ' +
501 + '<button type="button" id="wppb-force-2fa-confirm" class="button button-primary">' + <?php echo json_encode( esc_html__( 'Confirm & Save', 'profile-builder' ) ); ?> + '</button>' +
502 + '</div>' +
503 + '</div>' +
504 + '</div>'
505 + );
506 +
507 + // Intercept form submission
508 + $('form').on('submit', function(e) {
509 + // Only check if we are on the general settings page and submitting the main form
510 + if ($(this).find('input[name="option_page"]').val() !== 'wppb_general_settings') {
511 + return;
512 + }
513 +
514 + var force2FAEnabled = $('#wppb-force-2fa-enable').is(':checked');
515 + var main2FAEnabled = $('#wppb-auth-enable').is(':checked');
516 + var selectedRoles = $('#wppb-force-2fa-roles').val() || [];
517 + selectedRoles.sort();
518 +
519 + // Check if settings have changed
520 + var settingsChanged = false;
521 +
522 + // Case 1: Force 2FA Enabled status changed
523 + if (force2FAEnabled !== initialForce2FAEnabled) {
524 + settingsChanged = true;
525 + }
526 +
527 + // Case 2: Roles selection changed (only if Force 2FA is enabled)
528 + if (force2FAEnabled) {
529 + if (selectedRoles.length !== initialSelectedRoles.length) {
530 + settingsChanged = true;
531 + } else {
532 + for (var i = 0; i < selectedRoles.length; i++) {
533 + if (selectedRoles[i] !== initialSelectedRoles[i]) {
534 + settingsChanged = true;
535 + break;
536 + }
537 + }
538 + }
539 + }
540 +
541 + // Case 3: Main 2FA enabled status changed (only if Force 2FA is enabled)
542 + // This covers the case where Force 2FA was already checked but inactive because Main 2FA was off
543 + if (force2FAEnabled && main2FAEnabled !== initialMain2FAEnabled) {
544 + settingsChanged = true;
545 + }
546 +
547 + // Only show popup if Force 2FA is enabled AND Main 2FA is enabled AND settings have changed
548 + if (force2FAEnabled && main2FAEnabled && settingsChanged) {
549 + // Check if we already confirmed
550 + if ($(this).data('force-2fa-confirmed')) {
551 + return;
552 + }
553 +
554 + var selectedRolesText = [];
555 +
556 + $('#wppb-force-2fa-roles option:selected').each(function() {
557 + selectedRolesText.push($(this).text());
558 + });
559 +
560 + if (selectedRoles.length > 0) {
561 + e.preventDefault();
562 + var form = $(this);
563 +
564 + var message = '<p>' + <?php echo json_encode( esc_html__( 'You are enforcing 2FA for the following user roles:', 'profile-builder' ) ); ?> + ' <strong>' + selectedRolesText.join(', ') + '</strong>.</p>';
565 + message += '<p>' + <?php echo json_encode( esc_html__( 'Users with these roles will be required to set up 2FA on their next login.', 'profile-builder' ) ); ?> + '</p>';
566 +
567 + // Check if current user is affected
568 + var userAffected = false;
569 + for (var i = 0; i < currentUserRoles.length; i++) {
570 + if (selectedRoles.indexOf(currentUserRoles[i]) !== -1) {
571 + userAffected = true;
572 + break;
573 + }
574 + }
575 +
576 + if (userAffected && !currentUser2FAEnabled) {
577 + message += '<div class="notice notice-warning inline" style="margin: 10px 0; padding: 10px; display: block !important;"><p><strong>' + <?php echo json_encode( esc_html__( 'Warning:', 'profile-builder' ) ); ?> + '</strong> ' +
578 + <?php echo json_encode( esc_html__( 'Based on the configured settings, your account is also required to set up 2FA. Once you confirm this change, you will be redirected to set it up.', 'profile-builder' ) ); ?> + '</p></div>';
579 + }
580 +
581 + $('#wppb-force-2fa-message').html(message);
582 + $('#wppb-force-2fa-modal').show();
583 +
584 + // Handle Confirm
585 + $('#wppb-force-2fa-confirm').off('click').on('click', function() {
586 + $('#wppb-force-2fa-modal').hide();
587 + form.data('force-2fa-confirmed', true);
588 + form.submit();
589 + });
590 +
591 + // Handle Cancel
592 + $('#wppb-force-2fa-cancel').off('click').on('click', function() {
593 + $('#wppb-force-2fa-modal').hide();
594 + });
595 + }
596 + }
597 + });
598 + });
599 + </script>
600 +
601 + <div class="cozmoslabs-toggle-description">
602 + <label for="wppb-auth-enable" class="cozmoslabs-description"><?php esc_html_e( 'Enable the Google Authenticator functionality.', 'profile-builder' ); ?></label>
603 + </div>
604 + </div>
605 +
606 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch" id="wppb-2fa-require-totp-profile-edit" <?php echo $enabled === 'no' ? 'style="display: none;"' : '' ?> >
607 + <?php
608 + $require_totp_profile_edit = 'yes';
609 + if ( $wppb_two_factor_authentication_settings !== 'not_found' && is_array( $wppb_two_factor_authentication_settings ) && isset( $wppb_two_factor_authentication_settings['require_totp_profile_edit'] ) ) {
610 + $require_totp_profile_edit = $wppb_two_factor_authentication_settings['require_totp_profile_edit'];
611 + }
612 + ?>
613 +
614 +
615 + <label class="cozmoslabs-form-field-label" for="wppb-require-totp-profile-edit"><?php esc_html_e('Require TOTP Verification on Profile Edit', 'profile-builder'); ?></label>
616 +
617 + <div class="cozmoslabs-toggle-container">
618 + <input type="checkbox" name="wppb_two_factor_authentication_settings[require_totp_profile_edit]" id="wppb-require-totp-profile-edit" value="yes" <?php echo ($require_totp_profile_edit === 'yes') ? 'checked' : ''; ?> >
619 + <label class="cozmoslabs-toggle-track" for="wppb-require-totp-profile-edit"></label>
620 + </div>
621 +
622 + <div class="cozmoslabs-toggle-description">
623 + <label for="wppb-require-totp-profile-edit" class="cozmoslabs-description"><?php esc_html_e( 'Require users with Two-Factor Authentication enabled to verify their TOTP code every time they edit their profile. This setting is enabled by default.', 'profile-builder' ); ?></label>
624 + </div>
625 + </div>
626 +
627 + <div class="cozmoslabs-form-field-wrapper" id="wppb-auth-roles-selector" <?php echo $enabled === 'no' ? 'style="display: none;"' : '' ?> >
628 + <?php
629 + $roles = get_editable_roles( );
630 + $network_roles = array( );
631 + if ( !empty( $wppb_two_factor_authentication_settings['roles'] ) )
632 + $network_roles = is_array( $wppb_two_factor_authentication_settings['roles'] ) ? $wppb_two_factor_authentication_settings['roles'] : array( $wppb_two_factor_authentication_settings['roles'] );
633 + ?>
634 +
635 + <label class="cozmoslabs-form-field-label" for="wppb-auth-enable-roles"><?php esc_html_e( 'Enable Authenticator For', 'profile-builder' ); ?></label>
636 +
637 + <select name="wppb_two_factor_authentication_settings[roles][]" id="wppb-auth-enable-roles" class="wppb-select wppb-select2" multiple>
638 + <?php
639 + echo '<option value="*"' . (in_array('*', $network_roles, true) ? ' selected' : '') . '>'. esc_html__('ALL ROLES', 'profile-builder') .'</option>';
640 +
641 + foreach ($roles as $role_key => $role) {
642 + echo '<option value="' . esc_attr($role_key) . '"' . (in_array($role_key, $network_roles, true) ? ' selected' : '') . '>' . esc_html($role['name']) . '</option>';
643 + }
644 + ?>
645 + </select>
646 +
647 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( '"ALL ROLES" - Two-Factor Authentication will be enabled for all user roles.', 'profile-builder' ); ?></p>
648 + </div>
649 +
650 + <hr style="margin: 20px 0; border: 0; border-top: 1px solid #ddd;">
651 +
652 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
653 + <?php
654 + $force_2fa_enabled = 'no';
655 + if ( $wppb_two_factor_authentication_settings !== 'not_found' && is_array( $wppb_two_factor_authentication_settings ) && isset( $wppb_two_factor_authentication_settings['force_2fa_enabled'] ) ) {
656 + $force_2fa_enabled = $wppb_two_factor_authentication_settings['force_2fa_enabled'];
657 + }
658 + ?>
659 +
660 + <label class="cozmoslabs-form-field-label" for="wppb-force-2fa-enable"><?php esc_html_e('Force 2FA for Selected Roles', 'profile-builder'); ?></label>
661 +
662 + <div class="cozmoslabs-toggle-container">
663 + <input type="checkbox" name="wppb_two_factor_authentication_settings[force_2fa_enabled]" id="wppb-force-2fa-enable" value="yes" <?php echo ($force_2fa_enabled === 'yes') ? 'checked' : ''; ?> >
664 + <label class="cozmoslabs-toggle-track" for="wppb-force-2fa-enable"></label>
665 + </div>
666 +
667 + <div class="cozmoslabs-toggle-description">
668 + <label for="wppb-force-2fa-enable" class="cozmoslabs-description"><?php esc_html_e( 'Force users with selected roles to set up Two-Factor Authentication. Users will be redirected to their profile page if 2FA is not configured.', 'profile-builder' ); ?></label>
669 + </div>
670 + </div>
671 +
672 + <div class="cozmoslabs-form-field-wrapper" id="wppb-force-2fa-roles-selector" <?php echo $force_2fa_enabled === 'no' ? 'style="display: none;"' : '' ?> >
673 + <?php
674 + $force_2fa_roles = array( );
675 + if ( !empty( $wppb_two_factor_authentication_settings['force_2fa_roles'] ) )
676 + $force_2fa_roles = is_array( $wppb_two_factor_authentication_settings['force_2fa_roles'] ) ? $wppb_two_factor_authentication_settings['force_2fa_roles'] : array( $wppb_two_factor_authentication_settings['force_2fa_roles'] );
677 + ?>
678 +
679 + <label class="cozmoslabs-form-field-label" for="wppb-force-2fa-roles"><?php esc_html_e( 'Force 2FA For', 'profile-builder' ); ?></label>
680 +
681 + <select name="wppb_two_factor_authentication_settings[force_2fa_roles][]" id="wppb-force-2fa-roles" class="wppb-select wppb-select2" multiple>
682 + <?php
683 + // Only show roles that are enabled for 2FA
684 + $enabled_roles = isset( $wppb_two_factor_authentication_settings['roles'] ) ?
685 + $wppb_two_factor_authentication_settings['roles'] : array();
686 +
687 + // If '*' (all roles) is selected, show all roles
688 + if ( in_array( '*', $enabled_roles, true ) ) {
689 + foreach ($roles as $role_key => $role) {
690 + echo '<option value="' . esc_attr($role_key) . '"' . (in_array($role_key, $force_2fa_roles, true) ? ' selected' : '') . '>' . esc_html($role['name']) . '</option>';
691 + }
692 + } else {
693 + // Only show roles that are specifically enabled for 2FA
694 + foreach ($enabled_roles as $enabled_role) {
695 + if ( isset( $roles[$enabled_role] ) ) {
696 + echo '<option value="' . esc_attr($enabled_role) . '"' . (in_array($enabled_role, $force_2fa_roles, true) ? ' selected' : '') . '>' . esc_html($roles[$enabled_role]['name']) . '</option>';
697 + }
698 + }
699 + }
700 + ?>
701 + </select>
702 +
703 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Select which user roles will be forced to set up Two-Factor Authentication. Only roles that have 2FA enabled above are available.', 'profile-builder' ); ?></p>
704 + </div>
705 +
706 + <div class="cozmoslabs-form-field-wrapper" id="wppb-force-2fa-grace-period" <?php echo $force_2fa_enabled === 'no' ? 'style="display: none;"' : '' ?> >
707 + <?php
708 + $grace_period_days = 0;
709 + if ( !empty( $wppb_two_factor_authentication_settings['grace_period_days'] ) )
710 + $grace_period_days = intval( $wppb_two_factor_authentication_settings['grace_period_days'] );
711 + ?>
712 +
713 + <label class="cozmoslabs-form-field-label" for="wppb-force-2fa-grace-period-days"><?php esc_html_e( 'Grace Period', 'profile-builder' ); ?></label>
714 +
715 + <input type="number" name="wppb_two_factor_authentication_settings[grace_period_days]" id="wppb-force-2fa-grace-period-days" class="wppb-text" min="0" max="365" value="<?php echo esc_attr( $grace_period_days ); ?>" />
716 +
717 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Number of days users have to set up Two-Factor Authentication. Set to 0 for immediate enforcement.', 'profile-builder' ); ?></p>
718 + </div>
719 +
720 + <div class="cozmoslabs-form-field-wrapper" id="wppb-force-2fa-edit-profile-page-selector" <?php echo $force_2fa_enabled === 'no' ? 'style="display: none;"' : '' ?> >
721 + <?php
722 + $edit_profile_page_id = 'admin';
723 + if ( !empty( $wppb_two_factor_authentication_settings['edit_profile_page_id'] ) ) {
724 + $edit_profile_page_id = $wppb_two_factor_authentication_settings['edit_profile_page_id'];
725 + }
726 +
727 + // Get pages with Edit Profile shortcode or block
728 + $edit_profile_pages = array();
729 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/two-factor-authentication/class-two-factor-authentication.php' ) ) {
730 + require_once( WPPB_PAID_PLUGIN_DIR . '/features/two-factor-authentication/class-two-factor-authentication.php' );
731 + // The method only exists in paid add-on versions matching this base plugin; guard against a stale add-on to avoid a fatal error.
732 + if ( method_exists( 'WPPB_Two_Factor_Authenticator', 'get_edit_profile_pages' ) ) {
733 + $edit_profile_pages = WPPB_Two_Factor_Authenticator::get_edit_profile_pages();
734 + }
735 + }
736 + ?>
737 +
738 + <label class="cozmoslabs-form-field-label" for="wppb-force-2fa-edit-profile-page"><?php esc_html_e( 'Redirect to Edit Profile Page', 'profile-builder' ); ?></label>
739 +
740 + <select name="wppb_two_factor_authentication_settings[edit_profile_page_id]" id="wppb-force-2fa-edit-profile-page" class="wppb-select">
741 + <option value="admin" <?php selected( $edit_profile_page_id, 'admin' ); ?>><?php esc_html_e( 'Admin Profile Page', 'profile-builder' ); ?></option>
742 + <?php
743 + if ( !empty( $edit_profile_pages ) ) {
744 + foreach ( $edit_profile_pages as $page ) {
745 + echo '<option value="' . esc_attr( $page['ID'] ) . '" ' . selected( $edit_profile_page_id, $page['ID'], false ) . '>' . esc_html( $page['title'] ) . '</option>';
746 + }
747 + }
748 + ?>
749 + </select>
750 +
751 + <div class="cozmoslabs-description cozmoslabs-description-space-left">
752 + <?php
753 + if ( empty( $edit_profile_pages ) ) {
754 + echo '<div class="cozmoslabs-description cozmoslabs-description-upsell" style="margin-top: 10px;">' . esc_html__( 'No pages with Edit Profile forms found. Please create a page with the [wppb-edit-profile] shortcode or block.', 'profile-builder' ) . '</div>';
755 + } else {
756 + esc_html_e( 'Select which page users should be redirected to when they need to set up Two-Factor Authentication.', 'profile-builder' );
757 + }
758 + ?>
759 + </div>
760 + </div>
761 +
762 +
763 +
764 + </div>
765 + <?php endif; ?>
766 +
767 + <div class="cozmoslabs-form-subsection-wrapper">
768 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Other features', 'profile-builder' ); ?></h4>
769 +
770 + <div class="cozmoslabs-form-field-wrapper">
771 + <label class="cozmoslabs-form-field-label" for="hideAdminBarFor"><?php esc_html_e( 'Hide Admin Bar for User Roles', 'profile-builder' ); ?></label>
772 +
773 + <select name="wppb_general_settings[hide_admin_bar_for][]" class="wppb-select wppb-select2" id="hideAdminBarFor" multiple>
774 + <?php
775 + global $wp_roles;
776 + $general_settings = get_option( 'wppb_general_settings' );
777 + $selected_roles = isset($general_settings['hide_admin_bar_for']) ? $general_settings['hide_admin_bar_for'] : '';
778 +
779 + echo '<option value="allUserRoles"' . ( ( !empty( $selected_roles ) && in_array( 'allUserRoles', $selected_roles ) ) ? ' selected' : '' ) . '>' . esc_html__( 'All User Roles', 'profile-builder' ) . '</option>';
780 + echo '<option value="allUserRolesExceptAdmin"' . ( ( !empty( $selected_roles ) && in_array( 'allUserRolesExceptAdmin', $selected_roles ) ) ? ' selected' : '' ) . '>' . esc_html__( 'All User Roles Except Admin', 'profile-builder' ) . '</option>';
781 +
782 + foreach ( $wp_roles->roles as $role ) {
783 + $key = $role['name'];
784 +
785 + echo '<option value="'.esc_attr( $key ).'"' . ( ( !empty( $selected_roles ) && in_array( $key, $selected_roles ) ) ? ' selected' : '' ) . '>' . esc_html( translate_user_role( $key ) ) . '</option>';
786 + }
787 +
788 + ?>
789 + </select>
790 +
791 + <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Hide the WordPress Admin Bar for these user roles. You can select multiple roles to hide it for.', 'profile-builder' ); ?></p>
792 + </div>
793 +
794 + <?php
795 + if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) {
796 + ?>
797 +
798 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
799 + <label class="cozmoslabs-form-field-label" for="rolesEditorSelect"><?php esc_html_e('Roles Editor', 'profile-builder'); ?></label>
800 +
801 + <div class="cozmoslabs-toggle-container">
802 + <input type="checkbox" name="wppb_general_settings[rolesEditor]" id="rolesEditorSelect" value="yes" <?php echo (!empty($wppb_generalSettings['rolesEditor']) && $wppb_generalSettings['rolesEditor'] === 'yes') ? 'checked' : ''; ?> >
803 + <label class="cozmoslabs-toggle-track" for="rolesEditorSelect"></label>
804 + </div>
805 +
806 + <div class="cozmoslabs-toggle-description">
807 + <label for="rolesEditorSelect" class="cozmoslabs-description wppb-roles-editor-details"><?php esc_html_e( 'Easily create new custom user roles or customize any existing user role capabilities.', 'profile-builder' ); ?></label>
808 + </div>
809 +
810 + <p class="cozmoslabs-description cozmoslabs-description-space-left wppb-roles-editor-link"><?php printf( esc_html__( 'You can add / edit user roles at %1$sUsers > Roles Editor%2$s.', 'profile-builder' ), '<a href="'. esc_url( get_bloginfo( 'url' ) ).'/wp-admin/edit.php?post_type=wppb-roles-editor">', '</a>' )?></p>
811 + </div>
812 +
813 + <?php } ?>
814 +
815 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
816 + <label class="cozmoslabs-form-field-label" for="extraFieldsLayout"><?php esc_html_e('Load CSS', 'profile-builder'); ?></label>
817 +
818 + <div class="cozmoslabs-toggle-container">
819 + <input type="checkbox" id="extraFieldsLayout" name="wppb_general_settings[extraFieldsLayout]"<?php echo ( ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ? ' checked' : '' ); ?> value="default">
820 + <label class="cozmoslabs-toggle-track" for="extraFieldsLayout"></label>
821 + </div>
822 + <div class="cozmoslabs-toggle-description">
823 + <label for="extraFieldsLayout" class="cozmoslabs-description"><?php printf( esc_html__( 'You can find the default file here: %1$s', 'profile-builder' ), '<a href="'.dirname( plugin_dir_url( __FILE__ ) ).'/assets/css/style-front-end.css" target="_blank">'.dirname( dirname( plugin_basename( __FILE__ ) ) ).'/assets/css/style-front-end.css</a>' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
824 + </div>
825 + </div>
826 +
827 + </div>
828 +
829 + <?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
830 +
831 + <input type="hidden" name="action" value="update" />
832 +
833 + </div>
834 +
835 + <div class="submit cozmoslabs-submit">
836 + <h3 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Update Settings', 'profile-builder' ) ?></h3>
837 + <div class="cozmoslabs-publish-button-group">
838 + <p class="submit">
839 + <input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'profile-builder' ); ?>" />
840 + </p>
841 + </div>
842 + </div>
843 +
844 + </form>
845 +
846 + </div>
847 +
848 + </div>
849 +
425 850 <?php
426 851 }
427 852
428 853
@@ -502,9 +927,9 @@
502 927 ),
503 928 ),
504 929 array(
505 930 'id' => 'form-style-1',
506 - 'name' => 'Style 1',
931 + 'name' => 'Sublime',
507 932 'images' => array(
508 933 'main' => WPPB_PLUGIN_URL.'assets/images/style1-slide1.jpg',
509 934 'slide1' => WPPB_PLUGIN_URL.'assets/images/style1-slide2.jpg',
510 935 'slide2' => WPPB_PLUGIN_URL.'assets/images/style1-slide3.jpg',
@@ -511,9 +936,9 @@
511 936 ),
512 937 ),
513 938 array(
514 939 'id' => 'form-style-2',
515 - 'name' => 'Style 2',
940 + 'name' => 'Greenery',
516 941 'images' => array(
517 942 'main' => WPPB_PLUGIN_URL.'assets/images/style2-slide1.jpg',
518 943 'slide1' => WPPB_PLUGIN_URL.'assets/images/style2-slide2.jpg',
519 944 'slide2' => WPPB_PLUGIN_URL.'assets/images/style2-slide3.jpg',
@@ -520,9 +945,9 @@
520 945 ),
521 946 ),
522 947 array(
523 948 'id' => 'form-style-3',
524 - 'name' => 'Style 3',
949 + 'name' => 'Slim',
525 950 'images' => array(
526 951 'main' => WPPB_PLUGIN_URL.'assets/images/style3-slide1.jpg',
527 952 'slide1' => WPPB_PLUGIN_URL.'assets/images/style3-slide2.jpg',
528 953 'slide2' => WPPB_PLUGIN_URL.'assets/images/style3-slide3.jpg',
@@ -533,27 +958,27 @@
533 958 $output = '<div id="wppb-forms-design-browser">';
534 959
535 960 foreach ( $form_designs_data as $form_design ) {
536 961
537 - if ( $form_design['id'] != 'form-style-default' )
538 - $preview_button = '<div class="wppb-forms-design-preview" id="'. $form_design['id'] .'-info">Preview</div>';
539 - else $preview_button = '';
962 + if ( $form_design['id'] != 'form-style-default' ) {
963 + $preview_button = '<div class="wppb-forms-design-preview button-secondary" id="' . $form_design['id'] . '-info">Preview</div>';
964 + $title = esc_html__( 'Available in the Pro versions of the plugin', 'profile-builder' );
965 + }
966 + else {
967 + $preview_button = '';
968 + $title = '';
969 + }
540 970
541 - $output .= '
542 - <div class="wppb-forms-design" id="'. $form_design['id'] .'">
543 - <div class="wppb-forms-design-screenshot">
544 - <img src="' . $form_design['images']['main'] . '" alt="Form Design">
545 - '. $preview_button .'
546 - </div>
547 - <div class="wppb-forms-design-details">
548 - <div class="wppb-forms-design-title" style="border:none;">
549 - <h2>'. $form_design['name'] .'</h2>
550 - </div>
971 + $output .= '<div class="wppb-forms-design" id="'. $form_design['id'] .'" title="'. $title .'">
972 + <label>
973 + <input type="radio" id="wppb-fd-option-' . $form_design['id'] . '" value="' . $form_design['id'] . '" name="" disabled ' . ( $form_design['id'] == 'form-style-default' ? 'checked' : '' ) .'>
974 + ' . $form_design['name'] . '</label>
975 + <div class="wppb-forms-design-screenshot">
976 + <img src="' . $form_design['images']['main'] . '" alt="Form Design">
977 + '. $preview_button .'
978 + </div>
979 + </div>';
551 980
552 - </div>
553 - </div>
554 - ';
555 -
556 981 $img_count = 0;
557 982 $image_list = '';
558 983 foreach ( $form_design['images'] as $image ) {
559 984 $img_count++;
@@ -584,6 +1009,94 @@
584 1009 }
585 1010
586 1011 $output .= '</div>';
587 1012
1013 + $output .= '<p class="cozmoslabs-description cozmoslabs-description-upsell">'. sprintf( esc_html__( 'You can now beautify your forms using pre-made templates. Enable %3$sForm Designs%4$s by upgrading to %1$sBasic or PRO versions%2$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=pb-general-settings&utm_medium=client-site&utm_campaign=pb-form-design-templates#pricing" target="_blank">', '</a>', '<strong>', '</strong>' ) .'</p>';
1014 +
588 1015 return $output;
1016 +}
1017 +
1018 +
1019 +/*
1020 + * Generate the Register Version Form
1021 + *
1022 + */
1023 +function wppb_add_register_version_form() {
1024 + $status = wppb_get_serial_number_status();
1025 + $license = wppb_get_serial_number();
1026 + $license_details = get_option( 'wppb_license_details', false );
1027 +
1028 + if( !empty( $license ) ){
1029 + // process license so it doesn't get displayed in back-end
1030 + $license_length = strlen( $license );
1031 + $license = substr_replace( $license, '***************', 7, $license_length - 14 );
1032 + }
1033 + ?>
1034 +
1035 + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Register Website', 'profile-builder' ) ?></h4>
1036 +
1037 + <form method="post" action="<?php echo !is_multisite() ? 'options.php' : 'edit.php'; ?>">
1038 + <?php settings_fields( 'wppb_license_key' ); ?>
1039 +
1040 + <div class="cozmoslabs-form-field-wrapper cozmoslabs-form-field-serial-number">
1041 +
1042 + <label class="cozmoslabs-form-field-label" for="wppb_license_key"><?php esc_html_e( 'License key', 'profile-builder' ); ?></label>
1043 +
1044 + <div class="cozmoslabs-serial-wrap__holder">
1045 + <input id="wppb_license_key" name="wppb_license_key" type="text" class="regular-text" value="<?php echo esc_attr( $license ); ?>" />
1046 + <?php wp_nonce_field( 'wppb_license_nonce', 'wppb_license_nonce' ); ?>
1047 +
1048 + <?php if( $status !== false && $status == 'valid' ) {
1049 + $button_name = 'wppb_edd_license_deactivate';
1050 + $button_value = __('Deactivate License', 'profile-builder' );
1051 +
1052 + if( empty( $details['invalid'] ) )
1053 + echo '<span title="'. esc_html__( 'Active on this site', 'profile-builder' ) .'" class="wppb-active-license dashicons dashicons-yes"></span>';
1054 + else
1055 + echo '<span title="'. esc_html__( 'Your license is invalid', 'profile-builder' ) .'" class="wppb-invalid-license dashicons dashicons-warning"></span>';
1056 +
1057 + } else {
1058 + $button_name = 'wppb_edd_license_activate';
1059 + $button_value = __('Activate License', 'profile-builder');
1060 + }
1061 + ?>
1062 + <input type="submit" class="button-secondary" name="<?php echo esc_attr( $button_name ); ?>" value="<?php echo esc_attr( $button_value ); ?>"/>
1063 + </div>
1064 +
1065 + <?php if( $status != 'expired' && ( !empty( $license_details ) && !empty( $license_details->expires ) && $license_details->expires !== 'lifetime' ) && ( ( !isset( $license_details->subscription_status ) || $license_details->subscription_status != 'active' ) && strtotime( $license_details->expires ) < strtotime( '+14 days' ) ) ) : ?>
1066 + <div class="cozmoslabs-description-container yellow">
1067 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( 'Your %s license is about to expire on %s', 'profile-builder' ), '<strong>' . PROFILE_BUILDER . '</strong>', '<strong>' . date_i18n( get_option( 'date_format' ), strtotime( $license_details->expires ) ) . '</strong>' ) ); ?>
1068 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( 'Please %sRenew Your Licence%s to continue receiving access to new features, premium addons, product downloads & automatic updates — including important security patches and WordPress compatibility.', 'profile-builder' ), "<a href='https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_campaign=PBPro&utm_content=license-about-to-expire' target='_blank'>", "</a>" ) ); ?></p>
1069 + </div>
1070 + <?php elseif( $status == 'expired' ) : ?>
1071 + <div class="cozmoslabs-description-container red">
1072 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( 'Your %s license has expired.', 'profile-builder' ), '<strong>' . PROFILE_BUILDER . '</strong>' ) ); ?>
1073 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( 'Please %1$sRenew Your Licence%2$s to continue receiving access to new features, premium addons, product downloads & automatic updates — including important security patches and WordPress compatibility.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_campaign=PBPro&utm_content=license-expired" target="_blank">', '</a>' ) ); ?></p>
1074 + </div>
1075 + <?php elseif( $status == 'no_activations_left' ) : ?>
1076 + <div class="cozmoslabs-description-container red">
1077 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( 'Your %s license has reached its activation limit.', 'profile-builder' ), '<strong>' . PROFILE_BUILDER . '</strong>' ) ); ?>
1078 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( '%sUpgrade now%s for unlimited activations and extra features like multiple registration and edit profile forms, userlisting, custom redirects and more.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_campaign=PBPro&utm_content=license-activation-limit" target="_blank">', '</a>' ) ); ?>
1079 + </div>
1080 + <?php elseif( empty( $license ) || $status != 'valid' ) : ?>
1081 + <div class="cozmoslabs-description-container">
1082 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( 'Enter your license key. Your license key can be found in your %sCozmoslabs account%s. ', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_campaign=PBPro&utm_content=license-missing" target="_blank">', '</a>' ) ); ?></p>
1083 + <p class="cozmoslabs-description"><?php echo wp_kses_post( sprintf( __( 'You can use this core version of Profile Builder for free. For priority support and advanced functionality, %sa license key is required%s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_campaign=PBPro&utm_content=license-missing#pricing" target="_blank">', '</a>' ) ); ?></p>
1084 + </div>
1085 + <?php endif; ?>
1086 +
1087 + </div>
1088 + </form>
1089 +
1090 + <?php
1091 +}
1092 +
1093 +
1094 +/*
1095 + * Load scripts and styles we need on the page ( ex. Select2 )
1096 + *
1097 + */
1098 +function wppb_load_necessary_scripts() {
1099 + wp_enqueue_script( 'wppb-select2', WPPB_PLUGIN_URL . 'assets/js/select2/select2.min.js', array(), PROFILE_BUILDER_VERSION );
1100 + wp_enqueue_script( 'wppb-select2-compat', WPPB_PLUGIN_URL . 'assets/js/select2-compat.js', array(), PROFILE_BUILDER_VERSION );
1101 + wp_enqueue_style( 'wppb_select2_css', WPPB_PLUGIN_URL .'assets/css/select2/select2.min.css', array(), PROFILE_BUILDER_VERSION );
589 1102 }