PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 1.8.2
Wp Social Login and Register Social Counter v1.8.2
3.2.1 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 / inc / share.php
wp-social / inc Last commit date
elementor 4 years ago admin-create-shortcode.php 7 years ago admin-create-user.php 4 years ago admin-custom-function.php 4 years ago admin-rest-api.php 4 years ago admin-settings.php 4 years ago admin-social-button.php 4 years ago admin-social-enque-script.php 5 years ago counter-widget.php 4 years ago counter.php 4 years ago custom-function.php 4 years ago login-widget.php 4 years ago login.php 5 years ago share-widget.php 4 years ago share.php 4 years ago
share.php
474 lines
1 <?php
2
3 namespace WP_Social\Inc;
4
5 use WP_Social\App\Providers;
6 use WP_Social\App\Settings;
7 use WP_Social\App\Share_Settings;
8 use WP_Social\Lib\Provider\Share_Factory;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Class Name : Share;
14 * Class Details : this class for showing login button in login and register page for wp, woocommerce, buddyPress and others
15 *
16 * @params : void
17 * @return : void
18 *
19 * @since : 1.0
20 */
21 class Share {
22
23 private $app_key = ['c5752d2f90b7c95dd6fcf1ffc82a8fbb68d8c9e8', '1934f519a63e142e0d3c893e59cc37fe0172e98a'];
24 private $api_url = 'https://api.sharedcount.com/v1.0/?url=%s&apikey=%s';
25
26 public function __construct($load = true) {
27
28 if($load) {
29 //add_filter( 'plugin_row_meta', array( $this, 'xs_plugin_row_meta' ), 10, 2 );
30
31 add_shortcode('xs_social_share', [$this, 'social_share_shortcode']);
32
33 add_action('the_content', [$this, 'share_the_body_content']);
34 //add_action('wp_body_open', [ $this, 'share_the_body_content_body' ] );
35
36 add_action('wp_footer', [$this, 'share_the_body_content_body']);
37 }
38 }
39
40 /*
41 body and content
42 */
43 public function share_the_body_content($content = '') {
44
45 if(Share_Settings::instance()->is_share_content_enabled()) {
46
47 $position = Share_Settings::instance()->get_share_content_position();
48
49 /*
50 check indiviaual social share style positon
51 */
52 Global $post;
53 $page_position = get_post_custom( $post->ID );
54 if( isset($page_position['social_share_style'][0]) ){
55 $inner_position = $page_position['social_share_style'][0];
56 if( $inner_position !== 'global'){
57 $position = $inner_position;
58 }
59 }
60
61
62 $get_content = $this->get_share_data('all', ['class' => $position]);
63
64 if($position == 'after_content') {
65
66 return $content . $get_content;
67 }
68
69 if($position == 'before_content') {
70
71 return $get_content . $content;
72 }
73
74 if($position == 'both_content'){
75 return $get_content . $content . $get_content;
76 }
77 }
78
79 return $content;
80 }
81
82
83 /**
84 * This will give the html for fixed share
85 *
86 * @author UnKnown
87 *
88 */
89 public function share_the_body_content_body() {
90
91 $style = get_option('xs_style_setting_data_share', '');
92 $content_position = isset($style['login_button_content']) ? $style['login_button_content'] : '';
93
94 if(in_array($content_position, ['left_content', 'right_content', 'top_content', 'bottom_content'])) {
95
96 // set default type fixed_display for body
97 echo $this->get_share_data('all', ['class' => $content_position, 'type' => 'fixed_display']);
98 }
99 }
100
101
102 public function social_share_action($post_url = '', $id_post = 0) {
103
104
105 $option_key = 'xs_share_providers_data';
106 $xsc_options = get_option($option_key) ? get_option($option_key) : [];
107 $share_provider = isset($xsc_options['social']) ? $xsc_options['social'] : '';
108
109 if(empty($post_url) || $id_post == 0) {
110 return '';
111 }
112 $cache = 12;
113
114 $api_key_set = 'c5752d2f90b7c95dd6fcf1ffc82a8fbb68d8c9e8';
115
116 $get_transient = get_transient('xs_share_data__' . $id_post);
117 $get_transient_time = get_transient('timeout_xs_share_data__' . $id_post);
118
119 $prev_data = get_post_meta($id_post, 'xs_share_data__', true) ? get_post_meta($id_post, 'xs_share_data__', true) : [];
120
121
122 if($get_transient_time > time()) {
123 return '';
124 }
125
126 $url = sprintf($this->api_url, $post_url, $api_key_set);
127
128 $get_request = wp_remote_get($url, []);
129 $request = wp_remote_retrieve_body($get_request);
130 $api_call = @json_decode($request, true);
131
132 $return = [];
133 $xsc_transient = [];
134
135 if(is_array($share_provider) && sizeof($share_provider) > 0) :
136 foreach($share_provider as $k => $v) :
137 if(isset($v['enable'])) {
138 $before_data = isset($prev_data[$k]) ? $prev_data[$k] : 0;
139 if(!empty($get_transient[$k])) {
140 $result = $get_transient[$k];
141 } else {
142 if($k == 'facebook') {
143 $result = isset($api_call['Facebook']['share_count']) ? $api_call['Facebook']['share_count'] : $before_data;
144 } else {
145 if($k == 'pinterest') {
146 $result = isset($api_call['Pinterest']) ? $api_call['Pinterest'] : $before_data;
147 } else {
148 if($k == 'linkedin') {
149 $result = isset($api_call['LinkedIn']) ? $api_call['LinkedIn'] : $before_data;
150 } else {
151 if($k == 'stumbleUpon') {
152 $result = isset($api_call['StumbleUpon']) ? $api_call['StumbleUpon'] : $before_data;
153 } else {
154 $result = 0;
155 }
156 }
157 }
158 }
159 }
160 $return[$k] = $result;
161 $xsc_transient[$k] = $result;
162 }
163 endforeach;
164 endif;
165
166 update_post_meta($id_post, 'xs_share_data__', $return);
167
168 set_transient('xs_share_data__' . $id_post, $xsc_transient, $cache * 60 * 60);
169 }
170
171
172 /**
173 * Return Content for shortCode
174 *
175 * @author UnKnown
176 *
177 * @param $atts
178 * @param null $content
179 *
180 * @return string
181 */
182 public function social_share_shortcode($atts, $content = null) {
183
184 $atts = shortcode_atts(
185 array(
186 'provider' => 'all',
187 'class' => '',
188 'style' => '',
189 'hover' => '',
190 'layout' => 'horizontal',
191 'count' => 'No',
192 'box_only' => '',
193 ),
194 $atts,
195 'xs_social_share'
196 );
197
198 if(empty(trim($atts['provider'])) || $atts['provider'] == 'all') {
199 $provider = 'all';
200 } else {
201 $provider = explode(',', strtolower($atts['provider']));
202 }
203
204 $config = [];
205 $config['class'] = trim($atts['class']);
206 $config['style'] = trim($atts['style']);
207 $config['hover'] = trim($atts['hover']);
208 $config['hv_effect'] = trim($atts['layout']);
209 $config['show_count'] = ucfirst(strtolower(trim($atts['count'])));
210 $config['show_count'] = in_array($config['show_count'], ['Yes', 'No']) ? $config['show_count'] : 'No';
211 $config['conf_type'] = 'shortCode';
212
213 return $this->get_share_data($provider, $config);
214 }
215
216
217 /**
218 *
219 * @author UnKnown
220 * @modifiedBy Md. Atiqur Rahman <atiqur.su@gmail.com>
221 *
222 * @param string $provider
223 * @param array $config
224 *
225 * @return string
226 */
227 public function get_share_data($provider = 'all', $config = []) {
228
229 global $post;
230
231 $postId = isset($post->ID) ? $post->ID : 0;
232
233
234 $thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($postId), 'full');
235 $custom_logo_id = get_theme_mod('custom_logo');
236 $image = wp_get_attachment_image_src($custom_logo_id, 'full');
237 $customLogo = isset($image[0]) ? $image[0] : '';
238 $media = isset($thumbnail_src[0]) ? $thumbnail_src[0] : $customLogo;
239 $app_id = '';
240 $details = '';
241 $author = 'xpeedstudio';
242 $title = get_the_title($postId);
243 $source = get_bloginfo();
244
245
246 $config['conf_type'] = empty($config['conf_type']) ? 'content_body' : $config['conf_type'];
247
248
249 $core_provider = Providers::get_core_providers_share();
250 $provider = ($provider == 'all') ? array_keys($core_provider) : $provider;
251
252
253 $themeFontClass = Share_Settings::instance()->is_theme_font_enabled() ? 'wslu-theme-font-yes' : 'wslu-theme-font-no';
254 $customClass = empty($config['class']) ? '' : $config['class'];
255
256 $saved_style_settings = Settings::instance()->get_share_style_settings();
257 //$saved_global_settings = Settings::instance()->get_share_main_settings();
258 //$saved_provider_settings = Settings::instance()->get_share_provider_settings();
259
260
261 $styles = \WP_Social\Inc\Admin_Settings::share_styles();
262 $hvStyles = \WP_Social\Inc\Admin_Settings::$horizontal_style;
263
264 $hoverStyles = [
265 'none-none' => [
266 'name' => 'None',
267 'class' => 'wslu-none',
268 ],
269 ];
270
271 if(did_action('wslu_social_pro/plugin_loaded') && class_exists('\WP_Social_Pro\Inc\Admin_Settings')) {
272
273 $hoverStyles = \WP_Social_Pro\Inc\Admin_Settings::$share_hover_effects;
274 }
275
276 //defaults values
277 $showCountMarkup = false;
278 $shareStyleKey = 'style-1';
279 $shareHoverKey = 'none-none';
280 $vhEffectKey = 'horizontal';
281 $fixedWidget_style = 'main_content';
282 $displayCls = 'wslu-fixed_display';
283
284
285 if($config['conf_type'] == 'widget') {
286
287 #content for widget.....
288 #from widget we always hiding total markup
289 #always main style........................
290
291 if(isset($config['show_count']) && $config['show_count'] === 'yes') {
292 $showCountMarkup = true;
293 }else {
294 $showCountMarkup = false;
295 }
296 $fixed_display = 'main_content';
297 $displayCls = 'wslu-main_content';
298
299 $shareStyleKey = empty($config['style']) ? $shareStyleKey : $config['style']; //after resetting the plugin style-1 will be assigned
300 $shareHoverKey = empty($config['hover']) ? $shareHoverKey : $config['hover'];
301 $vhEffectKey = empty($config['hv_effect']) ? $vhEffectKey : $config['hv_effect'];
302
303 $mainStyleCls = isset($styles[$shareStyleKey]['class']) ? 'wslu-' . $shareStyleKey . ' ' . $styles[$shareStyleKey]['class'] : '';
304 $hoverEffect = empty($hoverStyles[$shareHoverKey]) ? $hoverStyles['none-none']['class'] : $hoverStyles[$shareHoverKey]['class'];
305 $vhClass = $hvStyles[$vhEffectKey]['class'];
306
307 $widget_style = $mainStyleCls . ' ' . $hoverEffect . ' ' . $vhClass . ' ' . $themeFontClass . ' ' . $displayCls;
308
309 } elseif($config['conf_type'] == 'shortCode') {
310
311 $fixed_display = 'main_content';
312 $displayCls = 'wslu-main_content';
313
314 #here always be the main display settings......
315 $shareStyleKeys = empty($saved_style_settings['main_content']['style']) ?
316 $shareStyleKey . ':' . $shareHoverKey . ':' . $vhEffectKey : $saved_style_settings['main_content']['style'];
317
318 $bArr = explode(':', $shareStyleKeys);
319
320 #Overridden by short-code attribute
321 $shareStyleKey = empty($config['style']) ? $bArr[0] : $config['style'];
322 $shareHoverKey = empty($config['hover']) ? $bArr[1] : $config['hover'];
323 $vhEffectKey = empty($config['hv_effect']) ? $bArr[2] : $config['hv_effect'];
324
325 $mainStyleCls = isset($styles[$shareStyleKey]['class']) ? 'wslu-' . $shareStyleKey . ' ' . $styles[$shareStyleKey]['class'] : '';
326 $hoverEffect = empty($hoverStyles[$shareHoverKey]) ? $hoverStyles['none-none']['class'] : $hoverStyles[$shareHoverKey]['class'];
327 $vhClass = empty($hvStyles[$vhEffectKey]) ? $hvStyles['horizontal']['class'] : $hvStyles[$vhEffectKey]['class'];
328
329 $widget_style = $mainStyleCls . ' ' . $hoverEffect . ' ' . $vhClass . ' ' . $themeFontClass . ' ' . $displayCls;
330
331 $showCountMarkup = $config['show_count'] == 'Yes';
332
333 } else {
334
335 //for appending/prepending to main content
336
337 $fixed_display = isset($config['type']) ? $config['type'] : 'main_content';
338
339 if($fixed_display == 'fixed_display') {
340
341 $shareStyleKey = 'style-1'; //defaults values
342 $shareHoverKey = 'none-none';
343 $vhEffectKey = 'vertical';
344 $displayCls = 'wslu-fixed_display';
345
346 $shareStyleKeys = empty($saved_style_settings['fixed_display']['style']) ?
347 $shareStyleKey . ':' . $shareHoverKey . ':' . $vhEffectKey : $saved_style_settings['fixed_display']['style'];
348
349 $bArr = explode(':', $shareStyleKeys);
350
351 $shareStyleKey = $bArr[0];
352 $shareHoverKey = $bArr[1];
353 $vhEffectKey = $bArr[2];
354
355 $mainStyleCls = isset($styles[$shareStyleKey]['class']) ? 'wslu-' . $shareStyleKey . ' ' . $styles[$shareStyleKey]['class'] : '';
356 $hoverEffect = empty($hoverStyles[$shareHoverKey]) ? $hoverStyles['none-none']['class'] : $hoverStyles[$shareHoverKey]['class'];
357 $vhClass = $hvStyles[$vhEffectKey]['class'];
358
359 $widget_style = $mainStyleCls . ' ' . $hoverEffect . ' ' . $vhClass . ' ' . $themeFontClass . ' ' . $displayCls;
360
361
362 $showFixedDisplaySC = empty($config['fixed_share_count']) ?
363 (empty($saved_style_settings['fixed_display']['show_social_count_share']) ? '0' :
364 $saved_style_settings['fixed_display']['show_social_count_share']) :
365 $config['fixed_share_count'];
366
367 $showCountMarkup = $showFixedDisplaySC == '1';
368
369 } else {
370
371 $shareStyleKeys = empty($saved_style_settings['main_content']['style']) ?
372 $shareStyleKey . ':' . $shareHoverKey . ':' . $vhEffectKey :
373 $saved_style_settings['main_content']['style'];
374
375 $bArr = explode(':', $shareStyleKeys);
376
377 $shareStyleKey = $bArr[0];
378 $shareHoverKey = $bArr[1];
379 $vhEffectKey = $bArr[2];
380 $displayCls = 'wslu-main_content';
381
382 $mainStyleCls = isset($styles[$shareStyleKey]['class']) ? 'wslu-' . $shareStyleKey . ' ' . $styles[$shareStyleKey]['class'] : '';
383 $hoverEffect = empty($hoverStyles[$shareHoverKey]) ? $hoverStyles['none-none']['class'] : $hoverStyles[$shareHoverKey]['class'];
384 $vhClass = $hvStyles[$vhEffectKey]['class'];
385
386 $widget_style = $mainStyleCls . ' ' . $hoverEffect . ' ' . $vhClass . ' ' . $themeFontClass . ' ' . $displayCls;
387
388 $showMainDisplaySC = empty($config['main_share_count']) ?
389 (empty($saved_style_settings['main_content']['show_social_count_share']) ? '0' :
390 $saved_style_settings['main_content']['show_social_count_share']) :
391 $config['main_share_count'];
392
393 $showCountMarkup = $showMainDisplaySC == '1';
394 }
395 }
396
397
398 $enabled_providers = Settings::instance()->get_enabled_providers_share();
399 $share_counting = [];
400
401 $currentUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
402
403 $share_counting = Share_Settings::instance()->get_share_count($post, $enabled_providers);
404
405
406 $totalSCount = 0;
407
408 if($showCountMarkup) {
409
410 foreach($enabled_providers as $key => $arr) {
411 if(!empty($arr['enable'])) {
412 $totalSCount += $share_counting[$key]['count'];
413 }
414 }
415 }
416
417
418 if(!empty($post->post_excerpt)) {
419
420 $details = $post->post_excerpt;
421 }
422
423
424 ob_start();
425 require(WSLU_LOGIN_PLUGIN . '/template/share/share-html.php');
426 $counter = ob_get_contents();
427 ob_end_clean();
428
429 return $counter;
430 }
431
432
433 /**
434 * This function should be replace with Providers::get_core_providers_share() methods for all places
435 *
436 */
437 public function social_share_link() {
438
439 $link = [];
440 $link['facebook'] = ['label' => 'Facebook', 'url' => 'http://www.facebook.com/sharer.php', 'params' => ['u' => '[%url%]', 't' => '[%title%]', 'v' => 3]];
441 $link['twitter'] = ['label' => 'Twitter', 'url' => 'https://twitter.com/intent/tweet', 'params' => ['text' => '[%title%] [%url%]', 'original_referer' => '[%url%]', 'related' => '[%author%]']];
442 $link['linkedin'] = ['label' => 'LinkedIn', 'url' => 'https://www.linkedin.com/shareArticle', 'params' => ['url' => '[%url%]', 'title' => '[%title%]', 'summary' => '[%details%]', 'source' => '[%source%]', 'mini' => true]];
443 $link['pinterest'] = ['label' => 'Pinterest', 'url' => 'https://pinterest.com/pin/create/button/', 'params' => ['url' => '[%url%]', 'media' => '[%media%]', 'description' => '[%details%]']];
444 $link['facebook-messenger'] = ['label' => 'Facebook Messenger', 'url' => 'https://www.facebook.com/dialog/send', 'params' => ['link' => '[%url%]', 'redirect_uri' => '[%url%]', 'display' => 'popup', 'app_id' => '[%app_id%]']];
445 $link['kik'] = ['label' => 'Kik', 'url' => 'https://www.kik.com/send/article/', 'params' => ['url' => '[%url%]', 'text' => '[%details%]', 'title' => '[%title%]']];
446 $link['skype'] = ['label' => 'Skype', 'url' => 'https://web.skype.com/share', 'params' => ['url' => '[%url%]']];
447 $link['trello'] = ['label' => 'Trello', 'url' => 'https://trello.com/add-card', 'params' => ['url' => '[%url%]', 'name' => '[%title%]', 'desc' => '[%details%]', 'mode' => 'popup']];
448 $link['viber'] = ['label' => 'Viber', 'url' => 'viber://forward', 'params' => ['text' => '[%title%] [%url%]']];
449 $link['whatsapp'] = ['label' => 'WhatsApp', 'url' => 'whatsapp://send', 'params' => ['text' => '[%title%] [%url%]']];
450 $link['telegram'] = ['label' => 'Telegram', 'url' => 'https://telegram.me/share/url', 'params' => ['url' => '[%url%]', 'text' => '[%title%]']];
451 $link['email'] = ['label' => 'Email', 'url' => 'mailto:', 'params' => ['body' => 'Title: [%title%] \n\n URL: [%url%]', 'subject' => '[%title%]']];
452 $link['reddit'] = ['label' => 'Reddit', 'url' => 'http://reddit.com/submit', 'params' => ['url' => '[%url%]', 'title' => '[%title%]']];
453 $link['digg'] = ['label' => 'Digg', 'url' => 'http://digg.com/submit', 'params' => ['url' => '[%url%]', 'title' => '[%title%]', 'phase' => 2]];
454 $link['stumbleupon'] = ['label' => 'StumbleUpon', 'url' => 'http://www.stumbleupon.com/submit', 'params' => ['url' => '[%url%]', 'title' => '[%title%]']];
455
456 return $link;
457 }
458
459
460 public function xs_plugin_row_meta($links, $file) {
461 if(strpos($file, 'wp-social.php') !== false) {
462 $new_links = array(
463 'demo' => '<a href="#" target="_blank"><span class="dashicons dashicons-welcome-view-site"></span>Live Demo</a>',
464 'doc' => '<a href="#" target="_blank"><span class="dashicons dashicons-media-document"></span>User Guideline</a>',
465 'support' => '<a href="https://help.wpmet.com/" target="_blank"><span class="dashicons dashicons-admin-users"></span>Support</a>',
466 'pro' => '<a href="#" target="_blank"><span class="dashicons dashicons-cart"></span>Premium version</a>',
467 );
468 $links = array_merge($links, $new_links);
469 }
470
471 return $links;
472 }
473 }
474