WordPress Share Buttons Plugin – AddThis - Version 3.0

Version Description

  • UX changes in admin settings
  • Credential verification in Admin settings. If AddThis account details are wrong it will be notified to user.
  • Bug fixes
Download this release

Release Info

Developer srijith.v
Plugin Icon 128x128 WordPress Share Buttons Plugin – AddThis
Version 3.0
Comparing to
See all releases

Code changes from version 2.5.1 to 3.0

addthis_settings_functions.php CHANGED
@@ -102,7 +102,18 @@ function _addthis_version_notification($atversion_update_status, $atversion)
102
  ob_end_clean();
103
  return $notification_content;
104
  }
105
-
 
 
 
 
 
 
 
 
 
 
 
106
  /**
107
  * The icon choser row. Should be made to look a bit prettier
108
  */
@@ -110,10 +121,11 @@ function _addthis_version_notification($atversion_update_status, $atversion)
110
  {
111
  $addthis_new_styles = _get_style_options();
112
  global $addthis_default_options;
113
-
114
  extract($options);
115
  if ($name == 'above')
116
  {
 
 
117
  $option = $above;
118
  $custom_size = $above_custom_size;
119
  $do_custom_services = ( isset( $above_do_custom_services ) && $above_do_custom_services ) ? 'checked="checked"' : '';
@@ -125,8 +137,9 @@ function _addthis_version_notification($atversion_update_status, $atversion)
125
  }
126
  else
127
  {
128
- $option = $below;
129
- $custom_size = $below_custom_size;
 
130
  $do_custom_services = ( isset( $below_do_custom_services ) && $below_do_custom_services ) ? 'checked="checked"' : '';
131
  $do_custom_preferred = ( isset( $below_do_custom_preferred ) && $below_do_custom_preferred ) ? 'checked="checked"' : '';
132
  $custom_services = $below_custom_services;
@@ -138,21 +151,29 @@ function _addthis_version_notification($atversion_update_status, $atversion)
138
  <tr>
139
  <td id="<?php echo $name ?>" colspan="2">
140
  <fieldset>
141
- <legend>&nbsp; <?php _e("Choose the sharing tool to display <b>$name</b> the post:", 'addthis_trans_domain') ?> &nbsp;</legend>
142
-
143
- <?php $imgLocationBase = apply_filters( 'at_files_uri', plugins_url( '' , basename(dirname(__FILE__)))) . '/addthis/img/' ;
 
 
 
 
 
 
 
 
 
144
  $imgLocationBase = apply_filters( 'addthis_files_uri', plugins_url( '' , basename(dirname(__FILE__)))) . '/addthis/img/' ;
145
- foreach ($addthis_new_styles as $k => $v)
 
146
  {
147
- $class = 'hidden';
148
  $checked = '';
149
  if ($option == $k || ($option == 'none' && $k == $addthis_default_options[$name] ) ){
150
  $checked = 'checked="checked"';
151
- $class = '';
152
  }
153
  if ($checked === '' && isset($v['defaultHide']) && $v['defaultHide'] == true)
154
  continue;
155
- echo "<div class='$name"."_option select_row $class '><span class='radio'><input $checked type='radio' value='".$k."' id='{$k}_{$name}' name='addthis_settings[$name]' /></span><label for='{$k}_{$name}'> <img alt='".$k."' src='". $imgLocationBase . $v['img'] ."' align='left' /></label><div class='clear'></div></div>";
156
  }
157
 
158
  $class = 'hidden';
@@ -186,23 +207,19 @@ function _addthis_version_notification($atversion_update_status, $atversion)
186
  echo "</ul></div>";
187
  }
188
 
189
- $class = 'hidden';
190
  $checked = '';
191
  if ($option == 'custom_string' || $option == 'none' && 'custom_strin' == $addthis_default_options[$name] )
192
  {
193
  $checked = 'checked="checked"';
194
- $class = '';
195
  }
196
 
197
- echo "<div class='$name"."_option select_row $class '><span class='radio mt4'><input $checked type='radio' value='custom_string' name='addthis_settings[$name]' id='$name"."_custom_string' /></span> <label for='{$name}_custom_string'>Custom button</label><div class='clear'></div></div>";
198
- _e( sprintf("<div style='max-width: 748px;' class='%s_custom_string_input'> This text box allows you to enter any AddThis markup that you wish. To see examples of what you can do, visit <a href='https://www.addthis.com/get/sharing'>AddThis.com Sharing Tools</a> and select any sharing tool. You can also check out our <a href='http://support.addthis.com/customer/portal/articles/381263-addthis-client-api#rendering-decoration'>Client API</a>. For any help you may need, please visit <a href='http://support.addthis.com'>AddThis Support</a></div>", $name ),'addthis_trans_domain');
199
- echo "<textarea style='max-width:748px;' rows='5' cols='120' name='addthis_settings[$name"."_custom_string]' class='$name"."_custom_string_input' />".esc_textarea($custom_string)."</textarea>";
200
 
201
  echo '</div>';
202
  ?>
203
- <div class="select_row description"><span class='radio mt0'><input type="radio" class='always' id="<?php echo $name . '_None' ?>" name="addthis_settings[<?php echo $name; ?>]" <?php echo ('none' == $option) ? 'checked="checked"' : '';?> value='none' /></span><label for="<?php echo $name . '_None' ?>">None</label></div>
204
- <p><a class="<?php echo $name;?>_option" href="#<?php echo $name;?>_more" id="<?php echo $name;?>_more"><span>More options</span><span class='hidden'>Less options</span></a></p>
205
-
206
  </fieldset>
207
  </td>
208
  </tr>
102
  ob_end_clean();
103
  return $notification_content;
104
  }
105
+ /**
106
+ * Swap the order of occurrence of two keys in an associative array
107
+ * @param type $array
108
+ * @param type $key1
109
+ * @param type $key2
110
+ */
111
+ function _addthis_swap_first_two_elements (&$array, $key)
112
+ {
113
+ $temp = array($key => $array[$key]);
114
+ unset($array[$key]);
115
+ $array = $temp + $array;
116
+ }
117
  /**
118
  * The icon choser row. Should be made to look a bit prettier
119
  */
