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

Version Description

  • Bugfix: fixed Share Buttons not generating links for posts in index and category pages
  • Enhancement: implemented debugging mode for server side share counts
Download this release

Release Info

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

Code changes from version 7.6.0.3 to 7.6.0.4

lib/social-share-counts/curl_multi_share_count.php CHANGED
@@ -87,6 +87,7 @@ class ShareaholicCurlMultiShareCount extends ShareaholicShareCount {
87
  if(is_numeric($counts)) {
88
  $response['data'][$service] = $counts;
89
  }
 
90
  curl_multi_remove_handle($multi_handle, $handle);
91
  curl_close($handle);
92
  }
@@ -98,6 +99,7 @@ class ShareaholicCurlMultiShareCount extends ShareaholicShareCount {
98
  private function curl_setopts($curl_handle, $config, $service) {
99
  // set the url to make the curl request
100
  curl_setopt($curl_handle, CURLOPT_URL, str_replace('%s', $this->url, $config[$service]['url']));
 
101
 
102
  // other necessary settings:
103
  // CURLOPT_HEADER means include header in output, which we do not want
@@ -105,7 +107,7 @@ class ShareaholicCurlMultiShareCount extends ShareaholicShareCount {
105
  curl_setopt_array($curl_handle, array(
106
  CURLOPT_HEADER => 0,
107
  CURLOPT_RETURNTRANSFER => 1,
108
- CURLOPT_TIMEOUT => 6,
109
  CURLOPT_SSL_VERIFYPEER => false,
110
  CURLOPT_SSL_VERIFYHOST => false,
111
  ));
87
  if(is_numeric($counts)) {
88
  $response['data'][$service] = $counts;
89
  }
90
+ $this->raw_response[$service] = $result;
91
  curl_multi_remove_handle($multi_handle, $handle);
92
  curl_close($handle);
93
  }
99
  private function curl_setopts($curl_handle, $config, $service) {
100
  // set the url to make the curl request
101
  curl_setopt($curl_handle, CURLOPT_URL, str_replace('%s', $this->url, $config[$service]['url']));
102
+ $timeout = isset($this->options['timeout']) ? $this->options['timeout'] : 6;
103
 
104
  // other necessary settings:
105
  // CURLOPT_HEADER means include header in output, which we do not want
107
  curl_setopt_array($curl_handle, array(
108
  CURLOPT_HEADER => 0,
109
  CURLOPT_RETURNTRANSFER => 1,
110
+ CURLOPT_TIMEOUT => $timeout,
111
  CURLOPT_SSL_VERIFYPEER => false,
112
  CURLOPT_SSL_VERIFYHOST => false,
113
  ));
lib/social-share-counts/seq_share_count.php CHANGED
@@ -47,9 +47,12 @@ class ShareaholicSeqShareCount extends ShareaholicShareCount {
47
  $this->$config[$service]['prepare']($this->url, $config);
48
  }
49
 
 
 
 
50
  $options = array(
51
  'method' => $config[$service]['method'],
52
- 'timeout' => 1,
53
  'headers' => isset($config[$service]['headers']) ? $config[$service]['headers'] : array(),
54
  'body' => isset($config[$service]['body']) ? $config[$service]['body'] : NULL,
55
  );
@@ -63,6 +66,7 @@ class ShareaholicSeqShareCount extends ShareaholicShareCount {
63
  if(is_numeric($counts)) {
64
  $response['data'][$service] = $counts;
65
  }
 
66
  }
67
  return $response;
68
  }
47
  $this->$config[$service]['prepare']($this->url, $config);
48
  }
49
 
50
+ $timeout = isset($config[$service]['timeout']) ? $config[$service]['timeout'] : 1;
51
+ $timeout = isset($this->options['timeout']) ? $this->options['timeout'] : $timeout;
52
+
53
  $options = array(
54
  'method' => $config[$service]['method'],
55
+ 'timeout' => $timeout,
56
  'headers' => isset($config[$service]['headers']) ? $config[$service]['headers'] : array(),
57
  'body' => isset($config[$service]['body']) ? $config[$service]['body'] : NULL,
58
  );
66
  if(is_numeric($counts)) {
67
  $response['data'][$service] = $counts;
68
  }
69
+ $this->raw_response[$service] = $result;
70
  }
71
  return $response;
72
  }
