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

Version Description

  • Bugfix: Should fix most, if not all, lingering issues related to share buttons or related content not showing up!
  • Various performance improvements
Download this release

Release Info

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

Code changes from version 7.0.3.0 to 7.0.3.1

Files changed (5) hide show
  1. curl.php +23 -17
  2. readme.txt +8 -1
  3. shareaholic.php +3 -3
  4. six_to_seven.php +1 -1
  5. utilities.php +23 -11
curl.php CHANGED
@@ -18,28 +18,30 @@ class ShareaholicCurl {
18
  *
19
  * Performs a POST request
20
  *
21
- * @param string $url the url you are POSTing to
22
- * @param array $data an associative array of the data you are posting
23
- * @param string $data_type defaults to nothing, you can pass in 'json'
 
24
  *
25
  * @return array the returned data json decoded
26
  */
27
- public static function post($url, $data = array(), $data_type = '') {
28
- return self::send_request_with_wp($url, $data, $data_type, 'POST');
29
  }
30
 
31
  /**
32
  *
33
  * Performs a GET request
34
  *
35
- * @param string $url the url you are GETing to
36
- * @param array $data an associative array of the data you are posting
37
- * @param string $data_type defaults to nothing, you can pass in 'json'
 
38
  *
39
  * @return array the returned data json decoded
40
  */
41
- public static function get($url, $data = array(), $data_type = '') {
42
- return self::send_request_with_wp($url, $data, $data_type, 'GET');
43
  }
44
 
45
  /**
@@ -48,13 +50,14 @@ class ShareaholicCurl {
48
  * various PHP eccenctricities.
49
  *
50
  * @param string $url
51
- * @param array $data an associative array of the data
52
- * @param string $data_type either an empty string or 'json'
53
- * @param string $method the HTTP verb to be used
 
54
  *
55
  * @return mixed the returned data json decoded or false
56
  */
57
- private static function send_request_with_wp($url, $data, $data_type, $method) {
58
  ShareaholicUtilities::log($url);
59
  ShareaholicUtilities::log($data);
60
  ShareaholicUtilities::log($data_type);
@@ -78,9 +81,12 @@ class ShareaholicCurl {
78
  }
79
 
80
  if (is_wp_error($response)) {
81
- $error_message = $response->get_error_message();
82
- ShareaholicUtilities::log($error_message);
83
- return false;
 
 
 
84
  }
85
  else {
86
  if(is_array($response) && array_key_exists('body', $response)) {
18
  *
19
  * Performs a POST request
20
  *
21
+ * @param string $url the url you are POSTing to
22
+ * @param array $data an associative array of the data you are posting
23
+ * @param string $data_type defaults to nothing, you can pass in 'json'
24
+ * @param bool $ignore_error whether to log a networking error
25
  *
26
  * @return array the returned data json decoded
27
  */
28
+ public static function post($url, $data = array(), $data_type = '', $ignore_error = false) {
29
+ return self::send_request_with_wp($url, $data, $data_type, $ignore_error, 'POST');
30
  }
31
 
32
  /**
33
  *
34
  * Performs a GET request
35
  *
36
+ * @param string $url the url you are GETing to
37
+ * @param array $data an associative array of the data you are posting
38
+ * @param string $data_type defaults to nothing, you can pass in 'json'
39
+ * @param bool $ignore_error whether to log a networking error
40
  *
41
  * @return array the returned data json decoded
42
  */
43
+ public static function get($url, $data = array(), $data_type = '', $ignore_error = false) {
44
+ return self::send_request_with_wp($url, $data, $data_type, $ignore_error, 'GET');
45
  }
46
 
47
  /**
50
  * various PHP eccenctricities.
51
  *
52
  * @param string $url
53
+ * @param array $data an associative array of the data
54
+ * @param string $data_type either an empty string or 'json'
55
+ * @param bool $ignore_error whether to log a networking error
56
+ * @param string $method the HTTP verb to be used
57
  *
58
  * @return mixed the returned data json decoded or false
59
  */
60
+ private static function send_request_with_wp($url, $data, $data_type, $ignore_error, $method) {
61
  ShareaholicUtilities::log($url);
62
  ShareaholicUtilities::log($data);
63
  ShareaholicUtilities::log($data_type);
81
  }
82
 
83
  if (is_wp_error($response)) {
84
+ $error_message = $response->get_error_message();
85
+ ShareaholicUtilities::log($error_message);
86
+ if (!$ignore_error) {
87
+ ShareaholicUtilities::log_event('CurlRequestFailure', array('error_message' => $error_message));
88
+ }
89
+ return false;
90
  }
91
  else {
92
  if(is_array($response) && array_key_exists('body', $response)) {
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, tweet button, twitter button, fark, buffer, myspace, orkut, netlog, hubspot, weheartit, printfriendly, yammer, 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, shortcode, yaarp, yarpp, nrelate, outbrain, linkwithin, related content, related posts, related, popular posts, popular, thumbnails, recommendations
4
  Requires at least: 2.7
5
  Tested up to: 3.5.2
6
- Stable tag: 7.0.3.0
7
 
8
  Adds an attractive social bookmarking menu and related content widget to your posts, pages, index, or any combination of the three.
9
 
@@ -141,6 +141,10 @@ Please see here: [Usage & Installation Instructions](https://shareaholic.com/too
141
 
142
  == Changelog ==
143
 
 
 
 
 
144
  = 7.0.3.0 =
145
  * New feature: You can now center, left AND right align your share buttons!
146
  * New feature: Added support for *custom headers* for share buttons! ([How-To Instructions](http://support.shareaholic.com/entries/24846703-How-to-use-a-custom-Header-image))
@@ -892,6 +896,9 @@ Please see here: [Usage & Installation Instructions](https://shareaholic.com/too
892
 
893
  == Upgrade Notice ==
894
 
 
 
 
895
  = 7.0.3.0 =
896
  Lots of new features! You can now center, left and right align your share buttons, use custom headers, toggle the "more options" button, various bug fixes, performance improvements and more.
897
 
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, tweet button, twitter button, fark, buffer, myspace, orkut, netlog, hubspot, weheartit, printfriendly, yammer, 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, shortcode, yaarp, yarpp, nrelate, outbrain, linkwithin, related content, related posts, related, popular posts, popular, thumbnails, recommendations
4
  Requires at least: 2.7
5
  Tested up to: 3.5.2
6
+ Stable tag: 7.0.3.1
7
 
8
  Adds an attractive social bookmarking menu and related content widget to your posts, pages, index, or any combination of the three.
9
 
141
 
142
  == Changelog ==
143
 
144
+ = 7.0.3.1 =
145
+ * Bugfix: Should fix most, if not all, lingering issues related to share buttons or related content not showing up!
146
+ * Various performance improvements
147
+
148
  = 7.0.3.0 =
149
  * New feature: You can now center, left AND right align your share buttons!
150
  * New feature: Added support for *custom headers* for share buttons! ([How-To Instructions](http://support.shareaholic.com/entries/24846703-How-to-use-a-custom-Header-image))
896
 
897
  == Upgrade Notice ==
898
 
899
+ = 7.0.3.1 =
900
+ This is a highly recommended upgrade. Should fix most, if not all, lingering issues related to share buttons and related content apps not showing on webpages.
901
+
902
  = 7.0.3.0 =
903
  Lots of new features! You can now center, left and right align your share buttons, use custom headers, toggle the "more options" button, various bug fixes, performance improvements and more.
904
 
shareaholic.php CHANGED
@@ -3,14 +3,14 @@
3
  * The main and first file!
4
  *
5
  * @package shareaholic
6
- * @version 7.0.3.0
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.0.3.0
14
  Author: Shareaholic
15
  Author URI: https://shareaholic.com
16
  Credits & Thanks: https://shareaholic.com/tools/wordpress/credits
@@ -43,7 +43,7 @@ require_once(SHAREAHOLIC_DIR . '/deprecation.php');
43
  */
44
  class Shareaholic {
45
  const URL = 'https://shareaholic.com';
46
- const VERSION = '7.0.3.0';
47
  /**
48
  * Starts off as false so that ::get_instance() returns
49
  * a new instance.
3
  * The main and first file!
4
  *
5
  * @package shareaholic
6
+ * @version 7.0.3.1
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.0.3.1
14
  Author: Shareaholic
15
  Author URI: https://shareaholic.com
16
  Credits & Thanks: https://shareaholic.com/tools/wordpress/credits
43
  */
44
  class Shareaholic {
45
  const URL = 'https://shareaholic.com';
46
+ const VERSION = '7.0.3.1';
47
  /**
48
  * Starts off as false so that ::get_instance() returns
49
  * a new instance.
six_to_seven.php CHANGED
@@ -65,7 +65,7 @@ class ShareaholicSixToSeven {
65
  'configuration_publisher' => array(
66
  'share_buttons_attributes' => $new_share_buttons_configuration,
67
  'recommendations_attributes' => $new_recommendations_configuration,
68
- 'site_name' => get_bloginfo('name'),
69
  'domain' => ShareaholicUtilities::site_url(),
70
  'verification_key' => $verification_key,
71
  'platform' => 'wordpress'
65
  'configuration_publisher' => array(
66
  'share_buttons_attributes' => $new_share_buttons_configuration,
67
  'recommendations_attributes' => $new_recommendations_configuration,
68
+ 'site_name' => ShareaholicUtilities::site_name(),
69
  'domain' => ShareaholicUtilities::site_url(),
70
  'verification_key' => $verification_key,
71
  'platform' => 'wordpress'
utilities.php CHANGED
@@ -310,9 +310,9 @@ class ShareaholicUtilities {
310
  if (preg_match('/spreadaholic/', Shareaholic::URL)) {
311
  return "http://spreadaholic.com:8080/assets-development/" . $asset;
312
  } elseif (preg_match('/staging\.shareaholic/', Shareaholic::URL)) {
313
- return '//dtym7iokkjlif.cloudfront.net/assets-staging/' . $asset;
314
  } else {
315
- return '//dtym7iokkjlif.cloudfront.net/assets/' . $asset;
316
  }
317
  }
318
 
@@ -455,23 +455,33 @@ class ShareaholicUtilities {
455
 
456
  /**
457
  * Returns the api key or creates a new one.
 
 
 
 
 
 
 
 
 
 
458
  */
459
  public static function get_or_create_api_key() {
 
 
 
 
 
460
  if (!self::is_locked('get_or_create_api_key')) {
461
  self::set_lock('get_or_create_api_key');
462
 
463
- $settings = self::get_settings();
464
- if (isset($settings['api_key']) && !empty($settings['api_key'])) {
465
- self::unlock('get_or_create_api_key');
466
- return $settings['api_key'];
467
- }
468
  delete_option('shareaholic_settings');
469
 
470
  $verification_key = md5(mt_rand());
471
  $response = ShareaholicCurl::post(Shareaholic::URL . '/publisher_tools/anonymous', array(
472
  'configuration_publisher' => array(
473
  'verification_key' => $verification_key,
474
- 'site_name' => get_bloginfo('name'),
475
  'domain' => self::site_url(),
476
  'platform' => 'wordpress',
477
  'shortener' => 'shrlc',
@@ -532,8 +542,6 @@ class ShareaholicUtilities {
532
  } elseif ($response && !is_array($response)) {
533
  $thing = preg_replace('/\n/', '', var_export($response, true));
534
  ShareaholicUtilities::log_event($name, array('reason' => 'the publisher configuration was not an array, it was this ' . $thing));
535
- } elseif (!$response) {
536
- ShareaholicUtilities::log_event($name, array('reason' => 'the response was false, meaning that some sort of error occured'));
537
  }
538
  }
539
 
@@ -546,6 +554,10 @@ class ShareaholicUtilities {
546
  return preg_replace('/https?:\/\//', '', site_url());
547
  }
548
 
 
 
 
 
549
  /**
550
  * Shockingly the built in PHP array_merge_recursive function is stupid.
551
  * this is stolen from the PHP docs and will overwrite existing keys instead
@@ -647,7 +659,7 @@ class ShareaholicUtilities {
647
  $event_api_url = Shareaholic::URL . '/api/events';
648
  $event_params = array('name' => "WordPress:".$event_name, 'data' => json_encode($event_metadata) );
649
 
650
- $response = ShareaholicCurl::post($event_api_url, $event_params);
651
  }
652
 
653
  /**
310
  if (preg_match('/spreadaholic/', Shareaholic::URL)) {
311
  return "http://spreadaholic.com:8080/assets-development/" . $asset;
312
  } elseif (preg_match('/staging\.shareaholic/', Shareaholic::URL)) {
313
+ return 'https://dsms0mj1bbhn4.cloudfront.net/assets-staging/' . $asset;
314
  } else {
315
+ return 'https://dsms0mj1bbhn4.cloudfront.net/assets/' . $asset;
316
  }
317
  }
318
 
455
 
456
  /**
457
  * Returns the api key or creates a new one.
458
+ *
459
+ * It first checks the database. If the key is not
460
+ * found (or is an empty string or empty array or
461
+ * anything that evaluates to false) then we will
462
+ * attempt to make a new one by POSTing to the
463
+ * anonymous configuration endpoint. That action
464
+ * is wrapped in a mutex to keep two requests from
465
+ * trying to create new api keys at the same time.
466
+ *
467
+ * @return string
468
  */
469
  public static function get_or_create_api_key() {
470
+ $api_key = self::get_option('api_key');
471
+ if ($api_key) {
472
+ return $api_key;
473
+ }
474
+
475
  if (!self::is_locked('get_or_create_api_key')) {
476
  self::set_lock('get_or_create_api_key');
477
 
 
 
 
 
 
478
  delete_option('shareaholic_settings');
479
 
480
  $verification_key = md5(mt_rand());
481
  $response = ShareaholicCurl::post(Shareaholic::URL . '/publisher_tools/anonymous', array(
482
  'configuration_publisher' => array(
483
  'verification_key' => $verification_key,
484
+ 'site_name' => self::site_name(),
485
  'domain' => self::site_url(),
486
  'platform' => 'wordpress',
487
  'shortener' => 'shrlc',
542
  } elseif ($response && !is_array($response)) {
543
  $thing = preg_replace('/\n/', '', var_export($response, true));
544
  ShareaholicUtilities::log_event($name, array('reason' => 'the publisher configuration was not an array, it was this ' . $thing));
 
 
545
  }
546
  }
547
 
554
  return preg_replace('/https?:\/\//', '', site_url());
555
  }
556
 
557
+ public static function site_name() {
558
+ get_bloginfo('name') ? get_bloginfo('name') : site_url();
559
+ }
560
+
561
  /**
562
  * Shockingly the built in PHP array_merge_recursive function is stupid.
563
  * this is stolen from the PHP docs and will overwrite existing keys instead
659
  $event_api_url = Shareaholic::URL . '/api/events';
660
  $event_params = array('name' => "WordPress:".$event_name, 'data' => json_encode($event_metadata) );
661
 
662
+ $response = ShareaholicCurl::post($event_api_url, $event_params, '', true);
663
  }
664
 
665
  /**