121
  {
122
  $addthis_new_styles = _get_style_options();
123
  global $addthis_default_options;
 
124
  extract($options);
125
  if ($name == 'above')
126
  {
127
+ _addthis_swap_first_two_elements($addthis_new_styles, 'large_toolbox');
128
+ $legend = 'Top';
129
  $option = $above;
130
  $custom_size = $above_custom_size;
131
  $do_custom_services = ( isset( $above_do_custom_services ) && $above_do_custom_services ) ? 'checked="checked"' : '';
137
  }
138
  else
139
  {
140
+ $legend = 'Bottom';
141
+ $option = $below;
142
+ $custom_size = $below_custom_size;
143
  $do_custom_services = ( isset( $below_do_custom_services ) && $below_do_custom_services ) ? 'checked="checked"' : '';
144
  $do_custom_preferred = ( isset( $below_do_custom_preferred ) && $below_do_custom_preferred ) ? 'checked="checked"' : '';
145
  $custom_services = $below_custom_services;
151
  <tr>
152
  <td id="<?php echo $name ?>" colspan="2">
153
  <fieldset>
154
+ <legend>&nbsp;<strong><?php _e("$legend Sharing Tool", 'addthis_trans_domain') ?></strong> &nbsp;</legend>
155
+
156
+ <?php
157
+ $sharing_checked = $option == 'none' ? '' : 'checked="checked"';
158
+ echo "<div class='enable-sharing-tool'><input type='checkbox' {$sharing_checked} value='{$option}' id='enable_{$name}' name='addthis_settings[enable_{$name}]' />
159
+ <label for='enable_{$name}'>";
160
+ echo _e('Enable the following sharing tool at the ', 'addthis_trans_domain' );
161
+ echo '<strong>';
162
+ echo _e($legend, 'addthis_trans_domain');
163
+ echo '</strong> of posts:</label></div>';
164
+
165
+ $imgLocationBase = apply_filters( 'at_files_uri', plugins_url( '' , basename(dirname(__FILE__)))) . '/addthis/img/' ;
166
  $imgLocationBase = apply_filters( 'addthis_files_uri', plugins_url( '' , basename(dirname(__FILE__)))) . '/addthis/img/' ;
167
+
168
+ foreach ($addthis_new_styles as $k => $v)
169
  {
 
170
  $checked = '';
171
  if ($option == $k || ($option == 'none' && $k == $addthis_default_options[$name] ) ){
172
  $checked = 'checked="checked"';
 
173
  }
174
  if ($checked === '' && isset($v['defaultHide']) && $v['defaultHide'] == true)
175
  continue;
176
+ echo "<div class='$name"."_option select_row'><span class='radio'><input $checked type='radio' value='".$k."' id='{$k}_{$name}' name='addthis_settings[$name]' /></span><label for='{$k}_{$name}'> <img alt='".$k."' src='". $imgLocationBase . $v['img'] ."' align='left' /></label><div class='clear'></div></div>";
177
  }
178
 
179
  $class = 'hidden';
207
  echo "</ul></div>";
208
  }
209
 
 
210
  $checked = '';
211
  if ($option == 'custom_string' || $option == 'none' && 'custom_strin' == $addthis_default_options[$name] )
212
  {
213
  $checked = 'checked="checked"';
 
214
  }
215
 
216
+ echo "<div class='$name"."_option select_row'><span class='radio mt4'><input $checked type='radio' value='custom_string' name='addthis_settings[$name]' id='$name"."_custom_string' /></span> <label for='{$name}_custom_string'>Custom button</label><div class='clear'></div></div>";
217
+ _e( sprintf("<div style='max-width: 748px;margin-left:20px' class='%s_custom_string_input'> This text box allows you to enter any AddThis markup that you wish. To see examples of what you can do, visit <a href='https://www.addthis.com/get/sharing'>AddThis.com Sharing Tools</a> and select any sharing tool. You can also check out our <a href='http://support.addthis.com/customer/portal/articles/381263-addthis-client-api#rendering-decoration'>Client API</a>. For any help you may need, please visit <a href='http://support.addthis.com'>AddThis Support</a></div>", $name ),'addthis_trans_domain');
218
+ echo "<textarea style='max-width:748px;margin-left:20px' rows='5' cols='120' name='addthis_settings[$name"."_custom_string]' class='$name"."_custom_string_input' />".esc_textarea($custom_string)."</textarea>";
219
 
220
  echo '</div>';
221
  ?>
222
+
 
 
223
  </fieldset>
224
  </td>
225
  </tr>
addthis_sidebar_widget.php CHANGED
@@ -19,7 +19,7 @@ class AddThisSidebarWidget extends WP_Widget {
19
  $control_ops = array( 'width' => 325);
20
 
21
  /* Create the widget. */
22
- $this->WP_Widget( 'addthis-widget', 'AddThis Widget', $widget_ops, $control_ops );
23
 
24
  }
25
 
@@ -91,7 +91,7 @@ class AddThisSidebarWidget extends WP_Widget {
91
  if ($k === $style)
92
  $checked = 'checked="checked"';
93
 
94
- echo '<input '.$checked.' style="margin:-15px 2px 0;" type="radio" name="' . $this->get_field_name('style') . '" value="'.$k.'"><img src="'. plugins_url( '/addthis/img/' . $v['img'], basename(dirname(__FILE__)) ) .'" /><br />';
95
  }
96
  ?>
97
  <?php
19
  $control_ops = array( 'width' => 325);
20
 
21
  /* Create the widget. */
22
+ $this->WP_Widget( 'addthis-widget', 'AddThis Share', $widget_ops, $control_ops );
23
 
24
  }
25
 
91
  if ($k === $style)
92
  $checked = 'checked="checked"';
93
 
94
+ echo '<div style="height:auto;"><input '.$checked.' style="margin:5px 5px 0 0;" type="radio" name="' . $this->get_field_name('style') . '" value="'.$k.'"><img align="middle" style="padding:5px 0" src="'. plugins_url( '/addthis/img/' . $v['img'], basename(dirname(__FILE__)) ) .'" /></div>';
95
  }
96
  ?>
97
  <?php
addthis_social_widget.php CHANGED
@@ -23,7 +23,7 @@
23
  * Plugin Name: AddThis Social Bookmarking Widget
24
  * Plugin URI: http://www.addthis.com
25
  * Description: Help your visitor promote your site! The AddThis Social Bookmarking Widget allows any visitor to bookmark your site easily with many popular services. Sign up for an AddThis.com account to see how your visitors are sharing your content--which services they're using for sharing, which content is shared the most, and more. It's all free--even the pretty charts and graphs.
26
- * Version: 2.5.1
27
  *
28
  * Author: The AddThis Team
29
  * Author URI: http://www.addthis.com/blog
