AddToAny Share Buttons - Version 1.7

Version Description

  • Simplify AddToAny asynchronous loading method
  • Use HTML5 data attributes for AddToAny instances
  • Remove old script block in footer
  • Increase support for AJAX loading by listening for the post-load event on non-AJAX requests
  • AddToAny readiness check in AddToAny settings
  • Add placement option for media pages in AddToAny settings
  • Handle "Show sharing buttons" option for media when updating from the WordPress editor
  • Add Copy Link button
  • Add Facebook Messenger share button
  • Add Trello share button
  • Update a few packaged icons
Download this release

Release Info

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

Code changes from version 1.6.18 to 1.7

README.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: micropat, addtoany
3
  Tags: AddToAny, sharing, share, social, share button, share buttons, share links, social icons, social media, media, marketing, bookmark, bookmarks, save, post, posts, page, pages, images, image, admin, analytics, statistics, stats, links, plugin, shortcode, sidebar, widget, responsive, email, e-mail, print, seo, button, amp, woocommerce, ecommerce, e-commerce, amazon, delicious, google, tumblr, linkedin, digg, reddit, facebook, facebook share, facebook like, like, twitter, twitter button, twitter share, tweet, tweet button, google plus, pinterest, pin, pin it, pinit, wanelo, buffer, stumbleupon, bitly, whatsapp, instagram, behance, flickr, foursquare, vimeo, youtube, feed, rss, addthis, sociable, share this, sharethis, shareaholic, icon, icons, vector, SVG, floating, floating buttons, wpml, wpmu, Add to Any
4
  Requires at least: 3.7
5
- Tested up to: 4.5
6
- Stable tag: 1.6.18
7
 
8
  Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp, many more, and follow icons too.
9
 
@@ -35,13 +35,13 @@ AddToAny is the universal sharing platform, and AddToAny's plugin is the most po
35
  = Analytics Integration =
36
 
37
  * Automatic Google Analytics integration (<a href="https://www.addtoany.com/ext/google_analytics/">access guide</a>) for sharing analytics
38
- * Track shared links with bit.ly, awe.sm, goo.gl, and custom URL shorteners
39
  * Display share counts on posts and pages
40
 
41
  = WordPress Optimized =
42
 
43
  * Loads asynchronously so your content always loads before or in parallel with AddToAny
44
- * Supports theme features such as HTML5 & XHTML, widgets, infinite scroll, post formats
45
  * Supports multilingual sites and multisite networks
46
  * No signup, no login, no account necessary
47
 
@@ -73,8 +73,8 @@ This plugin always strives to be the best WordPress plugin for sharing. Developm
73
 
74
  See also:
75
 
76
- * The standard <a href="https://www.addtoany.com/buttons/for/website">share buttons</a> code
77
- * The universal <a href="https://www.addtoany.com/buttons/for/wordpress_com">share button for WordPress.com</a>
78
 
79
  <a href="https://www.addtoany.com/blog/">AddToAny Blog</a> | <a href="https://www.addtoany.com/privacy">Privacy Policy</a>
80
 
@@ -134,7 +134,7 @@ Facebook expects the Title, Description, and Thumbnail of a shared page to be de
134
 
135
  Use Facebook's <a href="https://developers.facebook.com/tools/debug/sharing/" target="_blank">Sharing Debugger</a> on your pages to see how Facebook reads your site. "Scrape Again" to test site changes and clear Facebook's cache of a page, or use the <a href="https://developers.facebook.com/tools/debug/sharing/batch/" target="_blank">Batch Invalidator</a> to purge Facebook's cache of multiple URLs.
136
 
137
- To change the title, description and/or image on Facebook, your theme's header file should be modified according to <a href="https://developers.facebook.com/docs/sharing/opengraph" target="_blank">Facebook's OpenGraph specification</a>. With WordPress, this can be accomplished with plugins such as <a href="https://wordpress.org/plugins/wordpress-seo/">Yoast SEO</a> or <a href="https://wordpress.org/plugins/all-in-one-seo-pack/">All in One SEO Pack</a>. Please see those plugins for details, and post in the WordPress or plugin author's forums for more support.
138
 
139
  For more technical information on setting your pages up for Facebook sharing, see "Sharing Best Practices for Websites" in <a href="https://developers.facebook.com/docs/sharing/best-practices">Facebook's documentation</a>.
140
 
@@ -189,6 +189,19 @@ To share a specific image or video to certain services that accept arbitrary med
189
  ) );
190
  } ?>`
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  = How can I add a custom standalone share button? =
193
  You can create a plugin or customize the following example PHP code to add to your theme's functions.php file:
194
 
@@ -290,22 +303,17 @@ The Google+ Share Button width can be changed using CSS code, for instance: `.a2
290
 
291
  = Does the plugin output W3C valid code? =
292
 
293
- Yes, this plugin outputs 100% W3C valid HTML5 & XHTML and W3C valid CSS 3 by default.
294
-
295
- 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.
296
-
297
- Regardless of circumstances for passing W3C tests, the plugin will always output semantically valid and robot-readable code, so publishers do not have to worry about search engine crawler errors due to invalid code. Both <a href="https://en.wikipedia.org/wiki/Web_standards">web standards</a> and <a href="https://en.wikipedia.org/wiki/Cross-browser">cross-browser</a> compatibility are taken seriously.
298
 
