| @@ -25,9 +25,9 @@ | ||
| 25 | 25 | $settings_pages['sub-tabs']['profile-builder-toolbox-settings']['admin'] = __( 'Admin', 'profile-builder' ); |
| 26 | 26 | |
| 27 | 27 | //add sub-pages here for email customizer |
| 28 | 28 | if( file_exists( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' ) ){ |
| 29 | - | |
| 29 | + | |
| 30 | 30 | $settings_pages['pages']['user-email-customizer'] = __( 'Email Customizer', 'profile-builder' ); |
| 31 | 31 | $settings_pages['sub-pages']['user-email-customizer']['user-email-customizer'] = __( 'User Emails', 'profile-builder' ); |
| 32 | 32 | $settings_pages['sub-pages']['user-email-customizer']['admin-email-customizer'] = __( 'Administrator Emails', 'profile-builder' ); |
| 33 | 33 | |
| @@ -148,323 +148,706 @@ | ||
| 148 | 148 | </div> |
| 149 | 149 | |
| 150 | 150 | <?php settings_errors(); ?> |
| 151 | 151 | |
| 152 | - <?php wppb_generate_settings_tabs() ?> | |
| 152 | + <?php wppb_generate_settings_tabs(); ?> | |
| 153 | 153 | |
| 154 | 154 | <?php wppb_load_necessary_scripts(); ?> |
| 155 | 155 | |
| 156 | - <?php wppb_add_register_version_form() ?> | |
| 156 | + <div class="cozmoslabs-settings-container"> | |
| 157 | 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' ); ?> | |
| 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; ?> | |
| 161 | 163 | |
| 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' ); ?> | |
| 162 | 167 | |
| 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> | |
| 168 | + <div class="cozmoslabs-settings"> | |
| 167 | 169 | |
| 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> | |
| 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> | |
| 179 | 175 | |
| 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> | |
| 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; ?> | |
| 182 | 181 | |
| 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> | |
| 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> | |
| 185 | 184 | |
| 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> | |
| 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> | |
| 190 | 187 | |
| 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> | |
| 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> | |
| 195 | 192 | |
| 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> | |
| 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> | |
| 198 | 197 | |
| 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> | |
| 199 | 200 | |
| 200 | - <div class="cozmoslabs-toggle-container"> | |
| 201 | 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> | |
| 202 | + <div class="cozmoslabs-toggle-container"> | |
| 204 | 203 | |
| 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> | |
| 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> | |
| 211 | 206 | |
| 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> | |
| 212 | 211 | |
| 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> | |
| 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> | |
| 214 | 217 | |
| 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> | |
| 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' ) ) ) ); | |
| 217 | 223 | |
| 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' ) ) ) ); | |
| 224 | + foreach ( $pages as $key => $value ){ | |
| 225 | + echo '<option value="'.esc_attr( $value->ID ).'"'; | |
| 226 | + if ( $wppb_generalSettings['activationLandingPage'] == $value->ID ) | |
| 227 | + echo ' selected'; | |
| 223 | 228 | |
| 224 | - foreach ( $pages as $key => $value ){ | |
| 225 | - echo '<option value="'.esc_attr( $value->ID ).'"'; | |
| 226 | - if ( $wppb_generalSettings['activationLandingPage'] == $value->ID ) | |
| 227 | - echo ' selected'; | |
| 229 | + echo '>' . esc_html( $value->post_title ) . '</option>'; | |
| 230 | + } | |
| 231 | + ?> | |
| 232 | + </optgroup> | |
| 233 | + </select> | |
| 228 | 234 | |
| 229 | - echo '>' . esc_html( $value->post_title ) . '</option>'; | |
| 230 | - } | |
| 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 | + <?php | |
| 239 | + if ( PROFILE_BUILDER == 'Profile Builder Free' ) { | |
| 231 | 240 | ?> |
| 232 | - </optgroup> | |
| 233 | - </select> | |
| 234 | 241 | |
| 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> | |
| 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> | |
| 237 | 244 | |
| 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> | |
| 238 | 250 | |
| 239 | - <?php | |
| 240 | - if ( PROFILE_BUILDER == 'Profile Builder Free' ) { | |
| 241 | - ?> | |
| 251 | + <?php } ?> | |
| 242 | 252 | |
| 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 | 253 | |
| 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> | |
| 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 | + <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> | |
| 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> | |
| 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> | |
| 275 | + | |
| 276 | + <select name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-select wppb-select2" multiple> | |
| 277 | + <?php | |
| 278 | + $wppb_userRoles = wppb_adminApproval_onUserRole(); | |
| 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 | + | |
| 249 | 305 | </div> |
| 250 | 306 | |
| 251 | - <?php } ?> | |
| 307 | + <div class="cozmoslabs-form-subsection-wrapper"> | |
| 308 | + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Security', 'profile-builder' ); ?></h4> | |
| 252 | 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'] ); ?>"/> | |
| 253 | 313 | |
| 254 | - <?php | |
| 255 | - if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){ | |
| 256 | - ?> | |
| 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> | |
| 257 | 316 | |
| 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 | 317 | |
| 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> | |
| 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> | |
| 264 | 330 | </div> |
| 265 | 331 | |
| 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> | |
| 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> | |
| 268 | 359 | </div> |
| 269 | 360 | </div> |
| 270 | 361 | |
| 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> | |
| 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> | |
| 273 | 365 | |
| 274 | - <select name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-select wppb-select2" multiple> | |
| 275 | - <?php | |
| 276 | - $wppb_userRoles = wppb_adminApproval_onUserRole(); | |
| 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' ); | |
| 277 | 369 | |
| 278 | - if( ! empty( $wppb_userRoles ) ) { | |
| 279 | - foreach( $wppb_userRoles as $role => $role_name ) { | |
| 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 | + ?> | |
| 280 | 375 | |
| 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>'; | |
| 376 | + <label class="cozmoslabs-form-field-label" for="wppb-auth-enable"><?php esc_html_e('Two-Factor Authentication', 'profile-builder'); ?></label> | |
| 282 | 377 | |
| 283 | - } | |
| 284 | - } | |
| 285 | - ?> | |
| 286 | - </select> | |
| 287 | - </div> | |
| 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> | |
| 288 | 382 | |
| 289 | - <?php } ?> | |
| 383 | + <?php | |
| 384 | + $current_user = wp_get_current_user(); | |
| 385 | + ?> | |
| 290 | 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(); | |
| 291 | 399 | |
| 292 | - <?php | |
| 293 | - if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) { | |
| 294 | - ?> | |
| 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(); | |
| 295 | 407 | |
| 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> | |
| 408 | + $('#wppb-2fa-require-totp-profile-edit').hide(); | |
| 409 | + } | |
| 410 | + }); | |
| 298 | 411 | |
| 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> | |
| 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(); | |
| 303 | 418 | |
| 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> | |
| 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(); | |
| 308 | 423 | |
| 309 | - <?php } ?> | |
| 424 | + } | |
| 425 | + }); | |
| 310 | 426 | |
| 427 | + // Handle changes to "Enable Authenticator For" roles | |
| 428 | + $('#wppb-auth-enable-roles').on('change', function() { | |
| 429 | + updateForce2FARolesDropdown(); | |
| 430 | + }); | |
| 311 | 431 | |
| 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> | |
| 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 | + } | |
| 314 | 478 | |
| 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> | |
| 479 | + // Initial state | |
| 480 | + $('#wppb-auth-enable').trigger('change'); | |
| 481 | + updateForce2FARolesDropdown(); | |
| 320 | 482 | |
| 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> | |
| 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'; ?>; | |
| 323 | 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(); | |
| 324 | 492 | |
| 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'] ); ?>"/> | |
| 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 | + ); | |
| 328 | 506 | |
| 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> | |
| 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 | + } | |
| 331 | 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(); | |
| 332 | 518 | |
| 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> | |
| 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 | + } | |
| 335 | 540 | |
| 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> | |
| 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 | + } | |
| 343 | 546 | |
| 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> | |
| 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 | + } | |
| 346 | 553 | |
| 554 | + var selectedRolesText = []; | |
| 555 | + | |
| 556 | + $('#wppb-force-2fa-roles option:selected').each(function() { | |
| 557 | + selectedRolesText.push($(this).text()); | |
| 558 | + }); | |
| 347 | 559 | |
| 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> | |
| 560 | + if (selectedRoles.length > 0) { | |
| 561 | + e.preventDefault(); | |
| 562 | + var form = $(this); | |
| 350 | 563 | |
| 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 ); | |
| 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>'; | |
| 362 | 566 | |
| 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'; | |
| 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 | + } | |
| 367 | 575 | |
| 368 | - echo '>' . esc_html( $value->post_title ) . '</option>'; | |
| 369 | - } | |
| 370 | - ?> | |
| 371 | - </select> | |
| 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 | + } | |
| 372 | 580 | |
| 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> | |
| 581 | + $('#wppb-force-2fa-message').html(message); | |
| 582 | + $('#wppb-force-2fa-modal').show(); | |
| 375 | 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 | + }); | |
| 376 | 590 | |
| 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> | |
| 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> | |
| 379 | 600 | |
| 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'] : ''; | |
| 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> | |
| 385 | 605 | |
| 386 | - foreach ( $wp_roles->roles as $role ) { | |
| 387 | - $key = $role['name']; | |
| 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 | + ?> | |
| 388 | 613 | |
| 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 | 614 | |
| 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> | |
| 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> | |
| 396 | 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> | |
| 397 | 621 | |
| 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' ); | |
| 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> | |
| 401 | 626 | |
| 402 | - $enabled = 'no'; | |
| 403 | - if ( !empty( $wppb_two_factor_authentication_settings['enabled'] ) ) | |
| 404 | - $enabled = $wppb_two_factor_authentication_settings['enabled']; | |
| 405 | - ?> | |
| 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 | + ?> | |
| 406 | 634 | |
| 407 | - <label class="cozmoslabs-form-field-label" for="wppb-auth-enable"><?php esc_html_e('Two-Factor Authentication', 'profile-builder'); ?></label> | |
| 635 | + <label class="cozmoslabs-form-field-label" for="wppb-auth-enable-roles"><?php esc_html_e( 'Enable Authenticator For', 'profile-builder' ); ?></label> | |
| 408 | 636 | |
| 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> | |
| 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 | + | |
| 412 | 764 | </div> |
| 765 | + <?php endif; ?> | |
| 413 | 766 | |
| 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> | |
| 767 | + <div class="cozmoslabs-form-subsection-wrapper"> | |
| 768 | + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Other features', 'profile-builder' ); ?></h4> | |
| 418 | 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> | |
| 419 | 772 | |
| 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 | - ?> | |
| 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'] : ''; | |
| 427 | 778 | |
| 428 | - <label class="cozmoslabs-form-field-label" for="wppb-auth-enable-roles"><?php esc_html_e( 'Enable Authenticator For', 'profile-builder' ); ?></label> | |
| 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>'; | |
| 429 | 781 | |
| 430 | - <select name="wppb_two_factor_authentication_settings[roles][]" id="wppb-auth-enable-roles" class="wppb-select wppb-select2" multiple> | |
| 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 | + | |
| 431 | 794 | <?php |
| 432 | - echo '<option value="*"' . (in_array('*', $network_roles, true) ? ' selected' : '') . '>'. esc_html__('ALL ROLES', 'profile-builder') .'</option>'; | |
| 795 | + if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) { | |
| 796 | + ?> | |
| 433 | 797 | |
| 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> | |
| 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> | |
| 439 | 800 | |
| 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> | |
| 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> | |
| 442 | 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> | |
| 443 | 809 | |
| 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> | |
| 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> | |
| 446 | 812 | |
| 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> | |
| 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 | + | |
| 450 | 827 | </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> | |
| 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> | |
| 453 | 841 | </div> |
| 454 | 842 | </div> |
| 455 | 843 | |
| 844 | + </form> | |
| 456 | 845 | |
| 457 | - <?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?> | |
| 846 | + </div> | |
| 458 | 847 | |
| 848 | + </div> | |
| 459 | 849 | |
| 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 | 850 | <?php |
| 468 | 851 | } |
| 469 | 852 | |
| 470 | 853 | |
| @@ -544,9 +927,9 @@ | ||
| 544 | 927 | ), |
| 545 | 928 | ), |
| 546 | 929 | array( |
| 547 | 930 | 'id' => 'form-style-1', |
| 548 | - 'name' => 'Style 1', | |
| 931 | + 'name' => 'Sublime', | |
| 549 | 932 | 'images' => array( |
| 550 | 933 | 'main' => WPPB_PLUGIN_URL.'assets/images/style1-slide1.jpg', |
| 551 | 934 | 'slide1' => WPPB_PLUGIN_URL.'assets/images/style1-slide2.jpg', |
| 552 | 935 | 'slide2' => WPPB_PLUGIN_URL.'assets/images/style1-slide3.jpg', |
| @@ -553,9 +936,9 @@ | ||
| 553 | 936 | ), |
| 554 | 937 | ), |
| 555 | 938 | array( |
| 556 | 939 | 'id' => 'form-style-2', |
| 557 | - 'name' => 'Style 2', | |
| 940 | + 'name' => 'Greenery', | |
| 558 | 941 | 'images' => array( |
| 559 | 942 | 'main' => WPPB_PLUGIN_URL.'assets/images/style2-slide1.jpg', |
| 560 | 943 | 'slide1' => WPPB_PLUGIN_URL.'assets/images/style2-slide2.jpg', |
| 561 | 944 | 'slide2' => WPPB_PLUGIN_URL.'assets/images/style2-slide3.jpg', |
| @@ -562,9 +945,9 @@ | ||
| 562 | 945 | ), |
| 563 | 946 | ), |
| 564 | 947 | array( |
| 565 | 948 | 'id' => 'form-style-3', |
| 566 | - 'name' => 'Style 3', | |
| 949 | + 'name' => 'Slim', | |
| 567 | 950 | 'images' => array( |
| 568 | 951 | 'main' => WPPB_PLUGIN_URL.'assets/images/style3-slide1.jpg', |
| 569 | 952 | 'slide1' => WPPB_PLUGIN_URL.'assets/images/style3-slide2.jpg', |
| 570 | 953 | 'slide2' => WPPB_PLUGIN_URL.'assets/images/style3-slide3.jpg', |
| @@ -575,14 +958,21 @@ | ||
| 575 | 958 | $output = '<div id="wppb-forms-design-browser">'; |
| 576 | 959 | |
| 577 | 960 | foreach ( $form_designs_data as $form_design ) { |
| 578 | 961 | |
| 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 = ''; | |
| 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 | + } | |
| 582 | 970 | |
| 583 | - $output .= '<div class="wppb-forms-design" id="'. $form_design['id'] .'"> | |
| 584 | - <label>' . $form_design['name'] . '</label> | |
| 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> | |
| 585 | 975 | <div class="wppb-forms-design-screenshot"> |
| 586 | 976 | <img src="' . $form_design['images']['main'] . '" alt="Form Design"> |
| 587 | 977 | '. $preview_button .' |
| 588 | 978 | </div> |
| @@ -619,9 +1009,9 @@ | ||
| 619 | 1009 | } |
| 620 | 1010 | |
| 621 | 1011 | $output .= '</div>'; |
| 622 | 1012 | |
| 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>'; | |
| 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>'; | |
| 624 | 1014 | |
| 625 | 1015 | return $output; |
| 626 | 1016 | } |
| 627 | 1017 | |
| @@ -630,56 +1020,74 @@ | ||
| 630 | 1020 | * Generate the Register Version Form |
| 631 | 1021 | * |
| 632 | 1022 | */ |
| 633 | 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 ); | |
| 634 | 1027 | |
| 635 | - if ( !defined( 'WPPB_PAID_PLUGIN_DIR' ) && !defined( 'PROFILE_BUILDER_PAID_VERSION' ) ) | |
| 636 | - return ''; | |
| 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 | + ?> | |
| 637 | 1034 | |
| 638 | - $status = wppb_get_serial_number_status(); | |
| 639 | - $license = wppb_get_serial_number(); | |
| 640 | - ?> | |
| 1035 | + <h4 class="cozmoslabs-subsection-title"><?php esc_html_e( 'Register Website', 'profile-builder' ) ?></h4> | |
| 641 | 1036 | |
| 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> | |
| 1037 | + <form method="post" action="<?php echo !is_multisite() ? 'options.php' : 'edit.php'; ?>"> | |
| 1038 | + <?php settings_fields( 'wppb_license_key' ); ?> | |
| 644 | 1039 | |
| 645 | - <form method="post" action="<?php echo !is_multisite() ? 'options.php' : 'edit.php'; ?>"> | |
| 646 | - <?php settings_fields( 'wppb_license_key' ); ?> | |
| 1040 | + <div class="cozmoslabs-form-field-wrapper cozmoslabs-form-field-serial-number"> | |
| 647 | 1041 | |
| 648 | - <div class="cozmoslabs-form-field-wrapper"> | |
| 1042 | + <label class="cozmoslabs-form-field-label" for="wppb_license_key"><?php esc_html_e( 'License key', 'profile-builder' ); ?></label> | |
| 649 | 1043 | |
| 650 | - <label class="cozmoslabs-form-field-label" for="wppb_license_key"><?php esc_html_e( 'License key', 'profile-builder' ); ?></label> | |
| 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' ); ?> | |
| 651 | 1047 | |
| 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' ); ?> | |
| 1048 | + <?php if( $status !== false && $status == 'valid' ) { | |
| 1049 | + $button_name = 'wppb_edd_license_deactivate'; | |
| 1050 | + $button_value = __('Deactivate License', 'profile-builder' ); | |
| 655 | 1051 | |
| 656 | - <?php if( $status !== false && $status == 'valid' ) { | |
| 657 | - $button_name = 'wppb_edd_license_deactivate'; | |
| 658 | - $button_value = __('Deactivate License', 'profile-builder' ); | |
| 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>'; | |
| 659 | 1056 | |
| 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>'; | |
| 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> | |
| 664 | 1064 | |
| 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 ); ?>"/> | |
| 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> | |
| 671 | 1069 | </div> |
| 672 | - | |
| 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' ) : ?> | |
| 673 | 1081 | <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> | |
| 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> | |
| 676 | 1084 | </div> |
| 1085 | + <?php endif; ?> | |
| 677 | 1086 | |
| 678 | - </div> | |
| 679 | - </form> | |
| 1087 | + </div> | |
| 1088 | + </form> | |
| 680 | 1089 | |
| 681 | - </div> | |
| 682 | 1090 | <?php |
| 683 | 1091 | } |
| 684 | 1092 | |
| 685 | 1093 | |