WordPress Share Buttons Plugin – AddThis - Version 5.0.2

Version Description

  • Fixes for WordPress instances running on PHP verions below 5.5
Download this release

Release Info

Developer jgrodel
Plugin Icon 128x128 WordPress Share Buttons Plugin – AddThis
Version 5.0.2
Comparing to
See all releases

Code changes from version 5.0.1 to 5.0.2

AddThisConfigs.php CHANGED
@@ -192,13 +192,37 @@ if (!class_exists('AddThisConfigs')) {
192
 
193
  public function getProfileId() {
194
  $this->getConfigs();
195
- if(isset($this->configs['addthis_profile'])
196
- && !empty($this->configs['addthis_profile'])
197
  ) {
198
  return $this->configs['addthis_profile'];
199
  }
200
 
201
  return '';
202
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
  }
192
 
193
  public function getProfileId() {
194
  $this->getConfigs();
195
+ if( isset($this->configs['addthis_profile'])
196
+ && !empty($this->configs['addthis_profile'])
197
  ) {
198
  return $this->configs['addthis_profile'];
199
  }
200
 
201
  return '';
202
  }
203
+
204
+ public function getAnonymousProfileId() {
205
+ $this->getConfigs();
206
+ if( !isset($this->configs['addthis_anonymous_profile'])
207
+ || !$this->configs['addthis_anonymous_profile']
208
+ ) {
209
+ $prefix = $this->cmsInterface->getAnonymousProfileIdPrefix();
210
+ $url = $this->cmsInterface->getHomepageUrl();
211
+ $postfix = hash_hmac('md5', $url, 'addthis');
212
+ $this->configs['addthis_anonymous_profile'] = $prefix . '-' . $postfix;
213
+ $this->saveConfigs();
214
+ }
215
+
216
+ return $this->configs['addthis_anonymous_profile'];
217
+ }
218
+
219
+
220
+ public function getUsableProfileId() {
221
+ if ($this->getProfileId()) {
222
+ return $this->getProfileId();
223
+ }
224
+
225
+ return $this->getAnonymousProfileId();
226
+ }
227
  }
228
  }
