WordPress Share Buttons Plugin – AddThis - Version 1.6.0

Version Description

Download this release

Release Info

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

Code changes from version 1.5.5 to 1.6.0

Files changed (4) hide show
  1. addthis_social_widget.php +270 -43
  2. css/addthis.css +86 -0
  3. js/addthis.js +99 -0
  4. readme.txt +22 -7
addthis_social_widget.php CHANGED
@@ -27,18 +27,24 @@ else return;
27
  * Plugin Name: AddThis Social Bookmarking Widget
28
  * Plugin URI: http://www.addthis.com
29
  * 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.
30
- * Version: 1.5.5
31
  *
32
  * Author: The AddThis Team
33
  * Author URI: http://www.addthis.com
34
  */
35
- $addthis_settings = array(array('isdropdown', 'true'),
36
- array('customization', ''),
37
- array('language', 'en'),
38
- array('username', ''),
39
- array('style', 'share'));
40
 
41
- $addthis_languages = array('zh'=>'Chinese', 'da'=>'Danish', 'nl'=>'Dutch', 'en'=>'English', 'fi'=>'Finnish', 'fr'=>'French', 'de'=>'German', 'he'=>'Hebrew', 'it'=>'Italian', 'ja'=>'Japanese', 'ko'=>'Korean', 'no'=>'Norwegian', 'pl'=>'Polish', 'pt'=>'Portugese', 'ru'=>'Russian', 'es'=>'Spanish', 'sv'=>'Swedish');
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  $addthis_styles = array(
44
  'share' => array('img'=>'lg-share-%lang%.gif', 'w'=>125, 'h'=>16),
@@ -51,20 +57,161 @@ $addthis_styles = array(
51
  , 'custom' => array('img'=>'http://example.com/button.gif', 'w'=>16, 'h'=>16) */
52
  );
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  /**
56
  * Adds WP filter so we can append the AddThis button to post content.
57
  */
58
- function addthis_init($username=null, $style=null)
59
  {
60
  global $addthis_settings;
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  add_filter('the_content', 'addthis_social_widget');
63
  add_filter('admin_menu', 'addthis_admin_menu');
64
 
65
  add_option('addthis_username');
66
- add_option('addthis_options', 'email, favorites, digg, delicious, myspace, google, facebook, reddit, live, more');
 
 
 
 
67
  add_option('addthis_isdropdown', 'true');
 
68
  add_option('addthis_showonhome', 'true');
69
  add_option('addthis_showonpages', 'false');
70
  add_option('addthis_showoncats', 'false');
@@ -77,23 +224,30 @@ function addthis_init($username=null, $style=null)
77
  add_option('addthis_language', 'en');
78
 
79
  $addthis_settings['sidebar_only'] = get_option('addthis_sidebar_only') === 'true';
80
- $addthis_settings['isdropdown'] = get_option('addthis_isdropdown') === 'true';
81
  $addthis_settings['showonhome'] = !(get_option('addthis_showonhome') !== 'true');
82
  $addthis_settings['showonpages'] = get_option('addthis_showonpages') === 'true';
83
  $addthis_settings['showonarchives'] = get_option('addthis_showonarchives') === 'true';
84
  $addthis_settings['showoncats'] = get_option('addthis_showoncats') === 'true';
85
 
86
- if (!isset($style)) $style = get_option('addthis_style');
 
 
 
87
  if (strlen($style) == 0) $style = 'share';
88
  $addthis_settings['style'] = $style;
89
 
90
- if (!isset($username)) $username = get_option('addthis_username');
91
- $addthis_settings['username'] = $username;
 
 
 
 
92
 
93
  $language = get_option('addthis_language');
94
  $addthis_settings['language'] = $language;
95
 
96
- $advopts = array('brand', 'language', 'header_background', 'header_color', 'options');
97
  $addthis_settings['customization'] = '';
98
  for ($i = 0; $i < count($advopts); $i++)
99
  {
@@ -101,8 +255,13 @@ function addthis_init($username=null, $style=null)
101
  $val = get_option("addthis_$opt");
102
  if (isset($val) && strlen($val)) $addthis_settings['customization'] .= "var addthis_$opt = '$val';";
103
  }
 
104
 
105
  add_action('widgets_init', 'addthis_widget_init');
 
 
 
 
106
  }
107
 
108
  function addthis_widget_init()
@@ -138,26 +297,53 @@ function addthis_social_widget($content, $sidebar = false)
138
  else if (is_category() && !$addthis_settings['showoncats']) return $content;
139
  }
140
 
141
- $pub = $addthis_settings['username'];
142
- $link = $sidebar ? '[URL]' : urlencode(get_permalink());
143
- $title = $sidebar ? '[TITLE]' : urlencode(get_the_title($id));
 
 
 
 
 
 
144
 
145
- $content .= "\n<!-- AddThis Button BEGIN -->\n";
146
- if ($addthis_settings['isdropdown'])
 
