AddToAny Share Buttons - Version 1.6.12

Version Description

  • Enable counters on floating share buttons when enabled for standard share buttons
  • Fix settings link for Multisite administrators (thanks Jan)
  • Simplify internal methods that automatically place standard share buttons
  • Automatic placement logic for WordPress excerpts has changed ("excerpt" usage & presentation varies widely among WordPress themes & plugins)
  • If needed, you can uncheck the "Display at the bottom of excerpts" placement option in AddToAny settings to disable button placement in a post's excerpt/snippet/intro
  • Add width & height fields for custom icons in the Advanced Options section
  • Update admin slug
Download this release

Release Info

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

Code changes from version 1.6.11 to 1.6.12

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: micropat, addtoany
3
  Tags: AddToAny, sharing, share, social, share button, share buttons, share links, 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, 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, lockerz, addthis, sociable, share this, sharethis, shareaholic, icon, icons, vector, SVG, floating, floating buttons, wpml, wpmu, Add to Any
4
  Requires at least: 2.8
5
  Tested up to: 4.4
6
- Stable tag: 1.6.11
7
 
8
  Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp, many more, and follow icons too.
9
 
@@ -296,6 +296,15 @@ Upload (or move) the `add-to-any` plugin directory into the `/wp-content/mu-plug
296
 
297
  == Changelog ==
298
 
 
 
 
 
 
 
 
 
 
299
  = 1.6.11 =
300
  * Update `[addtoany]` shortcode to accept specific share buttons
301
  * Specify [AddToAny service codes](https://www.addtoany.com/services/) in the `buttons` attribute like: `[addtoany buttons="facebook,twitter,google_plus"]`
@@ -1373,6 +1382,11 @@ Upload (or move) the `add-to-any` plugin directory into the `/wp-content/mu-plug
1373
 
1374
  == Upgrade Notice ==
1375
 
 
 
 
 
 
1376
  = 1.6.7 =
1377
  If you are using AddToAny as a "must-use" autoloaded plugin (in the `mu-plugins` directory), the old method of moving `add-to-any.php` into `mu-plugins` is no longer supported and will not work. See the plugin's last FAQ about using a proxy PHP loader file that autoloads AddToAny.
1378
 
3
  Tags: AddToAny, sharing, share, social, share button, share buttons, share links, 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, 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, lockerz, addthis, sociable, share this, sharethis, shareaholic, icon, icons, vector, SVG, floating, floating buttons, wpml, wpmu, Add to Any
4
  Requires at least: 2.8
5
  Tested up to: 4.4
6
+ Stable tag: 1.6.12
7
 
8
  Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp, many more, and follow icons too.
9
 
296
 
297
  == Changelog ==
298
 
