Simple Social Media Share Buttons – Social Sharing for Everyone - Version 2.0.8

Version Description

  • Relaunched with a whole set of NEW FEATURES and Improvement. Please upgrade immediately and provide your feedback. highly recommended. Apologies in advance, if anything breaks!

=

Download this release

Release Info

Developer hiddenpearls
Plugin Icon 128x128 Simple Social Media Share Buttons – Social Sharing for Everyone
Version 2.0.8
Comparing to
See all releases

Code changes from version 2.0.7 to 2.0.8

assets/css/front.css CHANGED
@@ -2388,7 +2388,7 @@ div[class*="simplesocialbuttons-float"].simplesocial-simple-round button[class*
2388
  .ssb_inline-share_heading.right{
2389
  text-align: right;
2390
  }
2391
- @media screen and (max-width: 767px) {
2392
  .simplesocialbuttons-mobile-hidden{
2393
  display: none !important;
2394
  }
2388
  .ssb_inline-share_heading.right{
2389
  text-align: right;
2390
  }
2391
+ @media screen and (max-width: 768px) {
2392
  .simplesocialbuttons-mobile-hidden{
2393
  display: none !important;
2394
  }
classes/ssb-widget.php CHANGED
@@ -1,482 +1,482 @@
1
- <?php
2
-
3
- /**
4
- * Widget class for social share follower widget
5
- *
6
- * @sicne 2.0.2
7
- *
8
- * Class Ssb_Follower_Widget
9
- */
10
- class Ssb_Follower_Widget extends WP_Widget {
11
-
12
- /**
13
- * Google console api key for google+ and youtube api for getting follower and subscriber
14
- * @var string
15
- */
16
- private $api_key = 'AIzaSyBkQDWiRWxWKUoavuajUSAs28ld0Pdx8a4';
17
-
18
- /**
19
- * Transient Time
20
- *
21
- * 43200 = 12 Hours
22
- */
23
- private $cache_time = 43200;
24
-
25
- /**
26
- * Register ssb widget with WordPress.
27
- *
28
- * @since 2.0.2
29
- */
30
- function __construct() {
31
- $widget_ops = array(
32
- 'description' => 'Display Follow Button For your site',
33
- );
34
- parent::__construct( 'ssb_widget', 'Social Follow Widget', $widget_ops );
35
-
36
- }
37
-
38
- /**
39
- * Front-end display of widget.
40
- *
41
- * @see WP_Widget::widget()
42
- *
43
- * @param array $args Widget arguments.
44
- * @param array $instance Saved values from database.
45
- */
46
- function widget( $args, $instance ) {
47
- extract( $args );
48
- $display = '1';
49
-
50
- $widget_title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance );
51
-
52
- $show_facebook = $instance['show_facebook'];
53
- $show_twitter = $instance['show_twitter'];
54
- $show_google_plus = $instance['show_google_plus'];
55
- $show_youtube = $instance['show_youtube'];
56
- $show_pinterest = $instance['show_pinterest'];
57
-
58
- $facebook_id = $instance['facebook_id'];
59
- $facebook_show_counter = $instance['facebook_show_counter'];
60
- $facebook_text = $instance['facebook_text'];
61
- $facebook_access_token = $instance['facebook_access_token'];
62
-
63
- $twitter_id = $instance['twitter'];
64
- $twitter_show_counter = $instance['twitter_show_counter'];
65
- $twitter_text = $instance['twitter_text'];
66
- $twitter_api_key = $instance['twitter_api_key'];
67
- $twitter_secret_key = $instance['twitter_secret_key'];
68
-
69
- $google_id = $instance['google'];
70
- $google_show_counter = $instance['google_show_counter'];
71
- $google_text = $instance['google_text'];
72
-
73
- $youtube_id = $instance['youtube'];
74
- $youtube_show_counter = $instance['youtube_show_counter'];
75
- $youtube_text = $instance['youtube_text'];
76
- $youtube_type = $instance['youtube_type'];
77
-
78
- $pinterest_id = $instance['pinterest'];
79
- $pinterest_show_counter = $instance['pinterest_show_counter'];
80
- $pinterest_api_key = $instance['pinterest_api_key'];
81
- $pinterest_text = $instance['pinterest_text'];
82
-
83
- $fb_likes = $this->get_facebook_likes_count( $facebook_id, $facebook_access_token, $facebook_show_counter );
84
- $twitter_follower = $this->get_twitter_followers( $twitter_id, $twitter_api_key, $twitter_secret_key, $twitter_show_counter );
85
- $google_follower = $this->get_google_plus_follower( $google_id, $google_show_counter );
86
- $youtube_subscriber = $this->get_youtube_subscriber( $youtube_id, $youtube_show_counter, $youtube_type );
87
- $pinterest_follower = $this->get_pinterest_followers( $pinterest_api_key, $pinterest_show_counter );
88
-
89
- include SSB_PLUGIN_DIR . '/inc/ssb-widget-front.php';
90
- }
91
-
92
- /**
93
- * Back-end widget form.
94
- *
95
- * @see WP_Widget::form()
96
- *
97
- * @param array $instance Previously saved values from database.
98
- */
99
- public function form( $instance ) {
100
- $display = '1';
101
-
102
- //first time run when instance create
103
- if ( 0 == count( $instance ) ) {
104
- $instance['facebook_text'] = __( 'Follow us on Facebook', 'simple-social-buttons' );
105
- $instance['google_text'] = __( 'Follow us on Google+', 'simple-social-buttons' );
106
- $instance['youtube_text'] = __( 'Subscribe us on Youtube', 'simple-social-buttons' );
107
- $instance['twitter_text'] = __( 'Follow us on Twitter', 'simple-social-buttons' );
108
- $instance['pinterest_text'] = __( 'Pin us on Pinterest', 'simple-social-buttons' );
109
-
110
- }
111
-
112
-
113
- $title = ! empty( $instance['title'] ) ? $instance['title'] : esc_html__( 'Follow Us', 'simple-social-buttons' );
114
-
115
- $show_facebook = ! empty( $instance['show_facebook'] ) ? $instance['show_facebook'] : '';
116
- $show_twitter = ! empty( $instance['show_twitter'] ) ? $instance['show_twitter'] : '';
117
- $show_google_plus = ! empty( $instance['show_google_plus'] ) ? $instance['show_google_plus'] : '';
118
- $show_youtube = ! empty( $instance['show_youtube'] ) ? $instance['show_youtube'] : '';
119
- $show_pinterest = ! empty( $instance['show_pinterest'] ) ? $instance['show_pinterest'] : '';
120
-
121
- $facebook_id = ! empty( $instance['facebook_id'] ) ? $instance['facebook_id'] : '';
122
- $facebook_show_counter = ! empty( $instance['facebook_show_counter'] ) ? $instance['facebook_show_counter'] : '';
123
- $facebook_text = ! empty( $instance['facebook_text'] ) ? $instance['facebook_text'] : '';
124
- $facebook_app_id = ! empty( $instance['facebook_app_id'] ) ? $instance['facebook_app_id'] : '';
125
- $facebook_security_key = ! empty( $instance['facebook_security_key'] ) ? $instance['facebook_security_key'] : '';
126
- $facebook_access_token = ! empty( $instance['facebook_access_token'] ) ? $instance['facebook_access_token'] : '';
127
-
128
- $twitter = ! empty( $instance['twitter'] ) ? $instance['twitter'] : '';
129
- $twitter_api_key = ! empty( $instance['twitter_api_key'] ) ? $instance['twitter_api_key'] : '';
130
- $twitter_show_counter = ! empty( $instance['twitter_show_counter'] ) ? $instance['twitter_show_counter'] : '';
131
- $twitter_text = ! empty( $instance['twitter_text'] ) ? $instance['twitter_text'] : '';
132
- $twitter_secret_key = ! empty( $instance['twitter_secret_key'] ) ? $instance['twitter_secret_key'] : '';
133
-
134
- $google = ! empty( $instance['google'] ) ? $instance['google'] : '';
135
- $google_show_counter = ! empty( $instance['google_show_counter'] ) ? $instance['google_show_counter'] : '';
136
- $google_text = ! empty( $instance['google_text'] ) ? $instance['google_text'] : '';
137
-
138
- $youtube = ! empty( $instance['youtube'] ) ? $instance['youtube'] : '';
139
- $youtube_text = ! empty( $instance['youtube_text'] ) ? $instance['youtube_text'] : '';
140
- $youtube_type = ! empty( $instance['youtube_type'] ) ? $instance['youtube_type'] : '';
141
- $youtube_show_counter = ! empty( $instance['youtube_show_counter'] ) ? $instance['youtube_show_counter'] : '';
142
-
143
- $pinterest = ! empty( $instance['pinterest'] ) ? $instance['pinterest'] : '';
144
- $pinterest_text = ! empty( $instance['pinterest_text'] ) ? $instance['pinterest_text'] : '';
145
- $pinterest_show_counter = ! empty( $instance['pinterest_show_counter'] ) ? $instance['pinterest_show_counter'] : '';
146
- $pinterest_api_key = ! empty( $instance['pinterest_api_key'] ) ? $instance['pinterest_api_key'] : '';
147
-
148
- include SSB_PLUGIN_DIR . '/inc/ssb-widget-fields.php';
149
-
150
- }
151
-
152
- /**
153
- * Sanitize widget form values as they are saved.
154
- *
155
- * @see WP_Widget::update()
156
- *
157
- * @param array $new_instance Values just sent to be saved.
158
- * @param array $old_instance Previously saved values from database.
159
- *
160
- * @return array Updated safe values to be saved.
161
- */
162
- public function update( $new_instance, $old_instance ) {
163
-
164
- // delete transiant wheb user update widget settings.
165
- delete_transient( 'ssb_follow_facebook_counter' );
166
- delete_transient( 'ssb_follow_twitter_counter' );
167
- delete_transient( 'ssb_follow_google_counter' );
168
- delete_transient( 'ssb_follow_youtube_counter' );
169
- delete_transient( 'ssb_follow_pinterest_counter' );
170
-
171
- $instance = array();
172
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
173
-
174
- $instance['show_facebook'] = ! empty( $new_instance['show_facebook'] ) ? strip_tags( $new_instance['show_facebook'] ) : '0';
175
- $instance['show_twitter'] = ! empty( $new_instance['show_twitter'] ) ? strip_tags( $new_instance['show_twitter'] ) : '0';
176
- $instance['show_google_plus'] = ! empty( $new_instance['show_google_plus'] ) ? strip_tags( $new_instance['show_google_plus'] ) : '0';
177
- $instance['show_youtube'] = ! empty( $new_instance['show_youtube'] ) ? strip_tags( $new_instance['show_youtube'] ) : '0';
178
- $instance['show_pinterest'] = ! empty( $new_instance['show_pinterest'] ) ? strip_tags( $new_instance['show_pinterest'] ) : '0';
179
-
180
- $instance['facebook_id'] = sanitize_text_field( wp_unslash( $new_instance['facebook_id'] ) );
181
- $instance['facebook_app_id'] = sanitize_text_field( wp_unslash( $new_instance['facebook_app_id'] ) );
182
- $instance['facebook_security_key'] = sanitize_text_field( wp_unslash( $new_instance['facebook_security_key'] ) );
183
- $instance['facebook_access_token'] = sanitize_text_field( wp_unslash( $new_instance['facebook_access_token'] ) );
184
- $instance['facebook_show_counter'] = ( ! empty( $new_instance['facebook_show_counter'] ) ) ? strip_tags( $new_instance['facebook_show_counter'] ) : '0';
185
- $instance['facebook_text'] = sanitize_text_field( wp_unslash( $new_instance['facebook_text'] ) );
186
-
187
- $instance['twitter'] = sanitize_text_field( wp_unslash( $new_instance['twitter'] ) );
188
- $instance['twitter_api_key'] = sanitize_text_field( wp_unslash( $new_instance['twitter_api_key'] ) );
189
- $instance['twitter_secret_key'] = sanitize_text_field( wp_unslash( $new_instance['twitter_secret_key'] ) );
190
- $instance['twitter_show_counter'] = ( ! empty( $new_instance['twitter_show_counter'] ) ) ? strip_tags( $new_instance['twitter_show_counter'] ) : '0';
191
- $instance['twitter_text'] = sanitize_text_field( wp_unslash( $new_instance['twitter_text'] ) );
192
-
193
- $instance['google'] = sanitize_text_field( wp_unslash( $new_instance['google'] ) );
194
- $instance['google_show_counter'] = ( ! empty( $new_instance['google_show_counter'] ) ) ? strip_tags( $new_instance['google_show_counter'] ) : '0';
195
- $instance['google_text'] = sanitize_text_field( wp_unslash( $new_instance['google_text'] ) );
196
-
197
- $instance['youtube'] = sanitize_text_field( wp_unslash( $new_instance['youtube'] ) );
198
- $instance['youtube_show_counter'] = ( ! empty( $new_instance['youtube_show_counter'] ) ) ? strip_tags( $new_instance['youtube_show_counter'] ) : '0';
199
- $instance['youtube_text'] = sanitize_text_field( wp_unslash( $new_instance['youtube_text'] ) );
200
- $instance['youtube_type'] = sanitize_text_field( wp_unslash( $new_instance['youtube_type'] ) );
201
-
202
- $instance['pinterest'] = sanitize_text_field( wp_unslash( $new_instance['pinterest'] ) );
203
- $instance['pinterest_show_counter'] = ( ! empty( $new_instance['pinterest_show_counter'] ) ) ? strip_tags( $new_instance['pinterest_show_counter'] ) : '0';
204
- $instance['pinterest_text'] = sanitize_text_field( wp_unslash( $new_instance['pinterest_text'] ) );
205
- $instance['pinterest_api_key'] = sanitize_text_field( wp_unslash( $new_instance['pinterest_api_key'] ) );
206
-
207
- return $instance;
208
- }
209
-
210
- /**
211
- * passing facebook and access token return facebook like counter
212
- *
213
- * @since 2.0.2
214
- *
215
- * @param $facebook_id
216
- * @param $access_token
217
- *
218
- * @return int
219
- */
220
- function get_facebook_likes_count( $facebook_id, $access_token, $show_counter ) {
221
-
222
- if ( $show_counter ) {
223
-
224
- if ( false === get_transient( 'ssb_follow_facebook_counter' ) ) {
225
- $json_feed_url = "https://graph.facebook.com/$facebook_id/?fields=likes,fan_count&access_token=$access_token";
226
-
227
- $args = array( 'httpversion' => '1.1' );
228
- $json_feed = wp_remote_get( $json_feed_url, $args );
229
-
230
- if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
231
- return 0;
232
- }
233
- $result = json_decode( wp_remote_retrieve_body( $json_feed ) );
234
- $counter = ( isset( $result->fan_count ) ? $result->fan_count : 0 );
235
- $counter = $this->format_number( $counter );
236
-
237
- if ( ! empty( $counter ) ) {
238
- set_transient( 'ssb_follow_facebook_counter', $counter, $this->cache_time );
239
- }
240
-
241
- return $counter;
242
- } else {
243
- return get_transient( 'ssb_follow_facebook_counter' );
244
- }
245
- }
246
- }
247
-
248
- /**
249
- * Pass twitter user name and api key return twitter follower
250
- *
251
- * @since 2.0.2
252
- *
253
- * @param $twitter_handle
254
- * @param $api_key
255
- * @param $secret_key
256
- *
257
- * @return mixed|void
258
- */
259
- function get_twitter_followers( $twitter_handle, $api_key, $secret_key, $show_count ) {
260
- // some variables
261
- $consumerKey = $api_key;
262
- $consumerSecret = $secret_key;
263
- $token = get_option( 'ssb_follow_twitter_token' );
264
-
265
- // get follower count from cache
266
- $numberOfFollowers = get_transient( 'ssb_follow_twitter_counter' );
267
-
268
- if ( $show_count ) {
269
-
270
- // cache version does not exist or expired
271
- if ( false == get_transient( 'ssb_follow_twitter_counter' ) ) {
272
-
273
- // getting new auth bearer only if we don't have one
274
- if ( ! $token ) {
275
- // preparing credentials
276
- $credentials = $consumerKey . ':' . $consumerSecret;
277
- $toSend = base64_encode( $credentials );
278
-
279
- $args = array(
280
- 'method' => 'POST',
281
- 'httpversion' => '1.1',
282
- 'blocking' => true,
283
- 'headers' => array(
284
- 'Authorization' => 'Basic ' . $toSend,
285
- 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
286
- ),
287
- 'body' => array( 'grant_type' => 'client_credentials' ),
288
- );
289
-
290
- add_filter( 'https_ssl_verify', '__return_false' );
291
- $response = wp_remote_post( 'https://api.twitter.com/oauth2/token', $args );
292
-
293
- $keys = json_decode( wp_remote_retrieve_body( $response ) );
294
-
295
- if ( $keys && isset( $keys->access_token ) ) {
296
- // saving token to wp_options table.
297
- update_option( 'ssb_follow_twitter_token', $keys->access_token );
298
- $token = $keys->access_token;
299
- }
300
- }
301
-
302
- // we have bearer token wether we obtained it from API or from options.
303
- $args = array(
304
- 'httpversion' => '1.1',
305
- 'blocking' => true,
306
- 'headers' => array(
307
- 'Authorization' => "Bearer $token",
308
- ),
309
- );
310
-
311
- add_filter( 'https_ssl_verify', '__return_false' );
312
- $api_url = "https://api.twitter.com/1.1/users/show.json?screen_name=$twitter_handle";
313
- $response = wp_remote_get( $api_url, $args );
314
- if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
315
- return 0;
316
- }
317
-
318
- $followers = json_decode( wp_remote_retrieve_body( $response ) );
319
- $counter = isset( $followers->followers_count ) ? $followers->followers_count : 0;
320
- $counter = $this->format_number( $counter );
321
- // cache for an hour
322
- if ( ! empty( $counter ) ) {
323
- set_transient( 'ssb_follow_twitter_counter', $counter, $this->cache_time );
324
- }
325
-
326
- return $counter;
327
- }
328
-
329
- return get_transient( 'ssb_follow_twitter_counter' );
330
-
331
- }
332
- }
333
-
334
- /**
335
- * passing the google plus username return google+ follower
336
- *
337
- * @since 2.0.2
338
- *
339
- * @param $google_iD
340
- *
341
- * @return int
342
- */
343
- function get_google_plus_follower( $google_id, $show_counter ) {
344
-
345
- if ( $show_counter ) {
346
-
347
- if ( false === get_transient( 'ssb_follow_google_counter' ) ) {
348
- $json_feed_url = 'https://www.googleapis.com/plus/v1/people/' . $google_id . '?fields=circledByCount%2CplusOneCount&key=' . $this->api_key;
349
- $args = array( 'httpversion' => '1.1' );
350
- $json_feed = wp_remote_get( $json_feed_url, $args );
351
- if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
352
- return 0;
353
- }
354
- $result = json_decode( wp_remote_retrieve_body( $json_feed ) );
355
-
356
- $counter = isset( $result->circledByCount ) ? $result->circledByCount : 0;
357
-
358
- $counter = $this->format_number( $counter );
359
- if ( ! empty( $counter ) ) {
360
-
361
- set_transient( 'ssb_follow_google_counter', $counter, $this->cache_time );
362
- }
363
-
364
- return $counter;
365
- } else {
366
-
367
- return get_transient( 'ssb_follow_google_counter' );
368
- }
369
- }
370
- }
371
-
372
- /**
373
- * passing youtube channel id and access token return the channel subscriber counter
374
- * @since 2.0.2
375
- *
376
- * @param $channel_id
377
- * @param $access_token
378
- *
379
- * @return int
380
- */
381
- function get_youtube_subscriber( $channel_id, $show_counter, $youtube_type ) {
382
-
383
- if ( $show_counter ) {
384
-
385
- if ( false === get_transient( 'ssb_follow_youtube_counter' ) ) {
386
-
387
- // Check if username of channel id.
388
- $_type = $youtube_type == 'username' ? 'forUsername' : 'id';
389
-
390
- $json_feed_url = 'https://www.googleapis.com/youtube/v3/channels?key=' . $this->api_key . '&part=contentDetails,statistics&'. $_type . '=' . $channel_id;
391
- $args = array(
392
- 'httpversion' => '1.1',
393
- 'timeout' => 15
394
- );
395
- $json_feed = wp_remote_get( $json_feed_url, $args );
396
- if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
397
- return 0;
398
- }
399
- $result = json_decode( wp_remote_retrieve_body( $json_feed ) );
400
- $counter = isset( $result->items[0]->statistics->subscriberCount ) ? $result->items[0]->statistics->subscriberCount : 0;
401
- $counter = $this->format_number( $counter );
402
-
403
- if ( ! empty( $counter ) ) {
404
-
405
- set_transient( 'ssb_follow_youtube_counter', $counter, $this->cache_time );
406
- }
407
-
408
- return $counter;
409
- } else {
410
-
411
- return get_transient( 'ssb_follow_youtube_counter' );
412
- }
413
- }
414
-
415
- }
416
-
417
- /**
418
- * passing pinterest access_token for getting pinterest follower counter
419
- * @since 2.0.2
420
- * @param $access_token
421
- * @param $show_counter
422
- *
423
- * @return int|string
424
- */
425
- function get_pinterest_followers( $access_token, $show_counter ) {
426
-
427
- if ( $show_counter ) {
428
-
429
- if ( false === get_transient( 'ssb_follow_pinterest_counter' ) ) {
430
- $json_feed_url = 'https://api.pinterest.com/v1/me/followers/?access_token=' . $access_token;
431
- $args = array( 'httpversion' => '1.1' );
432
- $json_feed = wp_remote_get( $json_feed_url, $args );
433
- //$result = json_decode( $json_feed['body'] );
434
- if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
435
- return 0;
436
- }
437
- $result = json_decode( wp_remote_retrieve_body( $json_feed ),true );
438
- $counter = count($result['data'] );
439
- $counter = $this->format_number( $counter );
440
-
441
- if ( ! empty( $counter ) ) {
442
-
443
- set_transient( 'ssb_follow_pinterest_counter', $counter, $this->cache_time );
444
- }
445
-
446
- return $counter;
447
- } else {
448
-
449
- return get_transient( 'ssb_follow_pinterest_counter' );
450
- }
451
- }
452
-
453
- }
454
-
455
- /**
456
- * Format the (int)number into easy readable format like 1K, 1M
457
- * @since 2.0.2
458
- *
459
- * @param $value
460
- *
461
- * @return string
462
- */
463
- function format_number( $value ) {
464
- if ( $value > 999 && $value <= 999999 ) {
465
- return $result = floor( $value / 1000 ) . 'K';
466
- } elseif ( $value > 999999 ) {
467
- return $result = floor( $value / 1000000 ) . ' M';
468
- } else {
469
- return $result = $value;
470
- }
471
- }
472
-
473
- } // end class Ssb_Follower_Widget
474
-
475
- /**
476
- * Register plugin widget.
477
- */
478
- function ssb_register_widget() {
479
- register_widget( 'Ssb_Follower_Widget' );
480
- }
481
-
482
- add_action( 'widgets_init', 'ssb_register_widget' );
1
+ <?php
2
+
3
+ /**
4
+ * Widget class for social share follower widget
5
+ *
6
+ * @sicne 2.0.2
7
+ *
8
+ * Class Ssb_Follower_Widget
9
+ */
10
+ class Ssb_Follower_Widget extends WP_Widget {
11
+
12
+ /**
13
+ * Google console api key for google+ and youtube api for getting follower and subscriber
14
+ * @var string
15
+ */
16
+ private $api_key = 'AIzaSyBkQDWiRWxWKUoavuajUSAs28ld0Pdx8a4';
17
+
18
+ /**
19
+ * Transient Time
20
+ *
21
+ * 43200 = 12 Hours
22
+ */
23
+ private $cache_time = 43200;
24
+
25
+ /**
26
+ * Register ssb widget with WordPress.
27
+ *
28
+ * @since 2.0.2
29
+ */
30
+ function __construct() {
31
+ $widget_ops = array(
32
+ 'description' => 'Display Follow Button For your site',
33
+ );
34
+ parent::__construct( 'ssb_widget', 'Social Follow Widget', $widget_ops );
35
+
36
+ }
37
+
38
+ /**
39
+ * Front-end display of widget.
40
+ *
41
+ * @see WP_Widget::widget()
42
+ *
43
+ * @param array $args Widget arguments.
44
+ * @param array $instance Saved values from database.
45
+ */
46
+ function widget( $args, $instance ) {
47
+ extract( $args );
48
+ $display = '1';
49
+
50
+ $widget_title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance );
51
+
52
+ $show_facebook = $instance['show_facebook'];
53
+ $show_twitter = $instance['show_twitter'];
54
+ $show_google_plus = $instance['show_google_plus'];
55
+ $show_youtube = $instance['show_youtube'];
56
+ $show_pinterest = $instance['show_pinterest'];
57
+
58
+ $facebook_id = $instance['facebook_id'];
59
+ $facebook_show_counter = $instance['facebook_show_counter'];
60
+ $facebook_text = $instance['facebook_text'];
61
+ $facebook_access_token = $instance['facebook_access_token'];
62
+
63
+ $twitter_id = $instance['twitter'];
64
+ $twitter_show_counter = $instance['twitter_show_counter'];
65
+ $twitter_text = $instance['twitter_text'];
66
+ $twitter_api_key = $instance['twitter_api_key'];
67
+ $twitter_secret_key = $instance['twitter_secret_key'];
68
+
69
+ $google_id = $instance['google'];
70
+ $google_show_counter = $instance['google_show_counter'];
71
+ $google_text = $instance['google_text'];
72
+
73
+ $youtube_id = $instance['youtube'];
74
+ $youtube_show_counter = $instance['youtube_show_counter'];
75
+ $youtube_text = $instance['youtube_text'];
76
+ $youtube_type = $instance['youtube_type'];
77
+
78
+ $pinterest_id = $instance['pinterest'];
79
+ $pinterest_show_counter = $instance['pinterest_show_counter'];
80
+ $pinterest_api_key = $instance['pinterest_api_key'];
81
+ $pinterest_text = $instance['pinterest_text'];
82
+
83
+ $fb_likes = $this->get_facebook_likes_count( $facebook_id, $facebook_access_token, $facebook_show_counter );
84
+ $twitter_follower = $this->get_twitter_followers( $twitter_id, $twitter_api_key, $twitter_secret_key, $twitter_show_counter );
85
+ $google_follower = $this->get_google_plus_follower( $google_id, $google_show_counter );
86
+ $youtube_subscriber = $this->get_youtube_subscriber( $youtube_id, $youtube_show_counter, $youtube_type );
87
+ $pinterest_follower = $this->get_pinterest_followers( $pinterest_api_key, $pinterest_show_counter );
88
+
89
+ include SSB_PLUGIN_DIR . '/inc/ssb-widget-front.php';
90
+ }
91
+
92
+ /**
93
+ * Back-end widget form.
94
+ *
95
+ * @see WP_Widget::form()
96
+ *
97
+ * @param array $instance Previously saved values from database.
98
+ */
99
+ public function form( $instance ) {
100
+ $display = '1';
101
+
102
+ //first time run when instance create
103
+ if ( 0 == count( $instance ) ) {
104
+ $instance['facebook_text'] = __( 'Follow us on Facebook', 'simple-social-buttons' );
105
+ $instance['google_text'] = __( 'Follow us on Google+', 'simple-social-buttons' );
106
+ $instance['youtube_text'] = __( 'Subscribe us on Youtube', 'simple-social-buttons' );
107
+ $instance['twitter_text'] = __( 'Follow us on Twitter', 'simple-social-buttons' );
108
+ $instance['pinterest_text'] = __( 'Pin us on Pinterest', 'simple-social-buttons' );
109
+
110
+ }
111
+
112
+
113
+ $title = isset( $instance['title'] ) ? $instance['title'] : esc_html__( 'Follow Us', 'simple-social-buttons' );
114
+
115
+ $show_facebook = ! empty( $instance['show_facebook'] ) ? $instance['show_facebook'] : '';
116
+ $show_twitter = ! empty( $instance['show_twitter'] ) ? $instance['show_twitter'] : '';
117
+ $show_google_plus = ! empty( $instance['show_google_plus'] ) ? $instance['show_google_plus'] : '';
118
+ $show_youtube = ! empty( $instance['show_youtube'] ) ? $instance['show_youtube'] : '';
119
+ $show_pinterest = ! empty( $instance['show_pinterest'] ) ? $instance['show_pinterest'] : '';
120
+
121
+ $facebook_id = ! empty( $instance['facebook_id'] ) ? $instance['facebook_id'] : '';
122
+ $facebook_show_counter = ! empty( $instance['facebook_show_counter'] ) ? $instance['facebook_show_counter'] : '';
123
+ $facebook_text = ! empty( $instance['facebook_text'] ) ? $instance['facebook_text'] : '';
124
+ $facebook_app_id = ! empty( $instance['facebook_app_id'] ) ? $instance['facebook_app_id'] : '';
125
+ $facebook_security_key = ! empty( $instance['facebook_security_key'] ) ? $instance['facebook_security_key'] : '';
126
+ $facebook_access_token = ! empty( $instance['facebook_access_token'] ) ? $instance['facebook_access_token'] : '';
127
+
128
+ $twitter = ! empty( $instance['twitter'] ) ? $instance['twitter'] : '';
129
+ $twitter_api_key = ! empty( $instance['twitter_api_key'] ) ? $instance['twitter_api_key'] : '';
130
+ $twitter_show_counter = ! empty( $instance['twitter_show_counter'] ) ? $instance['twitter_show_counter'] : '';
131
+ $twitter_text = ! empty( $instance['twitter_text'] ) ? $instance['twitter_text'] : '';
132
+ $twitter_secret_key = ! empty( $instance['twitter_secret_key'] ) ? $instance['twitter_secret_key'] : '';
133
+
134
+ $google = ! empty( $instance['google'] ) ? $instance['google'] : '';
135
+ $google_show_counter = ! empty( $instance['google_show_counter'] ) ? $instance['google_show_counter'] : '';
136
+ $google_text = ! empty( $instance['google_text'] ) ? $instance['google_text'] : '';
137
+
138
+ $youtube = ! empty( $instance['youtube'] ) ? $instance['youtube'] : '';
139
+ $youtube_text = ! empty( $instance['youtube_text'] ) ? $instance['youtube_text'] : '';
140
+ $youtube_type = ! empty( $instance['youtube_type'] ) ? $instance['youtube_type'] : '';
141
+ $youtube_show_counter = ! empty( $instance['youtube_show_counter'] ) ? $instance['youtube_show_counter'] : '';
142
+
143
+ $pinterest = ! empty( $instance['pinterest'] ) ? $instance['pinterest'] : '';
144
+ $pinterest_text = ! empty( $instance['pinterest_text'] ) ? $instance['pinterest_text'] : '';
145
+ $pinterest_show_counter = ! empty( $instance['pinterest_show_counter'] ) ? $instance['pinterest_show_counter'] : '';
146
+ $pinterest_api_key = ! empty( $instance['pinterest_api_key'] ) ? $instance['pinterest_api_key'] : '';
147
+
148
+ include SSB_PLUGIN_DIR . '/inc/ssb-widget-fields.php';
149
+
150
+ }
151
+
152
+ /**
153
+ * Sanitize widget form values as they are saved.
154
+ *
155
+ * @see WP_Widget::update()
156
+ *
157
+ * @param array $new_instance Values just sent to be saved.
158
+ * @param array $old_instance Previously saved values from database.
159
+ *
160
+ * @return array Updated safe values to be saved.
161
+ */
162
+ public function update( $new_instance, $old_instance ) {
163
+
164
+ // delete transiant wheb user update widget settings.
165
+ delete_transient( 'ssb_follow_facebook_counter' );
166
+ delete_transient( 'ssb_follow_twitter_counter' );
167
+ delete_transient( 'ssb_follow_google_counter' );
168
+ delete_transient( 'ssb_follow_youtube_counter' );
169
+ delete_transient( 'ssb_follow_pinterest_counter' );
170
+
171
+ $instance = array();
172
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
173
+
174
+ $instance['show_facebook'] = ! empty( $new_instance['show_facebook'] ) ? strip_tags( $new_instance['show_facebook'] ) : '0';
175
+ $instance['show_twitter'] = ! empty( $new_instance['show_twitter'] ) ? strip_tags( $new_instance['show_twitter'] ) : '0';
176
+ $instance['show_google_plus'] = ! empty( $new_instance['show_google_plus'] ) ? strip_tags( $new_instance['show_google_plus'] ) : '0';
177
+ $instance['show_youtube'] = ! empty( $new_instance['show_youtube'] ) ? strip_tags( $new_instance['show_youtube'] ) : '0';
178
+ $instance['show_pinterest'] = ! empty( $new_instance['show_pinterest'] ) ? strip_tags( $new_instance['show_pinterest'] ) : '0';
179
+
180
+ $instance['facebook_id'] = sanitize_text_field( wp_unslash( $new_instance['facebook_id'] ) );
181
+ $instance['facebook_app_id'] = sanitize_text_field( wp_unslash( $new_instance['facebook_app_id'] ) );
182
+ $instance['facebook_security_key'] = sanitize_text_field( wp_unslash( $new_instance['facebook_security_key'] ) );
183
+ $instance['facebook_access_token'] = sanitize_text_field( wp_unslash( $new_instance['facebook_access_token'] ) );
184
+ $instance['facebook_show_counter'] = ( ! empty( $new_instance['facebook_show_counter'] ) ) ? strip_tags( $new_instance['facebook_show_counter'] ) : '0';
185
+ $instance['facebook_text'] = sanitize_text_field( wp_unslash( $new_instance['facebook_text'] ) );
186
+
187
+ $instance['twitter'] = sanitize_text_field( wp_unslash( $new_instance['twitter'] ) );
188
+ $instance['twitter_api_key'] = sanitize_text_field( wp_unslash( $new_instance['twitter_api_key'] ) );
189
+ $instance['twitter_secret_key'] = sanitize_text_field( wp_unslash( $new_instance['twitter_secret_key'] ) );
190
+ $instance['twitter_show_counter'] = ( ! empty( $new_instance['twitter_show_counter'] ) ) ? strip_tags( $new_instance['twitter_show_counter'] ) : '0';
191
+ $instance['twitter_text'] = sanitize_text_field( wp_unslash( $new_instance['twitter_text'] ) );
192
+
193
+ $instance['google'] = sanitize_text_field( wp_unslash( $new_instance['google'] ) );
194
+ $instance['google_show_counter'] = ( ! empty( $new_instance['google_show_counter'] ) ) ? strip_tags( $new_instance['google_show_counter'] ) : '0';
195
+ $instance['google_text'] = sanitize_text_field( wp_unslash( $new_instance['google_text'] ) );
196
+
197
+ $instance['youtube'] = sanitize_text_field( wp_unslash( $new_instance['youtube'] ) );
198
+ $instance['youtube_show_counter'] = ( ! empty( $new_instance['youtube_show_counter'] ) ) ? strip_tags( $new_instance['youtube_show_counter'] ) : '0';
199
+ $instance['youtube_text'] = sanitize_text_field( wp_unslash( $new_instance['youtube_text'] ) );
200
+ $instance['youtube_type'] = sanitize_text_field( wp_unslash( $new_instance['youtube_type'] ) );
201
+
202
+ $instance['pinterest'] = sanitize_text_field( wp_unslash( $new_instance['pinterest'] ) );
203
+ $instance['pinterest_show_counter'] = ( ! empty( $new_instance['pinterest_show_counter'] ) ) ? strip_tags( $new_instance['pinterest_show_counter'] ) : '0';
204
+ $instance['pinterest_text'] = sanitize_text_field( wp_unslash( $new_instance['pinterest_text'] ) );
205
+ $instance['pinterest_api_key'] = sanitize_text_field( wp_unslash( $new_instance['pinterest_api_key'] ) );
206
+
207
+ return $instance;
208
+ }
209
+
210
+ /**
211
+ * passing facebook and access token return facebook like counter
212
+ *
213
+ * @since 2.0.2
214
+ *
215
+ * @param $facebook_id
216
+ * @param $access_token
217
+ *
218
+ * @return int
219
+ */
220
+ function get_facebook_likes_count( $facebook_id, $access_token, $show_counter ) {
221
+
222
+ if ( $show_counter ) {
223
+
224
+ if ( false === get_transient( 'ssb_follow_facebook_counter' ) ) {
225
+ $json_feed_url = "https://graph.facebook.com/$facebook_id/?fields=likes,fan_count&access_token=$access_token";
226
+
227
+ $args = array( 'httpversion' => '1.1' );
228
+ $json_feed = wp_remote_get( $json_feed_url, $args );
229
+
230
+ if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
231
+ return 0;
232
+ }
233
+ $result = json_decode( wp_remote_retrieve_body( $json_feed ) );
234
+ $counter = ( isset( $result->fan_count ) ? $result->fan_count : 0 );
235
+ $counter = $this->format_number( $counter );
236
+
237
+ if ( ! empty( $counter ) ) {
238
+ set_transient( 'ssb_follow_facebook_counter', $counter, $this->cache_time );
239
+ }
240
+
241
+ return $counter;
242
+ } else {
243
+ return get_transient( 'ssb_follow_facebook_counter' );
244
+ }
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Pass twitter user name and api key return twitter follower
250
+ *
251
+ * @since 2.0.2
252
+ *
253
+ * @param $twitter_handle
254
+ * @param $api_key
255
+ * @param $secret_key
256
+ *
257
+ * @return mixed|void
258
+ */
259
+ function get_twitter_followers( $twitter_handle, $api_key, $secret_key, $show_count ) {
260
+ // some variables
261
+ $consumerKey = $api_key;
262
+ $consumerSecret = $secret_key;
263
+ $token = get_option( 'ssb_follow_twitter_token' );
264
+
265
+ // get follower count from cache
266
+ $numberOfFollowers = get_transient( 'ssb_follow_twitter_counter' );
267
+
268
+ if ( $show_count ) {
269
+
270
+ // cache version does not exist or expired
271
+ if ( false == get_transient( 'ssb_follow_twitter_counter' ) ) {
272
+
273
+ // getting new auth bearer only if we don't have one
274
+ if ( ! $token ) {
275
+ // preparing credentials
276
+ $credentials = $consumerKey . ':' . $consumerSecret;
277
+ $toSend = base64_encode( $credentials );
278
+
279
+ $args = array(
280
+ 'method' => 'POST',
281
+ 'httpversion' => '1.1',
282
+ 'blocking' => true,
283
+ 'headers' => array(
284
+ 'Authorization' => 'Basic ' . $toSend,
285
+ 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
286
+ ),
287
+ 'body' => array( 'grant_type' => 'client_credentials' ),
288
+ );
289
+
290
+ add_filter( 'https_ssl_verify', '__return_false' );
291
+ $response = wp_remote_post( 'https://api.twitter.com/oauth2/token', $args );
292
+
293
+ $keys = json_decode( wp_remote_retrieve_body( $response ) );
294
+
295
+ if ( $keys && isset( $keys->access_token ) ) {
296
+ // saving token to wp_options table.
297
+ update_option( 'ssb_follow_twitter_token', $keys->access_token );
298
+ $token = $keys->access_token;
299
+ }
300
+ }
301
+
302
+ // we have bearer token wether we obtained it from API or from options.
303
+ $args = array(
304
+ 'httpversion' => '1.1',
305
+ 'blocking' => true,
306
+ 'headers' => array(
307
+ 'Authorization' => "Bearer $token",
308
+ ),
309
+ );
310
+
311
+ add_filter( 'https_ssl_verify', '__return_false' );
312
+ $api_url = "https://api.twitter.com/1.1/users/show.json?screen_name=$twitter_handle";
313
+ $response = wp_remote_get( $api_url, $args );
314
+ if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
315
+ return 0;
316
+ }
317
+
318
+ $followers = json_decode( wp_remote_retrieve_body( $response ) );
319
+ $counter = isset( $followers->followers_count ) ? $followers->followers_count : 0;
320
+ $counter = $this->format_number( $counter );
321
+ // cache for an hour
322
+ if ( ! empty( $counter ) ) {
323
+ set_transient( 'ssb_follow_twitter_counter', $counter, $this->cache_time );
324
+ }
325
+
326
+ return $counter;
327
+ }
328
+
329
+ return get_transient( 'ssb_follow_twitter_counter' );
330
+
331
+ }
332
+ }
333
+
334
+ /**
335
+ * passing the google plus username return google+ follower
336
+ *
337
+ * @since 2.0.2
338
+ *
339
+ * @param $google_iD
340
+ *
341
+ * @return int
342
+ */
343
+ function get_google_plus_follower( $google_id, $show_counter ) {
344
+
345
+ if ( $show_counter ) {
346
+
347
+ if ( false === get_transient( 'ssb_follow_google_counter' ) ) {
348
+ $json_feed_url = 'https://www.googleapis.com/plus/v1/people/' . $google_id . '?fields=circledByCount%2CplusOneCount&key=' . $this->api_key;
349
+ $args = array( 'httpversion' => '1.1' );
350
+ $json_feed = wp_remote_get( $json_feed_url, $args );
351
+ if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
352
+ return 0;
353
+ }
354
+ $result = json_decode( wp_remote_retrieve_body( $json_feed ) );
355
+
356
+ $counter = isset( $result->circledByCount ) ? $result->circledByCount : 0;
357
+
358
+ $counter = $this->format_number( $counter );
359
+ if ( ! empty( $counter ) ) {
360
+
361
+ set_transient( 'ssb_follow_google_counter', $counter, $this->cache_time );
362
+ }
363
+
364
+ return $counter;
365
+ } else {
366
+
367
+ return get_transient( 'ssb_follow_google_counter' );
368
+ }
369
+ }
370
+ }
371
+
372
+ /**
373
+ * passing youtube channel id and access token return the channel subscriber counter
374
+ * @since 2.0.2
375
+ *
376
+ * @param $channel_id
377
+ * @param $access_token
378
+ *
379
+ * @return int
380
+ */
381
+ function get_youtube_subscriber( $channel_id, $show_counter, $youtube_type ) {
382
+
383
+ if ( $show_counter ) {
384
+
385
+ if ( false === get_transient( 'ssb_follow_youtube_counter' ) ) {
386
+
387
+ // Check if username of channel id.
388
+ $_type = $youtube_type == 'username' ? 'forUsername' : 'id';
389
+
390
+ $json_feed_url = 'https://www.googleapis.com/youtube/v3/channels?key=' . $this->api_key . '&part=contentDetails,statistics&'. $_type . '=' . $channel_id;
391
+ $args = array(
392
+ 'httpversion' => '1.1',
393
+ 'timeout' => 15
394
+ );
395
+ $json_feed = wp_remote_get( $json_feed_url, $args );
396
+ if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
397
+ return 0;
398
+ }
399
+ $result = json_decode( wp_remote_retrieve_body( $json_feed ) );
400
+ $counter = isset( $result->items[0]->statistics->subscriberCount ) ? $result->items[0]->statistics->subscriberCount : 0;
401
+ $counter = $this->format_number( $counter );
402
+
403
+ if ( ! empty( $counter ) ) {
404
+
405
+ set_transient( 'ssb_follow_youtube_counter', $counter, $this->cache_time );
406
+ }
407
+
408
+ return $counter;
409
+ } else {
410
+
411
+ return get_transient( 'ssb_follow_youtube_counter' );
412
+ }
413
+ }
414
+
415
+ }
416
+
417
+ /**
418
+ * passing pinterest access_token for getting pinterest follower counter
419
+ * @since 2.0.2
420
+ * @param $access_token
421
+ * @param $show_counter
422
+ *
423
+ * @return int|string
424
+ */
425
+ function get_pinterest_followers( $access_token, $show_counter ) {
426
+
427
+ if ( $show_counter ) {
428
+
429
+ if ( false === get_transient( 'ssb_follow_pinterest_counter' ) ) {
430
+ $json_feed_url = 'https://api.pinterest.com/v1/me/followers/?access_token=' . $access_token;
431
+ $args = array( 'httpversion' => '1.1' );
432
+ $json_feed = wp_remote_get( $json_feed_url, $args );
433
+ //$result = json_decode( $json_feed['body'] );
434
+ if ( is_wp_error( $json_feed ) || 200 !== wp_remote_retrieve_response_code( $json_feed ) ) {
435
+ return 0;
436
+ }
437
+ $result = json_decode( wp_remote_retrieve_body( $json_feed ),true );
438
+ $counter = count($result['data'] );
439
+ $counter = $this->format_number( $counter );
440
+
441
+ if ( ! empty( $counter ) ) {
442
+
443
+ set_transient( 'ssb_follow_pinterest_counter', $counter, $this->cache_time );
444
+ }
445
+
446
+ return $counter;
447
+ } else {
448
+
449
+ return get_transient( 'ssb_follow_pinterest_counter' );
450
+ }
451
+ }
452
+
453
+ }
454
+
455
+ /**
456
+ * Format the (int)number into easy readable format like 1K, 1M
457
+ * @since 2.0.2
458
+ *
459
+ * @param $value
460
+ *
461
+ * @return string
462
+ */
463
+ function format_number( $value ) {
464
+ if ( $value > 999 && $value <= 999999 ) {
465
+ return $result = floor( $value / 1000 ) . 'K';
466
+ } elseif ( $value > 999999 ) {
467
+ return $result = floor( $value / 1000000 ) . ' M';
468
+ } else {
469
+ return $result = $value;
470
+ }
471
+ }
472
+
473
+ } // end class Ssb_Follower_Widget
474
+
475
+ /**
476
+ * Register plugin widget.
477
+ */
478
+ function ssb_register_widget() {
479
+ register_widget( 'Ssb_Follower_Widget' );
480
+ }
481
+
482
+ add_action( 'widgets_init', 'ssb_register_widget' );
inc/ssb-widget-front.php CHANGED
@@ -1,31 +1,29 @@
1
- <?php
2
- echo $before_widget;
3
- if( !empty( $widget_title ) ){
4
-
5
- echo $before_title . $widget_title . $after_title;
6
- }
7
- ?>
8
-
9
- <section class="ssb_followers simplesocial-simple-round">
10
-
11
-
12
- <?php if( $display == $show_facebook ):?>
13
- <a class="ssb_button simplesocial-fb-follow" rel="nofollow" href="https://www.facebook.com/<?php echo $facebook_id;?>" target="_blank"><span class="simplesocialtxt"><?php echo $facebook_text;?> </span><span class="widget_counter"> <?php echo ( $display == $facebook_show_counter)? $fb_likes: '' ;?> </span></a>
14
- <?php endif;
15
- if( $display == $show_twitter ): ?>
16
- <a class="ssb_button simplesocial-twt-follow" rel="nofollow" href="https://www.twitter.com/<?php echo $twitter_id;?>" target="_blank"><span class="simplesocialtxt"><?php echo $twitter_text;?> </span><span class="widget_counter"> <?php echo ( $display == $twitter_show_counter)? $twitter_follower: '';?> </span></a>
17
- <?php endif;
18
- if ( $display == $show_google_plus ):?>
19
- <a class="ssb_button simplesocial-gplus-follow" rel="nofollow" href="https://www.plus.google.com/<?php echo $google_id;?>" target="_blank"><span class="simplesocialtxt"><?php echo $google_text;?> </span><span class="widget_counter"> <?php echo ( $display == $google_show_counter )? $google_follower: '';?> </span></a>
20
- <?php endif;
21
- if( $display == $show_youtube):
22
- ?>
23
- <a class="ssb_button simplesocial-yt-follow" rel="nofollow" href="https://www.youtube.com/user/<?php echo $youtube_id ?>" target="_blank"><span class="simplesocialtxt"><?php echo $youtube_text?> </span><span class="widget_counter"> <?php echo ( $display == $youtube_show_counter)?$youtube_subscriber:" ";?> </span></a>
24
- <?php endif;?>
25
- <?php if ( $display == $show_pinterest ):?>
26
- <a class="ssb_button simplesocial-pinterest-follow" rel="nofollow" href="https://pinterest.com/<?php echo $pinterest_id;?>/" target="_blank"><span class="simplesocialtxt"><?php echo $pinterest_text;?> </span><span class="widget_counter"> <?php echo ( $display == $pinterest_show_counter )? $pinterest_follower: '';?> </span></a>
27
- <?php endif;?>
28
-
29
-
30
- </section>
31
- <?php echo $after_widget;?>
1
+ <?php
2
+
3
+ if ( !empty( $widget_title ) ) {
4
+ echo $before_title . $widget_title . $after_title;
5
+ }
6
+ ?>
7
+
8
+ <section class="ssb_followers simplesocial-simple-round">
9
+
10
+ <?php if( $display == $show_facebook ):?>
11
+ <a class="ssb_button simplesocial-fb-follow" rel="nofollow" href="https://facebook.com/<?php echo $facebook_id;?>" target="_blank"><span class="simplesocialtxt"><?php echo $facebook_text;?> </span><span class="widget_counter"> <?php echo ( $display == $facebook_show_counter)? $fb_likes: '' ;?> </span></a>
12
+ <?php endif;
13
+ if( $display == $show_twitter ): ?>
14
+ <a class="ssb_button simplesocial-twt-follow" rel="nofollow" href="https://twitter.com/<?php echo $twitter_id;?>" target="_blank"><span class="simplesocialtxt"><?php echo $twitter_text;?> </span><span class="widget_counter"> <?php echo ( $display == $twitter_show_counter)? $twitter_follower: '';?> </span></a>
15
+ <?php endif;
16
+ if ( $display == $show_google_plus ):?>
17
+ <a class="ssb_button simplesocial-gplus-follow" rel="nofollow" href="https://plus.google.com/<?php echo $google_id;?>" target="_blank"><span class="simplesocialtxt"><?php echo $google_text;?> </span><span class="widget_counter"> <?php echo ( $display == $google_show_counter )? $google_follower: '';?> </span></a>
18
+ <?php endif;
19
+ if( $display == $show_youtube):
20
+ ?>
21
+ <a class="ssb_button simplesocial-yt-follow" rel="nofollow" href="https://youtube.com/user/<?php echo $youtube_id ?>" target="_blank"><span class="simplesocialtxt"><?php echo $youtube_text?> </span><span class="widget_counter"> <?php echo ( $display == $youtube_show_counter)?$youtube_subscriber:" ";?> </span></a>
22
+ <?php endif;?>
23
+ <?php if ( $display == $show_pinterest ):?>
24
+ <a class="ssb_button simplesocial-pinterest-follow" rel="nofollow" href="https://pinterest.com/<?php echo $pinterest_id;?>/" target="_blank"><span class="simplesocialtxt"><?php echo $pinterest_text;?> </span><span class="widget_counter"> <?php echo ( $display == $pinterest_show_counter )? $pinterest_follower: '';?> </span></a>
25
+ <?php endif;?>
26
+
27
+
28
+ </section>
29
+ <?php echo $after_widget;?>
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpbrigade.com/
4
  Tags: Social share, Social buttons, Whatsapp, Viber, LinkedIn, facebook, google, twitter, pinterest, plus one