lib/social-share-counts/share_count.php CHANGED
@@ -17,14 +17,18 @@ abstract class ShareaholicShareCount {
17
 
18
  protected $url;
19
  protected $services;
 
 
20
 
21
- public function __construct($url, $services) {
22
  // encode the url if needed
23
  if (!$this->is_url_encoded($url)) {
24
  $url = urlencode($url);
25
  }
26
  $this->url = $url;
27
  $this->services = $services;
 
 
28
  }
29
 
30
  public static function get_services_config() {
17
 
18
  protected $url;
19
  protected $services;
20
+ protected $options;
21
+ public $raw_response;
22
 
23
+ public function __construct($url, $services, $options) {
24
  // encode the url if needed
25
  if (!$this->is_url_encoded($url)) {
26
  $url = urlencode($url);
27
  }
28
  $this->url = $url;
29
  $this->services = $services;
30
+ $this->options = $options;
31
+ $this->raw_response = array();
32
  }
33
 
34
  public static function get_services_config() {
public.php CHANGED
@@ -366,17 +366,22 @@ class ShareaholicPublic {
366
  public static function canvas($id, $app, $title = NULL, $link = NULL, $summary = NULL) {
367
  global $post, $wp_query;
368
  $page_type = ShareaholicUtilities::page_type();
369
- $is_post = $page_type == 'page' || $page_type == 'post';
 
370
 
371
  $link = trim($link);
372
 
373
- if (trim($title) == NULL && $is_post) {
 
 
 
 
374
  $title = htmlspecialchars($post->post_title, ENT_QUOTES);
375
  }
376
- if (trim($link) == NULL && $is_post) {
377
  $link = get_permalink($post->ID);
378
  }
379
- if (trim($summary) == NULL && $is_post) {
380
  $summary = htmlspecialchars(strip_tags(strip_shortcodes($post->post_excerpt)), ENT_QUOTES);
381
  }
382
 
@@ -396,23 +401,42 @@ class ShareaholicPublic {
396
  *
397
  */
398
  public static function share_counts_api() {
 
399
  $cache_key = 'shr_api_res-' . md5( $_SERVER['QUERY_STRING'] );
400
  $result = get_transient($cache_key);
 
401
 
402
- if (!$result) {
403
  $url = isset($_GET['url']) ? $_GET['url'] : NULL;
404
  $services = isset($_GET['services']) ? $_GET['services'] : NULL;
405
  $result = array();
 
 
 
 
 
406
 
407
  if(is_array($services) && count($services) > 0 && !empty($url)) {
408
- if(self::has_curl()) {
409
- $shares = new ShareaholicCurlMultiShareCount($url, $services);
 
 
 
 
 
 
410
  } else {
411
- $shares = new ShareaholicSeqShareCount($url, $services);
412
  }
413
  $result = $shares->get_counts();
414
 
415
- if (isset($result['data'])) {
 
 
 
 
 
 
416
  set_transient( $cache_key, $result, SHARE_COUNTS_CHECK_CACHE_LENGTH );
417
  }
418
  }
366
  public static function canvas($id, $app, $title = NULL, $link = NULL, $summary = NULL) {
367
  global $post, $wp_query;
368
  $page_type = ShareaholicUtilities::page_type();
369
+ $is_list_page = $page_type == 'index' || $page_type == 'category';
370
+ $in_loop = in_the_loop();
371
 
372
  $link = trim($link);
373
 
374
+ // Use the $post object to get the title, link, and summary only if the
375
+ // title, link or summary is not provided AND one of the following is true:
376
+ // - we are on a non list page
377
+ // - we are in the wordpress loop
378
+ if (trim($title) == NULL && (!$is_list_page || $in_loop)) {
379
  $title = htmlspecialchars($post->post_title, ENT_QUOTES);
380
  }
381
+ if (trim($link) == NULL && (!$is_list_page || $in_loop)) {
382
  $link = get_permalink($post->ID);
383
  }
384
+ if (trim($summary) == NULL && (!$is_list_page || $in_loop)) {
385
  $summary = htmlspecialchars(strip_tags(strip_shortcodes($post->post_excerpt)), ENT_QUOTES);
386
  }
387
 
401
  *
402
  */
403
  public static function share_counts_api() {
404
+ $debug_mode = isset($_GET['debug']) && $_GET['debug'] === '1';
405
  $cache_key = 'shr_api_res-' . md5( $_SERVER['QUERY_STRING'] );
406
  $result = get_transient($cache_key);
407
+ $has_curl_multi = self::has_curl();
408
 
409
+ if (!$result || $debug_mode) {
410
  $url = isset($_GET['url']) ? $_GET['url'] : NULL;
411
  $services = isset($_GET['services']) ? $_GET['services'] : NULL;
412
  $result = array();
413
+ $options = array();
414
+
415
+ if ($debug_mode && isset($_GET['timeout'])) {
416
+ $options['timeout'] = intval($_GET['timeout']);
417
+ }
418
 
419
  if(is_array($services) && count($services) > 0 && !empty($url)) {
420
+ if ($debug_mode && isset($_GET['client'])) {
421
+ if ($has_curl_multi && $_GET['client'] !== 'seq') {
422
+ $shares = new ShareaholicCurlMultiShareCount($url, $services, $options);
423
+ } else {
424
+ $shares = new ShareaholicSeqShareCount($url, $services, $options);
425
+ }
426
+ } else if($has_curl_multi) {
427
+ $shares = new ShareaholicCurlMultiShareCount($url, $services, $options);
428
  } else {
429
+ $shares = new ShareaholicSeqShareCount($url, $services, $options);
430
  }
431
  $result = $shares->get_counts();
432
 
433
+ if ($debug_mode) {
434
+ $result['has_curl_multi'] = $has_curl_multi;
435
+ $result['curl_type'] = get_class($shares);
436
+ $result['raw'] = $shares->raw_response;
437
+ }
438
+
439
+ if (isset($result['data']) && !$debug_mode) {
440
  set_transient( $cache_key, $result, SHARE_COUNTS_CHECK_CACHE_LENGTH );
441
  }
442
  }
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.0
6
- Stable tag: 7.6.0.3
7
 
8
  The easiest, most effective way to grow your website traffic, effectively engage your audience, monetize, and gain insights for free.
9
 
@@ -175,6 +175,10 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
175
 
176
  == Changelog ==
177
 
 
 
 
 
178
  = 7.6.0.3 =
179
  * Bugfix: fixed Share Buttons not grabbing correct content when placed in the sidebar
180
  * Updated "welcome" splash screen
@@ -1170,6 +1174,10 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
1170
 
1171
  == Upgrade Notice ==
1172
 
 
 
 
 
1173
  = 7.6.0.3 =
1174
 
1175
  Bug fixes
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.0
6
+ Stable tag: 7.6.0.4
7
 
8
  The easiest, most effective way to grow your website traffic, effectively engage your audience, monetize, and gain insights for free.
9
 
175
 
176
  == Changelog ==
177
 
178
+ = 7.6.0.4 =
179
+ * Bugfix: fixed Share Buttons not generating links for posts in index and category pages
180
+ * Enhancement: implemented debugging mode for server side share counts
181
+
182
  = 7.6.0.3 =
183
  * Bugfix: fixed Share Buttons not grabbing correct content when placed in the sidebar
184
  * Updated "welcome" splash screen
1174
 
1175
  == Upgrade Notice ==
1176
 
1177
+ = 7.6.0.4 =
1178
+
1179
+ Bug fixes
1180
+
1181
  = 7.6.0.3 =
1182
 
1183
  Bug fixes
shareaholic.php CHANGED
@@ -3,14 +3,14 @@
3
  * The main file!
4
  *
5
  * @package shareaholic
6
- * @version 7.6.0.3
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.3
14
  Author: Shareaholic
15
  Author URI: https://shareaholic.com
16
  Text Domain: shareaholic
@@ -63,7 +63,7 @@ if (!class_exists('Shareaholic')) {
63
  const CM_API_URL = 'https://cm-web.shareaholic.com'; // uses static IPs for firewall whitelisting
64
  const REC_API_URL = 'http://recommendations.shareaholic.com';
65
 
66
- const VERSION = '7.6.0.3';
67
 
68
  /**
69
  * Starts off as false so that ::get_instance() returns
3
  * The main file!
4
  *
5
  * @package shareaholic
6
+ * @version 7.6.0.4
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.4
14
  Author: Shareaholic
15
  Author URI: https://shareaholic.com
16
  Text Domain: shareaholic
63
  const CM_API_URL = 'https://cm-web.shareaholic.com'; // uses static IPs for firewall whitelisting
64
  const REC_API_URL = 'http://recommendations.shareaholic.com';
65
 
66
+ const VERSION = '7.6.0.4';
67
 
68
  /**
69
  * Starts off as false so that ::get_instance() returns