PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / trunk
Wp Social Login and Register Social Counter vtrunk
trunk 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.4 1.4.5 1.4.6 1.4.8 1.4.9 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.8 2.2.9 3.0.0 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0
wp-social / app / settings.php
wp-social / app Last commit date
api-routes.php 7 months ago avatar.php 4 years ago counter-settings.php 5 years ago legacy.php 5 years ago login-settings.php 2 months ago providers.php 7 months ago route.php 7 months ago settings.php 5 years ago share-settings.php 4 years ago share.php 3 years ago
settings.php
288 lines
1 <?php
2
3 namespace WP_Social\App;
4
5 defined('ABSPATH') || exit;
6
7 class Settings {
8
9 public static $ok_counter_cached_data = 'xs_counter_options';
10 public static $ok_global_counter_setting = 'xs_counter_global_setting_data';
11 public static $ok_counter_provider_setting = 'xs_counter_providers_data';
12 public static $ok_enabled_providers_counter = 'xs_providers_enabled_counter';
13 public static $ok_enabled_providers_login = 'xs_providers_enabled_login';
14 public static $ok_enabled_providers_share = 'xs_providers_enabled_share';
15 public static $ok_login_settings_data = 'xs_provider_data';
16
17 private static $instance;
18
19 private $enabled_providers_login;
20 private $enabled_providers_counter;
21 private $enabled_providers_share;
22 private $share_style_settings;
23 private $share_main_settings;
24 private $provider_settings_share;
25 private $provider_settings_counter;
26 private $provider_settings_login;
27
28
29 public static function instance() {
30 if(!self::$instance) {
31 self::$instance = new static();
32 }
33
34 return self::$instance;
35 }
36
37 /**
38 * todo - we will finish it later
39 *
40 */
41 public function load() {
42
43 $enabled_counters = get_option(Settings::$ok_enabled_providers_counter, []);
44
45 /**
46 * This is just for legacy support for future version
47 * After 3/4 version we can safely assumes all of our client has updated the plugin to at least this version
48 *
49 */
50 if(empty($enabled_counters)) {
51
52 $old_settings = get_option(self::$ok_counter_provider_setting, []);
53
54 if(!empty($old_settings['social'])) {
55
56 $tmp = [];
57
58 foreach($old_settings['social'] as $key => $info) {
59
60 $tmp[$key]['enable'] = empty($info['enable']) ? '' : 1;
61 }
62
63 update_option(Settings::$ok_enabled_providers_counter, $tmp);
64
65 $enabled_counters = $tmp;
66 }
67 }
68
69 $this->enabled_providers_counter = $enabled_counters;
70
71
72 return $this;
73 }
74
75 public function load_share_style_settings() {
76
77 if(empty($this->share_style_settings)) {
78
79 $this->share_style_settings = get_option('xs_style_setting_data_share', []);
80 }
81
82 return $this;
83 }
84
85 public function load_share_main_settings() {
86
87 if(empty($this->share_main_settings)) {
88
89 $this->share_main_settings = get_option('xs_share_global_setting_data', []);
90 }
91
92 return $this;
93 }
94
95 protected function load_enabled_providers_share() {
96
97 if(empty($this->enabled_providers_share)) {
98
99 $this->enabled_providers_share = self::get_enabled_provider_conf_share();
100 }
101
102 return $this;
103 }
104
105 public function get_enabled_providers_share() {
106
107 return $this->load_enabled_providers_share()->enabled_providers_share;
108 }
109
110 public function get_providers_settings_share() {
111
112 if(empty($this->provider_settings_share)) {
113
114 $this->provider_settings_share = get_option('xs_share_providers_data', []);
115 }
116
117 return $this->provider_settings_share;
118 }
119
120 public function get_providers_settings_counter() {
121
122 if(empty($this->provider_settings_share)) {
123
124 }
125
126 return $this->provider_settings_share;
127 }
128
129 public function get_providers_settings_login() {
130
131 if(empty($this->provider_settings_share)) {
132
133 }
134
135 return $this->provider_settings_share;
136 }
137
138
139 public function get_share_style_settings() {
140
141 return $this->load_share_style_settings()->share_style_settings;
142 }
143
144 public function get_share_main_settings() {
145
146 return $this->load_share_main_settings()->share_main_settings;
147 }
148
149 /**
150 * Alias of get_providers_settings_share
151 *
152 * @return mixed
153 */
154 public function get_share_provider_settings() {
155
156 return $this->get_providers_settings_share();
157 }
158
159 public function update_share_provider_settings($val) {
160
161 update_option('xs_share_providers_data', $val, true);
162
163 $this->provider_settings_share = $val;
164
165 return $this;
166 }
167
168
169 public function is_instagram_counter_enabled() {
170
171 return !empty($this->enabled_providers_counter['instagram']['enable']);
172 }
173
174
175 /**
176 * Return caching time in seconds as set in global counter settings
177 *
178 * @return int
179 */
180 public static function get_counter_cache_time() {
181
182 $opt = get_option(self::$ok_global_counter_setting, []);
183
184 return empty($opt['global']['cache']) ? 12 * 3600 : intval(floatval($opt['global']['cache']) * 3600);
185 }
186
187
188 public static function get_counter_provider_settings() {
189
190 $opt = get_option(self::$ok_counter_provider_setting, []);
191
192 return empty($opt['social']) ? [] : $opt['social'];
193 }
194
195 public static function get_counter_provider_conf() {
196
197 $opt = get_option(self::$ok_counter_provider_setting, []);
198
199 return $opt;
200 }
201
202 public static function update_counter_provider_conf($val) {
203
204 return update_option(self::$ok_counter_provider_setting, $val);
205 }
206
207
208 public static function get_enabled_provider_conf_counter() {
209
210 $opt = get_option(self::$ok_enabled_providers_counter, []);
211
212 return $opt;
213 }
214
215 public static function update_enabled_provider_conf_counter($val) {
216
217 return update_option(self::$ok_enabled_providers_counter, $val);
218 }
219
220 public static function get_enabled_provider_conf_login() {
221
222 $opt = get_option(self::$ok_enabled_providers_login, []);
223
224 return $opt;
225 }
226
227 public static function update_enabled_provider_conf_login($val) {
228
229 return update_option(self::$ok_enabled_providers_login, $val);
230 }
231
232 public static function get_enabled_provider_conf_share() {
233
234 $opt = get_option(self::$ok_enabled_providers_share, []);
235
236 return $opt;
237 }
238
239 public static function update_enabled_provider_conf_share($val) {
240
241 return update_option(self::$ok_enabled_providers_share, $val);
242 }
243
244 public static function get_counter_cached_data() {
245
246 $opt = get_option(self::$ok_counter_cached_data, []);
247
248 return empty($opt['data']) ? [] : $opt['data'];
249 }
250
251 public static function get_login_settings_data() {
252
253 return get_option(self::$ok_login_settings_data, []);
254 }
255
256 public static function has_number_content_in_selected_style($selected_share_style, $all_style) {
257
258 return !empty($all_style[$selected_share_style]['content']['number']);
259 }
260
261 public static function has_text_content_in_selected_style($selected_share_style, $all_style) {
262
263 return !empty($all_style[$selected_share_style]['content']['text']);
264 }
265
266 public static function has_label_content_in_selected_style($selected_share_style, $all_style) {
267
268 return !empty($all_style[$selected_share_style]['content']['label']);
269 }
270
271
272 public static function get_extra_data_class($selected_share_style, $all_style) {
273
274 return empty($all_style[$selected_share_style]['content']) ? 'wslu-no-extra-data' : 'wslu-extra-data';
275 }
276
277
278 public static function get_hash($url = '') {
279
280 return md5($url);
281 }
282
283 public static function get_old_count($key) {
284
285 return apply_filters('wp_social_pro/provider/share/old_count', 0, $key);
286 }
287 }
288