299
  = How can I load the buttons after content insertion with AJAX and infinite scroll? =
300
 
301
  Fire the standard `post-load` event to have the plugin initiate AddToAny buttons:
302
  `jQuery( 'body' ).trigger( 'post-load' );`
303
 
304
- A few prerequisites:
305
 
306
  * The request has an `HTTP_X_REQUESTED_WITH` header set to `xmlhttprequest`
307
  * `jQuery` available
308
- * AddToAny `<script>` blocks in the response need to execute, so don't use jQuery's `load` method *with a selector expression*. Selector expression usage with that method will cause `<script>` blocks in the response <a href="https://api.jquery.com/load/#script-execution">to be stripped out</a>
309
 
310
  = Why does the menu appear behind embedded objects (like Flash)? =
311
 
@@ -326,6 +334,19 @@ Upload (or move) the `add-to-any` plugin directory into the `/wp-content/mu-plug
326
 
327
  == Changelog ==
328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  = 1.6.18 =
330
  * Fix default icon size
331
 
2
  Contributors: micropat, addtoany
3
  Tags: AddToAny, sharing, share, social, share button, share buttons, share links, social icons, social media, media, marketing, bookmark, bookmarks, save, post, posts, page, pages, images, image, admin, analytics, statistics, stats, links, plugin, shortcode, sidebar, widget, responsive, email, e-mail, print, seo, button, amp, woocommerce, ecommerce, e-commerce, amazon, delicious, google, tumblr, linkedin, digg, reddit, facebook, facebook share, facebook like, like, twitter, twitter button, twitter share, tweet, tweet button, google plus, pinterest, pin, pin it, pinit, wanelo, buffer, stumbleupon, bitly, whatsapp, instagram, behance, flickr, foursquare, vimeo, youtube, feed, rss, addthis, sociable, share this, sharethis, shareaholic, icon, icons, vector, SVG, floating, floating buttons, wpml, wpmu, Add to Any
4
  Requires at least: 3.7
5
+ Tested up to: 4.6
6
+ Stable tag: 1.7
7
 
8
  Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp, many more, and follow icons too.
9
 
35
  = Analytics Integration =
36
 
37
  * Automatic Google Analytics integration (<a href="https://www.addtoany.com/ext/google_analytics/">access guide</a>) for sharing analytics
38
+ * Track shared links with bit.ly, goo.gl, and custom URL shorteners
39
  * Display share counts on posts and pages
40
 
41
  = WordPress Optimized =
42
 
43
  * Loads asynchronously so your content always loads before or in parallel with AddToAny
44
+ * Supports theme features such as HTML5, widgets, infinite scroll, post formats
45
  * Supports multilingual sites and multisite networks
46
  * No signup, no login, no account necessary
47
 
73
 
74
  See also:
75
 
76
+ * The <a href="https://www.addtoany.com/buttons/">share buttons</a> for all platforms
77
+ * The <a href="https://www.addtoany.com/buttons/for/wordpress_com">share button for WordPress.com</a>
78
 
79
  <a href="https://www.addtoany.com/blog/">AddToAny Blog</a> | <a href="https://www.addtoany.com/privacy">Privacy Policy</a>
80
 
134
 
135
  Use Facebook's <a href="https://developers.facebook.com/tools/debug/sharing/" target="_blank">Sharing Debugger</a> on your pages to see how Facebook reads your site. "Scrape Again" to test site changes and clear Facebook's cache of a page, or use the <a href="https://developers.facebook.com/tools/debug/sharing/batch/" target="_blank">Batch Invalidator</a> to purge Facebook's cache of multiple URLs.
136
 
137
+ To change the title, description and/or image on Facebook, your theme's header file should be modified according to <a href="https://developers.facebook.com/docs/sharing/opengraph" target="_blank">Facebook's OpenGraph specification</a>. With WordPress, this can be accomplished with plugins such as <a href="https://wordpress.org/plugins/wordpress-seo/">Yoast SEO</a> or the Social Meta feature of the <a href="https://wordpress.org/plugins/all-in-one-seo-pack/">All in One SEO Pack</a>. Please see those plugins for details, and post in the WordPress or plugin author's forums for more support.
138
 
139
  For more technical information on setting your pages up for Facebook sharing, see "Sharing Best Practices for Websites" in <a href="https://developers.facebook.com/docs/sharing/best-practices">Facebook's documentation</a>.
140
 
189
  ) );
190
  } ?>`
191
 