147
  {
148
- if (isset($pub) || strlen($addthis_settings['customization']))
149
- {
150
- $content .= '<script type="text/javascript">' . (isset($pub) ? "\nvar addthis_pub = '$pub';\n" : "\n") . ($addthis_settings['customization']) . "\n</script>\n";
151
- }
 
 
152
  $content .= <<<EOF
153
- <div class="addthis_container"><a href="http://www.addthis.com/bookmark.php?v=250" onmouseover="return addthis_open(this, '', '$link', '$title')" onmouseout="addthis_close()" onclick="return addthis_sendto()">
 
154
  EOF;
155
- $content .= addthis_get_button_img() . '</a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
  else
158
  {
159
  $content .= <<<EOF
160
- <div class="addthis_container"><a href="http://www.addthis.com/bookmark.php?v=250" onclick="window.open('http://www.addthis.com/bookmark.php?v=250&pub=$pub&amp;url=$link&amp;title=$title', 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank">
 
161
  EOF;
162
  $content .= addthis_get_button_img() . '</a></div>';
163
  }
@@ -188,7 +374,7 @@ function addthis_get_button_img()
188
 
189
  if (!isset($addthis_styles[$btnStyle])) $btnStyle = 'share';
190
  $btnRecord = $addthis_styles[$btnStyle];
191
- $btnUrl = (strpos(trim($btnRecord['img']), 'http://') !== 0 ? "http://s7.addthis.com/static/btn/" : "") . $btnRecord['img'];
192
 
193
  if (strpos($btnUrl, '%lang%') !== false)
194
  {
@@ -210,13 +396,21 @@ function addthis_plugin_options_php4() {
210
  global $addthis_styles;
211
  global $addthis_languages;
212
  global $addthis_settings;
 
213
 
214
  ?>
215
  <div class="wrap">
216
  <h2>AddThis</h2>
217
 
218
  <form method="post" action="options.php">
219
- <?php wp_nonce_field('update-options'); ?>
 
 
 
 
 
 
 
220
 
221
  <h3>Required</h3>
222
  <table class="form-table">
@@ -224,7 +418,20 @@ function addthis_plugin_options_php4() {
224
  <th scope="row"><?php _e("AddThis username:", 'addthis_trans_domain' ); ?></th>
225
  <td><input type="text" name="addthis_username" value="<?php echo get_option('addthis_username'); ?>" /></td>
226
  </tr>
227
- <tr valign="top">
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  <th scope="row"><?php _e("Button style:", 'addthis_trans_domain' ); ?></th>
229
  <td>
230
  <select name="addthis_style">
@@ -239,11 +446,7 @@ function addthis_plugin_options_php4() {
239
  </td>
240
  </tr>
241
  <tr>
242
- <th scope="row"><?php _e("Use dropdown menu:", 'addthis_trans_domain' ); ?></th>
243
- <td><input type="checkbox" name="addthis_isdropdown" value="true" <?php echo (get_option('addthis_isdropdown') == 'true' ? 'checked' : ''); ?>/></td>
244
- </tr>
245
- <tr>
246
- <th scope="row"><?php _e("Show in sidebar only:", 'addthis_trans_domain' ); ?></th>
247
  <td><input type="checkbox" name="addthis_sidebar_only" value="true" <?php echo (get_option('addthis_sidebar_only') == 'true' ? 'checked' : ''); ?>/></td>
248
  </tr>
249
  </table>
@@ -254,17 +457,29 @@ function addthis_plugin_options_php4() {
254
 
255
  <h3>Advanced</h3>
256
  <table class="form-table">
257
- <tr valign="top">
258
- <td colspan="2">See <a href="http://addthis.com/customization">our customization docs</a>.</td>
259
- </tr>
 
260
  <tr>
261
- <th scope="row"><?php _e("Show on <a href=\"http://codex.wordpress.org/Pages\" target=\"blank\">pages</a>:", 'addthis_trans_domain' ); ?></th>
262
- <td><input type="checkbox" name="addthis_showonpages" value="true" <?php echo (get_option('addthis_showonpages') !== '' ? 'checked' : ''); ?>/></td>
263
  </tr>
 
 
 
 
 
 
 
264
  <tr>
265
  <th scope="row"><?php _e("Show on homepage:", 'addthis_trans_domain' ); ?></th>
266
  <td><input type="checkbox" name="addthis_showonhome" value="true" <?php echo (get_option('addthis_showonhome') == 'true' ? 'checked' : ''); ?>/></td>
267
  </tr>
 
 
 
 
268
  <tr>
269
  <th scope="row"><?php _e("Show in archives:", 'addthis_trans_domain' ); ?></th>
270
  <td><input type="checkbox" name="addthis_showonarchives" value="true" <?php echo (get_option('addthis_showonarchives') == 'true' ? 'checked' : ''); ?>/></td>
@@ -273,13 +488,19 @@ function addthis_plugin_options_php4() {
273
  <th scope="row"><?php _e("Show in categories:", 'addthis_trans_domain' ); ?></th>
274
  <td><input type="checkbox" name="addthis_showoncats" value="true" <?php echo (get_option('addthis_showoncats') == 'true' ? 'checked' : ''); ?>/></td>
275
  </tr>
 
 
 
 
 
 
276
  <tr valign="top">
277
  <th scope="row"><?php _e("Brand:", 'addthis_trans_domain' ); ?></th>
278
  <td><input type="text" name="addthis_brand" value="<?php echo get_option('addthis_brand'); ?>" /></td>
279
  </tr>
280
  <tr valign="top">
281
- <th scope="row"><?php _e("Drop-down options (comma-separated):", 'addthis_trans_domain' ); ?></th>
282
- <td><input type="text" name="addthis_options" value="<?php echo get_option('addthis_options'); ?>" size="100"/></td>
283
  </tr>
284
  <tr valign="top">
285
  <th scope="row"><?php _e("Language:", 'addthis_trans_domain' ); ?></th>
@@ -305,9 +526,15 @@ function addthis_plugin_options_php4() {
305
  </tr>
306
  </table>
307
 
 
 
 
 
308
  <input type="hidden" name="action" value="update" />
309
- <input type="hidden" name="page_options" value="addthis_username,addthis_style,addthis_sidebar_only,addthis_isdropdown,addthis_showonpages,addthis_showoncats,addthis_showonhome,addthis_showonarchives,addthis_language,addthis_brand,addthis_options,addthis_header_background,addthis_header_color"/>
310
-
 
 
311
  <p class="submit">
312
  <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
313
  </p>
27
  * Plugin Name: AddThis Social Bookmarking Widget
28
  * Plugin URI: http://www.addthis.com
29
  * 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.
30
+ * Version: 1.6.0
31
  *
32
  * Author: The AddThis Team
33
  * Author URI: http://www.addthis.com
34
  */
 
 
 
 
 
35
 
36
+ $addthis_settings = array();
37
+ $addthis_settings['isdropdown'] = 'true';
38
+ $addthis_settings['customization'] = '';
39
+ $addthis_settings['menu_type'] = 'dropdown';
40
+ $addthis_settings['language'] = 'en';
41
+ $addthis_settings['username'] = '';
42
+ $addthis_settings['fallback_username'] = '';
43
+ $addthis_settings['style'] = 'share';
44
+
45
+ $addthis_languages = array('af'=>'Afrikaaner', 'ar'=>'Arabic', 'zh'=>'Chinese', 'cs'=>'Czech', 'da'=>'Danish', 'nl'=>'Dutch', 'en'=>'English', 'fa'=>'Farsi', 'fi'=>'Finnish', 'fr'=>'French', 'ga'=>'Gaelic', 'de'=>'German', 'el'=>'Greek', 'he'=>'Hebrew', 'hi'=>'Hindi', 'it'=>'Italian', 'ja'=>'Japanese', 'ko'=>'Korean', 'lv'=>'Latvian', 'lt'=>'Lithuanian', 'no'=>'Norwegian', 'pl'=>'Polish', 'pt'=>'Portugese', 'ro'=>'Romanian', 'ru'=>'Russian', 'sk'=>'Slovakian', 'sl'=>'Slovenian', 'es'=>'Spanish', 'sv'=>'Swedish', 'th'=>'Thai', 'ur'=>'Urdu', 'cy'=>'Welsh', 'vi'=>'Vietnamese');
46
+
47
+ $addthis_menu_types = array('static', 'dropdown', 'toolbox');
48
 
49
  $addthis_styles = array(
50
  'share' => array('img'=>'lg-share-%lang%.gif', 'w'=>125, 'h'=>16),
57
  , 'custom' => array('img'=>'http://example.com/button.gif', 'w'=>16, 'h'=>16) */
58
  );
59
 
60
+ // Pre-2.6 compatibility
61
+ if ( ! defined( 'WP_CONTENT_URL' ) )
62
+ define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
63
+ if ( ! defined( 'WP_CONTENT_DIR' ) )
64
+ define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
65
+ if ( ! defined( 'WP_PLUGIN_URL' ) )
66
+ define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
67
+ if ( ! defined( 'WP_PLUGIN_DIR' ) )
68
+ define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
69
+
70
+ /**
71
+ * Generates unique IDs
72
+ */
73
+ function cuid()
74
+ {
75
+ $mt = dechex(mt_rand(0,min(0xffffffff,mt_getrandmax())));
76
+ $now = dechex(time());
77
+ $cuid = $now . str_pad($mt, 8, '0', STR_PAD_LEFT);
78
+ return $cuid;
79
+ }
80
+
81
+ /**
82
+ * Returns major.minor WordPress version.
83
+ */
84
+ function get_wp_version() {
85
+ return (float)substr(get_bloginfo('version'),0,3);
86
+ }
87
+
88
+
89
+ /**
90
+ * Adds AddThis CSS to page. Only used for admin dashboard in WP 2.7 and higher.
91
+ */
92
+ function addthis_print_style() {
93
+ wp_enqueue_style( 'addthis' );
94
+ }
95
+
96
+ /**
97
+ * Adds AddThis script to page. Only used for admin dashboard in WP 2.7 and higher.
98
+ */
99
+ function addthis_print_script() {
100
+ wp_enqueue_script( 'addthis' );
101
+ }
102
+
103
+ /**
104
+ * Our admin dashboard widget shows yesterday's top shared content and top shared-to services.
105
+ * Data is fetched via AJAX. We assume jQuery is available on any WP install supporting
106
+ * dashboard widgets.
107
+ *
108
+ * @see js/addthis.js
109
+ * @see js/addthis.css
110
+ */
111
+ function addthis_render_dashboard_widget() {
112
+ global $addthis_settings;
113
+ $username = urlencode($addthis_settings['username']);
114
+ $password = urlencode($addthis_settings['password']);
115
+
116
+ echo <<<ENDHTML
117
+ <p id="addthis_header" class="sub">Loading...</p>
118
+ <div id="addthis_data_container">
119
+ <div class="sub">
120
+ <table id="addthis_tab_table" style="display:none">
121
+ <colgroup><col width="25%"/><col width="25%"/><col width="50%"/></colgroup>
122
+ <tr>
123
+ <td><a id="addthis_posts_tab" class="addthis-tab atb-active" href="#" onclick="return addthis_toggle_tabs(false)">Top Content</a></td>
124
+ <td><a id="addthis_services_tab" class="addthis-tab" href="#" onclick="return addthis_toggle_tabs(true)">Top Services</a></td>
125
+ <td style="text-align:right;"><a href="http://addthis.com/myaccount">View all stats &raquo;</a></td>
126
+ </tr>
127
+ </table>
128
+ </div>
129
+
130
+ <div class="table">
131
+ <table id="addthis_data_posts_table" style="display:none">
132
+ <colgroup><col width="90%"/><col width="10%"/></colgroup>
133
+ <tbody id="addthis_data_posts">
134
+ </tbody>
135
+ </table>
136
+ <table id="addthis_data_services_table" style="display:none">
137
+ <colgroup><col width="40%"/><col width="10%"/><col width="40%"/><col width="10%"/></colgroup>
138
+ <tbody id="addthis_data_services">
139
+ </tbody>
140
+ </table>
141
+ </div>
142
+ </div>
143
+
144
+ <script type="text/javascript">
145
+ jQuery(document).ready(function(jQuery) {
146
+ addthis_populate_posts_table("{$username}","{$password}", 5 /* max rows to show in table */, '#addthis_data_posts', '#addthis_header');
147
+ addthis_populate_services_table("{$username}","{$password}", 10 /* max rows to show in table */, '#addthis_data_services', '#addthis_header');
148
+ });
149
+ </script>
150
+ ENDHTML;
151
+ }
152
+
153
+ /**
154
+ * Initialize the dashboard widget.
155
+ */
156
+ function addthis_dashboard_init() {
157
+ wp_add_dashboard_widget('dashboard_addthis', 'AddThis', 'addthis_render_dashboard_widget');
158
+ }
159
+
160
+ /**
161
+ * Formally registers AddThis settings. Only called in WP 2.7+.
162
+ */
163
+ function register_addthis_settings() {
164
+ register_setting('addthis', 'addthis_username');
165
+ register_setting('addthis', 'addthis_fallback_username');
166
+ register_setting('addthis', 'addthis_password');
167
+ register_setting('addthis', 'addthis_show_stats');
168
+ register_setting('addthis', 'addthis_style');
169
+ register_setting('addthis', 'addthis_sidebar_only');
170
+ register_setting('addthis', 'addthis_isdropdown');
171
+ register_setting('addthis', 'addthis_menu_type');
172
+ register_setting('addthis', 'addthis_showonpages');
173
+ register_setting('addthis', 'addthis_showoncats');
174
+ register_setting('addthis', 'addthis_showonhome');
175
+ register_setting('addthis', 'addthis_showonarchives');
176
+ register_setting('addthis', 'addthis_language');
177
+ register_setting('addthis', 'addthis_brand');
178
+ register_setting('addthis', 'addthis_options');
179
+ register_setting('addthis', 'addthis_header_background');
180
+ register_setting('addthis', 'addthis_header_color');
181
+ }
182
 
183
  /**
184
  * Adds WP filter so we can append the AddThis button to post content.
185
  */
186
+ function addthis_init()
187
  {
188
  global $addthis_settings;
189
 
190
+ if (get_wp_version() >= 2.7) {
191
+ if ( is_admin() ) {
192
+ add_action( 'admin_init', 'register_addthis_settings' );
193
+ }
194
+ }
195
+
196
+ if (function_exists('wp_register_style')) {
197
+ wp_register_style( 'addthis', WP_PLUGIN_URL . '/addthis/css/addthis.css');
198
+ wp_register_script( 'addthis', WP_PLUGIN_URL . '/addthis/js/addthis.js');
199
+
200
+ add_action('admin_print_styles', 'addthis_print_style');
201
+ add_action('admin_print_scripts', 'addthis_print_script');
202
+ }
203
+
204
  add_filter('the_content', 'addthis_social_widget');
205
  add_filter('admin_menu', 'addthis_admin_menu');
206
 
207
  add_option('addthis_username');
208
+ add_option('addthis_show_stats', 'false');
209
+ add_option('addthis_password');
210
+ add_option('addthis_fallback_username', 'wp-'.cuid());
211
+ add_option('addthis_options'); // no default value, so that we can update as times change
212
+ add_option('addthis_product', 'menu');
213
  add_option('addthis_isdropdown', 'true');
214
+ add_option('addthis_menu_type', (get_option('addthis_isdropdown') !== 'true' ? 'static' : 'dropdown'));
215
  add_option('addthis_showonhome', 'true');
216
  add_option('addthis_showonpages', 'false');
217
  add_option('addthis_showoncats', 'false');
224
  add_option('addthis_language', 'en');
225
 
226
  $addthis_settings['sidebar_only'] = get_option('addthis_sidebar_only') === 'true';
227
+ $addthis_settings['showstats'] = get_option('addthis_show_stats') === 'true';
228
  $addthis_settings['showonhome'] = !(get_option('addthis_showonhome') !== 'true');
229
  $addthis_settings['showonpages'] = get_option('addthis_showonpages') === 'true';
230
  $addthis_settings['showonarchives'] = get_option('addthis_showonarchives') === 'true';
231
  $addthis_settings['showoncats'] = get_option('addthis_showoncats') === 'true';
232
 
233
+ $product = get_option('addthis_product');
234
+
235
+
236
+ $style = get_option('addthis_style');
237
  if (strlen($style) == 0) $style = 'share';
238
  $addthis_settings['style'] = $style;
239
 
240
+ $addthis_settings['menu_type'] = get_option('addthis_menu_type');
241
+
242
+ $addthis_settings['username'] = get_option('addthis_username');
243
+ $addthis_settings['fallback_username'] = get_option('addthis_fallback_username');
244
+
245
+ $addthis_settings['password'] = get_option('addthis_password');
246
 
247
  $language = get_option('addthis_language');
248
  $addthis_settings['language'] = $language;
249
 
250
+ $advopts = array('brand', 'language', 'header_background', 'header_color');
251
  $addthis_settings['customization'] = '';
252
  for ($i = 0; $i < count($advopts); $i++)
253
  {
255
  $val = get_option("addthis_$opt");
256
  if (isset($val) && strlen($val)) $addthis_settings['customization'] .= "var addthis_$opt = '$val';";
257
  }
258
+ $addthis_settings['options'] = get_option('addthis_options');
259
 
260
  add_action('widgets_init', 'addthis_widget_init');
261
+
262
+ if (get_wp_version() >= 2.7 && $addthis_settings['showstats']) {
263
+ add_action('wp_dashboard_setup', 'addthis_dashboard_init' );
264
+ }
265
  }
266
 
267
  function addthis_widget_init()
297
  else if (is_category() && !$addthis_settings['showoncats']) return $content;
298
  }
299
 
300
+ $pub = ($addthis_settings['username']);
301
+ if (!$pub) {
302
+ $pub = ($addthis_settings['fallback_username']);
303
+ }
304
+ $pub = urlencode($pub);
305
+
306
+ $link = urlencode($sidebar ? get_bloginfo('url') : get_permalink());
307
+ $title = urlencode($sidebar ? get_bloginfo('title') : the_title('', '', false));
308
+ $addthis_options = $addthis_settings['options'];
309
 
310
+ $content .= "\n<!-- AddThis Button BEGIN -->\n".'<script type="text/javascript">';
311
+
312
+ if (strlen($addthis_settings['customization']))
313
  {
314
+ $content .= ($addthis_settings['customization']);
315
+ }
316
+
317
+ if ($addthis_settings['menu_type'] === 'dropdown')
318
+ {
319
+ if (strlen($addthis_options)) $content .= "var addthis_options = '$addthis_options';\n";
320
  $content .= <<<EOF
321
+ </script>
322
+ <div class="addthis_container"><a href="http://www.addthis.com/bookmark.php?v=250&amp;username=$pub" class="addthis_button" addthis:url="$link" addthis:title="$title">
323
  EOF;
324
+ $content .= addthis_get_button_img() . '</a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username='.$pub.'"></script></div>';
325
+ }
326
+ else if ($addthis_settings['menu_type'] === 'toolbox')
327
+ {
328
+ $content .= "\n</script>\n";
329
+ $content .= <<<EOF
330
+ <div class="addthis_container addthis_toolbox addthis_default_style" addthis:url="$link" addthis:title="$title"><a href="http://www.addthis.com/bookmark.php?v=250&amp;username=$pub" class="addthis_button_compact">Share</a><span class="addthis_separator">|</span>
331
+ EOF;
332
+ if (!strlen($addthis_options)) $addthis_options = 'email,favorites,print,facebook,twitter';
333
+ $addthis_options = split(',', $addthis_options);
334
+ foreach ($addthis_options as $option) {
335
+ $option = trim($option);
336
+ if ($option != 'more') {
337
+ $content .= '<a class="addthis_button_'.$option.'"></a>';
338
+ }
339
+ }
340
+ $content .= '<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username='.$pub.'"></script></div>';
341
  }
342
  else
343
  {
344
  $content .= <<<EOF
345
+ </script>
346
+ <div class="addthis_container"><a href="http://www.addthis.com/bookmark.php?v=250&amp;username=$pub" onclick="window.open('http://www.addthis.com/bookmark.php?v=250&username=$pub&amp;url=$link&amp;title=$title', 'ext_addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no'); return false;" title="Bookmark using any bookmark manager!" target="_blank">
347
  EOF;
348
  $content .= addthis_get_button_img() . '</a></div>';
349
  }
374
 
375
  if (!isset($addthis_styles[$btnStyle])) $btnStyle = 'share';
376
  $btnRecord = $addthis_styles[$btnStyle];
377
+ $btnUrl = (strpos(trim($btnRecord['img']), 'http://') !== 0 ? "http://s7.addthis.com/static/btn/v2/" : "") . $btnRecord['img'];
378
 
379
  if (strpos($btnUrl, '%lang%') !== false)
380
  {
396
  global $addthis_styles;
397
  global $addthis_languages;
398
  global $addthis_settings;
399
+ global $addthis_menu_types;
400
 
401
  ?>
402
  <div class="wrap">
403
  <h2>AddThis</h2>
404
 
405
  <form method="post" action="options.php">
406
+ <?php
407
+ // use the old-school settings style in older versions of wordpress
408
+ if (get_wp_version() < 2.7) {
409
+ wp_nonce_field('update-options');
410
+ } else {
411
+ settings_fields('addthis');
412
+ }
413
+ ?>
414
 
415
  <h3>Required</h3>
416
  <table class="form-table">
418
  <th scope="row"><?php _e("AddThis username:", 'addthis_trans_domain' ); ?></th>
419
  <td><input type="text" name="addthis_username" value="<?php echo get_option('addthis_username'); ?>" /></td>
420
  </tr>
421
+ <tr>
422
+ <th scope="row"><?php _e("Menu type:", 'addthis_trans_domain' ); ?></th>
423
+ <td>
424
+ <select name="addthis_menu_type" onchange="document.getElementById('at_buttonstyle').style.display = (this.value !== 'toolbox');">
425
+ <?php
426
+ $curmenutype = get_option('addthis_menu_type');
427
+ foreach ($addthis_menu_types as $type)
428
+ {
429
+ echo "<option value=\"$type\"". ($type == $curmenutype ? " selected":""). ">$type</option>";
430
+ }
431
+ ?>
432
+ </select>
433
+ </tr>
434
+ <tr valign="top" id="at_buttonstyle" style="display:<?php echo ($curmenutype != 'toolbox') ? 'block' : 'none'; ?> ?>">
435
  <th scope="row"><?php _e("Button style:", 'addthis_trans_domain' ); ?></th>
436
  <td>
437
  <select name="addthis_style">
446
  </td>
447
  </tr>
448
  <tr>
449
+ <th scope="row"><?php _e("Show in sidebar only:", 'addthis_trans_domain' ); ?><br/><span style="font-size:10px">(sidebar widget must be enabled)</span></th>
 
 
 
 
450
  <td><input type="checkbox" name="addthis_sidebar_only" value="true" <?php echo (get_option('addthis_sidebar_only') == 'true' ? 'checked' : ''); ?>/></td>
451
  </tr>
452
  </table>
457
 
458
  <h3>Advanced</h3>
459
  <table class="form-table">
460
+ <?php
461
+ // We can only support the dashboard widget for WordPress 2.7+
462
+ if (get_wp_version() >= 2.7) {
463
+ ?>
464
  <tr>
465
+ <th scope="row"><?php _e("Show stats in admin dashboard:", 'addthis_trans_domain' ); ?></th>
466
+ <td><input type="checkbox" name="addthis_show_stats" value="true" onchange="document.getElementById('password_row').style.display = (this.checked ? '' : 'none');" <?php echo (get_option('addthis_show_stats') !== '' ? 'checked' : ''); ?>/></td>
467
  </tr>
468
+ <tr id="password_row" style="<?php echo (get_option('addthis_show_stats') !== '' ? '' : 'display:none'); ?>">
469
+ <th scope="row"><?php _e("AddThis password:", 'addthis_trans_domain' ); ?><br/><span style="font-size:10px">(required for displaying stats)</span></th>
470
+ <td><input type="password" name="addthis_password" value="<?php echo get_option('addthis_password'); ?>"/></td>
471
+ </tr>
472
+ <?php
473
+ }
474
+ ?>
475
  <tr>
476
  <th scope="row"><?php _e("Show on homepage:", 'addthis_trans_domain' ); ?></th>
477
  <td><input type="checkbox" name="addthis_showonhome" value="true" <?php echo (get_option('addthis_showonhome') == 'true' ? 'checked' : ''); ?>/></td>
478
  </tr>
479
+ <tr>
480
+ <th scope="row"><?php _e("Show on <a href=\"http://codex.wordpress.org/Pages\" target=\"blank\">pages</a>:", 'addthis_trans_domain' ); ?></th>
481
+ <td><input type="checkbox" name="addthis_showonpages" value="true" <?php echo (get_option('addthis_showonpages') !== '' ? 'checked' : ''); ?>/></td>
482
+ </tr>
483
  <tr>
484
  <th scope="row"><?php _e("Show in archives:", 'addthis_trans_domain' ); ?></th>
485
  <td><input type="checkbox" name="addthis_showonarchives" value="true" <?php echo (get_option('addthis_showonarchives') == 'true' ? 'checked' : ''); ?>/></td>
488
  <th scope="row"><?php _e("Show in categories:", 'addthis_trans_domain' ); ?></th>
489
  <td><input type="checkbox" name="addthis_showoncats" value="true" <?php echo (get_option('addthis_showoncats') == 'true' ? 'checked' : ''); ?>/></td>
490
  </tr>
491
+ <tr valign="top">
492
+ <td colspan="2"></td>
493
+ </tr>
494
+ <tr valign="top">
495
+ <td colspan="2">For more details on the following options, see <a href="http://addthis.com/customization">our customization docs</a>.</td>
496
+ </tr>
497
  <tr valign="top">
498
  <th scope="row"><?php _e("Brand:", 'addthis_trans_domain' ); ?></th>
499
  <td><input type="text" name="addthis_brand" value="<?php echo get_option('addthis_brand'); ?>" /></td>
500
  </tr>
501
  <tr valign="top">
502
+ <th scope="row"><?php _e("Dropdown/Toolbox Services:", 'addthis_trans_domain'); ?> <br/> <span style="font-size:10px">(comma-separated)</span></th>
503
+ <td><input type="text" name="addthis_options" value="<?php echo get_option('addthis_options'); ?>" size="80"/></td>
504
  </tr>
505
  <tr valign="top">
506
  <th scope="row"><?php _e("Language:", 'addthis_trans_domain' ); ?></th>
526
  </tr>
527
  </table>
528
 
529
+ <?php
530
+ // use the old-school settings style in older versions of wordpress
531
+ if (get_wp_version() < 2.7) {
532
+ ?>
533
  <input type="hidden" name="action" value="update" />
534
+ <input type="hidden" name="page_options" value="addthis_username,addthis_password,addthis_show_stats,addthis_style,addthis_sidebar_only,addthis_menu_type,addthis_showonpages,addthis_showoncats,addthis_showonhome,addthis_showonarchives,addthis_language,addthis_brand,addthis_options,addthis_header_background,addthis_header_color"/>
535
+ <?php
536
+ }
537
+ ?>
538
  <p class="submit">
539
  <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
540
  </p>
css/addthis.css ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #dashboard_addthis .addthis-tab {
2
+ display: block;
3
+ background: #fff;
4
+ padding: 5px 12px;
5
+ }
6
+
7
+ #dashboard_addthis .addthis_tab {
8
+ text-align:center;
9
+ }
10
+ #dashboard_addthis .atb-active {
11
+ display: block;
12
+ background: #666;
13
+ padding: 5px 12px;
14
+ text-decoration: none;
15
+ color: #fff;
16
+ margin-right:5px;
17
+ }
18
+
19
+ #dashboard_addthis p.sub, #dashboard_addthis .table, #dashboard_addthis .versions {
20
+ margin:-12px;
21
+ }
22
+ #dashboard_addthis .inside {
23
+ font-size:11px;
24
+ }
25
+ #dashboard_addthis p.sub {
26
+ color:#777777;
27
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
28
+ font-size:13px;
29
+ font-style:italic;
30
+ padding:5px 10px 15px;
31
+ }
32
+ #dashboard_addthis .table {
33
+ -moz-background-clip:border;
34
+ -moz-background-inline-policy:continuous;
35
+ -moz-background-origin:padding;
36
+ background:#F9F9F9 none repeat scroll 0 0;
37
+ border-bottom:1px solid #ECECEC;
38
+ border-top:1px solid #ECECEC;
39
+ margin:0 -9px 10px;
40
+ padding:0 10px;
41
+ }
42
+ #dashboard_addthis table {
43
+ width:100%;
44
+ }
45
+ #dashboard_addthis .table td {
46
+ text-align: left;
47
+ }
48
+
49
+ #dashboard_addthis table td {
50
+ border-top:1px solid #ECECEC;
51
+ padding:3px 0 0 0;
52
+ white-space:nowrap;
53
+ }
54
+ #dashboard_addthis td.pp {
55
+ padding-right: 10px;
56
+ }
57
+ #dashboard_addthis table tr.first td {
58
+ border-top:medium none;
59
+ }
60
+ #dashboard_addthis table tr {
61
+ padding:0;
62
+ }
63
+ #dashboard_addthis .atb {
64
+ font-weight:bold;
65
+ }
66
+
67
+ #dashboard_addthis td.b {
68
+ font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
69
+ padding-right:6px;
70
+ }
71
+ #dashboard_addthis td.ll {
72
+ border-left:1px solid #cCcCcC!important;
73
+ padding-left:5px;
74
+ }
75
+ #dashboard_addthis .t {
76
+ color:#777777;
77
+ padding-right:12px;
78
+ padding-top:6px;
79
+ }
80
+ #dashboard_addthis td.first, #dashboard_addthis td.last {
81
+ width:1px;
82
+ }
83
+
84
+ #dashboard_addthis .analytics {
85
+ padding:6px 0px;
86
+ }
js/addthis.js ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var at_total_shares = 0,
2
+ at_populated_svcs = 0,
3
+ at_populated_content = 0;
4
+
5
+ function addthis_toggle_tabs(servicesOn) {
6
+ var on = 'services',
7
+ off = 'posts';
8
+
9
+ if (!servicesOn) {
10
+ var tmp = off;
11
+ off = on;
12
+ on = tmp;
13
+ }
14
+
15
+ jQuery('#addthis_data_'+off+'_table').hide();
16
+ jQuery('#addthis_data_'+on+'_table').show();
17
+
18
+ jQuery('#addthis_'+on+'_tab').attr("class","addthis_tab atb-active");
19
+ jQuery('#addthis_'+off+'_tab').attr("class","addthis_tab");
20
+ return false;
21
+ }
22
+
23
+ function addthis_populate_services_table(username, password, max, table_id, header_id) {
24
+ if (!at_populated_svcs) {
25
+ // load service json
26
+ jQuery.getJSON("http://api.addthis.com/analytics/1.0/pub/shares/service.json?suppress_response_codes=true&username="+encodeURIComponent(username)+"&password="+encodeURIComponent(password)+"&callback=?",
27
+ function(data){
28
+ if (!data || data.length == 0) {
29
+ jQuery(header_id).text("No shares yesterday.");
30
+ jQuery('#addthis_data_container').hide();
31
+ return;
32
+ }
33
+ if (data.error) {
34
+ jQuery('#addthis_data_container').hide();
35
+ jQuery(header_id).text("Error connecting to AddThis.");
36
+ return;
37
+ }
38
+ jQuery(header_id).text("Yesterday At a Glance");
39
+ jQuery.each(data, function(i,item){
40
+ at_total_shares += item.shares;
41
+ if ( i < max ) {
42
+ (i % 2 == 0 ? jQuery("<tr>").attr("id", "at_data_"+i).attr("class", i == 0 ? "first" : "") : jQuery("#at_data_"+(i-1)))
43
+ .append(jQuery("<td>").attr("class", "b").text(item.service))
44
+ .append(jQuery("<td>").attr("class", "t").text(item.shares))
45
+ .appendTo(table_id);
46
+ }
47
+ });
48
+
49
+ if (jQuery('#at_data_total_services').length) {
50
+ jQuery('#at_data_total_services').text(at_total_shares);
51
+ } else {
52
+ jQuery("<tr>").attr("class", "last")
53
+ .append(jQuery("<td>").attr("class", "b atb").text("Total Shares:"))
54
+ .append(jQuery("<td>"))
55
+ .append(jQuery("<td>"))
56
+ .append(jQuery("<td>").attr("id","at_data_total_services").attr("class", "t atb").text(at_total_shares))
57
+ .appendTo(table_id);
58
+ }
59
+
60
+ jQuery("#at_post_total").text(at_total_shares);
61
+ jQuery('#addthis_tab_table').show();
62
+ });
63
+ at_populated_svcs = 1;
64
+ }
65
+ }
66
+
67
+ function addthis_populate_posts_table(username, password, max, table_id, header_id) {
68
+ if (!at_populated_content) {
69
+ // get the top content data
70
+ jQuery.getJSON("http://api.addthis.com/analytics/1.0/pub/shares/content.json?suppress_response_codes=true&username="+encodeURIComponent(username)+"&password="+encodeURIComponent(password)+"&callback=?",
71
+ function(data){
72
+ var other = 0;
73
+ jQuery.each(data, function(i,item){
74
+ var title = item.title;
75
+ try { title = decodeURIComponent(title); } catch (e) { title = unescape(title); }
76
+ if (title.length > 53) title = title.substr(0, 50) + '...';
77
+ if ( i < max) {
78
+ jQuery("<tr>").attr("id", "at_post_data_"+i).attr("class", i == 0 ? "first" : "")
79
+ .append(jQuery("<td>").attr("class", "b").text(title))
80
+ .append(jQuery("<td>").attr("class", "t").text(item.shares))
81
+ .appendTo(table_id);
82
+ }
83
+ });
84
+
85
+ if (jQuery('#at_post_total').length) {
86
+ jQuery('#at_post_total').text(at_total_shares);
87
+ } else {
88
+ jQuery("<tr>").attr("class", "last").attr("id","at_data_total")
89
+ .append(jQuery("<td>").attr("class", "b atb").text("Total Shares:"))
90
+ .append(jQuery("<td id='at_post_total'>").attr("class", "t atb").text(at_total_shares))
91
+ .appendTo(table_id);
92
+ }
93
+
94
+ jQuery('#addthis_tab_table').show();
95
+ jQuery(table_id+"_table").show();
96
+ });
97
+ at_populated_content = 1;
98
+ }
99
+ }
readme.txt CHANGED
@@ -2,17 +2,32 @@
2
  Contributors: _mjk_
