PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.49
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.49
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 / functions.php

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

141 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 * Updates UsersWP setting value using key.
29 *
30 * @since 1.0.0
31 * @package userswp
32 *
33 * @param string|bool $key Setting Key.
34 * @param string $value Setting Value.
35 *
36 * @return bool Update success or not?.
37 */
38 function uwp_update_option( $key = false, $value = '' ) {
39
40 if ( ! $key ) {
41 return false;
42 }
43
44 $settings = get_option( 'uwp_settings', array() );
45
46 if ( ! is_array( $settings ) ) {
47 $settings = array();
48 }
49
50 $settings[ $key ] = $value;
51
52 $settings = apply_filters( 'uwp_update_option', $settings, $key, $value );
53 $settings = apply_filters( 'uwp_update_option_' . $key, $settings, $key, $value );
54
55 $updated = update_option( 'uwp_settings', $settings );
56
57 if ( $updated ) {
58 global $uwp_options;
59 $uwp_options[ $key ] = $value;
60 }
61
62 return $updated;
63 }
64
65 /**
66 * Deletes UsersWP setting value using key.
67 *
68 * @package userswp
69 *
70 * @param string|bool $key Setting Key.
71 *
72 * @return bool delete success or not?.
73 */
74 function uwp_delete_option( $key = '' ) {
75
76 if ( empty( $key ) ) {
77 return false;
78 }
79
80 $options = get_option( 'uwp_settings' );
81 if ( empty( $options ) ) {
82 $options = array();
83 }
84
85 if ( isset( $options[ $key ] ) ) {
86 unset( $options[ $key ] );
87 }
88
89 $updated = update_option( 'uwp_settings', $options );
90
91 if ( $updated ) {
92 global $uwp_options;
93 $uwp_options = $options;
94 }
95
96 return $updated;
97 }
98
99 /**
100 * Get UWP Settings.
101 *
102 * Retrieves all plugin settings.
103 *
104 * @return array UWP settings
105 */
106 function uwp_get_settings() {
107 $settings = get_option( 'uwp_settings' );
108
109 if ( empty( $settings ) ) {
110 // Update old settings with new single option.
111 $settings = array();
112
113 update_option( 'uwp_settings', $settings );
114 }
115
116 return apply_filters( 'uwp_get_settings', $settings );
117 }
118
119 function uwp_get_register_only_fields() {
120 $reg_only_fields = array( 'register_gdpr', 'register_tos', 'subscribe' );
121 return apply_filters( 'uwp_register_mandatory_fields', $reg_only_fields );
122 }
123
124
125 /**
126 * Get the advances setting toggle CSS class.
127 *
128 *
129 * @param string $default Default CSS class.
130 * @return string CSS class.
131 */
132 function uwp_advanced_toggle_class( $default = '' ) {
133 if ( uwp_get_option( 'admin_disable_advanced', false ) ) {
134 $class = '';
135 } else {
136 $class = $default ? $default : 'uwp-advanced-setting collapse in';
137 }
138
139 return $class;
140 }
141