AddToAny Share Buttons - Version 0.9.9.9

Version Description

Download this release

Release Info

Developer micropat
Plugin Icon 128x128 AddToAny Share Buttons
Version 0.9.9.9
Comparing to
See all releases

Code changes from version 0.9.9.8.2 to 0.9.9.9

Files changed (2) hide show
  1. README.txt +28 -9
  2. add-to-any.php +177 -70
README.txt CHANGED
@@ -1,15 +1,16 @@
1
  === AddToAny: Share/Bookmark/Email Buttons ===
2
  Contributors: micropat
3
- Tags: sharing, share, sharethis, bookmarking, social, social bookmarking, social bookmarks, bookmark, bookmarks, save, Post, posts, page, pages, images, image, admin, statistics, stats, links, plugin, widget, email, e-mail, seo, button, delicious, google buzz, buzz, google, digg, reddit, facebook, facebook like, like, myspace, twitter, tweet, messenger, stumbleupon, technorati, sexybookmarks, sociable, sharedaddy, icon, icons, wpmu, addtoany
4
  Requires at least: 2.8
5
  Tested up to: 3.1
6
- Stable tag: 0.9.9.8.2
7
 
8
- Help people share, bookmark, and email your posts & pages using any service, such as Facebook, Twitter, StumbleUpon, Digg and many more.
9
 
10
  == Description ==
11
 
12
- The WordPress plugin to help people **share**, **bookmark**, and **email** your posts and pages using any service, such as Facebook, Twitter, StumbleUpon, Google, Digg, Delicious, and well over 100 more sharing and social bookmarking sites. New: **Facebook Like Button** and **Twitter Tweet Button**.
 
13
 
14
  This sharing plugin comes with AddToAny's customizable Smart Menu, which places the services visitors use at the top of the menu, based on each visitor's browsing and usage history.
15
 
@@ -23,11 +24,12 @@ Standalone **share icons** let you optimize your blog posts for specific social
23
  * Individual share links (like Sociable)
24
  * Includes all <a href="http://www.addtoany.com/services/">services</a>
25
  * Google Analytics integration (<a href="http://www.addtoany.com/ext/google_analytics/">access guide</a>)
26
- * WordPress optimized, localized (English, Chinese, Spanish, Japanese, French, Portuguese, Italian, Dutch, Danish, Catalan, Persian, Russian, Turkish, Albanian, Romanian, Belarusian, Greek)
 
27
  * Easily customizable for beginners or advanced users, and highly extensible for developers and designers
28
  * Many more publisher and user features!
29
 
30
- After **years of active development**, over **1.7 million downloads**, and **ongoing support from the community**, AddToAny still strives to be the best WordPress plugin for sharing. We hope it's perfect for everyone by version 1.0.
31
 
32
  <a href="http://www.addtoany.com/share_save" title="Share">Share this</a> plugin
33
 
@@ -48,14 +50,18 @@ See also:
48
 
49
  = Where are the options? =
50
 
51
- In your Admin panel, go to `Settings` > `AddToAny`. Among other options, you can choose which button, individual icons and advanced sharing buttons (Facebook Like Button and Twitter Tweet Button) to display, and where and how to display them.
52
 
53
  To place AddToAny as a "widget" in your theme (if your theme supports WordPress Widgets), go to `Appearance` > `Widgets`, then drag AddToAny to an available Widget Area and click `Save`.
54
 
55
  = Why isn't the drop-down menu appearing? =
56
 
57
- It's likely because your theme wasn't <a href="http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks">coded properly</a>. With many themes you can use the Theme Editor to make sure that the following piece of code is included in your theme's `footer.php` file just before the `</body>` line:
58
 
 
 
 
 
59
  `<?php wp_footer(); ?>`
60
 
61
  = How can I add both the button and the individual icons to another area of my theme? =
@@ -163,7 +169,7 @@ It's not recommended, but you can change the width of the Facebook Like Button u
163
 
164
  Yes, AddToAny outputs 100% W3C valid XHTML & HTML5 and W3C valid CSS 3.0 by default.
165
 
166
- If you use the Facebook Like or Twitter Tweet buttons in an HTML5 theme, note that the button iframes use the `scrolling` attribute, which is valid XHTML but the attribute has been deprecated in HTML5. It's needed to prevent scrollbars from appearing over the Like & Tweet buttons inside of the iframes.
167
 