@@ -46,8 +46,8 @@ function addthis_early(){
46
 
47
 
48
  define( 'addthis_style_default' , 'fb_tw_p1_sc');
49
- define( 'ADDTHIS_PLUGIN_VERSION' , '2.5.1');
50
- define( 'ADDTHIS_PRODUCT_VERSION' , 'wpp-2.5.1');
51
  define( 'ADDTHIS_ATVERSION', '300');
52
  define( 'ADDTHIS_ATVERSION_MANUAL_UPDATE', -1);
53
  define( 'ADDTHIS_ATVERSION_AUTO_UPDATE', 0);
@@ -80,7 +80,7 @@ $atversion = array_key_exists('atversion_reverted', $addthis_options) && $addthi
80
 
81
  $addthis_new_styles = array(
82
 
83
- 'fb_tw_p1_sc' => array( 'src' => '<div class="addthis_toolbox addthis_default_style " %s ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>' , 'img' => 'fb-tw-p1-sc.jpg' , 'name' => 'Like, Tweet, +1, Share', 'above' => '', 'below' => ''
84
  ), // facebook tweet plus 1 share counter
85
  'large_toolbox' => array( 'src' => '<div class="addthis_toolbox addthis_default_style addthis_32x32_style" %s ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>', 'img' => 'toolbox-large.png', 'name' => 'Large Toolbox', 'above' => 'hidden ', 'below' => 'hidden'
86
  ), // 32x32
@@ -94,7 +94,7 @@ $addthis_new_styles = array(
94
  ), // facebook tweet share counter
95
  'simple_button' => array('src' => '<div class="addthis_toolbox addthis_default_style " %s><a href="//addthis.com/bookmark.php?v='.$atversion.'&amp;username=xa-4d2b47f81ddfbdce" class="addthis_button_compact">Share</a></div>', 'img' => 'share.jpg', 'name' => 'Share Button', 'above' => 'hidden ', 'below' => 'hidden', 'defaultHide' => true
96
  ), // Plus sign share
97
- 'button' => array( 'src' => '<div><a class="addthis_button" href="//addthis.com/bookmark.php?v='.$atversion.'" %s><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>', 'img' => 'button.jpg', 'name' => 'Classic Share Button', 'above' => 'hidden ', 'below' => 'hidden'
98
  ), // classic
99
  'share_counter' => array( 'src' => '<div class="addthis_toolbox addthis_default_style " %s ><a class="addthis_counter"></a></div>', 'img' => 'share_counter.png', 'name' => 'Share Counter', 'above' => 'hidden ', 'below' => 'hidden' , 'defaultHide' => true
100
  ),
@@ -870,7 +870,8 @@ if ( isset($data['wpfooter']))
870
  $options['wpfooter'] = (bool) $data['wpfooter'];
871
 
872
 
873
- if (! isset($data['above']) ){
 
874
  }
875
  elseif ( isset ($data['show_above']) )
876
  $options['above'] = 'none';
@@ -900,7 +901,8 @@ elseif ($data['above'] == 'custom_string')
900
 
901
  }
902
 
903
- if ( ! isset($data['below'] )){
 
904
  }
905
  elseif ( isset ($data['show_below']) )
906
  $options['below'] = 'none';
@@ -978,6 +980,9 @@ if ( isset ($data['atversion']))
978
  if ( isset ($data['atversion_update_status']))
979
  $options['atversion_update_status'] = sanitize_text_field($data['atversion_update_status']);
980
 
 
 
 
981
  if ( isset ($data['addthis_header_background']) && strlen($data['addthis_header_background']) != 0 )
982
  {
983
  if (! strpos($data['addthis_header_background'], '#') === 0)
@@ -1558,6 +1563,46 @@ function addthis_output_script($return = false, $justConfig = false )
1558
  return $script;
1559
  }
1560
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1561
  /*
1562
  * Merge the Add this settings with that given using JSON format
1563
  * @param String $appendString - The string to build and return the script
@@ -1712,6 +1757,7 @@ function addthis_options_page_scripts()
1712
  $script_location = apply_filters( 'at_files_uri', plugins_url( '', basename(dirname(__FILE__)) ) ) . '/addthis/js/'.$script ;
1713
  $script_location = apply_filters( 'addthis_files_uri', plugins_url( '', basename(dirname(__FILE__)) ) ) . '/addthis/js/'.$script ;
1714
  wp_enqueue_script( 'addthis_options_page_script', $script_location , array('jquery-ui-tabs', 'thickbox' ));
 
1715
 
1716
  }
1717
 
@@ -1725,7 +1771,7 @@ function addthis_options_page_style()
1725
 
1726
  function addthis_admin_menu()
1727
  {
1728
- $addthis = add_options_page('AddThis Plugin Options', 'AddThis', 'manage_options', basename(__FILE__), 'addthis_plugin_options_php4');
1729
  add_action('admin_print_scripts-' . $addthis, 'addthis_options_page_scripts');
1730
  add_action('admin_print_styles-' . $addthis, 'addthis_options_page_style');
1731
  }
@@ -1737,7 +1783,7 @@ function addthis_admin_menu()
1737
  'style' => addthis_style_default ,
1738
  'location' => 'below',
1739
  'below' => 'fb_tw_p1_sc',
1740
- 'above' => 'fb_tw_p1_sc',
1741
  'addthis_show_stats' => true,
1742
  'addthis_append_data'=> true,
1743
  'addthis_showonhome' => true,
@@ -1772,7 +1818,8 @@ function addthis_admin_menu()
1772
  'addthis_config_json' => '',
1773
  'addthis_share_json' => '',
1774
  'atversion' => ADDTHIS_ATVERSION,
1775
- 'atversion_update_status' => 0
 
1776
  );
1777
 
1778
  function addthis_plugin_options_php4() {
@@ -1821,12 +1868,23 @@ function addthis_plugin_options_php4() {
1821
  ?>
1822
 
1823
  <p><?php echo $addthis_addjs->getAtPluginPromoText(); ?></p>
 
 
1824
  <div class="page-header" id="tabs">
1825
-
1826
- <img alt='addthis' src="//cache.addthis.com/icons/v1/thumbs/32x32/more.png" class="header-img"/>
1827
  <ul class="nav-tab-wrapper">
1828
  <li><h2 class="nav-tab-wrapper"><a href="#tabs-1">Basic</a></h2></li>
1829
  <li><h2 class="nav-tab-wrapper"><a href="#tabs-2">Advanced</a></h2></li>
 
 
 
 
 
 
 
 
 
 
 
1830
  </ul>
1831
  <div class='clear'>&nbsp;</div>
1832
 
@@ -1834,6 +1892,7 @@ function addthis_plugin_options_php4() {
1834
  <?php echo $version_notification_content = _addthis_version_notification($atversion_update_status, $atversion);?>
1835
  <input type="hidden" value="<?php echo $atversion?>" name="addthis_settings[atversion]" id="addthis_atversion_hidden" />
1836
  <input type="hidden" value="<?php echo $atversion_update_status?>" name="addthis_settings[atversion_update_status]" id="addthis_atversion_update_status" />
 
1837
  <table class="form-table">
1838
  <tbody>
1839
  <?php _addthis_choose_icons('above', $options ); ?>
@@ -1843,23 +1902,34 @@ function addthis_plugin_options_php4() {
1843
 
1844
  <br/>
1845
 
1846
- <div style="margin-left:5px;">
1847
- <?php _e("<h3><a href='https://www.addthis.com/register?profile=wpp' target='_blank'>Register</a> for free in-depth analytics reports and better understand your site's social traffic.</h3>", 'addthis_trans_domain');?>
1848
  </div>
1849
- <table class="form-table" style="width:400px;">
1850
  <tbody>
1851
  <tr valign="top">
1852
- <td><?php _e("AddThis profile ID:", 'addthis_trans_domain' ); ?></td>
1853
- <td><input id="addthis_profile" type="text" name="addthis_settings[addthis_profile]" value="<?php echo $profile; ?>" autofill='off' autocomplete='off' /></td>
1854
- </tr>
1855
- <tr valign="top">
1856
- <td><?php _e("AddThis email / username:", 'addthis_trans_domain' ); ?></td>
1857
  <td><input id="addthis_username" type="text" name="addthis_settings[addthis_username]" value="<?php echo $username; ?>" autofill='off' autocomplete='off' /></td>
1858
  </tr>
1859
  <tr id="password_row" >
1860
  <td><?php _e("AddThis password:", 'addthis_trans_domain' ); ?><br/><span style="font-size:10px">(required for displaying stats)</span></td>
1861
  <td><input id="addthis_password" type="password" name="addthis_settings[addthis_password]" value="<?php echo $password; ?>" autocomplete='off' autofill='off' /></td>
1862
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1863
  </tbody>
1864
  </table>
1865
  <div class='clear'>&nbsp;</div>
23
  * Plugin Name: AddThis Social Bookmarking Widget
24
  * Plugin URI: http://www.addthis.com
25
  * Description: Help your visitor promote your site! The AddThis Social Bookmarking Widget allows any visitor to bookmark your site easily with many popular services. Sign up for an AddThis.com account to see how your visitors are sharing your content--which services they're using for sharing, which content is shared the most, and more. It's all free--even the pretty charts and graphs.
26
+ * Version: 3.0
27
  *
28
  * Author: The AddThis Team
29
  * Author URI: http://www.addthis.com/blog
46
 
47
 
48
  define( 'addthis_style_default' , 'fb_tw_p1_sc');
49
+ define( 'ADDTHIS_PLUGIN_VERSION' , '3.0');
50
+ define( 'ADDTHIS_PRODUCT_VERSION' , 'wpp-3.0');
51
  define( 'ADDTHIS_ATVERSION', '300');
52
  define( 'ADDTHIS_ATVERSION_MANUAL_UPDATE', -1);
53
  define( 'ADDTHIS_ATVERSION_AUTO_UPDATE', 0);
80
 
81
  $addthis_new_styles = array(
82
 
83
+ 'fb_tw_p1_sc' => array( 'src' => '<div class="addthis_toolbox addthis_default_style " %s ><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a><a class="addthis_counter addthis_pill_style"></a></div>' , 'img' => 'horizontal_share_rect.png' , 'name' => 'Like, Tweet, +1, Share', 'above' => '', 'below' => ''
84
  ), // facebook tweet plus 1 share counter
85
  'large_toolbox' => array( 'src' => '<div class="addthis_toolbox addthis_default_style addthis_32x32_style" %s ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>', 'img' => 'toolbox-large.png', 'name' => 'Large Toolbox', 'above' => 'hidden ', 'below' => 'hidden'
86
  ), // 32x32
94
  ), // facebook tweet share counter
95
  'simple_button' => array('src' => '<div class="addthis_toolbox addthis_default_style " %s><a href="//addthis.com/bookmark.php?v='.$atversion.'&amp;username=xa-4d2b47f81ddfbdce" class="addthis_button_compact">Share</a></div>', 'img' => 'share.jpg', 'name' => 'Share Button', 'above' => 'hidden ', 'below' => 'hidden', 'defaultHide' => true
96
  ), // Plus sign share
97
+ 'button' => array( 'src' => '<div><a class="addthis_button" href="//addthis.com/bookmark.php?v='.$atversion.'" %s><img src="//cache.addthis.com/cachefly/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>', 'img' => 'horizontal_share.png', 'name' => 'Classic Share Button', 'above' => 'hidden ', 'below' => 'hidden'
98
  ), // classic
99
  'share_counter' => array( 'src' => '<div class="addthis_toolbox addthis_default_style " %s ><a class="addthis_counter"></a></div>', 'img' => 'share_counter.png', 'name' => 'Share Counter', 'above' => 'hidden ', 'below' => 'hidden' , 'defaultHide' => true
100
  ),
870
  $options['wpfooter'] = (bool) $data['wpfooter'];
871
 
872
 
873
+ if (! isset($data['enable_above']) ){
874
+ $options['above'] = 'none';
875
  }
876
  elseif ( isset ($data['show_above']) )
877
  $options['above'] = 'none';
901
 
902
  }
903
 
904
+ if ( ! isset($data['enable_below'] )){
905
+ $options['below'] = 'none';
906
  }
907
  elseif ( isset ($data['show_below']) )
908
  $options['below'] = 'none';
980
  if ( isset ($data['atversion_update_status']))
981
  $options['atversion_update_status'] = sanitize_text_field($data['atversion_update_status']);
982
 
983
+ if ( isset ($data['credential_validation_status']))
984
+ $options['credential_validation_status'] = sanitize_text_field($data['credential_validation_status']);
985
+
986
  if ( isset ($data['addthis_header_background']) && strlen($data['addthis_header_background']) != 0 )
987
  {
988
  if (! strpos($data['addthis_header_background'], '#') === 0)
1563
  return $script;
1564
  }
1565
 
1566
+ add_action('wp_ajax_validate_addthis_api_credentials', 'validate_addthis_api_credentials');
1567
+ /**
1568
+ * AJAX action to test the AddThis credentials
1569
+ */
1570
+ function validate_addthis_api_credentials()
1571
+ {
1572
+ $ajax_response = array('profileerror' => 'true', 'profilemessage' => '',
1573
+ 'credentialerror' => 'true', 'credentialmessage' => '');
1574
+ if ($_POST['addthis_username'] && $_POST['addthis_password'] && $_POST['addthis_profile']) {
1575
+ $url = 'https://api.addthis.com/analytics/1.0/pub/shares.json?'.
1576
+ 'username=' . $_POST['addthis_username'].
1577
+ '&password=' . $_POST['addthis_password'].
1578
+ '&pubid=' . $_POST['addthis_profile'];
1579
+ $response = wp_remote_get($url);
1580
+ $credential_error = '&#x2716; The username, password, and profile combination you entered is invalid.';
1581
+ $profile_error = '&#x2716; Invalid AddThis profile ID';
1582
+
1583
+ if (!is_wp_error($response)) {
1584
+ if ($response['response']['code'] == 200) {
1585
+ $ajax_response['profileerror'] = 'false';
1586
+ $ajax_response['credentialerror'] = 'false';
1587
+ } else {
1588
+ if ($response['response']['code'] != 401) {
1589
+ $ajax_response['credentialerror'] = 'false';
1590
+ if (strpos($response['body'], '"invalidParameterName":"pubid"') === FALSE) {
1591
+ $ajax_response['profileerror'] = 'false';
1592
+ } else {
1593
+ $ajax_response['profilemessage'] = $profile_error;
1594
+ }
1595
+ } else {
1596
+ $ajax_response['credentialmessage'] = $credential_error;
1597
+ }
1598
+ }
1599
+ } else {
1600
+ $ajax_response['credentialmessage'] = 'error';
1601
+ }
1602
+ }
1603
+ die('{"profileerror":"' . $ajax_response['profileerror'] . '","profilemessage":"' . $ajax_response['profilemessage'] . '",
1604
+ "credentialerror":"' . $ajax_response['credentialerror'] . '","credentialmessage":"' . $ajax_response['credentialmessage'] . '"}');
1605
+ }
1606
  /*
1607
  * Merge the Add this settings with that given using JSON format
1608
  * @param String $appendString - The string to build and return the script
1757
  $script_location = apply_filters( 'at_files_uri', plugins_url( '', basename(dirname(__FILE__)) ) ) . '/addthis/js/'.$script ;
1758
  $script_location = apply_filters( 'addthis_files_uri', plugins_url( '', basename(dirname(__FILE__)) ) ) . '/addthis/js/'.$script ;
1759
  wp_enqueue_script( 'addthis_options_page_script', $script_location , array('jquery-ui-tabs', 'thickbox' ));
1760
+ wp_localize_script( 'addthis_options_page_script', 'addthis_option_params', array('wp_ajax_url'=> admin_url('admin-ajax.php'), 'addthis_validate_action' => 'validate_addthis_api_credentials') );
1761
 
1762
  }
1763
 
1771
 
1772
  function addthis_admin_menu()
1773
  {
1774
+ $addthis = add_options_page('AddThis Plugin Options', 'AddThis Share', 'manage_options', basename(__FILE__), 'addthis_plugin_options_php4');
1775
  add_action('admin_print_scripts-' . $addthis, 'addthis_options_page_scripts');
1776
  add_action('admin_print_styles-' . $addthis, 'addthis_options_page_style');
1777
  }
1783
  'style' => addthis_style_default ,
1784
  'location' => 'below',
1785
  'below' => 'fb_tw_p1_sc',
1786
+ 'above' => 'large_toolbox',
1787
  'addthis_show_stats' => true,
1788
  'addthis_append_data'=> true,
1789
  'addthis_showonhome' => true,
1818
  'addthis_config_json' => '',
1819
  'addthis_share_json' => '',
1820
  'atversion' => ADDTHIS_ATVERSION,
1821
+ 'atversion_update_status' => 0,
1822
+ 'credential_validation_status' => 0
1823
  );
1824
 
1825
  function addthis_plugin_options_php4() {
1868
  ?>
1869
 
1870
  <p><?php echo $addthis_addjs->getAtPluginPromoText(); ?></p>
1871
+ <img alt='addthis' src="//cache.addthis.com/icons/v1/thumbs/32x32/more.png" class="header-img"/>
1872
+ <span class="addthis-title">AddThis</span> <span class="addthis-plugin-name">Share</span>
1873
  <div class="page-header" id="tabs">
 
 
1874
  <ul class="nav-tab-wrapper">
1875
  <li><h2 class="nav-tab-wrapper"><a href="#tabs-1">Basic</a></h2></li>
1876
  <li><h2 class="nav-tab-wrapper"><a href="#tabs-2">Advanced</a></h2></li>
1877
+ <li style="float: right; border: none;padding-right:0px;">
1878
+ <strong><?php _e("AddThis Profile ID:", 'addthis_trans_domain' ); ?></strong>
1879
+ <input id="addthis_profile" type="text" name="addthis_settings[addthis_profile]" value="<?php echo $profile; ?>" autofill='off' autocomplete='off' />
1880
+ <br />
1881
+ <span id="addthis-profile-validation-message" style="float: right;color:red;font-size:10px"></span>
1882
+ <?php
1883
+ if ($credential_validation_status == 1) {
1884
+ echo '<span style="float: right;color:green;font-size:10px;">&#10004; Valid AddThis Profile ID</span>';
1885
+ }
1886
+ ?>
1887
+ </li>
1888
  </ul>
1889
  <div class='clear'>&nbsp;</div>
1890
 
1892
  <?php echo $version_notification_content = _addthis_version_notification($atversion_update_status, $atversion);?>
1893
  <input type="hidden" value="<?php echo $atversion?>" name="addthis_settings[atversion]" id="addthis_atversion_hidden" />
1894
  <input type="hidden" value="<?php echo $atversion_update_status?>" name="addthis_settings[atversion_update_status]" id="addthis_atversion_update_status" />
1895
+ <input type="hidden" value="<?php echo $credential_validation_status?>" name="addthis_settings[credential_validation_status]" id="addthis_credential_validation_status" />
1896
  <table class="form-table">
1897
  <tbody>
1898
  <?php _addthis_choose_icons('above', $options ); ?>
1902
 
1903
  <br/>
1904
 
1905
+ <div style="margin-left:5px;font-weight:bold">
1906
+ <?php _e("<a href='https://www.addthis.com/register?profile=wpp' target='_blank'>Register</a> for free in-depth analytics reports and better understand your site's social traffic.", 'addthis_trans_domain');?>
1907
  </div>
1908
+ <table class="form-table" style="width:600px;">
1909
  <tbody>
1910
  <tr valign="top">
1911
+ <td width="200"><?php _e("AddThis email / username:", 'addthis_trans_domain' ); ?></td>
 
 
 
 
1912
  <td><input id="addthis_username" type="text" name="addthis_settings[addthis_username]" value="<?php echo $username; ?>" autofill='off' autocomplete='off' /></td>
1913
  </tr>
1914
  <tr id="password_row" >
1915
  <td><?php _e("AddThis password:", 'addthis_trans_domain' ); ?><br/><span style="font-size:10px">(required for displaying stats)</span></td>
1916
  <td><input id="addthis_password" type="password" name="addthis_settings[addthis_password]" value="<?php echo $password; ?>" autocomplete='off' autofill='off' /></td>
1917
  </tr>
1918
+ <tr>
1919
+ <td style="height:32px">
1920
+
1921
+ </td>
1922
+ <td style="vertical-align:top;margin-top:0;padding-top:0;line-height:5px;font-size:10px">
1923
+ <img class="addthis-admin-loader" style="display:none" src="<?php echo plugins_url('img/loader.gif', __FILE__)?>" />
1924
+ <span class="addthis-admin-loader" style="display:none;color:gray">Connecting to AddThis profile <?php echo $profile; ?>..</span>
1925
+ <span id="addthis-credential-validation-message" style="color:red"></span>
1926
+ <?php
1927
+ if ($credential_validation_status == 1) {
1928
+ echo '<span style="color:green">&#10004; Valid AddThis Credentials</span>';
1929
+ }
1930
+ ?>
1931
+ </td>
1932
+ </tr>
1933
  </tbody>
1934
  </table>
1935
  <div class='clear'>&nbsp;</div>
css/options-page.css CHANGED
@@ -42,6 +42,7 @@ ul.nav-tab-wrapper li.ui-tabs-selected{
42
 
43
  .select_row {
44
  line-height: 32px;
 
45
  }
46
  .select_row .radio {
47
  display: inline-block;
@@ -172,4 +173,24 @@ width: 36px;
172
  background-color: #DDEFD7;
173
  border-color: #D0E2C9;
174
  color: #6A9B58;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
42
 
43
  .select_row {
44
  line-height: 32px;
45
+ padding-left:20px;
46
  }
47
  .select_row .radio {
48
  display: inline-block;
173
  background-color: #DDEFD7;
174
  border-color: #D0E2C9;
175
  color: #6A9B58;
176
+ }
177
+ .addthis-title {
178
+ color: #000;
179
+ font-size: 36px;
180
+ padding-left: 3px;
181
+ font-family: "HelveticaNeueBold","HelveticaNeue-Bold","Helvetica Neue", Helvetica, "open sans",arial,sans-serif;
182
+ font-weight: normal;
183
+ }
184
+ .addthis-plugin-name {
185
+ color: gray;
186
+ font-size: 36px;
187
+ font-weight: normal;
188
+ font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, "open sans",arial,sans-serif;
189
+ }
190
+
191
+ .enable-sharing-tool {
192
+ padding-bottom: 12px;
193
+ }
194
+ #wpbody-content {
195
+ font-family: Arial;
196
  }
img/horizontal_share.png ADDED
Binary file
img/horizontal_share_rect.png ADDED
Binary file
img/loader.gif ADDED
Binary file
img/toolbox-large.png CHANGED
Binary file
img/toolbox-small.png CHANGED
Binary file
js/options-page.32.js CHANGED
@@ -40,6 +40,7 @@ jQuery(document).ready(function($) {
40
  action: 'at_save_transient',
41
  value : stuff
42
  };
 
43
 
44
  jQuery.post(ajaxurl, data, function(response) {
45
  // Fix for WP 2.9's version of lightbox
@@ -72,24 +73,27 @@ jQuery(document).ready(function($) {
72
  });
73
  return false;
74
  });
75
- /**
76
- * Handle the toggling for More and Less options
77
- */
78
- $('#above_more, #below_more').click( function() {
79
- var allSharingRows = $(this).closest('td').find('.select_row');
80
- var toggleSharingRows = allSharingRows.find('input').not(':checked').not('.always').parent().parent();
81
- if($(this).children('span').not(".hidden").html() == "More options") {
82
- toggleSharingRows.removeClass('hidden');
83
- } else {
84
- toggleSharingRows.addClass('hidden');
85
- //1) "None" is selected 2) Minimized state => always display the first row.
86
- if (allSharingRows.find(".always").is(":checked")) {
87
- toggleSharingRows.first().removeClass('hidden');
88
- }
89
- }
90
- $(this).children('span').toggleClass('hidden');
91
- return false;
92
- });
 
 
 
93
 
94
  var show_above = $('input[name="addthis_settings[show_above]"]');
95
  var show_below = $('input[name="addthis_settings[show_below]"]');
@@ -200,5 +204,89 @@ jQuery(document).ready(function($) {
200
  $(this).closest("form").submit();
201
  return false;
202
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  });
40
  action: 'at_save_transient',
41
  value : stuff
42
  };
