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

Version Description

  • Please upgrade immediately. Releasing New features, few bugfixes and improvements.

=

Download this release

Release Info

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

Code changes from version 2.0.15 to 2.0.16

inc/utils.php CHANGED
@@ -166,7 +166,8 @@ function ssb_fetch_shares_via_curl_multi( $data, $options = array() ) {
166
  }
167
 
168
  foreach ( $stats as $social_name => $counts ) {
169
- if ( 'totalshare' == $social_name || 'fblike' == $social_name || 'viber' == $social_name || 'whatsapp' == $social_name ) { continue; }
 
170
  $stats_counts = call_user_func( 'ssb_format_' . $social_name . '_response', $counts );
171
  $new_counts = $stats_counts + $networks[ $social_name];
172
  $stats_result[ $social_name ] = $new_counts;
@@ -202,7 +203,8 @@ function ssb_fetch_shares_via_curl_multi( $data, $options = array() ) {
202
  $stats_result = array();
203
  $networks = array();
204
  foreach ( $stats as $social_name => $counts ) {
205
- if ( 'totalshare' == $social_name || 'fblike' == $social_name || 'viber' == $social_name || 'whatsapp' == $social_name ) { continue; }
 
206
  $stats_counts = call_user_func( 'ssb_format_' . $social_name . '_response', $counts );
207
  $networks[ $social_name] = $stats_counts;
208
  }
166
  }
167
 
168
  foreach ( $stats as $social_name => $counts ) {
169
+ if ( 'totalshare' == $social_name || 'viber' == $social_name || 'fblike' == $social_name || 'whatsapp' == $social_name || 'print' == $social_name || 'email' == $social_name || 'messenger' == $social_name )
170
+ { continue; }
171
  $stats_counts = call_user_func( 'ssb_format_' . $social_name . '_response', $counts );
172
  $new_counts = $stats_counts + $networks[ $social_name];
173
  $stats_result[ $social_name ] = $new_counts;
203
  $stats_result = array();
204
  $networks = array();
205
  foreach ( $stats as $social_name => $counts ) {
206
+ if ( 'totalshare' == $social_name || 'viber' == $social_name || 'fblike' == $social_name || 'whatsapp' == $social_name || 'print' == $social_name || 'email' == $social_name || 'messenger' == $social_name )
207
+ { continue; }
208
  $stats_counts = call_user_func( 'ssb_format_' . $social_name . '_response', $counts );
209
  $networks[ $social_name] = $stats_counts;
210
  }
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.15
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -131,7 +131,7 @@ counter = true or false
131
  align = left or right or centered
132
  order = googleplus,twitter,pinterest,fbshare,linkedin,reddit,whatsapp,viber,fblike
133
  theme = theme1 or theme2 or theme3 or theme4 or Flat or Circle or Official
134
-
135
  == Screenshots ==
136
 
137
  1. Drag and Drop Social media buttons.
@@ -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.15 =
150
  * Please upgrade immediately. Releasing New features, few bugfixes and improvements.
151
 
152
 
153
  == Changelog ==
154
 
 
 
 
 
 
155
  = 2.0.15 - 2018-06-05 =
156
  * New Feature: Button show on excerpt content.
157
  * Bug Fix: Undefined $_SERVER['HTTP_USER_AGENT'] in function.
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.16
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
131
  align = left or right or centered
132
  order = googleplus,twitter,pinterest,fbshare,linkedin,reddit,whatsapp,viber,fblike
133
  theme = theme1 or theme2 or theme3 or theme4 or Flat or Circle or Official
134
+ like_button_size = small(default), large
135
  == Screenshots ==
136
 
137
  1. Drag and Drop Social media buttons.
146
 
147
  == Upgrade Notice ==
148
 
149
+ = 2.0.16 =
150
  * Please upgrade immediately. Releasing New features, few bugfixes and improvements.
151
 
152
 
153
  == Changelog ==
154
 
155
+ = 2.0.16 - 2018-07-09 =
156
+ * Improvement: Like button size parameter added in short code.
157
+ * Bug Fix: Illegal offset string.
158
+ * Bug Fix: Reddit Api Invalid argument supplied for foreach()
159
+
160
  = 2.0.15 - 2018-06-05 =
161
  * New Feature: Button show on excerpt content.
162
  * Bug Fix: Undefined $_SERVER['HTTP_USER_AGENT'] in function.
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.15
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.15';
34
  public $pluginPrefix = 'ssb_pr_';
35
  public $hideCustomMetaKey = '_ssb_hide';
36
  private $fb_app_id = '891268654262273';
@@ -162,7 +162,6 @@ class SimpleSocialButtonsPR {
162
  if ( 'totalshare' == $social_name || 'viber' == $social_name || 'fblike' == $social_name || 'whatsapp' == $social_name || 'print' == $social_name || 'email' == $social_name || 'messenger' == $social_name ) {
163
  continue; }
164
  $_share_links[ $social_name ] = call_user_func( 'ssb_' . $social_name . '_generate_link', get_permalink( $post_id ) );
165
- $url = $this->http_or_https_resolve_url( get_permalink( $post_id ) );
166
  }
167
  // http url convert to https or vice versa
168
  $_alt_share_links = $this->http_or_https_link_generate( get_permalink( $post_id ) );
@@ -549,6 +548,7 @@ class SimpleSocialButtonsPR {
549
  continue; }
550
  $_share_links[ $social_name ] = call_user_func( 'ssb_' . $social_name . '_generate_link', $permalink );
551
  }
 
552
  // http url convert to https or vice versa
553
  $_alt_share_links = $this->http_or_https_link_generate( $permalink );
554
 
@@ -990,7 +990,7 @@ class SimpleSocialButtonsPR {
990
  counter = true,false
991
  align = left ,right,centered,
992
  order = googleplus,twitter,pinterest,fbshare,linkedin,reddit,whatsapp,viber,fblike,messenger,email
993
-
994
  theme
995
  theme1 = sm-round
996
  theme2 = simple-round
@@ -1007,6 +1007,7 @@ class SimpleSocialButtonsPR {
1007
  'order' => null,
1008
  'align' => '',
1009
  'counter' => 'false',
 
1010
  ), $atts
1011
  );
1012
 
@@ -1060,9 +1061,12 @@ class SimpleSocialButtonsPR {
1060
  $show_count = false;
1061
  }
1062
 
 
 
 
1063
  $extra_class .= ' simplesocialbuttons-inline-' . $this->_get_settings( 'inline', 'animation', 'no-animation' );
1064
 
1065
- $ssb_buttons_code = $this->generate_buttons_short_code( $theme, $selected_theme['order'], $this->selected_networks, $show_count, $show_total, $extra_class );
1066
 
1067
  }
