PluginProbe ʕ •ᴥ•ʔ
Nextend Social Login and Register / 3.1.9
Nextend Social Login and Register v3.1.9
trunk 1.0 1.1 1.2 1.4 1.4.9 1.6.0 2.0.2 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.24 3.0.25 3.0.27 3.0.28 3.0.29 3.0.3 3.0.4 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.25 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9
nextend-facebook-connect / class-settings.php
nextend-facebook-connect Last commit date
NSL 3 years ago admin 3 years ago includes 3 years ago js 3 years ago languages 3 years ago providers 3 years ago template-parts 3 years ago class-settings.php 6 years ago compat.php 6 years ago index.html 13 years ago licence.txt 6 years ago nextend-facebook-connect.php 3 years ago nextend-social-login.php 3 years ago readme.txt 3 years ago widget.php 6 years ago
class-settings.php
93 lines
1 <?php
2
3 class NextendSocialLoginSettings {
4
5 protected $optionKey;
6
7 protected $settings = array(
8 'default' => array(),
9 'stored' => array(),
10 'final' => array()
11 );
12
13 /**
14 * NextendSocialLoginSettings constructor.
15 *
16 * @param $optionKey string
17 * @param $defaultSettings array
18 */
19 public function __construct($optionKey, $defaultSettings) {
20 $this->optionKey = $optionKey;
21
22 $this->settings['default'] = $defaultSettings;
23
24
25 $storedSettings = get_option($this->optionKey);
26 if ($storedSettings !== false) {
27 $storedSettings = (array)maybe_unserialize($storedSettings);
28 } else {
29 $storedSettings = array();
30 }
31
32 $this->settings['stored'] = array_merge($this->settings['default'], $storedSettings);
33
34 $this->settings['final'] = apply_filters('nsl_finalize_settings_' . $optionKey, $this->settings['stored']);
35 }
36
37 public function get($key, $storage = 'final') {
38 if (!isset($this->settings[$storage][$key])) {
39 return false;
40 }
41
42 return $this->settings[$storage][$key];
43 }
44
45 public function set($key, $value) {
46 $this->settings['stored'][$key] = $value;
47 $this->storeSettings();
48 }
49
50 public function getAll($storage = 'final') {
51 return $this->settings[$storage];
52 }
53
54 /**
55 * @param array $postedData
56 *
57 * @return bool
58 */
59 public function update($postedData) {
60 if (is_array($postedData)) {
61 $newData = array();
62 $newData = apply_filters('nsl_update_settings_validate_' . $this->optionKey, $newData, $postedData);
63
64 if (count($newData)) {
65
66 $isChanged = false;
67 foreach ($newData AS $key => $value) {
68 if ($this->settings['stored'][$key] != $value) {
69 $this->settings['stored'][$key] = $value;
70 $isChanged = true;
71 }
72 }
73
74 if ($isChanged) {
75 $allowedKeys = array_keys($this->settings['default']);
76 $this->settings['stored'] = array_intersect_key($this->settings['stored'], array_flip($allowedKeys));
77
78 $this->storeSettings();
79
80 return true;
81 }
82 }
83 }
84
85 return false;
86 }
87
88 protected function storeSettings() {
89 update_option($this->optionKey, maybe_serialize($this->settings['stored']));
90
91 $this->settings['final'] = apply_filters('nsl_finalize_settings_' . $this->optionKey, $this->settings['stored']);
92 }
93 }