43
+
44
 
45
  jQuery.post(ajaxurl, data, function(response) {
46
  // Fix for WP 2.9's version of lightbox
73
  });
74
  return false;
75
  });
76
+
77
+ /**
78
+ * Handle enable disable top and bottom share buttons
79
+ */
80
+ $("#enable_above, #enable_below").click(enableShareIconsClickHandler);
81
+
82
+ function enableShareIconsClickHandler(){
83
+ toggleShareIconsContainer($(this));
84
+ }
85
+ function toggleShareIconsContainer(element){
86
+ var animationContainer = element.closest("td").find(".select_row");
87
+ if (!element.attr("checked")) {
88
+ animationContainer.css("opacity", 0.4);
89
+ animationContainer.find("input").attr("disabled", true);
90
+ } else {
91
+ animationContainer.css("opacity", 1);
92
+ animationContainer.find("input").attr("disabled", false);
93
+ }
94
+ }
95
+ toggleShareIconsContainer($("#enable_above"));
96
+ toggleShareIconsContainer($("#enable_below"));
97
 
98
  var show_above = $('input[name="addthis_settings[show_above]"]');
99
  var show_below = $('input[name="addthis_settings[show_below]"]');
204
  $(this).closest("form").submit();
205
  return false;
206
  });
207
+
208
+ var addthis_credential_validation_status = $("#addthis_credential_validation_status");
209
+ var addthis_validation_message = $("#addthis-credential-validation-message");
210
+ var addthis_profile_validation_message = $("#addthis-profile-validation-message");
211
+ //Validate the Addthis credentials
212
+ window.skipValidationInternalError = false;
213
+ function validate_addthis_credentials() {
214
+ $.ajax(
215
+ {"url" : addthis_option_params.wp_ajax_url,
216
+ "type" : "post",
217
+ "data" : {"action" : addthis_option_params.addthis_validate_action,
218
+ "addthis_profile" : $("#addthis_profile").val(),
219
+ "addthis_username" : $("#addthis_username").val(),
220
+ "addthis_password" : $("#addthis_password").val()
221
+ },
222
+ "dataType" : "json",
223
+ "beforeSend" : function() {
224
+ $(".addthis-admin-loader").show();
225
+ addthis_validation_message.html("").next().hide();
226
+ addthis_profile_validation_message.html("").next().hide();
227
+ },
228
+ "success": function(data) {
229
+ addthis_validation_message.show();
230
+ addthis_profile_validation_message.show();
231
+
232
+ if (data.credentialmessage == "error" || (data.profileerror == "false" && data.credentialerror == "false")) {
233
+ if (data.credentialmessage != "error") {
234
+ addthis_credential_validation_status.val(1);
235
+ } else {
236
+ window.skipValidationInternalError = true;
237
+ }
238
+ $("#addthis_settings").submit();
239
+ } else {
240
+ addthis_validation_message.html(data.credentialmessage);
241
+ addthis_profile_validation_message.html(data.profilemessage);
242
+ if (data.profilemessage != "") {
243
+ $('html, body').animate({"scrollTop":0}, 'slow');
244
+ }
245
+ }
246
 
247
+ },
248
+ "complete" :function(data) {
249
+ $(".addthis-admin-loader").hide();
250
+ },
251
+ "error" : function(jqXHR, textStatus, errorThrown) {
252
+ console.log(textStatus, errorThrown);
253
+ }
254
+ });
255
+ }
256
+ //Prevent default form submission
257
+ $("#addthis_settings").submit(function(){
258
+ if(window.skipValidationInternalError) {
259
+ return true;
260
+ }
261
+ var isProfileEmpty = $.trim($("#addthis_profile").val()) == "";
262
+ var isUsernameEmpty = $.trim($("#addthis_username").val()) == "";
263
+ var isPasswordEmpty = $.trim($("#addthis_password").val()) == "";
264
+ var isAnyFieldEmpty = isProfileEmpty || isUsernameEmpty || isPasswordEmpty;
265
+ var validationRequired = addthis_credential_validation_status.val() == 0;
266
+
267
+ if(isUsernameEmpty != isPasswordEmpty) {
268
+ var emptyLabel = isUsernameEmpty ? "username" : "password";
269
+ addthis_validation_message.html("&#x2716; AddThis " + emptyLabel + " is required to view analytics").next().hide();
270
+ return false;
271
+ } else if (isProfileEmpty && !isUsernameEmpty && !isPasswordEmpty) {
272
+ addthis_profile_validation_message.html("&#x2716; AddThis profile ID is required to view analytics").next().hide();
273
+ $('html, body').animate({"scrollTop":0}, 'slow');
274
+ return false;
275
+ } else if (!validationRequired || isAnyFieldEmpty) {
276
+ return true;
277
+ } else if(!isAnyFieldEmpty && validationRequired) {
278
+ validate_addthis_credentials();
279
+ return false;
280
+ }
281
+ });
282
+
283
+ $("#addthis_username, #addthis_password, #addthis_profile").change(function(){
284
+ addthis_credential_validation_status.val(0);
285
+ if($.trim($("#addthis_profile").val()) == "") {
286
+ addthis_profile_validation_message.next().hide();
287
+ }
288
+ if(($.trim($("#addthis_username").val()) == "") || ($.trim($("#addthis_password").val()) == "")) {
289
+ addthis_validation_message.next().hide();
290
+ }
291
+ });
292
  });
