PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 2.2.4
Wp Social Login and Register Social Counter v2.2.4
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 / share-settings.php
wp-social / app Last commit date
api-routes.php 5 years ago avatar.php 4 years ago counter-settings.php 5 years ago legacy.php 5 years ago login-settings.php 3 years ago providers.php 3 years ago route.php 4 years ago settings.php 5 years ago share-settings.php 4 years ago share.php 3 years ago
share-settings.php
233 lines
1 <?php
2
3 namespace WP_Social\App;
4
5 use WP_Social\Lib\Provider\Share_Factory;
6 use WP_Social\Traits\Singleton;
7
8 defined('ABSPATH') || exit;
9
10 class Share_Settings {
11
12 use Singleton;
13
14 const OK_GLOBAL = 'xs_share_global_setting_data';
15 const OK_STYLES = 'xs_style_setting_data_share';
16 const OK_PROVIDER = 'xs_share_providers_data';
17 const OK_PROVIDER_ENABLED = 'xs_providers_enabled_share';
18
19
20 private $global;
21 private $providers;
22 private $enabled;
23 private $styles;
24 private $def_share_style = 'style-1';
25
26 public function __construct() {
27
28 $this->global = get_option(self::OK_GLOBAL, []);
29 $this->enabled = get_option(self::OK_PROVIDER_ENABLED, []);
30 $this->providers = get_option(self::OK_PROVIDER, []);
31 $this->styles = get_option(self::OK_STYLES, []);
32 }
33
34
35 public function get_enabled_providers() {
36
37 if(empty($this->enabled)) {
38
39 return [];
40 }
41
42 $ret = [];
43
44 foreach($this->enabled as $key => $item) {
45
46 if(!empty($item['enable'])) {
47
48 $ret[$key] = $item;
49 }
50 }
51
52 return $ret;
53 }
54
55
56 public function update_enabled_providers($val) {
57
58 $this->enabled = $val;
59
60 update_option(self::OK_PROVIDER_ENABLED, $val, true);
61
62 return $this;
63 }
64
65
66 public function get_provider_settings() {
67
68 return $this->providers;
69 }
70
71
72 public function update_provider_settings($val) {
73
74 $this->providers = $val;
75
76 update_option(self::OK_PROVIDER, $val, true);
77
78 return $this;
79 }
80
81
82 public function get_horizontal_styles() {
83
84 return \WP_Social\Inc\Admin_Settings::$horizontal_style;
85 }
86
87
88 public function get_hover_styles() {
89
90 $hover_styles = [
91 'none-none' => [
92 'name' => 'None',
93 'class' => 'wslu-none',
94 ],
95 ];
96
97 return apply_filters('wp_social_pro/share/primary-content/hover-styles', $hover_styles);
98 }
99
100
101 public function get_selected_style() {
102
103 $set = $this->get_style_settings();
104
105 return empty($set['login_button_style']['main']) ? $this->def_share_style : $set['login_button_style']['main'];
106 }
107
108
109 public function get_selected_style_keys() {
110
111 $set = $this->get_style_settings();
112
113 $hover_key = 'none-none';
114 $vh_key = 'horizontal';
115 $def_key = 'style-1'.':'.$hover_key.':'.$vh_key;
116
117 return empty($set['main_content']['style']) ? $def_key : $set['main_content']['style'];
118 }
119
120
121 public function prepare_widget_class($styles) {
122
123 $hover_styles = $this->get_hover_styles();
124 $style_key = $this->get_selected_style_keys();
125 $bArr = explode(':', $style_key);
126
127 $style_cls = $bArr[0];
128 $hover_key = $bArr[1];
129 $vh_key = $bArr[2];
130 $display_cls = 'wslu-main_content';
131
132 $vh_styles = $this->get_horizontal_styles();
133 $font_cls = $this->get_theme_font_class();
134
135
136 return $styles[$style_cls]['class'] . ' ' .
137 $hover_styles[$hover_key]['class'] . ' ' .
138 $vh_styles[$vh_key]['class'] . ' ' .
139 $font_cls . ' ' .
140 $display_cls;
141 }
142
143
144 public function get_share_count($post, $enabled_providers) {
145
146 $share_counting = [];
147
148 if(is_object($post) && !empty($post->ID)) {
149
150 $url = get_permalink($post);
151
152 $factory = new Share_Factory($post->ID);
153
154 foreach($enabled_providers as $key => $conf) {
155
156 $obj = $factory->make($key);
157
158 $share_counting[$key]['count'] = $obj->set_uri_hash(Settings::get_hash($url))->get_url_share_count();
159 }
160 }
161
162 return $share_counting;
163 }
164
165
166 public function get_theme_font_class() {
167
168 return $this->is_theme_font_enabled() ? 'wslu-theme-font-yes' : 'wslu-theme-font-no';
169 }
170
171
172 public function get_old_count($key) {
173
174 return apply_filters('wp_social_pro/provider/share/old_count', 0, $key);
175 }
176
177
178 public function get_extra_data_class($selected_share_style, $all_style) {
179
180 return empty($all_style[$selected_share_style]['content']) ? 'wslu-no-extra-data' : 'wslu-extra-data';
181 }
182
183
184 public function get_style_settings() {
185
186 return $this->styles;
187 }
188
189
190 public function update_style_settings($val) {
191
192 $this->styles = $val;
193
194 update_option(self::OK_STYLES, $val, true);
195
196 return $this;
197 }
198
199
200 public function get_global_settings() {
201
202 return $this->global;
203 }
204
205
206 public function update_global_settings($val) {
207
208 $this->global = $val;
209
210 update_option(self::OK_GLOBAL, $val, true);
211
212 return $this;
213 }
214
215
216 public function is_theme_font_enabled() {
217
218 return !empty($this->global['show_font_from_theme']);
219 }
220
221
222 public function is_share_content_enabled() {
223
224 return empty($this->styles['login_content']) ? false : ($this->styles['login_content'] != 'no_content');
225 }
226
227
228 public function get_share_content_position() {
229
230 return empty($this->styles['login_content']) ? 'after_content' : ($this->styles['login_content']);
231 }
232 }
233