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

Version Description

  • Enhancement: Updated reset plugin routine to not get new key
Download this release

Release Info

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

Code changes from version 7.6.1.8 to 7.6.1.9

Files changed (5) hide show
  1. admin.php +1 -1
  2. public.php +1 -0
  3. readme.txt +8 -2
  4. shareaholic.php +3 -3
  5. utilities.php +118 -61
admin.php CHANGED
@@ -313,7 +313,7 @@ class ShareaholicAdmin {
313
  if(isset($_POST['reset_settings'])
314
  && $_POST['reset_settings'] == 'Y'
315
  && check_admin_referer($action, 'nonce_field')) {
316
- ShareaholicUtilities::destroy_settings();
317
  echo "<div class='updated settings_updated'><p><strong>"
318
  . sprintf(__('Settings successfully reset. Refresh this page to complete the reset.', 'shareaholic'))
319
  . "</strong></p></div>";
313
  if(isset($_POST['reset_settings'])
314
  && $_POST['reset_settings'] == 'Y'
315
  && check_admin_referer($action, 'nonce_field')) {
316
+ ShareaholicUtilities::reset_settings();
317
  echo "<div class='updated settings_updated'><p><strong>"
318
  . sprintf(__('Settings successfully reset. Refresh this page to complete the reset.', 'shareaholic'))
319
  . "</strong></p></div>";
public.php CHANGED
@@ -450,6 +450,7 @@ class ShareaholicPublic {
450
  }
451
  }
452
 
 
453
  header('Content-Type: application/json');
454
  header('Cache-Control: max-age=180'); // 3 minutes
455
  echo json_encode($result);
450
  }
451
  }
452
 
453
+ header('Access-Control-Allow-Origin: *');
454
  header('Content-Type: application/json');
455
  header('Cache-Control: max-age=180'); // 3 minutes
456
  echo json_encode($result);
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.2.4
6
- Stable tag: 7.6.1.8
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,9 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
170
 
171
  == Changelog ==
172
 
 
 
 
173
  = 7.6.1.8 =
174
  * Enhancement: Detect permalink changes in order to serve up-to-date content
175
 
