PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.10
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.10
1.2.74 1.2.73 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 All 174 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.10, at admin/settings/class-settings.php

808 lines 37.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 <tr valign="top">
144 <th scope="row"><?php echo __( 'User Profile Shortcode', 'userswp' ); ?></th>
145 <td>
146 <span class="short_code">[uwp_profile]</span>
147 <span class="description"><?php echo __( 'This is the shortcode for the front end user\'s profile.', 'userswp' ); ?></span>
148 </td>
149 </tr>
150
151 <tr valign="top">
152 <th scope="row"><?php echo __( 'Register Form Shortcode', 'userswp' ); ?></th>
153 <td>
154 <span class="short_code">[uwp_register]</span>
155 <span class="description"><?php echo __( 'This is the shortcode for the front end register form.', 'userswp' ); ?></span>
156 </td>
157 </tr>
158
159 <tr valign="top">
160 <th scope="row"><?php echo __( 'Login Form Shortcode', 'userswp' ); ?></th>
161 <td>
162 <span class="short_code">[uwp_login]</span>
163 <span class="description"><?php echo __( 'This is the shortcode for the front end login form.', 'userswp' ); ?></span>
164 </td>
165 </tr>
166
167 <tr valign="top">
168 <th scope="row"><?php echo __( 'Account Form Shortcode', 'userswp' ); ?></th>
169 <td>
170 <span class="short_code">[uwp_account]</span>
171 <span class="description"><?php echo __( 'This is the shortcode for the front end account form.', 'userswp' ); ?></span>
172 </td>
173 </tr>
174
175 <tr valign="top">
176 <th scope="row"><?php echo __( 'Forgot Password Form Shortcode', 'userswp' ); ?></th>
177 <td>
178 <span class="short_code">[uwp_forgot]</span>
179 <span class="description"><?php echo __( 'This is the shortcode for the front end forgot password form.', 'userswp' ); ?></span>
180 </td>
181 </tr>
182
183 <tr valign="top">
184 <th scope="row"><?php echo __( 'Change Password Form Shortcode', 'userswp' ); ?></th>
185 <td>
186 <span class="short_code">[uwp_change]</span>
187 <span class="description"><?php echo __( 'This is the shortcode for the front end change password form.', 'userswp' ); ?></span>
188 </td>
189 </tr>
190
191 <tr valign="top">
192 <th scope="row"><?php echo __( 'Reset Password Form Shortcode', 'userswp' ); ?></th>
193 <td>
194 <span class="short_code">[uwp_reset]</span>
195 <span class="description"><?php echo __( 'This is the shortcode for the front end reset password form.', 'userswp' ); ?></span>
196 </td>
197 </tr>
198
199 <tr valign="top">
200 <th scope="row"><?php echo __( 'Users List Shortcode', 'userswp' ); ?></th>
201 <td>
202 <span class="short_code">[uwp_users]</span>
203 <span class="description"><?php echo __( 'This is the shortcode for the front end users list.', 'userswp' ); ?></span>
204 </td>
205 </tr>
206
207 </table>
208 <?php
209 }
210
211 //subtabs
212 public function get_general_general_content() {
213 echo uwp_display_form();
214 }
215
216 public function display_form_title($title, $page, $active_tab) {
217 if ($page == 'userswp' && $active_tab == 'main') {
218 $title = __('General Options', 'userswp');
219 }
220 return $title;
221 }
222
223 public function get_general_info_content() {
224 ?>
225 <h3><?php echo __( 'Welcome to UsersWP', 'userswp' ); ?></h3>
226 <h4><?php echo __( 'Version 1.0.0', 'userswp' ); ?></h4>
227
228 <h3><?php echo __( 'Flexible, Lightweight and Fast', 'userswp' ); ?></h3>
229 <p><?php echo __( 'UsersWP allows you to add a customizable register and login form to your website.
230 It also adds an extended profile page that override the default author page.
231 UsersWP has been built to be lightweight and fast', 'userswp' ); ?></p>
232
233 <h3><?php echo __( 'Less options, more hooks', 'userswp' ); ?></h3>
234 <p><?php echo __( 'We cut down the options to the bare minimum and you will not find any fancy
235 styling options in this plugin as we believe they belong in your theme.
236 This doesn\'t mean that you cannot customize the plugin behaviour.
237 To do this we provided a long list of Filters and Actions for any developer
238 to extend UsersWP to fit their needs.', 'userswp' ); ?></p>
239
240 <h3><?php echo __( 'Override Templates', 'userswp' ); ?></h3>
241 <p><?php echo __( 'If you need to change the look and feel of any UsersWP templates,
242 simply create a folder named userswp inside your active child theme
243 and copy the template you wish to modify in it. You can now modify the template.
244 The plugin will use your modified version and you don\'t hve to worry about plugin or theme updates.
245 <a href="https://userswp.io/docs/override-templates/">Click here for examples</a>', 'userswp' ); ?></p>
246
247 <h3><?php echo __( 'Add-ons', 'userswp' ); ?></h3>
248 <p><?php echo __( 'We have a long list of free and premium add-ons that will help you extend users management on your wesbsite.
249 <a href="https://userswp.io/downloads/category/addons/">Click here for our official free and premium add-ons</a>', 'userswp' ); ?></p>
250 <?php
251 }
252
253 public function get_form_builder_tabs() {
254 $tab = 'account';
255
256 if (isset($_GET['tab'])) {
257 $tab = $_GET['tab'];
258 }
259
260 ?>
261
262 <div class="wp-filter" style="margin-top: 0;margin-bottom: 5px">
263 <ul class="filter-links">
264 <li id="uwp-form-builder-account-li">
265 <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>
266 </li>
267 <li id="uwp-form-builder-register-li">
268 <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>
269 </li>
270 <?php do_action('uwp_form_builder_tab_items', $tab); ?>
271 </ul>
272 </div>
273 <?php
274 }
275
276 public function get_form_builder_content() {
277
278 $tab = 'account';
279
280 if (isset($_GET['tab'])) {
281 $tab = $_GET['tab'];
282 }
283
284 $tab_content = $this->form_builder->uwp_form_builder($tab);
285 if ($tab == 'account') {
286 ?>
287 <h3 class=""><?php echo __( 'Manage Account Form Fields', 'userswp' ); ?></h3>
288 <?php
289 echo $tab_content;
290 } elseif ($tab == 'register') {
291 ?>
292 <h3 class=""><?php echo __( 'Manage Register Form Fields', 'userswp' ); ?></h3>
293 <?php
294 echo $tab_content;
295 }
296
297 do_action('uwp_extra_form_builder_content', $tab, $tab_content);
298 }
299
300 public function generic_display_form() {
301 echo uwp_display_form();
302 }
303
304 public function get_recaptcha_content() {
305 echo uwp_display_form();
306 }
307
308 public function get_geodirectory_content() {
309 echo uwp_display_form();
310 }
311
312 public function get_notifications_content() {
313 ?>
314 <h3 class=""><?php echo __( 'Email Notifications', 'userswp' ); ?></h3>
315
316 <table class="uwp-form-table">
317 <tbody>
318 <tr valign="top">
319 <th scope="row" class="titledesc"><?php echo __( 'List of usable shortcodes', 'userswp' ); ?></th>
320 <td class="forminp">
321 <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>
322 </td>
323 </tr>
324 </tbody>
325 </table>
326
327 <?php
328 echo uwp_display_form();
329 }
330
331 public function uwp_register_settings() {
332
333 if ( false == get_option( 'uwp_settings' ) ) {
334 add_option( 'uwp_settings' );
335 }
336
337 $callback = new UsersWP_Callback();
338
339 foreach( $this->uwp_get_registered_settings() as $tab => $settings ) {
340
341 foreach ( $settings as $key => $opt ) {
342 add_settings_section(
343 'uwp_settings_' . $tab .'_'.$key,
344 __return_null(),
345 '__return_false',
346 'uwp_settings_' . $tab .'_'.$key
347 );
348
349 foreach ($opt as $option) {
350 $name = isset( $option['name'] ) ? $option['name'] : '';
351
352 add_settings_field(
353 'uwp_settings[' . $option['id'] . ']',
354 $name,
355 method_exists($callback, 'uwp_' . $option['type'] . '_callback') ? array($callback, 'uwp_' . $option['type'] . '_callback') : array($callback, 'uwp_missing_callback'),
356 'uwp_settings_' . $tab .'_'.$key,
357 'uwp_settings_' . $tab .'_'.$key,
358 array(
359 'section' => $tab,
360 'id' => isset( $option['id'] ) ? $option['id'] : null,
361 'class' => isset( $option['class'] ) ? $option['class'] : null,
362 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
363 'name' => isset( $option['name'] ) ? $option['name'] : null,
364 'size' => isset( $option['size'] ) ? $option['size'] : null,
365 'options' => isset( $option['options'] ) ? $option['options'] : '',
366 'std' => isset( $option['std'] ) ? $option['std'] : '',
367 'min' => isset( $option['min'] ) ? $option['min'] : null,
368 'max' => isset( $option['max'] ) ? $option['max'] : null,
369 'step' => isset( $option['step'] ) ? $option['step'] : null,
370 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null,
371 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
372 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
373 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
374 'faux' => isset( $option['faux'] ) ? $option['faux'] : false,
375 'global' => isset( $setting['global'] ) ? $setting['global'] : true,
376 'multiple' => isset( $option['multiple'] ) ? $option['multiple'] : false,
377 )
378 );
379 }
380 }
381
382 }
383
384 // Creates our settings in the options table
385 register_setting( 'uwp_settings', 'uwp_settings', array($this, 'uwp_settings_sanitize') );
386
387 }
388
389 public function uwp_get_registered_settings() {
390
391 $file_obj = new UsersWP_Files();
392
393 /**
394 * 'Whitelisted' uwp settings, filters are provided for each settings
395 * section to allow extensions and other plugins to add their own settings
396 */
397 $uwp_settings = array(
398 /** General Settings */
399 'userswp' => array(
400 'main' => apply_filters( 'uwp_settings_general_main',
401 array(
402 'profile_page' => array(
403 'id' => 'profile_page',
404 'name' => __( 'User Profile Page', 'userswp' ),
405 'desc' => __( 'This is the front end user\'s profile page. This page automatically overrides the default WordPress author page.', 'userswp' ),
406 'type' => 'select',
407 'options' => uwp_get_pages(),
408 'chosen' => true,
409 'placeholder' => __( 'Select a page', 'userswp' ),
410 'class' => 'uwp_label_block',
411 ),
412 'register_page' => array(
413 'id' => 'register_page',
414 'name' => __( 'Register Page', 'userswp' ),
415 'desc' => __( 'This is the front end register page. This is where users create their account.', 'userswp' ),
416 'type' => 'select',
417 'options' => uwp_get_pages(),
418 'chosen' => true,
419 'placeholder' => __( 'Select a page', 'userswp' ),
420 'class' => 'uwp_label_block',
421 ),
422 'login_page' => array(
423 'id' => 'login_page',
424 'name' => __( 'Login Page', 'userswp' ),
425 'desc' => __( 'This is the front end login page. This is where users will login after creating their account.', 'userswp' ),
426 'type' => 'select',
427 'options' => uwp_get_pages(),
428 'chosen' => true,
429 'placeholder' => __( 'Select a page', 'userswp' ),
430 'class' => 'uwp_label_block',
431 ),
432 'account_page' => array(
433 'id' => 'account_page',
434 'name' => __( 'Account Page', 'userswp' ),
435 'desc' => __( 'This is the front end account page. This is where users can edit their account.', 'userswp' ),
436 'type' => 'select',
437 'options' => uwp_get_pages(),
438 'chosen' => true,
439 'placeholder' => __( 'Select a page', 'userswp' ),
440 'class' => 'uwp_label_block',
441 ),
442 'change_page' => array(
443 'id' => 'change_page',
444 'name' => __( 'Change Password Page', 'userswp' ),
445 'desc' => __( 'This is the front end Change Password page.', 'userswp' ),
446 'type' => 'select',
447 'options' => uwp_get_pages(),
448 'chosen' => true,
449 'placeholder' => __( 'Select a page', 'userswp' ),
450 'class' => 'uwp_label_block',
451 ),
452 'forgot_page' => array(
453 'id' => 'forgot_page',
454 'name' => __( 'Forgot Password Page', 'userswp' ),
455 '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' ),
456 'type' => 'select',
457 'options' => uwp_get_pages(),
458 'chosen' => true,
459 'placeholder' => __( 'Select a page', 'userswp' ),
460 'class' => 'uwp_label_block',
461 ),
462 'reset_page' => array(
463 'id' => 'reset_page',
464 'name' => __( 'Reset Password Page', 'userswp' ),
465 'desc' => __( 'This is the front end Reset Password page. This is the page where users can reset their password when they lose it.', 'userswp' ),
466 'type' => 'select',
467 'options' => uwp_get_pages(),
468 'chosen' => true,
469 'placeholder' => __( 'Select a page', 'userswp' ),
470 'class' => 'uwp_label_block',
471 ),
472 'users_page' => array(
473 'id' => 'users_page',
474 'name' => __( 'Users List Page', 'userswp' ),
475 'desc' => __( 'This is the front end Users List page. This is the page where all registered users of the websites are listed.', 'userswp' ),
476 'type' => 'select',
477 'options' => uwp_get_pages(),
478 'chosen' => true,
479 'placeholder' => __( 'Select a page', 'userswp' ),
480 'class' => 'uwp_label_block',
481 ),
482 'profile_no_of_items' => array(
483 'id' => 'profile_no_of_items',
484 'name' => __( 'Number of Items', 'userswp' ),
485 'type' => 'text',
486 'std' => '',
487 'desc' => __( 'Enter number of items to display in profile tabs.', 'userswp' ),
488 ),
489 )
490 ),
491 'register' => apply_filters( 'uwp_settings_general_register', uwp_settings_general_register_fields()),
492 'login' => apply_filters( 'uwp_settings_general_login', uwp_settings_general_loginout_fields()),
493 'profile' => apply_filters( 'uwp_settings_general_profile',
494 array(
495 'enable_profile_header' => array(
496 'id' => 'enable_profile_header',
497 'name' => __( 'Display Header in Profile', 'userswp' ),
498 'desc' => '',
499 'type' => 'checkbox',
500 'std' => '1',
501 'class' => 'uwp_label_inline',
502 ),
503 'profile_avatar_size' => array(
504 'id' => 'profile_avatar_size',
505 'name' => __( 'Profile Avatar max file size', 'userswp' ),
506 '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' ),
507 'type' => 'number',
508 'std' => '',
509 'size' => 'regular',
510 'placeholder' => __( 'Enter Profile Avatar max file size.', 'userswp' ),
511 ),
512 'profile_banner_size' => array(
513 'id' => 'profile_banner_size',
514 'name' => __( 'Profile Banner max file size', 'userswp' ),
515 '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' ),
516 'type' => 'number',
517 'std' => '',
518 'size' => 'regular',
519 'placeholder' => __( 'Enter Profile Banner max file size.', 'userswp' ),
520 ),
521 'profile_banner_width' => array(
522 'id' => 'profile_banner_width',
523 'name' => __( 'Profile banner width', 'userswp' ),
524 'desc' => '',
525 'type' => 'number',
526 'std' => '1000',
527 'size' => 'regular',
528 'placeholder' => __( 'Enter Profile banner width in Pixels', 'userswp' ),
529 ),
530 'enable_profile_body' => array(
531 'id' => 'enable_profile_body',
532 'name' => __( 'Display Body in Profile', 'userswp' ),
533 'desc' => '',
534 'type' => 'checkbox',
535 'std' => '1',
536 'class' => 'uwp_label_inline',
537 ),
538 'enable_profile_tabs' => array(
539 'id' => 'enable_profile_tabs',
540 'name' => __( 'Choose the tabs to display in Profile', 'userswp' ),
541 'desc' => __( 'Choose the tabs to display in UsersWP Profile', 'userswp' ),
542 'multiple' => true,
543 'chosen' => true,
544 'type' => 'select_order',
545 'options' => $this->uwp_available_tab_items(),
546 'placeholder' => __( 'Select Tabs', 'userswp' )
547 ),
548 )
549 ),
550 'users' => apply_filters( 'uwp_settings_general_profile',
551 array(
552 'users_default_layout' => array(
553 'id' => 'users_default_layout',
554 'name' => __( 'Users default layout', 'userswp' ),
555 'desc' => __( 'Choose the default layout for Users Page - Users List', 'userswp' ),
556 'type' => 'select',
557 'options' => $this->uwp_available_users_layout(),
558 'placeholder' => __( 'Select Layout', 'userswp' )
559 ),
560 )
561 ),
562 'change' => apply_filters( 'uwp_settings_general_change',
563 array(
564 'change_enable_old_password' => array(
565 'id' => 'change_enable_old_password',
566 'name' => __( 'Enabled Old Password?', 'userswp' ),
567 'desc' => 'This option adds an extra layer of security. User need to enter their old password before changing the password.',
568 'type' => 'checkbox',
569 'std' => '1',
570 'class' => 'uwp_label_inline',
571 ),
572 )
573 ),
574 'uninstall' => apply_filters( 'uwp_settings_general_uninstall',
575 array(
576 'uninstall_erase_data' => array(
577 'id' => 'uninstall_erase_data',
578 'name' => __( 'Remove Data on Uninstall?', 'userswp' ),
579 'desc' => '',
580 'type' => 'checkbox',
581 'std' => '1',
582 'class' => 'uwp_label_inline',
583 ),
584 )
585 ),
586 ),
587 'uwp_notifications' => array(
588 'main' => apply_filters( 'uwp_settings_notifications_main',
589 array(
590 'registration_activate_email_subject' => array(
591 'id' => 'registration_activate_email_subject',
592 'name' => __( 'Registration activate email', 'userswp' ),
593 'desc' => "",
594 'type' => 'text',
595 'size' => 'regular',
596 'placeholder' => __( 'Enter Registration activate email Subject', 'userswp' )
597 ),
598 'registration_activate_email_content' => array(
599 'id' => 'registration_activate_email_content',
600 'name' => "",
601 'desc' => "",
602 'type' => 'textarea',
603 'placeholder' => __( 'Enter Registration activate email Content', 'userswp' )
604 ),
605 'registration_success_email_subject' => array(
606 'id' => 'registration_success_email_subject',
607 'name' => __( 'Registration success email', 'userswp' ),
608 'desc' => "",
609 'type' => 'text',
610 'size' => 'regular',
611 'placeholder' => __( 'Enter Registration success email Subject', 'userswp' )
612 ),
613 'registration_success_email_content' => array(
614 'id' => 'registration_success_email_content',
615 'name' => "",
616 'desc' => "",
617 'type' => 'textarea',
618 'placeholder' => __( 'Enter Registration success email Content', 'userswp' )
619 ),
620 'forgot_password_email_subject' => array(
621 'id' => 'forgot_password_email_subject',
622 'name' => __( 'Forgot password email', 'userswp' ),
623 'desc' => "",
624 'type' => 'text',
625 'size' => 'regular',
626 'placeholder' => __( 'Enter forgot password email Subject', 'userswp' )
627 ),
628 'forgot_password_email_content' => array(
629 'id' => 'forgot_password_email_content',
630 'name' => "",
631 'desc' => "",
632 'type' => 'textarea',
633 'placeholder' => __( 'Enter forgot password email Content', 'userswp' )
634 ),
635 'reset_password_email_subject' => array(
636 'id' => 'reset_password_email_subject',
637 'name' => __( 'Reset password email', 'userswp' ),
638 'desc' => "",
639 'type' => 'text',
640 'size' => 'regular',
641 'placeholder' => __( 'Enter reset password email Subject', 'userswp' )
642 ),
643 'reset_password_email_content' => array(
644 'id' => 'reset_password_email_content',
645 'name' => "",
646 'desc' => "",
647 'type' => 'textarea',
648 'placeholder' => __( 'Enter reset password email Content', 'userswp' )
649 ),
650 'enable_account_update_notification' => array(
651 'id' => 'enable_account_update_notification',
652 'name' => __( 'Account update email', 'userswp' ),
653 'desc' => 'Enable account update notification',
654 'type' => 'checkbox',
655 'std' => '0',
656 'class' => 'uwp_label_inline',
657 ),
658 'account_update_email_subject' => array(
659 'id' => 'account_update_email_subject',
660 'name' => "",
661 'desc' => "",
662 'type' => 'text',
663 'size' => 'regular',
664 'placeholder' => __( 'Enter account update email Subject', 'userswp' )
665 ),
666 'account_update_email_content' => array(
667 'id' => 'account_update_email_content',
668 'name' => "",
669 'desc' => "",
670 'type' => 'textarea',
671 'placeholder' => __( 'Enter account update email Content', 'userswp' )
672 ),
673 )
674 ),
675 'admin' => apply_filters( 'uwp_settings_notifications_admin',
676 array(
677 'registration_success_email_subject_admin' => array(
678 'id' => 'registration_success_email_subject_admin',
679 'name' => __( 'New account registration', 'userswp' ),
680 'desc' => "",
681 'type' => 'text',
682 'std' => __( 'New account registration', 'userswp' ),
683 'size' => 'regular',
684 ),
685 'registration_success_email_content_admin' => array(
686 'id' => 'registration_success_email_content_admin',
687 'name' => "",
688 'desc' => "",
689 'type' => 'textarea',
690 'std' => __("A user has been registered recently on your website. [#extras#]", "userswp"),
691 ),
692 )
693 ),
694 ),
695 );
696
697 $uwp_settings = apply_filters( 'uwp_registered_settings', $uwp_settings );
698
699 return $uwp_settings;
700 }
701
702 public function uwp_get_settings() {
703
704 $settings = get_option( 'uwp_settings' );
705
706 if( empty( $settings ) ) {
707
708 // Update old settings with new single option
709
710 $general_settings = is_array( get_option( 'uwp_settings_general' ) ) ? get_option( 'uwp_settings_general' ) : array();
711 $ext_settings = is_array( get_option( 'uwp_settings_extensions' ) ) ? get_option( 'uwp_settings_extensions' ) : array();
712
713 $settings = array_merge( $general_settings, $ext_settings );
714
715 update_option( 'uwp_settings', $settings );
716
717 }
718 return apply_filters( 'uwp_get_settings', $settings );
719 }
720
721 public function uwp_settings_sanitize( $input = array() ) {
722 global $uwp_options;
723
724 if ( empty( $_POST['_wp_http_referer'] ) ) {
725 return $input;
726 }
727
728 $parsed_url = wp_parse_url($_POST['_wp_http_referer']);
729
730 if (!isset($parsed_url['query'])) {
731 return $input;
732 }
733 parse_str( $parsed_url['query'], $referrer );
734
735 $settings = $this->uwp_get_registered_settings();
736
737 $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'main';
738 $page = isset( $referrer['page'] ) ? $referrer['page'] : 'userswp';
739
740 $input = $input ? $input : array();
741 $input = apply_filters( 'uwp_settings_'.$page.'_' . $tab . '_sanitize', $input );
742
743 // Loop through each setting being saved and pass it through a sanitization filter
744 foreach ( $input as $key => $value ) {
745 // Get the setting type (checkbox, select, etc)
746 $type = isset( $settings[$page][$tab][$key]['type'] ) ? $settings[$page][$tab][$key]['type'] : false;
747
748 if ( $type ) {
749 // Field type specific filter
750 $input[$key] = apply_filters( 'uwp_settings_sanitize_' . $type, $value, $key );
751 }
752
753 // General filter
754 $input[$key] = apply_filters( 'uwp_settings_sanitize', $input[$key], $key );
755 }
756
757 // Loop through the whitelist and unset any that are empty for the tab being saved
758 if ( ! empty( $settings[$page][$tab] ) ) {
759 foreach ( $settings[$page][$tab] as $key => $value ) {
760
761 // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
762 if ( is_numeric( $key ) ) {
763 $key = $value['id'];
764 }
765
766 if ( empty( $input[$key] ) ) {
767 unset( $uwp_options[$key] );
768 }
769
770 }
771 }
772
773 // Merge our new settings with the existing
774 $output = array_merge( $uwp_options, $input );
775
776 flush_rewrite_rules();
777 add_settings_error( 'uwp-notices', '', __( 'Settings updated.', 'userswp' ), 'updated' );
778
779 return $output;
780 }
781
782 public function uwp_available_tab_items() {
783 $tabs_arr = array(
784 'more_info' => __( 'More Info', 'userswp' ),
785 'posts' => __( 'Posts', 'userswp' ),
786 'comments' => __( 'Comments', 'userswp' ),
787 );
788
789 $tabs_arr = apply_filters('uwp_available_tab_items', $tabs_arr);
790
791 return $tabs_arr;
792 }
793
794 public function uwp_available_users_layout() {
795 $tabs_arr = array(
796 'list' => __( 'List View', 'userswp' ),
797 '2col' => __( 'Grid View - 2 Column', 'userswp' ),
798 '3col' => __( 'Grid View - 3 Column', 'userswp' ),
799 '4col' => __( 'Grid View - 4 Column', 'userswp' ),
800 '5col' => __( 'Grid View - 5 Column', 'userswp' ),
801 );
802
803 $tabs_arr = apply_filters('uwp_available_users_layout', $tabs_arr);
804
805 return $tabs_arr;
806 }
807
808 }