168
  If you move the plugin's CSS code to your theme's stylesheet, note that one proprietary vendor prefix (`filter`) is used. It's utilized for cross-browser compatibility with Internet Explorer. For more information about the W3C CSS Validator and the `filter` property, see <a href="http://www.websitedev.de/css/validator-faq#extensions">Why don't [sic] my scrollbar properties, filters, etc. validate?</a> If you feel compelled, you can move the line into an Internet Explorer-only stylesheet, or remove the line at the cost of the opacity hover effect in Internet Explorer.
169
 
@@ -199,6 +205,19 @@ Upload the plugin directory (including all files and directories within) to the
199
 
200
  == Changelog ==
201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  = .9.9.8.2 =
203
  * Remove `frameborder` attribute (except for IE) on Tweet & Like iframes to support W3C validation against HTML5 themes
204
  * Note:
1
  === AddToAny: Share/Bookmark/Email Buttons ===
2
  Contributors: micropat
3
+ Tags: sharing, share, sharethis, bookmarking, social, social bookmarking, social bookmarks, bookmark, bookmarks, save, Post, posts, page, pages, images, image, admin, statistics, stats, links, plugin, widget, email, e-mail, seo, button, delicious, google buzz, buzz, google, digg, reddit, facebook, facebook like, like, myspace, twitter, tweet, +1, plus 1, google plus one, plus one, messenger, stumbleupon, technorati, addthis, sexybookmarks, sociable, sharedaddy, icon, icons, wpmu, addtoany
4
  Requires at least: 2.8
5
  Tested up to: 3.1
6
+ Stable tag: 0.9.9.9
7
 
8
+ Help people share, bookmark, and email your posts & pages using any service, such as Facebook, Twitter, Google, StumbleUpon, Digg and many more.
9
 
10
  == Description ==
11
 
12
+ The WordPress plugin to help people **share**, **bookmark**, and **email** your posts and pages using any service, such as Facebook, Twitter, StumbleUpon, Google, Digg, Delicious, and well over 100 more sharing and social bookmarking sites.
13
+ New: **Google +1 Button** in addition to the **Facebook Like Button** and **Twitter Tweet Button**.
14
 
15
  This sharing plugin comes with AddToAny's customizable Smart Menu, which places the services visitors use at the top of the menu, based on each visitor's browsing and usage history.
16
 
24
  * Individual share links (like Sociable)
25
  * Includes all <a href="http://www.addtoany.com/services/">services</a>
26
  * Google Analytics integration (<a href="http://www.addtoany.com/ext/google_analytics/">access guide</a>)
27
+ * WordPress optimized with asynchronous script loading
28
+ * Localized in English, Chinese, Spanish, Japanese, French, Portuguese, Italian, Dutch, Danish, Catalan, Persian, Russian, Turkish, Albanian, Romanian, Belarusian, Greek
29
  * Easily customizable for beginners or advanced users, and highly extensible for developers and designers
30
  * Many more publisher and user features!
31
 
32
+ After **years of active development**, over **1.75 million downloads**, and **ongoing support from the community**, AddToAny still strives to be the best WordPress plugin for sharing. We hope it's perfect for everyone by version 1.0.
33
 
34
  <a href="http://www.addtoany.com/share_save" title="Share">Share this</a> plugin
35
 
50
 
51
  = Where are the options? =
52
 
53
+ In your Admin panel, go to `Settings` > `AddToAny`. Among other options, you can choose which button, individual icons and advanced sharing buttons (Facebook Like Button, Twitter Tweet Button, Google +1 Button) to display, and where and how to display them.
54
 
55
  To place AddToAny as a "widget" in your theme (if your theme supports WordPress Widgets), go to `Appearance` > `Widgets`, then drag AddToAny to an available Widget Area and click `Save`.
56
 
57
  = Why isn't the drop-down menu appearing? =
58
 
59
+ It's likely because your theme wasn't <a href="http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks">coded properly</a>. With many themes you can use the Theme Editor to edit your theme's `header.php` and `footer.php` files.
60
 
61
+ In `header.php` place the following line of code just before the `</head>` line:
62
+ `<?php wp_head(); ?>`
63
+
64
+ In `footer.php` place the following line of code just before the `</body>` line:
65
  `<?php wp_footer(); ?>`
66
 
67
  = How can I add both the button and the individual icons to another area of my theme? =
169
 
170
  Yes, AddToAny outputs 100% W3C valid XHTML & HTML5 and W3C valid CSS 3.0 by default.