AddThisWordPressConnector.php CHANGED
@@ -25,8 +25,9 @@ if (!class_exists('AddthisWordpressConnector')) {
25
  Class AddthisWordpressConnector implements AddThisCmsConnectorInterface {
26
 
27
  static $settingsVariableName = 'addthis_settings';
28
- static $pluginVersion = '5.0.1';
29
  static $settingsPageId = 'addthis_social_widget';
 
30
  protected $configs = null;
31
 
32
  protected $defaultConfigs = array(
@@ -82,6 +83,10 @@ if (!class_exists('AddthisWordpressConnector')) {
82
  return $version;
83
  }
84
 
 
 
 
 
85
  /**
86
  * the folder name for the AddThis plugin - OMG why is this hard coded?!?
87
  * @return string
@@ -504,5 +509,10 @@ if (!class_exists('AddthisWordpressConnector')) {
504
 
505
  return false;
506
  }
 
 
 
 
 
507
  }
508
  }
25
  Class AddthisWordpressConnector implements AddThisCmsConnectorInterface {
26
 
27
  static $settingsVariableName = 'addthis_settings';
28
+ static $pluginVersion = '5.0.2';
29
  static $settingsPageId = 'addthis_social_widget';
30
+ static $anonymousProfileIdPrefix = 'wp';
31
  protected $configs = null;
32
 
33
  protected $defaultConfigs = array(
83
  return $version;
84
  }
85
 
86
+ static function getAnonymousProfileIdPrefix() {
87
+ return self::$anonymousProfileIdPrefix;
88
+ }
89
+
90
  /**
91
  * the folder name for the AddThis plugin - OMG why is this hard coded?!?
92
  * @return string
509
 
510
  return false;
511
  }
512
+
513
+ public function getHomepageUrl() {
514
+ $url = get_option('home');
515
+ return $url;
516
+ }
517
  }
518
  }
addthis_settings_functions.php CHANGED
@@ -449,6 +449,7 @@ function _addthis_deprecated_fields() {
449
  'addthis_copytracking1',
450
  'addthis_copytracking2',
451
  'addthis_copytrackingremove',
 
452
  'addthis_for_wordpress',
453
  'addthis_nag_username_ignore',
454
  'addthis_options',
449
  'addthis_copytracking1',
450
  'addthis_copytracking2',
451
  'addthis_copytrackingremove',
452
+ 'addthis_fallback_username',
453
  'addthis_for_wordpress',
454
  'addthis_nag_username_ignore',
455
  'addthis_options',
addthis_social_widget.php CHANGED
@@ -331,7 +331,6 @@ if ($addthis_options['addthis_plugin_controls'] == "AddThis") {
331
  // if the option saved, delete the old options
332
 
333
  delete_option('addthis_asynchronous_loading');
334
- delete_option('addthis_fallback_username');
335
  delete_option('addthis_product');
336
  delete_option('addthis_isdropdown');
337
  delete_option('addthis_menu_type');
@@ -386,20 +385,6 @@ if ($addthis_options['addthis_plugin_controls'] == "AddThis") {
386
 
387
  }
388
 
389
-
390
- /**
391
- * Generates unique IDs
392
- */
393
- function cuid()
394
- {
395
- $base = get_option('home');
396
- $cuid = hash_hmac('md5', $base, 'addthis');
397
- return $cuid;
398
- }
399
-
400
- define('ADDTHIS_FALLBACK_USERNAME', 'wp-'.cuid() );
401
-
402
-
403
  /**
404
  * For templates, we need a wrapper for printing out the code on demand.
405
  */
@@ -988,8 +973,6 @@ if ($addthis_options['addthis_plugin_controls'] == "AddThis") {
988
 
989
  $addthis_settings['menu_type'] = get_option('addthis_menu_type');
990
 
991
- $addthis_settings['fallback_username'] = get_option('addthis_fallback_username');
992
-
993
  $language = get_option('addthis_language');
994
  $addthis_settings['language'] = $language;
995
 
@@ -1338,13 +1321,6 @@ if ($addthis_options['addthis_plugin_controls'] == "AddThis") {
1338
  .'<script type="text/javascript">'
1339
  ."var addthis_product = '".ADDTHIS_PRODUCT_VERSION."';\n";
1340
 
1341
-
1342
- $pub = $addThisConfigs->getProfileId();
1343
- if (empty($pubid)) {
1344
- $pub = 'wp-'.cuid();
1345
- }
1346
- $pub = urlencode($pub);
1347
-
1348
  $addthis_config = array();
1349
  $addthis_share = array();
1350
 
@@ -1426,9 +1402,7 @@ if ($addthis_options['addthis_plugin_controls'] == "AddThis") {
1426
  $script .= 'if (typeof(addthis_share) == "undefined"){ addthis_share = ' . json_encode( apply_filters('addthis_share_js_var', $addthis_share ) ) .';}';
1427
  $script .= '</script>';
1428
 
1429
-
1430
- $script .= '<script type="text/javascript" src="//s7.addthis.com/js/'.$atversion.'/addthis_widget.js#pubid='.$pub.'"></script>';
1431
-
1432
 
1433
  if ( ! is_admin() && ! is_feed() )
1434
  echo $script;
@@ -1548,11 +1522,7 @@ if ($addthis_options['addthis_plugin_controls'] == "AddThis") {
1548
  }
1549
  }
1550
 
1551
- $pub = $addThisConfigs->getProfileId();
1552
- if (empty($pub)) {
1553
- $pub = 'wp-'.cuid();
1554
- }
1555
- $pub = urlencode($pub);
1556
 
1557
  $link = !is_null($url) ? $url : ($onSidebar ? get_bloginfo('url') : get_permalink());
1558
  $title = !is_null($title) ? $title : ($onSidebar ? get_bloginfo('title') : the_title('', '', false));
@@ -2287,18 +2257,18 @@ function _addthis_profile_id_card($credential_validation_status = false) {
2287
  $security = wp_nonce_field('update_' . $fieldName, $fieldName . '_nonce');
2288
  }
2289
 
2290
- if (!$addThisConfigs->getProfileId()) {
2291
- $description = $noPubIdDescription;
2292
- $buttonUrl = _addthis_profile_setup_url();
2293
- $buttonText = $noPubIdButtonText;
2294
- $alternatePath = '<p>Alternately, you can input your profile id manually below.</p>';
2295
- $target = '';
2296
- } else {
2297
  $description = $pubIdDescription;
2298
  $buttonUrl = _addthis_analytics_url();
2299
  $buttonText = $pubIdButtonText;
2300
  $alternatePath = '';
2301
  $target = 'target="_blank"';
 
 
 
 
 
 
2302
  }
2303
 
2304
  $html = '
331
  // if the option saved, delete the old options
332
 
333
  delete_option('addthis_asynchronous_loading');
 
334
  delete_option('addthis_product');
335
  delete_option('addthis_isdropdown');
336
  delete_option('addthis_menu_type');
385
 
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  /**
389
  * For templates, we need a wrapper for printing out the code on demand.
390
  */
973
 
974
  $addthis_settings['menu_type'] = get_option('addthis_menu_type');
975
 
 
 
976
  $language = get_option('addthis_language');
977
  $addthis_settings['language'] = $language;
978
 
1321
  .'<script type="text/javascript">'
1322
  ."var addthis_product = '".ADDTHIS_PRODUCT_VERSION."';\n";
1323
 
 
 
 
 
 
 
 
1324
  $addthis_config = array();
1325
  $addthis_share = array();
1326
 
1402
  $script .= 'if (typeof(addthis_share) == "undefined"){ addthis_share = ' . json_encode( apply_filters('addthis_share_js_var', $addthis_share ) ) .';}';
1403
  $script .= '</script>';
1404
 
1405
+ $script .= '<script type="text/javascript" src="//s7.addthis.com/js/'.$atversion.'/addthis_widget.js#pubid='. urlencode($addThisConfigs->getUsableProfileId()) . '"></script>';
 
 
1406
 
1407
  if ( ! is_admin() && ! is_feed() )
1408
  echo $script;
1522
  }
1523
  }
1524
 
1525
+ $pub = urlencode($addThisConfigs->getUsableProfileId());
 
 
 
 
1526
 
1527
  $link = !is_null($url) ? $url : ($onSidebar ? get_bloginfo('url') : get_permalink());
1528
  $title = !is_null($title) ? $title : ($onSidebar ? get_bloginfo('title') : the_title('', '', false));
2257
  $security = wp_nonce_field('update_' . $fieldName, $fieldName . '_nonce');
2258
  }
2259
 
2260
+ if ($addThisConfigs->getProfileId()) {
 
 
 
 
 
 
2261
  $description = $pubIdDescription;
2262
  $buttonUrl = _addthis_analytics_url();
2263
  $buttonText = $pubIdButtonText;
2264
  $alternatePath = '';
2265
  $target = 'target="_blank"';
2266
+ } else {
2267
+ $description = $noPubIdDescription;
2268
+ $buttonUrl = _addthis_profile_setup_url();
2269
+ $buttonText = $noPubIdButtonText;
2270
+ $alternatePath = '<p>Alternately, you can input your profile id manually below.</p>';
2271
+ $target = '';
2272
  }
2273
 
2274
  $html = '
includes/addthis_addjs_new.php CHANGED
@@ -30,7 +30,6 @@ Class AddThis_addjs{
30
 
31
  private $_options;
32
 
33
- private $_cuid;
34
  private $addThisConfigs;
35
 
36
  var $jsToAdd;
@@ -65,10 +64,6 @@ Class AddThis_addjs{
65
  if (is_array($this->_options)) {
66
  $this->atversion = array_key_exists('atversion_update_status', $this->_options) && $this->_options['atversion_update_status'] == ADDTHIS_ATVERSION_REVERTED ? $this->_options['atversion'] : ADDTHIS_ATVERSION;
67
  }
68
- // set the cuid
69
- $base = get_option('home');
70
- $cuid = hash_hmac('md5', $base, 'addthis');
71
- $this->_cuid = $cuid;
72
 
73
  // If the footer option isn't set, check for it
74
  if (! isset($this->_options['wpfooter']) && current_user_can('manage_options'))
@@ -212,7 +207,7 @@ Class AddThis_addjs{
212
  ' . $addthis_share_js . '
213
  </script>';
214
 
215
- $this->jsToAdd .= $firstScriptHalf . $this->atversion.'/addthis_widget.js#pubid='. urlencode( $this->addThisConfigs->getProfileId() ).'" ' . $async. '></script>';
216
  }
217
  }
218
 
30
 
31
  private $_options;
32
 
 
33
  private $addThisConfigs;
34
 
35
  var $jsToAdd;
64
  if (is_array($this->_options)) {
65
  $this->atversion = array_key_exists('atversion_update_status', $this->_options) && $this->_options['atversion_update_status'] == ADDTHIS_ATVERSION_REVERTED ? $this->_options['atversion'] : ADDTHIS_ATVERSION;
66
  }
 
 
 
 
67
 
68
  // If the footer option isn't set, check for it
69
  if (! isset($this->_options['wpfooter']) && current_user_can('manage_options'))
207
  ' . $addthis_share_js . '
208
  </script>';
209
 
210
+ $this->jsToAdd .= $firstScriptHalf . $this->atversion.'/addthis_widget.js#pubid='. urlencode( $this->addThisConfigs->getUsableProfileId() ).'" ' . $async. '></script>';
211
  }
212
  }
213
 
readme.txt CHANGED
@@ -86,6 +86,9 @@ PHP 5+ is preferred; PHP 4 is supported.
86
 
87
  == Changelog ==
88
 
 
 
 
89
  = 5.0.1 =
90
  * Improved migration of checkbox settings from 4.0 plugin
91
  * Improved settings page layout on mobile devices and small screens
@@ -327,7 +330,7 @@ Fixed nondeterministic bug with the_title(), causing the title to occasionally a
327
 
328
  == Upgrade Notice ==
329
 
330
- = 5.0.1 =
331
  * Two functional modes allowing users to choose whether to control sharing buttons from within the WordPress admin area (with limited features), or through the AddThis Dashboard at addthis.com.
332
  * Sharing sidebar configuration available within WordPress (in addition to the previously available sharing buttons above and below content).
333
  * Seperate preferences for what sharing buttons appear on what templates.
86
 
87
  == Changelog ==
88
 
89
+ = 5.0.2 =
90
+ * Fixes for WordPress instances running on PHP verions below 5.5
91
+
92
  = 5.0.1 =
93
  * Improved migration of checkbox settings from 4.0 plugin
94
  * Improved settings page layout on mobile devices and small screens
330
 
331
  == Upgrade Notice ==
332
 
333
+ = 5.0.2 =
334
  * Two functional modes allowing users to choose whether to control sharing buttons from within the WordPress admin area (with limited features), or through the AddThis Dashboard at addthis.com.
335
  * Sharing sidebar configuration available within WordPress (in addition to the previously available sharing buttons above and below content).
336
  * Seperate preferences for what sharing buttons appear on what templates.