299
+ = 1.6.12 =
300
+ * Enable counters on floating share buttons when enabled for standard share buttons
301
+ * Fix settings link for Multisite administrators (thanks Jan)
302
+ * Simplify internal methods that automatically place standard share buttons
303
+ * Automatic placement logic for [WordPress excerpts](https://codex.wordpress.org/Excerpt) has changed ("excerpt" usage & presentation varies widely among WordPress themes & plugins)
304
+ * If needed, you can uncheck the "Display at the bottom of excerpts" placement option in AddToAny settings to disable button placement in a post's excerpt/snippet/intro
305
+ * Add width & height fields for custom icons in the Advanced Options section
306
+ * Update admin slug
307
+
308
  = 1.6.11 =
309
  * Update `[addtoany]` shortcode to accept specific share buttons
310
  * Specify [AddToAny service codes](https://www.addtoany.com/services/) in the `buttons` attribute like: `[addtoany buttons="facebook,twitter,google_plus"]`
1382
 
1383
  == Upgrade Notice ==
1384
 
1385
+ = 1.6.12 =
1386
+ Automatic placement logic for [WordPress excerpts](https://codex.wordpress.org/Excerpt) has changed ("excerpt" usage & presentation varies widely among WordPress themes & plugins). If your theme displays buttons in a post's excerpt/snippet/intro after this plugin update, you can uncheck the "Display at the bottom of excerpts" placement option in AddToAny settings to remove those buttons.
1387
+
1388
+ Use custom icons? For improved layout and compatibility, specify the width & height of your icons in Settings > AddToAny > Advanced Options.
1389
+
1390
  = 1.6.7 =
1391
  If you are using AddToAny as a "must-use" autoloaded plugin (in the `mu-plugins` directory), the old method of moving `add-to-any.php` into `mu-plugins` is no longer supported and will not work. See the plugin's last FAQ about using a proxy PHP loader file that autoloads AddToAny.
1392
 
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. [<a href="options-general.php?page=add-to-any.php">Settings</a>]
6
- Version: 1.6.11
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, $A2A_SHARE_SAVE_auto_placement_ready,
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__ ) );
@@ -25,6 +25,9 @@ $A2A_locale = ! isset ( $A2A_locale ) ? '' : $A2A_locale;
25
  // Set plugin options
26
  $A2A_SHARE_SAVE_options = get_option( 'addtoany_options' );
27
 
 
 
 
28
  function A2A_SHARE_SAVE_init() {
29
  global $A2A_SHARE_SAVE_plugin_url_path,
30
  $A2A_SHARE_SAVE_plugin_basename,
@@ -36,12 +39,6 @@ function A2A_SHARE_SAVE_init() {
36
  }
37
 
38
  load_plugin_textdomain( 'add-to-any', false, $A2A_SHARE_SAVE_plugin_basename . '/languages/' );
39
-
40
- if ( ! isset( $A2A_SHARE_SAVE_options['display_in_excerpts'] ) || $A2A_SHARE_SAVE_options['display_in_excerpts'] != '-1' ) {
41
- // Excerpts use strip_tags() for the_content, so cancel if Excerpt and append to the_excerpt instead
42
- add_filter( 'get_the_excerpt', 'A2A_SHARE_SAVE_remove_from_content', 9 );
43
- add_filter( 'the_excerpt', 'A2A_SHARE_SAVE_add_to_content', 98 );
44
- }
45
  }
46
  add_filter( 'init', 'A2A_SHARE_SAVE_init' );
47
 
@@ -75,8 +72,6 @@ function A2A_SHARE_SAVE_link_vars( $linkname = false, $linkurl = false ) {
75
  return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc' );
76
  }
77
 
78
- include_once( $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php' );
79
-
80
  // Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
81
  function ADDTOANY_SHARE_SAVE_KIT( $args = false ) {
82
  global $_addtoany_counter;
@@ -94,10 +89,26 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = false ) {
94
 
95
  // Custom icons enabled?
96
  $custom_icons = ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) ? true : false;
 
 
 
97
 
98
- // Set a2a_kit_size_## class name unless "icon_size" is set to '16' or custom icons are enabled
 
 
 
 
 
 
99
  if ( $custom_icons ) {
100
- $icon_size = '';
 
 
 
 
 
 
 
101
  // a2a_kit_size_32 if no icon size, or no_small_icons arg is true
102
  } elseif ( ! isset( $options['icon_size'] ) || isset( $args['no_small_icons'] ) && true == $args['no_small_icons'] ) {
103
  $icon_size = ' a2a_kit_size_32';
@@ -105,17 +116,8 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = false ) {
105
  } elseif ( isset( $options['icon_size'] ) && $options['icon_size'] == '16' ) {
106
  $icon_size = '';
107
  // a2a_kit_size_## custom icon size
108
- } else {
109
- $icon_size = ' a2a_kit_size_' . $options['icon_size'] . '';
110
- }
111
-
112
- $kit_additional_classes = '';
113
- $kit_style = '';
114
-
115
- // Add additional classNames to .a2a_kit
116
- if ( isset( $args['kit_additional_classes'] ) ) {
117
- // Append space and className(s)
118
- $kit_additional_classes .= ' ' . $args['kit_additional_classes'];
119
  }
120
 
121
  // Add addtoany_list className unless disabled (for floating buttons)
@@ -201,6 +203,8 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
201
  // Custom icons expected at a specified URL, i.e. //example.com/blog/uploads/addtoany/icons/custom/
202
  $icons_dir = $options['custom_icons_url'];
203
  $icons_type = ( isset( $options['custom_icons_type'] ) ) ? $options['custom_icons_type'] : 'png';
 
 
204
  $custom_icons = true;
205
  } else {
206
  // Packaged 16px icons
@@ -285,7 +289,6 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
285
 
286
  // AddToAny counter enabled?
287
  $counter_enabled = ( ! $is_follow // Disable counters on Follow Kits
288
- && ! isset( $is_floating ) // Disable counters on floating buttons for now
289
  && in_array( $active_service, array( 'facebook', 'pinterest', 'linkedin', 'reddit' ) )
290
  && isset( $options['special_' . $active_service . '_options'] )
291
  && isset( $options['special_' . $active_service . '_options']['show_count'] )
@@ -305,8 +308,8 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
305
 
306
  // Remove dimension attributes if using custom icons
307
  if ( isset( $custom_icons ) ) {
308
- $width_attr = '';
309
- $height_attr = '';
310
  }
311
 
312
  $link = $html_wrap_open . "<a$class_attr href=\"$url\" title=\"$name\"$rel_nofollow target=\"_blank\">";
@@ -813,51 +816,44 @@ function A2A_SHARE_SAVE_footer_script() {
813
 
814
  add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
815
 
816
- function A2A_SHARE_SAVE_auto_placement( $title ) {
817
- global $A2A_SHARE_SAVE_auto_placement_ready;
818
- $A2A_SHARE_SAVE_auto_placement_ready = true;
819
-
820
- return $title;
821
- }
822
-
823
 
824
- /**
825
- * Remove the_content filter and add it for next time
826
- */
827
- function A2A_SHARE_SAVE_remove_from_content( $content ) {
828
- remove_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content', 98 );
829
- add_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content_next_time', 98 );
830
 
831
- return $content;
832
- }
 
 
 
833
 
834
- /**
835
- * Apply the_content filter "next time"
836
- */
837
- function A2A_SHARE_SAVE_add_to_content_next_time( $content ) {
838
- add_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content', 98 );
 
 
 
 
 
 
839
 
840
- return $content;
841
- }
842
-
843
-
844
- function A2A_SHARE_SAVE_add_to_content( $content ) {
845
- global $A2A_SHARE_SAVE_auto_placement_ready;
846
- $is_feed = is_feed();
847
- $options = get_option( 'addtoany_options' );
848
  $sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
849
  $sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
850
- $post_type = get_post_type( get_the_ID() );
851
 
852
- if ( ! $A2A_SHARE_SAVE_auto_placement_ready )
853
- return $content;
854
-
855
- if ( get_post_status( get_the_ID() ) == 'private' )
856
- return $content;
857
-
858
- // Disabled for this post?
859
- if ( ! empty( $sharing_disabled ) )
860
  return $content;
 
 
 
 
 
861
 
862
  if (
863
  (
@@ -877,6 +873,8 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
877
  ( is_archive() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
878
  // Search results posts (same as Archive page posts option)
879
  ( is_search() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
 
 
880
  // Posts in feed
881
  ( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
882
 
@@ -890,6 +888,7 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
890
  ( (strpos( $content, '<!--nosharesave-->') !== false ) )
891
  )
892
  ) {
 
893
  return $content;
894
  }
895
 
@@ -905,17 +904,17 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
905
  $html_header = '';
906
  }
907
 
908
- if ( ! $is_feed ) {
909
- $container_wrap_open = '<div class="addtoany_share_save_container %s">'; // Contains placeholder
910
- $container_wrap_open .= $html_header;
911
- $container_wrap_close = '</div>';
912
- } else { // Is feed
913
  $container_wrap_open = '<p>';
914
  $container_wrap_close = '</p>';
915
  $kit_args['html_container_open'] = '';
916
  $kit_args['html_container_close'] = '';
917
  $kit_args['html_wrap_open'] = '';
918
  $kit_args['html_wrap_close'] = '';
 
 
 
 
919
  }
920
 
921
  $options['position'] = isset( $options['position'] ) ? $options['position'] : 'bottom';
@@ -932,9 +931,8 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
932
  return $content;
933
  }
934
 
935
- // Only automatically output button code after the_title has been called - to avoid premature calling from misc. the_content filters (especially meta description)
936
- add_filter( 'the_title', 'A2A_SHARE_SAVE_auto_placement', 9 );
937
  add_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content', 98 );
 
938
 
939
 
940
  // [addtoany url="http://example.com/page.html" title="Some Example Page"]
@@ -1099,18 +1097,16 @@ if ( is_admin() ) {
1099
  }
1100
 
1101
  function A2A_SHARE_SAVE_add_menu_link() {
1102
- if ( current_user_can( 'manage_options' ) ) {
1103
- $page = add_options_page(
1104
- 'AddToAny: ' . __( "Share/Save", 'add-to-any' ) . " " . __( "Settings" )
1105
- , __( "AddToAny", 'add-to-any' )
1106
- , 'activate_plugins'
1107
- , basename( __FILE__ )
1108
- , 'A2A_SHARE_SAVE_options_page'
1109
- );
1110
-
1111
- /* Using registered $page handle to hook script load, to only load in AddToAny admin */
1112
- add_filter( 'admin_print_scripts-' . $page, 'A2A_SHARE_SAVE_scripts' );
1113
- }
1114
  }
1115
 
1116
  add_filter( 'admin_menu', 'A2A_SHARE_SAVE_add_menu_link' );
@@ -1135,7 +1131,7 @@ function A2A_SHARE_SAVE_actlinks( $links, $file ) {
1135
  }
1136
 
1137
  if ( $file == $this_plugin ) {
1138
- $settings_link = '<a href="options-general.php?page=add-to-any.php">' . __( 'Settings' ) . '</a>';
1139
  array_unshift( $links, $settings_link ); // before other links
1140
  }
1141
 
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. [<a href="options-general.php?page=addtoany">Settings</a>]
6
+ Version: 1.6.12
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 $_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__ ) );
25
  // Set plugin options
26
  $A2A_SHARE_SAVE_options = get_option( 'addtoany_options' );
27
 
28
+ include_once( $A2A_SHARE_SAVE_plugin_dir . '/addtoany.compat.php' );
29
+ include_once( $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php' );
30
+
31
  function A2A_SHARE_SAVE_init() {
32
  global $A2A_SHARE_SAVE_plugin_url_path,
33
  $A2A_SHARE_SAVE_plugin_basename,
39
  }
40
 
41
  load_plugin_textdomain( 'add-to-any', false, $A2A_SHARE_SAVE_plugin_basename . '/languages/' );
 
 
 
 
 
 
42
  }
43
  add_filter( 'init', 'A2A_SHARE_SAVE_init' );
44
 
72
  return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc' );
73
  }
74
 
 
 
75
  // Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
76
  function ADDTOANY_SHARE_SAVE_KIT( $args = false ) {
77
  global $_addtoany_counter;
89
 
90
  // Custom icons enabled?
91
  $custom_icons = ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) ? true : false;
92
+
93
+ $kit_additional_classes = '';
94
+ $kit_style = '';
95
 
96
+ // Add additional classNames to .a2a_kit
97
+ if ( isset( $args['kit_additional_classes'] ) ) {
98
+ // Append space and className(s)
99
+ $kit_additional_classes .= ' ' . $args['kit_additional_classes'];
100
+ }
101
+
102
+ // Set a2a_kit_size_## class name unless "icon_size" is set to '16'
103
  if ( $custom_icons ) {
104
+ // If vertical style (.a2a_vertical_style)
105
+ if ( strpos( $kit_additional_classes, 'a2a_vertical_style' ) !== false ) {
106
+ // Use width (if specified) for .a2a_kit_size_## class name to size default service counters
107
+ $icon_size = isset( $options['custom_icons_width'] ) ? ' a2a_kit_size_' . $options['custom_icons_width'] : '';
108
+ } else {
109
+ // Use height (if specified) for .a2a_kit_size_## class name to size default service counters
110
+ $icon_size = isset( $options['custom_icons_height'] ) ? ' a2a_kit_size_' . $options['custom_icons_height'] : '';
111
+ }
112
  // a2a_kit_size_32 if no icon size, or no_small_icons arg is true
113
  } elseif ( ! isset( $options['icon_size'] ) || isset( $args['no_small_icons'] ) && true == $args['no_small_icons'] ) {
114
  $icon_size = ' a2a_kit_size_32';
116
  } elseif ( isset( $options['icon_size'] ) && $options['icon_size'] == '16' ) {
117
  $icon_size = '';
118
  // a2a_kit_size_## custom icon size
119
+ } elseif ( isset( $options['icon_size'] ) ) {
120
+ $icon_size = ' a2a_kit_size_' . $options['icon_size'];
 
 
 
 
 
 
 
 
 
121
  }
122
 
123
  // Add addtoany_list className unless disabled (for floating buttons)
203
  // Custom icons expected at a specified URL, i.e. //example.com/blog/uploads/addtoany/icons/custom/
204
  $icons_dir = $options['custom_icons_url'];
205
  $icons_type = ( isset( $options['custom_icons_type'] ) ) ? $options['custom_icons_type'] : 'png';
206
+ $icons_width = ( isset( $options['custom_icons_width'] ) ) ? $options['custom_icons_width'] : '';
207
+ $icons_height = ( isset( $options['custom_icons_height'] ) ) ? $options['custom_icons_height'] : '';
208
  $custom_icons = true;
209
  } else {
210
  // Packaged 16px icons
289
 
290
  // AddToAny counter enabled?
291
  $counter_enabled = ( ! $is_follow // Disable counters on Follow Kits
 
292
  && in_array( $active_service, array( 'facebook', 'pinterest', 'linkedin', 'reddit' ) )
293
  && isset( $options['special_' . $active_service . '_options'] )
294
  && isset( $options['special_' . $active_service . '_options']['show_count'] )
308
 
309
  // Remove dimension attributes if using custom icons
310
  if ( isset( $custom_icons ) ) {
311
+ $width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
312
+ $height_attr = ! empty( $icons_height ) ? ' height="' . $icons_height . '"' : '';
313
  }
314
 
315
  $link = $html_wrap_open . "<a$class_attr href=\"$url\" title=\"$name\"$rel_nofollow target=\"_blank\">";
816
 
817
  add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
818
 
 
 
 
 
 
 
 
819
 
820
+ function A2A_SHARE_SAVE_add_to_content( $content ) {
821
+ global $wp_current_filter;
 
 
 
 
822
 
823
+ // Don't add to get_the_excerpt because it's too early and strips tags (adding to the_excerpt is allowed)
824
+ if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
825
+ // Return early
826
+ return $content;
827
+ }
828
 
829
+ // Don't add to the_content more than once
830
+ $done = false;
831
+ foreach ( $wp_current_filter as $filter ) {
832
+ if ( 'the_content' == $filter ) {
833
+ if ( $done ) {
834
+ return $content;
835
+ } else {
836
+ $done = true;
837
+ }
838
+ }
839
+ }
840
 
 
 
 
 
 
 
 
 
841
  $sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
842
  $sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
 
843
 
844
+ if (
845
+ // Private post
846
+ get_post_status( get_the_ID() ) == 'private' ||
847
+ // Sharing disabled on post
848
+ ! empty( $sharing_disabled )
849
+ ) {
850
+ // Return early
 
851
  return $content;
852
+ }
853
+
854
+ $is_feed = is_feed();
855
+ $options = get_option( 'addtoany_options' );
856
+ $post_type = get_post_type( get_the_ID() );
857
 
858
  if (
859
  (
873
  ( is_archive() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
874
  // Search results posts (same as Archive page posts option)
875
  ( is_search() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
876
+ // Excerpt (the_excerpt is the current filter)
877
+ ( 'the_excerpt' == current_filter() && isset( $options['display_in_excerpts'] ) && $options['display_in_excerpts'] == '-1' ) ||
878
  // Posts in feed
879
  ( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
880
 
888
  ( (strpos( $content, '<!--nosharesave-->') !== false ) )
889
  )
890
  ) {
891
+ // Return early
892
  return $content;
893
  }
894
 
904
  $html_header = '';
905
  }
906
 
907
+ if ( $is_feed ) {
 
 
 
 
908
  $container_wrap_open = '<p>';
909
  $container_wrap_close = '</p>';
910
  $kit_args['html_container_open'] = '';
911
  $kit_args['html_container_close'] = '';
912
  $kit_args['html_wrap_open'] = '';
913
  $kit_args['html_wrap_close'] = '';
914
+ } else {
915
+ $container_wrap_open = '<div class="addtoany_share_save_container %s">'; // Contains placeholder
916
+ $container_wrap_open .= $html_header;
917
+ $container_wrap_close = '</div>';
918
  }
919
 
920
  $options['position'] = isset( $options['position'] ) ? $options['position'] : 'bottom';
931
  return $content;
932
  }
933
 
 
 
934
  add_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content', 98 );
935
+ add_filter( 'the_excerpt', 'A2A_SHARE_SAVE_add_to_content', 98 );
936
 
937
 
938
  // [addtoany url="http://example.com/page.html" title="Some Example Page"]
1097
  }
1098
 
1099
  function A2A_SHARE_SAVE_add_menu_link() {
1100
+ $page = add_options_page(
1101
+ __( 'AddToAny Share Settings', 'add-to-any' ),
1102
+ __( 'AddToAny', 'add-to-any' ),
1103
+ 'manage_options',
1104
+ 'addtoany',
1105
+ 'A2A_SHARE_SAVE_options_page'
1106
+ );
1107
+
1108
+ /* Using registered $page handle to hook script load, to only load in AddToAny admin */
1109
+ add_filter( 'admin_print_scripts-' . $page, 'A2A_SHARE_SAVE_scripts' );
 
 
1110
  }
1111
 
1112
  add_filter( 'admin_menu', 'A2A_SHARE_SAVE_add_menu_link' );
1131
  }
1132
 
1133
  if ( $file == $this_plugin ) {
1134
+ $settings_link = '<a href="options-general.php?page=addtoany">' . __( 'Settings' ) . '</a>';
1135
  array_unshift( $links, $settings_link ); // before other links
1136
  }
1137
 
addtoany.admin.php CHANGED
@@ -269,6 +269,8 @@ function A2A_SHARE_SAVE_options_page() {
269
  $new_options['custom_icons'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons'] ) && $_POST['A2A_SHARE_SAVE_custom_icons'] == 'url' ) ? 'url' : '-1';
270
  $new_options['custom_icons_url'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_url'] ) ) ? trailingslashit( $_POST['A2A_SHARE_SAVE_custom_icons_url'] ) : '';
271
  $new_options['custom_icons_type'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_type'] ) ) ? $_POST['A2A_SHARE_SAVE_custom_icons_type'] : 'png';
 
 
272
  $new_options['inline_css'] = ( isset( $_POST['A2A_SHARE_SAVE_inline_css'] ) && $_POST['A2A_SHARE_SAVE_inline_css'] == '1') ? '1' : '-1';
273
  $new_options['cache'] = ( isset( $_POST['A2A_SHARE_SAVE_cache'] ) && $_POST['A2A_SHARE_SAVE_cache'] == '1' ) ? '1' : '-1';
274
 
@@ -402,8 +404,8 @@ function A2A_SHARE_SAVE_options_page() {
402
  <h1><?php _e( 'AddToAny Share Settings', 'add-to-any' ); ?></h1>
403
 
404
  <h2 class="nav-tab-wrapper">
405
- <a href="<?php echo admin_url( 'options-general.php?page=add-to-any.php' ); ?>" class="nav-tab<?php if ( 'default' == $current_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Standard' ); ?></a>
406
- <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'floating' ), admin_url( 'options-general.php?page=add-to-any.php' ) ) ); ?>" class="nav-tab<?php if ( 'floating' == $current_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Floating' ); ?></a>
407
  </h2>
408
 
409
  <form id="addtoany_admin_form" method="post" action="">
@@ -607,7 +609,7 @@ function A2A_SHARE_SAVE_options_page() {
607
 
608
  <br/><br/>
609
  <div class="setting-description">
610
- <?php _e("See <a href=\"widgets.php\" title=\"Theme Widgets\">Widgets</a> and <a href=\"options-general.php?page=add-to-any.php&action=floating\" title=\"AddToAny Floating Share Buttons\">Floating</a> for additional placement options. For advanced placement, see <a href=\"http://wordpress.org/plugins/add-to-any/faq/\">the FAQs</a>.", 'add-to-any'); ?>
611
  </div>
612
  </fieldset></td>
613
  </tr>
@@ -670,7 +672,13 @@ function A2A_SHARE_SAVE_options_page() {
670
  <?php _e('Use custom icons. URL:', 'add-to-any'); ?>
671
  </label>
672
  <input name="A2A_SHARE_SAVE_custom_icons_url" type="text" class="code" size="50" style="vertical-align:middle" placeholder="//example.com/blog/uploads/addtoany/icons/custom/" value="<?php if ( isset( $options['custom_icons_url'] ) ) echo $options['custom_icons_url']; ?>" />
673
- <input name="A2A_SHARE_SAVE_custom_icons_type" type="text" class="code" size="5" style="vertical-align:middle" maxlength="4" placeholder="png" value="<?php if ( isset( $options['custom_icons_type'] ) ) echo $options['custom_icons_type']; else echo 'png'; ?>" title="<?php esc_attr_e("Filename extension", 'add-to-any'); ?>" />
 
 
 
 
 
 
674
  <p class="description">
675
  <?php _e("Specify the URL of the directory containing your custom icons. For example, a URL of <code>//example.com/blog/uploads/addtoany/icons/custom/</code> containing <code>facebook.png</code> and <code>twitter.png</code>. Be sure that custom icon filenames match the icon filenames in <code>plugins/add-to-any/icons</code>. For AddToAny's Universal Button, select Image URL and specify the URL of your AddToAny universal share icon (<a href=\"#\" onclick=\"document.getElementsByName('A2A_SHARE_SAVE_button_custom')[0].focus();return false\">above</a>).", 'add-to-any'); ?>
676
  </p>
@@ -802,7 +810,7 @@ function A2A_SHARE_SAVE_options_page() {
802
 
803
  // Admin page header
804
  function A2A_SHARE_SAVE_admin_head() {
805
- if ( isset( $_GET['page'] ) && $_GET['page'] == 'add-to-any.php' ) {
806
 
807
  $options = get_option( 'addtoany_options' );
808
 
269
  $new_options['custom_icons'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons'] ) && $_POST['A2A_SHARE_SAVE_custom_icons'] == 'url' ) ? 'url' : '-1';
270
  $new_options['custom_icons_url'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_url'] ) ) ? trailingslashit( $_POST['A2A_SHARE_SAVE_custom_icons_url'] ) : '';
271
  $new_options['custom_icons_type'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_type'] ) ) ? $_POST['A2A_SHARE_SAVE_custom_icons_type'] : 'png';
272
+ $new_options['custom_icons_width'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_width'] ) ) ? $_POST['A2A_SHARE_SAVE_custom_icons_width'] : '';
273
+ $new_options['custom_icons_height'] = ( isset( $_POST['A2A_SHARE_SAVE_custom_icons_height'] ) ) ? $_POST['A2A_SHARE_SAVE_custom_icons_height'] : '';
274
  $new_options['inline_css'] = ( isset( $_POST['A2A_SHARE_SAVE_inline_css'] ) && $_POST['A2A_SHARE_SAVE_inline_css'] == '1') ? '1' : '-1';
275
  $new_options['cache'] = ( isset( $_POST['A2A_SHARE_SAVE_cache'] ) && $_POST['A2A_SHARE_SAVE_cache'] == '1' ) ? '1' : '-1';
276
 
404
  <h1><?php _e( 'AddToAny Share Settings', 'add-to-any' ); ?></h1>
405
 
406
  <h2 class="nav-tab-wrapper">
407
+ <a href="<?php echo admin_url( 'options-general.php?page=addtoany' ); ?>" class="nav-tab<?php if ( 'default' == $current_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Standard' ); ?></a>
408
+ <a href="<?php echo esc_url( add_query_arg( array( 'action' => 'floating' ), admin_url( 'options-general.php?page=addtoany' ) ) ); ?>" class="nav-tab<?php if ( 'floating' == $current_screen ) echo ' nav-tab-active'; ?>"><?php esc_html_e( 'Floating' ); ?></a>
409
  </h2>
410
 
411
  <form id="addtoany_admin_form" method="post" action="">
609
 
610
  <br/><br/>
611
  <div class="setting-description">
612
+ <?php _e("See <a href=\"widgets.php\" title=\"Theme Widgets\">Widgets</a> and <a href=\"options-general.php?page=addtoany&action=floating\" title=\"AddToAny Floating Share Buttons\">Floating</a> for additional placement options. For advanced placement, see <a href=\"http://wordpress.org/plugins/add-to-any/faq/\">the FAQs</a>.", 'add-to-any'); ?>
613
  </div>
614
  </fieldset></td>
615
  </tr>
672
  <?php _e('Use custom icons. URL:', 'add-to-any'); ?>
673
  </label>
674
  <input name="A2A_SHARE_SAVE_custom_icons_url" type="text" class="code" size="50" style="vertical-align:middle" placeholder="//example.com/blog/uploads/addtoany/icons/custom/" value="<?php if ( isset( $options['custom_icons_url'] ) ) echo $options['custom_icons_url']; ?>" />
675
+ <br/>
676
+ <label for="A2A_SHARE_SAVE_custom_icons_type"><?php _e('Filename extension', 'add-to-any'); ?></label>
677
+ <input name="A2A_SHARE_SAVE_custom_icons_type" type="text" class="code" size="5" maxlength="4" placeholder="png" value="<?php if ( isset( $options['custom_icons_type'] ) ) echo $options['custom_icons_type']; else echo 'png'; ?>" />
678
+ <label for="A2A_SHARE_SAVE_custom_icons_width"><?php _e('Width'); ?></label>
679
+ <input name="A2A_SHARE_SAVE_custom_icons_width" type="number" step="1" min="0" id="A2A_SHARE_SAVE_custom_icons_width" value="<?php if ( isset( $options['custom_icons_width'] ) ) echo $options['custom_icons_width']; ?>" class="small-text" />
680
+ <label for="A2A_SHARE_SAVE_custom_icons_height"><?php _e('Height'); ?></label>
681
+ <input name="A2A_SHARE_SAVE_custom_icons_height" type="number" step="1" min="0" id="A2A_SHARE_SAVE_custom_icons_height" value="<?php if ( isset( $options['custom_icons_height'] ) ) echo $options['custom_icons_height']; ?>" class="small-text" />
682
  <p class="description">
683
  <?php _e("Specify the URL of the directory containing your custom icons. For example, a URL of <code>//example.com/blog/uploads/addtoany/icons/custom/</code> containing <code>facebook.png</code> and <code>twitter.png</code>. Be sure that custom icon filenames match the icon filenames in <code>plugins/add-to-any/icons</code>. For AddToAny's Universal Button, select Image URL and specify the URL of your AddToAny universal share icon (<a href=\"#\" onclick=\"document.getElementsByName('A2A_SHARE_SAVE_button_custom')[0].focus();return false\">above</a>).", 'add-to-any'); ?>
684
  </p>
810
 
811
  // Admin page header
812
  function A2A_SHARE_SAVE_admin_head() {
813
+ if ( isset( $_GET['page'] ) && $_GET['page'] == 'addtoany' ) {
814
 
815
  $options = get_option( 'addtoany_options' );
816
 
addtoany.compat.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Load theme compatibility functions
5
+ */
6
+ function addtoany_load_theme_compat() {
7
+ add_action( 'loop_start', 'addtoany_excerpt_remove' );
8
+ }
9
+
10
+ add_action( 'after_setup_theme', 'addtoany_load_theme_compat', -1 );
11
+
12
+ /**
13
+ * Remove from excerpts where buttons could be redundant or awkward
14
+ */
15
+ function addtoany_excerpt_remove() {
16
+ // If Twenty Sixteen theme
17
+ if ( 'twentysixteen' == get_stylesheet() || 'twentysixteen' == get_template() ) {
18
+ // If blog index, single, or archive page, where excerpts are used as "intros"
19
+ if ( is_single() || is_archive() || is_home() ) {
20
+ remove_filter( 'the_excerpt', 'A2A_SHARE_SAVE_add_to_content', 98 );
21
+ }
22
+ }
23
+ }
addtoany.widgets.php CHANGED
@@ -76,7 +76,7 @@ class A2A_SHARE_SAVE_Widget extends WP_Widget {
76
  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
77
  </p>
78
  <p>
79
- <a href="options-general.php?page=add-to-any.php"><?php _e('AddToAny Settings', 'add-to-any'); ?>...</a>
80
  </p>
81
  <?php
82
  }
@@ -186,7 +186,7 @@ class A2A_Follow_Widget extends WP_Widget {
186
  </p>
187
  <?php endforeach; ?>
188
  <p>
189
- <a href="options-general.php?page=add-to-any.php"><?php _e('AddToAny Settings', 'add-to-any'); ?>...</a>
190
  </p>
191
  <?php
192
  }
76
  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
77
  </p>
78
  <p>
79
+ <a href="options-general.php?page=addtoany"><?php _e('AddToAny Settings', 'add-to-any'); ?>...</a>
80
  </p>
81
  <?php
82
  }
186
  </p>
187
  <?php endforeach; ?>
188
  <p>
189
+ <a href="options-general.php?page=addtoany"><?php _e('AddToAny Settings', 'add-to-any'); ?>...</a>
190
  </p>
191
  <?php
192
  }
icons/facebook.png CHANGED
Binary file