PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.6
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 2.0.7 All 340 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.6, at admin/general-settings.php

589 lines 28.7 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-admin-bar-settings' => __( 'Admin Bar', 'profile-builder' ),
13 'profile-builder-content_restriction' => __( 'Content Restriction', 'profile-builder' ),
14 'profile-builder-private-website' => __( 'Private Website', 'profile-builder' ),
15 'profile-builder-toolbox-settings' => __( 'Advanced Settings', 'profile-builder' ),
16 );
17
18 //add tabs here for Advanced Settings
19 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['forms'] = __( 'Forms', 'profile-builder' );
20 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['fields'] = __( 'Fields', 'profile-builder' );
21
22 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' )
23 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['userlisting'] = __( 'Userlisting', 'profile-builder' );
24
25 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['shortcodes'] = __( 'Shortcodes', 'profile-builder' );
26 $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['admin'] = __( 'Admin', 'profile-builder' );
27
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 //add sub-pages here for email customizer
34 if( file_exists( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' ) ){
35
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 } else if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php' ) ) {
41 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') ){
42 $settings_pages['pages']['user-email-customizer'] = __( 'Email Customizer', 'profile-builder' );
43 $settings_pages['sub-pages']['user-email-customizer']['user-email-customizer'] = __( 'User Emails', 'profile-builder' );
44 $settings_pages['sub-pages']['user-email-customizer']['admin-email-customizer'] = __( 'Administrator Emails', 'profile-builder' );
45 }
46 }
47
48 return $settings_pages;
49 }
50
51 /**
52 * Function that generates the html for the tabs and subtabs on the settings page
53 */
54 function wppb_generate_settings_tabs(){
55 ?>
56 <nav class="nav-tab-wrapper">
57 <?php
58 $pages = wppb_get_settings_pages();
59
60 $active_tab = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
61 //if we are on a subpage we need to change the active tab to the parent
62 if( !empty( $pages['sub-pages'] ) ) {
63 foreach ($pages['sub-pages'] as $parent_slug => $subpages) {
64 if (array_key_exists($active_tab, $subpages)) {
65 $active_tab = $parent_slug;
66 }
67 }
68 }
69
70 foreach( $pages['pages'] as $page_slug => $tab_name ){
71 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>';
72 }
73 ?>
74 </nav>
75 <?php
76
77 // this is not always the same as the active tab
78 $active_subpage = sanitize_text_field($_GET['page']);
79
80 if( !empty( $pages['sub-pages'] ) ) {
81 foreach ($pages['sub-pages'] as $parent_slug => $subpages) {
82 if (array_key_exists( sanitize_text_field( $active_subpage ), $subpages)) {
83 echo '<ul class="wppb-subtabs subsubsub">';
84 foreach ($subpages as $subpage_slug => $subpage_name) {
85 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 }
87 echo '</ul>';
88 }
89 }
90 }
91
92 if( !empty( $pages['sub-tabs'] ) ) {
93 foreach ($pages['sub-tabs'] as $parent_slug => $tabs) {
94 if ( $active_subpage == $parent_slug) {
95 echo '<ul class="wppb-subtabs subsubsub">';
96 //determine the active tab, if no tab present then default to the first one
97 if( isset($_GET['tab']) )
98 $active_tab = sanitize_text_field( $_GET['tab'] );
99 else {
100 $keys = array_keys($tabs);
101 $active_tab = array_shift( $keys );
102 }
103 foreach ($tabs as $tab_slug => $tab_name) {
104 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>';
105 }
106 echo '</ul>';
107 }
108 }
109 }
110 }
111
112 /**
113 * Function that creates the "General Settings" submenu page
114 *
115 * @since v.2.0
116 *
117 * @return void
118 */
119 function wppb_register_general_settings_submenu_page() {
120 add_submenu_page( 'profile-builder', __( 'Settings', 'profile-builder' ), __( 'Settings', 'profile-builder' ), 'manage_options', 'profile-builder-general-settings', 'wppb_general_settings_content' );
121 }
122 add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 );
123
124
125 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' ) );
127 }
128
129
130 /**
131 * Function that adds content to the "General Settings" submenu page
132 *
133 * @since v.2.0
134 *
135 * @return string
136 */
137 function wppb_general_settings_content() {
138 wppb_generate_default_settings_defaults();
139 ?>
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>
145
146 <?php settings_errors(); ?>
147
148 <?php wppb_generate_settings_tabs() ?>
149
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' ); ?>
153
154 <table class="form-table">
155
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 } ?>
169
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>
179
180 </tr>
181 <?php } ?>
182
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>
197
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>
215
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' ) ) ) );
226
227 foreach ( $pages as $key => $value ){
228 echo '<option value="'.esc_attr( $value->ID ).'"';
229 if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
230 echo ' selected';
231
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>
242
243
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>
261
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
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>
287
288 <?php } ?>
289
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 } ?>
308
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 } ?>
321
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>
339
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>
351
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>
366
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>
374 <?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 );
383
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';
388
389 echo '>' . esc_html( $value->post_title ) . '</option>';
390 }
391
392 ?>
393
394 </select>
395
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>
399
400 </td>
401 </tr>
402
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>
414
415 <?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
416 </table>
417
418
419
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>
424
425 <?php
426 }
427
428
429 /*
430 * Function that sanitizes the general settings
431 *
432 * @param array $wppb_generalSettings
433 *
434 * @since v.2.0.7
435 */
436 function wppb_general_settings_sanitize( $wppb_generalSettings ) {
437 $wppb_generalSettings = apply_filters( 'wppb_general_settings_sanitize_extra', $wppb_generalSettings );
438
439 if( !empty( $wppb_generalSettings ) ){
440 foreach( $wppb_generalSettings as $settings_name => $settings_value ){
441 if( $settings_name == "minimum_password_length" || $settings_name == "activationLandingPage" )
442 $wppb_generalSettings[$settings_name] = absint( $settings_value );
443 elseif( $settings_name == "extraFieldsLayout" || $settings_name == "emailConfirmation" || $settings_name == "adminApproval" || $settings_name == "loginWith" || $settings_name == "minimum_password_strength" )
444 $wppb_generalSettings[$settings_name] = sanitize_text_field( $settings_value );
445 elseif( $settings_name == "adminApprovalOnUserRole" ){
446 if( is_array( $settings_value ) && !empty( $settings_value ) ){
447 foreach( $settings_value as $key => $value ){
448 $wppb_generalSettings[$settings_name][$key] = sanitize_text_field( $value );
449 }
450 }
451 }
452 }
453 }
454
455 return $wppb_generalSettings;
456 }
457
458
459 /*
460 * Function that pushes settings errors to the user
461 *
462 * @since v.2.0.7
463 */
464 function wppb_general_settings_admin_notices() {
465 settings_errors( 'wppb_general_settings' );
466 }
467 add_action( 'admin_notices', 'wppb_general_settings_admin_notices' );
468
469
470 /*
471 * Function that return user roles
472 *
473 * @since v.2.2.0
474 *
475 * @return array
476 */
477 function wppb_adminApproval_onUserRole() {
478 global $wp_roles;
479
480 $wp_roles = new WP_Roles();
481
482 $roles = $wp_roles->get_names();
483
484 unset( $roles['administrator'] );
485
486 return $roles;
487 }
488
489
490
491 /*
492 * Generate the Form Designs Preview Showcase
493 *
494 */
495 function wppb_display_form_designs_preview() {
496 $form_designs_data = array(
497 array(
498 'id' => 'form-style-default',
499 'name' => 'Default',
500 'images' => array(
501 'main' => WPPB_PLUGIN_URL.'assets/images/pb-default-forms.jpg',
502 ),
503 ),
504 array(
505 'id' => 'form-style-1',
506 'name' => 'Style 1',
507 'images' => array(
508 'main' => WPPB_PLUGIN_URL.'assets/images/style1-slide1.jpg',
509 'slide1' => WPPB_PLUGIN_URL.'assets/images/style1-slide2.jpg',
510 'slide2' => WPPB_PLUGIN_URL.'assets/images/style1-slide3.jpg',
511 ),
512 ),
513 array(
514 'id' => 'form-style-2',
515 'name' => 'Style 2',
516 'images' => array(
517 'main' => WPPB_PLUGIN_URL.'assets/images/style2-slide1.jpg',
518 'slide1' => WPPB_PLUGIN_URL.'assets/images/style2-slide2.jpg',
519 'slide2' => WPPB_PLUGIN_URL.'assets/images/style2-slide3.jpg',
520 ),
521 ),
522 array(
523 'id' => 'form-style-3',
524 'name' => 'Style 3',
525 'images' => array(
526 'main' => WPPB_PLUGIN_URL.'assets/images/style3-slide1.jpg',
527 'slide1' => WPPB_PLUGIN_URL.'assets/images/style3-slide2.jpg',
528 'slide2' => WPPB_PLUGIN_URL.'assets/images/style3-slide3.jpg',
529 ),
530 )
531 );
532
533 $output = '<div id="wppb-forms-design-browser">';
534
535 foreach ( $form_designs_data as $form_design ) {
536
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 = '';
540
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>
551
552 </div>
553 </div>
554 ';
555
556 $img_count = 0;
557 $image_list = '';
558 foreach ( $form_design['images'] as $image ) {
559 $img_count++;
560 $active_img = ( $img_count == 1 ) ? ' active' : '';
561 $image_list .= '<img class="wppb-forms-design-preview-image'. $active_img .'" src="'. $image .'">';
562 }
563
564 if ( $img_count > 1 ) {
565 $previous_button = '<div class="wppb-slideshow-button wppb-forms-design-sildeshow-previous disabled" data-theme-id="'. $form_design['id'] .'" data-slideshow-direction="previous"> < </div>';
566 $next_button = '<div class="wppb-slideshow-button wppb-forms-design-sildeshow-next" data-theme-id="'. $form_design['id'] .'" data-slideshow-direction="next"> > </div>';
567 $justify_content = 'space-between';
568 }
569 else {
570 $previous_button = $next_button = '';
571 $justify_content = 'center';
572 }
573
574 $output .= '<div id="modal-'. $form_design['id'] .'" class="wppb-forms-design-modal" title="'. $form_design['name'] .'">
575 <div class="wppb-forms-design-modal-slideshow" style="justify-content: '. $justify_content .'">
576 '. $previous_button .'
577 <div class="wppb-forms-design-modal-images">
578 '. $image_list .'
579 </div>
580 '. $next_button .'
581 </div>
582 </div>';
583
584 }
585
586 $output .= '</div>';
587
588 return $output;
589 }