js/options-page.js CHANGED
@@ -76,32 +76,34 @@ jQuery(document).ready(function($) {
76
  });
77
 
78
  /**
79
- * Handle the toggling for More and Less options
80
- */
81
- $('#above_more, #below_more').click( function() {
82
- var allSharingRows = $(this).closest('td').find('.select_row');
83
- var toggleSharingRows = allSharingRows.find('input').not(':checked').not('.always').parent().parent();
84
- if($(this).children('span').not(".hidden").html() == "More options") {
85
- toggleSharingRows.removeClass('hidden');
86
- } else {
87
- toggleSharingRows.addClass('hidden');
88
- //1) "None" is selected 2) Minimized state => always display the first row.
89
- if (allSharingRows.find(".always").is(":checked")) {
90
- toggleSharingRows.first().removeClass('hidden');
91
- }
92
- }
93
- $(this).children('span').toggleClass('hidden');
94
- return false;
95
- });
 
 
96
 
97
  var show_above = $('input[name="addthis_settings[show_above]"]');
98
  var show_below = $('input[name="addthis_settings[show_below]"]');
99
- if ( show_above.attr('checked') != "undefined" && show_above.attr('checked') == true)
100
  {
101
  $('.above_option').toggleClass('hide');
102
  }
103
 
104
- if ( show_below.attr('checked') != "undefined" && show_below.attr('checked') == true)
105
  {
106
  $('.below_option').toggleClass('hide');
107
  }