192
+ = How can I place the follow buttons in a specific area of my site? =
193
+
194
+ See the [supported follow services](https://www.addtoany.com/buttons/customize/follow_buttons) for service code names, then place this example code in your theme's file(s) where you want the follow buttons to appear:
195
+ `<?php if ( function_exists( 'ADDTOANY_FOLLOW_KIT' ) ) {
196
+ ADDTOANY_FOLLOW_KIT( array(
197
+ 'buttons' => array(
198
+ 'facebook' => array( 'id' => 'zuck' ),
199
+ 'instagram' => array( 'id' => 'kevin' ),
200
+ 'twitter' => array( 'id' => 'jack' ),
201
+ ),
202
+ ) );
203
+ } ?>`
204
+
205
  = How can I add a custom standalone share button? =
206
  You can create a plugin or customize the following example PHP code to add to your theme's functions.php file:
207
 
303
 
304
  = Does the plugin output W3C valid code? =
305
 
306
+ Yes, this plugin outputs 100% W3C valid HTML5 and W3C valid CSS 3 by default.
 
 
 
 
307
 
308
  = How can I load the buttons after content insertion with AJAX and infinite scroll? =
309
 
310
  Fire the standard `post-load` event to have the plugin initiate AddToAny buttons:
311
  `jQuery( 'body' ).trigger( 'post-load' );`
312
 
313
+ A couple prerequisites:
314
 
315
  * The request has an `HTTP_X_REQUESTED_WITH` header set to `xmlhttprequest`
316
  * `jQuery` available
 
317
 
318
  = Why does the menu appear behind embedded objects (like Flash)? =
319
 
334
 
335
  == Changelog ==
336
 
337
+ = 1.7 =
338
+ * Simplify AddToAny asynchronous loading method
339
+ * Use HTML5 data attributes for AddToAny instances
340
+ * Remove old script block in footer
341
+ * Increase support for AJAX loading by listening for the `post-load` event on non-AJAX requests
342
+ * AddToAny readiness check in AddToAny settings
343
+ * Add placement option for media pages in AddToAny settings
344
+ * Handle "Show sharing buttons" option for media when updating from the WordPress editor
345
+ * Add Copy Link button
346
+ * Add Facebook Messenger share button
347
+ * Add Trello share button
348
+ * Update a few packaged icons
349
+
350
  = 1.6.18 =
351
  * Fix default icon size
352
 
add-to-any.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: AddToAny Share Buttons
4
  Plugin URI: https://www.addtoany.com/
5
  Description: Share buttons for your pages including AddToAny's universal sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp and many more.
6
- Version: 1.6.18
7
  Author: AddToAny
8
  Author URI: https://www.addtoany.com/
9
  Text Domain: add-to-any
@@ -11,7 +11,7 @@ Domain Path: /languages
11
  */
12
 
13
  // Explicitly globalize to support bootstrapped WordPress
14
- global $_addtoany_counter, $_addtoany_init, $_addtoany_targets, $A2A_locale, $A2A_FOLLOW_services,
15
  $A2A_SHARE_SAVE_plugin_basename, $A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url_path, $A2A_SHARE_SAVE_services;
16
 
17
  $A2A_SHARE_SAVE_plugin_basename = plugin_basename( dirname( __FILE__ ) );
@@ -75,17 +75,21 @@ function A2A_SHARE_SAVE_link_vars( $linkname = false, $linkurl = false, $linkmed
75
 
76
  // Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
77
  function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
78
- global $_addtoany_counter;
79
 
80
- $_addtoany_counter++;
 
 
81
 
82
- $options = get_option( 'addtoany_options' );
83
 
84
  $defaults = array(
85
- 'output_later' => false,
86
- 'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
 
87
  );
88
 
 
89
  $args = wp_parse_args( $args, $defaults );
90
  extract( $args );
91
 
@@ -98,8 +102,11 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
98
 
99
  // Custom icons enabled?
100
  $custom_icons = ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) ? true : false;
101
-
102
  $kit_additional_classes = '';
 
 
 
103
  $kit_style = '';
104
 
105
  // Add additional classNames to .a2a_kit
@@ -140,10 +147,8 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
140
  }
141
 
142
  if ( ! isset( $args['html_container_open'] ) ) {
143
- $args['html_container_open'] = '<div class="a2a_kit' . $icon_size_classname . $kit_additional_classes . ' a2a_target"';
144
- $args['html_container_open'] .= ' id="wpa2a_' . $_addtoany_counter . '"'; // ID is later removed by JS (for AJAX)
145
- $args['html_container_open'] .= $kit_style;
146
- $args['html_container_open'] .= '>';
147
  $args['is_kit'] = true;
148
  }
149
  if ( ! isset( $args['html_container_close'] ) )
@@ -359,14 +364,13 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
359
 
360
  // $args array = output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl, no_universal_button
361
 
362
- global $A2A_SHARE_SAVE_plugin_url_path, $_addtoany_targets, $_addtoany_counter, $_addtoany_init;
363
 
364
  $options = get_option( 'addtoany_options' );
365
 
366
  $linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
367
  $linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
368
  $linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
369
- $_addtoany_targets = ( isset( $_addtoany_targets ) ) ? $_addtoany_targets : array();
370
 
371
  $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl, $linkmedia)); // linkname_enc, etc.
372
 
@@ -392,20 +396,12 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
392
  $args = wp_parse_args( $args, $defaults );
393
  extract( $args );
394
 
395
- // If not enclosed in an AddToAny Kit, count & target this button (instead of Kit) for async loading
396
- if ( ! $args['is_kit'] ) {
397
- $_addtoany_counter++;
398
- $button_class = ' a2a_target';
399
- $button_id = ' id="wpa2a_' . $_addtoany_counter . '"'; // ID is later removed by JS (for AJAX)
400
- } else {
401
- $button_class = '';
402
- $button_id = '';
403
- }
404
-
405
- /* AddToAny button */
406
-
407
  $is_feed = is_feed();