@@ -1216,6 +1219,9 @@ Please see here: [Usage & Installation Instructions](http://support.shareaholic.
1216
 
1217
  == Upgrade Notice ==
1218
 
 
 
 
1219
  = 7.6.1.8 =
1220
  * Enhancement: Detect permalink changes in order to serve up-to-date content
1221
 
2
  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
6
+ Stable tag: 7.6.1.9
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.1.9 =
174
+ * Enhancement: Updated reset plugin routine to not get new key
175
+
176
  = 7.6.1.8 =
177
  * Enhancement: Detect permalink changes in order to serve up-to-date content
178
 
1219
 
1220
  == Upgrade Notice ==
1221
 
1222
+ = 7.6.1.9 =
1223
+ * Enhancement: Updated reset plugin routine to not get new key
1224
+
1225
  = 7.6.1.8 =
1226
  * Enhancement: Detect permalink changes in order to serve up-to-date content
1227
 
shareaholic.php CHANGED
@@ -3,14 +3,14 @@
3
  * The main file!
4
  *
5
  * @package shareaholic
6
- * @version 7.6.1.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.1.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.1.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.1.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.1.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.1.9';
68
 
69
  /**
70
  * Starts off as false so that ::get_instance() returns
utilities.php CHANGED
@@ -58,15 +58,20 @@ class ShareaholicUtilities {
58
  return get_option('shareaholic_settings', self::defaults());
59
  }
60
 
61
- /**
62
- * Destroys all settings except the acceptance
63
- * of the terms of service.
64
- *
65
- * @return bool
66
- */
67
- public static function destroy_settings() {
68
- delete_option('shareaholic_get_or_create_api_key');
69
- return delete_option('shareaholic_settings');
 
 
 
 
 
70
  }
71
 
72
  /**
@@ -613,27 +618,11 @@ class ShareaholicUtilities {
613
 
614
  $verification_key = md5(mt_rand());
615
 
616
- $turned_on_share_buttons_locations = array(
617
- array('name' => 'post_below_content', 'counter' => 'badge-counter'),
618
- array('name' => 'page_below_content', 'counter' => 'badge-counter'),
619
- array('name' => 'index_below_content', 'counter' => 'badge-counter'),
620
- array('name' => 'category_below_content', 'counter' => 'badge-counter')
621
- );
622
- $turned_off_share_buttons_locations = array(
623
- array('name' => 'post_above_content', 'counter' => 'badge-counter'),
624
- array('name' => 'page_above_content', 'counter' => 'badge-counter'),
625
- array('name' => 'index_above_content', 'counter' => 'badge-counter'),
626
- array('name' => 'category_above_content', 'counter' => 'badge-counter')
627
- );
628
 
629
- $turned_on_recommendations_locations = array(
630
- array('name' => 'post_below_content'),
631
- array('name' => 'page_below_content'),
632
- );
633
- $turned_off_recommendations_locations = array(
634
- array('name' => 'index_below_content'),
635
- array('name' => 'category_below_content'),
636
- );
637
 
638
  $share_buttons_attributes = array_merge($turned_on_share_buttons_locations, $turned_off_share_buttons_locations);
639
  $recommendations_attributes = array_merge($turned_on_recommendations_locations, $turned_off_recommendations_locations);
@@ -668,38 +657,7 @@ class ShareaholicUtilities {
668
  ));
669
 
670
  if (isset($response['body']['location_name_ids']) && is_array($response['body']['location_name_ids'])) {
671
-
672
- $turned_on_share_buttons_keys = array();
673
- foreach($turned_on_share_buttons_locations as $loc) {
674
- $turned_on_share_buttons_keys[] = $loc['name'];
675
- }
676
-
677
- $turned_on_recommendations_keys = array();
678
- foreach($turned_on_recommendations_locations as $loc) {
679
- $turned_on_recommendations_keys[] = $loc['name'];
680
- }
681
-
682
- $turned_off_share_buttons_keys = array();
683
- foreach($turned_off_share_buttons_locations as $loc) {
684
- $turned_off_share_buttons_keys[] = $loc['name'];
685
- }
686
-
687
- $turned_off_recommendations_keys = array();
688
- foreach($turned_off_recommendations_locations as $loc) {
689
- $turned_off_recommendations_keys[] = $loc['name'];
690
- }
691
-
692
- $turn_on = array(
693
- 'share_buttons' => self::associative_array_slice($response['body']['location_name_ids']['share_buttons'], $turned_on_share_buttons_keys),
694
- 'recommendations' => self::associative_array_slice($response['body']['location_name_ids']['recommendations'], $turned_on_recommendations_keys)
695
- );
696
-
697
- $turn_off = array(
698
- 'share_buttons' => self::associative_array_slice($response['body']['location_name_ids']['share_buttons'], $turned_off_share_buttons_keys),
699
- 'recommendations' => self::associative_array_slice($response['body']['location_name_ids']['recommendations'], $turned_off_recommendations_keys)
700
- );
701
-
702
- ShareaholicUtilities::turn_on_locations($turn_on, $turn_off);
703
  ShareaholicUtilities::clear_cache();
704
  } else {
705
  ShareaholicUtilities::log_bad_response('FailedToCreateApiKey', $response);
@@ -716,6 +674,105 @@ class ShareaholicUtilities {
716
  }
717
  }
718
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  /**
720
  * Log reasons for a failure of a response.
721
  *
58
  return get_option('shareaholic_settings', self::defaults());
59
  }
60
 
61
+ public static function reset_settings() {
62
+ $settings = self::get_settings();
63
+ $api_key = self::get_option('api_key');
64
+
65
+ $response = ShareaholicCurl::post(
66
+ Shareaholic::API_URL . '/publisher_tools/' . $api_key . '/reset/',
67
+ $settings,
68
+ 'json'
69
+ );
70
+
71
+ // set the location on/off back to their defaults
72
+ if (isset($settings['location_name_ids']) && is_array($settings['location_name_ids'])) {
73
+ self::set_default_location_settings($settings['location_name_ids']);
74
+ }
75
  }
76
 
77
  /**
618
 
619
  $verification_key = md5(mt_rand());
620
 
621
+ $turned_on_share_buttons_locations = self::get_default_sb_on_locations();
622
+ $turned_off_share_buttons_locations = self::get_default_sb_off_locations();
 
 
 
 
 
 
 
 
 
 
623
 
624
+ $turned_on_recommendations_locations = self::get_default_rec_on_locations();
625
+ $turned_off_recommendations_locations = self::get_default_rec_off_locations();
 
 
 
 
 
 
626
 
627
  $share_buttons_attributes = array_merge($turned_on_share_buttons_locations, $turned_off_share_buttons_locations);
628
  $recommendations_attributes = array_merge($turned_on_recommendations_locations, $turned_off_recommendations_locations);
657
  ));
658
 
659
  if (isset($response['body']['location_name_ids']) && is_array($response['body']['location_name_ids'])) {
660
+ self::set_default_location_settings($response['body']['location_name_ids']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661
  ShareaholicUtilities::clear_cache();
662
  } else {
663
  ShareaholicUtilities::log_bad_response('FailedToCreateApiKey', $response);
674
  }
675
  }
676
 
677
+
678
+ /**
679
+ * Get share buttons locations that should be turned on by default
680
+ *
681
+ * @return {Array}
682
+ */
683
+ public static function get_default_sb_on_locations() {
684
+ return array(
685
+ array('name' => 'post_below_content', 'counter' => 'badge-counter'),
686
+ array('name' => 'page_below_content', 'counter' => 'badge-counter'),
687
+ array('name' => 'index_below_content', 'counter' => 'badge-counter'),
688
+ array('name' => 'category_below_content', 'counter' => 'badge-counter')
689
+ );
690
+ }
691
+
692
+ /**
693
+ * Get share buttons locations that should be turned off by default
694
+ *
695
+ * @return {Array}
696
+ */
697
+ public static function get_default_sb_off_locations() {
698
+ return array(
699
+ array('name' => 'post_above_content', 'counter' => 'badge-counter'),
700
+ array('name' => 'page_above_content', 'counter' => 'badge-counter'),
701
+ array('name' => 'index_above_content', 'counter' => 'badge-counter'),
702
+ array('name' => 'category_above_content', 'counter' => 'badge-counter')
703
+ );
704
+ }
705
+
706
+ /**
707
+ * Get recommendations locations that should be turned on by default
708
+ *
709
+ * @return {Array}
710
+ */
711
+ public static function get_default_rec_on_locations() {
712
+ return array(
713
+ array('name' => 'post_below_content'),
714
+ array('name' => 'page_below_content'),
715
+ );
716
+ }
717
+
718
+
719
+ /**
720
+ * Get recommendations locations that should be turned off by default
721
+ *
722
+ * @return {Array}
723
+ */
724
+ public static function get_default_rec_off_locations() {
725
+ return array(
726
+ array('name' => 'index_below_content'),
727
+ array('name' => 'category_below_content'),
728
+ );
729
+ }
730
+
731
+ /**
732
+ * Given an object, set the default on/off locations
733
+ * for share buttons and recommendations
734
+ *
735
+ */
736
+ public static function set_default_location_settings($location_name_ids) {
737
+ $turned_on_share_buttons_locations = self::get_default_sb_on_locations();
738
+ $turned_off_share_buttons_locations = self::get_default_sb_off_locations();
739
+
740
+ $turned_on_recommendations_locations = self::get_default_rec_on_locations();
741
+ $turned_off_recommendations_locations = self::get_default_rec_off_locations();
742
+
743
+ $turned_on_share_buttons_keys = array();
744
+ foreach($turned_on_share_buttons_locations as $loc) {
745
+ $turned_on_share_buttons_keys[] = $loc['name'];
746
+ }
747
+
748
+ $turned_on_recommendations_keys = array();
749
+ foreach($turned_on_recommendations_locations as $loc) {
750
+ $turned_on_recommendations_keys[] = $loc['name'];
751
+ }
752
+
753
+ $turned_off_share_buttons_keys = array();
754
+ foreach($turned_off_share_buttons_locations as $loc) {
755
+ $turned_off_share_buttons_keys[] = $loc['name'];
756
+ }
757
+
758
+ $turned_off_recommendations_keys = array();
759
+ foreach($turned_off_recommendations_locations as $loc) {
760
+ $turned_off_recommendations_keys[] = $loc['name'];
761
+ }
762
+
763
+ $turn_on = array(
764
+ 'share_buttons' => self::associative_array_slice($location_name_ids['share_buttons'], $turned_on_share_buttons_keys),
765
+ 'recommendations' => self::associative_array_slice($location_name_ids['recommendations'], $turned_on_recommendations_keys)
766
+ );
767
+
768
+ $turn_off = array(
769
+ 'share_buttons' => self::associative_array_slice($location_name_ids['share_buttons'], $turned_off_share_buttons_keys),
770
+ 'recommendations' => self::associative_array_slice($location_name_ids['recommendations'], $turned_off_recommendations_keys)
771
+ );
772
+
773
+ ShareaholicUtilities::turn_on_locations($turn_on, $turn_off);
774
+ }
775
+
776
  /**
777
  * Log reasons for a failure of a response.
778
  *