PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.2.7
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.2.7
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.2.7, at admin/general-settings.php

260 lines 11.8 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 $wppb_general_settings = get_option( 'wppb_general_settings', 'not_found' );
17
18 if ( $wppb_general_settings == 'not_found' )
19 update_option( 'wppb_general_settings', array( 'extraFieldsLayout' => 'default', 'emailConfirmation' => 'no', 'activationLandingPage' => '', 'adminApproval' => 'no', 'loginWith' => 'usernameemail' ) );
20 }
21
22
23 /**
24 * Function that adds content to the "General Settings" submenu page
25 *
26 * @since v.2.0
27 *
28 * @return string
29 */
30 function wppb_general_settings_content() {
31 wppb_generate_default_settings_defaults();
32 ?>
33 <div class="wrap wppb-wrap">
34 <form method="post" action="options.php#general-settings">
35 <?php $wppb_generalSettings = get_option( 'wppb_general_settings' ); ?>
36 <?php settings_fields( 'wppb_general_settings' ); ?>
37
38 <h2><?php _e( 'General Settings', 'profile-builder' ); ?></h2>
39 <table class="form-table">
40 <tr>
41 <th scope="row">
42 <?php _e( "Load Profile Builder's own CSS file in the front-end:", "profile-builder" ); ?>
43 </th>
44 <td>
45 <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>
46 <ul>
47 <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>
48 </ul>
49 </td>
50 </tr>
51
52 <tr>
53 <th scope="row">
54 <?php _e( '"Email Confirmation" Activated:', 'profile-builder' );?>
55 </th>
56 <td>
57 <select name="wppb_general_settings[emailConfirmation]" class="wppb-select" id="wppb_settings_email_confirmation" onchange="wppb_display_page_select(this.value)">
58 <option value="yes" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
59 <option value="no" <?php if ( $wppb_generalSettings['emailConfirmation'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
60 </select>
61 <ul>
62 <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" addon.', 'profile-builder' ); ?></li>
63 <?php if ( $wppb_generalSettings['emailConfirmation'] == 'yes' ) { ?>
64 <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>
65 <?php } ?>
66 </ul>
67 </td>
68 </tr>
69
70 <tr id="wppb-settings-activation-page">
71 <th scope="row">
72 <?php _e( '"Email Confirmation" Landing Page:', 'profile-builder' ); ?>
73 </th>
74 <td>
75 <select name="wppb_general_settings[activationLandingPage]" class="wppb-select">
76 <option value="" <?php if ( empty( $wppb_generalSettings['emailConfirmation'] ) ) echo 'selected'; ?>></option>
77 <optgroup label="<?php _e( 'Existing Pages', 'profile-builder' ); ?>">
78 <?php
79 $pages = get_pages( apply_filters( 'wppb_page_args_filter', array( 'sort_order' => 'ASC', 'sort_column' => 'post_title', 'post_type' => 'page', 'post_status' => array( 'publish' ) ) ) );
80
81 foreach ( $pages as $key => $value ){
82 echo '<option value="'.$value->ID.'"';
83 if ( $wppb_generalSettings['activationLandingPage'] == $value->ID )
84 echo ' selected';
85
86 echo '>' . $value->post_title . '</option>';
87 }
88 ?>
89 </optgroup>
90 </select>
91 <p class="description">
92 <?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' ); ?>
93 </p>
94 </td>
95 </tr>
96
97
98 <?php
99 if ( file_exists( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ){
100 ?>
101 <tr>
102 <th scope="row">
103 <?php _e( '"Admin Approval" Activated:', 'profile-builder' ); ?>
104 </th>
105 <td>
106 <select id="adminApprovalSelect" name="wppb_general_settings[adminApproval]" class="wppb-select" onchange="wppb_display_page_select_aa(this.value)">
107 <option value="yes" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'yes' ) echo 'selected'; ?>><?php _e( 'Yes', 'profile-builder' ); ?></option>
108 <option value="no" <?php if( !empty( $wppb_generalSettings['adminApproval'] ) && $wppb_generalSettings['adminApproval'] == 'no' ) echo 'selected'; ?>><?php _e( 'No', 'profile-builder' ); ?></option>
109 </select>
110 <ul>
111 <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>
112 <ul>
113 </td>
114 </tr>
115
116 <tr class="dynamic2">
117 <th scope="row">
118 <?php _e( '"Admin Approval" on User Role:', 'profile-builder' ); ?>
119 </th>
120 <td>
121 <div id="wrap">
122 <?php
123 $wppb_userRoles = wppb_adminApproval_onUserRole();
124
125 if( ! empty( $wppb_userRoles ) ) {
126 foreach( $wppb_userRoles as $role => $role_name ) {
127 echo '<label><input type="checkbox" id="adminApprovalOnUserRoleCheckbox" name="wppb_general_settings[adminApprovalOnUserRole][]" class="wppb-checkboxes" value="' . $role . '"';
128 if( ! empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) && in_array( $role, $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
129 if( empty( $wppb_generalSettings['adminApprovalOnUserRole'] ) ) echo ' checked';
130 echo '>';
131 echo $role_name . '</label><br>';
132 }
133 }
134 ?>
135 </div>
136 <ul>
137 <li class="description"><?php printf( __( 'Select on what user roles to activate Admin Approval.', 'profile-builder' ) ) ?></li>
138 <ul>
139 </td>
140 </tr>
141
142 <?php } ?>
143
144 <?php
145 if ( PROFILE_BUILDER == 'Profile Builder Free' ) {
146 ?>
147 <tr>
148 <th scope="row">
149 <?php _e( '"Admin Approval" Feature:', 'profile-builder' ); ?>
150 </th>
151 <td>
152 <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="http://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=general-settings-link&utm_campaign=PBFree">', '</a>' )?></em></p>
153 </td>
154 </tr>
155 <?php } ?>
156
157 <tr>
158 <th scope="row">
159 <?php _e( 'Allow Users to Log in With:', 'profile-builder' ); ?>
160 </th>
161 <td>
162 <select name="wppb_general_settings[loginWith]" class="wppb-select">
163 <option value="usernameemail" <?php if ( $wppb_generalSettings['loginWith'] == 'usernameemail' ) echo 'selected'; ?>><?php _e( 'Username and Email', 'profile-builder' ); ?></option>
164 <option value="username" <?php if ( $wppb_generalSettings['loginWith'] == 'username' ) echo 'selected'; ?>><?php _e( 'Username', 'profile-builder' ); ?></option>
165 <option value="email" <?php if ( $wppb_generalSettings['loginWith'] == 'email' ) echo 'selected'; ?>><?php _e( 'Email', 'profile-builder' ); ?></option>
166 </select>
167 <ul>
168 <li class="description"><?php _e( '"Username and Email" - users can Log In with both Username and Email.', 'profile-builder' ); ?></li>
169 <li class="description"><?php _e( '"Username" - users can Log In only with Username.', 'profile-builder' ); ?></li>
170 <li class="description"><?php _e( '"Email" - users can Log In only with Email.', 'profile-builder' ); ?></li>
171 </ul>
172 </td>
173 </tr>
174
175 <tr>
176 <th scope="row">
177 <?php _e( 'Minimum Password Length:', 'profile-builder' ); ?>
178 </th>
179 <td>
180 <input type="text" name="wppb_general_settings[minimum_password_length]" class="wppb-text" value="<?php if( !empty( $wppb_generalSettings['minimum_password_length'] ) ) echo $wppb_generalSettings['minimum_password_length']; ?>"/>
181 <ul>
182 <li class="description"><?php _e( 'Enter the minimum characters the password should have. Leave empty for no minimum limit', 'profile-builder' ); ?> </li>
183 </ul>
184 </td>
185 </tr>
186
187 <tr>
188 <th scope="row">
189 <?php _e( 'Minimum Password Strength:', 'profile-builder' ); ?>
190 </th>
191 <td>
192 <select name="wppb_general_settings[minimum_password_strength]" class="wppb-select">
193 <option value=""><?php _e( 'Disabled', 'profile-builder' ); ?></option>
194 <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>
195 <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>
196 <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>
197 <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>
198 </select>
199 </td>
200 </tr>
201
202 <?php do_action( 'wppb_extra_general_settings', $wppb_generalSettings ); ?>
203 </table>
204
205
206
207 <input type="hidden" name="action" value="update" />
208 <p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" /></p>
209 </form>
210 </div>
211
212 <?php
213 }
214
215
216 /*
217 * Function that sanitizes the general settings
218 *
219 * @param array $wppb_generalSettings
220 *
221 * @since v.2.0.7
222 */
223 function wppb_general_settings_sanitize( $wppb_generalSettings ) {
224
225 $wppb_generalSettings = apply_filters( 'wppb_general_settings_sanitize_extra', $wppb_generalSettings );
226
227 return $wppb_generalSettings;
228 }
229
230
231 /*
232 * Function that pushes settings errors to the user
233 *
234 * @since v.2.0.7
235 */
236 function wppb_general_settings_admin_notices() {
237 settings_errors( 'wppb_general_settings' );
238 }
239 add_action( 'admin_notices', 'wppb_general_settings_admin_notices' );
240
241
242 /*
243 * Function that return user roles
244 *
245 * @since v.2.2.0
246 *
247 * @return array
248 */
249 function wppb_adminApproval_onUserRole() {
250 global $wp_roles;
251
252 $wp_roles = new WP_Roles();
253
254 $roles = $wp_roles->get_names();
255
256 unset( $roles['administrator'] );
257
258 return $roles;
259 }
260