408
  $is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
 
 
 
 
409
  $button_target = $is_amp ? ' target="_blank"' : '';
410
  $button_href_querystring = ($is_feed || $is_amp) ? '#url=' . $linkurl_enc . '&amp;title=' . $linkname_enc : '';
411
 
@@ -465,8 +461,8 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
465
  $button_class .= ' a2a_counter';
466
  }
467
 
468
- $button_html = $html_container_open . $html_wrap_open . '<a class="a2a_dd' . $button_class . ' addtoany_share_save" href="https://www.addtoany.com/share' .$button_href_querystring . '"' . $button_id
469
- . $style . $button_target
470
  . '>' . $button . '</a>';
471
 
472
  } else {
@@ -474,64 +470,6 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
474
  $button_html = '';
475
  }
476
 
477
- // Hook to disable script output
478
- // Example: add_filter( 'addtoany_script_disabled', '__return_true' );
479
- $script_disabled = apply_filters( 'addtoany_script_disabled', false );
480
- // Doing AJAX? (the DOING_AJAX constant can be unreliable)
481
- $ajax = ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) ? true : false;
482
-
483
- // If not a feed and script is not disabled,
484
- // and not admin (unless doing AJAX, probably through admin-ajax.php)
485
- if ( ! $is_feed && ! $script_disabled && ( ! is_admin() || $ajax ) ) {
486
- if ($use_current_page) {
487
- $button_config = "\n{title:document.title,"
488
- . "url:location.href}";
489
- $_addtoany_targets[] = $button_config;
490
- } else {
491
- // wp_json_encode available since 4.1
492
- $linkname_sanitized = function_exists( 'wp_json_encode' ) ? wp_json_encode ( $linkname ) : json_encode( $linkname );
493
- $linkmedia_optional = ! empty( $linkmedia ) ? ',media:"' . $linkmedia . '"' : '' ;
494
- $button_config = "\n{title:". $linkname_sanitized . ','
495
- . 'url:"' . $linkurl . '"'
496
- . $linkmedia_optional . '}';
497
- $_addtoany_targets[] = $button_config;
498
- }
499
-
500
- // If doing AJAX (the DOING_AJAX constant can be unreliable)
501
- if ( $ajax ) {
502
- $javascript_button_config = "<script type=\"text/javascript\"><!--\n"
503
- . "if(wpa2a.targets)wpa2a.targets.push("
504
- . $button_config
505
- . ");\n";
506
-
507
- if ( ! $_addtoany_init ) {
508
- // Catch post-load event to support infinite scroll (and more?)
509
- $javascript_button_config .= "\nif('function'===typeof(jQuery))"
510
- . "jQuery(document).ready(function($){"
511
- . "$('body').on('post-load',function(){"
512
- . "if(wpa2a.script_ready)wpa2a.init();"
513
- . "wpa2a.script_load();" // Load external script if not already called
514
- . "});"
515
- . "});";
516
- }
517
-
518
- $javascript_button_config .= "\n//--></script>\n";
519
- } else {
520
- $javascript_button_config = '';
521
- }
522
-
523
- if ( ! $_addtoany_init ) {
524
- $javascript_load_early = "\n<script type=\"text/javascript\"><!--\n"
525
- . "if(wpa2a)wpa2a.script_load();"
526
- . "\n//--></script>\n";
527
- } else {
528
- $javascript_load_early = "";
529
- }
530
-
531
- $button_html .= $javascript_load_early . $javascript_button_config;
532
- $_addtoany_init = true;
533
- }
534
-
535
  // Closing tags come after <script> to validate in case the container is a list element
536
  $button_html .= $html_wrap_close . $html_container_close;
537
 
@@ -785,48 +723,17 @@ function A2A_SHARE_SAVE_head_script() {
785
  . ( ( $additional_js ) ? "\n" . stripslashes( $additional_js ) : '' );
786
  $A2A_SHARE_SAVE_external_script_called = true;
787
 
788
- $javascript_header = "\n" . '<script type="text/javascript">' . "<!--\n"
789
-
790
- . "var a2a_config=a2a_config||{},"
791
- . "wpa2a={done:false,"
792
- . "html_done:false,"
793
- . "script_ready:false,"
794
- . "script_load:function(){"
795
- . "var a=document.createElement('script'),"
796
- . "s=document.getElementsByTagName('script')[0];"
797
- . "a.type='text/javascript';a.async=true;"
798
- . "a.src='" . $static_server . "/page.js';"
799
- . "s.parentNode.insertBefore(a,s);"
800
- . "wpa2a.script_load=function(){};"
801
- . "},"
802
- . "script_onready:function(){"
803
- . "wpa2a.script_ready=true;"
804
- . "if(wpa2a.html_done)wpa2a.init();"
805
- . "},"
806
- . "init:function(){"
807
- . "for(var i=0,el,target,targets=wpa2a.targets,length=targets.length;i<length;i++){"
808
- . "el=document.getElementById('wpa2a_'+(i+1));"
809
- . "target=targets[i];"
810
- . "a2a_config.linkname=target.title;"
811
- . "a2a_config.linkurl=target.url;"
812
- . "a2a_config.linkmedia=target.media;"
813
- . "if(el){"
814
- . "a2a.init('page',{target:el});"
815
- . "el.id='';" // Remove ID so AJAX can reuse the same ID
816
- . "}"
817
- . "wpa2a.done=true;"
818
- . "}"
819
- . "wpa2a.targets=[];" // Empty targets array so AJAX can reuse from index 0
820
- . "}"
821
- . "};"
822
-
823
  . "a2a_config.callbacks=a2a_config.callbacks||[];"
824
- . "a2a_config.callbacks.push({ready:wpa2a.script_onready});"
825
  . "a2a_config.templates=a2a_config.templates||{};"
826
  . A2A_menu_locale()
827
  . $script_configs
828
 
829
- . "\n//--></script>\n";
 
 
830
 
831
  echo $javascript_header;
832
  }
