Version Description
- Require PHP 5.3 as a bare minimum for compatibility features
Download this release
Release Info
Developer | micropat |
Plugin | AddToAny Share Buttons |
Version | 1.7.40 |
Comparing to | |
See all releases |
Code changes from version 1.7.39 to 1.7.40
- README.txt +5 -2
- add-to-any.php +153 -145
- addtoany.compat.php +13 -13
- addtoany.update.php +2 -2
- addtoany.widgets.php +7 -7
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 |
Requires PHP: 5.6
|
7 |
-
Stable tag: 1.7.
|
8 |
|
9 |
Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, WhatsApp, Pinterest, Reddit, many more, and follow icons too.
|
10 |
|
@@ -346,6 +346,9 @@ Upload (or move) the `add-to-any` plugin directory into the `/wp-content/mu-plug
|
|
346 |
|
347 |
== Changelog ==
|
348 |
|
|
|
|
|
|
|
349 |
= 1.7.39 =
|
350 |
* Fix AMP version of the AddToAny universal icon
|
351 |
* Enable the `addtoany_content_priority` filter hook to modify the priority of standard placement in content
|
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.4
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 1.7.40
|
8 |
|
9 |
Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, WhatsApp, Pinterest, Reddit, many more, and follow icons too.
|
10 |
|
346 |
|
347 |
== Changelog ==
|
348 |
|
349 |
+
= 1.7.40 =
|
350 |
+
* Require PHP 5.3 as a bare minimum for compatibility features
|
351 |
+
|
352 |
= 1.7.39 =
|
353 |
* Fix AMP version of the AddToAny universal icon
|
354 |
* Enable the `addtoany_content_priority` filter hook to modify the priority of standard placement in content
|
add-to-any.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
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.
|
7 |
-
Author: AddToAny
|
8 |
-
Author URI: https://www.addtoany.com/
|
9 |
-
Text Domain: add-to-any
|
10 |
-
Domain Path: /languages
|
11 |
-
*/
|
12 |
-
|
13 |
-
// Explicitly globalize to support bootstrapped WordPress
|
14 |
global $A2A_locale, $A2A_FOLLOW_services,
|
15 |
$A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url,
|
16 |
$A2A_SHARE_SAVE_services;
|
@@ -18,22 +18,26 @@ global $A2A_locale, $A2A_FOLLOW_services,
|
|
18 |
$A2A_SHARE_SAVE_plugin_dir = untrailingslashit( plugin_dir_path( __FILE__ ) );
|
19 |
$A2A_SHARE_SAVE_plugin_url = untrailingslashit( plugin_dir_url( __FILE__ ) );
|
20 |
|
21 |
-
// Set AddToAny locale (JavaScript)
|
22 |
$A2A_locale = ! isset ( $A2A_locale ) ? '' : $A2A_locale;
|
23 |
-
// Set plugin options
|
24 |
$A2A_SHARE_SAVE_options = get_option( 'addtoany_options', array() );
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php';
|
28 |
|
29 |
function A2A_SHARE_SAVE_init() {
|
30 |
global $A2A_SHARE_SAVE_plugin_dir,
|
31 |
$A2A_SHARE_SAVE_options;
|
32 |
|
33 |
-
// Load the textdomain for translations
|
34 |
load_plugin_textdomain( 'add-to-any', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
|
35 |
|
36 |
-
// Update plugin options
|
37 |
$options = $A2A_SHARE_SAVE_options;
|
38 |
$old_buttons = array(
|
39 |
'share_save_256_24.gif|256|24', 'share_save_171_16.gif|171|16', 'share_save_120_16.gif|120|16',
|
@@ -41,7 +45,7 @@ function A2A_SHARE_SAVE_init() {
|
|
41 |
'share_16_16.png|16|16', 'favicon.png|16|16',
|
42 |
);
|
43 |
|
44 |
-
// If old button enabled
|
45 |
if ( ! empty( $options['button'] ) && in_array( $options['button'], $old_buttons ) ) {
|
46 |
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.update.php';
|
47 |
addtoany_update_options();
|
@@ -57,7 +61,7 @@ function A2A_SHARE_SAVE_link_vars( $args = array() ) {
|
|
57 |
$linkmedia = empty( $args['linkmedia'] ) ? '' : $args['linkmedia'];
|
58 |
$use_current_page = isset( $args['use_current_page'] ) ? $args['use_current_page'] : false;
|
59 |
|
60 |
-
// Set linkname if needed, and not a Follow kit
|
61 |
if ( ! $linkname && empty( $args['is_follow'] ) ) {
|
62 |
if ( $use_current_page ) {
|
63 |
$linkname = is_home() || is_front_page() ? get_bloginfo( 'name' ) : rtrim( wp_title( '', false, 'right' ) );
|
@@ -70,7 +74,7 @@ function A2A_SHARE_SAVE_link_vars( $args = array() ) {
|
|
70 |
|
71 |
$linkname_enc = rawurlencode( $linkname );
|
72 |
|
73 |
-
// Set linkurl if needed, and not a Follow kit
|
74 |
if ( ! $linkurl && empty( $args['is_follow'] ) ) {
|
75 |
if ( $use_current_page ) {
|
76 |
$linkurl = esc_url_raw( home_url( $_SERVER['REQUEST_URI'] ) );
|
@@ -83,13 +87,13 @@ function A2A_SHARE_SAVE_link_vars( $args = array() ) {
|
|
83 |
|
84 |
$linkurl_enc = rawurlencode( $linkurl );
|
85 |
|
86 |
-
// Set linkmedia (only applies to services that explicitly accept media; Pinterest does, most do not)
|
87 |
$linkmedia_enc = ! empty( $args['linkmedia'] ) ? rawurlencode( $args['linkmedia'] ) : '';
|
88 |
|
89 |
return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc', 'linkmedia', 'linkmedia_enc', 'use_current_page' );
|
90 |
}
|
91 |
|
92 |
-
// Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
|
93 |
function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
94 |
$options = get_option( 'addtoany_options', array() );
|
95 |
|
@@ -103,10 +107,10 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
|
103 |
|
104 |
$args = wp_parse_args( $args, $defaults );
|
105 |
|
106 |
-
// If universal button disabled, and not manually disabled through args
|
107 |
if ( isset( $options['button'] ) && $options['button'] == 'NONE' && ! isset( $args['no_universal_button'] ) ) {
|
108 |
-
// Pass this setting on to ADDTOANY_SHARE_SAVE_BUTTON
|
109 |
-
//
|
110 |
$args['no_universal_button'] = true;
|
111 |
}
|
112 |
|
@@ -120,33 +124,33 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
|
120 |
$kit_data_scroll_show = empty( $args['scroll_show'] ) ? '' : ' data-a2a-scroll-show="' . esc_attr( $args['scroll_show'] ) . '"';
|
121 |
$kit_style = '';
|
122 |
|
123 |
-
// Add additional classNames to .a2a_kit
|
124 |
if ( ! empty( $args['kit_additional_classes'] ) ) {
|
125 |
-
// Append space and className(s)
|
126 |
$kit_additional_classes .= ' ' . $args['kit_additional_classes'];
|
127 |
}
|
128 |
|
129 |
-
// Set a2a_kit_size_## class name
|
130 |
if ( $custom_icons ) {
|
131 |
// If vertical style (.a2a_vertical_style)
|
132 |
if ( strpos( $kit_additional_classes, 'a2a_vertical_style' ) !== false ) {
|
133 |
-
// Use width (if specified) for .a2a_kit_size_## class name to size default service counters
|
134 |
$icon_size_classname = isset( $options['custom_icons_width'] ) ? ' a2a_kit_size_' . $options['custom_icons_width'] : '';
|
135 |
} else {
|
136 |
-
// Use height (if specified) for .a2a_kit_size_## class name to size default service counters
|
137 |
$icon_size_classname = isset( $options['custom_icons_height'] ) ? ' a2a_kit_size_' . $options['custom_icons_height'] : '';
|
138 |
}
|
139 |
-
// a2a_kit_size_## icon size
|
140 |
} else {
|
141 |
$icon_size_classname = ' a2a_kit_size_' . $args['icon_size'];
|
142 |
}
|
143 |
|
144 |
-
// Add addtoany_list className unless disabled (for floating buttons)
|
145 |
if ( ! isset( $args['no_addtoany_list_classname'] ) ) {
|
146 |
$kit_additional_classes .= ' addtoany_list';
|
147 |
}
|
148 |
|
149 |
-
// Add style attribute if set
|
150 |
if ( ! empty( $args['kit_style'] ) ) {
|
151 |
$kit_style = ' style="' . esc_attr( $args['kit_style'] ) . '"';
|
152 |
}
|
@@ -158,9 +162,11 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
|
158 |
}
|
159 |
if ( ! isset( $args['html_container_close'] ) )
|
160 |
$args['html_container_close'] = "</div>";
|
161 |
-
// Close container element in ADDTOANY_SHARE_SAVE_BUTTON, not prematurely in ADDTOANY_SHARE_SAVE_ICONS
|
162 |
-
|
163 |
-
|
|
|
|
|
164 |
|
165 |
if ( ! isset( $args['html_wrap_open'] ) )
|
166 |
$args['html_wrap_open'] = "";
|
@@ -169,8 +175,10 @@ function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
|
169 |
|
170 |
$kit_html = ADDTOANY_SHARE_SAVE_ICONS( $args );
|
171 |
|
172 |
-
|
173 |
-
|
|
|
|
|
174 |
|
175 |
$kit_html .= ADDTOANY_SHARE_SAVE_BUTTON( $args );
|
176 |
|
@@ -213,7 +221,7 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
|
|
213 |
|
214 |
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
|
215 |
|
216 |
-
//
|
217 |
$large_icons = $is_amp ? false : true;
|
218 |
|
219 |
// Directory of either custom icons or the packaged icons
|
@@ -225,7 +233,7 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
|
|
225 |
$icons_height = ( isset( $options['custom_icons_height'] ) ) ? $options['custom_icons_height'] : '';
|
226 |
$custom_icons = true;
|
227 |
} else {
|
228 |
-
// Default to local SVGs
|
229 |
$icons_dir = plugins_url('/icons/', __FILE__ );
|
230 |
$icons_type = 'svg';
|
231 |
}
|
@@ -244,14 +252,14 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
|
|
244 |
$services = apply_filters( 'A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services );
|
245 |
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
|
246 |
|
247 |
-
// Include Facebook Like and Twitter Tweet etc. unless no_special_services arg is true
|
248 |
if ( ! isset( $args['no_special_services'] ) || false == $args['no_special_services'] ) {
|
249 |
array_unshift( $service_codes, 'facebook_like', 'twitter_tweet', 'pinterest_pin' );
|
250 |
}
|
251 |
|
252 |
-
// Use default services if services have not been selected yet
|
253 |
$active_services = isset( $options['active_services'] ) ? $options['active_services'] : array( 'facebook', 'twitter', 'email' );
|
254 |
-
// Services set by "buttons" arg? Then use "buttons" arg instead
|
255 |
$active_services = empty( $args['buttons'] ) ? $active_services : $args['buttons'];
|
256 |
}
|
257 |
|
@@ -280,19 +288,19 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
|
|
280 |
|
281 |
// If it's a URL instead of a service ID
|
282 |
if ( $is_url ) {
|
283 |
-
// Just use the given URL instead of the URL template
|
284 |
$href = $follow_id;
|
285 |
} else {
|
286 |
-
// Replace the ID placeholder in the URL template
|
287 |
$href = str_replace( '${id}', $follow_id, $service['href'] );
|
288 |
}
|
289 |
$href = ( 'feed' == $code_name ) ? $follow_id : $href;
|
290 |
|
291 |
-
// If icon_url is set, presume custom service
|
292 |
if ( isset( $service['icon_url'] ) ) {
|
293 |
$custom_service = true;
|
294 |
}
|
295 |
-
// Else if Share Kit and HREF specified, presume custom service
|
296 |
} elseif ( isset( $service['href'] ) ) {
|
297 |
$custom_service = true;
|
298 |
$href = $service['href'];
|
@@ -341,13 +349,13 @@ function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
|
|
341 |
$target_attr = '';
|
342 |
}
|
343 |
|
344 |
-
// Use rel="noopener" for links that open in a new tab/window
|
345 |
$rel_noopener = $custom_service || ! $target_attr ? '' : ' noopener';
|
346 |
$rel_noopener_only = $rel_noopener || $target_attr ? ' rel="noopener"' : '';
|
347 |
$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)
|
348 |
$rel_attr = $args['basic_html'] ? '' : $rel_attr;
|
349 |
|
350 |
-
// Set dimension attributes if using custom icons and dimension is specified
|
351 |
if ( isset( $custom_icons ) ) {
|
352 |
$width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
|
353 |
$height_attr = ! empty( $icons_height ) ? ' height="' . $icons_height . '"' : '';
|
@@ -412,20 +420,20 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
|
|
412 |
if ( ! $args['no_universal_button'] ) {
|
413 |
|
414 |
if ( isset( $options['button'] ) && 'CUSTOM' == $options['button'] ) {
|
415 |
-
// Custom button
|
416 |
$button_src = $options['button_custom'];
|
417 |
$button_width = '';
|
418 |
$button_height = '';
|
419 |
$button_style = '';
|
420 |
} else if ( isset( $options['button'] ) && 'TEXT' == $options['button'] ) {
|
421 |
-
// Text-only button
|
422 |
$button_text = stripslashes( $options[ 'button_text'] );
|
423 |
-
// Do not display universal icon
|
424 |
$button_class .= ' addtoany_no_icon';
|
425 |
} else {
|
426 |
-
// Default AddToAny button
|
427 |
if ( $is_amp ) {
|
428 |
-
// AMP (Accelerated Mobile Page)
|
429 |
$button_src = 'https://static.addtoany.com/buttons/a2a.svg';
|
430 |
$button_width = ! empty( $args['icon_size'] ) ? ' width="' . $args['icon_size'] .'"' : ' width="32"';
|
431 |
$button_height = ! empty( $args['icon_size'] ) ? ' height="' . $args['icon_size'] .'"' : ' height="32"';
|
@@ -443,7 +451,7 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
|
|
443 |
$button = '';
|
444 |
}
|
445 |
|
446 |
-
// Add additional classNames to .a2a_dd
|
447 |
$button_additional_classes = ! empty( $args['button_additional_classes'] ) ? ' ' . $args['button_additional_classes'] : '';
|
448 |
|
449 |
if ( isset( $options['button_show_count'] ) && $options['button_show_count'] == '1' ) {
|
@@ -456,11 +464,11 @@ function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
|
|
456 |
. '>' . $button . '</a>';
|
457 |
|
458 |
} else {
|
459 |
-
// Universal button disabled
|
460 |
$button_html = '';
|
461 |
}
|
462 |
|
463 |
-
// Closing tags come after <script> to validate in case the container is a list element
|
464 |
$button_html .= $args['html_wrap_close'] . $args['html_container_close'];
|
465 |
|
466 |
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
|
@@ -549,7 +557,7 @@ if ( ! function_exists( 'A2A_menu_locale' ) ) {
|
|
549 |
function ADDTOANY_FOLLOW_KIT( $args = array() ) {
|
550 |
$options = get_option( 'addtoany_options', array() );
|
551 |
|
552 |
-
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT
|
553 |
$defaults = array(
|
554 |
'buttons' => array(),
|
555 |
'linkname' => '',
|
@@ -570,10 +578,10 @@ function ADDTOANY_FOLLOW_KIT( $args = array() ) {
|
|
570 |
|
571 |
$args = wp_parse_args( $args, $defaults );
|
572 |
|
573 |
-
// Add a2a_follow className to Kit classes
|
574 |
$args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_follow' );
|
575 |
|
576 |
-
// If $args['buttons']['feed']['id'] is set
|
577 |
$buttons = $args['buttons'];
|
578 |
if ( ! empty( $buttons['feed'] ) && ! empty( $buttons['feed']['id'] ) ) {
|
579 |
$args['linkurl'] = $buttons['feed']['id'];
|
@@ -593,7 +601,7 @@ function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
|
593 |
|
594 |
$floating_html = '';
|
595 |
|
596 |
-
// Overridable by args below
|
597 |
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical']
|
598 |
&& ! in_array( $options['floating_vertical'], array( 'left_attached', 'right_attached' ) )
|
599 |
) ? $options['floating_vertical'] : false;
|
@@ -605,13 +613,13 @@ function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
|
605 |
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
606 |
|
607 |
if ( ! empty( $sharing_disabled ) ) {
|
608 |
-
// Overridable by args below
|
609 |
$vertical_type = false;
|
610 |
$horizontal_type = false;
|
611 |
}
|
612 |
}
|
613 |
|
614 |
-
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT
|
615 |
$defaults = array(
|
616 |
'linkname' => '',
|
617 |
'linkurl' => '',
|
@@ -629,7 +637,7 @@ function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
|
629 |
|
630 |
$args = wp_parse_args( $args, $defaults );
|
631 |
|
632 |
-
// Individual floating type args can override saved options
|
633 |
if ( isset( $args['vertical_type'] ) && $args['vertical_type'] === true ) {
|
634 |
$vertical_type = true;
|
635 |
}
|
@@ -637,46 +645,46 @@ function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
|
637 |
$horizontal_type = true;
|
638 |
}
|
639 |
|
640 |
-
// If either floating type is enabled
|
641 |
-
//
|
642 |
if ( $vertical_type || $horizontal_type ) {
|
643 |
// Vertical type?
|
644 |
if ( $vertical_type ) {
|
645 |
-
// Prevent overwriting of $args
|
646 |
$vertical_args = $args;
|
647 |
|
648 |
-
// Top position
|
649 |
$position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
|
650 |
-
// Left or right offset
|
651 |
$offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
|
652 |
-
// Icon size
|
653 |
$vertical_args['icon_size'] = ( isset( $options['floating_vertical_icon_size'] ) ) ? $options['floating_vertical_icon_size'] : '32';
|
654 |
|
655 |
-
// Show on scroll value from the top
|
656 |
$vertical_scroll_show_top = isset( $options['floating_vertical_scroll_top'] ) && '1' == $options['floating_vertical_scroll_top']
|
657 |
&& isset( $options['floating_vertical_scroll_top_pixels'] )
|
658 |
&& is_numeric( $options['floating_vertical_scroll_top_pixels'] ) ? $options['floating_vertical_scroll_top_pixels'] : '';
|
659 |
-
// Show on scroll value from the bottom
|
660 |
$vertical_scroll_show_bottom = isset( $options['floating_vertical_scroll_bottom'] ) && '1' == $options['floating_vertical_scroll_bottom']
|
661 |
&& isset( $options['floating_vertical_scroll_bottom_pixels'] )
|
662 |
&& is_numeric( $options['floating_vertical_scroll_bottom_pixels'] ) ? $options['floating_vertical_scroll_bottom_pixels'] : '';
|
663 |
-
// Merge values as required
|
664 |
if ( ! empty( $vertical_scroll_show_bottom ) ) {
|
665 |
$vertical_args['scroll_show'] = empty( $vertical_scroll_show_top ) ? '0,' . $vertical_scroll_show_bottom : $vertical_scroll_show_top . ',' . $vertical_scroll_show_bottom;
|
666 |
} elseif ( ! empty( $vertical_scroll_show_top ) ) {
|
667 |
$vertical_args['scroll_show'] = $vertical_scroll_show_top;
|
668 |
}
|
669 |
|
670 |
-
// Add a2a_vertical_style className to Kit classes
|
671 |
$vertical_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_vertical_style' );
|
672 |
|
673 |
-
// Add declarations to Kit style attribute
|
674 |
if ( 'left_docked' === $vertical_type ) {
|
675 |
$vertical_args['kit_style'] = 'left:' . $offset . ';top:' . $position . ';';
|
676 |
} elseif ( 'right_docked' === $vertical_type ) {
|
677 |
$vertical_args['kit_style'] = 'right:' . $offset . ';top:' . $position . ';';
|
678 |
}
|
679 |
-
//
|
680 |
if ( ! empty( $options['floating_vertical_bg'] ) && 'custom' === $options['floating_vertical_bg'] ) {
|
681 |
$vertical_args['kit_style'] .= ! empty( $options['floating_vertical_bg_color'] ) ? 'background-color:' . $options['floating_vertical_bg_color'] . ';' : '';
|
682 |
} else {
|
@@ -688,34 +696,34 @@ function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
|
688 |
|
689 |
// Horizontal type?
|
690 |
if ( $horizontal_type ) {
|
691 |
-
// Prevent overwriting of $args values
|
692 |
$horizontal_args = $args;
|
693 |
|
694 |
-
// Left or right position
|
695 |
$position = ( isset( $options['floating_horizontal_position'] ) ) ? $options['floating_horizontal_position'] . 'px' : '0px';
|
696 |
-
// Bottom offset
|
697 |
$offset = ( isset( $options['floating_horizontal_offset'] ) ) ? $options['floating_horizontal_offset'] . 'px' : '0px';
|
698 |
-
// Icon size
|
699 |
$horizontal_args['icon_size'] = ( isset( $options['floating_horizontal_icon_size'] ) ) ? $options['floating_horizontal_icon_size'] : '32';
|
700 |
-
// Show on scroll value from the top
|
701 |
$horizontal_scroll_show_top = isset( $options['floating_horizontal_scroll_top'] ) && '1' == $options['floating_horizontal_scroll_top']
|
702 |
&& isset( $options['floating_horizontal_scroll_top_pixels'] )
|
703 |
&& is_numeric( $options['floating_horizontal_scroll_top_pixels'] ) ? $options['floating_horizontal_scroll_top_pixels'] : '';
|
704 |
-
// Show on scroll value from the bottom
|
705 |
$horizontal_scroll_show_bottom = isset( $options['floating_horizontal_scroll_bottom'] ) && '1' == $options['floating_horizontal_scroll_bottom']
|
706 |
&& isset( $options['floating_horizontal_scroll_bottom_pixels'] )
|
707 |
&& is_numeric( $options['floating_horizontal_scroll_bottom_pixels'] ) ? $options['floating_horizontal_scroll_bottom_pixels'] : '';
|
708 |
-
// Merge values as required
|
709 |
if ( ! empty( $horizontal_scroll_show_bottom ) ) {
|
710 |
$horizontal_args['scroll_show'] = empty( $horizontal_scroll_show_top ) ? '0,' . $horizontal_scroll_show_bottom : $horizontal_scroll_show_top . ',' . $horizontal_scroll_show_bottom;
|
711 |
} elseif ( ! empty( $horizontal_scroll_show_top ) ) {
|
712 |
$horizontal_args['scroll_show'] = $horizontal_scroll_show_top;
|
713 |
}
|
714 |
|
715 |
-
// Add a2a_default_style className to Kit classes
|
716 |
$horizontal_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_default_style' );
|
717 |
|
718 |
-
// Add declarations to Kit style attribute
|
719 |
if ( 'left_docked' === $horizontal_type ) {
|
720 |
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:' . $position . ';';
|
721 |
} elseif ( 'right_docked' === $horizontal_type ) {
|
@@ -723,7 +731,7 @@ function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
|
723 |
} elseif ( 'center_docked' === $horizontal_type ) {
|
724 |
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:50%;transform:translateX(-50%);';
|
725 |
}
|
726 |
-
// Background color
|
727 |
if ( ! empty( $options['floating_horizontal_bg'] ) && 'custom' === $options['floating_horizontal_bg'] ) {
|
728 |
$horizontal_args['kit_style'] .= ! empty( $options['floating_horizontal_bg_color'] ) ? 'background-color:' . $options['floating_horizontal_bg_color'] . ';' : '';
|
729 |
} else {
|
@@ -742,7 +750,7 @@ function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
|
742 |
|
743 |
|
744 |
function A2A_SHARE_SAVE_head_script() {
|
745 |
-
// Hook to disable script output
|
746 |
// Example: add_filter( 'addtoany_script_disabled', '__return_true' );
|
747 |
$script_disabled = apply_filters( 'addtoany_script_disabled', false );
|
748 |
|
@@ -769,28 +777,28 @@ function A2A_SHARE_SAVE_head_script() {
|
|
769 |
$cache = $modified_time && time() - $modified_time < 172800 ? true : false;
|
770 |
// If cache is recent
|
771 |
if ( $cache ) {
|
772 |
-
// Set a "ver" parameter's value to the file's modified time for cache management
|
773 |
$querystring = '?ver=' . $modified_time;
|
774 |
} else {
|
775 |
-
// Revert the cache option
|
776 |
A2A_SHARE_SAVE_revert_cache();
|
777 |
}
|
778 |
}
|
779 |
|
780 |
-
// Set static server
|
781 |
$static_server = $cache ? $upload_dir['baseurl'] . '/addtoany' : 'https://static.addtoany.com/menu';
|
782 |
|
783 |
-
// Icon colors
|
784 |
$icon_bg = ! empty( $options['icon_bg'] ) && in_array( $options['icon_bg'], array( 'custom', 'transparent' ) ) ? $options['icon_bg'] : false;
|
785 |
$icon_bg_color = 'custom' === $icon_bg && ! empty( $options['icon_bg_color'] ) ? $options['icon_bg_color'] : '';
|
786 |
$icon_bg_color = 'transparent' === $icon_bg ? 'transparent' : $icon_bg_color;
|
787 |
$icon_fg = ! empty( $options['icon_fg'] ) && 'custom' === $options['icon_fg'] ? true : false;
|
788 |
$icon_fg_color = $icon_fg && ! empty( $options['icon_fg_color'] ) ? ',' . $options['icon_fg_color'] : '';
|
789 |
-
// Use "unset" keyword for background if only the foreground is set
|
790 |
$icon_bg_color = empty( $icon_bg_color ) && ! empty( $icon_fg_color ) ? 'unset' : $icon_bg_color;
|
791 |
$icon_color = $icon_bg_color . $icon_fg_color;
|
792 |
|
793 |
-
// Floating vertical relative to content
|
794 |
$floating_js = '';
|
795 |
if (
|
796 |
isset( $options['floating_vertical'] )
|
@@ -798,12 +806,12 @@ function A2A_SHARE_SAVE_head_script() {
|
|
798 |
&& ! empty( $options['floating_vertical_attached_to'] )
|
799 |
&& empty( $sharing_disabled )
|
800 |
) {
|
801 |
-
// Top position
|
802 |
$floating_js_position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
|
803 |
-
// Left or right offset
|
804 |
$floating_js_offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
|
805 |
|
806 |
-
// Style attribute (accepts "left" attached only)
|
807 |
$floating_js_kit_style = 'left_attached' === $options['floating_vertical'] ? 'margin-left:' . $floating_js_offset . ';' : '';
|
808 |
$floating_js_kit_style .= 'top:' . $floating_js_position . ';';
|
809 |
|
@@ -827,7 +835,7 @@ function A2A_SHARE_SAVE_head_script() {
|
|
827 |
. '});';
|
828 |
}
|
829 |
|
830 |
-
// Enternal script call + initial JS + set-once variables
|
831 |
$additional_js = ( isset( $options['additional_js_variables'] ) ) ? $options['additional_js_variables'] : '' ;
|
832 |
$script_configs = ( ( $cache ) ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '' )
|
833 |
. ( $icon_color ? "\n" . 'a2a_config.icon_color="' . $icon_color . '";' : '' )
|
@@ -872,9 +880,9 @@ add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
|
|
872 |
function A2A_SHARE_SAVE_add_to_content( $content ) {
|
873 |
global $wp_current_filter;
|
874 |
|
875 |
-
// Don't add to get_the_excerpt because it's too early and strips tags (adding to the_excerpt is allowed)
|
876 |
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
|
877 |
-
// Return early
|
878 |
return $content;
|
879 |
}
|
880 |
|
@@ -882,9 +890,9 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
|
|
882 |
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
883 |
|
884 |
if (
|
885 |
-
// Private post
|
886 |
get_post_status( get_the_ID() ) == 'private' ||
|
887 |
-
// Sharing disabled on post
|
888 |
! empty( $sharing_disabled )
|
889 |
) {
|
890 |
// Return early
|
@@ -897,7 +905,7 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
|
|
897 |
|
898 |
if (
|
899 |
(
|
900 |
-
// Legacy tags
|
901 |
// <!--sharesave--> tag
|
902 |
strpos( $content, '<!--sharesave-->' ) === false ||
|
903 |
// <!--nosharesave--> tag
|
@@ -905,32 +913,32 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
|
|
905 |
) &&
|
906 |
(
|
907 |
// Posts
|
908 |
-
// All posts
|
909 |
( is_singular('post') && isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) ||
|
910 |
-
// Front page posts
|
911 |
( is_home() && isset( $options['display_in_posts_on_front_page'] ) && $options['display_in_posts_on_front_page'] == '-1' ) ||
|
912 |
-
// Archive page posts (Category, Tag, Author and Date pages)
|
913 |
( is_archive() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
914 |
-
// Search results posts (same as Archive page posts option)
|
915 |
( is_search() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
916 |
-
// Excerpt (the_excerpt is the current filter)
|
917 |
( 'the_excerpt' == current_filter() && isset( $options['display_in_excerpts'] ) && $options['display_in_excerpts'] == '-1' ) ||
|
918 |
-
// Posts in feed
|
919 |
( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
|
920 |
|
921 |
-
// Custom post types
|
922 |
( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' ) ||
|
923 |
|
924 |
// Pages
|
925 |
-
// Individual pages
|
926 |
( is_singular('page') && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
|
927 |
-
// Attachment (media) pages
|
928 |
( is_attachment() && isset( $options['display_in_attachments'] ) && $options['display_in_attachments'] == '-1' ) ||
|
929 |
-
// <!--nosharesave--> legacy tag
|
930 |
( (strpos( $content, '<!--nosharesave-->') !== false ) )
|
931 |
)
|
932 |
) {
|
933 |
-
// Return early
|
934 |
return $content;
|
935 |
}
|
936 |
|
@@ -962,11 +970,11 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
|
|
962 |
$options['position'] = isset( $options['position'] ) ? $options['position'] : 'bottom';
|
963 |
|
964 |
if ($options['position'] == 'both' || $options['position'] == 'top') {
|
965 |
-
// Prepend to content
|
966 |
$content = sprintf( $container_wrap_open, 'addtoany_content_top' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close . $content;
|
967 |
}
|
968 |
if ( $options['position'] == 'bottom' || $options['position'] == 'both') {
|
969 |
-
// Append to content
|
970 |
$content .= sprintf( $container_wrap_open, 'addtoany_content_bottom' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close;
|
971 |
}
|
972 |
|
@@ -976,7 +984,7 @@ function A2A_SHARE_SAVE_add_to_content( $content ) {
|
|
976 |
|
977 |
function A2A_SHARE_SAVE_pre_get_posts( $query ) {
|
978 |
if ( $query->is_main_query() ) {
|
979 |
-
// Hook to change the standard buttons' priority number in content
|
980 |
// Example: add_filter( 'addtoany_content_priority', 20 );
|
981 |
$priority = apply_filters( 'addtoany_content_priority', 98 );
|
982 |
|
@@ -1020,7 +1028,7 @@ function A2A_SHARE_SAVE_stylesheet() {
|
|
1020 |
if ( ! is_admin() ) {
|
1021 |
wp_enqueue_style( 'addtoany', plugins_url('/addtoany.min.css', __FILE__ ), false, '1.15' );
|
1022 |
|
1023 |
-
// Prepare inline CSS
|
1024 |
$inline_css = '';
|
1025 |
|
1026 |
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] ) ? $options['floating_vertical'] : false;
|
@@ -1031,13 +1039,13 @@ function A2A_SHARE_SAVE_stylesheet() {
|
|
1031 |
// and respsonsiveness is enabled
|
1032 |
( ! isset( $options['floating_vertical_responsive'] ) || '-1' != $options['floating_vertical_responsive'] )
|
1033 |
) {
|
1034 |
-
// Get min-width for media query
|
1035 |
$vertical_max_width = (
|
1036 |
isset( $options['floating_vertical_responsive_max_width'] ) &&
|
1037 |
is_numeric( $options['floating_vertical_responsive_max_width'] )
|
1038 |
) ? $options['floating_vertical_responsive_max_width'] : '980';
|
1039 |
|
1040 |
-
// Set media query
|
1041 |
$inline_css .= '@media screen and (max-width:' . $vertical_max_width . 'px){' . "\n"
|
1042 |
. '.a2a_floating_style.a2a_vertical_style{display:none;}' . "\n"
|
1043 |
. '}';
|
@@ -1048,16 +1056,16 @@ function A2A_SHARE_SAVE_stylesheet() {
|
|
1048 |
// and respsonsiveness is enabled
|
1049 |
( ! isset( $options['floating_horizontal_responsive'] ) || '-1' != $options['floating_horizontal_responsive'] )
|
1050 |
) {
|
1051 |
-
// Get max-width for media query
|
1052 |
$horizontal_min_width = (
|
1053 |
isset( $options['floating_horizontal_responsive_min_width'] ) &&
|
1054 |
is_numeric( $options['floating_horizontal_responsive_min_width'] )
|
1055 |
) ? $options['floating_horizontal_responsive_min_width'] : '981';
|
1056 |
|
1057 |
-
// Insert newline if there is inline CSS already
|
1058 |
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
1059 |
|
1060 |
-
// Set media query
|
1061 |
$inline_css .= '@media screen and (min-width:' . $horizontal_min_width . 'px){' . "\n"
|
1062 |
. '.a2a_floating_style.a2a_default_style{display:none;}' . "\n"
|
1063 |
. '}';
|
@@ -1067,7 +1075,7 @@ function A2A_SHARE_SAVE_stylesheet() {
|
|
1067 |
if ( ! empty( $options['additional_css'] ) ) {
|
1068 |
$custom_css = stripslashes( $options['additional_css'] );
|
1069 |
|
1070 |
-
// Insert newline if there is inline CSS already
|
1071 |
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
1072 |
|
1073 |
$inline_css .= $custom_css;
|
@@ -1075,7 +1083,7 @@ function A2A_SHARE_SAVE_stylesheet() {
|
|
1075 |
|
1076 |
// If there is inline CSS
|
1077 |
if ( 0 < strlen( $inline_css ) ) {
|
1078 |
-
// Insert inline CSS
|
1079 |
wp_add_inline_style( 'addtoany', $inline_css );
|
1080 |
}
|
1081 |
}
|
@@ -1092,7 +1100,7 @@ function A2A_SHARE_SAVE_enqueue_script() {
|
|
1092 |
add_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' );
|
1093 |
|
1094 |
/**
|
1095 |
-
*
|
1096 |
*/
|
1097 |
|
1098 |
function A2A_SHARE_SAVE_refresh_cache() {
|
@@ -1100,28 +1108,28 @@ function A2A_SHARE_SAVE_refresh_cache() {
|
|
1100 |
$file_urls = explode( "\n", $contents, 20 );
|
1101 |
$upload_dir = wp_upload_dir();
|
1102 |
|
1103 |
-
// Try to create directory if it doesn't already exist
|
1104 |
if ( ! wp_mkdir_p( dirname( $upload_dir['basedir'] . '/addtoany/foo' ) ) ) {
|
1105 |
-
// Handle directory creation issue
|
1106 |
-
// Revert cache option
|
1107 |
A2A_SHARE_SAVE_revert_cache();
|
1108 |
}
|
1109 |
|
1110 |
if ( count( $file_urls ) > 0 ) {
|
1111 |
for ( $i = 0; $i < count( $file_urls ); $i++ ) {
|
1112 |
-
// Download files
|
1113 |
$file_url = trim( $file_urls[ $i ] );
|
1114 |
$file_name = substr( strrchr( $file_url, '/' ), 1, 99 );
|
1115 |
|
1116 |
-
// Place files in uploads/addtoany directory
|
1117 |
$response = wp_remote_get( $file_url, array(
|
1118 |
'filename' => $upload_dir['basedir'] . '/addtoany/' . $file_name,
|
1119 |
-
'stream' => true, // Required to use `filename` arg
|
1120 |
) );
|
1121 |
|
1122 |
-
// Handle error
|
1123 |
if ( is_wp_error( $response ) ) {
|
1124 |
-
// Revert cache option
|
1125 |
A2A_SHARE_SAVE_revert_cache();
|
1126 |
}
|
1127 |
}
|
@@ -1131,37 +1139,37 @@ function A2A_SHARE_SAVE_refresh_cache() {
|
|
1131 |
add_action( 'addtoany_refresh_cache', 'A2A_SHARE_SAVE_refresh_cache' );
|
1132 |
|
1133 |
function A2A_SHARE_SAVE_schedule_cache() {
|
1134 |
-
// Unschedule if already scheduled
|
1135 |
A2A_SHARE_SAVE_unschedule_cache();
|
1136 |
|
1137 |
-
// Try to schedule daily cache refreshes, running once now
|
1138 |
$result = wp_schedule_event( time(), 'daily', 'addtoany_refresh_cache' );
|
1139 |
|
1140 |
-
// Revert cache option if the event didn't get scheduled
|
1141 |
if ( false === $result ) {
|
1142 |
A2A_SHARE_SAVE_revert_cache();
|
1143 |
}
|
1144 |
}
|
1145 |
|
1146 |
function A2A_SHARE_SAVE_unschedule_cache() {
|
1147 |
-
// Unschedule if scheduled
|
1148 |
wp_clear_scheduled_hook( 'addtoany_refresh_cache' );
|
1149 |
}
|
1150 |
|
1151 |
function A2A_SHARE_SAVE_revert_cache() {
|
1152 |
-
// Unschedule
|
1153 |
A2A_SHARE_SAVE_unschedule_cache();
|
1154 |
|
1155 |
-
// Get all existing AddToAny options
|
1156 |
$options = get_option( 'addtoany_options', array() );
|
1157 |
|
1158 |
-
// Revert cache option
|
1159 |
$options['cache'] = '-1';
|
1160 |
update_option( 'addtoany_options', $options );
|
1161 |
}
|
1162 |
|
1163 |
/**
|
1164 |
-
* Activation hook
|
1165 |
*/
|
1166 |
|
1167 |
function addtoany_activation() {
|
@@ -1178,7 +1186,7 @@ function addtoany_activation() {
|
|
1178 |
register_activation_hook( __FILE__, 'addtoany_activation' );
|
1179 |
|
1180 |
/**
|
1181 |
-
* Deactivation hook
|
1182 |
*/
|
1183 |
|
1184 |
function addtoany_deactivation() {
|
@@ -1189,7 +1197,7 @@ function addtoany_deactivation() {
|
|
1189 |
register_deactivation_hook( __FILE__, 'addtoany_deactivation' );
|
1190 |
|
1191 |
/**
|
1192 |
-
* Admin Options
|
1193 |
*/
|
1194 |
|
1195 |
if ( is_admin() ) {
|
@@ -1218,7 +1226,7 @@ function A2A_SHARE_SAVE_widgets_init() {
|
|
1218 |
|
1219 |
add_action( 'widgets_init', 'A2A_SHARE_SAVE_widgets_init' );
|
1220 |
|
1221 |
-
// Place in Option List on Settings > Plugins page
|
1222 |
function A2A_SHARE_SAVE_actlinks( $links, $file ) {
|
1223 |
// Static so we don't call plugin_basename on every plugin row.
|
1224 |
static $this_plugin;
|
@@ -1229,7 +1237,7 @@ function A2A_SHARE_SAVE_actlinks( $links, $file ) {
|
|
1229 |
|
1230 |
if ( $file == $this_plugin ) {
|
1231 |
$settings_link = '<a href="options-general.php?page=addtoany">' . __( 'Settings' ) . '</a>';
|
1232 |
-
array_unshift( $links, $settings_link ); //
|
1233 |
}
|
1234 |
|
1235 |
return $links;
|
1 |
<?php
|
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.40
|
7 |
+
* Author: AddToAny
|
8 |
+
* Author URI: https://www.addtoany.com/
|
9 |
+
* Text Domain: add-to-any
|
10 |
+
* Domain Path: /languages
|
11 |
+
*/
|
12 |
+
|
13 |
+
// Explicitly globalize to support bootstrapped WordPress.
|
14 |
global $A2A_locale, $A2A_FOLLOW_services,
|
15 |
$A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url,
|
16 |
$A2A_SHARE_SAVE_services;
|
18 |
$A2A_SHARE_SAVE_plugin_dir = untrailingslashit( plugin_dir_path( __FILE__ ) );
|
19 |
$A2A_SHARE_SAVE_plugin_url = untrailingslashit( plugin_dir_url( __FILE__ ) );
|
20 |
|
21 |
+
// Set AddToAny locale (JavaScript).
|
22 |
$A2A_locale = ! isset ( $A2A_locale ) ? '' : $A2A_locale;
|
23 |
+
// Set plugin options.
|
24 |
$A2A_SHARE_SAVE_options = get_option( 'addtoany_options', array() );
|
25 |
|
26 |
+
// Require PHP 5.3 as a bare minimum for compatibility features that use anonymous functions (PHP 5.3+).
|
27 |
+
if ( version_compare( phpversion(), '5.3.0', '>=' ) ) {
|
28 |
+
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.compat.php';
|
29 |
+
}
|
30 |
+
|
31 |
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php';
|
32 |
|
33 |
function A2A_SHARE_SAVE_init() {
|
34 |
global $A2A_SHARE_SAVE_plugin_dir,
|
35 |
$A2A_SHARE_SAVE_options;
|
36 |
|
37 |
+
// Load the textdomain for translations.
|
38 |
load_plugin_textdomain( 'add-to-any', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
|
39 |
|
40 |
+
// Update plugin options.
|
41 |
$options = $A2A_SHARE_SAVE_options;
|
42 |
$old_buttons = array(
|
43 |
'share_save_256_24.gif|256|24', 'share_save_171_16.gif|171|16', 'share_save_120_16.gif|120|16',
|
45 |
'share_16_16.png|16|16', 'favicon.png|16|16',
|
46 |
);
|
47 |
|
48 |
+
// If old button enabled.
|
49 |
if ( ! empty( $options['button'] ) && in_array( $options['button'], $old_buttons ) ) {
|
50 |
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.update.php';
|
51 |
addtoany_update_options();
|
61 |
$linkmedia = empty( $args['linkmedia'] ) ? '' : $args['linkmedia'];
|
62 |
$use_current_page = isset( $args['use_current_page'] ) ? $args['use_current_page'] : false;
|
63 |
|
64 |
+
// Set linkname if needed, and not a Follow kit.
|
65 |
if ( ! $linkname && empty( $args['is_follow'] ) ) {
|
66 |
if ( $use_current_page ) {
|
67 |
$linkname = is_home() || is_front_page() ? get_bloginfo( 'name' ) : rtrim( wp_title( '', false, 'right' ) );
|
74 |
|
75 |
$linkname_enc = rawurlencode( $linkname );
|
76 |
|
77 |
+
// Set linkurl if needed, and not a Follow kit.
|
78 |
if ( ! $linkurl && empty( $args['is_follow'] ) ) {
|
79 |
if ( $use_current_page ) {
|
80 |
$linkurl = esc_url_raw( home_url( $_SERVER['REQUEST_URI'] ) );
|
87 |
|
88 |
$linkurl_enc = rawurlencode( $linkurl );
|
89 |
|
90 |
+
// Set linkmedia (only applies to services that explicitly accept media; Pinterest does, most do not).
|
91 |
$linkmedia_enc = ! empty( $args['linkmedia'] ) ? rawurlencode( $args['linkmedia'] ) : '';
|
92 |
|
93 |
return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc', 'linkmedia', 'linkmedia_enc', 'use_current_page' );
|
94 |
}
|
95 |
|
96 |
+
// Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON.
|
97 |
function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
98 |
$options = get_option( 'addtoany_options', array() );
|
99 |
|
107 |
|
108 |
$args = wp_parse_args( $args, $defaults );
|
109 |
|
110 |
+
// If universal button disabled, and not manually disabled through args.
|
111 |
if ( isset( $options['button'] ) && $options['button'] == 'NONE' && ! isset( $args['no_universal_button'] ) ) {
|
112 |
+
// Pass this setting on to ADDTOANY_SHARE_SAVE_BUTTON,
|
113 |
+
// and only via this ADDTOANY_SHARE_SAVE_KIT function because it is used for automatic placement.
|
114 |
$args['no_universal_button'] = true;
|
115 |
}
|
116 |
|
124 |
$kit_data_scroll_show = empty( $args['scroll_show'] ) ? '' : ' data-a2a-scroll-show="' . esc_attr( $args['scroll_show'] ) . '"';
|
125 |
$kit_style = '';
|
126 |
|
127 |
+
// Add additional classNames to .a2a_kit.
|
128 |
if ( ! empty( $args['kit_additional_classes'] ) ) {
|
129 |
+
// Append space and className(s).
|
130 |
$kit_additional_classes .= ' ' . $args['kit_additional_classes'];
|
131 |
}
|
132 |
|
133 |
+
// Set a2a_kit_size_## class name.
|
134 |
if ( $custom_icons ) {
|
135 |
// If vertical style (.a2a_vertical_style)
|
136 |
if ( strpos( $kit_additional_classes, 'a2a_vertical_style' ) !== false ) {
|
137 |
+
// Use width (if specified) for .a2a_kit_size_## class name to size default service counters.
|
138 |
$icon_size_classname = isset( $options['custom_icons_width'] ) ? ' a2a_kit_size_' . $options['custom_icons_width'] : '';
|
139 |
} else {
|
140 |
+
// Use height (if specified) for .a2a_kit_size_## class name to size default service counters.
|
141 |
$icon_size_classname = isset( $options['custom_icons_height'] ) ? ' a2a_kit_size_' . $options['custom_icons_height'] : '';
|
142 |
}
|
143 |
+
// Set a2a_kit_size_## icon size.
|
144 |
} else {
|
145 |
$icon_size_classname = ' a2a_kit_size_' . $args['icon_size'];
|
146 |
}
|
147 |
|
148 |
+
// Add addtoany_list className unless disabled (for floating buttons).
|
149 |
if ( ! isset( $args['no_addtoany_list_classname'] ) ) {
|
150 |
$kit_additional_classes .= ' addtoany_list';
|
151 |
}
|
152 |
|
153 |
+
// Add style attribute if set.
|
154 |
if ( ! empty( $args['kit_style'] ) ) {
|
155 |
$kit_style = ' style="' . esc_attr( $args['kit_style'] ) . '"';
|
156 |
}
|
162 |
}
|
163 |
if ( ! isset( $args['html_container_close'] ) )
|
164 |
$args['html_container_close'] = "</div>";
|
165 |
+
// Close container element in ADDTOANY_SHARE_SAVE_BUTTON, not prematurely in ADDTOANY_SHARE_SAVE_ICONS.
|
166 |
+
// Cache for _BUTTON.
|
167 |
+
$html_container_close = $args['html_container_close'];
|
168 |
+
// Avoid passing to ADDTOANY_SHARE_SAVE_ICONS since set in _BUTTON.
|
169 |
+
unset($args['html_container_close']);
|
170 |
|
171 |
if ( ! isset( $args['html_wrap_open'] ) )
|
172 |
$args['html_wrap_open'] = "";
|
175 |
|
176 |
$kit_html = ADDTOANY_SHARE_SAVE_ICONS( $args );
|
177 |
|
178 |
+
// Set again because it was unset above for _ICONS.
|
179 |
+
$args['html_container_close'] = $html_container_close;
|
180 |
+
// Avoid passing to ADDTOANY_SHARE_SAVE_BUTTON since set in _ICONS.
|
181 |
+
unset( $args['html_container_open'] );
|
182 |
|
183 |
$kit_html .= ADDTOANY_SHARE_SAVE_BUTTON( $args );
|
184 |
|
221 |
|
222 |
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
|
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
|
233 |
$icons_height = ( isset( $options['custom_icons_height'] ) ) ? $options['custom_icons_height'] : '';
|
234 |
$custom_icons = true;
|
235 |
} else {
|
236 |
+
// Default to local SVGs.
|
237 |
$icons_dir = plugins_url('/icons/', __FILE__ );
|
238 |
$icons_type = 'svg';
|
239 |
}
|
252 |
$services = apply_filters( 'A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services );
|
253 |
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
|
254 |
|
255 |
+
// Include Facebook Like and Twitter Tweet etc. unless no_special_services arg is true.
|
256 |
if ( ! isset( $args['no_special_services'] ) || false == $args['no_special_services'] ) {
|
257 |
array_unshift( $service_codes, 'facebook_like', 'twitter_tweet', 'pinterest_pin' );
|
258 |
}
|
259 |
|
260 |
+
// Use default services if services have not been selected yet.
|
261 |
$active_services = isset( $options['active_services'] ) ? $options['active_services'] : array( 'facebook', 'twitter', 'email' );
|
262 |
+
// Services set by "buttons" arg? Then use "buttons" arg instead.
|
263 |
$active_services = empty( $args['buttons'] ) ? $active_services : $args['buttons'];
|
264 |
}
|
265 |
|
288 |
|
289 |
// If it's a URL instead of a service ID
|
290 |
if ( $is_url ) {
|
291 |
+
// Just use the given URL instead of the URL template.
|
292 |
$href = $follow_id;
|
293 |
} else {
|
294 |
+
// Replace the ID placeholder in the URL template.
|
295 |
$href = str_replace( '${id}', $follow_id, $service['href'] );
|
296 |
}
|
297 |
$href = ( 'feed' == $code_name ) ? $follow_id : $href;
|
298 |
|
299 |
+
// If icon_url is set, presume custom service.
|
300 |
if ( isset( $service['icon_url'] ) ) {
|
301 |
$custom_service = true;
|
302 |
}
|
303 |
+
// Else if Share Kit and HREF specified, presume custom service.
|
304 |
} elseif ( isset( $service['href'] ) ) {
|
305 |
$custom_service = true;
|
306 |
$href = $service['href'];
|
349 |
$target_attr = '';
|
350 |
}
|
351 |
|
352 |
+
// Use rel="noopener" for links that open in a new tab/window.
|
353 |
$rel_noopener = $custom_service || ! $target_attr ? '' : ' noopener';
|
354 |
$rel_noopener_only = $rel_noopener || $target_attr ? ' rel="noopener"' : '';
|
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 . '"' : '';
|
420 |
if ( ! $args['no_universal_button'] ) {
|
421 |
|
422 |
if ( isset( $options['button'] ) && 'CUSTOM' == $options['button'] ) {
|
423 |
+
// Custom button.
|
424 |
$button_src = $options['button_custom'];
|
425 |
$button_width = '';
|
426 |
$button_height = '';
|
427 |
$button_style = '';
|
428 |
} else if ( isset( $options['button'] ) && 'TEXT' == $options['button'] ) {
|
429 |
+
// Text-only button.
|
430 |
$button_text = stripslashes( $options[ 'button_text'] );
|
431 |
+
// Do not display universal icon.
|
432 |
$button_class .= ' addtoany_no_icon';
|
433 |
} else {
|
434 |
+
// Default AddToAny button.
|
435 |
if ( $is_amp ) {
|
436 |
+
// AMP (Accelerated Mobile Page).
|
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"';
|
451 |
$button = '';
|
452 |
}
|
453 |
|
454 |
+
// Add additional classNames to .a2a_dd.
|
455 |
$button_additional_classes = ! empty( $args['button_additional_classes'] ) ? ' ' . $args['button_additional_classes'] : '';
|
456 |
|
457 |
if ( isset( $options['button_show_count'] ) && $options['button_show_count'] == '1' ) {
|
464 |
. '>' . $button . '</a>';
|
465 |
|
466 |
} else {
|
467 |
+
// Universal button disabled.
|
468 |
$button_html = '';
|
469 |
}
|
470 |
|
471 |
+
// Closing tags come after <script> to validate in case the container is a list element.
|
472 |
$button_html .= $args['html_wrap_close'] . $args['html_container_close'];
|
473 |
|
474 |
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
|
557 |
function ADDTOANY_FOLLOW_KIT( $args = array() ) {
|
558 |
$options = get_option( 'addtoany_options', array() );
|
559 |
|
560 |
+
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT.
|
561 |
$defaults = array(
|
562 |
'buttons' => array(),
|
563 |
'linkname' => '',
|
578 |
|
579 |
$args = wp_parse_args( $args, $defaults );
|
580 |
|
581 |
+
// Add a2a_follow className to Kit classes.
|
582 |
$args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_follow' );
|
583 |
|
584 |
+
// If $args['buttons']['feed']['id'] is set.
|
585 |
$buttons = $args['buttons'];
|
586 |
if ( ! empty( $buttons['feed'] ) && ! empty( $buttons['feed']['id'] ) ) {
|
587 |
$args['linkurl'] = $buttons['feed']['id'];
|
601 |
|
602 |
$floating_html = '';
|
603 |
|
604 |
+
// Overridable by args below.
|
605 |
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical']
|
606 |
&& ! in_array( $options['floating_vertical'], array( 'left_attached', 'right_attached' ) )
|
607 |
) ? $options['floating_vertical'] : false;
|
613 |
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
614 |
|
615 |
if ( ! empty( $sharing_disabled ) ) {
|
616 |
+
// Overridable by args below.
|
617 |
$vertical_type = false;
|
618 |
$horizontal_type = false;
|
619 |
}
|
620 |
}
|
621 |
|
622 |
+
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT.
|
623 |
$defaults = array(
|
624 |
'linkname' => '',
|
625 |
'linkurl' => '',
|
637 |
|
638 |
$args = wp_parse_args( $args, $defaults );
|
639 |
|
640 |
+
// Individual floating type args can override saved options.
|
641 |
if ( isset( $args['vertical_type'] ) && $args['vertical_type'] === true ) {
|
642 |
$vertical_type = true;
|
643 |
}
|
645 |
$horizontal_type = true;
|
646 |
}
|
647 |
|
648 |
+
// If either floating type is enabled,
|
649 |
+
// expect either a string from options, or a boolean from args.
|
650 |
if ( $vertical_type || $horizontal_type ) {
|
651 |
// Vertical type?
|
652 |
if ( $vertical_type ) {
|
653 |
+
// Prevent overwriting of $args.
|
654 |
$vertical_args = $args;
|
655 |
|
656 |
+
// Top position.
|
657 |
$position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
|
658 |
+
// Left or right offset.
|
659 |
$offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
|
660 |
+
// Icon size.
|
661 |
$vertical_args['icon_size'] = ( isset( $options['floating_vertical_icon_size'] ) ) ? $options['floating_vertical_icon_size'] : '32';
|
662 |
|
663 |
+
// Show on scroll value from the top.
|
664 |
$vertical_scroll_show_top = isset( $options['floating_vertical_scroll_top'] ) && '1' == $options['floating_vertical_scroll_top']
|
665 |
&& isset( $options['floating_vertical_scroll_top_pixels'] )
|
666 |
&& is_numeric( $options['floating_vertical_scroll_top_pixels'] ) ? $options['floating_vertical_scroll_top_pixels'] : '';
|
667 |
+
// Show on scroll value from the bottom.
|
668 |
$vertical_scroll_show_bottom = isset( $options['floating_vertical_scroll_bottom'] ) && '1' == $options['floating_vertical_scroll_bottom']
|
669 |
&& isset( $options['floating_vertical_scroll_bottom_pixels'] )
|
670 |
&& is_numeric( $options['floating_vertical_scroll_bottom_pixels'] ) ? $options['floating_vertical_scroll_bottom_pixels'] : '';
|
671 |
+
// Merge values as required.
|
672 |
if ( ! empty( $vertical_scroll_show_bottom ) ) {
|
673 |
$vertical_args['scroll_show'] = empty( $vertical_scroll_show_top ) ? '0,' . $vertical_scroll_show_bottom : $vertical_scroll_show_top . ',' . $vertical_scroll_show_bottom;
|
674 |
} elseif ( ! empty( $vertical_scroll_show_top ) ) {
|
675 |
$vertical_args['scroll_show'] = $vertical_scroll_show_top;
|
676 |
}
|
677 |
|
678 |
+
// Add a2a_vertical_style className to Kit classes.
|
679 |
$vertical_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_vertical_style' );
|
680 |
|
681 |
+
// Add declarations to Kit style attribute.
|
682 |
if ( 'left_docked' === $vertical_type ) {
|
683 |
$vertical_args['kit_style'] = 'left:' . $offset . ';top:' . $position . ';';
|
684 |
} elseif ( 'right_docked' === $vertical_type ) {
|
685 |
$vertical_args['kit_style'] = 'right:' . $offset . ';top:' . $position . ';';
|
686 |
}
|
687 |
+
// Set background color.
|
688 |
if ( ! empty( $options['floating_vertical_bg'] ) && 'custom' === $options['floating_vertical_bg'] ) {
|
689 |
$vertical_args['kit_style'] .= ! empty( $options['floating_vertical_bg_color'] ) ? 'background-color:' . $options['floating_vertical_bg_color'] . ';' : '';
|
690 |
} else {
|
696 |
|
697 |
// Horizontal type?
|
698 |
if ( $horizontal_type ) {
|
699 |
+
// Prevent overwriting of $args values.
|
700 |
$horizontal_args = $args;
|
701 |
|
702 |
+
// Left or right position.
|
703 |
$position = ( isset( $options['floating_horizontal_position'] ) ) ? $options['floating_horizontal_position'] . 'px' : '0px';
|
704 |
+
// Bottom offset.
|
705 |
$offset = ( isset( $options['floating_horizontal_offset'] ) ) ? $options['floating_horizontal_offset'] . 'px' : '0px';
|
706 |
+
// Icon size.
|
707 |
$horizontal_args['icon_size'] = ( isset( $options['floating_horizontal_icon_size'] ) ) ? $options['floating_horizontal_icon_size'] : '32';
|
708 |
+
// Show on scroll value from the top.
|
709 |
$horizontal_scroll_show_top = isset( $options['floating_horizontal_scroll_top'] ) && '1' == $options['floating_horizontal_scroll_top']
|
710 |
&& isset( $options['floating_horizontal_scroll_top_pixels'] )
|
711 |
&& is_numeric( $options['floating_horizontal_scroll_top_pixels'] ) ? $options['floating_horizontal_scroll_top_pixels'] : '';
|
712 |
+
// Show on scroll value from the bottom.
|
713 |
$horizontal_scroll_show_bottom = isset( $options['floating_horizontal_scroll_bottom'] ) && '1' == $options['floating_horizontal_scroll_bottom']
|
714 |
&& isset( $options['floating_horizontal_scroll_bottom_pixels'] )
|
715 |
&& is_numeric( $options['floating_horizontal_scroll_bottom_pixels'] ) ? $options['floating_horizontal_scroll_bottom_pixels'] : '';
|
716 |
+
// Merge values as required.
|
717 |
if ( ! empty( $horizontal_scroll_show_bottom ) ) {
|
718 |
$horizontal_args['scroll_show'] = empty( $horizontal_scroll_show_top ) ? '0,' . $horizontal_scroll_show_bottom : $horizontal_scroll_show_top . ',' . $horizontal_scroll_show_bottom;
|
719 |
} elseif ( ! empty( $horizontal_scroll_show_top ) ) {
|
720 |
$horizontal_args['scroll_show'] = $horizontal_scroll_show_top;
|
721 |
}
|
722 |
|
723 |
+
// Add a2a_default_style className to Kit classes.
|
724 |
$horizontal_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_default_style' );
|
725 |
|
726 |
+
// Add declarations to Kit style attribute.
|
727 |
if ( 'left_docked' === $horizontal_type ) {
|
728 |
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:' . $position . ';';
|
729 |
} elseif ( 'right_docked' === $horizontal_type ) {
|
731 |
} elseif ( 'center_docked' === $horizontal_type ) {
|
732 |
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:50%;transform:translateX(-50%);';
|
733 |
}
|
734 |
+
// Background color.
|
735 |
if ( ! empty( $options['floating_horizontal_bg'] ) && 'custom' === $options['floating_horizontal_bg'] ) {
|
736 |
$horizontal_args['kit_style'] .= ! empty( $options['floating_horizontal_bg_color'] ) ? 'background-color:' . $options['floating_horizontal_bg_color'] . ';' : '';
|
737 |
} else {
|
750 |
|
751 |
|
752 |
function A2A_SHARE_SAVE_head_script() {
|
753 |
+
// Hook to disable script output.
|
754 |
// Example: add_filter( 'addtoany_script_disabled', '__return_true' );
|
755 |
$script_disabled = apply_filters( 'addtoany_script_disabled', false );
|
756 |
|
777 |
$cache = $modified_time && time() - $modified_time < 172800 ? true : false;
|
778 |
// If cache is recent
|
779 |
if ( $cache ) {
|
780 |
+
// Set a "ver" parameter's value to the file's modified time for cache management.
|
781 |
$querystring = '?ver=' . $modified_time;
|
782 |
} else {
|
783 |
+
// Revert the cache option.
|
784 |
A2A_SHARE_SAVE_revert_cache();
|
785 |
}
|
786 |
}
|
787 |
|
788 |
+
// Set static server.
|
789 |
$static_server = $cache ? $upload_dir['baseurl'] . '/addtoany' : 'https://static.addtoany.com/menu';
|
790 |
|
791 |
+
// Icon colors.
|
792 |
$icon_bg = ! empty( $options['icon_bg'] ) && in_array( $options['icon_bg'], array( 'custom', 'transparent' ) ) ? $options['icon_bg'] : false;
|
793 |
$icon_bg_color = 'custom' === $icon_bg && ! empty( $options['icon_bg_color'] ) ? $options['icon_bg_color'] : '';
|
794 |
$icon_bg_color = 'transparent' === $icon_bg ? 'transparent' : $icon_bg_color;
|
795 |
$icon_fg = ! empty( $options['icon_fg'] ) && 'custom' === $options['icon_fg'] ? true : false;
|
796 |
$icon_fg_color = $icon_fg && ! empty( $options['icon_fg_color'] ) ? ',' . $options['icon_fg_color'] : '';
|
797 |
+
// Use "unset" keyword for background if only the foreground is set.
|
798 |
$icon_bg_color = empty( $icon_bg_color ) && ! empty( $icon_fg_color ) ? 'unset' : $icon_bg_color;
|
799 |
$icon_color = $icon_bg_color . $icon_fg_color;
|
800 |
|
801 |
+
// Floating vertical relative to content.
|
802 |
$floating_js = '';
|
803 |
if (
|
804 |
isset( $options['floating_vertical'] )
|
806 |
&& ! empty( $options['floating_vertical_attached_to'] )
|
807 |
&& empty( $sharing_disabled )
|
808 |
) {
|
809 |
+
// Top position.
|
810 |
$floating_js_position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
|
811 |
+
// Left or right offset.
|
812 |
$floating_js_offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
|
813 |
|
814 |
+
// Style attribute (accepts "left" attached only).
|
815 |
$floating_js_kit_style = 'left_attached' === $options['floating_vertical'] ? 'margin-left:' . $floating_js_offset . ';' : '';
|
816 |
$floating_js_kit_style .= 'top:' . $floating_js_position . ';';
|
817 |
|
835 |
. '});';
|
836 |
}
|
837 |
|
838 |
+
// Enternal script call + initial JS + set-once variables.
|
839 |
$additional_js = ( isset( $options['additional_js_variables'] ) ) ? $options['additional_js_variables'] : '' ;
|
840 |
$script_configs = ( ( $cache ) ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '' )
|
841 |
. ( $icon_color ? "\n" . 'a2a_config.icon_color="' . $icon_color . '";' : '' )
|
880 |
function A2A_SHARE_SAVE_add_to_content( $content ) {
|
881 |
global $wp_current_filter;
|
882 |
|
883 |
+
// Don't add to get_the_excerpt because it's too early and strips tags (adding to the_excerpt is allowed).
|
884 |
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
|
885 |
+
// Return early.
|
886 |
return $content;
|
887 |
}
|
888 |
|
890 |
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
891 |
|
892 |
if (
|
893 |
+
// Private post?
|
894 |
get_post_status( get_the_ID() ) == 'private' ||
|
895 |
+
// Sharing disabled on post?
|
896 |
! empty( $sharing_disabled )
|
897 |
) {
|
898 |
// Return early
|
905 |
|
906 |
if (
|
907 |
(
|
908 |
+
// Legacy tags?
|
909 |
// <!--sharesave--> tag
|
910 |
strpos( $content, '<!--sharesave-->' ) === false ||
|
911 |
// <!--nosharesave--> tag
|
913 |
) &&
|
914 |
(
|
915 |
// Posts
|
916 |
+
// All posts.
|
917 |
( is_singular('post') && isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) ||
|
918 |
+
// Front page posts.
|
919 |
( is_home() && isset( $options['display_in_posts_on_front_page'] ) && $options['display_in_posts_on_front_page'] == '-1' ) ||
|
920 |
+
// Archive page posts (Category, Tag, Author and Date pages).
|
921 |
( is_archive() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
922 |
+
// Search results posts (same as Archive page posts option).
|
923 |
( is_search() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
924 |
+
// Excerpt (the_excerpt is the current filter).
|
925 |
( 'the_excerpt' == current_filter() && isset( $options['display_in_excerpts'] ) && $options['display_in_excerpts'] == '-1' ) ||
|
926 |
+
// Posts in feed.
|
927 |
( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
|
928 |
|
929 |
+
// Custom post types.
|
930 |
( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' ) ||
|
931 |
|
932 |
// Pages
|
933 |
+
// Individual pages.
|
934 |
( is_singular('page') && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
|
935 |
+
// Attachment (media) pages.
|
936 |
( is_attachment() && isset( $options['display_in_attachments'] ) && $options['display_in_attachments'] == '-1' ) ||
|
937 |
+
// <!--nosharesave--> legacy tag.
|
938 |
( (strpos( $content, '<!--nosharesave-->') !== false ) )
|
939 |
)
|
940 |
) {
|
941 |
+
// Return early.
|
942 |
return $content;
|
943 |
}
|
944 |
|
970 |
$options['position'] = isset( $options['position'] ) ? $options['position'] : 'bottom';
|
971 |
|
972 |
if ($options['position'] == 'both' || $options['position'] == 'top') {
|
973 |
+
// Prepend to content.
|
974 |
$content = sprintf( $container_wrap_open, 'addtoany_content_top' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close . $content;
|
975 |
}
|
976 |
if ( $options['position'] == 'bottom' || $options['position'] == 'both') {
|
977 |
+
// Append to content.
|
978 |
$content .= sprintf( $container_wrap_open, 'addtoany_content_bottom' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close;
|
979 |
}
|
980 |
|
984 |
|
985 |
function A2A_SHARE_SAVE_pre_get_posts( $query ) {
|
986 |
if ( $query->is_main_query() ) {
|
987 |
+
// Hook to change the standard buttons' priority number in content.
|
988 |
// Example: add_filter( 'addtoany_content_priority', 20 );
|
989 |
$priority = apply_filters( 'addtoany_content_priority', 98 );
|
990 |
|
1028 |
if ( ! is_admin() ) {
|
1029 |
wp_enqueue_style( 'addtoany', plugins_url('/addtoany.min.css', __FILE__ ), false, '1.15' );
|
1030 |
|
1031 |
+
// Prepare inline CSS.
|
1032 |
$inline_css = '';
|
1033 |
|
1034 |
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] ) ? $options['floating_vertical'] : false;
|
1039 |
// and respsonsiveness is enabled
|
1040 |
( ! isset( $options['floating_vertical_responsive'] ) || '-1' != $options['floating_vertical_responsive'] )
|
1041 |
) {
|
1042 |
+
// Get min-width for media query.
|
1043 |
$vertical_max_width = (
|
1044 |
isset( $options['floating_vertical_responsive_max_width'] ) &&
|
1045 |
is_numeric( $options['floating_vertical_responsive_max_width'] )
|
1046 |
) ? $options['floating_vertical_responsive_max_width'] : '980';
|
1047 |
|
1048 |
+
// Set media query.
|
1049 |
$inline_css .= '@media screen and (max-width:' . $vertical_max_width . 'px){' . "\n"
|
1050 |
. '.a2a_floating_style.a2a_vertical_style{display:none;}' . "\n"
|
1051 |
. '}';
|
1056 |
// and respsonsiveness is enabled
|
1057 |
( ! isset( $options['floating_horizontal_responsive'] ) || '-1' != $options['floating_horizontal_responsive'] )
|
1058 |
) {
|
1059 |
+
// Get max-width for media query.
|
1060 |
$horizontal_min_width = (
|
1061 |
isset( $options['floating_horizontal_responsive_min_width'] ) &&
|
1062 |
is_numeric( $options['floating_horizontal_responsive_min_width'] )
|
1063 |
) ? $options['floating_horizontal_responsive_min_width'] : '981';
|
1064 |
|
1065 |
+
// Insert newline if there is inline CSS already.
|
1066 |
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
1067 |
|
1068 |
+
// Set media query.
|
1069 |
$inline_css .= '@media screen and (min-width:' . $horizontal_min_width . 'px){' . "\n"
|
1070 |
. '.a2a_floating_style.a2a_default_style{display:none;}' . "\n"
|
1071 |
. '}';
|
1075 |
if ( ! empty( $options['additional_css'] ) ) {
|
1076 |
$custom_css = stripslashes( $options['additional_css'] );
|
1077 |
|
1078 |
+
// Insert newline if there is inline CSS already.
|
1079 |
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
1080 |
|
1081 |
$inline_css .= $custom_css;
|
1083 |
|
1084 |
// If there is inline CSS
|
1085 |
if ( 0 < strlen( $inline_css ) ) {
|
1086 |
+
// Insert inline CSS.
|
1087 |
wp_add_inline_style( 'addtoany', $inline_css );
|
1088 |
}
|
1089 |
}
|
1100 |
add_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' );
|
1101 |
|
1102 |
/**
|
1103 |
+
* AddToAny caching.
|
1104 |
*/
|
1105 |
|
1106 |
function A2A_SHARE_SAVE_refresh_cache() {
|
1108 |
$file_urls = explode( "\n", $contents, 20 );
|
1109 |
$upload_dir = wp_upload_dir();
|
1110 |
|
1111 |
+
// Try to create directory if it doesn't already exist.
|
1112 |
if ( ! wp_mkdir_p( dirname( $upload_dir['basedir'] . '/addtoany/foo' ) ) ) {
|
1113 |
+
// Handle directory creation issue.
|
1114 |
+
// Revert cache option.
|
1115 |
A2A_SHARE_SAVE_revert_cache();
|
1116 |
}
|
1117 |
|
1118 |
if ( count( $file_urls ) > 0 ) {
|
1119 |
for ( $i = 0; $i < count( $file_urls ); $i++ ) {
|
1120 |
+
// Download files.
|
1121 |
$file_url = trim( $file_urls[ $i ] );
|
1122 |
$file_name = substr( strrchr( $file_url, '/' ), 1, 99 );
|
1123 |
|
1124 |
+
// Place files in uploads/addtoany directory.
|
1125 |
$response = wp_remote_get( $file_url, array(
|
1126 |
'filename' => $upload_dir['basedir'] . '/addtoany/' . $file_name,
|
1127 |
+
'stream' => true, // Required to use `filename` arg.
|
1128 |
) );
|
1129 |
|
1130 |
+
// Handle error.
|
1131 |
if ( is_wp_error( $response ) ) {
|
1132 |
+
// Revert cache option.
|
1133 |
A2A_SHARE_SAVE_revert_cache();
|
1134 |
}
|
1135 |
}
|
1139 |
add_action( 'addtoany_refresh_cache', 'A2A_SHARE_SAVE_refresh_cache' );
|
1140 |
|
1141 |
function A2A_SHARE_SAVE_schedule_cache() {
|
1142 |
+
// Unschedule if already scheduled.
|
1143 |
A2A_SHARE_SAVE_unschedule_cache();
|
1144 |
|
1145 |
+
// Try to schedule daily cache refreshes, running once now.
|
1146 |
$result = wp_schedule_event( time(), 'daily', 'addtoany_refresh_cache' );
|
1147 |
|
1148 |
+
// Revert cache option if the event didn't get scheduled.
|
1149 |
if ( false === $result ) {
|
1150 |
A2A_SHARE_SAVE_revert_cache();
|
1151 |
}
|
1152 |
}
|
1153 |
|
1154 |
function A2A_SHARE_SAVE_unschedule_cache() {
|
1155 |
+
// Unschedule if scheduled.
|
1156 |
wp_clear_scheduled_hook( 'addtoany_refresh_cache' );
|
1157 |
}
|
1158 |
|
1159 |
function A2A_SHARE_SAVE_revert_cache() {
|
1160 |
+
// Unschedule.
|
1161 |
A2A_SHARE_SAVE_unschedule_cache();
|
1162 |
|
1163 |
+
// Get all existing AddToAny options.
|
1164 |
$options = get_option( 'addtoany_options', array() );
|
1165 |
|
1166 |
+
// Revert cache option.
|
1167 |
$options['cache'] = '-1';
|
1168 |
update_option( 'addtoany_options', $options );
|
1169 |
}
|
1170 |
|
1171 |
/**
|
1172 |
+
* Activation hook.
|
1173 |
*/
|
1174 |
|
1175 |
function addtoany_activation() {
|
1186 |
register_activation_hook( __FILE__, 'addtoany_activation' );
|
1187 |
|
1188 |
/**
|
1189 |
+
* Deactivation hook.
|
1190 |
*/
|
1191 |
|
1192 |
function addtoany_deactivation() {
|
1197 |
register_deactivation_hook( __FILE__, 'addtoany_deactivation' );
|
1198 |
|
1199 |
/**
|
1200 |
+
* Admin Options.
|
1201 |
*/
|
1202 |
|
1203 |
if ( is_admin() ) {
|
1226 |
|
1227 |
add_action( 'widgets_init', 'A2A_SHARE_SAVE_widgets_init' );
|
1228 |
|
1229 |
+
// Place in Option List on Settings > Plugins page.
|
1230 |
function A2A_SHARE_SAVE_actlinks( $links, $file ) {
|
1231 |
// Static so we don't call plugin_basename on every plugin row.
|
1232 |
static $this_plugin;
|
1237 |
|
1238 |
if ( $file == $this_plugin ) {
|
1239 |
$settings_link = '<a href="options-general.php?page=addtoany">' . __( 'Settings' ) . '</a>';
|
1240 |
+
array_unshift( $links, $settings_link ); // Before other links.
|
1241 |
}
|
1242 |
|
1243 |
return $links;
|
addtoany.compat.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Load theme compatibility functions
|
5 |
*/
|
6 |
function addtoany_load_theme_compat() {
|
7 |
add_action( 'loop_start', 'addtoany_excerpt_remove' );
|
@@ -10,12 +10,12 @@ function addtoany_load_theme_compat() {
|
|
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 |
}
|
@@ -23,13 +23,13 @@ function addtoany_excerpt_remove() {
|
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
-
* Load AMP (Accelerated Mobile Pages) compatibility functions
|
27 |
*/
|
28 |
|
29 |
add_action( 'amp_post_template_css', 'addtoany_amp_additional_css_styles' );
|
30 |
|
31 |
function addtoany_amp_additional_css_styles( $amp_template ) {
|
32 |
-
// CSS only
|
33 |
?>
|
34 |
.addtoany_list a {
|
35 |
padding: 0 4px;
|
@@ -49,15 +49,15 @@ add_action( 'wp_loaded', 'addtoany_priority_for_amp_jetpack' );
|
|
49 |
|
50 |
function addtoany_priority_for_amp_jetpack() {
|
51 |
// If the AMP plugin is enabled, the Jetpack plugin is enabled,
|
52 |
-
// and Jetpack's Related Posts module is enabled
|
53 |
if ( class_exists( 'AMP_Autoloader' ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'related-posts' ) ) {
|
54 |
-
// Change priority to 20
|
55 |
add_filter( 'addtoany_content_priority', function() { return 20; } );
|
56 |
}
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
-
* Move buttons from WooCommerce product description to WooCommerce's sharing block
|
61 |
*/
|
62 |
add_action( 'woocommerce_share', 'addtoany_woocommerce_share', 10 );
|
63 |
|
@@ -71,23 +71,23 @@ function addtoany_woocommerce_share() {
|
|
71 |
$post_type = get_post_type( get_the_ID() );
|
72 |
|
73 |
if (
|
74 |
-
// Private post
|
75 |
get_post_status( get_the_ID() ) == 'private' ||
|
76 |
-
// Sharing disabled on post
|
77 |
! empty( $sharing_disabled ) ||
|
78 |
-
// Custom post type (usually "product") disabled
|
79 |
( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' )
|
80 |
) {
|
81 |
return;
|
82 |
} else {
|
83 |
-
// If a Sharing Header is set
|
84 |
if ( ! empty( $options['header'] ) ) {
|
85 |
echo '<div class="addtoany_header">' . stripslashes( $options['header'] ) . '</div>';
|
86 |
} else {
|
87 |
$html_header = '';
|
88 |
}
|
89 |
|
90 |
-
// Display share buttons
|
91 |
ADDTOANY_SHARE_SAVE_KIT();
|
92 |
}
|
93 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Load theme compatibility functions.
|
5 |
*/
|
6 |
function addtoany_load_theme_compat() {
|
7 |
add_action( 'loop_start', 'addtoany_excerpt_remove' );
|
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 |
}
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
+
* Load AMP (Accelerated Mobile Pages) compatibility functions.
|
27 |
*/
|
28 |
|
29 |
add_action( 'amp_post_template_css', 'addtoany_amp_additional_css_styles' );
|
30 |
|
31 |
function addtoany_amp_additional_css_styles( $amp_template ) {
|
32 |
+
// CSS only.
|
33 |
?>
|
34 |
.addtoany_list a {
|
35 |
padding: 0 4px;
|
49 |
|
50 |
function addtoany_priority_for_amp_jetpack() {
|
51 |
// If the AMP plugin is enabled, the Jetpack plugin is enabled,
|
52 |
+
// and Jetpack's Related Posts module is enabled.
|
53 |
if ( class_exists( 'AMP_Autoloader' ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'related-posts' ) ) {
|
54 |
+
// Change priority to 20.
|
55 |
add_filter( 'addtoany_content_priority', function() { return 20; } );
|
56 |
}
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* Move buttons from WooCommerce product description to WooCommerce's sharing block.
|
61 |
*/
|
62 |
add_action( 'woocommerce_share', 'addtoany_woocommerce_share', 10 );
|
63 |
|
71 |
$post_type = get_post_type( get_the_ID() );
|
72 |
|
73 |
if (
|
74 |
+
// Private post.
|
75 |
get_post_status( get_the_ID() ) == 'private' ||
|
76 |
+
// Sharing disabled on post.
|
77 |
! empty( $sharing_disabled ) ||
|
78 |
+
// Custom post type (usually "product") disabled.
|
79 |
( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' )
|
80 |
) {
|
81 |
return;
|
82 |
} else {
|
83 |
+
// If a Sharing Header is set.
|
84 |
if ( ! empty( $options['header'] ) ) {
|
85 |
echo '<div class="addtoany_header">' . stripslashes( $options['header'] ) . '</div>';
|
86 |
} else {
|
87 |
$html_header = '';
|
88 |
}
|
89 |
|
90 |
+
// Display share buttons.
|
91 |
ADDTOANY_SHARE_SAVE_KIT();
|
92 |
}
|
93 |
}
|
addtoany.update.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Migrate old AddToAny options
|
5 |
*/
|
6 |
function addtoany_update_options() {
|
7 |
|
@@ -16,7 +16,7 @@ function addtoany_update_options() {
|
|
16 |
|
17 |
// If old button enabled
|
18 |
if ( ! empty( $options_old['button'] ) && in_array( $options_old['button'], $old_buttons) ) {
|
19 |
-
// Switch to custom button URL
|
20 |
$options_new['button'] = 'CUSTOM';
|
21 |
$options_new['button_custom'] = 'https://static.addtoany.com/buttons/' . current( explode( '|', $options_old['button'] ) );
|
22 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Migrate old AddToAny options.
|
5 |
*/
|
6 |
function addtoany_update_options() {
|
7 |
|
16 |
|
17 |
// If old button enabled
|
18 |
if ( ! empty( $options_old['button'] ) && in_array( $options_old['button'], $old_buttons) ) {
|
19 |
+
// Switch to custom button URL.
|
20 |
$options_new['button'] = 'CUSTOM';
|
21 |
$options_new['button_custom'] = 'https://static.addtoany.com/buttons/' . current( explode( '|', $options_old['button'] ) );
|
22 |
}
|
addtoany.widgets.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
*/
|
12 |
class A2A_SHARE_SAVE_Widget extends WP_Widget {
|
13 |
|
14 |
-
/**
|
15 |
function __construct() {
|
16 |
$widget_ops = array(
|
17 |
'description' => 'Share buttons for sharing your content.',
|
@@ -30,7 +30,7 @@ class A2A_SHARE_SAVE_Widget extends WP_Widget {
|
|
30 |
wp_enqueue_script( 'addtoany-widget-init', plugins_url( 'addtoany.admin.js', __FILE__ ), array(), '0.1', true );
|
31 |
}
|
32 |
|
33 |
-
/** Backwards compatibility for A2A_SHARE_SAVE_Widget::display(); usage */
|
34 |
public function display( $args = false ) {
|
35 |
self::widget( $args, NULL );
|
36 |
}
|
@@ -99,7 +99,7 @@ class A2A_SHARE_SAVE_Widget extends WP_Widget {
|
|
99 |
*/
|
100 |
class A2A_Follow_Widget extends WP_Widget {
|
101 |
|
102 |
-
/**
|
103 |
function __construct() {
|
104 |
$widget_ops = array(
|
105 |
'description' => 'Follow buttons link to your social media.',
|
@@ -146,12 +146,12 @@ class A2A_Follow_Widget extends WP_Widget {
|
|
146 |
|
147 |
$active_services = array();
|
148 |
|
149 |
-
// See which services have IDs set
|
150 |
$services = $this->get_follow_services();
|
151 |
foreach ( $services as $code => $service ) {
|
152 |
$code_id = $code . '_id';
|
153 |
if ( ! empty( $instance[ $code_id ] ) ) {
|
154 |
-
// Set ID value
|
155 |
$active_services[ $code ] = array( 'id' => $instance[ $code_id ] );
|
156 |
}
|
157 |
}
|
@@ -174,7 +174,7 @@ class A2A_Follow_Widget extends WP_Widget {
|
|
174 |
$instance['title'] = sanitize_text_field( $new_instance['title'] );
|
175 |
$instance['icon_size'] = sanitize_text_field( $new_instance['icon_size'] );
|
176 |
|
177 |
-
// Accept service IDs
|
178 |
$services = $this->get_follow_services();
|
179 |
foreach ( $services as $code => $service ) {
|
180 |
$code_id = $code . '_id';
|
@@ -199,7 +199,7 @@ class A2A_Follow_Widget extends WP_Widget {
|
|
199 |
if ( ! empty( $instance['icon_size'] ) ) {
|
200 |
$icon_size = $instance['icon_size'];
|
201 |
} elseif ( ! empty( $options['icon_size'] ) ) {
|
202 |
-
// Fallback to standard icon size if saved
|
203 |
$icon_size = $options['icon_size'];
|
204 |
} else {
|
205 |
$icon_size = '32';
|
11 |
*/
|
12 |
class A2A_SHARE_SAVE_Widget extends WP_Widget {
|
13 |
|
14 |
+
/** Constructor */
|
15 |
function __construct() {
|
16 |
$widget_ops = array(
|
17 |
'description' => 'Share buttons for sharing your content.',
|
30 |
wp_enqueue_script( 'addtoany-widget-init', plugins_url( 'addtoany.admin.js', __FILE__ ), array(), '0.1', true );
|
31 |
}
|
32 |
|
33 |
+
/** Backwards compatibility for A2A_SHARE_SAVE_Widget::display(); usage. */
|
34 |
public function display( $args = false ) {
|
35 |
self::widget( $args, NULL );
|
36 |
}
|
99 |
*/
|
100 |
class A2A_Follow_Widget extends WP_Widget {
|
101 |
|
102 |
+
/** Constructor */
|
103 |
function __construct() {
|
104 |
$widget_ops = array(
|
105 |
'description' => 'Follow buttons link to your social media.',
|
146 |
|
147 |
$active_services = array();
|
148 |
|
149 |
+
// See which services have IDs set.
|
150 |
$services = $this->get_follow_services();
|
151 |
foreach ( $services as $code => $service ) {
|
152 |
$code_id = $code . '_id';
|
153 |
if ( ! empty( $instance[ $code_id ] ) ) {
|
154 |
+
// Set ID value.
|
155 |
$active_services[ $code ] = array( 'id' => $instance[ $code_id ] );
|
156 |
}
|
157 |
}
|
174 |
$instance['title'] = sanitize_text_field( $new_instance['title'] );
|
175 |
$instance['icon_size'] = sanitize_text_field( $new_instance['icon_size'] );
|
176 |
|
177 |
+
// Accept service IDs.
|
178 |
$services = $this->get_follow_services();
|
179 |
foreach ( $services as $code => $service ) {
|
180 |
$code_id = $code . '_id';
|
199 |
if ( ! empty( $instance['icon_size'] ) ) {
|
200 |
$icon_size = $instance['icon_size'];
|
201 |
} elseif ( ! empty( $options['icon_size'] ) ) {
|
202 |
+
// Fallback to standard icon size if saved.
|
203 |
$icon_size = $options['icon_size'];
|
204 |
} else {
|
205 |
$icon_size = '32';
|