1068
 
@@ -1077,7 +1081,7 @@ class SimpleSocialButtonsPR {
1077
  *
1078
  * @param mixed $order - order of social buttons
1079
  */
1080
- function generate_buttons_short_code( $short_code_theme, $short_code_order, $order = null, $show_count = false, $show_total = false, $extra_class = '' ) {
1081
 
1082
  // googleplus,fbshare,twitter,pinterest,whatsapp,viber,reddit,linkedin,messenger,email,print
1083
  // define empty buttons code to use
@@ -1124,11 +1128,13 @@ class SimpleSocialButtonsPR {
1124
  // special case if post id not exist for example short code run on widget out side the loop in archive page and old counts not exsist
1125
  if ( 0 == $post_id ) {
1126
  $non_exist_post_record = get_option( 'ssb_not_exist_post_old_counts' );
 
1127
  }
1128
 
 
1129
  // Reset the cache timestamp if needed
1130
  // if false fetch the new share counts.
1131
- if ( ( isset( $this->settings['cache'] ) && $this->settings['cache'] == 'off' ) || ( ! $non_exist_post_record ) ) {
1132
 
1133
  $_share_links = array();
1134
  $_alt_share_links = array();
@@ -1137,14 +1143,11 @@ class SimpleSocialButtonsPR {
1137
  continue;
1138
  }
1139
  $_share_links[ $social_name ] = call_user_func( 'ssb_' . $social_name . '_generate_link', $permalink );
1140
- $url = $this->http_or_https_resolve_url( $permalink );
1141
- // get alt hurl to cover http or https issue
1142
- $_alt_share_links[ $social_name ] = call_user_func( 'ssb_' . $social_name . '_generate_link', $url );
1143
- }
1144
 
1145
- $result = ssb_fetch_shares_via_curl_multi( array_filter( $_share_links ) );
1146
-
1147
- $share_counts = ssb_fetch_fresh_counts( $result, $post_id, $_alt_share_links );
 
1148
  // update_post_meta( $post_id,'ssb_cache_timestamp',floor( ( ( date( 'U' ) / 60) / 60 ) ) );
1149
  } else {
1150
  $share_counts = ssb_fetch_cached_counts( array_flip( $arrButtons ), $post_id );
@@ -1313,7 +1316,6 @@ class SimpleSocialButtonsPR {
1313
  $_html .= '<span class="ssb_counter ssb_reddit_counter">' . $reddit_score . '</span>';
1314
  }
1315
  $_html .= '</button>';
1316
-
1317
  }
1318
 
1319
  $arrButtonsCode[] = $_html;
@@ -1343,8 +1345,7 @@ class SimpleSocialButtonsPR {
1343
  break;
1344
 
1345
  case 'fblike':
1346
- $_html = '<div class="fb-like ssb-fb-like" data-href="' . $permalink . '" data-layout="button_count" data-action="like" data-size="small" data-show-faces="false" data-share="false"></div>';
1347
-
1348
  $arrButtonsCode[] = $_html;
1349
 
1350
  break;
@@ -1613,7 +1614,7 @@ class SimpleSocialButtonsPR {
1613
  public function is_mobile() {
1614
 
1615
  $useragent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : 'none';
1616
-
1617
  if ( preg_match( '/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent ) || preg_match( '/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr( $useragent, 0, 4 ) ) ) {
1618
  return true;
1619
  } else {
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.16
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.16';
34
  public $pluginPrefix = 'ssb_pr_';
35
  public $hideCustomMetaKey = '_ssb_hide';
36
  private $fb_app_id = '891268654262273';
162
  if ( 'totalshare' == $social_name || 'viber' == $social_name || 'fblike' == $social_name || 'whatsapp' == $social_name || 'print' == $social_name || 'email' == $social_name || 'messenger' == $social_name ) {
163
  continue; }
164
  $_share_links[ $social_name ] = call_user_func( 'ssb_' . $social_name . '_generate_link', get_permalink( $post_id ) );
 
165
  }
166
  // http url convert to https or vice versa
167
  $_alt_share_links = $this->http_or_https_link_generate( get_permalink( $post_id ) );
548
  continue; }
549
  $_share_links[ $social_name ] = call_user_func( 'ssb_' . $social_name . '_generate_link', $permalink );
550
  }
551
+
552
  // http url convert to https or vice versa
553
  $_alt_share_links = $this->http_or_https_link_generate( $permalink );
554
 
990
  counter = true,false
991
  align = left ,right,centered,
992
  order = googleplus,twitter,pinterest,fbshare,linkedin,reddit,whatsapp,viber,fblike,messenger,email
993
+ like_button_size = small or large , Default small
994
  theme
995
  theme1 = sm-round
996
  theme2 = simple-round
1007
  'order' => null,
1008
  'align' => '',
1009
  'counter' => 'false',
1010
+ 'like_button_size' => 'small',
1011
  ), $atts
1012
  );
1013
 
1061
  $show_count = false;
1062
  }
