PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.27
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.27
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 1.0.22 All 173 releases
userswp / admin / settings / functions.php

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

142 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Gets UsersWP setting value using key.
4 *
5 * @since 1.0.0
6 * @package userswp
7 *
8 * @param string $key Setting Key.
9 * @param bool|string $default Default value.
10 * @param bool $cache Use cache to retrieve the value?.
11 *
12 * @return string Setting Value.
13 */
14 function uwp_get_option( $key = '', $default = false, $cache = true ) {
15
16 if ($cache) {
17 global $uwp_options;
18 } else {
19 $uwp_options = get_option( 'uwp_settings' );
20 }
21
22 $value = isset( $uwp_options[ $key ] ) ? $uwp_options[ $key ] : $default;
23 $value = apply_filters( 'uwp_get_option', $value, $key, $default );
24 return apply_filters( 'uwp_get_option_' . $key, $value, $key, $default );
25
26 }
27
28 /**
29 * Updates UsersWP setting value using key.
30 *
31 * @since 1.0.0
32 * @package userswp
33 *
34 * @param string|bool $key Setting Key.
35 * @param string $value Setting Value.
36 *
37 * @return bool Update success or not?.
38 */
39 function uwp_update_option( $key = false, $value = '') {
40
41 if (!$key ) {
42 return false;
43 }
44
45 $settings = get_option( 'uwp_settings', array());
46
47 if( !is_array( $settings ) ) {
48 $settings = array();
49 }
50
51 $settings[ $key ] = $value;
52
53 $settings = apply_filters( 'uwp_update_option', $settings, $key, $value );
54 $settings = apply_filters( 'uwp_update_option_' . $key, $settings, $key, $value );
55
56 $updated = update_option( 'uwp_settings', $settings );
57
58 if ( $updated ) {
59 global $uwp_options;
60 $uwp_options[ $key ] = $value;
61 }
62
63 return $updated;
64
65 }
66
67 /**
68 * Deletes UsersWP setting value using key.
69 *
70 * @package userswp
71 *
72 * @param string|bool $key Setting Key.
73 *
74 * @return bool delete success or not?.
75 */
76 function uwp_delete_option( $key = '' ) {
77
78 if ( empty( $key ) ) {
79 return false;
80 }
81
82 $options = get_option( 'uwp_settings' );
83 if ( empty( $options ) ) {
84 $options = array();
85 }
86
87 if ( isset( $options[ $key ] ) ) {
88 unset( $options[ $key ] );
89 }
90
91 $updated = update_option( 'uwp_settings', $options );
92
93 if ( $updated ) {
94 global $uwp_options;
95 $uwp_options = $options;
96 }
97
98 return $updated;
99 }
100
101 /**
102 * Get UWP Settings.
103 *
104 * Retrieves all plugin settings.
105 *
106 * @return array UWP settings
107 */
108 function uwp_get_settings() {
109 $settings = get_option( 'uwp_settings' );
110
111 if ( empty( $settings ) ) {
112 // Update old settings with new single option.
113 $settings = array();
114
115 update_option( 'uwp_settings', $settings );
116 }
117
118 return apply_filters( 'uwp_get_settings', $settings );
119 }
120
121 function uwp_get_register_only_fields(){
122 $reg_only_fields = array('username', 'register_gdpr', 'register_tos', 'subscribe');
123 return apply_filters('uwp_register_mandatory_fields', $reg_only_fields);
124 }
125
126
127 /**
128 * Get the advances setting toggle CSS class.
129 *
130 *
131 * @param string $default Default CSS class.
132 * @return string CSS class.
133 */
134 function uwp_advanced_toggle_class( $default = '' ) {
135 if ( uwp_get_option( 'admin_disable_advanced', false ) ) {
136 $class = '';
137 } else {
138 $class = $default ? $default : 'uwp-advanced-setting collapse in';
139 }
140
141 return $class;
142 }