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

Version Description

  • Enhancement: Added page type tag to shareaholic:keywords (you will soon be able to exclude or include Related Content based on page type ie. page, post, etc)
  • Bugfix: Fixed issue where plugin version was not getting updated in some cases
Download this release

Release Info

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

Code changes from version 8.3.0 to 8.3.1

Files changed (5) hide show
  1. admin.php +35 -34
  2. public.php +6 -7
  3. readme.txt +8 -1
  4. shareaholic.php +30 -52
  5. utilities.php +21 -8
admin.php CHANGED
@@ -551,11 +551,11 @@ JQUERY;
551
  /**
552
  * This function is in charge of determining whether to send the "get started" email
553
  */
554
- public static function welcome_email() {
555
  // check whether email has been sent
556
- if (ShareaholicUtilities::get_option('welcome_email_sent') != true) {
557
  // set flag that the email has been sent
558
- ShareaholicUtilities::update_options(array('welcome_email_sent' => true));
559
  // send email
560
  ShareaholicAdmin::send_welcome_email();
561
  }
@@ -566,47 +566,48 @@ JQUERY;
566
  * This function is in charge of sending the "get started" email
567
  */
568
  public static function send_welcome_email() {
569
- $site_url = get_bloginfo('url');
570
- $api_key = ShareaholicUtilities::get_option('api_key');
571
- $payment_url = 'https://shareaholic.com/user-settings/payments';
572
- $shr_wp_dashboard_url = admin_url('admin.php?page=shareaholic-settings');
573
- $sign_up_link = esc_url(admin_url("admin.php?shareaholic_redirect_url=shareaholic.com/signup/"));
574
- $to = get_bloginfo('admin_email');
575
- $subject = 'Thank you for installing Shareaholic for WordPress!';
576
- $message = "
577
- <p>Hi there,</p>
 
578
 
579
- <p>Thank you for installing Shareaholic on $site_url! You are one step closer to growing your website. Completing your set-up is easy, just follow these three easy steps and you'll be ready to go:</p>
580
 
581
- <p><strong>Step 1. Customize to your needs</strong><br /><br />
582
 
583
- Personalize the various apps (ex. Share Buttons and Related Content) to match your website design using the \"Customize\" buttons in your <a href='$shr_wp_dashboard_url'>Shareaholic App Manager in WordPress</a>, then choose where you want them to appear on your website using the checkboxes!
584
 
585
- <p><strong>Step 2: Create your free Shareaholic account</strong><br /><br />
586
 
587
- This will enable you to add more features like Analytics, Floating Share Buttons, Share Buttons for Images, Follow Buttons and more. <strong><a href='$sign_up_link'>Click here to sign-up</a></strong>, or <a href='$sign_up_link'>login to an existing Shareaholic account</a> and we'll automatically sync the plugin settings with your account.</p>
588
 
589
- <p><strong>Step 3: Control your earnings and setup how you would like to get paid</strong><br /><br />
590
 
591
- Decide how much you would like to earn from Promoted Content (native ads that appear in the Related Content app) and other monetization apps by editing your settings in the \"Monetization\" section of the plugin. Next, visit the \"Payments\" <a href='$payment_url'>section of your Shareaholic.com account</a> to add your PayPal information, so you can collect the revenue your site earns.</p>
592
 
593
- <p>Have questions? Simply reply to this email and we will help you out!</p>
594
 
595
- <p>Let's get started,<br /><br />
596
 
597
- The Shareaholic Team<br />
598
- <a href='http://support.shareaholic.com'>support.shareaholic.com</a><br /><br />
599
- <img width='200' height='36' src='https://shareaholic.com/assets/layouts/shareaholic-logo.png' alt='Shareaholic' title='Shareaholic' /><br />
600
- <p style='font-size:12px;color:#C3C2C2;'>This is an automated, one-time e-mail sent by your WordPress CMS directly to the website admin</p><br />
601
- <img width='0' height='0' src='https://www.google-analytics.com/collect?v=1&tid=UA-12964573-6&cid=$api_key&t=event&ec=email&ea=open&el=$site_url-$api_key&cs=lifecycle&cm=email&cn=wp_welcome_email' />";
602
 
603
- $headers = "From: Shareaholic <hello@shareaholic.com>\r\n";
604
- $headers.= "Reply-To: Customer Happiness <hello@shareaholic.com>\r\n";
605
- $headers.= "X-Mailer: PHP/" . phpversion() . "\r\n";
606
- $headers.= "MIME-Version: 1.0\r\n";
607
- $headers.= "Content-type: text/html; charset=utf-8\r\n";
608
-
609
- if (function_exists('wp_mail')){
610
  wp_mail($to, $subject, $message, $headers);
611
  }
612
  }
@@ -615,7 +616,7 @@ JQUERY;
615
  global $pagenow;
616
  if ($pagenow == 'options-permalink.php') {
617
  $css_class = 'error';
618
- $message = 'WARNING: changing the permalink structure will reset the share counts for your pages.';
619
  echo "<div class='$css_class'><p style='font-weight: bold;'>";
620
  _e($message, 'Shareaholic');
621
  echo '</p></div>';
551
  /**
552
  * This function is in charge of determining whether to send the "get started" email
553
  */
554
+ public static function welcome_email() {
555
  // check whether email has been sent
556
+ if (ShareaholicUtilities::get_option('welcome_email_sent') != "y") {
557
  // set flag that the email has been sent
558
+ ShareaholicUtilities::update_options(array('welcome_email_sent' => "y"));
559
  // send email
560
  ShareaholicAdmin::send_welcome_email();
561
  }
566
  * This function is in charge of sending the "get started" email
567
  */
568
  public static function send_welcome_email() {
569
+ if (function_exists('wp_mail')) {
570
+ $site_url = get_bloginfo('url');
571
+ $api_key = ShareaholicUtilities::get_option('api_key');
572
+ $payment_url = 'https://shareaholic.com/user-settings/payments';
573
+ $shr_wp_dashboard_url = esc_url(admin_url("admin.php?page=shareaholic-settings"));
574
+ $sign_up_link = esc_url(admin_url("admin.php?shareaholic_redirect_url=shareaholic.com/signup/"));
575
+ $to = get_bloginfo('admin_email');
576
+ $subject = 'Thank you for installing Shareaholic Plugin for WordPress!';
577
+ $message = "
578
+ <p>Hi there,</p>
579
 
580
+ <p>Thank you for installing Shareaholic on $site_url! You are one step closer to growing your website. Completing your set-up is easy, just follow these three easy steps and you'll be ready to go:</p>
581
 
582
+ <p><strong>Step 1. Customize to your needs</strong><br /><br />
583
 
584
+ Personalize the various apps (ex. Share Buttons and Related Content) to match your website design using the \"Customize\" buttons in your <a href='$shr_wp_dashboard_url'>Shareaholic App Manager in WordPress</a>, then choose where you want them to appear on your website using the checkboxes!
585
 
586
+ <p><strong>Step 2: Create your free Shareaholic account</strong><br /><br />
587
 
588
+ This will enable you to add more features like Analytics, Floating Share Buttons, Share Buttons for Images, Follow Buttons and more. <strong><a href='$sign_up_link'>Click here to sign-up</a></strong>, or <a href='$sign_up_link'>login to an existing Shareaholic account</a> and we'll automatically sync the plugin settings with your account.</p>
589
 
590
+ <p><strong>Step 3: Control your earnings and setup how you would like to get paid</strong><br /><br />
591
 
592
+ Decide how much you would like to earn from Promoted Content (native ads that appear in the Related Content app) and other monetization apps by editing your settings in the \"Monetization\" section of the plugin. Next, visit the \"Payments\" <a href='$payment_url'>section of your Shareaholic.com account</a> to add your PayPal information, so you can collect the revenue your site earns.</p>
593
 
594
+ <p>Have questions? Simply reply to this email and we will help you out!</p>
595
 
596
+ <p>Let's get started,<br /><br />
597
 
598
+ The Shareaholic Team<br />
599
+ <a href='http://support.shareaholic.com'>support.shareaholic.com</a><br /><br />
600
+ <img width='200' height='36' src='https://shareaholic.com/assets/layouts/shareaholic-logo.png' alt='Shareaholic' title='Shareaholic' /><br />
601
+ <p style='font-size:12px;color:#C3C2C2;'>This is an automated, one-time e-mail sent by your WordPress CMS directly to the website admin</p><br />
602
+ <img width='0' height='0' src='https://www.google-analytics.com/collect?v=1&tid=UA-12964573-6&cid=$api_key&t=event&ec=email&ea=open&el=$site_url-$api_key&cs=lifecycle&cm=email&cn=wp_welcome_email' />";
603
 
604
+ $headers = "From: Shareaholic <hello@shareaholic.com>\r\n";
605
+ $headers.= "Reply-To: Shareaholic <hello@shareaholic.com>\r\n";
606
+ $headers.= "X-Mailer: PHP/" . phpversion() . "\r\n";
607
+ $headers.= "MIME-Version: 1.0\r\n";
608
+ $headers.= "Content-type: text/html; charset=utf-8\r\n";
609
+
610
+ // Send email
611
  wp_mail($to, $subject, $message, $headers);
612
  }
613
  }
616
  global $pagenow;
617
  if ($pagenow == 'options-permalink.php') {
618
  $css_class = 'error';
619
+ $message = 'WARNING: Updating your permalink structure will reset the social share counts for your pages. <a href="https://shareaholic.com/plans">Upgrade to Shareaholic Premium</a> to enable <a href="https://support.shareaholic.com/hc/en-us/articles/115002083586">Share Count Recovery</a>.';
620
  echo "<div class='$css_class'><p style='font-weight: bold;'>";
621
  _e($message, 'Shareaholic');
622
  echo '</p></div>';
public.php CHANGED
@@ -62,8 +62,7 @@ class ShareaholicPublic {
62
  * Inserts the script code snippet into the head of the page
63
  */
64
  public static function script_tag() {
65
- if (ShareaholicUtilities::has_accepted_terms_of_service() &&
66
- ShareaholicUtilities::get_or_create_api_key()) {
67
  ShareaholicUtilities::load_template('script_tag', array(
68
  'api_key' => ShareaholicUtilities::get_option('api_key'),
69
  'base_settings' => ShareaholicPublicJS::get_base_settings(),
@@ -124,10 +123,10 @@ class ShareaholicPublic {
124
  } else {
125
  $id = $post->ID;
126
  }
127
-
128
  // Get post tags
129
  $keywords = implode(', ' , ShareaholicUtilities::permalink_keywords($id));
130
-
131
  // Get post categories
132
  $categories_array = get_the_category($id);
133
  $categories = '';
@@ -143,11 +142,11 @@ class ShareaholicPublic {
143
  $categories = trim($output, $separator);
144
  }
145
 
146
- // Merge post tags and categories
147
  if ($keywords != ''){
148
- $keywords .= ', '.$categories;
149
  } else {
150
- $keywords .= $categories;
151
  }
152
 
153
  // Encode, lowercase & trim appropriately
62
  * Inserts the script code snippet into the head of the page
63
  */
64
  public static function script_tag() {
65
+ if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_or_create_api_key()) {
 
66
  ShareaholicUtilities::load_template('script_tag', array(
67
  'api_key' => ShareaholicUtilities::get_option('api_key'),
68
  'base_settings' => ShareaholicPublicJS::get_base_settings(),
123
  } else {
124
  $id = $post->ID;
125
  }
126
+
127
  // Get post tags
128
  $keywords = implode(', ' , ShareaholicUtilities::permalink_keywords($id));
129
+
130
  // Get post categories
131
  $categories_array = get_the_category($id);
132
  $categories = '';
142
  $categories = trim($output, $separator);
143
  }
144
 
145
+ // Merge post tags, categories and post type
146
  if ($keywords != ''){
147
+ $keywords .= ', '.$categories.', '.$post->post_type;
148
  } else {
149
+ $keywords .= $categories.', '.$post->post_type;
150
  }
151
 
152
  // Encode, lowercase & trim appropriately
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: shareaholic
3
  Tags: share buttons, related content, cookie compliance, eu cookie law, shareaholic, shareholic, sexybookmarks, recommendations, cookie consent, 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, google classroom, disqus, spotify, zillow, feedly, kik, line, livejournal, baidu
4
  Requires at least: 3.0
5
  Tested up to: 4.8
6
- Stable tag: 8.3.0
7
 
8
  World's leading all-in-one Content Amplification Platform that helps grow your site traffic, engagement, conversions & monetization for FREE.
9
 
@@ -196,6 +196,10 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
196
 
197
  == Changelog ==
198
 
 
 
 
 
199
  = 8.3.0 =
200
  * Bugfix: Fixed issue where Share Buttons and Related Content apps were not showing after excerpts
201
  * Various other performance updates and bug fixes
@@ -641,6 +645,9 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
641
 
642
  == Upgrade Notice ==
643
 
 
 
 
644
  = 8.3.0 =
645
  Various enhancements
646
 
3
  Tags: share buttons, related content, cookie compliance, eu cookie law, shareaholic, shareholic, sexybookmarks, recommendations, cookie consent, 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, google classroom, disqus, spotify, zillow, feedly, kik, line, livejournal, baidu
4
  Requires at least: 3.0
5
  Tested up to: 4.8
6
+ Stable tag: 8.3.1
7
 
8
  World's leading all-in-one Content Amplification Platform that helps grow your site traffic, engagement, conversions & monetization for FREE.
9
 
196
 
197
  == Changelog ==
198
 
199
+ = 8.3.1 =
200
+ * Enhancement: Added page type tag to shareaholic:keywords (you will soon be able to exclude or include Related Content based on page type ie. page, post, etc)
201
+ * Bugfix: Fixed issue where plugin version was not getting updated in some cases
202
+
203
  = 8.3.0 =
204
  * Bugfix: Fixed issue where Share Buttons and Related Content apps were not showing after excerpts
205
  * Various other performance updates and bug fixes
645
 
646
  == Upgrade Notice ==
647
 
648
+ = 8.3.1 =
649
+ Various bug fixes
650
+
651
  = 8.3.0 =
652
  Various enhancements
653
 
shareaholic.php CHANGED
@@ -3,14 +3,14 @@
3
  * The main file!
4
  *
5
  * @package shareaholic
6
- * @version 8.3.0
7
  */
8
 
9
  /*
10
  Plugin Name: Shareaholic | share buttons, analytics, related content
11
  Plugin URI: https://shareaholic.com/publishers/
12
  Description: The world's leading all-in-one Content Amplification Platform that helps grow your website traffic, engagement, conversions & monetization. See <a href="admin.php?page=shareaholic-settings">configuration panel</a> for more settings.
13
- Version: 8.3.0
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 = '8.3.0';
67
 
68
  /**
69
  * Starts off as false so that ::get_instance() returns
@@ -90,8 +90,8 @@ if (!class_exists('Shareaholic')) {
90
  add_action('wp_ajax_shareaholic_permalink_list', array('ShareaholicPublic', 'permalink_list'));
91
 
92
  // SDK Badge
93
- add_action('wp_ajax_nopriv_shareaholic_sdk_info', array('ShareaholicPublic', 'sdk_info'));
94
- add_action('wp_ajax_shareaholic_sdk_info', array('ShareaholicPublic', 'sdk_info'));
95
 
96
  // Permalink info for Related Content index
97
  add_action('wp_ajax_nopriv_shareaholic_permalink_info', array('ShareaholicPublic', 'permalink_info'));
@@ -101,15 +101,15 @@ if (!class_exists('Shareaholic')) {
101
  add_action('wp_ajax_nopriv_shareaholic_permalink_related', array('ShareaholicPublic', 'permalink_related'));
102
  add_action('wp_ajax_shareaholic_permalink_related', array('ShareaholicPublic', 'permalink_related'));
103
 
104
- add_action('init', array('ShareaholicPublic', 'init'));
105
- add_action('after_setup_theme', array('ShareaholicPublic', 'after_setup_theme'));
106
- add_action('the_content', array('ShareaholicPublic', 'draw_canvases'));
107
- add_action('the_excerpt', array('ShareaholicPublic', 'draw_canvases'));
108
 
109
- add_action('wp_head', array('ShareaholicPublic', 'wp_head'), 6);
110
- add_shortcode('shareaholic', array('ShareaholicPublic', 'shortcode'));
111
 
112
- add_action('plugins_loaded', array($this, 'shareaholic_init'));
113
 
114
  add_action('admin_init', array('ShareaholicAdmin', 'admin_init'));
115
  add_action('admin_enqueue_scripts', array('ShareaholicAdmin', 'admin_header'));
@@ -119,10 +119,6 @@ if (!class_exists('Shareaholic')) {
119
  add_action('admin_enqueue_scripts', array('ShareaholicAdmin', 'enqueue_scripts'));
120
  add_action('admin_menu', array('ShareaholicAdmin', 'admin_menu'));
121
 
122
- if (!ShareaholicUtilities::has_accepted_terms_of_service()) {
123
- add_action('admin_notices', array('ShareaholicAdmin', 'show_terms_of_service'));
124
- }
125
-
126
  // add_action('publish_post', array('ShareaholicNotifier', 'post_notify'));
127
  // add_action('publish_page', array('ShareaholicNotifier', 'post_notify'));
128
 
@@ -144,6 +140,11 @@ if (!class_exists('Shareaholic')) {
144
  // do something before a site's permalink structure changes
145
  add_action('update_option_permalink_structure', array('ShareaholicUtilities', 'notify_content_manager_sitemap'));
146
 
 
 
 
 
 
147
  // use the admin notice API
148
  add_action('admin_notices', array('ShareaholicAdmin', 'admin_notices'));
149
 
@@ -183,10 +184,6 @@ if (!class_exists('Shareaholic')) {
183
  */
184
  public static function init() {
185
  self::update();
186
- if (ShareaholicUtilities::has_accepted_terms_of_service() &&
187
- isset($_GET['page']) && preg_match('/shareaholic/', $_GET['page'])) {
188
- ShareaholicUtilities::get_or_create_api_key();
189
- }
190
  }
191
 
192
  /**
@@ -194,42 +191,21 @@ if (!class_exists('Shareaholic')) {
194
  */
195
  public function shareaholic_init() {
196
  ShareaholicUtilities::localize();
197
-
198
- // Send Welcome email if we haven't sent it already (check whenever a new site ID is set)
199
- if (ShareaholicUtilities::get_option('api_key') != NULL) {
200
- ShareaholicAdmin::welcome_email();
201
  }
202
  }
203
-
204
  /**
205
- * Runs any update code if the version is different from what's
206
- * stored in the settings. This will only run if we are on the
207
- * shareaholic admin page to minimize any concurrency issues.
208
  */
209
  public static function update() {
210
- if (isset($_GET['page']) && preg_match('/shareaholic/', $_GET['page'])) {
211
- if (!ShareaholicUtilities::has_accepted_terms_of_service()) {
212
- add_action('admin_notices', array('ShareaholicAdmin', 'show_terms_of_service'));
213
- } else {
214
- if (ShareaholicUtilities::get_version() != self::VERSION) {
215
- ShareaholicUtilities::log_event("Upgrade", array ('previous_plugin_version' => ShareaholicUtilities::get_version()));
216
- ShareaholicUtilities::perform_update();
217
- ShareaholicUtilities::set_version(self::VERSION);
218
-
219
- if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_option('api_key') != NULL) {
220
- ShareaholicUtilities::notify_content_manager_sitemap();
221
- ShareaholicUtilities::notify_content_manager_singledomain();
222
- }
223
-
224
- // Call the share counts api to check for connectivity on update
225
- if (has_action('wp_ajax_nopriv_shareaholic_share_counts_api') && has_action('wp_ajax_shareaholic_share_counts_api')) {
226
- ShareaholicUtilities::share_counts_api_connectivity_check();
227
- }
228
-
229
- // Activate the Shareaholic Cron job for existing plugin users
230
- ShareaholicCron::activate();
231
- }
232
- }
233
  }
234
  }
235
 
@@ -254,7 +230,7 @@ if (!class_exists('Shareaholic')) {
254
  // workaround: http://codex.wordpress.org/Function_Reference/register_activation_hook
255
  add_option( 'Activated_Plugin_Shareaholic', 'shareaholic' );
256
 
257
- if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_option('api_key') != NULL){
258
  ShareaholicUtilities::notify_content_manager_sitemap();
259
  ShareaholicUtilities::notify_content_manager_singledomain();
260
  }
@@ -274,6 +250,7 @@ if (!class_exists('Shareaholic')) {
274
  ShareaholicUtilities::log_event("Deactivate");
275
  ShareaholicUtilities::clear_cache();
276
  ShareaholicCron::deactivate();
 
277
  }
278
 
279
  /**
@@ -282,6 +259,7 @@ if (!class_exists('Shareaholic')) {
282
  public function uninstall() {
283
  ShareaholicUtilities::log_event("Uninstall");
284
  delete_option('shareaholic_settings');
 
285
  }
286
  }
287
 
3
  * The main file!
4
  *
5
  * @package shareaholic
6
+ * @version 8.3.1
7
  */
8
 
9
  /*
10
  Plugin Name: Shareaholic | share buttons, analytics, related content
11
  Plugin URI: https://shareaholic.com/publishers/
12
  Description: The world's leading all-in-one Content Amplification Platform that helps grow your website traffic, engagement, conversions & monetization. See <a href="admin.php?page=shareaholic-settings">configuration panel</a> for more settings.
13
+ Version: 8.3.1
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 = '8.3.1';
67
 
68
  /**
69
  * Starts off as false so that ::get_instance() returns
90
  add_action('wp_ajax_shareaholic_permalink_list', array('ShareaholicPublic', 'permalink_list'));
91
 
92
  // SDK Badge
93
+ add_action('wp_ajax_nopriv_shareaholic_sdk_info', array('ShareaholicPublic', 'sdk_info'));
94
+ add_action('wp_ajax_shareaholic_sdk_info', array('ShareaholicPublic', 'sdk_info'));
95
 
96
  // Permalink info for Related Content index
97
  add_action('wp_ajax_nopriv_shareaholic_permalink_info', array('ShareaholicPublic', 'permalink_info'));
101
  add_action('wp_ajax_nopriv_shareaholic_permalink_related', array('ShareaholicPublic', 'permalink_related'));
102
  add_action('wp_ajax_shareaholic_permalink_related', array('ShareaholicPublic', 'permalink_related'));
103
 
104
+ add_action('init', array('ShareaholicPublic', 'init'));
105
+ add_action('after_setup_theme', array('ShareaholicPublic', 'after_setup_theme'));
106
+ add_action('the_content', array('ShareaholicPublic', 'draw_canvases'));
107
+ add_action('the_excerpt', array('ShareaholicPublic', 'draw_canvases'));
108
 
109
+ add_action('wp_head', array('ShareaholicPublic', 'wp_head'), 6);
110
+ add_shortcode('shareaholic', array('ShareaholicPublic', 'shortcode'));
111
 
112
+ add_action('plugins_loaded', array($this, 'shareaholic_init'));
113
 
114
  add_action('admin_init', array('ShareaholicAdmin', 'admin_init'));
115
  add_action('admin_enqueue_scripts', array('ShareaholicAdmin', 'admin_header'));
119
  add_action('admin_enqueue_scripts', array('ShareaholicAdmin', 'enqueue_scripts'));
120
  add_action('admin_menu', array('ShareaholicAdmin', 'admin_menu'));
121
 
 
 
 
 
122
  // add_action('publish_post', array('ShareaholicNotifier', 'post_notify'));
123
  // add_action('publish_page', array('ShareaholicNotifier', 'post_notify'));
124
 
140
  // do something before a site's permalink structure changes
141
  add_action('update_option_permalink_structure', array('ShareaholicUtilities', 'notify_content_manager_sitemap'));
142
 
143
+ // Show ToS notice
144
+ if (!ShareaholicUtilities::has_accepted_terms_of_service()) {
145
+ add_action('admin_notices', array('ShareaholicAdmin', 'show_terms_of_service'));
146
+ }
147
+
148
  // use the admin notice API
149
  add_action('admin_notices', array('ShareaholicAdmin', 'admin_notices'));
150
 
184
  */
185
  public static function init() {
186
  self::update();
 
 
 
 
187
  }
188
 
189
  /**
191
  */
192
  public function shareaholic_init() {
193
  ShareaholicUtilities::localize();
194
+
195
+ if (ShareaholicUtilities::has_accepted_terms_of_service() &&
196
+ isset($_GET['page']) && preg_match('/shareaholic/', $_GET['page'])) {
197
+ ShareaholicUtilities::get_or_create_api_key();
198
  }
199
  }
200
+
201
  /**
202
+ * Runs any update code if the plugin version is different from what is stored in the settings.
 
 
203
  */
204
  public static function update() {
205
+ if (ShareaholicUtilities::get_version() != Shareaholic::VERSION) {
206
+ ShareaholicUtilities::log_event("Upgrade", array ('previous_plugin_version' => ShareaholicUtilities::get_version()));
207
+ ShareaholicUtilities::perform_update();
208
+ ShareaholicUtilities::set_version(Shareaholic::VERSION);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
210
  }
211
 
230
  // workaround: http://codex.wordpress.org/Function_Reference/register_activation_hook
231
  add_option( 'Activated_Plugin_Shareaholic', 'shareaholic' );
232
 
233
+ if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_option('api_key') != NULL) {
234
  ShareaholicUtilities::notify_content_manager_sitemap();
235
  ShareaholicUtilities::notify_content_manager_singledomain();
236
  }
250
  ShareaholicUtilities::log_event("Deactivate");
251
  ShareaholicUtilities::clear_cache();
252
  ShareaholicCron::deactivate();
253
+ delete_option('shareaholic_get_or_create_api_key');
254
  }
255
 
256
  /**
259
  public function uninstall() {
260
  ShareaholicUtilities::log_event("Uninstall");
261
  delete_option('shareaholic_settings');
262
+ delete_option('shareaholic_get_or_create_api_key');
263
  }
264
  }
265
 
utilities.php CHANGED
@@ -330,22 +330,33 @@ class ShareaholicUtilities {
330
  * This is the function that will perform the update.
331
  */
332
  public static function perform_update() {
 
 
333
  if (self::get_version() && intval(self::get_version()) <= 6) {
334
- // an update so big, it gets it's own class!
335
  ShareaholicSixToSeven::update();
336
  }
337
- if (self::get_option('metakey_6to7_upgraded') != 'true') {
338
- global $wpdb;
339
- $results = $wpdb->query( "UPDATE $wpdb->postmeta SET `meta_key` = 'shareaholic_disable_open_graph_tags' WHERE `meta_key` = 'Hide OgTags'" );
340
- $results = $wpdb->query( "UPDATE $wpdb->postmeta SET `meta_key` = 'shareaholic_disable_share_buttons' WHERE `meta_key` = 'Hide SexyBookmarks'" );
341
- self::update_options(array('metakey_6to7_upgraded' => 'true'));
 
 
 
 
 
342
  }
 
 
 
343
 
 
344
  $version = ShareaholicUtilities::get_version();
345
  if (!empty($version)){
346
  ShareaholicUtilities::clear_cache();
347
  }
348
- // any other things that need to be updated
 
349
  }
350
 
351
  /**
@@ -670,7 +681,7 @@ class ShareaholicUtilities {
670
  $data,
671
  'json'
672
  );
673
-
674
  if ($response && preg_match('/20*/', $response['response']['code'])) {
675
  self::update_options(array(
676
  'api_key' => $response['body']['api_key'],
@@ -680,6 +691,8 @@ class ShareaholicUtilities {
680
 
681
  if (isset($response['body']['location_name_ids']) && is_array($response['body']['location_name_ids'])) {
682
  self::set_default_location_settings($response['body']['location_name_ids']);
 
 
683
  ShareaholicUtilities::clear_cache();
684
  } else {
685
  ShareaholicUtilities::log_bad_response('FailedToCreateApiKey', $response);
330
  * This is the function that will perform the update.
331
  */
332
  public static function perform_update() {
333
+
334
+ // Upgrade v6 users
335
  if (self::get_version() && intval(self::get_version()) <= 6) {
 
336
  ShareaholicSixToSeven::update();
337
  }
338
+
339
+ // Re-acquire site content. Important: Run ONLY if API KEY is set
340
+ if (ShareaholicUtilities::has_accepted_terms_of_service() && ShareaholicUtilities::get_option('api_key') != NULL) {
341
+ ShareaholicUtilities::notify_content_manager_sitemap();
342
+ ShareaholicUtilities::notify_content_manager_singledomain();
343
+ }
344
+
345
+ // Check for SS Share Counts API connectivity
346
+ if (has_action('wp_ajax_nopriv_shareaholic_share_counts_api') && has_action('wp_ajax_shareaholic_share_counts_api')) {
347
+ ShareaholicUtilities::share_counts_api_connectivity_check();
348
  }
349
+
350
+ // Activate Shareaholic Cron job
351
+ ShareaholicCron::activate();
352
 
353
+ // Clear site cache
354
  $version = ShareaholicUtilities::get_version();
355
  if (!empty($version)){
356
  ShareaholicUtilities::clear_cache();
357
  }
358
+
359
+ // add other things that need to run on version change
360
  }
361
 
362
  /**
681
  $data,
682
  'json'
683
  );
684
+
685
  if ($response && preg_match('/20*/', $response['response']['code'])) {
686
  self::update_options(array(
687
  'api_key' => $response['body']['api_key'],
691
 
692
  if (isset($response['body']['location_name_ids']) && is_array($response['body']['location_name_ids'])) {
693
  self::set_default_location_settings($response['body']['location_name_ids']);
694
+
695
+ ShareaholicAdmin::welcome_email();
696
  ShareaholicUtilities::clear_cache();
697
  } else {
698
  ShareaholicUtilities::log_bad_response('FailedToCreateApiKey', $response);