AddToAny Share Buttons - Version 1.7.44

Version Description

  • Update the Print service to support AMP (thanks andrei0x309)
  • Enable the addtoany_icons_bg_color filter hook to programmatically change the color of icons
    • The addtoany_icons_bg_color filter only applies to the standard share buttons on AMP in this release
    • A future release will apply the filter globally on all pages
Download this release

Release Info

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

Code changes from version 1.7.43 to 1.7.44

Files changed (2) hide show
  1. README.txt +9 -3
  2. add-to-any.php +20 -5
README.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: micropat, addtoany
3
  Tags: buttons, share, icons, social media, share buttons, sharing, share button, media, social, marketing, links, email, seo, woocommerce, google, linkedin, reddit, facebook, twitter, pinterest, whatsapp, instagram, youtube, share this, sharethis, feed
4
  Requires at least: 3.7
5
- Tested up to: 5.6
6
  Requires PHP: 5.6
7
- Stable tag: 1.7.43
8
 
9
  Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, WhatsApp, Pinterest, Reddit, many more, and follow icons too.
10
 
@@ -63,7 +63,7 @@ AddToAny is the home of universal sharing, and the AddToAny plugin is the most p
63
  = Wide Support =
64
 
65
  * Over 10 years of development
66
- * Over 10 million downloads
67
  * Translated into dozens of languages
68
  * Ongoing support from the community
69
 
