PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.13
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.13
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / admin / settings / class-settings.php

class-settings.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.0.13, at admin/settings/class-settings.php

858 lines 40.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin-specific functionality of the plugin.
4 *
5 * @link http://wpgeodirectory.com
6 * @since 1.0.0
7 *
8 * @package userswp
9 * @subpackage userswp/admin/settings
10 */
11
12 /**
13 * The admin-specific functionality of the plugin.
14 *
15 * Defines the plugin name, version, and two examples hooks for how to
16 * enqueue the admin-specific stylesheet and JavaScript.
17 *
18 * @package userswp
19 * @subpackage userswp/admin/settings
20 * @author GeoDirectory Team <info@wpgeodirectory.com>
21 */
22 class UsersWP_Admin_Settings {
23
24 private $form_builder;
25
26 public function __construct($form_builder) {
27
28 $this->form_builder = $form_builder;
29
30 }
31
32 public function init_settings() {
33
34 global $uwp_options;
35 $uwp_options = $this->uwp_get_settings();
36
37 }
38
39 public function uwp_settings_page() {
40
41 $page = isset( $_GET['page'] ) ? $_GET['page'] : 'userswp';
42
43 $settings_array = uwp_get_settings_tabs();
44 $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_array[$page] ) ? $_GET['tab'] : 'main';
45 ?>
46 <div class="wrap">
47
48 <h1><?php echo get_admin_page_title(); ?></h1>
49
50 <div id="users-wp">
51 <div class="item-list-tabs">
52
53 <?php if (isset($settings_array[$page]) && count($settings_array[$page]) > 1) { ?>
54
55 <div class="wp-filter" style="margin-top: 0;margin-bottom: 5px">
56 <ul class="filter-links">
57 <?php
58 foreach( $settings_array[$page] as $tab_id => $tab_name ) {
59
60 $tab_url = add_query_arg( array(
61 'settings-updated' => false,
62 'tab' => $tab_id,
63 'subtab' => false
64 ) );
65
66 $active = $active_tab == $tab_id ? ' current selected' : '';
67 ?>
68 <li id="uwp-<?php echo $tab_id; ?>-li">
69 <a class="<?php echo $active; ?>" id="uwp-<?php echo $tab_id; ?>" href="<?php echo esc_url( $tab_url ); ?>"><?php echo esc_html( $tab_name ); ?></a>
70 </li>
71 <?php
72 }
73 ?>
74 </ul>
75 </div>
76
77 <?php } ?>
78
79 <?php do_action($page.'_settings_'.$active_tab.'_tab_content_before'); ?>
80
81 <div class="postbox">
82 <div class="tab-content inside">
83 <?php
84 // {current page}_settings_{active tab}_tab_content
85 // ex: uwp_settings_main_tab_content
86 do_action($page.'_settings_'.$active_tab.'_tab_content', uwp_display_form());
87 ?>
88 </div>
89 </div>
90 </div>
91
92 </div>
93
94 </div>
95 <?php }
96
97 public function get_general_content() {
98
99 $subtab = 'general';
100
101 if (isset($_GET['subtab'])) {
102 $subtab = $_GET['subtab'];
103 }
104 ?>
105 <div class="item-list-sub-tabs">
106 <ul class="item-list-sub-tabs-ul">
107 <li class="<?php if ($subtab == 'general') { echo "current selected"; } ?>">
108 <a href="<?php echo add_query_arg(array('tab' => 'main', 'subtab' => 'general')); ?>"><?php echo __( 'General Settings', 'userswp' ); ?></a>
109 </li>
110 <li class="<?php if ($subtab == 'shortcodes') { echo "current selected"; } ?>">
111 <a href="<?php echo add_query_arg(array('tab' => 'main', 'subtab' => 'shortcodes')); ?>"><?php echo __( 'Shortcodes', 'userswp' ); ?></a>
112 </li>
113 <li class="<?php if ($subtab == 'info') { echo "current selected"; } ?>">
114 <a href="<?php echo add_query_arg(array('tab' => 'main', 'subtab' => 'info')); ?>"><?php echo __( 'Info', 'userswp' ); ?></a>
115 </li>
116 </ul>
117 </div>
118 <?php
119 if ($subtab == 'general') {
120 $this->get_general_general_content();
121 } elseif ($subtab == 'shortcodes') {
122 $this->get_general_shortcodes_content();
123 } elseif ($subtab == 'info') {
124 $this->get_general_info_content();
125 }
126 }
127
128 //main tabs
129
130 public function uwp_get_pages_as_option($selected) {
131 $page_options = uwp_get_pages();
132 foreach ($page_options as $key => $page_title) {
133 ?>
134 <option value="<?php echo $key; ?>" <?php selected( $selected, $key ); ?>><?php echo $page_title; ?></option>
135 <?php
136 }
137 }
138
139 public function get_general_shortcodes_content() {
140 ?>
141 <table class="uwp-form-table">
142
143 <?php do_action('uwp_before_general_shortcodes_content'); ?>
144
145 <tr valign="top">
146 <th scope="row"><?php echo __( 'User Profile Shortcode', 'userswp' ); ?></th>
147 <td>
148 <span class="short_code">[uwp_profile]</span>
149 <span class="description"><?php echo __( 'This is the shortcode for the front end user\'s profile.', 'userswp' ); ?></span>
150 </td>
151 </tr>
152
153 <tr valign="top">
154 <th scope="row"><?php echo __( 'Register Form Shortcode', 'userswp' ); ?></th>
155 <td>
156 <span class="short_code">[uwp_register]</span>
157 <span class="description"><?php echo __( 'This is the shortcode for the front end register form.', 'userswp' ); ?></span>
158 </td>
159 </tr>
160
161 <tr valign="top">
162 <th scope="row"><?php echo __( 'Login Form Shortcode', 'userswp' ); ?></th>
163 <td>
164 <span class="short_code">[uwp_login]</span>
165 <span class="description"><?php echo __( 'This is the shortcode for the front end login form.', 'userswp' ); ?></span>
166 </td>
167 </tr>
168
169 <tr valign="top">
170 <th scope="row"><?php echo __( 'Account Form Shortcode', 'userswp' ); ?></th>
171 <td>
172 <span class="short_code">[uwp_account]</span>
173 <span class="description"><?php echo __( 'This is the shortcode for the front end account form.', 'userswp' ); ?></span>
174 </td>
175 </tr>
176
177 <tr valign="top">
178 <th scope="row"><?php echo __( 'Forgot Password Form Shortcode', 'userswp' ); ?></th>
179 <td>
180 <span class="short_code">[uwp_forgot]</span>
181 <span class="description"><?php echo __( 'This is the shortcode for the front end forgot password form.', 'userswp' ); ?></span>
182 </td>
183 </tr>
184
185 <tr valign="top">
186 <th scope="row"><?php echo __( 'Change Password Form Shortcode', 'userswp' ); ?></th>
187 <td>
188 <span class="short_code">[uwp_change]</span>
189 <span class="description"><?php echo __( 'This is the shortcode for the front end change password form.', 'userswp' ); ?></span>
190 </td>
191 </tr>
192
193 <tr valign="top">
194 <th scope="row"><?php echo __( 'Reset Password Form Shortcode', 'userswp' ); ?></th>
195 <td>
196 <span class="short_code">[uwp_reset]</span>
197 <span class="description"><?php echo __( 'This is the shortcode for the front end reset password form.', 'userswp' ); ?></span>
198 </td>
199 </tr>
200
201 <tr valign="top">
202 <th scope="row"><?php echo __( 'Users List Shortcode', 'userswp' ); ?></th>
203 <td>
204 <span class="short_code">[uwp_users]</span>
205 <span class="description"><?php echo __( 'This is the shortcode for the front end users list.', 'userswp' ); ?></span>
206 </td>
207 </tr>
208
209 <?php do_action('uwp_after_general_shortcodes_content'); ?>
210
211 </table>
212 <?php
213 }
214
215 //subtabs
216 public function get_general_general_content() {
217 echo uwp_display_form();
218 }
219
220 public function display_form_title($title, $page, $active_tab) {
221 if ($page == 'userswp' && $active_tab == 'main') {
222 $title = __('General Options', 'userswp');
223 }
224 return $title;
225 }
226
227 public function get_general_info_content() {
228 ?>
229 <h3><?php echo __( 'Welcome to UsersWP', 'userswp' ); ?></h3>
230 <h4><?php echo __( 'Version 1.0.0', 'userswp' ); ?></h4>
231
232 <h3><?php echo __( 'Flexible, Lightweight and Fast', 'userswp' ); ?></h3>
233 <p><?php echo __( 'UsersWP allows you to add a customizable register and login form to your website.
234 It also adds an extended profile page that override the default author page.
235 UsersWP has been built to be lightweight and fast', 'userswp' ); ?></p>
236
237 <h3><?php echo __( 'Less options, more hooks', 'userswp' ); ?></h3>
238 <p><?php echo __( 'We cut down the options to the bare minimum and you will not find any fancy
239 styling options in this plugin as we believe they belong in your theme.
240 This doesn\'t mean that you cannot customize the plugin behaviour.
241 To do this we provided a long list of Filters and Actions for any developer
242 to extend UsersWP to fit their needs.', 'userswp' ); ?></p>
243
244 <h3><?php echo __( 'Override Templates', 'userswp' ); ?></h3>
245 <p><?php echo __( 'If you need to change the look and feel of any UsersWP templates,
246 simply create a folder named userswp inside your active child theme
247 and copy the template you wish to modify in it. You can now modify the template.
248 The plugin will use your modified version and you don\'t have to worry about plugin or theme updates.
249 <a href="https://userswp.io/docs/override-templates/">Click here for examples</a>', 'userswp' ); ?></p>
250
251 <h3><?php echo __( 'Add-ons', 'userswp' ); ?></h3>
252 <p><?php echo __( 'We have a long list of free and premium add-ons that will help you extend users management on your website.
253 <a href="https://userswp.io/downloads/category/addons/">Click here for our official free and premium add-ons</a>', 'userswp' ); ?></p>
254 <?php
255 }
256
257 public function get_form_builder_tabs() {
258 $tab = 'account';
259
260 if (isset($_GET['tab'])) {
261 $tab = $_GET['tab'];
262 }
263
264 ?>
265
266 <div class="wp-filter" style="margin-top: 0;margin-bottom: 5px">
267 <ul class="filter-links">
268 <li id="uwp-form-builder-account-li">
269 <a id="uwp-form-builder-account" class="<?php if ($tab == 'account') { echo "current selected"; } ?>" href="<?php echo add_query_arg(array('tab' => 'account')); ?>"><?php echo __( 'Account', 'userswp' ); ?></a>
270 </li>
271 <li id="uwp-form-builder-register-li">
272 <a id="uwp-form-builder-register" class="<?php if ($tab == 'register') { echo "current selected"; } ?>" href="<?php echo add_query_arg(array('tab' => 'register')); ?>"><?php echo __( 'Register', 'userswp' ); ?></a>
273 </li>
274 <?php do_action('uwp_form_builder_tab_items', $tab); ?>
275 </ul>
276 </div>
277 <?php
278 }
279
280 public function get_form_builder_content() {
281
282 $tab = 'account';
283
284 if (isset($_GET['tab'])) {
285 $tab = $_GET['tab'];
286 }
287
288 $tab_content = $this->form_builder->uwp_form_builder($tab);
289 if ($tab == 'account') {
290 ?>
291 <h3 class=""><?php echo __( 'Manage Account Form Fields', 'userswp' ); ?></h3>
292 <?php
293 echo $tab_content;
294 } elseif ($tab == 'register') {
295 ?>
296 <h3 class=""><?php echo __( 'Manage Register Form Fields', 'userswp' ); ?></h3>
297 <?php
298 echo $tab_content;
299 }
300
301 do_action('uwp_extra_form_builder_content', $tab, $tab_content);
302 }
303
304 public function generic_display_form() {
305 echo uwp_display_form();
306 }
307
308 public function get_recaptcha_content() {
309 echo uwp_display_form();
310 }
311
312 public function get_geodirectory_content() {
313 echo uwp_display_form();
314 }
315
316 public function get_notifications_content() {
317 ?>
318 <h3 class=""><?php echo __( 'Email Notifications', 'userswp' ); ?></h3>
319
320 <table class="uwp-form-table">
321 <tbody>
322 <tr valign="top">
323 <th scope="row" class="titledesc"><?php echo __( 'List of usable shortcodes', 'userswp' ); ?></th>
324 <td class="forminp">
325 <span class="description">[#site_name_url#],[#site_name#],[#to_name#],[#from_name#],[#login_url#],[#user_name#],[#from_email#],[#user_login#],[#username#],[#current_date#],[#login_details#],[#reset_link#],[#activation_link#]</span>
326 </td>
327 </tr>
328 </tbody>
329 </table>
330
331 <?php
332 echo uwp_display_form();
333 }
334
335 public function uwp_register_settings() {
336
337 if ( false == get_option( 'uwp_settings' ) ) {
338 add_option( 'uwp_settings' );
339 }
340
341 $callback = new UsersWP_Callback();
342
343 foreach( $this->uwp_get_registered_settings() as $tab => $settings ) {
344
345 foreach ( $settings as $key => $opt ) {
346 add_settings_section(
347 'uwp_settings_' . $tab .'_'.$key,
348 __return_null(),
349 '__return_false',
350 'uwp_settings_' . $tab .'_'.$key
351 );
352
353 foreach ($opt as $option) {
354 $name = isset( $option['name'] ) ? $option['name'] : '';
355
356 add_settings_field(
357 'uwp_settings[' . $option['id'] . ']',
358 $name,
359 method_exists($callback, 'uwp_' . $option['type'] . '_callback') ? array($callback, 'uwp_' . $option['type'] . '_callback') : array($callback, 'uwp_missing_callback'),
360 'uwp_settings_' . $tab .'_'.$key,
361 'uwp_settings_' . $tab .'_'.$key,
362 array(
363 'section' => $tab,
364 'id' => isset( $option['id'] ) ? $option['id'] : null,
365 'class' => isset( $option['class'] ) ? $option['class'] : null,
366 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
367 'name' => isset( $option['name'] ) ? $option['name'] : null,
368 'size' => isset( $option['size'] ) ? $option['size'] : null,
369 'options' => isset( $option['options'] ) ? $option['options'] : '',
370 'std' => isset( $option['std'] ) ? $option['std'] : '',
371 'min' => isset( $option['min'] ) ? $option['min'] : null,
372 'max' => isset( $option['max'] ) ? $option['max'] : null,
373 'step' => isset( $option['step'] ) ? $option['step'] : null,
374 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null,
375 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
376 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
377 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
378 'faux' => isset( $option['faux'] ) ? $option['faux'] : false,
379 'global' => isset( $setting['global'] ) ? $setting['global'] : true,
380 'multiple' => isset( $option['multiple'] ) ? $option['multiple'] : false,
381 )
382 );
383 }
384 }
385
386 }
387
388 // Creates our settings in the options table
389 register_setting( 'uwp_settings', 'uwp_settings', array($this, 'uwp_settings_sanitize') );
390
391 }
392
393 public function uwp_get_registered_settings() {
394
395 $file_obj = new UsersWP_Files();
396
397 /**
398 * 'Whitelisted' uwp settings, filters are provided for each settings
399 * section to allow extensions and other plugins to add their own settings
400 */
401 $uwp_settings = array(
402 /** General Settings */
403 'userswp' => array(
404 'main' => apply_filters( 'uwp_settings_general_main',
405 array(
406 'profile_page' => array(
407 'id' => 'profile_page',
408 'name' => __( 'User Profile Page', 'userswp' ),
409 'desc' => __( 'This is the front end user\'s profile page. This page automatically overrides the default WordPress author page.', 'userswp' ),
410 'type' => 'select',
411 'options' => uwp_get_pages(),
412 'chosen' => true,
413 'placeholder' => __( 'Select a page', 'userswp' ),
414 'class' => 'uwp_label_block',
415 ),
416 'register_page' => array(
417 'id' => 'register_page',
418 'name' => __( 'Register Page', 'userswp' ),
419 'desc' => __( 'This is the front end register page. This is where users create their account.', 'userswp' ),
420 'type' => 'select',
421 'options' => uwp_get_pages(),
422 'chosen' => true,
423 'placeholder' => __( 'Select a page', 'userswp' ),
424 'class' => 'uwp_label_block',
425 ),
426 'login_page' => array(
427 'id' => 'login_page',
428 'name' => __( 'Login Page', 'userswp' ),
429 'desc' => __( 'This is the front end login page. This is where users will login after creating their account.', 'userswp' ),
430 'type' => 'select',
431 'options' => uwp_get_pages(),
432 'chosen' => true,
433 'placeholder' => __( 'Select a page', 'userswp' ),
434 'class' => 'uwp_label_block',
435 ),
436 'account_page' => array(
437 'id' => 'account_page',
438 'name' => __( 'Account Page', 'userswp' ),
439 'desc' => __( 'This is the front end account page. This is where users can edit their account.', 'userswp' ),
440 'type' => 'select',
441 'options' => uwp_get_pages(),
442 'chosen' => true,
443 'placeholder' => __( 'Select a page', 'userswp' ),
444 'class' => 'uwp_label_block',
445 ),
446 'change_page' => array(
447 'id' => 'change_page',
448 'name' => __( 'Change Password Page', 'userswp' ),
449 'desc' => __( 'This is the front end Change Password page.', 'userswp' ),
450 'type' => 'select',
451 'options' => uwp_get_pages(),
452 'chosen' => true,
453 'placeholder' => __( 'Select a page', 'userswp' ),
454 'class' => 'uwp_label_block',
455 ),
456 'forgot_page' => array(
457 'id' => 'forgot_page',
458 'name' => __( 'Forgot Password Page', 'userswp' ),
459 'desc' => __( 'This is the front end Forgot Password page. This is the page where users are sent to reset their password when they lose it.', 'userswp' ),
460 'type' => 'select',
461 'options' => uwp_get_pages(),
462 'chosen' => true,
463 'placeholder' => __( 'Select a page', 'userswp' ),
464 'class' => 'uwp_label_block',
465 ),
466 'reset_page' => array(
467 'id' => 'reset_page',
468 'name' => __( 'Reset Password Page', 'userswp' ),
469 'desc' => __( 'This is the front end Reset Password page. This is the page where users can reset their password when they lose it.', 'userswp' ),
470 'type' => 'select',
471 'options' => uwp_get_pages(),
472 'chosen' => true,
473 'placeholder' => __( 'Select a page', 'userswp' ),
474 'class' => 'uwp_label_block',
475 ),
476 'users_page' => array(
477 'id' => 'users_page',
478 'name' => __( 'Users List Page', 'userswp' ),
479 'desc' => __( 'This is the front end Users List page. This is the page where all registered users of the websites are listed.', 'userswp' ),
480 'type' => 'select',
481 'options' => uwp_get_pages(),
482 'chosen' => true,
483 'placeholder' => __( 'Select a page', 'userswp' ),
484 'class' => 'uwp_label_block',
485 ),
486 'profile_no_of_items' => array(
487 'id' => 'profile_no_of_items',
488 'name' => __( 'Number of Items', 'userswp' ),
489 'type' => 'text',
490 'std' => '',
491 'desc' => __( 'Enter number of items to display in profile tabs.', 'userswp' ),
492 ),
493 )
494 ),
495 'register' => apply_filters( 'uwp_settings_general_register', uwp_settings_general_register_fields()),
496 'login' => apply_filters( 'uwp_settings_general_login', uwp_settings_general_loginout_fields()),
497 'profile' => apply_filters( 'uwp_settings_general_profile',
498 array(
499 'enable_profile_header' => array(
500 'id' => 'enable_profile_header',
501 'name' => __( 'Display Header in Profile', 'userswp' ),
502 'desc' => '',
503 'type' => 'checkbox',
504 'std' => '1',
505 'class' => 'uwp_label_inline',
506 ),
507 'profile_avatar_size' => array(
508 'id' => 'profile_avatar_size',
509 'name' => __( 'Profile Avatar max file size', 'userswp' ),
510 'desc' => __( 'Enter Profile Avatar max file size in Kb. e.g. 512 for 512 kb, 1024 for 1 Mb, 2048 for 2 Mb etc. If empty WordPress default (<b>'.$file_obj->uwp_formatSizeinKb($file_obj->uwp_get_max_upload_size()).'</b>) will be used.', 'userswp' ),
511 'type' => 'number',
512 'std' => '',
513 'size' => 'regular',
514 'placeholder' => __( 'Enter Profile Avatar max file size.', 'userswp' ),
515 ),
516 'profile_banner_size' => array(
517 'id' => 'profile_banner_size',
518 'name' => __( 'Profile Banner max file size', 'userswp' ),
519 'desc' => __( 'Enter Profile Banner max file size in Kb. e.g. 512 for 512 kb, 1024 for 1 Mb, 2048 for 2 Mb etc. If empty WordPress default (<b>'.$file_obj->uwp_formatSizeinKb($file_obj->uwp_get_max_upload_size()).'</b>) will be used.', 'userswp' ),
520 'type' => 'number',
521 'std' => '',
522 'size' => 'regular',
523 'placeholder' => __( 'Enter Profile Banner max file size.', 'userswp' ),
524 ),
525 'profile_banner_width' => array(
526 'id' => 'profile_banner_width',
527 'name' => __( 'Profile banner width', 'userswp' ),
528 'desc' => '',
529 'type' => 'number',
530 'std' => '1000',
531 'size' => 'regular',
532 'placeholder' => __( 'Enter Profile banner width in Pixels', 'userswp' ),
533 ),
534 'profile_default_banner' => array(
535 'id' => 'profile_default_banner',
536 'name' => __( 'Default banner image', 'userswp' ),
537 'desc' => __( 'Recommended image size: 1000x300', 'userswp'),
538 'type' => 'media',
539 'std' => '',
540 'placeholder' => USERSWP_PLUGIN_URL."public/assets/images/banner.png"
541 ),
542 'profile_default_profile' => array(
543 'id' => 'profile_default_profile',
544 'name' => __( 'Default profile image', 'userswp' ),
545 'desc' => __( 'Recommended image size: 150x150', 'userwp'),
546 'type' => 'media',
547 'std' => '',
548 'placeholder' => USERSWP_PLUGIN_URL."public/assets/images/no_profile.png"
549 ),
550 'enable_profile_body' => array(
551 'id' => 'enable_profile_body',
552 'name' => __( 'Display Body in Profile', 'userswp' ),
553 'desc' => '',
554 'type' => 'checkbox',
555 'std' => '1',
556 'class' => 'uwp_label_inline',
557 ),
558 'enable_profile_tabs' => array(
559 'id' => 'enable_profile_tabs',
560 'name' => __( 'Choose the tabs to display in Profile', 'userswp' ),
561 'desc' => __( 'Choose the tabs to display in UsersWP Profile', 'userswp' ),
562 'multiple' => true,
563 'chosen' => true,
564 'type' => 'select_order',
565 'options' => $this->uwp_available_tab_items(),
566 'placeholder' => __( 'Select Tabs', 'userswp' )
567 ),
568 )
569 ),
570 'users' => apply_filters( 'uwp_settings_general_profile',
571 array(
572 'users_default_layout' => array(
573 'id' => 'users_default_layout',
574 'name' => __( 'Users default layout', 'userswp' ),
575 'desc' => __( 'Choose the default layout for Users Page - Users List', 'userswp' ),
576 'type' => 'select',
577 'options' => $this->uwp_available_users_layout(),
578 'placeholder' => __( 'Select Layout', 'userswp' )
579 ),
580 'users_excluded_from_list' => array(
581 'id' => 'users_excluded_from_list',
582 'name' => __( 'Users to exclude', 'userswp' ),
583 'type' => 'text',
584 'std' => '',
585 'desc' => __( 'Enter comma separated ids of users to exclude from users listing.', 'userswp' ),
586 ),
587 )
588 ),
589 'change' => apply_filters( 'uwp_settings_general_change',
590 array(
591 'change_enable_old_password' => array(
592 'id' => 'change_enable_old_password',
593 'name' => __( 'Enabled Old Password?', 'userswp' ),
594 'desc' => 'This option adds an extra layer of security. User need to enter their old password before changing the password.',
595 'type' => 'checkbox',
596 'std' => '1',
597 'class' => 'uwp_label_inline',
598 ),
599 'change_disable_password_nag' => array(
600 'id' => 'change_disable_password_nag',
601 'name' => __( 'Disable system generated password notice.', 'userswp' ),
602 'desc' => 'This option will disable system generated password notice if user has not changed default password after registration.',
603 'type' => 'checkbox',
604 'std' => '0',
605 'class' => 'uwp_label_inline',
606 ),
607 )
608 ),
609 'uninstall' => apply_filters( 'uwp_settings_general_uninstall',
610 array(
611 'uninstall_erase_data' => array(
612 'id' => 'uninstall_erase_data',
613 'name' => __( 'UsersWP', 'userswp' ),
614 'desc' => __( 'Remove all data when deleted?', 'userswp' ),
615 'type' => 'checkbox',
616 'std' => '1',
617 'class' => 'uwp_label_inline',
618 ),
619 )
620 ),
621 ),
622 'uwp_notifications' => array(
623 'main' => apply_filters( 'uwp_settings_notifications_main',
624 array(
625 'registration_activate_email_subject' => array(
626 'id' => 'registration_activate_email_subject',
627 'name' => __( 'Registration activate email', 'userswp' ),
628 'desc' => "",
629 'type' => 'text',
630 'size' => 'regular',
631 'placeholder' => __( 'Enter Registration activate email Subject', 'userswp' )
632 ),
633 'registration_activate_email_content' => array(
634 'id' => 'registration_activate_email_content',
635 'name' => "",
636 'desc' => "",
637 'type' => 'textarea',
638 'placeholder' => __( 'Enter Registration activate email Content', 'userswp' )
639 ),
640 'registration_success_email_subject' => array(
641 'id' => 'registration_success_email_subject',
642 'name' => __( 'Registration success email', 'userswp' ),
643 'desc' => "",
644 'type' => 'text',
645 'size' => 'regular',
646 'placeholder' => __( 'Enter Registration success email Subject', 'userswp' )
647 ),
648 'registration_success_email_content' => array(
649 'id' => 'registration_success_email_content',
650 'name' => "",
651 'desc' => "",
652 'type' => 'textarea',
653 'placeholder' => __( 'Enter Registration success email Content', 'userswp' )
654 ),
655 'forgot_password_email_subject' => array(
656 'id' => 'forgot_password_email_subject',
657 'name' => __( 'Forgot password email', 'userswp' ),
658 'desc' => "",
659 'type' => 'text',
660 'size' => 'regular',
661 'placeholder' => __( 'Enter forgot password email Subject', 'userswp' )
662 ),
663 'forgot_password_email_content' => array(
664 'id' => 'forgot_password_email_content',
665 'name' => "",
666 'desc' => "",
667 'type' => 'textarea',
668 'placeholder' => __( 'Enter forgot password email Content', 'userswp' )
669 ),
670 'change_password_email_subject' => array(
671 'id' => 'change_password_email_subject',
672 'name' => __( 'Change password email', 'userswp' ),
673 'desc' => "",
674 'type' => 'text',
675 'size' => 'regular',
676 'placeholder' => __( 'Enter change password email Subject', 'userswp' )
677 ),
678 'change_password_email_content' => array(
679 'id' => 'change_password_email_content',
680 'name' => "",
681 'desc' => "",
682 'type' => 'textarea',
683 'placeholder' => __( 'Enter change password email Content', 'userswp' )
684 ),
685 'reset_password_email_subject' => array(
686 'id' => 'reset_password_email_subject',
687 'name' => __( 'Reset password email', 'userswp' ),
688 'desc' => "",
689 'type' => 'text',
690 'size' => 'regular',
691 'placeholder' => __( 'Enter reset password email Subject', 'userswp' )
692 ),
693 'reset_password_email_content' => array(
694 'id' => 'reset_password_email_content',
695 'name' => "",
696 'desc' => "",
697 'type' => 'textarea',
698 'placeholder' => __( 'Enter reset password email Content', 'userswp' )
699 ),
700 'enable_account_update_notification' => array(
701 'id' => 'enable_account_update_notification',
702 'name' => __( 'Account update email', 'userswp' ),
703 'desc' => 'Enable account update notification',
704 'type' => 'checkbox',
705 'std' => '0',
706 'class' => 'uwp_label_inline',
707 ),
708 'account_update_email_subject' => array(
709 'id' => 'account_update_email_subject',
710 'name' => "",
711 'desc' => "",
712 'type' => 'text',
713 'size' => 'regular',
714 'placeholder' => __( 'Enter account update email Subject', 'userswp' )
715 ),
716 'account_update_email_content' => array(
717 'id' => 'account_update_email_content',
718 'name' => "",
719 'desc' => "",
720 'type' => 'textarea',
721 'placeholder' => __( 'Enter account update email Content', 'userswp' )
722 ),
723 )
724 ),
725 'admin' => apply_filters( 'uwp_settings_notifications_admin',
726 array(
727 'registration_success_email_subject_admin' => array(
728 'id' => 'registration_success_email_subject_admin',
729 'name' => __( 'New account registration', 'userswp' ),
730 'desc' => "",
731 'type' => 'text',
732 'std' => __( 'New account registration', 'userswp' ),
733 'size' => 'regular',
734 ),
735 'registration_success_email_content_admin' => array(
736 'id' => 'registration_success_email_content_admin',
737 'name' => "",
738 'desc' => "",
739 'type' => 'textarea',
740 'std' => __("A user has been registered recently on your website. [#extras#]", "userswp"),
741 ),
742 )
743 ),
744 ),
745 );
746
747 $uwp_settings = apply_filters( 'uwp_registered_settings', $uwp_settings );
748
749 return $uwp_settings;
750 }
751
752 public function uwp_get_settings() {
753
754 $settings = get_option( 'uwp_settings' );
755
756 if( empty( $settings ) ) {
757
758 // Update old settings with new single option
759
760 $general_settings = is_array( get_option( 'uwp_settings_general' ) ) ? get_option( 'uwp_settings_general' ) : array();
761 $ext_settings = is_array( get_option( 'uwp_settings_extensions' ) ) ? get_option( 'uwp_settings_extensions' ) : array();
762
763 $settings = array_merge( $general_settings, $ext_settings );
764
765 update_option( 'uwp_settings', $settings );
766
767 }
768 return apply_filters( 'uwp_get_settings', $settings );
769 }
770
771 public function uwp_settings_sanitize( $input = array() ) {
772 global $uwp_options;
773
774 if ( empty( $_POST['_wp_http_referer'] ) ) {
775 return $input;
776 }
777
778 $parsed_url = wp_parse_url($_POST['_wp_http_referer']);
779
780 if (!isset($parsed_url['query'])) {
781 return $input;
782 }
783 parse_str( $parsed_url['query'], $referrer );
784
785 $settings = $this->uwp_get_registered_settings();
786
787 $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'main';
788 $page = isset( $referrer['page'] ) ? $referrer['page'] : 'userswp';
789
790 $input = $input ? $input : array();
791 $input = apply_filters( 'uwp_settings_'.$page.'_' . $tab . '_sanitize', $input );
792
793 // Loop through each setting being saved and pass it through a sanitization filter
794 foreach ( $input as $key => $value ) {
795 // Get the setting type (checkbox, select, etc)
796 $type = isset( $settings[$page][$tab][$key]['type'] ) ? $settings[$page][$tab][$key]['type'] : false;
797
798 if ( $type ) {
799 // Field type specific filter
800 $input[$key] = apply_filters( 'uwp_settings_sanitize_' . $type, $value, $key );
801 }
802
803 // General filter
804 $input[$key] = apply_filters( 'uwp_settings_sanitize', $input[$key], $key );
805 }
806
807 // Loop through the whitelist and unset any that are empty for the tab being saved
808 if ( ! empty( $settings[$page][$tab] ) ) {
809 foreach ( $settings[$page][$tab] as $key => $value ) {
810
811 // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
812 if ( is_numeric( $key ) ) {
813 $key = $value['id'];
814 }
815
816 if ( empty( $input[$key] ) ) {
817 unset( $uwp_options[$key] );
818 }
819
820 }
821 }
822
823 // Merge our new settings with the existing
824 $output = array_merge( $uwp_options, $input );
825
826 flush_rewrite_rules();
827 add_settings_error( 'uwp-notices', '', __( 'Settings updated.', 'userswp' ), 'updated' );
828
829 return $output;
830 }
831
832 public function uwp_available_tab_items() {
833 $tabs_arr = array(
834 'more_info' => __( 'More Info', 'userswp' ),
835 'posts' => __( 'Posts', 'userswp' ),
836 'comments' => __( 'Comments', 'userswp' ),
837 );
838
839 $tabs_arr = apply_filters('uwp_available_tab_items', $tabs_arr);
840
841 return $tabs_arr;
842 }
843
844 public function uwp_available_users_layout() {
845 $tabs_arr = array(
846 'list' => __( 'List View', 'userswp' ),
847 '2col' => __( 'Grid View - 2 Column', 'userswp' ),
848 '3col' => __( 'Grid View - 3 Column', 'userswp' ),
849 '4col' => __( 'Grid View - 4 Column', 'userswp' ),
850 '5col' => __( 'Grid View - 5 Column', 'userswp' ),
851 );
852
853 $tabs_arr = apply_filters('uwp_available_users_layout', $tabs_arr);
854
855 return $tabs_arr;
856 }
857
858 }