1063
 
1064
+ //set fb like button size
1065
+ $like_button_size = $selected_theme['like_button_size'];
1066
+
1067
  $extra_class .= ' simplesocialbuttons-inline-' . $this->_get_settings( 'inline', 'animation', 'no-animation' );
1068
 
1069
+ $ssb_buttons_code = $this->generate_buttons_short_code( $theme, $like_button_size, $selected_theme['order'], $this->selected_networks, $show_count, $show_total, $extra_class );
1070
 
1071
  }
1072
 
1081
  *
1082
  * @param mixed $order - order of social buttons
1083
  */
1084
+ function generate_buttons_short_code( $short_code_theme, $like_button_size, $short_code_order, $order = null, $show_count = false, $show_total = false, $extra_class = '' ) {
1085
 
1086
  // googleplus,fbshare,twitter,pinterest,whatsapp,viber,reddit,linkedin,messenger,email,print
1087
  // define empty buttons code to use
1128
  // special case if post id not exist for example short code run on widget out side the loop in archive page and old counts not exsist
1129
  if ( 0 == $post_id ) {
1130
  $non_exist_post_record = get_option( 'ssb_not_exist_post_old_counts' );
1131
+ $non_exist_post_record = true;
1132
  }
1133
 
1134
+
1135
  // Reset the cache timestamp if needed
1136
  // if false fetch the new share counts.
1137
+ if ( ( isset( $this->settings['cache'] ) && $this->settings['cache'] == 'off' ) || ( $non_exist_post_record ) ) {
1138
 
1139
  $_share_links = array();
1140
  $_alt_share_links = array();
1143
  continue;
1144
  }
1145
  $_share_links[ $social_name ] = call_user_func( 'ssb_' . $social_name . '_generate_link', $permalink );
 
 
 
 
1146
 
1147
+ }
1148
+ $_alt_share_links = $this->http_or_https_link_generate( $permalink );
1149
+ $result = ssb_fetch_shares_via_curl_multi( array_filter( $_share_links ) );
1150
+ $share_counts = ssb_fetch_fresh_counts( $result, $post_id, $_alt_share_links );
1151
  // update_post_meta( $post_id,'ssb_cache_timestamp',floor( ( ( date( 'U' ) / 60) / 60 ) ) );