@@ -117,7 +119,7 @@ jQuery(document).ready(function($) {
117
 
118
  var aboveCustom = $('#above_custom_button');
119
  var aboveCustomShow = function(){
120
- if ( aboveCustom.attr('checked') != 'undefined' && aboveCustom.attr('checked') == true)
121
  {
122
  $('.above_option_custom').removeClass('hidden');
123
  }
@@ -128,7 +130,7 @@ jQuery(document).ready(function($) {
128
  };
129
  var belowCustom = $('#below_custom_button');
130
  var belowCustomShow = function(){
131
- if ( belowCustom.attr('checked') != 'undefined' && belowCustom.attr('checked') == true)
132
  {
133
  $('.below_option_custom').removeClass('hidden');
134
  }
@@ -140,7 +142,7 @@ jQuery(document).ready(function($) {
140
 
141
  var aboveCustomString = $('#above_custom_string');
142
  var aboveCustomStringShow = function(){
143
- if ( aboveCustomString.attr('checked') != 'undefined' && aboveCustomString.attr('checked') == true)
144
  {
145
  $('.above_custom_string_input').removeClass('hidden');
146
  }
@@ -203,4 +205,88 @@ jQuery(document).ready(function($) {
203
  return false;
204
  });
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  });
76
  });
77
 
78
  /**
79
+ * Handle enable disable top and bottom share buttons
80
+ */
81
+ $("#enable_above, #enable_below").click(enableShareIconsClickHandler);
82
+
83
+ function enableShareIconsClickHandler(){
84
+ toggleShareIconsContainer($(this));
85
+ }
86
+ function toggleShareIconsContainer(element){
87
+ var animationContainer = element.closest("td").find(".select_row");
88
+ if (!element.attr("checked")) {
89
+ animationContainer.css("opacity", 0.4);
90
+ animationContainer.find("input").attr("disabled", true);
91
+ } else {
92
+ animationContainer.css("opacity", 1);
93
+ animationContainer.find("input").attr("disabled", false);
94
+ }
95
+ }
96
+ toggleShareIconsContainer($("#enable_above"));
97
+ toggleShareIconsContainer($("#enable_below"));
98
 
99
  var show_above = $('input[name="addthis_settings[show_above]"]');
100
  var show_below = $('input[name="addthis_settings[show_below]"]');
101
+ if ( show_above.prop('checked') != "undefined" && show_above.prop('checked') == true)
102
  {
103
  $('.above_option').toggleClass('hide');
104
  }
105
 
106
+ if ( show_below.prop('checked') != "undefined" && show_below.prop('checked') == true)
107
  {
108
  $('.below_option').toggleClass('hide');
109
  }
119
 
120
  var aboveCustom = $('#above_custom_button');
121
  var aboveCustomShow = function(){
122
+ if ( aboveCustom.prop('checked') != 'undefined' && aboveCustom.prop('checked') == true)
123
  {
124
  $('.above_option_custom').removeClass('hidden');
125
  }
130
  };
131
  var belowCustom = $('#below_custom_button');
132
  var belowCustomShow = function(){
133
+ if ( belowCustom.prop('checked') != 'undefined' && belowCustom.prop('checked') == true)
134
  {
135
  $('.below_option_custom').removeClass('hidden');
136
  }
142
 
143
  var aboveCustomString = $('#above_custom_string');
144
  var aboveCustomStringShow = function(){
145
+ if ( aboveCustomString.prop('checked') != 'undefined' && aboveCustomString.prop('checked') == true)
146
  {
147
  $('.above_custom_string_input').removeClass('hidden');
148
  }
205
  return false;
206
  });
207
 
208
+ var addthis_credential_validation_status = $("#addthis_credential_validation_status");
209
+ var addthis_validation_message = $("#addthis-credential-validation-message");
210
+ var addthis_profile_validation_message = $("#addthis-profile-validation-message");
211
+ //Validate the Addthis credentials
212
+ window.skipValidationInternalError = false;
213
+ function validate_addthis_credentials() {
214
+ $.ajax(
215
+ {"url" : addthis_option_params.wp_ajax_url,
216
+ "type" : "post",
217
+ "data" : {"action" : addthis_option_params.addthis_validate_action,
218
+ "addthis_profile" : $("#addthis_profile").val(),
219
+ "addthis_username" : $("#addthis_username").val(),
220
+ "addthis_password" : $("#addthis_password").val()
221
+ },
222
+ "dataType" : "json",
223
+ "beforeSend" : function() {
224
+ $(".addthis-admin-loader").show();
225
+ addthis_validation_message.html("").next().hide();
226
+ addthis_profile_validation_message.html("").next().hide();
227
+ },
228
+ "success": function(data) {
229
+ addthis_validation_message.show();
230
+ addthis_profile_validation_message.show();
231
+
232
+ if (data.credentialmessage == "error" || (data.profileerror == "false" && data.credentialerror == "false")) {
233
+ if (data.credentialmessage != "error") {
234
+ addthis_credential_validation_status.val(1);
235
+ } else {
236
+ window.skipValidationInternalError = true;
237
+ }
238
+ $("#addthis_settings").submit();
239
+ } else {
240
+ addthis_validation_message.html(data.credentialmessage);
241
+ addthis_profile_validation_message.html(data.profilemessage);
242
+ if (data.profilemessage != "") {
243
+ $('html, body').animate({"scrollTop":0}, 'slow');
244
+ }
245
+ }
246
+
247
+ },
248
+ "complete" :function(data) {
249
+ $(".addthis-admin-loader").hide();
250
+ },
251
+ "error" : function(jqXHR, textStatus, errorThrown) {
252
+ console.log(textStatus, errorThrown);
253
+ }
254
+ });
255
+ }
256
+ //Prevent default form submission
257
+ $("#addthis_settings").submit(function(){
258
+ if(window.skipValidationInternalError) {
259
+ return true;
260
+ }
261
+ var isProfileEmpty = $.trim($("#addthis_profile").val()) == "";
262
+ var isUsernameEmpty = $.trim($("#addthis_username").val()) == "";
263
+ var isPasswordEmpty = $.trim($("#addthis_password").val()) == "";
264
+ var isAnyFieldEmpty = isProfileEmpty || isUsernameEmpty || isPasswordEmpty;
265
+ var validationRequired = addthis_credential_validation_status.val() == 0;
266
+
267
+ if(isUsernameEmpty != isPasswordEmpty) {
268
+ var emptyLabel = isUsernameEmpty ? "username" : "password";
269
+ addthis_validation_message.html("&#x2716; AddThis " + emptyLabel + " is required to view analytics").next().hide();
270
+ return false;
271
+ } else if (isProfileEmpty && !isUsernameEmpty && !isPasswordEmpty) {
272
+ addthis_profile_validation_message.html("&#x2716; AddThis profile ID is required to view analytics").next().hide();
273
+ $('html, body').animate({"scrollTop":0}, 'slow');
274
+ return false;
275
+ } else if (!validationRequired || isAnyFieldEmpty) {
276
+ return true;
277
+ } else if(!isAnyFieldEmpty && validationRequired) {
278
+ validate_addthis_credentials();
279
+ return false;
280
+ }
281
+ });
282
+
283
+ $("#addthis_username, #addthis_password, #addthis_profile").change(function(){
284
+ addthis_credential_validation_status.val(0);
285
+ if($.trim($("#addthis_profile").val()) == "") {
286
+ addthis_profile_validation_message.next().hide();
287
+ }
288
+ if(($.trim($("#addthis_username").val()) == "") || ($.trim($("#addthis_password").val()) == "")) {
289
+ addthis_validation_message.next().hide();
290
+ }
291
+ });
292
  });
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: srijith.v, solchea, jorbin, _mjk_, addthis_paul, joesullivan
3
  Tags: share, addthis, social, bookmark, sharing, bookmarking, widget,AddThis, addtoany, aim, bookmark, buzz, del.icio.us, Digg,e-mail, email, Facebook, google bookmarks, google buzz, myspace,network, NewsVine, Reddit, Share, share this, sharethis, social, socialize, stumbleupon, twitter, windows live, yahoo buzz, pintrest, widget
4
  Requires at least: 2.9
5
  Tested up to: 3.4.2
6
- Stable tag: 2.5.1
7
 
8
  The AddThis Social Bookmarking Widget allows any visitor to bookmark and share your site easily with over 330 popular services.
9
 
@@ -78,6 +78,11 @@ In the screen options you can enable the AddThis meta box. Check the box and sa
78
  PHP 5+ is preferred; PHP 4 is supported.
79
 
80
  == Changelog ==
 
 
 
 
 
81
  = 2.5.1 =
82
  * Added hashtag support for Twitter
83
  * Conflict removed with <a href="http://wordpress.org/extend/plugins/addthis-follow/">AddThis Follow</a> and <a href="http://wordpress.org/extend/plugins/addthis-welcome/">AddThis Welcome Bar</a> Wordpress plugins
@@ -202,6 +207,9 @@ Fixed nondeterministic bug with the_title(), causing the title to occasionally a
202
 
203
 
204
  == Upgrade Notice ==
 
 
 
205
  = 2.5.1 =
206
  Bug fixes.
207
 
3
  Tags: share, addthis, social, bookmark, sharing, bookmarking, widget,AddThis, addtoany, aim, bookmark, buzz, del.icio.us, Digg,e-mail, email, Facebook, google bookmarks, google buzz, myspace,network, NewsVine, Reddit, Share, share this, sharethis, social, socialize, stumbleupon, twitter, windows live, yahoo buzz, pintrest, widget
4
  Requires at least: 2.9
5
  Tested up to: 3.4.2
6
+ Stable tag: 3.0
7
 
8
  The AddThis Social Bookmarking Widget allows any visitor to bookmark and share your site easily with over 330 popular services.
9
 
78
  PHP 5+ is preferred; PHP 4 is supported.
79
 
80
  == Changelog ==
81
+ = 3.0 =
82
+ * UX changes in admin settings
83
+ * Credential verification in Admin settings. If AddThis account details are wrong it will be notified to user.
84
+ * Bug fixes
85
+
86
  = 2.5.1 =
87
  * Added hashtag support for Twitter
88
  * Conflict removed with <a href="http://wordpress.org/extend/plugins/addthis-follow/">AddThis Follow</a> and <a href="http://wordpress.org/extend/plugins/addthis-welcome/">AddThis Welcome Bar</a> Wordpress plugins
207
 
208
 
209
  == Upgrade Notice ==
210
+ = 3.0 =
211
+ Updated UI, AddThis account verification and bug fixes.
212
+
213
  = 2.5.1 =
214
  Bug fixes.
215