@@ -834,29 +741,12 @@ function A2A_SHARE_SAVE_head_script() {
834
  add_action( 'wp_head', 'A2A_SHARE_SAVE_head_script' );
835
 
836
  function A2A_SHARE_SAVE_footer_script() {
837
- global $_addtoany_targets;
838
-
839
- // Hook to disable script output
840
- // Example: add_filter( 'addtoany_script_disabled', '__return_true' );
841
- $script_disabled = apply_filters( 'addtoany_script_disabled', false );
842
-
843
- if ( is_admin() || is_feed() || $script_disabled )
844
  return;
845
-
846
- $_addtoany_targets = ( isset( $_addtoany_targets ) ) ? $_addtoany_targets : array();
847
 
848
  $floating_html = ADDTOANY_SHARE_SAVE_FLOATING( array( 'output_later' => true ) );
849
 
850
- $javascript_footer = "\n" . '<script type="text/javascript">' . "<!--\n"
851
- . "wpa2a.targets=["
852
- . implode( ",", $_addtoany_targets )
853
- . "];\n"
854
- . "wpa2a.html_done=true;"
855
- . "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()
856
- . "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
857
- . "\n//--></script>\n";
858
-
859
- echo $floating_html . $javascript_footer;
860
  }
861
 
862
  add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
@@ -917,6 +807,8 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
917
  // Pages
918
  // Individual pages
919
  ( is_page() && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
 
 
920
  // <!--nosharesave--> legacy tag
921
  ( (strpos( $content, '<!--nosharesave-->') !== false ) )
922
  )
@@ -1076,6 +968,16 @@ function A2A_SHARE_SAVE_stylesheet() {
1076
 
1077
  add_action( 'wp_print_styles', 'A2A_SHARE_SAVE_stylesheet' );
1078
 
 
 
 
 
 
 
 
 
 
 
1079
 
1080
  /**
1081
  * Cache AddToAny
3
  Plugin Name: AddToAny Share Buttons
4
  Plugin URI: https://www.addtoany.com/
5
  Description: Share buttons for your pages including AddToAny's universal sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp and many more.
6
+ Version: 1.7
7
  Author: AddToAny
8
  Author URI: https://www.addtoany.com/
9
  Text Domain: add-to-any
11
  */
12
 
13
  // Explicitly globalize to support bootstrapped WordPress
14
+ global $A2A_locale, $A2A_FOLLOW_services,
15
  $A2A_SHARE_SAVE_plugin_basename, $A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url_path, $A2A_SHARE_SAVE_services;
16
 
17
  $A2A_SHARE_SAVE_plugin_basename = plugin_basename( dirname( __FILE__ ) );
75
 
76
  // Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
77
  function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
78
+ $options = get_option( 'addtoany_options' );
79
 
80
+ $linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
81
+ $linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
82
+ $linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
83
 
84
+ $args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $linkname, $linkurl, $linkmedia ) ); // linkname_enc, etc.
85
 
86
  $defaults = array(
87
+ 'output_later' => false,
88
+ 'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
89
+ 'use_current_page' => false,
90
  );
91
 
92
+
93
  $args = wp_parse_args( $args, $defaults );
94
  extract( $args );
95
 
102
 
103
  // Custom icons enabled?
104
  $custom_icons = ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) ? true : false;
105
+
106
  $kit_additional_classes = '';
107
+ $kit_data_media = empty( $linkmedia ) ? '' : ' data-a2a-media="' . $linkmedia . '"';
108
+ $kit_data_title = empty( $linkname ) || $use_current_page ? '' : ' data-a2a-title="' . $linkname . '"';
109
+ $kit_data_url = empty( $linkurl ) || $use_current_page ? '' : ' data-a2a-url="' . $linkurl . '"';
110
  $kit_style = '';
111
 
112
  // Add additional classNames to .a2a_kit
147
  }
148
 
149
  if ( ! isset( $args['html_container_open'] ) ) {
150
+ $args['html_container_open'] = '<div class="a2a_kit' . $icon_size_classname . $kit_additional_classes . '"'
151
+ . $kit_data_url . $kit_data_title . $kit_data_media . $kit_style . '>';
 
 
152
  $args['is_kit'] = true;
153
  }
154
  if ( ! isset( $args['html_container_close'] ) )
364
 
365
  // $args array = output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl, no_universal_button
366
 
367
+ global $A2A_SHARE_SAVE_plugin_url_path;
368
 
369
  $options = get_option( 'addtoany_options' );
370
 
371
  $linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
372
  $linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