171
 
172
+ If you use the Facebook Like, Twitter Tweet or Google +1 buttons in an HTML5 theme, note that the button iframes use the `scrolling` attribute, which is valid XHTML but the attribute has been deprecated in HTML5. It's needed to prevent scrollbars from appearing over the Like, Tweet, and +1 buttons inside of the iframes.
173
 
174
  If you move the plugin's CSS code to your theme's stylesheet, note that one proprietary vendor prefix (`filter`) is used. It's utilized for cross-browser compatibility with Internet Explorer. For more information about the W3C CSS Validator and the `filter` property, see <a href="http://www.websitedev.de/css/validator-faq#extensions">Why don't [sic] my scrollbar properties, filters, etc. validate?</a> If you feel compelled, you can move the line into an Internet Explorer-only stylesheet, or remove the line at the cost of the opacity hover effect in Internet Explorer.
175
 
205
 
206
  == Changelog ==
207
 
208
+ = .9.9.9 =
209
+ * Asynchronous loading (faster, non-blocking, major new feature!)
210
+ * Supports most themes and additionally works around buggy themes that improperly process content for excerpts, featured/related posts, etc.
211
+ * Improperly-coded themes may prevent AddToAny from fully loading
212
+ * If your theme is coded improperly, you can switch to the previous plugin version (<a href="">download version .9.9.8.3</a>) until you switch to a working theme or your theme author fixes the issue
213
+ * See the FAQ entry for "Why isn't the drop-down menu appearing?" for more information
214
+ * Google +1 button
215
+ * HTTPS support for Facebook Like & Twitter Tweet buttons (Google +1 button always uses HTTPS)
216
+
217
+ = .9.9.8.3 =
218
+ * Fix Facebook Like cut-off issue in IE8
219
+ * Increase Facebook Like height by 1 pixel to accommodate IE8's calculated height for iframes
220
+
221
  = .9.9.8.2 =
222
  * Remove `frameborder` attribute (except for IE) on Tweet & Like iframes to support W3C validation against HTML5 themes
223
  * Note:
add-to-any.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: AddToAny: Share/Bookmark/Email Buttons
4
  Plugin URI: http://www.addtoany.com/
5
- Description: Help people share, bookmark, and email your posts & pages using any service, such as Facebook, Twitter, StumbleUpon, Digg and many more. [<a href="options-general.php?page=add-to-any.php">Settings</a>]
6
- Version: .9.9.8.2
7
  Author: AddToAny
8
  Author URI: http://www.addtoany.com/
9
  */
@@ -76,9 +76,14 @@ include_once($A2A_SHARE_SAVE_plugin_dir . '/services.php');
76
 
77
  // Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
78
  function ADDTOANY_SHARE_SAVE_KIT( $args = false ) {
 
79
 
80
- if ( ! isset($args['html_container_open']))
81
- $args['html_container_open'] = "<div class=\"a2a_kit addtoany_list\">";
 
 
 
 
82
  if ( ! isset($args['html_container_close']))
83
  $args['html_container_close'] = "</div>";
84
  // Close container element in ADDTOANY_SHARE_SAVE_BUTTON, not prematurely in ADDTOANY_SHARE_SAVE_ICONS
@@ -135,7 +140,7 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
135
  $service_codes = array_keys($A2A_SHARE_SAVE_services);
136
 
137
  // Include Facebook Like and Twitter Tweet
138
- array_unshift($service_codes, 'facebook_like', 'twitter_tweet');
139
 
140
  $options = get_option('addtoany_options');
141
 
@@ -151,7 +156,7 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
151
  if ( !in_array($active_service, $service_codes) )
152
  continue;
153
 
154
- if ($active_service == 'facebook_like' || $active_service == 'twitter_tweet') {
155
  $link = ADDTOANY_SHARE_SAVE_SPECIAL($active_service, $args);
156
  }
157
  else {
@@ -206,10 +211,11 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
206
 
207
  // $args array = output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl
208
 
209
- global $A2A_SHARE_SAVE_plugin_url_path;
210
 
211
  $linkname = (isset($args['linkname'])) ? $args['linkname'] : FALSE;
212
  $linkurl = (isset($args['linkurl'])) ? $args['linkurl'] : FALSE;
 
213
 
214
  $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl)); // linkname_enc, etc.
215
 
@@ -220,6 +226,7 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
220
  'linkurl_enc' => '',