5
  Requires at least: 4.0
6
  Tested up to: 4.9
7
- Stable tag: 2.0.7
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -91,7 +91,7 @@ Simple Social Buttons is currently in the following languages:
91
  2. Upload folder named simple-social-buttons to the /wp-content/plugins/ directory
92
  3. Activate the plugin through the 'Plugins' menu in WordPress
93
  4. Go to Plugin settings -> Everything is self explanatory on settings page. Select networks, styles, locations and then chose settings for each location.
94
- 5. (Optional) Customize the buttons in the Settings > Inline, Siderbar, Popup, Media, Flyins.
95
 
96
  That's it. Buttons will show on your blog posts or any custom type you want. Just select it from each section.
97
 
@@ -111,7 +111,7 @@ Use [plugin's forum](http://wordpress.org/support/plugin/simple-social-buttons "
111
 
112
  = Why upgrade to Pro? =
113
 
114
- Premium version includes Priority support, premium featuers like access to customizing colors of social media buttons, Social popups, fly-ins, on Media Social buttons etc
115
 
116
  Check the more details [here](https://wpbrigade.com/wordpress/plugins/simple-social-buttons-pro/?utm_source=simple-social-buttons-lite&utm_medium=link-faqs&utm_campaign=pro-upgrade "This plugin makes Social Sharing easy for EVERYONE.")
117
 
@@ -123,7 +123,7 @@ Yes, you can use ShortCode [SSB] to use in your Templates/Themes.
123
 
124
  [SSB] to call with plugin settings values.
125
 
126
- [SSB theme="Official" aign="right" counter="true" order="googleplus,twitter,pinterest,fbshare,linkedin" ]
127
 
128
  Attributes with all the possible values.
129
 
@@ -146,12 +146,17 @@ theme = theme1 or theme2 or theme3 or theme4 or Flat or Circle or Official
146
 
147
  == Upgrade Notice ==
148
 
149
- = 2.0.7 =
150
  * Relaunched with a whole set of NEW FEATURES and Improvement. Please upgrade immediately and provide your feedback. highly recommended. Apologies in advance, if anything breaks!
151
 
152
 
153
  == Changelog ==
154
 
 
 
 
 
 
155
  = 2.0.7 - 2018-01-20 =
156
  * New Feature: Share Title text Option added.
157
  * New Feature: Settings Option for excluding Simple Social Buttons on Search Page.
@@ -164,11 +169,11 @@ theme = theme1 or theme2 or theme3 or theme4 or Flat or Circle or Official
164
 
165
  = 2.0.5 - 2017-12-27 =
166
  * New Feature: Social Follow Widget.
167
- * New Feature: Social Media Sharing Buttons ShortCode to use in tempalates.
168
  * Bug Fix: Hide Social Media Sharing Buttons on single posts/pages or custom post types.
169
  * New Feature: Added Official Social Media Sharing Buttons for Facebook, Twitter, Google+, LinkedIn and Pinterest.
170
  * Enhancement: Improved Social Media Images Quality for Retina machines
171
- * Bug Fix: Changed the facebook like button in plugin settings.
172
  * Enhancement: Improved Speed and code optimization.
173
  * Compatibility: Compatible with WordPress 4.9
174
 
@@ -187,7 +192,7 @@ theme = theme1 or theme2 or theme3 or theme4 or Flat or Circle or Official
187
  * Bug Fix: Compatibility issues with older PHP versions.
188
 
189
  = 2.0.0 - 2017-10-31 =
190
- * New Feature: Refactored i.e rewritten the whole plugin with lots of new features.
191
  * New Feature: Inline social share buttons with animations and custom colors in Pro version.
192
  * New Feature: Sidebar social share buttons with animations and custom colors in Pro version.
193
  * New Feature: Social share Popups with events triggers on exit/intent and on scroll.
4
  Tags: Social share, Social buttons, Whatsapp, Viber, LinkedIn, facebook, google, twitter, pinterest, plus one
5
  Requires at least: 4.0
6
  Tested up to: 4.9
7
+ Stable tag: 2.0.8
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
91
  2. Upload folder named simple-social-buttons to the /wp-content/plugins/ directory
92
  3. Activate the plugin through the 'Plugins' menu in WordPress
93
  4. Go to Plugin settings -> Everything is self explanatory on settings page. Select networks, styles, locations and then chose settings for each location.
94
+ 5. (Optional) Customize the buttons in the Settings > Inline, Sidebar, Popup, Media, Flyins.
95
 
96
  That's it. Buttons will show on your blog posts or any custom type you want. Just select it from each section.
97
 
111
 
112
  = Why upgrade to Pro? =
113
 
114
+ Premium version includes Priority support, premium features like access to customizing colors of social media buttons, Social popups, fly-ins, on Media Social buttons etc
115
 
116
  Check the more details [here](https://wpbrigade.com/wordpress/plugins/simple-social-buttons-pro/?utm_source=simple-social-buttons-lite&utm_medium=link-faqs&utm_campaign=pro-upgrade "This plugin makes Social Sharing easy for EVERYONE.")
117
 
123
 
124
  [SSB] to call with plugin settings values.
125
 
126
+ [SSB theme="Official" align="right" counter="true" order="googleplus,twitter,pinterest,fbshare,linkedin" ]
127
 
128
  Attributes with all the possible values.
129
 
146
 
147
  == Upgrade Notice ==
148
 
149
+ = 2.0.8 =
150
  * Relaunched with a whole set of NEW FEATURES and Improvement. Please upgrade immediately and provide your feedback. highly recommended. Apologies in advance, if anything breaks!
151
 
152
 
153
  == Changelog ==
154
 
155
+ = 2.0.8 - 2018-01-24 =
156
+ * Bug Fix: Google Plus issue on widget.
157
+ * Bug Fix: Hide SideBar up to IPad Mini.
158
+ * Bug Fix: Widget Title show even it remove.
159
+
160
  = 2.0.7 - 2018-01-20 =
161
  * New Feature: Share Title text Option added.
162
  * New Feature: Settings Option for excluding Simple Social Buttons on Search Page.
169
 
170
  = 2.0.5 - 2017-12-27 =
171
  * New Feature: Social Follow Widget.
172
+ * New Feature: Social Media Sharing Buttons ShortCode to use in templates.
173
  * Bug Fix: Hide Social Media Sharing Buttons on single posts/pages or custom post types.
174
  * New Feature: Added Official Social Media Sharing Buttons for Facebook, Twitter, Google+, LinkedIn and Pinterest.
175
  * Enhancement: Improved Social Media Images Quality for Retina machines
176
+ * Bug Fix: Changed the Facebook like button in plugin settings.
177
  * Enhancement: Improved Speed and code optimization.
178
  * Compatibility: Compatible with WordPress 4.9
179
 
192
  * Bug Fix: Compatibility issues with older PHP versions.
193
 
194
  = 2.0.0 - 2017-10-31 =
195
+ * New Feature: Refactored i.e. rewritten the whole plugin with lots of new features.
196
  * New Feature: Inline social share buttons with animations and custom colors in Pro version.
197
  * New Feature: Sidebar social share buttons with animations and custom colors in Pro version.
198
  * New Feature: Social share Popups with events triggers on exit/intent and on scroll.
simple-social-buttons.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Social Buttons
4
  * Plugin URI: http://www.WPBrigade.com/wordpress/plugins/simple-social-buttons/
5
  * Description: Simple Social Buttons adds an advanced set of social media sharing buttons to your WordPress sites, such as: Google +1, Facebook, WhatsApp, Viber, Twitter, Reddit, LinkedIn and Pinterest. This makes it the most <code>Flexible Social Sharing Plugin ever for Everyone.</code>
6
- * Version: 2.0.7
7
  * Author: WPBrigade
8
  * Author URI: http://www.WPBrigade.com/
9
  * Text Domain: simple-social-buttons
@@ -30,7 +30,7 @@
30
 
31
  class SimpleSocialButtonsPR {
32
  public $pluginName = 'Simple Social Buttons';
33
- public $pluginVersion = '2.0.7';
34
  public $pluginPrefix = 'ssb_pr_';
35
  public $hideCustomMetaKey = '_ssb_hide';
36
 
@@ -428,6 +428,11 @@ class SimpleSocialButtonsPR {
428
  */
429
  function insert_buttons( $content ) {
430
 
 
 
 
 
 
431
  // Return Content if hide ssb.
432
  if ( get_post_meta( get_the_id(), $this->hideCustomMetaKey, true ) == 'true' ) {
433
  return $content;
3
  * Plugin Name: Simple Social Buttons
4
  * Plugin URI: http://www.WPBrigade.com/wordpress/plugins/simple-social-buttons/
5
  * Description: Simple Social Buttons adds an advanced set of social media sharing buttons to your WordPress sites, such as: Google +1, Facebook, WhatsApp, Viber, Twitter, Reddit, LinkedIn and Pinterest. This makes it the most <code>Flexible Social Sharing Plugin ever for Everyone.</code>
6
+ * Version: 2.0.8
7
  * Author: WPBrigade
8
  * Author URI: http://www.WPBrigade.com/
9
  * Text Domain: simple-social-buttons
30
 
31
  class SimpleSocialButtonsPR {
32
  public $pluginName = 'Simple Social Buttons';
33
+ public $pluginVersion = '2.0.8';
34
  public $pluginPrefix = 'ssb_pr_';
35
  public $hideCustomMetaKey = '_ssb_hide';
36
 
428
  */
429
  function insert_buttons( $content ) {
430
 
431
+ // Return the content if we are not in loop.
432
+ if ( ! is_main_query() || ! in_the_loop() ) {
433
+ return $content;
434
+ }
435
+
436
  // Return Content if hide ssb.
437
  if ( get_post_meta( get_the_id(), $this->hideCustomMetaKey, true ) == 'true' ) {
438
  return $content;