WordPress Social Tools, Related Posts, Monetization – Shareaholic - Version 7.6.0.9

Version Description

  • Bugfix: Added isset checks for undefined indexes being thrown
  • Bugfix: Parse out BOM character from HTTP responses
Download this release

Release Info

Developer hngu_shareaholic
Plugin Icon 128x128 WordPress Social Tools, Related Posts, Monetization – Shareaholic
Version 7.6.0.9
Comparing to
See all releases

Code changes from version 7.6.0.8 to 7.6.0.9

Files changed (4) hide show
  1. curl.php +25 -0
  2. readme.txt +8 -1
  3. shareaholic.php +3 -3
  4. utilities.php +17 -22
curl.php CHANGED
@@ -94,6 +94,10 @@ class ShareaholicCurl {
94
  else {
95
  if(is_array($response) && array_key_exists('body', $response)) {
96
  $body = $response['body'];
 
 
 
 
97
  $response['body'] = ShareaholicUtilities::object_to_array(json_decode($body)) ?
98
  ShareaholicUtilities::object_to_array(json_decode($body)) : $body;
99
  return $response;
@@ -206,6 +210,27 @@ class ShareaholicCurl {
206
  return false;
207
  }
208
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
210
 
211
  ?>
94
  else {
95
  if(is_array($response) && array_key_exists('body', $response)) {
96
  $body = $response['body'];
97
+
98
+ // strip out any BOM appended characters
99
+ $body = self::strip_utf8_bom($body);
100
+
101
  $response['body'] = ShareaholicUtilities::object_to_array(json_decode($body)) ?
102
  ShareaholicUtilities::object_to_array(json_decode($body)) : $body;
103
  return $response;
210
  return false;
211
  }
212
  }
213
+
214
+ /**
215
+ * Sometimes the response from APIs begins with BOM (byte order mark) which
216
+ * makes it difficult to parse JSON responses.
217
+ *
218
+ * If it exists, remove it and return the cleaned up string
219
+ *
220
+ * @param {String} $str the string to strip BOM
221
+ * @return {String} the stripped out string if BOM exists
222
+ */
223
+ private static function strip_utf8_bom($str) {
224
+ // create binary string for BOM
225
+ $bom = pack("CCC", 0xef, 0xbb, 0xbf);
226
+
227
+ // binary safe compare the BOM with the string
228
+ if (0 === strncmp($str, $bom, 3)) {
229
+ return substr($str, 3);
230
+ }
231
+
232
+ return $str;
233
+ }
234
  }
235
 
236
  ?>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: shareaholic
3
  Tags: sexybookmarks, shareaholic, shareholic, facebook, twitter, linkedin, URL Shortener, bitly, tinyurl, Goo.gl, Google+1, Google Analytics, Google Plus, Google, Instapaper, Wish List, Digg, Gmail, Google Bookmarks, Translate, Tumblr, AIM, Yahoo Messenger, Delicious, StumbleUpon, mister wong, evernote, add this, addtoany, share this, sharethis, share and follow, share and enjoy, sharing is sexy, sharing is caring, yahoo, reddit, hackernews, houzz, yummly, tweet button, twitter button, fark, buffer, myspace, orkut, netlog, hubspot, weheartit, printfriendly, yammer, wanelo, pinterest, google translate, bookmarks, social, email button, social share, socialize, sociable, sharebar, bookmark button, share button, social bookmarking, bookmarks menu, bookmarking, share, seo, analytics, stats, sharing, facebook like, facebook recommend, WPMU, mutisite, sumome, shortcode, yaarp, yarpp, nrelate, outbrain, linkwithin, related content, related posts, related, popular posts, popular, thumbnails, recommendations
4
  Requires at least: 3.0
5
  Tested up to: 4.1
6
- Stable tag: 7.6.0.8
7
 
8
  The easiest, most effective way to grow your website traffic, effectively engage your audience, monetize, and gain insights for free.
9
 
@@ -169,6 +169,10 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
169
 
170
  == Changelog ==
171
 
 
 
 
 
172
  = 7.6.0.8 =
173
  * Enhancement: Added Google API key to authenticate API calls for Google Plus share counts for improved the reliability
174
 
@@ -1184,6 +1188,9 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
1184
 
1185
  == Upgrade Notice ==
1186
 
 
 
 
1187
  = 7.6.0.8 =
1188
  Added Google API key to authenticate API calls for Google Plus share counts for improved the reliability
1189
 
3
  Tags: sexybookmarks, shareaholic, shareholic, facebook, twitter, linkedin, URL Shortener, bitly, tinyurl, Goo.gl, Google+1, Google Analytics, Google Plus, Google, Instapaper, Wish List, Digg, Gmail, Google Bookmarks, Translate, Tumblr, AIM, Yahoo Messenger, Delicious, StumbleUpon, mister wong, evernote, add this, addtoany, share this, sharethis, share and follow, share and enjoy, sharing is sexy, sharing is caring, yahoo, reddit, hackernews, houzz, yummly, tweet button, twitter button, fark, buffer, myspace, orkut, netlog, hubspot, weheartit, printfriendly, yammer, wanelo, pinterest, google translate, bookmarks, social, email button, social share, socialize, sociable, sharebar, bookmark button, share button, social bookmarking, bookmarks menu, bookmarking, share, seo, analytics, stats, sharing, facebook like, facebook recommend, WPMU, mutisite, sumome, shortcode, yaarp, yarpp, nrelate, outbrain, linkwithin, related content, related posts, related, popular posts, popular, thumbnails, recommendations
4
  Requires at least: 3.0
5
  Tested up to: 4.1
6
+ Stable tag: 7.6.0.9
7
 
8
  The easiest, most effective way to grow your website traffic, effectively engage your audience, monetize, and gain insights for free.
9
 
169
 
170
  == Changelog ==
171
 
172
+ = 7.6.0.9 =
173
+ * Bugfix: Added isset checks for undefined indexes being thrown
174
+ * Bugfix: Parse out BOM character from HTTP responses
175
+
176
  = 7.6.0.8 =
177
  * Enhancement: Added Google API key to authenticate API calls for Google Plus share counts for improved the reliability
178
 
1188
 
1189
  == Upgrade Notice ==
1190
 
1191
+ = 7.6.0.9 =
1192
+ Many improvements and bug fixes.
1193
+
1194
  = 7.6.0.8 =
1195
  Added Google API key to authenticate API calls for Google Plus share counts for improved the reliability
1196
 
shareaholic.php CHANGED
@@ -3,14 +3,14 @@
3
  * The main file!
4
  *
5
  * @package shareaholic
6
- * @version 7.6.0.8
7
  */
8
 
9
  /*
10
  Plugin Name: Shareaholic | share buttons, analytics, related content
11
  Plugin URI: https://shareaholic.com/publishers/
12
  Description: Whether you want to get people sharing, grow your fans, make money, or know who's reading your content, Shareaholic will help you get it done. See <a href="admin.php?page=shareaholic-settings">configuration panel</a> for more settings.
13
- Version: 7.6.0.8
14
  Author: Shareaholic
15
  Author URI: https://shareaholic.com
16
  Text Domain: shareaholic
@@ -64,7 +64,7 @@ if (!class_exists('Shareaholic')) {
64
  const CM_API_URL = 'https://cm-web.shareaholic.com'; // uses static IPs for firewall whitelisting
65
  const REC_API_URL = 'http://recommendations.shareaholic.com';
66
 
67
- const VERSION = '7.6.0.8';
68
 
69
  /**
70
  * Starts off as false so that ::get_instance() returns
3
  * The main file!
4
  *
5
  * @package shareaholic
6
+ * @version 7.6.0.9
7
  */
8
 
9
  /*
10
  Plugin Name: Shareaholic | share buttons, analytics, related content
11
  Plugin URI: https://shareaholic.com/publishers/
12
  Description: Whether you want to get people sharing, grow your fans, make money, or know who's reading your content, Shareaholic will help you get it done. See <a href="admin.php?page=shareaholic-settings">configuration panel</a> for more settings.
13
+ Version: 7.6.0.9
14
  Author: Shareaholic
15
  Author URI: https://shareaholic.com
16
  Text Domain: shareaholic
64
  const CM_API_URL = 'https://cm-web.shareaholic.com'; // uses static IPs for firewall whitelisting
65
  const REC_API_URL = 'http://recommendations.shareaholic.com';
66
 
67
+ const VERSION = '7.6.0.9';
68
 
69
  /**
70
  * Starts off as false so that ::get_instance() returns
utilities.php CHANGED
@@ -1204,7 +1204,7 @@ class ShareaholicUtilities {
1204
  *
1205
  */
1206
  public static function share_counts_api_connectivity_check() {
1207
-
1208
  // if we already checked and it is successful, then do not call the API again
1209
  $share_counts_connect_check = self::get_option('share_counts_connect_check');
1210
  if (isset($share_counts_connect_check) && $share_counts_connect_check == 'SUCCESS') {
@@ -1299,30 +1299,25 @@ class ShareaholicUtilities {
1299
  return array();
1300
  }
1301
 
1302
- $capabilities = $current_user->get_role_caps();
1303
- $roles = $current_user->roles;
1304
 
1305
- return array(
 
 
 
 
 
 
 
1306
  'roles' => $current_user->roles,
1307
- 'capabilities' => array(
1308
- 'switch_themes' => $capabilities['switch_themes'],
1309
- 'edit_themes' => $capabilities['edit_themes'],
1310
- 'activate_plugins' => $capabilities['activate_plugins'],
1311
- 'edit_plugins' => $capabilities['edit_plugins'],
1312
- 'manage_options' => $capabilities['manage_options'],
1313
- 'unfiltered_html' => $capabilities['unfiltered_html'],
1314
- 'edit_dashboard' => $capabilities['edit_dashboard'],
1315
- 'update_plugins' => $capabilities['update_plugins'],
1316
- 'delete_plugins' => $capabilities['delete_plugins'],
1317
- 'install_plugins' => $capabilities['install_plugins'],
1318
- 'update_themes' => $capabilities['update_themes'],
1319
- 'install_themes' => $capabilities['install_themes'],
1320
- 'update_core' => $capabilities['update_core'],
1321
- 'edit_theme_options' => $capabilities['edit_theme_options'],
1322
- 'delete_themes' => $capabilities['delete_themes'],
1323
- 'administrator' => $capabilities['administrator']
1324
- ),
1325
  'is_super_admin' => is_super_admin()
1326
  );
 
 
 
 
 
 
1327
  }
1328
  }
1204
  *
1205
  */
1206
  public static function share_counts_api_connectivity_check() {
1207
+
1208
  // if we already checked and it is successful, then do not call the API again
1209
  $share_counts_connect_check = self::get_option('share_counts_connect_check');
1210
  if (isset($share_counts_connect_check) && $share_counts_connect_check == 'SUCCESS') {
1299
  return array();
1300
  }
1301
 
1302
+ $user_caps = $current_user->get_role_caps();
 
1303
 
1304
+ $caps = array('switch_themes', 'edit_themes', 'activate_plugins',
1305
+ 'edit_plugins', 'manage_options', 'unfiltered_html', 'edit_dashboard',
1306
+ 'update_plugins', 'delete_plugins', 'install_plugins', 'update_themes',
1307
+ 'install_themes', 'update_core', 'edit_theme_options', 'delete_themes',
1308
+ 'administrator'
1309
+ );
1310
+
1311
+ $user_info = array(
1312
  'roles' => $current_user->roles,
1313
+ 'capabilities' => array(),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1314
  'is_super_admin' => is_super_admin()
1315
  );
1316
+
1317
+ foreach($caps as $cap) {
1318
+ $user_info['capabilities'][$cap] = isset($user_caps[$cap]) ? $user_caps[$cap] : '';
1319
+ }
1320
+
1321
+ return $user_info;
1322
  }
1323
  }