221
  'use_current_page' => FALSE,
222
  'output_later' => FALSE,
 
223
  'html_container_open' => '',
224
  'html_container_close' => '',
225
  'html_wrap_open' => '',
@@ -229,6 +236,16 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
229
  $args = wp_parse_args( $args, $defaults );
230
  extract( $args );
231
 
 
 
 
 
 
 
 
 
 
 
232
  /* AddToAny button */
233
 
234
  $is_feed = is_feed();
@@ -272,49 +289,30 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
272
  $button = '<img src="'.$button_src.'"'.$button_width.$button_height.' alt="Share"/>';
273
  }
274
 
275
- $button_html = $html_container_open . $html_wrap_open . '<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save' .$button_href_querystring . '"'
276
  . $style . $button_target
277
  . '>' . $button . '</a>' . $html_wrap_close . $html_container_close;
278
 
279
  // If not a feed
280
  if( ! $is_feed ) {
281
- $http_or_https = (is_ssl()) ? 'https' : 'http';
282
-
283
- global $A2A_SHARE_SAVE_external_script_called;
284
- if ( ! $A2A_SHARE_SAVE_external_script_called ) {
285
- // Use local cache?
286
- $cache = ($options['cache']=='1') ? TRUE : FALSE;
287
- $upload_dir = wp_upload_dir();
288
- $static_server = ($cache) ? $upload_dir['baseurl'] . '/addtoany' : $http_or_https . '://static.addtoany.com/menu';
289
-
290
- // Enternal script call + initial JS + set-once variables
291
- $initial_js = 'var a2a_config = a2a_config || {};' . "\n";
292
- $additional_js = $options['additional_js_variables'];
293
- $external_script_call = (($cache) ? 'a2a_config.static_server="' . $static_server . '";' . "\n" : '' )
294
- . (($options['onclick']=='1') ? 'a2a_config.onclick=1;' . "\n" : '')
295
- . (($options['show_title']=='1') ? 'a2a_config.show_title=1;' . "\n" : '')
296
- . (($additional_js) ? stripslashes($additional_js) . "\n" : '')
297
- . "//-->" . '</script><script type="text/javascript" src="' . $static_server . '/page.js"></script>';
298
- $A2A_SHARE_SAVE_external_script_called = true;
299
- }
300
- else {
301
- $external_script_call = "a2a.init('page');\n//--></script>";
302
- $initial_js = '';
303
- }
304
-
305
- $button_javascript = "\n" . '<script type="text/javascript">' . "<!--\n"
306
- . $initial_js
307
- . A2A_menu_locale();
308
  if ($use_current_page) {
309
- $button_javascript .= 'a2a_config.linkname=document.title;' . "\n"
310
- . 'a2a_config.linkurl=location.href;' . "\n";
311
  } else {
312
- $button_javascript .= 'a2a_config.linkname="' . esc_js($linkname) . '";' . "\n"
313
- . 'a2a_config.linkurl="' . $linkurl . '";' . "\n";
314
  }
315
- $button_javascript .= $external_script_call . "\n\n";
316
- $button_html .= $button_javascript;
317
-
 
 
 
 
 
 
 
 
318
  }
319
 
320
  if ( $output_later )
@@ -332,8 +330,9 @@ function ADDTOANY_SHARE_SAVE_SPECIAL($special_service_code, $args = array() ) {
332
  $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl)); // linkname_enc, etc.
333
  extract( $args );
334
 
 
335
  $iframe_template_begin = '<iframe';
336
- $iframe_template_end = ' class="addtoany_special_service %1$s" src="%2$s" scrolling="no" style="border:none;overflow:hidden;width:%3$dpx;height:20px"></iframe>';
337
  $iframe_template = $iframe_template_begin . $iframe_template_end;
338
 
339
  // IE ridiculousness to support transparent iframes while maintaining W3C validity
@@ -342,9 +341,11 @@ function ADDTOANY_SHARE_SAVE_SPECIAL($special_service_code, $args = array() ) {
342
  . '<![endif]--><!--[if !IE]><!-->' . $iframe_template . '<!--<![endif]-->';
343
 
344
  if ($special_service_code == 'facebook_like')
345
- $special_html = sprintf($iframe_template, $special_service_code, 'http://www.facebook.com/plugins/like.php?href=' . $linkurl_enc . '&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany', 90);
346
  elseif ($special_service_code == 'twitter_tweet')
347
- $special_html = sprintf($iframe_template, $special_service_code, 'http://platform.twitter.com/widgets/tweet_button.html?url=' . $linkurl_enc . '&amp;counturl=' . $linkurl_enc . '&amp;count=horizontal&amp;text=' . $linkname_enc, 55);
 
 
348
 
349
  if ( $output_later )
350
  return $special_html;
@@ -383,27 +384,129 @@ if (!function_exists('A2A_menu_locale')) {
383
  }
384
  }