373
  $linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
 
374
 
375
  $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl, $linkmedia)); // linkname_enc, etc.
376
 
396
  $args = wp_parse_args( $args, $defaults );
397
  extract( $args );
398
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  $is_feed = is_feed();
400
  $is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
401
+ $button_class = '';
402
+ $button_data_media = $is_kit || empty( $linkmedia ) ? '' : ' data-a2a-media="' . $linkmedia . '"';
403
+ $button_data_title = $is_kit || empty( $linkname ) ? '' : ' data-a2a-title="' . $linkname . '"';
404
+ $button_data_url = $is_kit || empty( $linkurl ) ? '' : ' data-a2a-url="' . $linkurl . '"';
405
  $button_target = $is_amp ? ' target="_blank"' : '';
406
  $button_href_querystring = ($is_feed || $is_amp) ? '#url=' . $linkurl_enc . '&amp;title=' . $linkname_enc : '';
407
 
461
  $button_class .= ' a2a_counter';
462
  }
463
 
464
+ $button_html = $html_container_open . $html_wrap_open . '<a class="a2a_dd' . $button_class . ' addtoany_share_save" href="https://www.addtoany.com/share' .$button_href_querystring . '"'
465
+ . $button_data_url . $button_data_title . $button_data_media . $style . $button_target
466
  . '>' . $button . '</a>';
467
 
468
  } else {
470
  $button_html = '';
471
  }
472
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  // Closing tags come after <script> to validate in case the container is a list element
474
  $button_html .= $html_wrap_close . $html_container_close;
475
 
723
  . ( ( $additional_js ) ? "\n" . stripslashes( $additional_js ) : '' );
724
  $A2A_SHARE_SAVE_external_script_called = true;
725
 
726
+ $javascript_header = "\n" . '<script type="text/javascript">' . "\n"
727
+
728
+ . "var a2a_config=a2a_config||{};"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
729
  . "a2a_config.callbacks=a2a_config.callbacks||[];"
 
730
  . "a2a_config.templates=a2a_config.templates||{};"
731
  . A2A_menu_locale()
732
  . $script_configs
733
 
734
+ . "\n</script>\n"
735
+
736
+ . '<script type="text/javascript" src="' . $static_server . '/page.js" async="async"></script>' . "\n";
737
 
738
  echo $javascript_header;
739
  }
741
  add_action( 'wp_head', 'A2A_SHARE_SAVE_head_script' );
742
 
743
  function A2A_SHARE_SAVE_footer_script() {
744
+ if ( is_admin() || is_feed() )
 
 
 
 
 
 
745
  return;
 
 
746
 
747
  $floating_html = ADDTOANY_SHARE_SAVE_FLOATING( array( 'output_later' => true ) );
748
 
749
+ echo $floating_html;
 
 
 
 
 
 
 
 
 
750
  }
751
 
752
  add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
807
  // Pages
808
  // Individual pages
809
  ( is_page() && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
810
+ // Attachment (media) pages
811
+ ( is_attachment() && isset( $options['display_in_attachments'] ) && $options['display_in_attachments'] == '-1' ) ||
812
  // <!--nosharesave--> legacy tag
813
  ( (strpos( $content, '<!--nosharesave-->') !== false ) )
814
  )
968
 
969
  add_action( 'wp_print_styles', 'A2A_SHARE_SAVE_stylesheet' );
970
 
971
+ function A2A_SHARE_SAVE_enqueue_script() {
972
+ global $A2A_SHARE_SAVE_plugin_url_path;
973
+
974
+ if ( wp_script_is( 'jquery', 'registered' ) ) {
975
+ wp_enqueue_script( 'addtoany', $A2A_SHARE_SAVE_plugin_url_path . '/addtoany.min.js', array( 'jquery' ), '1.0' );
976
+ }
977
+ }
978
+
979
+ add_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' );
980
+
981
 