@@ -346,6 +346,12 @@ Upload (or move) the `add-to-any` plugin directory into the `/wp-content/mu-plug
346
 
347
  == Changelog ==
348
 
 
 
 
 
 
 
349
  = 1.7.43 =
350
  * Update the vertical floating bar's "Attach to content" option to check whether content exists before attaching
351
 
2
  Contributors: micropat, addtoany
3
  Tags: buttons, share, icons, social media, share buttons, sharing, share button, media, social, marketing, links, email, seo, woocommerce, google, linkedin, reddit, facebook, twitter, pinterest, whatsapp, instagram, youtube, share this, sharethis, feed
4
  Requires at least: 3.7
5
+ Tested up to: 5.7
6
  Requires PHP: 5.6
7
+ Stable tag: 1.7.44
8
 
9
  Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, WhatsApp, Pinterest, Reddit, many more, and follow icons too.
10
 
63
  = Wide Support =
64
 
65
  * Over 10 years of development
66
+ * Over 12 million downloads
67
  * Translated into dozens of languages
68
  * Ongoing support from the community
69
 
346
 
347
  == Changelog ==
348
 
349
+ = 1.7.44 =
350
+ * Update the Print service to support AMP (thanks andrei0x309)
351
+ * Enable the `addtoany_icons_bg_color` filter hook to programmatically change the color of icons
352
+ * The `addtoany_icons_bg_color` filter only applies to the standard share buttons on AMP in this release
353
+ * A future release will apply the filter globally on all pages
354
+
355
  = 1.7.43 =
356
  * Update the vertical floating bar's "Attach to content" option to check whether content exists before attaching
357
 
add-to-any.php CHANGED
@@ -2,8 +2,8 @@
2
  /**
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.43
7
  * Author: AddToAny
8
  * Author URI: https://www.addtoany.com/
9
  * Text Domain: add-to-any
@@ -223,6 +223,9 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
223
 
224
  // Use large icons except for AMP.
225
  $large_icons = $is_amp ? false : true;
 
 
 
226
 
227
  // Directory of either custom icons or the packaged icons
228
  if ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) {
@@ -332,7 +335,9 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
332
  $height_attr = isset( $service['icon_height'] ) ? ' height="' . esc_attr( $service['icon_height'] ) . '"' : ' height="16"';
333
  $height_attr = $is_amp && ! empty( $args['icon_size'] ) ? ' height="' . esc_attr( $args['icon_size'] ) . '"' : $height_attr;
334
 
335
- $img_style_attr = $is_amp && ! empty( $service['color'] ) ? ' style="background-color:#' . esc_attr( $service['color'] ) . ';"' : '';
 
 
336
 
337
  $url = isset( $href ) ? $href : 'https://www.addtoany.com/add_to/' . $code_name . '?linkurl=' . $args['linkurl_enc'] .'&linkname=' . $args['linkname_enc'];
338
  $src = $icon_url ? $icon_url : $icons_dir . $icon . '.' . $icons_type;
@@ -355,13 +360,21 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
355
  $rel_attr = $args['is_follow'] ? $rel_noopener_only : ' rel="nofollow' . $rel_noopener . '"'; // ($args['is_follow'] indicates a Follow Kit. 'nofollow' is for search crawlers. Different things)
356
  $rel_attr = $args['basic_html'] ? '' : $rel_attr;
357
 
 
 
 
 
 
 
 
 
358
  // Set dimension attributes if using custom icons and dimension is specified.
359
  if ( isset( $custom_icons ) ) {
360
  $width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
361
  $height_attr = ! empty( $icons_height ) ? ' height="' . $icons_height . '"' : '';
362
  }
363
 
364
- $link = $args['html_wrap_open'] . "<a$class_attr$href_attr$title_attr$rel_attr$target_attr>";
365
  $link .= ( $large_icons && ! isset( $custom_icons ) && ! $custom_service ) ? '' : '<img' . $img_style_attr . ' src="' . esc_attr( $src ) . '"' . $width_attr . $height_attr . ' alt="' . esc_attr( $name ) . '">';
366
  $link .= "</a>" . $args['html_wrap_close'];
367
  }
@@ -409,6 +422,8 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
409
 
410
  $is_feed = is_feed();
411
  $is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
 
 
412
  $button_class = '';
413
  $button_data_media = $args['is_kit'] || empty( $args['linkmedia'] ) ? '' : ' data-a2a-media="' . esc_attr( $args['linkmedia'] ) . '"';
414
  $button_data_title = $args['is_kit'] || empty( $args['linkname'] ) ? '' : ' data-a2a-title="' . esc_attr( $args['linkname'] ) . '"';
@@ -437,7 +452,7 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
437
  $button_src = 'https://static.addtoany.com/buttons/a2a.svg';
438
  $button_width = ! empty( $args['icon_size'] ) ? ' width="' . $args['icon_size'] .'"' : ' width="32"';
439
  $button_height = ! empty( $args['icon_size'] ) ? ' height="' . $args['icon_size'] .'"' : ' height="32"';
440
- $button_style = $is_amp ? ' style="background-color:#0166ff"' : '';
441
  }
442
  }
443
 
2
  /**
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, LinkedIn, Pinterest, WhatsApp and many more.
6
+ * Version: 1.7.44
7
  * Author: AddToAny
8
  * Author URI: https://www.addtoany.com/
9
  * Text Domain: add-to-any
223
 
224
  // Use large icons except for AMP.
225
  $large_icons = $is_amp ? false : true;
226
+
227
+ // Make the color of the icons extensible, primariliy for AMP use cases.
228
+ $icon_bg_color_filtered = apply_filters( 'addtoany_icons_bg_color', '' );
229
 
230
  // Directory of either custom icons or the packaged icons
231
  if ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) {
335
  $height_attr = isset( $service['icon_height'] ) ? ' height="' . esc_attr( $service['icon_height'] ) . '"' : ' height="16"';
336
  $height_attr = $is_amp && ! empty( $args['icon_size'] ) ? ' height="' . esc_attr( $args['icon_size'] ) . '"' : $height_attr;
337
 
338
+ $img_style_attr_bg_color = ! empty( $service['color'] ) ? '#' . $service['color'] : '';
339
+ $img_style_attr_bg_color = ! empty( $icon_bg_color_filtered ) ? $icon_bg_color_filtered : $img_style_attr_bg_color;
340
+ $img_style_attr = $is_amp && ! empty( $img_style_attr_bg_color ) ? ' style="background-color:' . esc_attr( $img_style_attr_bg_color ) . ';"' : '';
341
 
342
  $url = isset( $href ) ? $href : 'https://www.addtoany.com/add_to/' . $code_name . '?linkurl=' . $args['linkurl_enc'] .'&amp;linkname=' . $args['linkname_enc'];
343
  $src = $icon_url ? $icon_url : $icons_dir . $icon . '.' . $icons_type;
360
  $rel_attr = $args['is_follow'] ? $rel_noopener_only : ' rel="nofollow' . $rel_noopener . '"'; // ($args['is_follow'] indicates a Follow Kit. 'nofollow' is for search crawlers. Different things)
361
  $rel_attr = $args['basic_html'] ? '' : $rel_attr;
362
 
363
+ // Use AMP's "print" action.
364
+ if ( $is_amp && 'print' === $code_name ) {
365
+ $amp_on_attr = 'on="tap:AMP.print()"';
366
+ $href_attr = '#';
367
+ } else {
368
+ $amp_on_attr = '';
369
+ }
370
+
371
  // Set dimension attributes if using custom icons and dimension is specified.
372
  if ( isset( $custom_icons ) ) {
373
  $width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
374
  $height_attr = ! empty( $icons_height ) ? ' height="' . $icons_height . '"' : '';
375
  }
376
 
377
+ $link = $args['html_wrap_open'] . "<a$class_attr$href_attr$title_attr$rel_attr$target_attr$amp_on_attr>";
378
  $link .= ( $large_icons && ! isset( $custom_icons ) && ! $custom_service ) ? '' : '<img' . $img_style_attr . ' src="' . esc_attr( $src ) . '"' . $width_attr . $height_attr . ' alt="' . esc_attr( $name ) . '">';
379
  $link .= "</a>" . $args['html_wrap_close'];
380
  }
422
 
423
  $is_feed = is_feed();
424
  $is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
425
+ // Make the color of the icons extensible, primariliy for AMP use cases.
426
+ $icon_bg_color_filtered = apply_filters( 'addtoany_icons_bg_color', '#0166ff' );
427
  $button_class = '';
428
  $button_data_media = $args['is_kit'] || empty( $args['linkmedia'] ) ? '' : ' data-a2a-media="' . esc_attr( $args['linkmedia'] ) . '"';
429
  $button_data_title = $args['is_kit'] || empty( $args['linkname'] ) ? '' : ' data-a2a-title="' . esc_attr( $args['linkname'] ) . '"';
452
  $button_src = 'https://static.addtoany.com/buttons/a2a.svg';
453
  $button_width = ! empty( $args['icon_size'] ) ? ' width="' . $args['icon_size'] .'"' : ' width="32"';
454
  $button_height = ! empty( $args['icon_size'] ) ? ' height="' . $args['icon_size'] .'"' : ' height="32"';
455
+ $button_style = ! empty( $icon_bg_color_filtered ) ? ' style="background-color:' . esc_attr( $icon_bg_color_filtered ) . '"' : '';
456
  }
457
  }
458