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