385
 
386
- if (!function_exists('A2A_wp_footer_check')) {
387
- function A2A_wp_footer_check()
388
- {
389
- // If footer.php exists in the current theme, scan for "wp_footer"
390
- $file = get_template_directory() . '/footer.php';
391
- if( is_file($file) ) {
392
- $search_string = "wp_footer";
393
- $file_lines = @file($file);
394
-
395
- foreach($file_lines as $line) {
396
- $searchCount = substr_count($line, $search_string);
397
- if($searchCount > 0) {
398
- return true;
399
- break;
400
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  }
402
-
403
- // wp_footer() not found:
404
- echo "<div class=\"plugin-update\">" . __("Your theme needs to be fixed. To fix your theme, use the <a href=\"theme-editor.php\">Theme Editor</a> to insert <code>&lt;?php wp_footer(); ?&gt;</code> just before the <code>&lt;/body&gt;</code> line of your theme's <code>footer.php</code> file.") . "</div>";
405
  }
406
- }
 
 
 
407
  }
408
 
409
  function A2A_SHARE_SAVE_auto_placement($title) {
@@ -485,18 +588,19 @@ function A2A_SHARE_SAVE_add_to_content($content) {
485
 
486
  $kit_args = array(
487
  "output_later" => true,
488
- "html_container_open" => ($is_feed) ? "" : "<div class=\"a2a_kit addtoany_list\">",
489
- "html_container_close" => ($is_feed) ? "" : "</div>",
490
- "html_wrap_open" => ($is_feed) ? "" : "",
491
- "html_wrap_close" => ($is_feed) ? " " : "",
492
  );
493
 
494
  if ( ! $is_feed ) {
495
  $container_wrap_open = '<div class="addtoany_share_save_container">';
496
  $container_wrap_close = '</div>';
497
- } else {
498
  $container_wrap_open = '<p>';
499
  $container_wrap_close = '</p>';
 
 
 
 
500
  }
501
 
502
  $options['position'] = isset($options['position']) ? $options['position'] : 'bottom';
@@ -776,7 +880,7 @@ function A2A_SHARE_SAVE_options_page() {
776
 
777
  ?>
778
 
779
- <?php A2A_wp_footer_check(); ?>
780
 
781
  <div class="wrap">
782
 
@@ -802,6 +906,9 @@ function A2A_SHARE_SAVE_options_page() {
802
  </li>
803
  <li id="a2a_wp_twitter_tweet" class="addtoany_special_service" title="Twitter Tweet button">
804
  <span><img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/icons/twitter_tweet.png'; ?>" width="55" height="20" alt="Twitter Tweet" /></span>
 
 
 
805
  </li>
806
  <?php
807
  // Show all services
2
  /*
3
  Plugin Name: AddToAny: Share/Bookmark/Email Buttons
4
  Plugin URI: http://www.addtoany.com/
5
+ Description: Help people share, bookmark, and email your posts & pages using any service, such as Facebook, Twitter, Google, StumbleUpon, Digg and many more. [<a href="options-general.php?page=add-to-any.php">Settings</a>]
6
+ Version: .9.9.9
7
  Author: AddToAny
8
  Author URI: http://www.addtoany.com/
9
  */
76
 
77
  // Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
78
  function ADDTOANY_SHARE_SAVE_KIT( $args = false ) {
79
+ global $_addtoany_counter;
80
 
81
+ $_addtoany_counter++;
82
+
83
+ if ( ! isset($args['html_container_open'])) {
84
+ $args['html_container_open'] = '<div class="a2a_kit a2a_target addtoany_list" id="wpa2a_' . $_addtoany_counter . '">';
85
+ $args['is_kit'] = TRUE;
86
+ }
87
  if ( ! isset($args['html_container_close']))
88
  $args['html_container_close'] = "</div>";
89
  // Close container element in ADDTOANY_SHARE_SAVE_BUTTON, not prematurely in ADDTOANY_SHARE_SAVE_ICONS
140
  $service_codes = array_keys($A2A_SHARE_SAVE_services);
141
 
142
  // Include Facebook Like and Twitter Tweet
143
+ array_unshift($service_codes, 'facebook_like', 'twitter_tweet', 'google_plusone');
144
 
145
  $options = get_option('addtoany_options');
146
 
156
  if ( !in_array($active_service, $service_codes) )
157
  continue;
158
 
159
+ if ($active_service == 'facebook_like' || $active_service == 'twitter_tweet' || $active_service == 'google_plusone') {
160
  $link = ADDTOANY_SHARE_SAVE_SPECIAL($active_service, $args);
161
  }
162
  else {
211
 
212
  // $args array = output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl
213
 
214
+ global $A2A_SHARE_SAVE_plugin_url_path, $_addtoany_targets, $_addtoany_counter, $_addtoany_init;
215
 
216
  $linkname = (isset($args['linkname'])) ? $args['linkname'] : FALSE;
217
  $linkurl = (isset($args['linkurl'])) ? $args['linkurl'] : FALSE;
218
+ $_addtoany_targets = (isset($_addtoany_targets)) ? $_addtoany_targets : array();
219
 
220
  $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl)); // linkname_enc, etc.
221
 
226
  'linkurl_enc' => '',
227
  'use_current_page' => FALSE,
228
  'output_later' => FALSE,
229
+ 'is_kit' => FALSE,
230
  'html_container_open' => '',
231
  'html_container_close' => '',
232
  'html_wrap_open' => '',
236
  $args = wp_parse_args( $args, $defaults );
237
  extract( $args );
238
 
239
+ // If not enclosed in an AddToAny Kit, count & target this button (instead of Kit) for async loading
240
+ if ( ! $args['is_kit']) {
241
+ $_addtoany_counter++;
242
+ $button_class = ' a2a_target';
243
+ $button_id = ' id="wpa2a_' . $_addtoany_counter . '"';
244
+ } else {
245
+ $button_class = '';
246
+ $button_id = '';
247
+ }
248
+
249
  /* AddToAny button */
250
 
251
  $is_feed = is_feed();
289
  $button = '<img src="'.$button_src.'"'.$button_width.$button_height.' alt="Share"/>';
290
  }
291
 
292
+ $button_html = $html_container_open . $html_wrap_open . '<a class="a2a_dd' . $button_class . ' addtoany_share_save" href="http://www.addtoany.com/share_save' .$button_href_querystring . '"' . $button_id
293
  . $style . $button_target
294
  . '>' . $button . '</a>' . $html_wrap_close . $html_container_close;
295
 
296
  // If not a feed
297
  if( ! $is_feed ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  if ($use_current_page) {
299
+ $_addtoany_targets[] = "\n{title:document.title,"
300
+ . "url:location.href}";
301
  } else {
302
+ $_addtoany_targets[] = "\n{title:'". esc_js($linkname) . "',"
303
+ . "url:'" . $linkurl . "'}";
304
  }
305
+
306
+ if ( ! $_addtoany_init) {
307
+ $javascript_load_early = "\n<script type=\"text/javascript\"><!--\n"
308
+ . "wpa2a.script_load();"
309
+ . "\n//--></script>\n";
310
+ }
311
+ else
312
+ $javascript_load_early = "";
313
+
314
+ $button_html .= $javascript_load_early;
315
+ $_addtoany_init = TRUE;
316
  }
317
 
318
  if ( $output_later )
330
  $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl)); // linkname_enc, etc.
331
  extract( $args );
332
 
333
+ $http_or_https = (is_ssl()) ? 'https' : 'http';
334
  $iframe_template_begin = '<iframe';
335
+ $iframe_template_end = ' class="addtoany_special_service %1$s" src="%2$s" scrolling="no" style="border:none;overflow:hidden;width:%3$dpx;height:%4$dpx"></iframe>';
336
  $iframe_template = $iframe_template_begin . $iframe_template_end;
337
 
338
  // IE ridiculousness to support transparent iframes while maintaining W3C validity
341
  . '<![endif]--><!--[if !IE]><!-->' . $iframe_template . '<!--<![endif]-->';
342
 
343
  if ($special_service_code == 'facebook_like')
344
+ $special_html = sprintf($iframe_template, $special_service_code, $http_or_https . '://www.facebook.com/plugins/like.php?href=' . $linkurl_enc . '&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany', 90, 21);
345
  elseif ($special_service_code == 'twitter_tweet')
346
+ $special_html = sprintf($iframe_template, $special_service_code, $http_or_https . '://platform.twitter.com/widgets/tweet_button.html?url=' . $linkurl_enc . '&amp;counturl=' . $linkurl_enc . '&amp;count=horizontal&amp;text=' . $linkname_enc, 55, 20);
347
+ elseif ($special_service_code == 'google_plusone')
348
+ $special_html = sprintf($iframe_template, $special_service_code, 'https://plusone.google.com/u/0/_/%2B1/button#url=' . $linkurl_enc . '&size=medium', 32, 20);
349
 
350
  if ( $output_later )
351
  return $special_html;
384
  }
385
  }
