PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.7.1
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.7.1
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / admin / general-settings.php

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

310 lines 15.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Function that creates the "General Settings" submenu page
4 *
5 * @since v.2.0
6 *
7 * @return void
8 */
9 function wppb_register_general_settings_submenu_page() {
10 add_submenu_page( 'profile-builder', __( 'General Settings', 'profile-builder' ), __( 'General Settings', 'profile-builder' ), 'manage_options', 'profile-builder-general-settings', 'wppb_general_settings_content' );
11 }
12 add_action( 'admin_menu', 'wppb_register_general_settings_submenu_page', 3 );
13
14
15 function wppb_generate_default_settings_defaults(){
16 add_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'usernameemail', 'rolesEditor' => 'no', 'contentRestriction' => 'no' ) );
17 }
18
19
20 /**
21 * Function that adds content to the "General Settings" submenu page
22 *
23 * @since v.2.0
24 *
25 * @return string
26 */
27 function wppb_general_settings_content() {
28 wppb_generate_default_settings_defaults();
29 ?>
30 <div class="wrap wppb-wrap">
31 <form method="post" action="options.php#general-settings">
32 <?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?>
33 <?php settings_fields( 'wppb_general_settings' ); ?>
34
35 <h2><?php _e( 'General Settings', 'profile-builder' ); ?></h2>
36 <table class="form-table">
37 <tr>
38 <th scope="row">
39 <?php _e( "Load Profile Builder's own CSS file in the front-end:", "profile-builder" ); ?>
40 </th>
41 <td>
42 <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 _e( 'Yes', 'profile-builder' ); ?></label>
43 <ul>
44 <li class="description"><?php printf( __( '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>' ); ?></li>
45 </ul>
46 </td>
47 </tr>
48
49 <tr>
50 <th scope="row">
51 <?php _e( '"Email Confirmation" Activated:', 'profile-builder' );?>
52 </th>
53 <td>
54 <select name="wppb_general_settings[emailConfirmation]" class="wppb-select" id="wppb_settings_email_confirmation" onchange="wppb_display_page_select(this.value)">
55 <option value="yes" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
56 <option value="no" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
57 </select>
58 <ul>
59 <li class="description"><?php _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>
60 <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) { ?>
61 <li class="description dynamic1"><?php printf( __( 'You can find a list of unconfirmed email addresses %1$sUsers > All Users > Email Confirmation%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=unconfirmed_emails">', '</a>' )?></li>
62 <?php } ?>
63 </ul>
64 </td>
65 </tr>
66
67 <tr id="wppb-settings-activation-page">
68 <th scope="row">
69 <?php _e( '"Email Confirmation" Landing Page:', 'profile-builder' ); ?>
70 </th>
71 <td>
72 <select name="wppb_general_settings[activationLandingPage]" class="wppb-select">
73 <option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option>
74 <optgroup label="<?php _e( 'Existing Pages', 'profile-builder' ); ?>">
75 <?php
76 $pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) );
77
78 foreach ( $pages as $key => $value ){
79 echo '<option value="'.$value->ID.'"';
80 if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
81 echo ' selected';
82
83 echo '>' . $value->post_title . '</option>';
84 }
85 ?>
86 </optgroup>
87 </select>
88 <p class="description">
89 <?php _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' ); ?>
90 </p>
91 </td>
92 </tr>
93
94
95 <?php
96 if ( file_exists( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){
97 ?>
98 <tr>
99 <th scope="row">
100 <?php _e( '"Admin Approval" Activated:', 'profile-builder' ); ?>
101 </th>
102 <td>
103 <select id="adminApprovalSelect" name="wppb_general_settings[adminApproval]" class="wppb-select" onchange="wppb_display_page_select_aa(this.value)">
104 <option value="yes" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
105 <option value="no" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
106 </select>
107 <ul>
108 <li class="description dynamic2"><?php printf( __( 'You can find a list of users at %1$sUsers > All Users > Admin Approval%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/users.php?page=admin_approval&orderby=registered&order=desc">', '</a>' )?></li>
109 <ul>
110 </td>
111 </tr>
112
113 <tr class="dynamic2">
114 <th scope="row">
115 <?php _e( '"Admin Approval" on User Role:', 'profile-builder' ); ?>
116 </th>
117 <td>
118 <div id="wrap">
119 <?php
120 $wppb_userRoles = wppb_adminApproval_onUserRole();
121
122 if( ! empty( $wppb_userRoles ) ) {
123 foreach( $wppb_userRoles as $role => $role_name ) {
124 echo '<label><input type="checkbox" id="adminApprovalOnUserRoleCheckbox" name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-checkboxes" value="' . esc_attr( $role ) . '"';
125 if( ! empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) && in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
126 if( empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
127 echo '>';
128 echo $role_name . '</label><br>';
129 }
130 }
131 ?>
132 </div>
133 <ul>
134 <li class="description"><?php printf( __( 'Select on what user roles to activate Admin Approval.', 'profile-builder' ) ) ?></li>
135 <ul>
136 </td>
137 </tr>
138
139 <?php } ?>
140
141 <?php
142 if( file_exists( WPPB_PLUGIN_DIR.'/features/roles-editor/roles-editor.php' ) ) {
143 ?>
144 <tr>
145 <th scope="row">
146 <?php _e( '"Roles Editor" Activated:', 'profile-builder' ); ?>
147 </th>
148 <td>
149 <select id="rolesEditorSelect" name="wppb_general_settings[rolesEditor]" class="wppb-select" onchange="wppb_display_page_select_re(this.value)">
150 <option value="no" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
151 <option value="yes" <?php if( !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
152 </select>
153 <ul>
154 <li class="description dynamic3"><?php printf( __( 'You can add / edit user roles at %1$sUsers > Roles Editor%2$s.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/edit.php?post_type=wppb-roles-editor">', '</a>' )?></li>
155 <ul>
156 </td>
157 </tr>
158 <?php } ?>
159
160 <?php
161 if( file_exists( WPPB_PLUGIN_DIR.'/features/content-restriction/content-restriction.php' ) ) {
162 ?>
163 <tr>
164 <th scope="row">
165 <?php _e( '"Content Restriction" Activated:', 'profile-builder' ); ?>
166 </th>
167 <td>
168 <select id="contentRestrictionSelect" name="wppb_general_settings[contentRestriction]" class="wppb-select" onchange="wppb_display_page_select_cr(this.value)">
169 <option value="no" <?php if( !empty( $wppb_generalSettings['contentRestriction'] ) && $wppb_generalSettings['contentRestriction'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
170 <option value="yes" <?php if( !empty( $wppb_generalSettings['contentRestriction'] ) && $wppb_generalSettings['contentRestriction'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
171 </select>
172 <ul>
173 <li class="description dynamic4"><?php printf( __( 'Set your settings at %1$sProfile Builder > Content Restriction%2$s and use each page / post / custom post type individual meta-box to restrict content.', 'profile-builder' ), '<a href="'.get_bloginfo( 'url' ).'/wp-admin/admin.php?page=profile-builder-content_restriction">', '</a>' )?></li>
174 <ul>
175 </td>
176 </tr>
177 <?php } ?>
178
179 <?php
180 if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
181 ?>
182 <tr>
183 <th scope="row">
184 <?php _e( '"Admin Approval" Feature:', 'profile-builder' ); ?>
185 </th>
186 <td>
187 <p><em> <?php printf( __( '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>
188 </td>
189 </tr>
190 <?php } ?>
191
192 <tr>
193 <th scope="row">
194 <?php _e( 'Allow Users to Log in With:', 'profile-builder' ); ?>
195 </th>
196 <td>
197 <select name="wppb_general_settings[loginWith]" class="wppb-select">
198 <option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php _e( 'Username and Email', 'profile-builder' ); ?></option>
199 <option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php _e( 'Username', 'profile-builder' ); ?></option>
200 <option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php _e( 'Email', 'profile-builder' ); ?></option>
201 </select>
202 <ul>
203 <li class="description"><?php _e( '"Username and Email" - users can Log In with both Username and Email.', 'profile-builder' ); ?></li>
204 <li class="description"><?php _e( '"Username" - users can Log In only with Username.', 'profile-builder' ); ?></li>
205 <li class="description"><?php _e( '"Email" - users can Log In only with Email.', 'profile-builder' ); ?></li>
206 </ul>
207 </td>
208 </tr>
209
210 <tr>
211 <th scope="row">
212 <?php _e( 'Minimum Password Length:', 'profile-builder' ); ?>
213 </th>
214 <td>
215 <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'] ); ?>"/>
216 <ul>
217 <li class="description"><?php _e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profile-builder' ); ?> </li>
218 </ul>
219 </td>
220 </tr>
221
222 <tr>
223 <th scope="row">
224 <?php _e( 'Minimum Password Strength:', 'profile-builder' ); ?>
225 </th>
226 <td>
227 <select name="wppb_general_settings[minimum_password_strength]" class="wppb-select">
228 <option value=""><?php _e( 'Disabled', 'profile-builder' ); ?></option>
229 <option value="short" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'short' ) echo 'selected'; ?>><?php _e( 'Very weak', 'profile-builder' ); ?></option>
230 <option value="bad" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'bad' ) echo 'selected'; ?>><?php _e( 'Weak', 'profile-builder' ); ?></option>
231 <option value="good" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'good' ) echo 'selected'; ?>><?php _e( 'Medium', 'profile-builder' ); ?></option>
232 <option value="strong" <?php if ( !empty($wppb_generalSettings['minimum_password_strength']) && $wppb_generalSettings['minimum_password_strength'] == 'strong' ) echo 'selected'; ?>><?php _e( 'Strong', 'profile-builder' ); ?></option>
233 </select>
234 </td>
235 </tr>
236
237 <?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
238 </table>
239
240
241
242 <input type="hidden" name="action" value="update" />
243 <p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" /></p>
244 </form>
245 </div>
246
247 <?php
248 }
249
250
251 /*
252 * Function that sanitizes the general settings
253 *
254 * @param array $wppb_generalSettings
255 *
256 * @since v.2.0.7
257 */
258 function wppb_general_settings_sanitize( $wppb_generalSettings ) {
259 $wppb_generalSettings = apply_filters( 'wppb_general_settings_sanitize_extra', $wppb_generalSettings );
260
261 if( !empty( $wppb_generalSettings ) ){
262 foreach( $wppb_generalSettings as $settings_name => $settings_value ){
263 if( $settings_name == "minimum_password_length" || $settings_name == "activationLandingPage" )
264 $wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_NUMBER_INT );
265 elseif( $settings_name == "extraFieldsLayout" || $settings_name == "emailConfirmation" || $settings_name == "adminApproval" || $settings_name == "loginWith" || $settings_name == "minimum_password_strength" )
266 $wppb_generalSettings[$settings_name] = filter_var( $settings_value, FILTER_SANITIZE_STRING );
267 elseif( $settings_name == "adminApprovalOnUserRole" ){
268 if( is_array( $settings_value ) && !empty( $settings_value ) ){
269 foreach( $settings_value as $key => $value ){
270 $wppb_generalSettings[$settings_name][$key] = filter_var( $value, FILTER_SANITIZE_STRING );
271 }
272 }
273 }
274 }
275 }
276
277 return $wppb_generalSettings;
278 }
279
280
281 /*
282 * Function that pushes settings errors to the user
283 *
284 * @since v.2.0.7
285 */
286 function wppb_general_settings_admin_notices() {
287 settings_errors( 'wppb_general_settings' );
288 }
289 add_action( 'admin_notices', 'wppb_general_settings_admin_notices' );
290
291
292 /*
293 * Function that return user roles
294 *
295 * @since v.2.2.0
296 *
297 * @return array
298 */
299 function wppb_adminApproval_onUserRole() {
300 global $wp_roles;
301
302 $wp_roles = new WP_Roles();
303
304 $roles = $wp_roles->get_names();
305
306 unset( $roles['administrator'] );
307
308 return $roles;
309 }
310