| 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 |
if ( file_exists( WPPB_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 |
$settings_pages['sub-tabs']['profile-builder-toolbox-settings']['shortcodes'] = __( 'Shortcodes', 'profile-builder' ); |
| 24 |
$settings_pages['sub-tabs']['profile-builder-toolbox-settings']['admin'] = __( 'Admin', 'profile-builder' ); |
| 25 |
|
| 26 |
//add tab for 2FA |
| 27 |
if (file_exists(WPPB_PLUGIN_DIR . '/features/two-factor-authentication/class-two-factor-authentication.php')) { |
| 28 |
$settings_pages['pages']['profile-builder-two-factor-authentication'] = __( 'Two-Factor Authentication', 'profile-builder' ); |
| 29 |
} |
| 30 |
|
| 31 |
//add sub-pages here for email customizer |
| 32 |
if (file_exists(WPPB_PLUGIN_DIR . '/add-ons/add-ons.php')) { |
| 33 |
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') ){ |
| 34 |
$settings_pages['pages']['user-email-customizer'] = __( 'Email Customizer', 'profile-builder' ); |
| 35 |
$settings_pages['sub-pages']['user-email-customizer']['user-email-customizer'] = __( 'User Emails', 'profile-builder' ); |
| 36 |
$settings_pages['sub-pages']['user-email-customizer']['admin-email-customizer'] = __( 'Administrator Emails', 'profile-builder' ); |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
return $settings_pages; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Function that generates the html for the tabs and subtabs on the settings page |
| 45 |
*/ |
| 46 |
function wppb_generate_settings_tabs(){ |
| 47 |
?> |
| 48 |
<nav class="nav-tab-wrapper"> |
| 49 |
<?php |
| 50 |
$pages = wppb_get_settings_pages(); |
| 51 |
|
| 52 |
$active_tab = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
| 53 |
//if we are on a subpage we need to change the active tab to the parent |
| 54 |
if( !empty( $pages['sub-pages'] ) ) { |
| 55 |
foreach ($pages['sub-pages'] as $parent_slug => $subpages) { |
| 56 |
if (array_key_exists($active_tab, $subpages)) { |
| 57 |
$active_tab = $parent_slug; |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
foreach( $pages['pages'] as $page_slug => $tab_name ){ |
| 63 |
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>'; |
| 64 |
} |
| 65 |
?> |
| 66 |
</nav> |
| 67 |
<?php |
| 68 |
|
| 69 |
// this is not always the same as the active tab |
| 70 |
$active_subpage = sanitize_text_field($_GET['page']); |
| 71 |
|
| 72 |
if( !empty( $pages['sub-pages'] ) ) { |
| 73 |
foreach ($pages['sub-pages'] as $parent_slug => $subpages) { |
| 74 |
if (array_key_exists( sanitize_text_field( $active_subpage ), $subpages)) { |
| 75 |
echo '<ul class="wppb-subtabs subsubsub">'; |
| 76 |
foreach ($subpages as $subpage_slug => $subpage_name) { |
| 77 |
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>'; |
| 78 |
} |
| 79 |
echo '</ul>'; |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
if( !empty( $pages['sub-tabs'] ) ) { |
| 85 |
foreach ($pages['sub-tabs'] as $parent_slug => $tabs) { |
| 86 |
if ( $active_subpage == $parent_slug) { |
| 87 |
echo '<ul class="wppb-subtabs subsubsub">'; |
| 88 |
//determine the active tab, if no tab present then default to the first one |
| 89 |
if( isset($_GET['tab']) ) |
| 90 |
$active_tab = sanitize_text_field( $_GET['tab'] ); |
| 91 |
else { |
| 92 |
$keys = array_keys($tabs); |
| 93 |
$active_tab = array_shift( $keys ); |
| 94 |
} |
| 95 |
foreach ($tabs as $tab_slug => $tab_name) { |
| 96 |
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>'; |
| 97 |
} |
| 98 |
echo '</ul>'; |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Function that creates the "General Settings" submenu page |
| 106 |
* |
| 107 |
* @since v.2.0 |
| 108 |
* |
| 109 |
* @return void |
| 110 |
*/ |
| 111 |
function wppb_register_general_settings_submenu_page() { |
| 112 |
add_submenu_page( 'profile-builder', __( 'Settings', 'profile-builder' ), __( 'Settings', 'profile-builder' ), 'manage_options', 'profile-builder-general-settings', 'wppb_general_settings_content' ); |
| 113 |
} |
| 114 |
add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 ); |
| 115 |
|
| 116 |
|
| 117 |
function wppb_generate_default_settings_defaults(){ |
| 118 |
add_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'automaticallyLogIn' => 'No', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'usernameemail', 'rolesEditor' => 'no', 'conditional_fields_ajax' => 'no' ) ); |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
/** |
| 123 |
* Function that adds content to the "General Settings" submenu page |
| 124 |
* |
| 125 |
* @since v.2.0 |
| 126 |
* |
| 127 |
* @return string |
| 128 |
*/ |
| 129 |
function wppb_general_settings_content() { |
| 130 |
wppb_generate_default_settings_defaults(); |
| 131 |
?> |
| 132 |
<div class="wrap wppb-wrap"> |
| 133 |
<h2><?php esc_html_e( 'Profile Builder Settings', 'profile-builder' ); ?></h2> |
| 134 |
|
| 135 |
<?php settings_errors(); ?> |
| 136 |
|
| 137 |
<?php wppb_generate_settings_tabs() ?> |
| 138 |
|
| 139 |
<form method="post" action="options.php#general-settings"> |
| 140 |
<?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?> |
| 141 |
<?php settings_fields( 'wppb_general_settings' ); ?> |
| 142 |
|
| 143 |
<table class="form-table"> |
| 144 |
<tr> |
| 145 |
<th scope="row"> |
| 146 |
<?php esc_html_e( "Load Profile Builder's own CSS file in the front-end:", "profile-builder" ); ?> |
| 147 |
</th> |
| 148 |
<td> |
| 149 |
<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> |
| 150 |
<ul> |
| 151 |
<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> |
| 152 |
</ul> |
| 153 |
</td> |
| 154 |
</tr> |
| 155 |
|
| 156 |
<tr> |
| 157 |
<th scope="row"> |
| 158 |
<?php esc_html_e( 'Automatically Log In:', 'profile-builder' );?> |
| 159 |
</th> |
| 160 |
<td> |
| 161 |
<select name="wppb_general_settings[automaticallyLogIn]" class="wppb-select" id="wppb_settings_automatically_log_in" onchange="wppb_display_page_select(this.value)"> |
| 162 |
<option value="Yes" <?php if ( !empty( $wppb_generalSettings['automaticallyLogIn'] ) && $wppb_generalSettings['automaticallyLogIn'] === 'Yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option> |
| 163 |
<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> |
| 164 |
</select> |
| 165 |
<ul> |
| 166 |
<li class="description"><?php esc_html_e( 'Select "Yes" to automatically log in new users after successful registration.', 'profile-builder' ); ?></li> |
| 167 |
</ul> |
| 168 |
</td> |
| 169 |
</tr> |
| 170 |
|
| 171 |
<tr> |
| 172 |
<th scope="row"> |
| 173 |
<?php esc_html_e( '"Email Confirmation" Activated:', 'profile-builder' );?> |
| 174 |
</th> |
| 175 |
<td> |
| 176 |
<select name="wppb_general_settings[emailConfirmation]" class="wppb-select" id="wppb_settings_email_confirmation" onchange="wppb_display_page_select(this.value)"> |
| 177 |
<option value="yes" <?php if ( !empty( $wppb_generalSettings['emailConfirmation'] ) && $wppb_generalSettings['emailConfirmation'] === 'yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option> |
| 178 |
<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> |
| 179 |
</select> |
| 180 |
<ul> |
| 181 |
<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> |
| 182 |
<?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) { ?> |
| 183 |
<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> |
| 184 |
<?php } ?> |
| 185 |
</ul> |
| 186 |
</td> |
| 187 |
</tr> |
| 188 |
|
| 189 |
<tr id="wppb-settings-activation-page"> |
| 190 |
<th scope="row"> |
| 191 |
<?php esc_html_e( '"Email Confirmation" Landing Page:', 'profile-builder' ); ?> |
| 192 |
</th> |
| 193 |
<td> |
| 194 |
<select name="wppb_general_settings[activationLandingPage]" class="wppb-select"> |
| 195 |
<option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option> |
| 196 |
<optgroup label="<?php esc_html_e( 'Existing Pages', 'profile-builder' ); ?>"> |
| 197 |
<?php |
| 198 |
$pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) ); |
| 199 |
|
| 200 |
foreach ( $pages as $key => $value ){ |
| 201 |
echo '<option value="'.esc_attr( $value->ID ).'"'; |
| 202 |
if ( $wppb_generalSettings['activationLandingPage'] == $value->ID ) |
| 203 |
echo ' selected'; |
| 204 |
|
| 205 |
echo '>' . esc_html( $value->post_title ) . '</option>'; |
| 206 |
} |
| 207 |
?> |
| 208 |
</optgroup> |
| 209 |
</select> |
| 210 |
<p class="description"> |
| 211 |
<?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' ); ?> |
| 212 |
</p> |
| 213 |
</td> |
| 214 |
</tr> |
| 215 |
|
| 216 |
|
| 217 |
<?php |
| 218 |
if ( file_exists( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){ |
| 219 |
?> |
| 220 |
<tr> |
| 221 |
<th scope="row"> |
| 222 |
<?php esc_html_e( '"Admin Approval" Activated:', 'profile-builder' ); ?> |
| 223 |
</th> |
| 224 |
<td> |
| 225 |
<select id="adminApprovalSelect" name="wppb_general_settings[adminApproval]" class="wppb-select" onchange="wppb_display_page_select_aa(this.value)"> |
| 226 |
<option value="yes" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option> |
| 227 |
<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> |
| 228 |
</select> |
| 229 |
<ul> |
| 230 |
<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> |
| 231 |
<ul> |
| 232 |
</td> |
| 233 |
</tr> |
| 234 |
|
| 235 |
<tr class="dynamic2"> |
| 236 |
<th scope="row"> |
| 237 |
<?php esc_html_e( '"Admin Approval" on User Role:', 'profile-builder' ); ?> |
| 238 |
</th> |
| 239 |
<td> |
| 240 |
<div id="wrap"> |
| 241 |
<?php |
| 242 |
$wppb_userRoles = wppb_adminApproval_onUserRole(); |
| 243 |
|
| 244 |
if( ! empty( $wppb_userRoles ) ) { |
| 245 |
foreach( $wppb_userRoles as $role => $role_name ) { |
| 246 |
echo '<label><input type="checkbox" id="adminApprovalOnUserRoleCheckbox" name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-checkboxes" value="' . esc_attr( $role ) . '"'; |
| 247 |
if( ! empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) && in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked'; |
| 248 |
if( empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked'; |
| 249 |
echo '>'; |
| 250 |
echo esc_html( $role_name ) . '</label><br>'; |
| 251 |
} |
| 252 |
} |
| 253 |
?> |
| 254 |
</div> |
| 255 |
<ul> |
| 256 |
<li class="description"><?php printf( esc_html__( 'Select on what user roles to activate Admin Approval.', 'profile-builder' ) ) ?></li> |
| 257 |
<ul> |
| 258 |
</td> |
| 259 |
</tr> |
| 260 |
|
| 261 |
<?php } ?> |
| 262 |
|
| 263 |
<?php |
| 264 |
if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) { |
| 265 |
?> |
| 266 |
<tr> |
| 267 |
<th scope="row"> |
| 268 |
<?php esc_html_e( '"Roles Editor" Activated:', 'profile-builder' ); ?> |
| 269 |
</th> |
| 270 |
<td> |
| 271 |
<select id="rolesEditorSelect" name="wppb_general_settings[rolesEditor]" class="wppb-select" onchange="wppb_display_page_select_re(this.value)"> |
| 272 |
<option value="no" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'no' ) echo 'selected'; ?>><?php esc_html_e( 'No', 'profile-builder' ); ?></option> |
| 273 |
<option value="yes" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'yes' ) echo 'selected'; ?>><?php esc_html_e( 'Yes', 'profile-builder' ); ?></option> |
| 274 |
</select> |
| 275 |
<ul> |
| 276 |
<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> |
| 277 |
<ul> |
| 278 |
</td> |
| 279 |
</tr> |
| 280 |
<?php } ?> |
| 281 |
|
| 282 |
<?php |
| 283 |
if ( PROFILE_BUILDER == 'Profile Builder Free' ) { |
| 284 |
?> |
| 285 |
<tr> |
| 286 |
<th scope="row"> |
| 287 |
<?php esc_html_e( '"Admin Approval" Feature:', 'profile-builder' ); ?> |
| 288 |
</th> |
| 289 |
<td> |
| 290 |
<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$sHobbyist 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> |
| 291 |
</td> |
| 292 |
</tr> |
| 293 |
<?php } ?> |
| 294 |
|
| 295 |
<tr> |
| 296 |
<th scope="row"> |
| 297 |
<?php esc_html_e( 'Allow Users to Log in With:', 'profile-builder' ); ?> |
| 298 |
</th> |
| 299 |
<td> |
| 300 |
<select name="wppb_general_settings[loginWith]" class="wppb-select"> |
| 301 |
<option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php esc_html_e( 'Username and Email', 'profile-builder' ); ?></option> |
| 302 |
<option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php esc_html_e( 'Username', 'profile-builder' ); ?></option> |
| 303 |
<option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php esc_html_e( 'Email', 'profile-builder' ); ?></option> |
| 304 |
</select> |
| 305 |
<ul> |
| 306 |
<li class="description"><?php esc_html_e( '"Username and Email" - users can Log In with either their Username or their Email.', 'profile-builder' ); ?></li> |
| 307 |
<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> |
| 308 |
<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> |
| 309 |
</ul> |
| 310 |
</td> |
| 311 |
</tr> |
| 312 |
|
| 313 |
<tr> |
| 314 |
<th scope="row"> |
| 315 |
<?php esc_html_e( 'Minimum Password Length:', 'profile-builder' ); ?> |
| 316 |
</th> |
| 317 |
<td> |
| 318 |
<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'] ); ?>"/> |
| 319 |
<ul> |
| 320 |
<li class="description"><?php esc_html_e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profile-builder' ); ?> </li> |
| 321 |
</ul> |
| 322 |
</td> |
| 323 |
</tr> |
| 324 |
|
| 325 |
<tr> |
| 326 |
<th scope="row"> |
| 327 |
<?php esc_html_e( 'Minimum Password Strength:', 'profile-builder' ); ?> |
| 328 |
</th> |
| 329 |
<td> |
| 330 |
<select name="wppb_general_settings[minimum_password_strength]" class="wppb-select"> |
| 331 |
<option value=""><?php esc_html_e( 'Disabled', 'profile-builder' ); ?></option> |
| 332 |
<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> |
| 333 |
<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> |
| 334 |
<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> |
| 335 |
<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> |
| 336 |
</select> |
| 337 |
</td> |
| 338 |
</tr> |
| 339 |
|
| 340 |
<?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?> |
| 341 |
</table> |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
<input type="hidden" name="action" value="update" /> |
| 346 |
<p class="submit"><input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'profile-builder' ); ?>" /></p> |
| 347 |
</form> |
| 348 |
</div> |
| 349 |
|
| 350 |
<?php |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
/* |
| 355 |
* Function that sanitizes the general settings |
| 356 |
* |
| 357 |
* @param array $wppb_generalSettings |
| 358 |
* |
| 359 |
* @since v.2.0.7 |
| 360 |
*/ |
| 361 |
function wppb_general_settings_sanitize( $wppb_generalSettings ) { |
| 362 |
$wppb_generalSettings = apply_filters( 'wppb_general_settings_sanitize_extra', $wppb_generalSettings ); |
| 363 |
|
| 364 |
if( !empty( $wppb_generalSettings ) ){ |
| 365 |
foreach( $wppb_generalSettings as $settings_name => $settings_value ){ |
| 366 |
if( $settings_name == "minimum_password_length" || $settings_name == "activationLandingPage" ) |
| 367 |
$wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_NUMBER_INT ); |
| 368 |
elseif( $settings_name == "extraFieldsLayout" || $settings_name == "emailConfirmation" || $settings_name == "adminApproval" || $settings_name == "loginWith" || $settings_name == "minimum_password_strength" ) |
| 369 |
$wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_STRING ); |
| 370 |
elseif( $settings_name == "adminApprovalOnUserRole" ){ |
| 371 |
if( is_array( $settings_value ) && !empty( $settings_value ) ){ |
| 372 |
foreach( $settings_value as $key => $value ){ |
| 373 |
$wppb_generalSettings[$settings_name][$key] = filter_var( $value, FILTER_SANITIZE_STRING ); |
| 374 |
} |
| 375 |
} |
| 376 |
} |
| 377 |
} |
| 378 |
} |
| 379 |
|
| 380 |
return $wppb_generalSettings; |
| 381 |
} |
| 382 |
|
| 383 |
|
| 384 |
/* |
| 385 |
* Function that pushes settings errors to the user |
| 386 |
* |
| 387 |
* @since v.2.0.7 |
| 388 |
*/ |
| 389 |
function wppb_general_settings_admin_notices() { |
| 390 |
settings_errors( 'wppb_general_settings' ); |
| 391 |
} |
| 392 |
add_action( 'admin_notices', 'wppb_general_settings_admin_notices' ); |
| 393 |
|
| 394 |
|
| 395 |
/* |
| 396 |
* Function that return user roles |
| 397 |
* |
| 398 |
* @since v.2.2.0 |
| 399 |
* |
| 400 |
* @return array |
| 401 |
*/ |
| 402 |
function wppb_adminApproval_onUserRole() { |
| 403 |
global $wp_roles; |
| 404 |
|
| 405 |
$wp_roles = new WP_Roles(); |
| 406 |
|
| 407 |
$roles = $wp_roles->get_names(); |
| 408 |
|
| 409 |
unset( $roles['administrator'] ); |
| 410 |
|
| 411 |
return $roles; |
| 412 |
} |
| 413 |
|