386
 
387
+
388
+ function A2A_SHARE_SAVE_head_script() {
389
+ if (is_admin())
390
+ return;
391
+
392
+ $options = get_option('addtoany_options');
393
+
394
+ $http_or_https = (is_ssl()) ? 'https' : 'http';
395
+
396
+ global $A2A_SHARE_SAVE_external_script_called;
397
+ if ( ! $A2A_SHARE_SAVE_external_script_called ) {
398
+ // Use local cache?
399
+ $cache = ($options['cache']=='1') ? TRUE : FALSE;
400
+ $upload_dir = wp_upload_dir();
401
+ $static_server = ($cache) ? $upload_dir['baseurl'] . '/addtoany' : $http_or_https . '://static.addtoany.com/menu';
402
+
403
+ // Enternal script call + initial JS + set-once variables
404
+ $additional_js = $options['additional_js_variables'];
405
+ $script_configs = (($cache) ? 'a2a_config.static_server="' . $static_server . '";' . "\n" : '' )
406
+ . (($options['onclick']=='1') ? 'a2a_config.onclick=1;' . "\n" : '')
407
+ . (($options['show_title']=='1') ? 'a2a_config.show_title=1;' . "\n" : '')
408
+ . (($additional_js) ? stripslashes($additional_js) . "\n" : '');
409
+ $A2A_SHARE_SAVE_external_script_called = true;
410
+ }
411
+ else {
412
+ $script_configs = "";
413
+ }
414
+
415
+ $javascript_header = "\n" . '<script type="text/javascript">' . "<!--\n"
416
+ . "var a2a_config=a2a_config||{},"
417
+ . "wpa2a={done:false,"
418
+ . "html_done:false,"
419
+ . "script_ready:false,"
420
+ . "script_load:function(){"
421
+ . "var a=document.createElement('script'),"
422
+ . "s=document.getElementsByTagName('script')[0];"
423
+ . "a.type='text/javascript';a.async=true;"
424
+ . "a.src='" . $static_server . "/page.js';"
425
+ . "s.parentNode.insertBefore(a,s);"
426
+ . "wpa2a.script_load=function(){};"
427
+ . "},"
428
+ . "script_onready:function(){"
429
+ . "if(a2a.type=='page'){" // Check a2a internal var to ensure script loaded is page.js not feed.js
430
+ . "wpa2a.script_ready=true;"
431
+ . "if(wpa2a.html_done)wpa2a.init();"
432
+ . "}"
433
+ . "},"
434
+ . "init:function(){"
435
+ . "for(var i=0,el,target,targets=wpa2a.targets,length=targets.length;i<length;i++){"
436
+ . "el=document.getElementById('wpa2a_'+(i+1));"
437
+ . "target=targets[i];"
438
+ . "a2a_config.linkname=target.title;"
439
+ . "a2a_config.linkurl=target.url;"
440
+ . "if(el)a2a.init('page',{target:el});wpa2a.done=true;"
441
+ . "}"
442
+ . "}"
443
+ . "};"
444
+ . "a2a_config.tracking_callback=['ready',wpa2a.script_onready];"
445
+ . A2A_menu_locale()
446
+ . "\n//--></script>\n";
447
+
448
+ echo $javascript_header;
449
+ }
450
+
451
+ add_action('wp_head', 'A2A_SHARE_SAVE_head_script');
452
+
453
+ function A2A_SHARE_SAVE_footer_script() {
454
+ global $_addtoany_targets;
455
+
456
+ if (is_admin())
457
+ return;
458
+
459
+ $javascript_footer = "\n" . '<script type="text/javascript">' . "<!--\n"
460
+ . "wpa2a.targets=["
461
+ . implode(",", $_addtoany_targets)
462
+ . "];\n"
463
+ . "wpa2a.html_done=true;"
464
+ . "if(wpa2a.script_ready&&!wpa2a.done)wpa2a.init();" // External script may load before html_done=true, but will only init if html_done=true. So call wpa2a.init() if external script is ready, and if wpa2a.init() hasn't been called already. Otherwise, wait for callback to call wpa2a.init()
465
+ . "wpa2a.script_load();" // Load external script if not already called with the first AddToAny button. Fixes issues where first button code is processed internally but without actual code output
466
+ . "\n//--></script>\n";
467
+ echo $javascript_footer;
468
+ }
469
+
470
+ add_action('wp_footer', 'A2A_SHARE_SAVE_footer_script');
471
+
472
+
473
+
474
+ function A2A_SHARE_SAVE_theme_hooks_check() {
475
+ $template_directory = get_template_directory();
476
+
477
+ // If footer.php exists in the current theme, scan for "wp_footer"
478
+ $file = $template_directory . '/footer.php';
479
+ if (is_file($file)) {
480
+ $search_string = "wp_footer";
481
+ $file_lines = @file($file);
482
+
483
+ foreach ($file_lines as $line) {
484
+ $searchCount = substr_count($line, $search_string);
485
+ if ($searchCount > 0) {
486
+ return true;
487
+ }
488
+ }
489
+
490
+ // wp_footer() not found:
491
+ echo "<div class=\"update-nag\">" . __("Your theme needs to be fixed. To fix your theme, use the <a href=\"theme-editor.php\">Theme Editor</a> to insert <code>&lt;?php wp_footer(); ?&gt;</code> just before the <code>&lt;/body&gt;</code> line of your theme's <code>footer.php</code> file.") . "</div>";
492
+ }
493
+
494
+ // If header.php exists in the current theme, scan for "wp_head"
495
+ $file = $template_directory . '/header.php';
496
+ if (is_file($file)) {
497
+ $search_string = "wp_head";
498
+ $file_lines = @file($file);
499
+
500
+ foreach ($file_lines as $line) {
501
+ $searchCount = substr_count($line, $search_string);
502
+ if ($searchCount > 0) {
503
+ return true;
504
  }
 
 
 
505
  }
506
+
507
+ // wp_footer() not found:
508
+ echo "<div class=\"update-nag\">" . __("Your theme needs to be fixed. To fix your theme, use the <a href=\"theme-editor.php\">Theme Editor</a> to insert <code>&lt;?php wp_head(); ?&gt;</code> just before the <code>&lt;/head&gt;</code> line of your theme's <code>header.php</code> file.") . "</div>";
509
+ }
510
  }
