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

Version Description

  • Bugfix: limit the summary data attribute to at most 500 characters
  • Enhancement: present a plugin review notice to WP admins
Download this release

Release Info

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

Code changes from version 7.6.2.2 to 7.6.2.3

Files changed (5) hide show
  1. admin.php +61 -0
  2. public.php +1 -0
  3. readme.txt +9 -1
  4. shareaholic.php +3 -3
  5. utilities.php +23 -0
admin.php CHANGED
@@ -11,6 +11,10 @@
11
  * @package shareaholic
12
  */
13
  class ShareaholicAdmin {
 
 
 
 
14
 
15
  /**
16
  * Loads before all else
@@ -25,6 +29,63 @@ class ShareaholicAdmin {
25
  ShareaholicUtilities::share_counts_api_connectivity_check();
26
  }
27
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
 
30
  /**
11
  * @package shareaholic
12
  */
13
  class ShareaholicAdmin {
14
+
15
+ const ACTIVATE_TIMESTAMP_OPTION = 'shareaholic_activate_timestamp';
16
+ const REVIEW_PERIOD = 1296000; // 15 days in seconds
17
+ const REVIEW_DISMISS_OPTION = 'shareaholic_review_dismiss';
18
 
19
  /**
20
  * Loads before all else
29
  ShareaholicUtilities::share_counts_api_connectivity_check();
30
  }
31
  }
32
+ self::check_review_dismissal();
33
+ self::check_plugin_review();
34
+ }
35
+
36
+ /**
37
+ * Check if the user has dismissed the review message
38
+ *
39
+ */
40
+ public static function check_review_dismissal() {
41
+ if (!is_admin() ||
42
+ !current_user_can('manage_options') ||
43
+ !isset($_GET['_wpnonce']) ||
44
+ !wp_verify_nonce($_GET['_wpnonce'], 'review-nonce') ||
45
+ !isset($_GET[self::REVIEW_DISMISS_OPTION])) {
46
+ return;
47
+ }
48
+
49
+ add_site_option(self::REVIEW_DISMISS_OPTION, true);
50
+ }
51
+
52
+ /**
53
+ * Check if we should display the review message days after the
54
+ * plugin has been activated
55
+ *
56
+ */
57
+ public static function check_plugin_review() {
58
+ $activation_timestamp = get_site_option(self::ACTIVATE_TIMESTAMP_OPTION);
59
+ $review_dismissal = get_site_option(self::REVIEW_DISMISS_OPTION);
60
+
61
+ if ($review_dismissal == true) {
62
+ return;
63
+ }
64
+
65
+ if (!$activation_timestamp) {
66
+ $activation_timestamp = time();
67
+ add_site_option(self::ACTIVATE_TIMESTAMP_OPTION, $activation_timestamp);
68
+ }
69
+
70
+ // display review message after a certain period of time after activation
71
+ if (time() - $activation_timestamp > self::REVIEW_PERIOD) {
72
+ add_action('admin_notices', array('ShareaholicAdmin', 'display_review_notice'));
73
+ }
74
+ }
75
+
76
+ public static function display_review_notice() {
77
+ $dismiss_url = wp_nonce_url('?'. self::REVIEW_DISMISS_OPTION .'=true', 'review-nonce');
78
+
79
+ echo '
80
+ <div class="updated">
81
+ <p>' . __('You have been using the ', 'shareaholic') . '<a href="' . admin_url('admin.php?page=shareaholic-settings') . '">Shareaholic plugin</a>' . __(' for some time now, do you like it? If so, please consider leaving us a review on WordPress.org! It would help us out a lot and we would really appreciate it.', 'shareaholic') . '
82
+ <br />
83
+ <br />
84
+ <a onclick="location.href=\'' . esc_url($dismiss_url) . '\';" class="button button-primary" href="' . esc_url('https://wordpress.org/support/view/plugin-reviews/shareaholic?rate=5#postform') . '" target="_blank">' . __('Leave a Review', 'shareaholic') . '</a>
85
+ <a href="' . esc_url($dismiss_url) . '">' . __('No thanks', 'shareaholic') . '</a>
86
+ </p>
87
+ </div>';
88
+
89
  }
90
 
91
  /**
public.php CHANGED
@@ -379,6 +379,7 @@ class ShareaholicPublic {
379
  }
380
  if (trim($summary) == NULL && (!$is_list_page || $in_loop)) {
381
  $summary = htmlspecialchars(strip_tags(strip_shortcodes($post->post_excerpt)), ENT_QUOTES);
 
382
  }
383
 
384
  $canvas = "<div class='shareaholic-canvas'
379
  }
380
  if (trim($summary) == NULL && (!$is_list_page || $in_loop)) {
381
  $summary = htmlspecialchars(strip_tags(strip_shortcodes($post->post_excerpt)), ENT_QUOTES);
382
+ $summary = ShareaholicUtilities::truncate_text($summary, 500);
383
  }
384
 
385
  $canvas = "<div class='shareaholic-canvas'
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: shareaholic
3
  Tags: shareaholic, shareholic, sexybookmarks, recommendations, related content, cookie consent, share buttons, email button, social sharing, social bookmarking, share image, image sharing, follow buttons, floated share buttons, floating share buttons, analytics, social media, social plugin, facebook, twitter, google plus, google bookmarks, gmail, linkedin, pinterest, reddit, tumblr, evernote, digg, delicious, stumbleupon, printfriendly, fancy, amazon, xing, vk, yahoo, mister wong, viadeo, odnoklassniki box.net, diigo, yammer, ycombinator, hotmail, instapaper, mixi, arto, whatsapp, hootsuite, inbound.org, plurk, aim, buffer, meneame, pinboard.in, stumpedia, bitly, blogger, yummly, izeby, kaboodle, weibo, instagram, tinyurl, typepad, weheartit, flipboard, pocket, wanelo, fark, wykop, symphony, kindle, houzz, youtube, sms, onenote
4
  Requires at least: 3.0
5
  Tested up to: 4.3.1
6
- Stable tag: 7.6.2.2
7
 
8
  The easiest, most effective way to grow your website traffic, effectively engage your audience, monetize, and gain insights for free.
9
 
@@ -170,6 +170,10 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
170
 
171
  == Changelog ==
172
 
 
 
 
 
173
  = 7.6.2.2 =
174
  * Enhancement: updated Shareaholic JavaScript snippet - now a lot simpler!
175
  * Bugfix: added hooks to prevent conflicts with Shortcode UI plugin
@@ -1229,6 +1233,10 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
1229
 
1230
  == Upgrade Notice ==
1231
 
 
 
 
 
1232
  = 7.6.2.2 =
1233
  * Enhancement: updated Shareaholic JavaScript snippet - now a lot simpler!
1234
  * Bugfix: added hooks to prevent conflicts with Shortcode UI plugin
3
  Tags: shareaholic, shareholic, sexybookmarks, recommendations, related content, cookie consent, share buttons, email button, social sharing, social bookmarking, share image, image sharing, follow buttons, floated share buttons, floating share buttons, analytics, social media, social plugin, facebook, twitter, google plus, google bookmarks, gmail, linkedin, pinterest, reddit, tumblr, evernote, digg, delicious, stumbleupon, printfriendly, fancy, amazon, xing, vk, yahoo, mister wong, viadeo, odnoklassniki box.net, diigo, yammer, ycombinator, hotmail, instapaper, mixi, arto, whatsapp, hootsuite, inbound.org, plurk, aim, buffer, meneame, pinboard.in, stumpedia, bitly, blogger, yummly, izeby, kaboodle, weibo, instagram, tinyurl, typepad, weheartit, flipboard, pocket, wanelo, fark, wykop, symphony, kindle, houzz, youtube, sms, onenote
4
  Requires at least: 3.0
5
  Tested up to: 4.3.1
6
+ Stable tag: 7.6.2.3
7
 
8
  The easiest, most effective way to grow your website traffic, effectively engage your audience, monetize, and gain insights for free.
9
 
170
 
171
  == Changelog ==
172
 
173
+ = 7.6.2.3 =
174
+ * Bugfix: limit the summary data attribute to at most 500 characters
175
+ * Enhancement: present a plugin review notice to WP admins
176
+
177
  = 7.6.2.2 =
178
  * Enhancement: updated Shareaholic JavaScript snippet - now a lot simpler!
179
  * Bugfix: added hooks to prevent conflicts with Shortcode UI plugin
1233
 
1234
  == Upgrade Notice ==
1235
 
1236
+ = 7.6.2.3 =
1237
+ * Bugfix: limit the summary data attribute to at most 500 characters
1238
+ * Enhancement: present a plugin review notice to WP admins
1239
+
1240
  = 7.6.2.2 =
1241
  * Enhancement: updated Shareaholic JavaScript snippet - now a lot simpler!
1242
  * Bugfix: added hooks to prevent conflicts with Shortcode UI plugin
shareaholic.php CHANGED
@@ -3,14 +3,14 @@
3
  * The main file!
4
  *
5
  * @package shareaholic
6
- * @version 7.6.2.2
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.2.2
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.2.2';
67
 
68
  /**
69
  * Starts off as false so that ::get_instance() returns
3
  * The main file!
4
  *
5
  * @package shareaholic
6
+ * @version 7.6.2.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.2.3
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.2.3';
67
 
68
  /**
69
  * Starts off as false so that ::get_instance() returns
utilities.php CHANGED
@@ -1369,4 +1369,27 @@ class ShareaholicUtilities {
1369
 
1370
  return $user_info;
1371
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1372
  }
1369
 
1370
  return $user_info;
1371
  }
1372
+
1373
+ /**
1374
+ * Shorten a string to a certain character limit
1375
+ * If the limit is reached, then return the truncated text
1376
+ *
1377
+ * @param {String} $text the text to truncate
1378
+ * @param {Number} $char_count the max number of characters
1379
+ * @return {String} the truncated text
1380
+ */
1381
+ public static function truncate_text($text, $char_count) {
1382
+ $words = preg_split('/\s+/', $text);
1383
+ $truncated_text = '';
1384
+
1385
+ foreach($words as $word) {
1386
+ if (strlen($word) + strlen($truncated_text) >= $char_count) {
1387
+ break;
1388
+ }
1389
+
1390
+ $truncated_text .= ' ' . $word;
1391
+ }
1392
+
1393
+ return trim($truncated_text);
1394
+ }
1395
  }