PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.9
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.9
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 / admin / general-settings.php

general-settings.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.9, at admin/general-settings.php

694 lines 37.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 /**
4 * Function that returns an array with the settings tabs(pages) and secondary tabs( can be sub-pages (we load a registered page as a secondary tab) or actual sub-tabs )
5 * @return array with the tabs
6 */
7 function wppb_get_settings_pages(){
8 $wppb_module_settings = get_option('wppb_module_settings');
9
10 $settings_pages['pages'] = array(
11 'profile-builder-general-settings' => __( 'General Settings', 'profile-builder' ),
12 'profile-builder-content_restriction' => __( 'Content Restriction', 'profile-builder' ),
13 'profile-builder-private-website' => __( 'Private Website', 'profile-builder' ),
14 'profile-builder-toolbox-settings' => __( 'Advanced Settings', 'profile-builder' ),
15 );
16
17 //add tabs here for Advanced Settings
18 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['forms'] = __( 'Forms', 'profile-builder' );
19 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['fields'] = __( 'Fields', 'profile-builder' );
20
21 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php' ) && isset( $wppb_module_settings['wppb_userListing'] ) && $wppb_module_settings['wppb_userListing'] === 'show' )
22 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['userlisting'] = __( 'Userlisting', 'profile-builder' );
23
24 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['shortcodes'] = __( 'Shortcodes', 'profile-builder' );
25 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['admin'] = __( 'Admin', 'profile-builder' );
26
27 //add sub-pages here for email customizer
28 if( file_exists( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' ) ){
29
30 $settings_pages['pages']['user-email-customizer'] = __( 'Email Customizer', 'profile-builder' );
31 $settings_pages['sub-pages']['user-email-customizer']['user-email-customizer'] = __( 'User Emails', 'profile-builder' );
32 $settings_pages['sub-pages']['user-email-customizer']['admin-email-customizer'] = __( 'Administrator Emails', 'profile-builder' );
33
34 } else if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php' ) ) {
35 if( ( isset($wppb_module_settings['wppb_emailCustomizerAdmin']) && $wppb_module_settings['wppb_emailCustomizerAdmin'] == 'show' ) || ( isset($wppb_module_settings['wppb_emailCustomizer']) && $wppb_module_settings['wppb_emailCustomizer'] == 'show') ){
36 $settings_pages['pages']['user-email-customizer'] = __( 'Email Customizer', 'profile-builder' );
37 $settings_pages['sub-pages']['user-email-customizer']['user-email-customizer'] = __( 'User Emails', 'profile-builder' );
38 $settings_pages['sub-pages']['user-email-customizer']['admin-email-customizer'] = __( 'Administrator Emails', 'profile-builder' );
39 }
40 }
41
42 return $settings_pages;
43 }
44
45 /**
46 * Function that generates the html for the tabs and subtabs on the settings page
47 */
48 function wppb_generate_settings_tabs(){
49 ?>
50 <nav class="nav-tab-wrapper cozmoslabs-nav-tab-wrapper">
51 <?php
52 $pages = wppb_get_settings_pages();
53
54 $active_tab = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
55 //if we are on a subpage we need to change the active tab to the parent
56 if( !empty( $pages['sub-pages'] ) ) {
57 foreach ($pages['sub-pages'] as $parent_slug => $subpages) {
58 if (array_key_exists($active_tab, $subpages)) {
59 $active_tab = $parent_slug;
60 }
61 }
62 }
63
64 foreach( $pages['pages'] as $page_slug => $tab_name ){
65 echo '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => $page_slug ), 'admin.php' ) ) ) . '" class="nav-tab ' . ( $active_tab == $page_slug ? 'nav-tab-active' : '' ) . '">'. esc_html( $tab_name ) .'</a>';
66 }
67 ?>
68 </nav>
69 <?php
70
71 // this is not always the same as the active tab
72 $active_subpage = sanitize_text_field($_GET['page']);
73
74 if( !empty( $pages['sub-pages'] ) ) {
75 foreach ($pages['sub-pages'] as $parent_slug => $subpages) {
76 if (array_key_exists( sanitize_text_field( $active_subpage ), $subpages)) {
77 echo '<ul class="wppb-subtabs subsubsub cozmoslabs-nav-sub-tab-wrapper">';
78 foreach ($subpages as $subpage_slug => $subpage_name) {
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>';
80 }
81 echo '</ul>';
82 }
83 }
84 }
85
86 if( !empty( $pages['sub-tabs'] ) ) {
87 foreach ($pages['sub-tabs'] as $parent_slug => $tabs) {
88 if ( $active_subpage == $parent_slug) {
89 echo '<ul class="wppb-subtabs subsubsub cozmoslabs-nav-sub-tab-wrapper">';
90 //determine the active tab, if no tab present then default to the first one
91 if( isset($_GET['tab']) )
92 $active_tab = sanitize_text_field( $_GET['tab'] );
93 else {
94 $keys = array_keys($tabs);
95 $active_tab = array_shift( $keys );
96 }
97 foreach ($tabs as $tab_slug => $tab_name) {
98 echo '<li><a href="' . esc_url( add_query_arg( array('tab' => $tab_slug) ) ) . '" class="nav-sub-tab ' . ( $active_tab == $tab_slug ? 'current' : '') . '">' . esc_html( $tab_name ) . '</a></li>';
99 }
100 echo '</ul>';
101 }
102 }
103 }
104 }
105
106 /**
107 * Function that creates the "General Settings" submenu page
108 *
109 * @since v.2.0
110 *
111 * @return void
112 */
113 function wppb_register_general_settings_submenu_page() {
114 add_submenu_page( 'profile-builder', __( 'Settings', 'profile-builder' ), __( 'Settings', 'profile-builder' ), 'manage_options', 'profile-builder-general-settings', 'wppb_general_settings_content' );
115 }
116 add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 );
117
118
119 function wppb_generate_default_settings_defaults(){
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' => '' ) );
121 }
122
123
124 /**
125 * Function that adds content to the "General Settings" submenu page
126 *
127 * @since v.2.0
128 *
129 * @return string
130 */
131 function wppb_general_settings_content() {
132 wppb_generate_default_settings_defaults();
133 ?>
134 <div class="wrap wppb-wrap cozmoslabs-wrap">
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
150 <?php settings_errors(); ?>
151
152 <?php wppb_generate_settings_tabs() ?>
153
154 <?php wppb_load_necessary_scripts(); ?>
155
156 <?php wppb_add_register_version_form() ?>
157
158 <form method="post" action="options.php#general-settings">
159 <?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?>
160 <?php settings_fields( 'wppb_general_settings' ); ?>
161
162
163 <div class="cozmoslabs-form-subsection-wrapper" id="wppb-form_desings">
164 <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Design & User Experience', 'profile-builder' ); ?></h4>
165 <p class="cozmoslabs-description" style="margin-bottom: 5px;"><?php esc_html_e( 'Choose a style that better suits your website.', 'profile-builder' ); ?></p>
166 <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>
167
168 <div class="cozmoslabs-form-field-wrapper">
169 <?php
170 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/form-designs/form-designs.php' ) ) {
171 echo wppb_render_forms_design_selector(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
172 }
173 elseif ( PROFILE_BUILDER == 'Profile Builder Free' ) {
174 echo wppb_display_form_designs_preview(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
175 }
176 ?>
177 </div>
178 </div>
179
180 <div class="cozmoslabs-form-subsection-wrapper">
181 <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Optimize The login and Registration flow for your members', 'profile-builder' ); ?></h4>
182
183 <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
184 <label class="cozmoslabs-form-field-label" for="wppb_settings_automatically_log_in"><?php esc_html_e('Automatically Log In', 'profile-builder'); ?></label>
185
186 <div class="cozmoslabs-toggle-container">
187 <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' : ''; ?> >
188 <label class="cozmoslabs-toggle-track" for="wppb_settings_automatically_log_in"></label>
189 </div>
190
191 <div class="cozmoslabs-toggle-description">
192 <p class="cozmoslabs-description"><?php esc_html_e( 'Select "Yes" to automatically log in new users after successful registration.', 'profile-builder' ); ?></p>
193 </div>
194 </div>
195
196 <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
197 <label class="cozmoslabs-form-field-label" for="wppb_settings_email_confirmation"><?php esc_html_e('Email Confirmation', 'profile-builder'); ?></label>
198
199
200 <div class="cozmoslabs-toggle-container">
201
202 <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' : ''; ?> >
203 <label class="cozmoslabs-toggle-track" for="wppb_settings_email_confirmation"></label>
204
205 </div>
206 <div class="cozmoslabs-toggle-description">
207 <p 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' ); ?></p>
208 <p class="cozmoslabs-description" 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>
209 </div>
210 </div>
211
212
213
214
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>
217
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' ) ) ) );
223
224 foreach ( $pages as $key => $value ){
225 echo '<option value="'.esc_attr( $value->ID ).'"';
226 if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
227 echo ' selected';
228
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
238
239 <?php
240 if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
241 ?>
242
243 <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
244 <label class="cozmoslabs-form-field-label"><?php esc_html_e('Admin Approval', 'profile-builder'); ?></label>
245
246 <p class="cozmoslabs-description cozmoslabs-description-align-right">
247 <?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#pricing">', '</a>' )?>
248 </p>
249 </div>
250
251 <?php } ?>
252
253
254 <?php
255 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){
256 ?>
257
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>
260
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>
265
266 <div class="cozmoslabs-toggle-description">
267 <p class="cozmoslabs-description 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>
268 </div>
269 </div>
270
271 <div class="cozmoslabs-form-field-wrapper wppb-aa-user-list">
272 <label class="cozmoslabs-form-field-label" for="adminApprovalOnUserRoleSelect"><?php esc_html_e('Admin Approval User Role', 'profile-builder'); ?></label>
273
274 <select name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-select wppb-select2" multiple>
275 <?php
276 $wppb_userRoles = wppb_adminApproval_onUserRole();
277
278 if( ! empty( $wppb_userRoles ) ) {
279 foreach( $wppb_userRoles as $role => $role_name ) {
280
281 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>';
282
283 }
284 }
285 ?>
286 </select>
287 </div>
288
289 <?php } ?>
290
291
292 <?php
293 if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) {
294 ?>
295
296 <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
297 <label class="cozmoslabs-form-field-label" for="rolesEditorSelect"><?php esc_html_e('Roles Editor', 'profile-builder'); ?></label>
298
299 <div class="cozmoslabs-toggle-container">
300 <input type="checkbox" name="wppb_general_settings[rolesEditor]" id="rolesEditorSelect" value="yes" <?php echo (!empty($wppb_generalSettings['rolesEditor']) && $wppb_generalSettings['rolesEditor'] === 'yes') ? 'checked' : ''; ?> >
301 <label class="cozmoslabs-toggle-track" for="rolesEditorSelect"></label>
302 </div>
303
304 <div class="cozmoslabs-toggle-description">
305 <p class="cozmoslabs-description 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>
306 </div>
307 </div>
308
309 <?php } ?>
310
311
312 <div class="cozmoslabs-form-field-wrapper">
313 <label class="cozmoslabs-form-field-label" for="loginWithSelect"><?php esc_html_e( 'Allow Users to Log in With:', 'profile-builder' ); ?></label>
314
315 <select name="wppb_general_settings[loginWith]" class="wppb-select" id="loginWithSelect">
316 <option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php esc_html_e( 'Username and Email', 'profile-builder' ); ?></option>
317 <option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php esc_html_e( 'Username', 'profile-builder' ); ?></option>
318 <option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php esc_html_e( 'Email', 'profile-builder' ); ?></option>
319 </select>
320
321 <p class="cozmoslabs-description cozmoslabs-description-space-left"><?php esc_html_e( 'Choose what the user will be logging in with.', 'profile-builder' ); ?></p>
322 </div>
323
324
325 <div class="cozmoslabs-form-field-wrapper">
326 <label class="cozmoslabs-form-field-label" for="minimumPasswordLength"><?php esc_html_e( 'Minimum Password Length', 'profile-builder' ); ?></label>
327 <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'] ); ?>"/>
328
329 <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>
330 </div>
331
332
333 <div class="cozmoslabs-form-field-wrapper">
334 <label class="cozmoslabs-form-field-label" for="minimumPasswordStrength"><?php esc_html_e( 'Minimum Password Strength', 'profile-builder' ); ?></label>
335
336 <select name="wppb_general_settings[minimum_password_strength]" class="wppb-select" id="minimumPasswordStrength">
337 <option value=""><?php esc_html_e( 'Disabled', 'profile-builder' ); ?></option>
338 <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>
339 <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>
340 <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>
341 <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>
342 </select>
343
344 <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>
345 </div>
346
347
348 <div class="cozmoslabs-form-field-wrapper">
349 <label class="cozmoslabs-form-field-label" for="lostPasswordPage"><?php esc_html_e( 'Password Recovery Page', 'profile-builder' ); ?></label>
350
351 <select name="wppb_general_settings[lost_password_page]" class="wppb-select" id="lostPasswordPage">
352 <option value=""> <?php esc_html_e( 'None', 'profile-builder' ); ?></option>
353 <?php
354 $args = array(
355 'post_type' => 'page',
356 'post_status' => 'publish',
357 'numberposts' => -1,
358 'orderby' => 'name',
359 'order' => 'ASC'
360 );
361 $pages = get_posts( $args );
362
363 foreach ( $pages as $key => $value ){
364 echo '<option value="'.esc_attr( $value->guid ).'"';
365 if ( isset( $wppb_generalSettings['lost_password_page'] ) && $wppb_generalSettings['lost_password_page'] == $value->guid )
366 echo ' selected';
367
368 echo '>' . esc_html( $value->post_title ) . '</option>';
369 }
370 ?>
371 </select>
372
373 <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>
374 </div>
375
376
377 <div class="cozmoslabs-form-field-wrapper">
378 <label class="cozmoslabs-form-field-label" for="hideAdminBarFor"><?php esc_html_e( 'Hide Admin Bar for User Roles', 'profile-builder' ); ?></label>
379
380 <select name="wppb_general_settings[hide_admin_bar_for][]" class="wppb-select wppb-select2" id="hideAdminBarFor" multiple>
381 <?php
382 global $wp_roles;
383 $general_settings = get_option( 'wppb_general_settings' );
384 $selected_roles = isset($general_settings['hide_admin_bar_for']) ? $general_settings['hide_admin_bar_for'] : '';
385
386 foreach ( $wp_roles->roles as $role ) {
387 $key = $role['name'];
388
389 echo '<option value="'.esc_attr( $key ).'"' . ( ( !empty( $selected_roles ) && in_array( $key, $selected_roles ) ) ? ' selected' : '' ) . '>' . esc_html( translate_user_role( $key ) ) . '</option>';
390 }
391 ?>
392 </select>
393
394 <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>
395 </div>
396
397
398 <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
399 <?php
400 $wppb_two_factor_authentication_settings = get_option( 'wppb_two_factor_authentication_settings', 'not_found' );
401
402 $enabled = 'no';
403 if ( !empty( $wppb_two_factor_authentication_settings['enabled'] ) )
404 $enabled = $wppb_two_factor_authentication_settings['enabled'];
405 ?>
406
407 <label class="cozmoslabs-form-field-label" for="wppb-auth-enable"><?php esc_html_e('Two-Factor Authentication', 'profile-builder'); ?></label>
408
409 <div class="cozmoslabs-toggle-container">
410 <input type="checkbox" name="wppb_two_factor_authentication_settings[enabled]" id="wppb-auth-enable" value="yes" <?php echo ($enabled === 'yes') ? 'checked' : ''; ?> >
411 <label class="cozmoslabs-toggle-track" for="wppb-auth-enable"></label>
412 </div>
413
414 <div class="cozmoslabs-toggle-description">
415 <p class="cozmoslabs-description"><?php esc_html_e( 'Activate the Google Authenticator functionality.', 'profile-builder' ); ?></p>
416 </div>
417 </div>
418
419
420 <div class="cozmoslabs-form-field-wrapper" id="wppb-auth-roles-selector" <?php echo $enabled === 'no' ? 'style="display: none;"' : '' ?> >
421 <?php
422 $roles = get_editable_roles( );
423 $network_roles = array( );
424 if ( !empty( $wppb_two_factor_authentication_settings['roles'] ) )
425 $network_roles = is_array( $wppb_two_factor_authentication_settings['roles'] ) ? $wppb_two_factor_authentication_settings['roles'] : array( $wppb_two_factor_authentication_settings['roles'] );
426 ?>
427
428 <label class="cozmoslabs-form-field-label" for="wppb-auth-enable-roles"><?php esc_html_e( 'Enable Authenticator For', 'profile-builder' ); ?></label>
429
430 <select name="wppb_two_factor_authentication_settings[roles][]" id="wppb-auth-enable-roles" class="wppb-select wppb-select2" multiple>
431 <?php
432 echo '<option value="*"' . (in_array('*', $network_roles, true) ? ' selected' : '') . '>'. esc_html__('ALL ROLES', 'profile-builder') .'</option>';
433
434 foreach ($roles as $role_key => $role) {
435 echo '<option value="' . esc_attr($role_key) . '"' . (in_array($role_key, $network_roles, true) ? ' selected' : '') . '>' . esc_html($role['name']) . '</option>';
436 }
437 ?>
438 </select>
439
440 <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>
441 </div>
442
443
444 <div class="cozmoslabs-form-field-wrapper cozmoslabs-toggle-switch">
445 <label class="cozmoslabs-form-field-label" for="extraFieldsLayout"><?php esc_html_e('Load CSS', 'profile-builder'); ?></label>
446
447 <div class="cozmoslabs-toggle-container">
448 <input type="checkbox" id="extraFieldsLayout" name="wppb_general_settings[extraFieldsLayout]"<?php echo ( ( isset( $wppb_generalSettings['extraFieldsLayout'] ) && ( $wppb_generalSettings['extraFieldsLayout'] == 'default' ) ) ? ' checked' : '' ); ?> value="default">
449 <label class="cozmoslabs-toggle-track" for="extraFieldsLayout"></label>
450 </div>
451 <div class="cozmoslabs-toggle-description">
452 <p 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 ?></p>
453 </div>
454 </div>
455
456
457 <?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
458
459
460 </div>
461
462 <input type="hidden" name="action" value="update" />
463 <p class="submit"><input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'profile-builder' ); ?>" /></p>
464 </form>
465 </div>
466
467 <?php
468 }
469
470
471 /*
472 * Function that sanitizes the general settings
473 *
474 * @param array $wppb_generalSettings
475 *
476 * @since v.2.0.7
477 */
478 function wppb_general_settings_sanitize( $wppb_generalSettings ) {
479 $wppb_generalSettings = apply_filters( 'wppb_general_settings_sanitize_extra', $wppb_generalSettings );
480
481 if( !empty( $wppb_generalSettings ) ){
482 foreach( $wppb_generalSettings as $settings_name => $settings_value ){
483 if( $settings_name == "minimum_password_length" || $settings_name == "activationLandingPage" )
484 $wppb_generalSettings[$settings_name] = absint( $settings_value );
485 elseif( $settings_name == "extraFieldsLayout" || $settings_name == "emailConfirmation" || $settings_name == "adminApproval" || $settings_name == "loginWith" || $settings_name == "minimum_password_strength" )
486 $wppb_generalSettings[$settings_name] = sanitize_text_field( $settings_value );
487 elseif( $settings_name == "adminApprovalOnUserRole" ){
488 if( is_array( $settings_value ) && !empty( $settings_value ) ){
489 foreach( $settings_value as $key => $value ){
490 $wppb_generalSettings[$settings_name][$key] = sanitize_text_field( $value );
491 }
492 }
493 }
494 }
495 }
496
497 return $wppb_generalSettings;
498 }
499
500
501 /*
502 * Function that pushes settings errors to the user
503 *
504 * @since v.2.0.7
505 */
506 function wppb_general_settings_admin_notices() {
507 settings_errors( 'wppb_general_settings' );
508 }
509 add_action( 'admin_notices', 'wppb_general_settings_admin_notices' );
510
511
512 /*
513 * Function that return user roles
514 *
515 * @since v.2.2.0
516 *
517 * @return array
518 */
519 function wppb_adminApproval_onUserRole() {
520 global $wp_roles;
521
522 $wp_roles = new WP_Roles();
523
524 $roles = $wp_roles->get_names();
525
526 unset( $roles['administrator'] );
527
528 return $roles;
529 }
530
531
532
533 /*
534 * Generate the Form Designs Preview Showcase
535 *
536 */
537 function wppb_display_form_designs_preview() {
538 $form_designs_data = array(
539 array(
540 'id' => 'form-style-default',
541 'name' => 'Default',
542 'images' => array(
543 'main' => WPPB_PLUGIN_URL.'assets/images/pb-default-forms.jpg',
544 ),
545 ),
546 array(
547 'id' => 'form-style-1',
548 'name' => 'Style 1',
549 'images' => array(
550 'main' => WPPB_PLUGIN_URL.'assets/images/style1-slide1.jpg',
551 'slide1' => WPPB_PLUGIN_URL.'assets/images/style1-slide2.jpg',
552 'slide2' => WPPB_PLUGIN_URL.'assets/images/style1-slide3.jpg',
553 ),
554 ),
555 array(
556 'id' => 'form-style-2',
557 'name' => 'Style 2',
558 'images' => array(
559 'main' => WPPB_PLUGIN_URL.'assets/images/style2-slide1.jpg',
560 'slide1' => WPPB_PLUGIN_URL.'assets/images/style2-slide2.jpg',
561 'slide2' => WPPB_PLUGIN_URL.'assets/images/style2-slide3.jpg',
562 ),
563 ),
564 array(
565 'id' => 'form-style-3',
566 'name' => 'Style 3',
567 'images' => array(
568 'main' => WPPB_PLUGIN_URL.'assets/images/style3-slide1.jpg',
569 'slide1' => WPPB_PLUGIN_URL.'assets/images/style3-slide2.jpg',
570 'slide2' => WPPB_PLUGIN_URL.'assets/images/style3-slide3.jpg',
571 ),
572 )
573 );
574
575 $output = '<div id="wppb-forms-design-browser">';
576
577 foreach ( $form_designs_data as $form_design ) {
578
579 if ( $form_design['id'] != 'form-style-default' )
580 $preview_button = '<div class="wppb-forms-design-preview button-secondary" id="'. $form_design['id'] .'-info">Preview</div>';
581 else $preview_button = '';
582
583 $output .= '<div class="wppb-forms-design" id="'. $form_design['id'] .'">
584 <label>' . $form_design['name'] . '</label>
585 <div class="wppb-forms-design-screenshot">
586 <img src="' . $form_design['images']['main'] . '" alt="Form Design">
587 '. $preview_button .'
588 </div>
589 </div>';
590
591 $img_count = 0;
592 $image_list = '';
593 foreach ( $form_design['images'] as $image ) {
594 $img_count++;
595 $active_img = ( $img_count == 1 ) ? ' active' : '';
596 $image_list .= '<img class="wppb-forms-design-preview-image'. $active_img .'" src="'. $image .'">';
597 }
598
599 if ( $img_count > 1 ) {
600 $previous_button = '<div class="wppb-slideshow-button wppb-forms-design-sildeshow-previous disabled" data-theme-id="'. $form_design['id'] .'" data-slideshow-direction="previous"> < </div>';
601 $next_button = '<div class="wppb-slideshow-button wppb-forms-design-sildeshow-next" data-theme-id="'. $form_design['id'] .'" data-slideshow-direction="next"> > </div>';
602 $justify_content = 'space-between';
603 }
604 else {
605 $previous_button = $next_button = '';
606 $justify_content = 'center';
607 }
608
609 $output .= '<div id="modal-'. $form_design['id'] .'" class="wppb-forms-design-modal" title="'. $form_design['name'] .'">
610 <div class="wppb-forms-design-modal-slideshow" style="justify-content: '. $justify_content .'">
611 '. $previous_button .'
612 <div class="wppb-forms-design-modal-images">
613 '. $image_list .'
614 </div>
615 '. $next_button .'
616 </div>
617 </div>';
618
619 }
620
621 $output .= '</div>';
622
623 $output .= '<p class="cozmoslabs-description">'. sprintf( esc_html__( 'You can now beautify your forms using new Styles. 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=wpbackend&utm_medium=clientsite&utm_content=general-settings-link&utm_campaign=PBFree#pricing" target="_blank">', '</a>', '<strong>', '</strong>' ) .'</p>';
624
625 return $output;
626 }
627
628
629 /*
630 * Generate the Register Version Form
631 *
632 */
633 function wppb_add_register_version_form() {
634
635 if ( !defined( 'WPPB_PAID_PLUGIN_DIR' ) && !defined( 'PROFILE_BUILDER_PAID_VERSION' ) )
636 return '';
637
638 $status = wppb_get_serial_number_status();
639 $license = wppb_get_serial_number();
640 ?>
641
642 <div class="cozmoslabs-form-subsection-wrapper" id="wppb-register-version">
643 <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Register Website', 'profile-builder' ) ?></h4>
644
645 <form method="post" action="<?php echo !is_multisite() ? 'options.php' : 'edit.php'; ?>">
646 <?php settings_fields( 'wppb_license_key' ); ?>
647
648 <div class="cozmoslabs-form-field-wrapper">
649
650 <label class="cozmoslabs-form-field-label" for="wppb_license_key"><?php esc_html_e( 'License key', 'profile-builder' ); ?></label>
651
652 <div class="cozmoslabs-serial-wrap__holder">
653 <input id="wppb_license_key" name="wppb_license_key" type="password" class="regular-text" value="<?php echo esc_attr( $license ); ?>" />
654 <?php wp_nonce_field( 'wppb_license_nonce', 'wppb_license_nonce' ); ?>
655
656 <?php if( $status !== false && $status == 'valid' ) {
657 $button_name = 'wppb_edd_license_deactivate';
658 $button_value = __('Deactivate License', 'profile-builder' );
659
660 if( empty( $details['invalid'] ) )
661 echo '<span title="'. esc_html__( 'Active on this site', 'profile-builder' ) .'" class="wppb-active-license dashicons dashicons-yes"></span>';
662 else
663 echo '<span title="'. esc_html__( 'Your license is invalid', 'profile-builder' ) .'" class="wppb-invalid-license dashicons dashicons-warning"></span>';
664
665 } else {
666 $button_name = 'wppb_edd_license_activate';
667 $button_value = __('Activate License', 'profile-builder');
668 }
669 ?>
670 <input type="submit" class="button-secondary" name="<?php echo esc_attr( $button_name ); ?>" value="<?php echo esc_attr( $button_value ); ?>"/>
671 </div>
672
673 <div class="cozmoslabs-description-container">
674 <p class="cozmoslabs-description"><?php esc_html_e( 'Enter your license key. Your license key can be found in your Cozmoslabs account. ', 'profile-builder' ) ?></p>
675 <p class="cozmoslabs-description"><?php esc_html_e( 'You can use this core version of Profile Builder for free. For priority support and advanced functionality, a license key is required.', 'profile-builder' ) ?></p>
676 </div>
677
678 </div>
679 </form>
680
681 </div>
682 <?php
683 }
684
685
686 /*
687 * Load scripts and styles we need on the page ( ex. Select2 )
688 *
689 */
690 function wppb_load_necessary_scripts() {
691 wp_enqueue_script( 'wppb-select2', WPPB_PLUGIN_URL . 'assets/js/select2/select2.min.js', array(), PROFILE_BUILDER_VERSION );
692 wp_enqueue_script( 'wppb-select2-compat', WPPB_PLUGIN_URL . 'assets/js/select2-compat.js', array(), PROFILE_BUILDER_VERSION );
693 wp_enqueue_style( 'wppb_select2_css', WPPB_PLUGIN_URL .'assets/css/select2/select2.min.css', array(), PROFILE_BUILDER_VERSION );
694 }