3
  Tags: share, addthis, social, bookmark, sharing, bookmarking, widget
4
  Requires at least: 2.3
5
- Tested up to: 2.7
6
- Stable tag: 1.5.4
7
 
8
  The AddThis Social Bookmarking Widget allows any visitor to bookmark and share your site easily with many popular services.
9
 
10
  == Description ==
11
- Help your visitor promote your site! The AddThis Social Bookmarking Widget allows your users to bookmark your site easily with over 45 popular services, and to share it with friends via email. Our button is small, unobtrusive, quick to load and recognized all over the web.
12
-
13
- 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.
14
-
15
- Over 120,000 sites have installed AddThis. Join us!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  == Installation ==
18
 
2
  Contributors: _mjk_
3
  Tags: share, addthis, social, bookmark, sharing, bookmarking, widget
4
  Requires at least: 2.3
5
+ Tested up to: 2.9.1
6
+ Stable tag: 1.6.0
7
 
8
  The AddThis Social Bookmarking Widget allows any visitor to bookmark and share your site easily with many popular services.
9
 
10
  == Description ==
11
+ Get more traffic back to your site! With AddThis, your users can promote your content for you by sharing to over 200 of the most popular social networking and bookmarking sites (like Facebook, Twitter, Digg, StumbleUpon and MySpace), and by emailing it to their friends. 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.
12
+
13
+ = WHY USE ADDTHIS? =
14
+ 1. Ease of use. AddThis is easy to install, customize and localize. We've worked hard to make it the simplest, most recognized sharing tool on the internet.
15
+ 2. Performance. The AddThis menu code is tiny and fast. We constantly optimize its behavior and design to make sharing a snap.
16
+ 3. Peace of mind. AddThis gathers the best services on the internet so you don't have to, and backs them up with industrial strength analytics, code caching, active tech support and a thriving developer community.
17
+ 4. Flexibility. AddThis can be customized via API, and served securely via SSL. You can roll your own sharing toolbars with our toolbox. Share just about anything, anywhere -- your way.
18
+ 5. Global reach. AddThis sends content to more than 50 sharing services over 20 billion times a month in 20+ languages, to over half a billion unique users in countries all over the world.
19
+ 6. It's free!
20
+
21
+ = OVER 200 SUPPORTED SERVICES =
22
+ We currently support over 200 services, from email and blogging platforms to social networks and news aggregators, and we add new services every month. Want to know if your favorite service is supported? This list is accurate up to the minute: <a href="http://www.addthis.com/services">http://www.addthis.com/services</a>.
23
+
24
+ = ADDITIONAL FEATURES =
25
+ 1. Email right from the page and import your address book from Gmail, Hotmail and Yahoo without opening another application or window
26
+ 2. Bookmark in your browser
27
+ 3. Print
28
+
29
+ = WHO ELSE USES ADDTHIS? =
30
+ Over 500,000 sites have installed AddThis. With over half a billion unique users, AddThis is helping share content all over the world, in more than sixty languages. You might be surprised who's sharing their website using AddThis--<a href="http://addthis.com/features#partners">here are just a few</a>.
31
 
32
  == Installation ==
33