1152
  } else {
1153
  $share_counts = ssb_fetch_cached_counts( array_flip( $arrButtons ), $post_id );
1316
  $_html .= '<span class="ssb_counter ssb_reddit_counter">' . $reddit_score . '</span>';
1317
  }
1318
  $_html .= '</button>';
 
1319
  }
1320
 
1321
  $arrButtonsCode[] = $_html;
1345
  break;
1346
 
1347
  case 'fblike':
1348
+ $_html = '<div class="fb-like ssb-fb-like" data-href="' . $permalink . '" data-layout="button_count" data-action="like" data-size="'. $like_button_size .'" data-show-faces="false" data-share="false"></div>';
 
1349
  $arrButtonsCode[] = $_html;
1350
 
1351
  break;
1614
  public function is_mobile() {
1615
 
1616
  $useragent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : 'none';
1617
+
1618
  if ( preg_match( '/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent ) || preg_match( '/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr( $useragent, 0, 4 ) ) ) {
1619
  return true;
1620
  } else {
ssb-social-counts/reddit.php CHANGED
@@ -7,11 +7,21 @@ function ssb_reddit_generate_link( $url ) {
7
  }
8
 
9
 
 
10
  function ssb_format_reddit_response( $response ) {
11
  $response = json_decode( $response, true );
 
12
  $score = 0;
13
- foreach ( $response['data']['children'] as $child ) {
14
- $score += $child['data']['score'];
 
 
 
 
 
 
 
 
15
  }
16
 
17
  return $score;
7
  }
8
 
9
 
10
+
11
  function ssb_format_reddit_response( $response ) {
12
  $response = json_decode( $response, true );
13
+
14
  $score = 0;
15
+ // check data if data exist in respose and has length greater than 0.
16
+ if ( isset( $response['data']['children'] ) && count( $response['data']['children'] ) > 0 ) {
17
+ foreach ( $response['data']['children'] as $child ) {
18
+ // check score exist
19
+ if ( isset( $child['data']['score'] ) ) {
20
+
21
+ $score += $child['data']['score'];
22
+
23
+ }
24
+ }
25
  }
26
 
27
  return $score;