511
 
512
  function A2A_SHARE_SAVE_auto_placement($title) {
588
 
589
  $kit_args = array(
590
  "output_later" => true,
591
+ "is_kit" => ($is_feed) ? FALSE : TRUE,
 
 
 
592
  );
593
 
594
  if ( ! $is_feed ) {
595
  $container_wrap_open = '<div class="addtoany_share_save_container">';
596
  $container_wrap_close = '</div>';
597
+ } else { // Is feed
598
  $container_wrap_open = '<p>';
599
  $container_wrap_close = '</p>';
600
+ $kit_args['html_container_open'] = '';
601
+ $kit_args['html_container_close'] = '';
602
+ $kit_args['html_wrap_open'] = '';
603
+ $kit_args['html_wrap_close'] = '';
604
  }
605
 
606
  $options['position'] = isset($options['position']) ? $options['position'] : 'bottom';
880
 
881
  ?>
882
 
883
+ <?php A2A_SHARE_SAVE_theme_hooks_check(); ?>
884
 
885
  <div class="wrap">
886
 
906
  </li>
907
  <li id="a2a_wp_twitter_tweet" class="addtoany_special_service" title="Twitter Tweet button">
908
  <span><img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/icons/twitter_tweet.png'; ?>" width="55" height="20" alt="Twitter Tweet" /></span>
909
+ </li>
910
+ <li id="a2a_wp_google_plusone" class="addtoany_special_service" title="Google +1 button">
911
+ <span><img src="<?php echo $A2A_SHARE_SAVE_plugin_url_path.'/icons/google_plusone.png'; ?>" width="32" height="20" alt="Google +1" /></span>
912
  </li>
913
  <?php
914
  // Show all services