982
  /**
983
  * Cache AddToAny
addtoany.admin.js CHANGED
@@ -6,14 +6,9 @@ jQuery( function() {
6
  }
7
 
8
  function addtoany_init() {
9
- if ( ! wpa2a )
10
- return;
11
-
12
- if (wpa2a.script_ready)
13
- wpa2a.init();
14
-
15
- // Load external script if not already called
16
- wpa2a.script_load();
17
  }
18
 
19
  // Init AddToAny when a partial is rendered.
6
  }
7
 
8
  function addtoany_init() {
9
+ if ( window.a2a ) {
10
+ a2a.init_all( 'page' );
11
+ }
 
 
 
 
 
12
  }
13
 
14
  // Init AddToAny when a partial is rendered.
addtoany.admin.php CHANGED
@@ -67,6 +67,7 @@ function A2A_SHARE_SAVE_meta_box_save( $post_id ) {
67
 
68
  add_action( 'admin_init', 'A2A_SHARE_SAVE_add_meta_box' );
69
  add_action( 'save_post', 'A2A_SHARE_SAVE_meta_box_save' );
 
70
 
71
  /**
72
  * Migrate old AddToAny options
@@ -270,6 +271,7 @@ function A2A_SHARE_SAVE_options_page() {
270
  $new_options['display_in_excerpts'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_excerpts'] ) && $_POST['A2A_SHARE_SAVE_display_in_excerpts'] == '1' ) ? '1' : '-1';
271
  $new_options['display_in_posts'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_posts'] ) && $_POST['A2A_SHARE_SAVE_display_in_posts'] == '1' ) ? '1' : '-1';
272
  $new_options['display_in_pages'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_pages'] ) && $_POST['A2A_SHARE_SAVE_display_in_pages'] == '1' ) ? '1' : '-1';
 
273
  $new_options['display_in_feed'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_feed'] ) && $_POST['A2A_SHARE_SAVE_display_in_feed'] == '1' ) ? '1' : '-1';
274
  $new_options['show_title'] = ( isset( $_POST['A2A_SHARE_SAVE_show_title'] ) && $_POST['A2A_SHARE_SAVE_show_title'] == '1' ) ? '1' : '-1';
275
  $new_options['onclick'] = ( isset( $_POST['A2A_SHARE_SAVE_onclick'] ) && $_POST['A2A_SHARE_SAVE_onclick'] == '1' ) ? '1' : '-1';
@@ -359,7 +361,7 @@ function A2A_SHARE_SAVE_options_page() {
359
  update_option( 'addtoany_options', $new_options );
360
 
361
  ?>
362
- <div class="updated fade"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
363
  <?php
364
 
365
  } else if ( isset( $_POST['Reset'] ) ) {
@@ -607,6 +609,13 @@ function A2A_SHARE_SAVE_options_page() {
607
  <input name="A2A_SHARE_SAVE_display_in_pages" type="checkbox"<?php if ( ! isset( $options['display_in_pages'] ) || $options['display_in_pages'] != '-1' ) echo ' checked="checked"'; ?> value="1"/>
608
  <?php printf(__('Display at the %s of pages', 'add-to-any'), position_in_content( $options, false )); ?>
609
  </label>
 
 
 
 
 
 
 
610
 
611
  <?php
612
  $custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' ) );
@@ -644,7 +653,7 @@ function A2A_SHARE_SAVE_options_page() {
644
  <p><?php _e("You can use AddToAny's Menu Styler to customize the colors of your universal share menu. When you're done, be sure to paste the generated code in the <a href=\"#\" onclick=\"document.getElementById('A2A_SHARE_SAVE_additional_js_variables').focus();return false\">Additional JavaScript</a> box below.", 'add-to-any'); ?></p>
645
  </label>
646
  <p>
647
- <a href="https://www.addtoany.com/buttons/share_save/menu_style/wordpress" class="button-secondary" title="<?php _e("Open the AddToAny Menu Styler in a new window", 'add-to-any'); ?>" target="_blank" onclick="document.getElementById('A2A_SHARE_SAVE_additional_js_variables').focus(); document.getElementById('A2A_SHARE_SAVE_menu_styler_note').style.display='';"><?php _e("Open Menu Styler", 'add-to-any'); ?></a>
648
  </p>
649
  </fieldset></td>
650
  </tr>
@@ -815,8 +824,11 @@ function A2A_SHARE_SAVE_options_page() {
815
  <p><?php _e('Search the <a href="http://wordpress.org/tags/add-to-any">support forums</a>.','add-to-any'); ?></p>
816
  </div>
817
 
818
- <script type="text/javascript" src="http<?php if ( is_ssl() ) echo 's'; ?>://static.addtoany.com/menu/page.js"></script>
819
- <script type="text/javascript">if ( a2a && a2a.svg_css ) a2a.svg_css();</script>
 
 
 
820
 
821
  <?php
822
 
67
 
68
  add_action( 'admin_init', 'A2A_SHARE_SAVE_add_meta_box' );
69
  add_action( 'save_post', 'A2A_SHARE_SAVE_meta_box_save' );
70
+ add_action( 'edit_attachment', 'A2A_SHARE_SAVE_meta_box_save' );
71
 
72
  /**
73
  * Migrate old AddToAny options
271
  $new_options['display_in_excerpts'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_excerpts'] ) && $_POST['A2A_SHARE_SAVE_display_in_excerpts'] == '1' ) ? '1' : '-1';
272
  $new_options['display_in_posts'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_posts'] ) && $_POST['A2A_SHARE_SAVE_display_in_posts'] == '1' ) ? '1' : '-1';
273
  $new_options['display_in_pages'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_pages'] ) && $_POST['A2A_SHARE_SAVE_display_in_pages'] == '1' ) ? '1' : '-1';
274
+ $new_options['display_in_attachments'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_attachments'] ) && $_POST['A2A_SHARE_SAVE_display_in_attachments'] == '1' ) ? '1' : '-1';
275
  $new_options['display_in_feed'] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_feed'] ) && $_POST['A2A_SHARE_SAVE_display_in_feed'] == '1' ) ? '1' : '-1';
276
  $new_options['show_title'] = ( isset( $_POST['A2A_SHARE_SAVE_show_title'] ) && $_POST['A2A_SHARE_SAVE_show_title'] == '1' ) ? '1' : '-1';
277
  $new_options['onclick'] = ( isset( $_POST['A2A_SHARE_SAVE_onclick'] ) && $_POST['A2A_SHARE_SAVE_onclick'] == '1' ) ? '1' : '-1';
361
  update_option( 'addtoany_options', $new_options );
362
 
363
  ?>
364
+ <div class="updated"><p><?php _e( 'Settings saved.' ); ?></p></div>
365
  <?php
366
 
367
  } else if ( isset( $_POST['Reset'] ) ) {
609
  <input name="A2A_SHARE_SAVE_display_in_pages" type="checkbox"<?php if ( ! isset( $options['display_in_pages'] ) || $options['display_in_pages'] != '-1' ) echo ' checked="checked"'; ?> value="1"/>
610
  <?php printf(__('Display at the %s of pages', 'add-to-any'), position_in_content( $options, false )); ?>
611
  </label>
612
+ <br/>
613
+ <label>
614
+ <input name="A2A_SHARE_SAVE_display_in_attachments" type="checkbox"<?php
615
+ if ( ! isset( $options['display_in_attachments'] ) || $options['display_in_attachments'] != '-1' ) echo ' checked="checked"';
616
+ ?> value="1"/>
617
+ <?php printf(__('Display at the %s of media pages', 'add-to-any'), position_in_content( $options, false )); ?>
618
+ </label>
619
 
620
  <?php
621
  $custom_post_types = array_values( get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' ) );
653
  <p><?php _e("You can use AddToAny's Menu Styler to customize the colors of your universal share menu. When you're done, be sure to paste the generated code in the <a href=\"#\" onclick=\"document.getElementById('A2A_SHARE_SAVE_additional_js_variables').focus();return false\">Additional JavaScript</a> box below.", 'add-to-any'); ?></p>
654
  </label>
655
  <p>
656
+ <a href="https://www.addtoany.com/buttons/share/menu_style/wordpress" class="button-secondary" title="<?php _e("Open the AddToAny Menu Styler in a new window", 'add-to-any'); ?>" target="_blank" onclick="document.getElementById('A2A_SHARE_SAVE_additional_js_variables').focus(); document.getElementById('A2A_SHARE_SAVE_menu_styler_note').style.display='';"><?php _e("Open Menu Styler", 'add-to-any'); ?></a>
657
  </p>
658
  </fieldset></td>
659
  </tr>
824
  <p><?php _e('Search the <a href="http://wordpress.org/tags/add-to-any">support forums</a>.','add-to-any'); ?></p>
825
  </div>
826
 
827
+ <script src="http<?php if ( is_ssl() ) echo 's'; ?>://static.addtoany.com/menu/page.js"></script>
828
+ <script>
829
+ if ( window.a2a && a2a.svg_css ) a2a.svg_css();
830
+ jQuery(document).ready( function() { if ( ! window.a2a) jQuery('<div class="error"><p><strong>Something is preventing AddToAny from loading. Try disabling content blockers such as ad-blocking add-ons, or try another web browser.</strong></p></div>').insertBefore('.nav-tab-wrapper:eq(0)'); });
831
+ </script>
832
 
833
  <?php
834
 
addtoany.min.js ADDED
@@ -0,0 +1 @@
 
1
+ "function"==typeof jQuery&&jQuery(document).ready(function(a){a("body").on("post-load",function(){window.a2a&&a2a.init_all("page")})});
addtoany.services.php CHANGED
@@ -106,6 +106,10 @@ $A2A_SHARE_SAVE_services = array(
106
  "name" => "CiteULike",
107
  "icon" => "citeulike",
108
  ),
 
 
 
 
109
  "delicious" => array(
110
  "name" => "Delicious",
111
  "icon" => "delicious",
@@ -146,6 +150,10 @@ $A2A_SHARE_SAVE_services = array(
146
  "name" => "Evernote",
147
  "icon" => "evernote",
148
  ),
 
 
 
 
149
  "fark" => array(
150
  "name" => "Fark",
151
  "icon" => "fark",
@@ -338,6 +346,10 @@ $A2A_SHARE_SAVE_services = array(
338
  "name" => "Telegram",
339
  "icon" => "telegram",
340
  ),
 
 
 
 
341
  "tuenti" => array(
342
  "name" => "Tuenti",
343
  "icon" => "tuenti",
106
  "name" => "CiteULike",
107
  "icon" => "citeulike",
108
  ),
109
+ "copy_link" => array(
110
+ "name" => "Copy Link",
111
+ "icon" => "link",
112
+ ),
113
  "delicious" => array(
114
  "name" => "Delicious",
115
  "icon" => "delicious",
150
  "name" => "Evernote",
151
  "icon" => "evernote",
152
  ),
153
+ "facebook_messenger" => array(
154
+ "name" => "Facebook Messenger",
155
+ "icon" => "facebook_messenger",
156
+ ),
157
  "fark" => array(
158
  "name" => "Fark",
159
  "icon" => "fark",
346
  "name" => "Telegram",
347
  "icon" => "telegram",
348
  ),
349
+ "trello" => array(
350
+ "name" => "Trello",
351
+ "icon" => "trello",
352
+ ),
353
  "tuenti" => array(
354
  "name" => "Tuenti",
355
  "icon" => "tuenti",
icons/aim.png CHANGED
Binary file
icons/facebook_messenger.png ADDED
Binary file
icons/instagram.png CHANGED
Binary file
icons/link.png ADDED
Binary file
icons/trello.png ADDED
Binary file
icons/tuenti.png CHANGED
Binary file