Version Description
- Use the
wp_enqueue_scripts
action hook instead ofwp_print_styles
for the plugin's stylesheet - Use the
home_url()
instead of theHost
header when generating the current URL to be shared (thanks Paul)
Download this release
Release Info
Developer | micropat |
Plugin | AddToAny Share Buttons |
Version | 1.7.15 |
Comparing to | |
See all releases |
Code changes from version 1.7.14 to 1.7.15
- README.txt +919 -915
- add-to-any.php +1105 -1105
README.txt
CHANGED
@@ -1,916 +1,920 @@
|
|
1 |
-
=== AddToAny Share Buttons ===
|
2 |
-
Contributors: micropat, addtoany
|
3 |
-
Tags: AddToAny, share, sharing, social, share buttons, share button, social media, media, marketing, links, email, seo, woocommerce, google, linkedin, reddit, facebook, like, twitter, pinterest, whatsapp, instagram, youtube, share this, sharethis, feed, icons
|
4 |
-
Requires at least: 3.7
|
5 |
-
Tested up to: 4.8
|
6 |
-
Stable tag: 1.7.
|
7 |
-
|
8 |
-
Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp, many more, and follow icons too.
|
9 |
-
|
10 |
-
== Description ==
|
11 |
-
|
12 |
-
The AddToAny WordPress sharing plugin helps people share your posts and pages to any service, such as Facebook, Twitter, Pinterest, Google, WhatsApp, LinkedIn, Tumblr, Reddit, and over 100 more sharing and social media sites & apps.
|
13 |
-
|
14 |
-
AddToAny is the universal sharing platform, and AddToAny's plugin is the most popular share plugin for WordPress, making sites social media ready since 2006.
|
15 |
-
|
16 |
-
= Share Buttons & Follow Buttons =
|
17 |
-
|
18 |
-
* **Counters** — fast & official share counts in the same style
|
19 |
-
* **Floating** share buttons — responsive & customizable, vertical & horizontal
|
20 |
-
* **Vector** share & follow buttons (SVG icons)
|
21 |
-
* **Universal** Share Button and Smart Menu
|
22 |
-
* Individual share links and custom share icons
|
23 |
-
* Choose from over 100 services
|
24 |
-
* 3rd party buttons include the Facebook Like Button, Twitter Tweet Button, Pinterest Pin It Button, Google+ Share Button and Google +1 Button
|
25 |
-
* Universal email sharing makes it easy to share via Gmail, Yahoo! Mail, Outlook.com (Hotmail), AOL Mail, and any other web and native apps
|
26 |
-
|
27 |
-
<a href="https://www.addtoany.com/">Share Buttons</a> demo
|
28 |
-
|
29 |
-
= Custom Placement =
|
30 |
-
* Before content, after content, or before & after content
|
31 |
-
* Vertical Floating Share Bar, and Horizontal Floating Share Bar
|
32 |
-
* As a shortcode, or a widget within a theme's layout
|
33 |
-
* Programmatically with template tags
|
34 |
-
|
35 |
-
= Analytics Integration =
|
36 |
-
|
37 |
-
* Automatic Google Analytics integration (<a href="https://www.addtoany.com/ext/google_analytics/">access guide</a>) for sharing analytics
|
38 |
-
* Track shared links with Bitly, Google URL Shortener, and custom URL shorteners
|
39 |
-
* Display share counts on posts and pages
|
40 |
-
|
41 |
-
= WordPress Optimized =
|
42 |
-
|
43 |
-
* Loads asynchronously so your content always loads before or in parallel with AddToAny
|
44 |
-
* Supports theme features such as HTML5, widgets, infinite scroll, post formats
|
45 |
-
* Supports WooCommerce, multilingual sites, and multisite networks
|
46 |
-
* No signup, no login, no account necessary
|
47 |
-
|
48 |
-
= Mobile Optimized & Retina Ready =
|
49 |
-
|
50 |
-
* AddToAny gives users the choice in sharing from a service's native app or from a web app. For example, choose between Twitter's native app or Twitter's mobile web app
|
51 |
-
* Responsive Floating Share Buttons are mobile ready by default, and configurable breakpoints make floating buttons work with any theme
|
52 |
-
* AddToAny's SVG icons are super-lightweight and pixel-perfect at any size, and AddToAny's responsive share menu fits on all displays
|
53 |
-
* Automatic <a href="https://wordpress.org/plugins/amp/">AMP</a> (Accelerated Mobile Pages) support for social share buttons on AMP pages
|
54 |
-
|
55 |
-
= Customizable & Extensible =
|
56 |
-
|
57 |
-
* Choose exactly where you want AddToAny to appear
|
58 |
-
* Easily <a href="https://www.addtoany.com/buttons/customize/wordpress">customize sharing</a> on your WordPress site
|
59 |
-
* <a href="/plugins/add-to-any/faq/">Highly extensible</a> for developers and designers
|
60 |
-
* Custom icons let you use any icons at any location (media uploads directory, CDN, etc.)
|
61 |
-
* Many more publisher and user features
|
62 |
-
|
63 |
-
= Wide Support =
|
64 |
-
|
65 |
-
* Over 10 years of development
|
66 |
-
* Over 6 million downloads
|
67 |
-
* Translated into dozens of languages
|
68 |
-
* Ongoing support from the community
|
69 |
-
|
70 |
-
This plugin always strives to be the best WordPress plugin for sharing. Development is fueled by your praise and feedback.
|
71 |
-
|
72 |
-
<a href="https://www.addtoany.com/share#url=https%3A%2F%2Fwordpress.org%2Fplugins%2Fadd-to-any%2F&title=AddToAny%20Sharing%20Plugin%20for%20WordPress" title="Share">Share</a> this plugin
|
73 |
-
|
74 |
-
See also:
|
75 |
-
|
76 |
-
* The <a href="https://www.addtoany.com/buttons/">share buttons</a> for all platforms
|
77 |
-
* The <a href="https://www.addtoany.com/buttons/for/wordpress_com">share button for WordPress.com</a>
|
78 |
-
|
79 |
-
<a href="https://www.addtoany.com/blog/">AddToAny Blog</a> | <a href="https://www.addtoany.com/privacy">Privacy Policy</a>
|
80 |
-
|
81 |
-
== Installation ==
|
82 |
-
|
83 |
-
In WordPress:
|
84 |
-
|
85 |
-
1. Go to `Plugins` > `Add New` > search for `addtoany`
|
86 |
-
1. Press `Install Now` for the AddToAny plugin
|
87 |
-
1. Press `Activate Plugin`
|
88 |
-
|
89 |
-
Manual installation:
|
90 |
-
|
91 |
-
1. Upload the `add-to-any` directory to the `/wp-content/plugins/` directory
|
92 |
-
1. Activate the plugin through the `Plugins` menu in WordPress
|
93 |
-
|
94 |
-
WP-CLI installation:
|
95 |
-
|
96 |
-
1. `wp plugin install add-to-any --activate`
|
97 |
-
|
98 |
-
== Frequently Asked Questions ==
|
99 |
-
|
100 |
-
= Where are the options, and how can I customize the sharing plugin? =
|
101 |
-
|
102 |
-
In WordPress, go to `Settings` > `AddToAny`.
|
103 |
-
|
104 |
-
Setup Follow buttons (like Instagram, YouTube, etc.) using the AddToAny Follow widget in `Appearance` > `Widgets` (or `Appearance` > `Customize`).
|
105 |
-
|
106 |
-
To further customize AddToAny, see the <a href="https://www.addtoany.com/buttons/customize/wordpress">WordPress sharing documentation</a> for the AddToAny plugin. Many customizations will have you copy & paste one or more lines of code into your "Additional JavaScript" or "Additional CSS" box. Those boxes are in `Settings` > `AddToAny`.
|
107 |
-
|
108 |
-
= Something is wrong. What should I try first? =
|
109 |
-
|
110 |
-
Try temporarily switching themes and deactivating other plugins to identify a potential conflict. If you find a conflict, try contacting that theme or plugin author. If an issue persists on a default theme with all other plugins deactivated, search the WordPress plugin's <a href="https://wordpress.org/support/plugin/add-to-any/">support forum</a>.
|
111 |
-
|
112 |
-
Feel free to <a href="https://wordpress.org/support/plugin/add-to-any">post here</a>, where the community can hopefully help you. Describe the issue, what troubleshooting you have already done, provide a link to your site, and any other potentially relevant information.
|
113 |
-
|
114 |
-
= The share buttons are not displaying for me. Why, and what should I try? =
|
115 |
-
|
116 |
-
Something on your own device/browser/connection is likely filtering out major social buttons.
|
117 |
-
|
118 |
-
Try another web browser, device, and/or Internet connection to see if the buttons appear. Tools like browserling.com or browserstack.com will give you an idea of what other people are seeing. The usual cause for this uncommon issue is 3rd party browser add-on software that blocks ads and optionally filters out major social buttons. Some security apps and Internet connections have an option to filter social buttons. Usually a social filter option is disabled by default, but if you find that some software is inappropriately filtering AddToAny buttons, <a href="https://www.addtoany.com/contact/">let AddToAny know</a>.
|
119 |
-
|
120 |
-
= What is the shortcode for sharing? =
|
121 |
-
|
122 |
-
You can place your share buttons exactly where you want them by inserting the following shortcode:
|
123 |
-
|
124 |
-
`[addtoany]`
|
125 |
-
|
126 |
-
Customize the shared URL like so:
|
127 |
-
|
128 |
-
`[addtoany url="https://www.example.com/page.html" title="Some Example Page"]`
|
129 |
-
|
130 |
-
Display specific share buttons by specifying comma-separated <a href="https://www.addtoany.com/services/">service codes</a>:
|
131 |
-
|
132 |
-
`[addtoany buttons="facebook,twitter,google_plus"]`
|
133 |
-
|
134 |
-
Share a specific image or video to certain services that accept arbitrary media (Pinterest, Yummly):
|
135 |
-
|
136 |
-
`[addtoany buttons="pinterest,yummly" media="https://www.example.com/media/picture.jpg"]`
|
137 |
-
|
138 |
-
= For Facebook sharing, how can I set the thumbnail image and description Facebook uses? =
|
139 |
-
|
140 |
-
Facebook expects the Title, Description, and Thumbnail of a shared page to be defined in the Open Graph <a href="https://www.addtoany.com/ext/meta-tags/" target="_blank">meta tags</a> of a shared page.
|
141 |
-
|
142 |
-
Use Facebook's <a href="https://developers.facebook.com/tools/debug/sharing/" target="_blank">Sharing Debugger</a> on your pages to see how Facebook reads your site. "Scrape Again" to test site changes and clear Facebook's cache of a page, or use the <a href="https://developers.facebook.com/tools/debug/sharing/batch/" target="_blank">Batch Invalidator</a> to purge Facebook's cache of multiple URLs.
|
143 |
-
|
144 |
-
To change the title, description and/or image on Facebook, your theme's header file should be modified according to <a href="https://developers.facebook.com/docs/sharing/opengraph" target="_blank">Facebook's OpenGraph specification</a>. With WordPress, this can be accomplished with plugins such as <a href="https://wordpress.org/plugins/wordpress-seo/">Yoast SEO</a> or the Social Meta feature of the <a href="https://wordpress.org/plugins/all-in-one-seo-pack/">All in One SEO Pack</a>. Please see those plugins for details, and post in the WordPress or plugin author's forums for more support.
|
145 |
-
|
146 |
-
For more technical information on setting your pages up for Facebook sharing, see "Sharing Best Practices for Websites" in <a href="https://developers.facebook.com/docs/sharing/best-practices">Facebook's documentation</a>.
|
147 |
-
|
148 |
-
= Why do share links route through AddToAny? =
|
149 |
-
|
150 |
-
Since 2006, AddToAny is trusted across the web to always route to each service's current endpoint. This routing enables publisher customization, visitor personalization, and keeps the AddToAny plugin remarkably lightweight without the need for constant plugin updates. In AddToAny menus, visitors see the services they actually use. On mobile, AddToAny presents the choice of sharing to a service's native app or mobile site and the preference is used on the next share. Publishers take advantage of AddToAny services such as <a href="https://www.addtoany.com/buttons/customize/wordpress/email_template">email templates</a>, <a href="https://www.addtoany.com/buttons/customize/wordpress/twitter_message">Twitter templates</a>, <a href="https://www.addtoany.com/buttons/customize/wordpress/link_tracking">URL shortener & parameters</a>, and more. Just as service icons change, service endpoints change too, and AddToAny is updated daily to reflect service endpoint and API changes.
|
151 |
-
|
152 |
-
= How can I use custom icons? =
|
153 |
-
|
154 |
-
Upload sharing icons in a single directory to a public location, and make sure the icon filenames match the icon filenames packaged in the AddToAny plugin. In WordPress, go to `Settings` > `AddToAny` > `Advanced Options` > check the "Use custom icons" checkbox and specify the URL to your custom icons directory (including the trailing `/`). For AddToAny's universal button, go to Universal Button, select `Image URL` and specify the exact location of your AddToAny universal share icon (including the filename).
|
155 |
-
|
156 |
-
= How can I place the share buttons in a specific area of my site? =
|
157 |
-
|
158 |
-
In the Theme Editor (or another code editor), place this code block where you want the button and individual icons to appear in your theme:
|
159 |
-
|
160 |
-
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>`
|
161 |
-
|
162 |
-
You can specify [AddToAny service code(s)](https://www.addtoany.com/services/) to show specific share buttons, for example:
|
163 |
-
|
164 |
-
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
165 |
-
ADDTOANY_SHARE_SAVE_KIT( array(
|
166 |
-
'buttons' => array( 'facebook', 'twitter', 'google_plus', 'whatsapp' ),
|
167 |
-
) );
|
168 |
-
} ?>`
|
169 |
-
|
170 |
-
To customize the shared URL and title:
|
171 |
-
|
172 |
-
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
173 |
-
ADDTOANY_SHARE_SAVE_KIT( array(
|
174 |
-
'linkname' => 'Example Page',
|
175 |
-
'linkurl' => 'https://example.com/page.html',
|
176 |
-
) );
|
177 |
-
} ?>`
|
178 |
-
|
179 |
-
To share the current URL and title (detected on the client-side):
|
180 |
-
|
181 |
-
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
182 |
-
ADDTOANY_SHARE_SAVE_KIT( array( 'use_current_page' => true ) );
|
183 |
-
} ?>`
|
184 |
-
|
185 |
-
To hardcode the shared current URL and modify the title (server-side):
|
186 |
-
|
187 |
-
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
188 |
-
ADDTOANY_SHARE_SAVE_KIT( array(
|
189 |
-
'linkname' => is_home() ? get_bloginfo( 'description' ) : wp_title( '', false ),
|
190 |
-
'linkurl' => esc_url_raw( (
|
191 |
-
) );
|
192 |
-
} ?>`
|
193 |
-
|
194 |
-
To share a specific image or video to certain services that accept arbitrary media (Pinterest, Yummly):
|
195 |
-
|
196 |
-
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
197 |
-
ADDTOANY_SHARE_SAVE_KIT( array(
|
198 |
-
'buttons' => array( 'pinterest', 'yummly' ),
|
199 |
-
'linkmedia' => 'https://www.example.com/media/picture.jpg',
|
200 |
-
'linkname' => 'Example Page',
|
201 |
-
'linkurl' => 'https://www.example.com/page.html',
|
202 |
-
) );
|
203 |
-
} ?>`
|
204 |
-
|
205 |
-
= How can I place the follow buttons in a specific area of my site? =
|
206 |
-
|
207 |
-
See the [supported follow services](https://www.addtoany.com/buttons/customize/follow_buttons) for service code names, then place this example code in your theme's file(s) where you want the follow buttons to appear:
|
208 |
-
|
209 |
-
`<?php if ( function_exists( 'ADDTOANY_FOLLOW_KIT' ) ) {
|
210 |
-
ADDTOANY_FOLLOW_KIT( array(
|
211 |
-
'buttons' => array(
|
212 |
-
'facebook' => array( 'id' => 'zuck' ),
|
213 |
-
'instagram' => array( 'id' => 'kevin' ),
|
214 |
-
'twitter' => array( 'id' => 'jack' ),
|
215 |
-
),
|
216 |
-
) );
|
217 |
-
} ?>`
|
218 |
-
|
219 |
-
= How can I add a custom standalone share button? =
|
220 |
-
You can create a plugin or customize the following example PHP code to add to your theme's functions.php file:
|
221 |
-
|
222 |
-
`function addtoany_add_share_services( $services ) {
|
223 |
-
$services['example_share_service'] = array(
|
224 |
-
'name' => 'Example Share Service',
|
225 |
-
'icon_url' => 'https://www.example.com/my-icon.svg',
|
226 |
-
'icon_width' => 32,
|
227 |
-
'icon_height' => 32,
|
228 |
-
'href' => 'https://www.example.com/share?url=A2A_LINKURL&title=A2A_LINKNAME',
|
229 |
-
);
|
230 |
-
return $services;
|
231 |
-
}
|
232 |
-
add_filter( 'A2A_SHARE_SAVE_services', 'addtoany_add_share_services', 10, 1 );`
|
233 |
-
|
234 |
-
= How can I add a custom follow button? =
|
235 |
-
You can create a plugin or customize the following example PHP code to add to your theme's functions.php file:
|
236 |
-
|
237 |
-
`function addtoany_add_follow_services( $services ) {
|
238 |
-
$services['example_follow_service'] = array(
|
239 |
-
'name' => 'Example Follow Service',
|
240 |
-
'icon_url' => 'https://www.example.com/my-icon.svg',
|
241 |
-
'icon_width' => 32,
|
242 |
-
'icon_height' => 32,
|
243 |
-
'href' => 'https://www.example.com/ID',
|
244 |
-
);
|
245 |
-
return $services;
|
246 |
-
}
|
247 |
-
add_filter( 'A2A_FOLLOW_services', 'addtoany_add_follow_services', 10, 1 );`
|
248 |
-
|
249 |
-
= How can I align the standard sharing buttons to the center or to the right side of posts? =
|
250 |
-
It depends on your theme, but you can try adding the following CSS code to your Additional CSS box in Settings > AddToAny.
|
251 |
-
|
252 |
-
To align right:
|
253 |
-
|
254 |
-
`.addtoany_share_save_container { text-align:right; }`
|
255 |
-
|
256 |
-
To align center:
|
257 |
-
|
258 |
-
`.addtoany_share_save_container { text-align:center; }`
|
259 |
-
|
260 |
-
= How can I remove the button(s) from individual posts and pages? =
|
261 |
-
|
262 |
-
When editing a post or page, uncheck "Show sharing buttons", which is located at the bottom of the editor page. Be sure to update or publish to save your changes.
|
263 |
-
|
264 |
-
An older method was to insert the following tag into the page or post (HTML tab) that you do not want the button(s) to appear in: `<!--nosharesave-->`
|
265 |
-
|
266 |
-
= How can I force the button(s) to appear in individual posts and pages? =
|
267 |
-
|
268 |
-
When editing a post or page, check the "Show sharing buttons" checkbox, which is located at the bottom of the editor page. Be sure to update or publish to save your changes. Note that, by default, AddToAny is setup to display on all posts and pages.
|
269 |
-
|
270 |
-
An older method was to insert the following tag into the page or post (HTML tab) that you want the button(s) to appear in: `<!--sharesave-->`
|
271 |
-
|
272 |
-
= How can I remove the button(s) from category pages, or tag/author/date/search pages? =
|
273 |
-
|
274 |
-
Go to `Settings` > `AddToAny` > uncheck `Display at the top or bottom of posts on archive pages`. Archive pages include Category, Tag, Author, Date, and also Search pages.
|
275 |
-
|
276 |
-
= How can I programmatically remove the button(s)? =
|
277 |
-
|
278 |
-
In your theme's `functions.php`, you can add a filter to disable AddToAny sharing.
|
279 |
-
|
280 |
-
Disable AddToAny sharing in specific categories, for example:
|
281 |
-
|
282 |
-
`function addtoany_disable_sharing_in_some_categories() {
|
283 |
-
// Examples of in_category usage: https://codex.wordpress.org/Function_Reference/in_category
|
284 |
-
if ( in_category( array( 'my_category_1_slug', 'my_category_2_slug' ) ) ) {
|
285 |
-
return true;
|
286 |
-
}
|
287 |
-
}
|
288 |
-
add_filter( 'addtoany_sharing_disabled', 'addtoany_disable_sharing_in_some_categories' );`
|
289 |
-
|
290 |
-
Disable AddToAny sharing on a custom post type, for example:
|
291 |
-
|
292 |
-
`function addtoany_disable_sharing_on_my_custom_post_type() {
|
293 |
-
if ( 'my_custom_post_type' == get_post_type() ) {
|
294 |
-
return true;
|
295 |
-
}
|
296 |
-
}
|
297 |
-
add_filter( 'addtoany_sharing_disabled', 'addtoany_disable_sharing_on_my_custom_post_type' );`
|
298 |
-
|
299 |
-
= How can I position a vertical floating share buttons bar relative to content? =
|
300 |
-
|
301 |
-
In settings, disable the default placement of the Vertical Buttons. In your theme's file(s), find the parent element that you want to position the vertical bar to (the parent element should have a specified width), then add the following example PHP code as a child of that parent element:
|
302 |
-
|
303 |
-
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_FLOATING' ) ) {
|
304 |
-
ADDTOANY_SHARE_SAVE_FLOATING( array(
|
305 |
-
'kit_style' => 'margin-left:-100px; top:150px;',
|
306 |
-
'vertical_type' => true,
|
307 |
-
) );
|
308 |
-
} ?>`
|
309 |
-
|
310 |
-
= Why does the Facebook Like Button, Pinterest Pin It Button, Google+ Share Button, or Google +1 Button have so much whitespace to the right of it? =
|
311 |
-
|
312 |
-
The minimum width for the Facebook Like Button is 90 pixels. This is required to display the total number of Likes to the right of the button. See Facebook's <a href="https://developers.facebook.com/docs/plugins/like-button">Like Button documentation</a> for details
|
313 |
-
|
314 |
-
It's not recommended, but you can change the width of the Facebook Like Button using CSS code, for instance: `.a2a_button_facebook_like { width:50px !important; }`
|
315 |
-
|
316 |
-
The Pinterest Pin It Button with 'show count' enabled is 76 pixels. You can change the width using CSS code, for instance: `.a2a_button_pinterest_pin { width:90px !important; }`
|
317 |
-
|
318 |
-
The Google +1 Button with 'show count' enabled is 90 pixels. You can change the width using CSS code, for instance: `.a2a_button_google_plusone { width:65px !important; }`
|
319 |
-
|
320 |
-
The Google+ Share Button width can be changed using CSS code, for instance: `.a2a_button_google_plus_share { width:57px !important; }`
|
321 |
-
|
322 |
-
= Does the plugin output W3C valid code? =
|
323 |
-
|
324 |
-
Yes, this plugin outputs 100% W3C valid HTML5 and W3C valid CSS 3 by default.
|
325 |
-
|
326 |
-
= How can I load the buttons after content insertion with Ajax and infinite scroll? =
|
327 |
-
|
328 |
-
AddToAny supports the <a href="https://codex.wordpress.org/AJAX_in_Plugins#The_post-load_JavaScript_Event">standard `post-load` event</a>.
|
329 |
-
|
330 |
-
Ajax and infinite scroll plugins/themes should always fire the `post-load` event after content insertion, so request <a href="https://codex.wordpress.org/AJAX_in_Plugins#The_post-load_JavaScript_Event">standard `post-load` support</a> from plugin & theme authors as needed.
|
331 |
-
|
332 |
-
Use the following line to dispatch the `post-load` event for AddToAny and other plugins:
|
333 |
-
|
334 |
-
`jQuery( 'body' ).trigger( 'post-load' );`
|
335 |
-
|
336 |
-
= How can I set the plugin as a "Must-Use" plugin that is autoloaded and activated for all sites? =
|
337 |
-
|
338 |
-
Upload (or move) the `add-to-any` plugin directory into the `/wp-content/mu-plugins/` directory. Then create a proxy PHP loader file (such as `load.php`) in your `mu-plugins` directory, for example:
|
339 |
-
|
340 |
-
`<?php require WPMU_PLUGIN_DIR . '/add-to-any/add-to-any.php';`
|
341 |
-
|
342 |
-
== Screenshots ==
|
343 |
-
|
344 |
-
1. AddToAny vector share buttons (SVG icons) are pixel-perfect and customizable
|
345 |
-
2. Mini share menu that drops down when visitors use the universal share button
|
346 |
-
3. Full universal share menu modal that includes all services
|
347 |
-
4. Settings for Standard Share Buttons
|
348 |
-
5. Settings for Floating Share Bars
|
349 |
-
|
350 |
-
== Changelog ==
|
351 |
-
|
352 |
-
= 1.7.
|
353 |
-
*
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
*
|
362 |
-
*
|
363 |
-
|
364 |
-
= 1.7.
|
365 |
-
*
|
366 |
-
*
|
367 |
-
|
368 |
-
|
369 |
-
*
|
370 |
-
|
371 |
-
|
372 |
-
*
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
*
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
*
|
381 |
-
*
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
*
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
*
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
*
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
*
|
403 |
-
|
404 |
-
|
405 |
-
*
|
406 |
-
|
407 |
-
|
408 |
-
*
|
409 |
-
*
|
410 |
-
|
411 |
-
= 1.7.
|
412 |
-
*
|
413 |
-
*
|
414 |
-
|
415 |
-
|
416 |
-
*
|
417 |
-
|
418 |
-
|
419 |
-
*
|
420 |
-
*
|
421 |
-
|
422 |
-
|
423 |
-
* AddToAny
|
424 |
-
*
|
425 |
-
*
|
426 |
-
*
|
427 |
-
*
|
428 |
-
* Add
|
429 |
-
*
|
430 |
-
|
431 |
-
|
432 |
-
*
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
*
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
*
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
*
|
445 |
-
|
446 |
-
|
447 |
-
*
|
448 |
-
*
|
449 |
-
*
|
450 |
-
*
|
451 |
-
* Add
|
452 |
-
|
453 |
-
|
454 |
-
*
|
455 |
-
*
|
456 |
-
|
457 |
-
= 1.6.
|
458 |
-
*
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
* Fix
|
463 |
-
|
464 |
-
|
465 |
-
*
|
466 |
-
*
|
467 |
-
*
|
468 |
-
|
469 |
-
|
470 |
-
*
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
*
|
475 |
-
*
|
476 |
-
*
|
477 |
-
|
478 |
-
|
479 |
-
*
|
480 |
-
*
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
*
|
485 |
-
*
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
*
|
491 |
-
*
|
492 |
-
|
493 |
-
|
494 |
-
*
|
495 |
-
*
|
496 |
-
|
497 |
-
|
498 |
-
*
|
499 |
-
*
|
500 |
-
|
501 |
-
|
502 |
-
*
|
503 |
-
*
|
504 |
-
*
|
505 |
-
*
|
506 |
-
|
507 |
-
|
508 |
-
*
|
509 |
-
* Remove
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
*
|
514 |
-
*
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
*
|
520 |
-
*
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
*
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
*
|
529 |
-
|
530 |
-
|
531 |
-
*
|
532 |
-
*
|
533 |
-
|
534 |
-
|
535 |
-
*
|
536 |
-
|
537 |
-
|
538 |
-
*
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
*
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
*
|
549 |
-
|
550 |
-
|
551 |
-
=
|
552 |
-
*
|
553 |
-
*
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
*
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
*
|
562 |
-
|
563 |
-
|
564 |
-
*
|
565 |
-
* Remove
|
566 |
-
|
567 |
-
|
568 |
-
*
|
569 |
-
|
570 |
-
|
571 |
-
*
|
572 |
-
*
|
573 |
-
|
574 |
-
= 1.5.
|
575 |
-
*
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
*
|
585 |
-
*
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
*
|
591 |
-
*
|
592 |
-
*
|
593 |
-
|
594 |
-
|
595 |
-
*
|
596 |
-
*
|
597 |
-
|
598 |
-
= 1.5.
|
599 |
-
*
|
600 |
-
*
|
601 |
-
|
602 |
-
|
603 |
-
*
|
604 |
-
|
605 |
-
|
606 |
-
*
|
607 |
-
*
|
608 |
-
|
609 |
-
|
610 |
-
*
|
611 |
-
*
|
612 |
-
|
613 |
-
|
614 |
-
*
|
615 |
-
*
|
616 |
-
|
617 |
-
= 1.4 =
|
618 |
-
*
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
*
|
625 |
-
*
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
*
|
631 |
-
*
|
632 |
-
|
633 |
-
= 1.3.
|
634 |
-
*
|
635 |
-
*
|
636 |
-
|
637 |
-
|
638 |
-
*
|
639 |
-
*
|
640 |
-
|
641 |
-
|
642 |
-
*
|
643 |
-
*
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
*
|
649 |
-
*
|
650 |
-
|
651 |
-
= 1.3.
|
652 |
-
* Fix
|
653 |
-
*
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
*
|
659 |
-
*
|
660 |
-
|
661 |
-
|
662 |
-
*
|
663 |
-
|
664 |
-
|
665 |
-
*
|
666 |
-
*
|
667 |
-
|
668 |
-
= 1.3.
|
669 |
-
*
|
670 |
-
*
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
*
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
*
|
679 |
-
|
680 |
-
|
681 |
-
*
|
682 |
-
|
683 |
-
|
684 |
-
*
|
685 |
-
*
|
686 |
-
|
687 |
-
= 1.2.9.
|
688 |
-
*
|
689 |
-
*
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
*
|
694 |
-
* Update
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
*
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
*
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
*
|
712 |
-
|
713 |
-
= 1.2.8.
|
714 |
-
*
|
715 |
-
* Add
|
716 |
-
|
717 |
-
= 1.2.8.
|
718 |
-
*
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
*
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
*
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
*
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
*
|
742 |
-
* Update
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
* Add
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
*
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
*
|
764 |
-
|
765 |
-
= 1.2.7.
|
766 |
-
*
|
767 |
-
*
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
*
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
*
|
776 |
-
*
|
777 |
-
|
778 |
-
|
779 |
-
*
|
780 |
-
|
781 |
-
|
782 |
-
= 1.2.
|
783 |
-
*
|
784 |
-
*
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
* Add
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
* Add
|
794 |
-
|
795 |
-
= 1.2.
|
796 |
-
*
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
*
|
808 |
-
*
|
809 |
-
*
|
810 |
-
*
|
811 |
-
*
|
812 |
-
*
|
813 |
-
*
|
814 |
-
|
815 |
-
|
816 |
-
*
|
817 |
-
*
|
818 |
-
|
819 |
-
|
820 |
-
*
|
821 |
-
*
|
822 |
-
* Update
|
823 |
-
* Update
|
824 |
-
* Update
|
825 |
-
*
|
826 |
-
|
827 |
-
|
828 |
-
*
|
829 |
-
*
|
830 |
-
|
831 |
-
= 1.1.
|
832 |
-
* Fix
|
833 |
-
*
|
834 |
-
|
835 |
-
= 1.1.
|
836 |
-
* Fix
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
*
|
844 |
-
*
|
845 |
-
*
|
846 |
-
|
847 |
-
|
848 |
-
*
|
849 |
-
*
|
850 |
-
|
851 |
-
|
852 |
-
* Add
|
853 |
-
* Add
|
854 |
-
*
|
855 |
-
*
|
856 |
-
*
|
857 |
-
*
|
858 |
-
*
|
859 |
-
*
|
860 |
-
*
|
861 |
-
* Remove
|
862 |
-
|
863 |
-
|
864 |
-
*
|
865 |
-
*
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
* Update
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
* Update
|
875 |
-
|
876 |
-
= 1.0.
|
877 |
-
*
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
*
|
882 |
-
|
883 |
-
|
884 |
-
*
|
885 |
-
|
886 |
-
|
887 |
-
*
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
916 |
Â
Floating Share Buttons are now available! Click the "Floating" tab in Settings > AddToAny.
|
1 |
+
=== AddToAny Share Buttons ===
|
2 |
+
Contributors: micropat, addtoany
|
3 |
+
Tags: AddToAny, share, sharing, social, share buttons, share button, social media, media, marketing, links, email, seo, woocommerce, google, linkedin, reddit, facebook, like, twitter, pinterest, whatsapp, instagram, youtube, share this, sharethis, feed, icons
|
4 |
+
Requires at least: 3.7
|
5 |
+
Tested up to: 4.8
|
6 |
+
Stable tag: 1.7.15
|
7 |
+
|
8 |
+
Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp, many more, and follow icons too.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
The AddToAny WordPress sharing plugin helps people share your posts and pages to any service, such as Facebook, Twitter, Pinterest, Google, WhatsApp, LinkedIn, Tumblr, Reddit, and over 100 more sharing and social media sites & apps.
|
13 |
+
|
14 |
+
AddToAny is the universal sharing platform, and AddToAny's plugin is the most popular share plugin for WordPress, making sites social media ready since 2006.
|
15 |
+
|
16 |
+
= Share Buttons & Follow Buttons =
|
17 |
+
|
18 |
+
* **Counters** — fast & official share counts in the same style
|
19 |
+
* **Floating** share buttons — responsive & customizable, vertical & horizontal
|
20 |
+
* **Vector** share & follow buttons (SVG icons)
|
21 |
+
* **Universal** Share Button and Smart Menu
|
22 |
+
* Individual share links and custom share icons
|
23 |
+
* Choose from over 100 services
|
24 |
+
* 3rd party buttons include the Facebook Like Button, Twitter Tweet Button, Pinterest Pin It Button, Google+ Share Button and Google +1 Button
|
25 |
+
* Universal email sharing makes it easy to share via Gmail, Yahoo! Mail, Outlook.com (Hotmail), AOL Mail, and any other web and native apps
|
26 |
+
|
27 |
+
<a href="https://www.addtoany.com/">Share Buttons</a> demo
|
28 |
+
|
29 |
+
= Custom Placement =
|
30 |
+
* Before content, after content, or before & after content
|
31 |
+
* Vertical Floating Share Bar, and Horizontal Floating Share Bar
|
32 |
+
* As a shortcode, or a widget within a theme's layout
|
33 |
+
* Programmatically with template tags
|
34 |
+
|
35 |
+
= Analytics Integration =
|
36 |
+
|
37 |
+
* Automatic Google Analytics integration (<a href="https://www.addtoany.com/ext/google_analytics/">access guide</a>) for sharing analytics
|
38 |
+
* Track shared links with Bitly, Google URL Shortener, and custom URL shorteners
|
39 |
+
* Display share counts on posts and pages
|
40 |
+
|
41 |
+
= WordPress Optimized =
|
42 |
+
|
43 |
+
* Loads asynchronously so your content always loads before or in parallel with AddToAny
|
44 |
+
* Supports theme features such as HTML5, widgets, infinite scroll, post formats
|
45 |
+
* Supports WooCommerce, multilingual sites, and multisite networks
|
46 |
+
* No signup, no login, no account necessary
|
47 |
+
|
48 |
+
= Mobile Optimized & Retina Ready =
|
49 |
+
|
50 |
+
* AddToAny gives users the choice in sharing from a service's native app or from a web app. For example, choose between Twitter's native app or Twitter's mobile web app
|
51 |
+
* Responsive Floating Share Buttons are mobile ready by default, and configurable breakpoints make floating buttons work with any theme
|
52 |
+
* AddToAny's SVG icons are super-lightweight and pixel-perfect at any size, and AddToAny's responsive share menu fits on all displays
|
53 |
+
* Automatic <a href="https://wordpress.org/plugins/amp/">AMP</a> (Accelerated Mobile Pages) support for social share buttons on AMP pages
|
54 |
+
|
55 |
+
= Customizable & Extensible =
|
56 |
+
|
57 |
+
* Choose exactly where you want AddToAny to appear
|
58 |
+
* Easily <a href="https://www.addtoany.com/buttons/customize/wordpress">customize sharing</a> on your WordPress site
|
59 |
+
* <a href="/plugins/add-to-any/faq/">Highly extensible</a> for developers and designers
|
60 |
+
* Custom icons let you use any icons at any location (media uploads directory, CDN, etc.)
|
61 |
+
* Many more publisher and user features
|
62 |
+
|
63 |
+
= Wide Support =
|
64 |
+
|
65 |
+
* Over 10 years of development
|
66 |
+
* Over 6 million downloads
|
67 |
+
* Translated into dozens of languages
|
68 |
+
* Ongoing support from the community
|
69 |
+
|
70 |
+
This plugin always strives to be the best WordPress plugin for sharing. Development is fueled by your praise and feedback.
|
71 |
+
|
72 |
+
<a href="https://www.addtoany.com/share#url=https%3A%2F%2Fwordpress.org%2Fplugins%2Fadd-to-any%2F&title=AddToAny%20Sharing%20Plugin%20for%20WordPress" title="Share">Share</a> this plugin
|
73 |
+
|
74 |
+
See also:
|
75 |
+
|
76 |
+
* The <a href="https://www.addtoany.com/buttons/">share buttons</a> for all platforms
|
77 |
+
* The <a href="https://www.addtoany.com/buttons/for/wordpress_com">share button for WordPress.com</a>
|
78 |
+
|
79 |
+
<a href="https://www.addtoany.com/blog/">AddToAny Blog</a> | <a href="https://www.addtoany.com/privacy">Privacy Policy</a>
|
80 |
+
|
81 |
+
== Installation ==
|
82 |
+
|
83 |
+
In WordPress:
|
84 |
+
|
85 |
+
1. Go to `Plugins` > `Add New` > search for `addtoany`
|
86 |
+
1. Press `Install Now` for the AddToAny plugin
|
87 |
+
1. Press `Activate Plugin`
|
88 |
+
|
89 |
+
Manual installation:
|
90 |
+
|
91 |
+
1. Upload the `add-to-any` directory to the `/wp-content/plugins/` directory
|
92 |
+
1. Activate the plugin through the `Plugins` menu in WordPress
|
93 |
+
|
94 |
+
WP-CLI installation:
|
95 |
+
|
96 |
+
1. `wp plugin install add-to-any --activate`
|
97 |
+
|
98 |
+
== Frequently Asked Questions ==
|
99 |
+
|
100 |
+
= Where are the options, and how can I customize the sharing plugin? =
|
101 |
+
|
102 |
+
In WordPress, go to `Settings` > `AddToAny`.
|
103 |
+
|
104 |
+
Setup Follow buttons (like Instagram, YouTube, etc.) using the AddToAny Follow widget in `Appearance` > `Widgets` (or `Appearance` > `Customize`).
|
105 |
+
|
106 |
+
To further customize AddToAny, see the <a href="https://www.addtoany.com/buttons/customize/wordpress">WordPress sharing documentation</a> for the AddToAny plugin. Many customizations will have you copy & paste one or more lines of code into your "Additional JavaScript" or "Additional CSS" box. Those boxes are in `Settings` > `AddToAny`.
|
107 |
+
|
108 |
+
= Something is wrong. What should I try first? =
|
109 |
+
|
110 |
+
Try temporarily switching themes and deactivating other plugins to identify a potential conflict. If you find a conflict, try contacting that theme or plugin author. If an issue persists on a default theme with all other plugins deactivated, search the WordPress plugin's <a href="https://wordpress.org/support/plugin/add-to-any/">support forum</a>.
|
111 |
+
|
112 |
+
Feel free to <a href="https://wordpress.org/support/plugin/add-to-any">post here</a>, where the community can hopefully help you. Describe the issue, what troubleshooting you have already done, provide a link to your site, and any other potentially relevant information.
|
113 |
+
|
114 |
+
= The share buttons are not displaying for me. Why, and what should I try? =
|
115 |
+
|
116 |
+
Something on your own device/browser/connection is likely filtering out major social buttons.
|
117 |
+
|
118 |
+
Try another web browser, device, and/or Internet connection to see if the buttons appear. Tools like browserling.com or browserstack.com will give you an idea of what other people are seeing. The usual cause for this uncommon issue is 3rd party browser add-on software that blocks ads and optionally filters out major social buttons. Some security apps and Internet connections have an option to filter social buttons. Usually a social filter option is disabled by default, but if you find that some software is inappropriately filtering AddToAny buttons, <a href="https://www.addtoany.com/contact/">let AddToAny know</a>.
|
119 |
+
|
120 |
+
= What is the shortcode for sharing? =
|
121 |
+
|
122 |
+
You can place your share buttons exactly where you want them by inserting the following shortcode:
|
123 |
+
|
124 |
+
`[addtoany]`
|
125 |
+
|
126 |
+
Customize the shared URL like so:
|
127 |
+
|
128 |
+
`[addtoany url="https://www.example.com/page.html" title="Some Example Page"]`
|
129 |
+
|
130 |
+
Display specific share buttons by specifying comma-separated <a href="https://www.addtoany.com/services/">service codes</a>:
|
131 |
+
|
132 |
+
`[addtoany buttons="facebook,twitter,google_plus"]`
|
133 |
+
|
134 |
+
Share a specific image or video to certain services that accept arbitrary media (Pinterest, Yummly):
|
135 |
+
|
136 |
+
`[addtoany buttons="pinterest,yummly" media="https://www.example.com/media/picture.jpg"]`
|
137 |
+
|
138 |
+
= For Facebook sharing, how can I set the thumbnail image and description Facebook uses? =
|
139 |
+
|
140 |
+
Facebook expects the Title, Description, and Thumbnail of a shared page to be defined in the Open Graph <a href="https://www.addtoany.com/ext/meta-tags/" target="_blank">meta tags</a> of a shared page.
|
141 |
+
|
142 |
+
Use Facebook's <a href="https://developers.facebook.com/tools/debug/sharing/" target="_blank">Sharing Debugger</a> on your pages to see how Facebook reads your site. "Scrape Again" to test site changes and clear Facebook's cache of a page, or use the <a href="https://developers.facebook.com/tools/debug/sharing/batch/" target="_blank">Batch Invalidator</a> to purge Facebook's cache of multiple URLs.
|
143 |
+
|
144 |
+
To change the title, description and/or image on Facebook, your theme's header file should be modified according to <a href="https://developers.facebook.com/docs/sharing/opengraph" target="_blank">Facebook's OpenGraph specification</a>. With WordPress, this can be accomplished with plugins such as <a href="https://wordpress.org/plugins/wordpress-seo/">Yoast SEO</a> or the Social Meta feature of the <a href="https://wordpress.org/plugins/all-in-one-seo-pack/">All in One SEO Pack</a>. Please see those plugins for details, and post in the WordPress or plugin author's forums for more support.
|
145 |
+
|
146 |
+
For more technical information on setting your pages up for Facebook sharing, see "Sharing Best Practices for Websites" in <a href="https://developers.facebook.com/docs/sharing/best-practices">Facebook's documentation</a>.
|
147 |
+
|
148 |
+
= Why do share links route through AddToAny? =
|
149 |
+
|
150 |
+
Since 2006, AddToAny is trusted across the web to always route to each service's current endpoint. This routing enables publisher customization, visitor personalization, and keeps the AddToAny plugin remarkably lightweight without the need for constant plugin updates. In AddToAny menus, visitors see the services they actually use. On mobile, AddToAny presents the choice of sharing to a service's native app or mobile site and the preference is used on the next share. Publishers take advantage of AddToAny services such as <a href="https://www.addtoany.com/buttons/customize/wordpress/email_template">email templates</a>, <a href="https://www.addtoany.com/buttons/customize/wordpress/twitter_message">Twitter templates</a>, <a href="https://www.addtoany.com/buttons/customize/wordpress/link_tracking">URL shortener & parameters</a>, and more. Just as service icons change, service endpoints change too, and AddToAny is updated daily to reflect service endpoint and API changes.
|
151 |
+
|
152 |
+
= How can I use custom icons? =
|
153 |
+
|
154 |
+
Upload sharing icons in a single directory to a public location, and make sure the icon filenames match the icon filenames packaged in the AddToAny plugin. In WordPress, go to `Settings` > `AddToAny` > `Advanced Options` > check the "Use custom icons" checkbox and specify the URL to your custom icons directory (including the trailing `/`). For AddToAny's universal button, go to Universal Button, select `Image URL` and specify the exact location of your AddToAny universal share icon (including the filename).
|
155 |
+
|
156 |
+
= How can I place the share buttons in a specific area of my site? =
|
157 |
+
|
158 |
+
In the Theme Editor (or another code editor), place this code block where you want the button and individual icons to appear in your theme:
|
159 |
+
|
160 |
+
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>`
|
161 |
+
|
162 |
+
You can specify [AddToAny service code(s)](https://www.addtoany.com/services/) to show specific share buttons, for example:
|
163 |
+
|
164 |
+
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
165 |
+
ADDTOANY_SHARE_SAVE_KIT( array(
|
166 |
+
'buttons' => array( 'facebook', 'twitter', 'google_plus', 'whatsapp' ),
|
167 |
+
) );
|
168 |
+
} ?>`
|
169 |
+
|
170 |
+
To customize the shared URL and title:
|
171 |
+
|
172 |
+
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
173 |
+
ADDTOANY_SHARE_SAVE_KIT( array(
|
174 |
+
'linkname' => 'Example Page',
|
175 |
+
'linkurl' => 'https://example.com/page.html',
|
176 |
+
) );
|
177 |
+
} ?>`
|
178 |
+
|
179 |
+
To share the current URL and title (detected on the client-side):
|
180 |
+
|
181 |
+
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
182 |
+
ADDTOANY_SHARE_SAVE_KIT( array( 'use_current_page' => true ) );
|
183 |
+
} ?>`
|
184 |
+
|
185 |
+
To hardcode the shared current URL and modify the title (server-side):
|
186 |
+
|
187 |
+
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
188 |
+
ADDTOANY_SHARE_SAVE_KIT( array(
|
189 |
+
'linkname' => is_home() ? get_bloginfo( 'description' ) : wp_title( '', false ),
|
190 |
+
'linkurl' => esc_url_raw( home_url( $_SERVER['REQUEST_URI'] ) ),
|
191 |
+
) );
|
192 |
+
} ?>`
|
193 |
+
|
194 |
+
To share a specific image or video to certain services that accept arbitrary media (Pinterest, Yummly):
|
195 |
+
|
196 |
+
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) {
|
197 |
+
ADDTOANY_SHARE_SAVE_KIT( array(
|
198 |
+
'buttons' => array( 'pinterest', 'yummly' ),
|
199 |
+
'linkmedia' => 'https://www.example.com/media/picture.jpg',
|
200 |
+
'linkname' => 'Example Page',
|
201 |
+
'linkurl' => 'https://www.example.com/page.html',
|
202 |
+
) );
|
203 |
+
} ?>`
|
204 |
+
|
205 |
+
= How can I place the follow buttons in a specific area of my site? =
|
206 |
+
|
207 |
+
See the [supported follow services](https://www.addtoany.com/buttons/customize/follow_buttons) for service code names, then place this example code in your theme's file(s) where you want the follow buttons to appear:
|
208 |
+
|
209 |
+
`<?php if ( function_exists( 'ADDTOANY_FOLLOW_KIT' ) ) {
|
210 |
+
ADDTOANY_FOLLOW_KIT( array(
|
211 |
+
'buttons' => array(
|
212 |
+
'facebook' => array( 'id' => 'zuck' ),
|
213 |
+
'instagram' => array( 'id' => 'kevin' ),
|
214 |
+
'twitter' => array( 'id' => 'jack' ),
|
215 |
+
),
|
216 |
+
) );
|
217 |
+
} ?>`
|
218 |
+
|
219 |
+
= How can I add a custom standalone share button? =
|
220 |
+
You can create a plugin or customize the following example PHP code to add to your theme's functions.php file:
|
221 |
+
|
222 |
+
`function addtoany_add_share_services( $services ) {
|
223 |
+
$services['example_share_service'] = array(
|
224 |
+
'name' => 'Example Share Service',
|
225 |
+
'icon_url' => 'https://www.example.com/my-icon.svg',
|
226 |
+
'icon_width' => 32,
|
227 |
+
'icon_height' => 32,
|
228 |
+
'href' => 'https://www.example.com/share?url=A2A_LINKURL&title=A2A_LINKNAME',
|
229 |
+
);
|
230 |
+
return $services;
|
231 |
+
}
|
232 |
+
add_filter( 'A2A_SHARE_SAVE_services', 'addtoany_add_share_services', 10, 1 );`
|
233 |
+
|
234 |
+
= How can I add a custom follow button? =
|
235 |
+
You can create a plugin or customize the following example PHP code to add to your theme's functions.php file:
|
236 |
+
|
237 |
+
`function addtoany_add_follow_services( $services ) {
|
238 |
+
$services['example_follow_service'] = array(
|
239 |
+
'name' => 'Example Follow Service',
|
240 |
+
'icon_url' => 'https://www.example.com/my-icon.svg',
|
241 |
+
'icon_width' => 32,
|
242 |
+
'icon_height' => 32,
|
243 |
+
'href' => 'https://www.example.com/ID',
|
244 |
+
);
|
245 |
+
return $services;
|
246 |
+
}
|
247 |
+
add_filter( 'A2A_FOLLOW_services', 'addtoany_add_follow_services', 10, 1 );`
|
248 |
+
|
249 |
+
= How can I align the standard sharing buttons to the center or to the right side of posts? =
|
250 |
+
It depends on your theme, but you can try adding the following CSS code to your Additional CSS box in Settings > AddToAny.
|
251 |
+
|
252 |
+
To align right:
|
253 |
+
|
254 |
+
`.addtoany_share_save_container { text-align:right; }`
|
255 |
+
|
256 |
+
To align center:
|
257 |
+
|
258 |
+
`.addtoany_share_save_container { text-align:center; }`
|
259 |
+
|
260 |
+
= How can I remove the button(s) from individual posts and pages? =
|
261 |
+
|
262 |
+
When editing a post or page, uncheck "Show sharing buttons", which is located at the bottom of the editor page. Be sure to update or publish to save your changes.
|
263 |
+
|
264 |
+
An older method was to insert the following tag into the page or post (HTML tab) that you do not want the button(s) to appear in: `<!--nosharesave-->`
|
265 |
+
|
266 |
+
= How can I force the button(s) to appear in individual posts and pages? =
|
267 |
+
|
268 |
+
When editing a post or page, check the "Show sharing buttons" checkbox, which is located at the bottom of the editor page. Be sure to update or publish to save your changes. Note that, by default, AddToAny is setup to display on all posts and pages.
|
269 |
+
|
270 |
+
An older method was to insert the following tag into the page or post (HTML tab) that you want the button(s) to appear in: `<!--sharesave-->`
|
271 |
+
|
272 |
+
= How can I remove the button(s) from category pages, or tag/author/date/search pages? =
|
273 |
+
|
274 |
+
Go to `Settings` > `AddToAny` > uncheck `Display at the top or bottom of posts on archive pages`. Archive pages include Category, Tag, Author, Date, and also Search pages.
|
275 |
+
|
276 |
+
= How can I programmatically remove the button(s)? =
|
277 |
+
|
278 |
+
In your theme's `functions.php`, you can add a filter to disable AddToAny sharing.
|
279 |
+
|
280 |
+
Disable AddToAny sharing in specific categories, for example:
|
281 |
+
|
282 |
+
`function addtoany_disable_sharing_in_some_categories() {
|
283 |
+
// Examples of in_category usage: https://codex.wordpress.org/Function_Reference/in_category
|
284 |
+
if ( in_category( array( 'my_category_1_slug', 'my_category_2_slug' ) ) ) {
|
285 |
+
return true;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
add_filter( 'addtoany_sharing_disabled', 'addtoany_disable_sharing_in_some_categories' );`
|
289 |
+
|
290 |
+
Disable AddToAny sharing on a custom post type, for example:
|
291 |
+
|
292 |
+
`function addtoany_disable_sharing_on_my_custom_post_type() {
|
293 |
+
if ( 'my_custom_post_type' == get_post_type() ) {
|
294 |
+
return true;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
add_filter( 'addtoany_sharing_disabled', 'addtoany_disable_sharing_on_my_custom_post_type' );`
|
298 |
+
|
299 |
+
= How can I position a vertical floating share buttons bar relative to content? =
|
300 |
+
|
301 |
+
In settings, disable the default placement of the Vertical Buttons. In your theme's file(s), find the parent element that you want to position the vertical bar to (the parent element should have a specified width), then add the following example PHP code as a child of that parent element:
|
302 |
+
|
303 |
+
`<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_FLOATING' ) ) {
|
304 |
+
ADDTOANY_SHARE_SAVE_FLOATING( array(
|
305 |
+
'kit_style' => 'margin-left:-100px; top:150px;',
|
306 |
+
'vertical_type' => true,
|
307 |
+
) );
|
308 |
+
} ?>`
|
309 |
+
|
310 |
+
= Why does the Facebook Like Button, Pinterest Pin It Button, Google+ Share Button, or Google +1 Button have so much whitespace to the right of it? =
|
311 |
+
|
312 |
+
The minimum width for the Facebook Like Button is 90 pixels. This is required to display the total number of Likes to the right of the button. See Facebook's <a href="https://developers.facebook.com/docs/plugins/like-button">Like Button documentation</a> for details
|
313 |
+
|
314 |
+
It's not recommended, but you can change the width of the Facebook Like Button using CSS code, for instance: `.a2a_button_facebook_like { width:50px !important; }`
|
315 |
+
|
316 |
+
The Pinterest Pin It Button with 'show count' enabled is 76 pixels. You can change the width using CSS code, for instance: `.a2a_button_pinterest_pin { width:90px !important; }`
|
317 |
+
|
318 |
+
The Google +1 Button with 'show count' enabled is 90 pixels. You can change the width using CSS code, for instance: `.a2a_button_google_plusone { width:65px !important; }`
|
319 |
+
|
320 |
+
The Google+ Share Button width can be changed using CSS code, for instance: `.a2a_button_google_plus_share { width:57px !important; }`
|
321 |
+
|
322 |
+
= Does the plugin output W3C valid code? =
|
323 |
+
|
324 |
+
Yes, this plugin outputs 100% W3C valid HTML5 and W3C valid CSS 3 by default.
|
325 |
+
|
326 |
+
= How can I load the buttons after content insertion with Ajax and infinite scroll? =
|
327 |
+
|
328 |
+
AddToAny supports the <a href="https://codex.wordpress.org/AJAX_in_Plugins#The_post-load_JavaScript_Event">standard `post-load` event</a>.
|
329 |
+
|
330 |
+
Ajax and infinite scroll plugins/themes should always fire the `post-load` event after content insertion, so request <a href="https://codex.wordpress.org/AJAX_in_Plugins#The_post-load_JavaScript_Event">standard `post-load` support</a> from plugin & theme authors as needed.
|
331 |
+
|
332 |
+
Use the following line to dispatch the `post-load` event for AddToAny and other plugins:
|
333 |
+
|
334 |
+
`jQuery( 'body' ).trigger( 'post-load' );`
|
335 |
+
|
336 |
+
= How can I set the plugin as a "Must-Use" plugin that is autoloaded and activated for all sites? =
|
337 |
+
|
338 |
+
Upload (or move) the `add-to-any` plugin directory into the `/wp-content/mu-plugins/` directory. Then create a proxy PHP loader file (such as `load.php`) in your `mu-plugins` directory, for example:
|
339 |
+
|
340 |
+
`<?php require WPMU_PLUGIN_DIR . '/add-to-any/add-to-any.php';`
|
341 |
+
|
342 |
+
== Screenshots ==
|
343 |
+
|
344 |
+
1. AddToAny vector share buttons (SVG icons) are pixel-perfect and customizable
|
345 |
+
2. Mini share menu that drops down when visitors use the universal share button
|
346 |
+
3. Full universal share menu modal that includes all services
|
347 |
+
4. Settings for Standard Share Buttons
|
348 |
+
5. Settings for Floating Share Bars
|
349 |
+
|
350 |
+
== Changelog ==
|
351 |
+
|
352 |
+
= 1.7.15 =
|
353 |
+
* Use the `wp_enqueue_scripts` action hook instead of `wp_print_styles` for the plugin's stylesheet
|
354 |
+
* Use the `home_url()` instead of the `Host` header when generating the current URL to be shared (thanks Paul)
|
355 |
+
|
356 |
+
= 1.7.14 =
|
357 |
+
* Fix the standard placement option for WooCommerce Product types
|
358 |
+
|
359 |
+
= 1.7.13 =
|
360 |
+
* Update standard placement for [WooCommerce](https://woocommerce.com/) to display share buttons after the product meta block instead of the product description
|
361 |
+
* In WooCommerce, you can customize where share buttons display by [editing](https://docs.woocommerce.com/document/editing-projects-templates-safely/) your `share.php` Single Product Share template.
|
362 |
+
* Use Japanese language pack (thanks miccweb)
|
363 |
+
|
364 |
+
= 1.7.12 =
|
365 |
+
* Use `rel="noopener"` on links that open in a new tab/window for site JavaScript performance in some browsers
|
366 |
+
* Fix the `[addtoany]` shortcode's `buttons` attribute
|
367 |
+
|
368 |
+
= 1.7.11 =
|
369 |
+
* Add icon size option to Follow buttons widget
|
370 |
+
* Replace "Large" and "Small" icon size options with single field
|
371 |
+
* Replace old universal buttons with custom button URLs
|
372 |
+
* Update CSS to apply style to custom icon sizes
|
373 |
+
* Always use HTTPS script and endpoints
|
374 |
+
|
375 |
+
= 1.7.10 =
|
376 |
+
* Fix vertical floating bar's class name and media query from the previous release
|
377 |
+
|
378 |
+
= 1.7.9 =
|
379 |
+
* Show optional meta box ("Show sharing buttons") below the WordPress editor by default, without having to save AddToAny settings first
|
380 |
+
* Enable the `shortcode_atts_addtoany` hook to filter the default attributes of the `[addtoany]` shortcode
|
381 |
+
* Accept `kit_additional_classes` argument in Floating and Follow button output functions (thanks Rocco Marco)
|
382 |
+
|
383 |
+
= 1.7.8 =
|
384 |
+
* AddToAny Follow widgets will now use full URLs when specified for a service ID
|
385 |
+
* Add Papaly
|
386 |
+
* Add Refind
|
387 |
+
* Update Pinterest icon
|
388 |
+
|
389 |
+
= 1.7.7 =
|
390 |
+
* Resolve syntax issue with [out-of-date PHP versions](https://secure.php.net/eol.php) below PHP 5.3
|
391 |
+
|
392 |
+
= 1.7.6 =
|
393 |
+
* Skip background colors on AMP icons for [out-of-date PHP versions](https://secure.php.net/eol.php) below PHP 5.3
|
394 |
+
|
395 |
+
= 1.7.5 =
|
396 |
+
* Add background colors to share buttons on [AMP](https://wordpress.org/plugins/amp/) (Accelerated Mobile Pages) to support new AddToAny SVG icons
|
397 |
+
* Fix AMP issue from `in_the_loop` check in 1.7.3
|
398 |
+
* Remove `in_the_loop` context check because AMP doesn't use the loop
|
399 |
+
* Use packaged AddToAny icon in admin (thanks xaviernieto)
|
400 |
+
|
401 |
+
= 1.7.4 =
|
402 |
+
* Fix custom/secondary contexts check when the WP query object is unavailable
|
403 |
+
|
404 |
+
= 1.7.3 =
|
405 |
+
* Add icon size options for the floating share buttons
|
406 |
+
* Replace packaged PNG icons with SVG icons
|
407 |
+
* Update services in AddToAny settings
|
408 |
+
* Update standard placement to prevent the share buttons from automatically appearing in custom/secondary contexts
|
409 |
+
* Set feed URL & title in AddToAny Follow widgets using HTML5 data attributes
|
410 |
+
|
411 |
+
= 1.7.2 =
|
412 |
+
* Accept arguments in universal button template tag for additional classes and HTML contents
|
413 |
+
* Override box shadow on buttons in some themes such as the new Twenty Seventeen default theme in WordPress 4.7
|
414 |
+
|
415 |
+
= 1.7.1 =
|
416 |
+
* Fix floating share buttons fallback so that the current page is shared by default
|
417 |
+
* Show meta box ("Show sharing buttons") below the WordPress editor when a floating share bar is enabled
|
418 |
+
* Remove deprecated option that displayed the title in the mini menu
|
419 |
+
* Add Douban share button
|
420 |
+
* Add Draugiem share button
|
421 |
+
|
422 |
+
= 1.7 =
|
423 |
+
* Simplify AddToAny asynchronous loading method
|
424 |
+
* Use HTML5 data attributes for AddToAny instances
|
425 |
+
* Remove old script block in footer
|
426 |
+
* Increase support for AJAX loading by listening for the `post-load` event on non-AJAX requests
|
427 |
+
* AddToAny readiness check in AddToAny settings
|
428 |
+
* Add placement option for media pages in AddToAny settings
|
429 |
+
* Handle "Show sharing buttons" option for media when updating from the WordPress editor
|
430 |
+
* Add Copy Link button
|
431 |
+
* Add Facebook Messenger share button
|
432 |
+
* Add Trello share button
|
433 |
+
* Update a few packaged icons
|
434 |
+
|
435 |
+
= 1.6.18 =
|
436 |
+
* Fix default icon size
|
437 |
+
|
438 |
+
= 1.6.17 =
|
439 |
+
* New `media` attribute for sharing a specific image or video to the few services that accept arbitrary media (Pinterest, Yummly)
|
440 |
+
* Update `[addtoany]` shortcode to accept specific `media` URL
|
441 |
+
* Specify a direct media URL in the `media` attribute like `[addtoany buttons="pinterest,yummly" media="https://www.example.com/media/picture.jpg"]` to have Pinterest pin that image
|
442 |
+
|
443 |
+
= 1.6.16 =
|
444 |
+
* Fix customizer preview check for WordPress versions older than 4.0 (thanks Jessica)
|
445 |
+
|
446 |
+
= 1.6.15 =
|
447 |
+
* AddToAny widgets support new selective refresh in the WordPress 4.5 Customizer
|
448 |
+
* AddToAny share endpoints default to HTTPS on HTTPS sites
|
449 |
+
* Permit changing the target attribute for custom services (thanks Jasper)
|
450 |
+
* The meta box ("Show sharing buttons") below the WordPress editor will no longer show when standard placement is disabled for the current post type
|
451 |
+
* Add Kik share button
|
452 |
+
* Add Skype share button
|
453 |
+
* Add Viber share button
|
454 |
+
* Add WeChat share button
|
455 |
+
* Add Snapchat follow button
|
456 |
+
|
457 |
+
= 1.6.14 =
|
458 |
+
* [AMP](https://wordpress.org/plugins/amp/) (Accelerated Mobile Pages) support for share buttons in posts
|
459 |
+
* PHP template code now accepts the `icon_size` argument
|
460 |
+
|
461 |
+
= 1.6.13 =
|
462 |
+
* Fix automatic placement in post excerpts for certain themes & plugins that display post content on a page (thanks Agis)
|
463 |
+
|
464 |
+
= 1.6.12 =
|
465 |
+
* Enable counters on floating share buttons when enabled for standard share buttons
|
466 |
+
* Fix settings link for Multisite administrators (thanks Jan)
|
467 |
+
* Simplify internal methods that automatically place standard share buttons
|
468 |
+
* Automatic placement logic for [WordPress excerpts](https://codex.wordpress.org/Excerpt) has changed ("excerpt" usage & presentation varies widely among WordPress themes & plugins)
|
469 |
+
* 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
|
470 |
+
* Add width & height fields for custom icons in the Advanced Options section
|
471 |
+
* Update admin slug
|
472 |
+
|
473 |
+
= 1.6.11 =
|
474 |
+
* Update `[addtoany]` shortcode to accept specific share buttons
|
475 |
+
* Specify [AddToAny service codes](https://www.addtoany.com/services/) in the `buttons` attribute like: `[addtoany buttons="facebook,twitter,google_plus"]`
|
476 |
+
* Add SMS share button
|
477 |
+
* Add Telegram share button
|
478 |
+
* Add Google Classroom share button
|
479 |
+
* Add GitHub follow button
|
480 |
+
* Update Instagram URL
|
481 |
+
|
482 |
+
= 1.6.10 =
|
483 |
+
* Enable simpler syntax when using multiple share message templates
|
484 |
+
* Override box shadow on buttons caused by CSS such as the default Twenty Sixteen theme's
|
485 |
+
* Replace deprecated WP function used for the local cache option
|
486 |
+
|
487 |
+
= 1.6.9 =
|
488 |
+
* Fix decoding of HTML entities in shared titles when the default character encoding is not UTF-8
|
489 |
+
* Update packaged languages
|
490 |
+
* Use Romanian language pack (thanks Adrian Pop)
|
491 |
+
* Use Swedish language pack (thanks Piani)
|
492 |
+
|
493 |
+
= 1.6.8 =
|
494 |
+
* Universal share counter is now available
|
495 |
+
* Tweet counters have been removed because <a href="https://www.addtoany.com/blog/twitter-share-count/">Twitter no longer provides counts</a>
|
496 |
+
* Official buttons (Facebook Like, etc.) have been moved to the bottom of the available services list
|
497 |
+
* Support WP-CLI v0.21.0+ (thanks Compute and Daniel Bachhuber)
|
498 |
+
* Support bootstrapped WordPress
|
499 |
+
* Support for other script loading methods
|
500 |
+
|
501 |
+
= 1.6.7 =
|
502 |
+
* New Additional CSS box for AddToAny CSS customizations
|
503 |
+
* Rename Additional Options box to Additional JavaScript box
|
504 |
+
* Fix quotes and other special characters in shared titles
|
505 |
+
* Simplify sections in settings
|
506 |
+
* Update universal button to canonical endpoint
|
507 |
+
* Use SSL for local cache updates
|
508 |
+
* Support must-use plugin usage via a proxy PHP loader so `add-to-any.php` can remain in the `add-to-any` directory
|
509 |
+
* Remove support for old method of moving `add-to-any.php` into `mu-plugins` for auto-loading
|
510 |
+
|
511 |
+
= 1.6.6 =
|
512 |
+
* Harden local caching option (thanks pineappleclock)
|
513 |
+
* Remove old warning message when template tags seem to be missing (thanks Tenebral, and theme authors everywhere)
|
514 |
+
* Adjust gettext calls by switching to single quotes for the text domain argument
|
515 |
+
|
516 |
+
= 1.6.5 =
|
517 |
+
* Update Google icon
|
518 |
+
* Update Google+ icon
|
519 |
+
* Update Tumblr logo
|
520 |
+
* Remove NewsTrust
|
521 |
+
|
522 |
+
= 1.6.4 =
|
523 |
+
* Fix placement option for custom post types to not inherit the placement option for regular posts (thanks Air)
|
524 |
+
* Permit custom AddToAny button in floating share bars (thanks billsmithem)
|
525 |
+
* Update widget docblocks so they are not mistaken for PHP 4 constructors
|
526 |
+
|
527 |
+
= 1.6.3 =
|
528 |
+
* Fix Google+ follow button URL by removing the hardcoded `+` (thanks foxtucker)
|
529 |
+
* Be sure to add the `+` to your `ID` if you have a Google+ custom URL.
|
530 |
+
* Custom follow services can be added to the Follow widget using the `A2A_FOLLOW_services` filter hook (see the FAQ)
|
531 |
+
* Harden CSS vertical alignment of custom icon images and Tweet button
|
532 |
+
* Change admin heading to `<h1>` for improved accessibility
|
533 |
+
|
534 |
+
= 1.6.2 =
|
535 |
+
* Support AJAX loading from `admin-ajax.php`
|
536 |
+
* Update CSS to fix alignment issues in some themes with button images and the Facebook Like button
|
537 |
+
* Add small follow icons (Instagram, YouTube, Vimeo, Flickr, Foursquare, Behance, and RSS PNGs)
|
538 |
+
* Add Known
|
539 |
+
* Remove obsoleted detection of page.js versus feed.js
|
540 |
+
|
541 |
+
= 1.6.1 =
|
542 |
+
* Titles with special characters are sanitized differently
|
543 |
+
* Using `wp_json_encode` (or `json_encode`) instead of `esc_js` for sanitizing JavaScript strings (thanks Nigel Fish)
|
544 |
+
* Fix issue where the new feed button pointed to an example URL instead of the saved URL (thanks debij)
|
545 |
+
* Resolve Follow widget notice when widget is empty in debug mode
|
546 |
+
|
547 |
+
= 1.6.0.1 =
|
548 |
+
* Resolve notices in debug mode
|
549 |
+
|
550 |
+
= 1.6 =
|
551 |
+
* <a href="https://www.addtoany.com/buttons/customize/wordpress/follow_buttons">Follow buttons</a> have arrived for WordPress!
|
552 |
+
* Includes Instagram, YouTube, Vimeo, Flickr, Foursquare, Behance, and RSS
|
553 |
+
* Go to `Appearance` > `Customize` or `Appearance` > `Widgets` to setup your follow buttons
|
554 |
+
|
555 |
+
= 1.5.9 =
|
556 |
+
* Accept custom icons of all file types such as png, svg, gif, jpg, webp, etc.
|
557 |
+
* Remove empty width and height attributes on custom icons for W3C validation
|
558 |
+
* AddToAny is certified as multilingual-ready by <a href="https://wpml.org/">WPML</a>
|
559 |
+
|
560 |
+
= 1.5.8 =
|
561 |
+
* Toggle share buttons on custom post types in AddToAny settings
|
562 |
+
* Supports WooCommerce Product post types
|
563 |
+
* Supports bbPress Forum, Topic, Reply post types
|
564 |
+
* Remove QQ (use Qzone)
|
565 |
+
* Remove border from buttons that some themes add to links in posts
|
566 |
+
|
567 |
+
= 1.5.7 =
|
568 |
+
* <a href="https://www.addtoany.com/buttons/customize/wordpress/icon_color">Custom color share buttons</a> have arrived!
|
569 |
+
* Remove Bookmark/Favorites (low browser support)
|
570 |
+
* Remove duplicate Print service (old and redundant)
|
571 |
+
* Remove FriendFeed
|
572 |
+
* Remove Springpad
|
573 |
+
|
574 |
+
= 1.5.6 =
|
575 |
+
* Bulgarian translation (by Artem Delik)
|
576 |
+
* Update French translation to resolve missing placement options
|
577 |
+
|
578 |
+
= 1.5.5 =
|
579 |
+
* Support multilingual sites using WPML, including Polylang
|
580 |
+
|
581 |
+
= 1.5.4 =
|
582 |
+
* New optional sharing header to easily place a label above the default share buttons
|
583 |
+
* Accepts HTML
|
584 |
+
* Fix text width of counters where long numbers would break to a newline (thanks Chris)
|
585 |
+
* Remove old Additional Options note in settings
|
586 |
+
|
587 |
+
= 1.5.3 =
|
588 |
+
* <a href="https://www.addtoany.com/buttons/customize/wordpress/events" title="Track shares, or change the shared URL">Share event handling</a> comes to the WordPress plugin!
|
589 |
+
* This means you can track and modify the share with some JavaScripting
|
590 |
+
* Track shares with Adobe Analytics, Clicky, KISSmetrics, Mixpanel, Piwik, Webtrends, Woopra, custom analytics, etc.
|
591 |
+
* Google Analytics integration is automatic as always
|
592 |
+
* Modify the shared URL
|
593 |
+
* Modify the shared Title for services that accept a Title directly (i.e. Twitter, but not Facebook)
|
594 |
+
* Update asynchronous loading to use new callbacks property
|
595 |
+
* Add Renren
|
596 |
+
* Remove blip, iwiw
|
597 |
+
|
598 |
+
= 1.5.2 =
|
599 |
+
* Localize More button string
|
600 |
+
* Improve interoperability among feed readers by removing official service buttons from feeds
|
601 |
+
|
602 |
+
= 1.5.1 =
|
603 |
+
* Update Print icon
|
604 |
+
* Update YouMob icon
|
605 |
+
* Update Symbaloo icon
|
606 |
+
* Update Qzone (QQ) icon
|
607 |
+
* Remove allvoices, arto, bebo, funp, jumptags, khabbr, linkagogo, linkatopia, nowpublic, orkut, phonefavs, startaid, technotizie, wists, xerpi
|
608 |
+
|
609 |
+
= 1.5 =
|
610 |
+
* Custom icon sizes (applied to AddToAny vector icons)
|
611 |
+
* Fix custom standalone service icons when used with large icons
|
612 |
+
* Add Kakao
|
613 |
+
* Add Qzone
|
614 |
+
* Add Yummly
|
615 |
+
* Update Wykop icon
|
616 |
+
|
617 |
+
= 1.4.1 =
|
618 |
+
* Update CSS to fix Facebook Like button verical aligment caused by Facebook's inline styling change
|
619 |
+
* Fix issue with shared titles containing unwanted HTML tags caused by some themes
|
620 |
+
|
621 |
+
= 1.4 =
|
622 |
+
* New: Share counters in the same style for Facebook, Twitter, Pinterest, Linkedin and Reddit!
|
623 |
+
* In Settings > AddToAny > Standalone Buttons, click the down arrow and toggle the "Show count" checkbox for any supported service
|
624 |
+
* Floating buttons do not display share counts in this release
|
625 |
+
* Update CSS to support AddToAny share counters
|
626 |
+
|
627 |
+
= 1.3.8.1 =
|
628 |
+
* Add LINE icon (thanks tokyodev)
|
629 |
+
* Add Mixi icon
|
630 |
+
* Add Hacker News icon
|
631 |
+
* Update Twitter icon
|
632 |
+
|
633 |
+
= 1.3.8 =
|
634 |
+
* Floating share buttons are now disabled when "Show sharing buttons" is unchecked for a post/page
|
635 |
+
* French translation (by Jacques Soulé)
|
636 |
+
|
637 |
+
= 1.3.7 =
|
638 |
+
* New <a href="https://www.addtoany.com/blog/new-universal-sharing-menu-design/">share menu</a> design for the universal share button!
|
639 |
+
* Floating share buttons code can be placed manually in theme files
|
640 |
+
* Ideal for positioning the vertical share bar relative to site content
|
641 |
+
* See the FAQ "How can I position a vertical floating share buttons bar relative to content?"
|
642 |
+
* Fix JS console "undefined" notices during site previews (thanks Georgi Yankov)
|
643 |
+
* Update universal sharing fallback to use HTTPS/SSL
|
644 |
+
|
645 |
+
= 1.3.6 =
|
646 |
+
* Add LINE
|
647 |
+
* Add Mixi
|
648 |
+
* Add Hacker News
|
649 |
+
* Update Twitter icon
|
650 |
+
|
651 |
+
= 1.3.5 =
|
652 |
+
* Fix 'small icon + text' double-icon issue where the AddToAny Kit icon would appear in addition to packaged icon
|
653 |
+
* Adjust default placement options for better control over the excerpts option
|
654 |
+
|
655 |
+
= 1.3.4 =
|
656 |
+
* Fix large text-only icon where the AddToAny universal icon was appearing
|
657 |
+
* Remove !important style declaration for small universal icon (thanks Tom Bryan)
|
658 |
+
* Remove Mister Wong
|
659 |
+
* Remove Yigg
|
660 |
+
|
661 |
+
= 1.3.3 =
|
662 |
+
* Append trailing slash to custom icons location as necessary
|
663 |
+
* Point to additional placement options and information
|
664 |
+
* Remove old placement instructions for hardcoding
|
665 |
+
* Remove old error reporting suppression in admin
|
666 |
+
* Ukrainian translation (by Michael Yunat)
|
667 |
+
|
668 |
+
= 1.3.2 =
|
669 |
+
* Avoid loading button script in admin, especially for visual editor plugins
|
670 |
+
* Add addtoany_script_disabled hook to programmatically disable JavaScript
|
671 |
+
|
672 |
+
= 1.3.1 =
|
673 |
+
* Floating share buttons are now responsive by default
|
674 |
+
* Responsive breakpoints configurable in Floating options
|
675 |
+
* "Use default CSS" must be enabled in Advanced Options for responsiveness
|
676 |
+
|
677 |
+
= 1.3.0.1 =
|
678 |
+
* Apply universal sharing button toggle to floating buttons
|
679 |
+
|
680 |
+
= 1.3 =
|
681 |
+
* Floating share buttons (major new feature!)
|
682 |
+
* AddToAny Vertical Share Bar
|
683 |
+
* AddToAny Horizontal Share Bar
|
684 |
+
* Update admin interface
|
685 |
+
* Update options
|
686 |
+
|
687 |
+
= 1.2.9.3 =
|
688 |
+
* Prevent script output in feeds on some sites
|
689 |
+
* Remove constants for old WP versions (below 2.6)
|
690 |
+
|
691 |
+
= 1.2.9.2 =
|
692 |
+
* Fix transparency on AddToAny's universal share icon
|
693 |
+
* Add addtoany_sharing_disabled hook to programmatically disable sharing
|
694 |
+
* Update Menu Options
|
695 |
+
|
696 |
+
= 1.2.9.1 =
|
697 |
+
* Update template code
|
698 |
+
* Update Advanced Options description
|
699 |
+
* Fix button return notice for certain use cases
|
700 |
+
|
701 |
+
= 1.2.9 =
|
702 |
+
* New Custom Icons option in the Advanced Options section
|
703 |
+
* Use any icons at any location (media uploads directory, CDN, etc.)
|
704 |
+
* This new method for using custom icons permits plugin updates that do not overwrite custom icons
|
705 |
+
* Improve descriptions in settings
|
706 |
+
|
707 |
+
= 1.2.8.7 =
|
708 |
+
* Fix code styling
|
709 |
+
|
710 |
+
= 1.2.8.6 =
|
711 |
+
* Fix advanced caching option (most sites should not use this option)
|
712 |
+
|
713 |
+
= 1.2.8.5 =
|
714 |
+
* For CSS customization, delineate between top and bottom in default sharing placement
|
715 |
+
* Add .addtoany_content_top and .addtoany_content_top class names to .addtoany_share_save_container
|
716 |
+
|
717 |
+
= 1.2.8.4 =
|
718 |
+
* Add Wanelo
|
719 |
+
* Add WhatsApp
|
720 |
+
|
721 |
+
= 1.2.8.3 =
|
722 |
+
* Set border to none on images for small icons and custom icons
|
723 |
+
|
724 |
+
= 1.2.8.2 =
|
725 |
+
* Add pointer to settings in admin
|
726 |
+
|
727 |
+
= 1.2.8.1 =
|
728 |
+
* Remove Favoriten
|
729 |
+
* Remove Grono
|
730 |
+
* Remove Hyves
|
731 |
+
|
732 |
+
= 1.2.8.0 =
|
733 |
+
* Update Customize documentation links
|
734 |
+
|
735 |
+
= 1.2.7.9 =
|
736 |
+
* Fix Print icon
|
737 |
+
|
738 |
+
= 1.2.7.8 =
|
739 |
+
* Update Google+ Share button
|
740 |
+
* Update Google +1 button
|
741 |
+
* Update Delicious small icon
|
742 |
+
* Update Diaspora small icon
|
743 |
+
|
744 |
+
= 1.2.7.7 =
|
745 |
+
* Perfect compatibility with WordPress 3.8
|
746 |
+
* Update email icon
|
747 |
+
* Add confirm dialog to universal sharing toggle
|
748 |
+
* Rename files and backend improvements for admin
|
749 |
+
|
750 |
+
= 1.2.7.6 =
|
751 |
+
* Add option to disable universal sharing button
|
752 |
+
* Disables the universal sharing button in automatic placement and ADDTOANY_SHARE_SAVE_KIT
|
753 |
+
* The universal sharing button is still available via ADDTOANY_SHARE_SAVE_BUTTON (see FAQ)
|
754 |
+
* Fix fieldset focusing in admin
|
755 |
+
|
756 |
+
= 1.2.7.5 =
|
757 |
+
* Update Facebook Like button
|
758 |
+
|
759 |
+
= 1.2.7.4 =
|
760 |
+
* Improve vertical alignment consistency of 3rd party buttons across themes
|
761 |
+
|
762 |
+
= 1.2.7.3 =
|
763 |
+
* Harden AJAX detection
|
764 |
+
|
765 |
+
= 1.2.7.2 =
|
766 |
+
* Support infinite scrolling of post content in themes
|
767 |
+
* Support AJAX loading (on a `post-load` event)
|
768 |
+
|
769 |
+
= 1.2.7.1 =
|
770 |
+
* Wrap addtoany shortcode with .addtoany_shortcode to enable specific styling
|
771 |
+
* Add Flipboard
|
772 |
+
* Update FAQ on hardcoding just the icons (both large and small icons)
|
773 |
+
|
774 |
+
= 1.2.7 =
|
775 |
+
* Fix backwards compatibility with WordPress 2.8
|
776 |
+
* Checkbox option to disable sharing buttons on each post and page
|
777 |
+
* Add Baidu
|
778 |
+
* Add Mendeley
|
779 |
+
* Add Springpad
|
780 |
+
* Update VK (Vkontakte)
|
781 |
+
|
782 |
+
= 1.2.6 =
|
783 |
+
* Harden option to disable sharing buttons on each post and page
|
784 |
+
* Extend option to custom post types
|
785 |
+
|
786 |
+
= 1.2.5 =
|
787 |
+
* Large SVG icons are the default sharing format
|
788 |
+
* Default standalone services are Facebook, Twitter, Google Plus
|
789 |
+
* Note: If your sharing button suddenly changes (because you haven't saved AddToAny settings yet), you can go back to the traditional sharing button in Settings > AddToAny. Choose "Small" for the Icon Size to see the traditional buttons, and in Standalone Buttons, click "Add/Remove Services" to deselect Facebook, Twitter, and Google Plus. Then click Save Changes to save your AddToAny Share Settings.
|
790 |
+
* Popular services have been moved to the top of the Standalone Buttons list
|
791 |
+
|
792 |
+
= 1.2.4 =
|
793 |
+
* Add Pinterest Pin It Button and options
|
794 |
+
|
795 |
+
= 1.2.3 =
|
796 |
+
* Adjust CSS to improve icon and text alignment
|
797 |
+
* Add FAQ for removing sharing button(s) from Archive pages (including Category, Tag, Author, Date, and Search pages)
|
798 |
+
|
799 |
+
= 1.2.2 =
|
800 |
+
* Fix code formatting (indents, newlines)
|
801 |
+
|
802 |
+
= 1.2.1 =
|
803 |
+
* Checkbox option to disable sharing buttons on each post and page
|
804 |
+
|
805 |
+
= 1.2 =
|
806 |
+
* Large sharing buttons (major new feature!)
|
807 |
+
* Scalable vector icons (SVG icons)
|
808 |
+
* Mobile ready
|
809 |
+
* Retina and high-PPI ready
|
810 |
+
* Customizable through CSS code (effects, height & width, border-radius, and much more)
|
811 |
+
* Support for older browsers (reverts gracefully to PNG)
|
812 |
+
* Large icons are available for the most popular services right now. More services will roll out soon
|
813 |
+
* Adjust CSS for large icons
|
814 |
+
* Remove old Internet Explorer stylesheet for rollover opacity effect
|
815 |
+
* Add Icon Size options to settings
|
816 |
+
* Defaults and settings adjustments
|
817 |
+
* Simplify labels in settings
|
818 |
+
|
819 |
+
= 1.1.6 =
|
820 |
+
* Add App.net
|
821 |
+
* Add Outlook.com (formerly Hotmail)
|
822 |
+
* Update Pinterest icon
|
823 |
+
* Update Box icon
|
824 |
+
* Update Digg icon
|
825 |
+
* Update Evernote icon
|
826 |
+
* Update Instapaper icon
|
827 |
+
* Update Yahoo! icon
|
828 |
+
* Update Vkontakte (VK) icon
|
829 |
+
* Remove unused icons
|
830 |
+
|
831 |
+
= 1.1.5 =
|
832 |
+
* Fix debug mode notices when manually placed in a theme file that does not display a post/page
|
833 |
+
* Sanitize active services output in admin
|
834 |
+
|
835 |
+
= 1.1.4 =
|
836 |
+
* Fix admin panel display of 3rd party button options after saving changes
|
837 |
+
* Fix debug mode notices in admin
|
838 |
+
|
839 |
+
= 1.1.3 =
|
840 |
+
* Fix validation and semantics of script tag placement, particularly when button is contained in a list element
|
841 |
+
|
842 |
+
= 1.1.2 =
|
843 |
+
* Fix settings page conflict with certain features of the Jetpack plugin and other plugins & themes
|
844 |
+
* Fix saving of 3rd party button options (for Facebook Like, Twitter Tweet, Google +1)
|
845 |
+
* Fix service sorting
|
846 |
+
* Add Pocket (formerly Read It Later)
|
847 |
+
* Remove Read It Later (now Pocket)
|
848 |
+
* Remove HelloTxt
|
849 |
+
* Update Slashdot icon
|
850 |
+
|
851 |
+
= 1.1.1 =
|
852 |
+
* Add Pinboard
|
853 |
+
* Add Buffer
|
854 |
+
* Add Diaspora
|
855 |
+
* Add Kindle It
|
856 |
+
* Add Mail.Ru
|
857 |
+
* Add Odnoklassniki
|
858 |
+
* Update Pinterest icon
|
859 |
+
* Update Google icon
|
860 |
+
* Update Google+ icon
|
861 |
+
* Remove Google Reader
|
862 |
+
* Remove Posterous
|
863 |
+
* Remove Sphere
|
864 |
+
* Remove Tipd
|
865 |
+
* Remove Vodpod
|
866 |
+
|
867 |
+
= 1.1 =
|
868 |
+
* Fix settings page conflict with certain features of the Jetpack plugin and other plugins & themes
|
869 |
+
* Fix settings page's down arrow icon for advanced 3rd party buttons (Like, Tweet, etc.)
|
870 |
+
* Update branding
|
871 |
+
* Update buttons
|
872 |
+
|
873 |
+
= 1.0.3 =
|
874 |
+
* Update Twitter logo
|
875 |
+
|
876 |
+
= 1.0.2 =
|
877 |
+
* Add new Google+ Share button
|
878 |
+
* Update FAQ for resizing advanced 3rd party buttons
|
879 |
+
|
880 |
+
= 1.0.1 =
|
881 |
+
* Fix markup output for advanced 3rd party buttons when displayed as WordPress widget
|
882 |
+
|
883 |
+
= 1.0 =
|
884 |
+
* After 5 years of development: Version One Point Oh!
|
885 |
+
* Load advanced 3rd party buttons faster (Facebook Like, Twitter Tweet, Google +1)
|
886 |
+
* Use A2A Kit for speed, extensibility, measurability
|
887 |
+
* Adjust CSS to accommodate external resources for advanced 3rd party buttons
|
888 |
+
* Lithuanian translation (by Vincent G.)
|
889 |
+
|
890 |
+
= 0.9 =
|
891 |
+
* For all prior versions, see 1.6.12 or earlier
|
892 |
+
|
893 |
+
== Upgrade Notice ==
|
894 |
+
|
895 |
+
= 1.7.13 =
|
896 |
+
For [WooCommerce](https://woocommerce.com/) sites, the default standard placement for share buttons has moved from the product description to after the product meta block. You can customize exactly where share buttons display by [editing](https://docs.woocommerce.com/document/editing-projects-templates-safely/) your `share.php` Single Product Share template.
|
897 |
+
|
898 |
+
= 1.6.12 =
|
899 |
+
Automatic placement logic for [WordPress excerpts](https://codex.wordpress.org/Excerpt) has changed. 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. Use custom icons? For improved layout and compatibility, specify the width & height of your icons in Settings > AddToAny > Advanced Options.
|
900 |
+
|
901 |
+
= 1.6.7 =
|
902 |
+
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.
|
903 |
+
|
904 |
+
= 1.6.3 =
|
905 |
+
If you configured a Google+ follow button through an AddToAny Follow widget, the automatic `+` in your URL has been removed to permit default Google+ URLs which do not have a `+` preceding the ID number. Be sure to add the `+` back if you have a Google+ custom URL.
|
906 |
+
|
907 |
+
= 1.6 =
|
908 |
+
Follow buttons are now available! Look for the AddToAny Follow widget in Appearance > Customize or Appearance > Widgets.
|
909 |
+
|
910 |
+
= 1.5.3 =
|
911 |
+
Switch to the Large or Custom icon size if you haven't already - AddToAny's vector icons are way better than the traditional Small icons.
|
912 |
+
|
913 |
+
= 1.4 =
|
914 |
+
AddToAny share counters are now available for supported standalone buttons! For Facebook, Twitter, Pinterest, Reddit and Linkedin, click the down arrow and toggle the "Show count" checkbox.
|
915 |
+
|
916 |
+
= 1.3.1 =
|
917 |
+
Floating share buttons are now responsive by default, ready for mobile & tablets. You can toggle responsiveness and set responsive breakpoints in the "Floating" tab of Settings > AddToAny.
|
918 |
+
|
919 |
+
= 1.3 =
|
920 |
Â
Floating Share Buttons are now available! Click the "Floating" tab in Settings > AddToAny.
|
add-to-any.php
CHANGED
@@ -1,1105 +1,1105 @@
|
|
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_plugin_basename, $A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url_path,
|
16 |
-
$A2A_SHARE_SAVE_services, $A2A_SHARE_SAVE_amp_icons_css;
|
17 |
-
|
18 |
-
$A2A_SHARE_SAVE_plugin_basename = plugin_basename( dirname( __FILE__ ) );
|
19 |
-
$A2A_SHARE_SAVE_plugin_dir = untrailingslashit( plugin_dir_path( __FILE__ ) );
|
20 |
-
$A2A_SHARE_SAVE_plugin_url_path = untrailingslashit( plugin_dir_url( __FILE__ ) );
|
21 |
-
|
22 |
-
// HTTPS?
|
23 |
-
$A2A_SHARE_SAVE_plugin_url_path = is_ssl() ? str_replace( 'http:', 'https:', $A2A_SHARE_SAVE_plugin_url_path ) : $A2A_SHARE_SAVE_plugin_url_path;
|
24 |
-
// Set AddToAny locale (JavaScript)
|
25 |
-
$A2A_locale = ! isset ( $A2A_locale ) ? '' : $A2A_locale;
|
26 |
-
// Set plugin options
|
27 |
-
$A2A_SHARE_SAVE_options = get_option( 'addtoany_options', array() );
|
28 |
-
|
29 |
-
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.compat.php';
|
30 |
-
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php';
|
31 |
-
|
32 |
-
function A2A_SHARE_SAVE_init() {
|
33 |
-
global $A2A_SHARE_SAVE_plugin_dir,
|
34 |
-
$A2A_SHARE_SAVE_plugin_basename,
|
35 |
-
$A2A_SHARE_SAVE_options;
|
36 |
-
|
37 |
-
// Load the textdomain for translations
|
38 |
-
load_plugin_textdomain( 'add-to-any', false, $A2A_SHARE_SAVE_plugin_basename . '/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',
|
44 |
-
'share_save_256_24.png|256|24', 'share_save_171_16.png|171|16', 'share_save_120_16.png|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();
|
52 |
-
}
|
53 |
-
}
|
54 |
-
add_filter( 'init', 'A2A_SHARE_SAVE_init' );
|
55 |
-
|
56 |
-
function A2A_SHARE_SAVE_link_vars( $linkname = false, $linkurl = false, $linkmedia = false, $use_current_page = false ) {
|
57 |
-
global $post;
|
58 |
-
|
59 |
-
// Set linkname
|
60 |
-
if ( ! $linkname ) {
|
61 |
-
if ( $use_current_page ) {
|
62 |
-
$linkname = is_home() || is_front_page() ? get_bloginfo( 'name' ) : rtrim( wp_title( '', false, 'right' ) );
|
63 |
-
} elseif ( isset( $post ) ) {
|
64 |
-
$linkname = html_entity_decode( strip_tags( get_the_title( $post->ID ) ), ENT_QUOTES, 'UTF-8' );
|
65 |
-
} else {
|
66 |
-
$linkname = '';
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
$linkname_enc = rawurlencode( $linkname );
|
71 |
-
|
72 |
-
// Set linkurl
|
73 |
-
if ( ! $linkurl ) {
|
74 |
-
if ( $use_current_page ) {
|
75 |
-
$linkurl = esc_url_raw
|
76 |
-
} elseif ( isset( $post ) ) {
|
77 |
-
$linkurl = get_permalink( $post->ID );
|
78 |
-
} else {
|
79 |
-
$linkurl = '';
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
$linkurl_enc = rawurlencode( $linkurl );
|
84 |
-
|
85 |
-
// Set linkmedia (only applies to services that explicitly accept media; Pinterest does, most do not)
|
86 |
-
$linkmedia_enc = ! empty( $linkmedia ) ? rawurlencode( $linkmedia ) : false;
|
87 |
-
|
88 |
-
return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc', 'linkmedia', 'linkmedia_enc' );
|
89 |
-
}
|
90 |
-
|
91 |
-
// Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
|
92 |
-
function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
93 |
-
$options = get_option( 'addtoany_options', array() );
|
94 |
-
|
95 |
-
$linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
|
96 |
-
$linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
|
97 |
-
$linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
|
98 |
-
$use_current_page = isset( $args['use_current_page'] ) ? $args['use_current_page'] : false;
|
99 |
-
|
100 |
-
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $linkname, $linkurl, $linkmedia, $use_current_page ) ); // linkname_enc, etc.
|
101 |
-
|
102 |
-
$defaults = array(
|
103 |
-
'output_later' => false,
|
104 |
-
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
105 |
-
);
|
106 |
-
|
107 |
-
$args = wp_parse_args( $args, $defaults );
|
108 |
-
extract( $args );
|
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 |
-
|
117 |
-
// Custom icons enabled?
|
118 |
-
$custom_icons = ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) ? true : false;
|
119 |
-
|
120 |
-
$kit_additional_classes = '';
|
121 |
-
$kit_data_media = empty( $linkmedia ) ? '' : ' data-a2a-media="' . $linkmedia . '"';
|
122 |
-
$kit_data_title = empty( $linkname ) || $use_current_page ? '' : ' data-a2a-title="' . $linkname . '"';
|
123 |
-
$kit_data_url = empty( $linkurl ) || $use_current_page ? '' : ' data-a2a-url="' . $linkurl . '"';
|
124 |
-
$kit_style = '';
|
125 |
-
|
126 |
-
// Add additional classNames to .a2a_kit
|
127 |
-
if ( ! empty( $args['kit_additional_classes'] ) ) {
|
128 |
-
// Append space and className(s)
|
129 |
-
$kit_additional_classes .= ' ' . $args['kit_additional_classes'];
|
130 |
-
}
|
131 |
-
|
132 |
-
// Set a2a_kit_size_## class name
|
133 |
-
if ( $custom_icons ) {
|
134 |
-
// If vertical style (.a2a_vertical_style)
|
135 |
-
if ( strpos( $kit_additional_classes, 'a2a_vertical_style' ) !== false ) {
|
136 |
-
// Use width (if specified) for .a2a_kit_size_## class name to size default service counters
|
137 |
-
$icon_size_classname = isset( $options['custom_icons_width'] ) ? ' a2a_kit_size_' . $options['custom_icons_width'] : '';
|
138 |
-
} else {
|
139 |
-
// Use height (if specified) for .a2a_kit_size_## class name to size default service counters
|
140 |
-
$icon_size_classname = isset( $options['custom_icons_height'] ) ? ' a2a_kit_size_' . $options['custom_icons_height'] : '';
|
141 |
-
}
|
142 |
-
// a2a_kit_size_## icon size
|
143 |
-
} else {
|
144 |
-
$icon_size_classname = ' a2a_kit_size_' . $icon_size;
|
145 |
-
}
|
146 |
-
|
147 |
-
// Add addtoany_list className unless disabled (for floating buttons)
|
148 |
-
if ( ! isset( $args['no_addtoany_list_classname'] ) ) {
|
149 |
-
$kit_additional_classes .= ' addtoany_list';
|
150 |
-
}
|
151 |
-
|
152 |
-
// Add style attribute if set
|
153 |
-
if ( isset( $args['kit_style'] ) ) {
|
154 |
-
$kit_style = ' style="' . $args['kit_style'] . '"';
|
155 |
-
}
|
156 |
-
|
157 |
-
if ( ! isset( $args['html_container_open'] ) ) {
|
158 |
-
$args['html_container_open'] = '<div class="a2a_kit' . $icon_size_classname . $kit_additional_classes . '"'
|
159 |
-
. $kit_data_url . $kit_data_title . $kit_data_media . $kit_style . '>';
|
160 |
-
$args['is_kit'] = true;
|
161 |
-
}
|
162 |
-
if ( ! isset( $args['html_container_close'] ) )
|
163 |
-
$args['html_container_close'] = "</div>";
|
164 |
-
// Close container element in ADDTOANY_SHARE_SAVE_BUTTON, not prematurely in ADDTOANY_SHARE_SAVE_ICONS
|
165 |
-
$html_container_close = $args['html_container_close']; // Cache for _BUTTON
|
166 |
-
unset($args['html_container_close']); // Avoid passing to ADDTOANY_SHARE_SAVE_ICONS since set in _BUTTON
|
167 |
-
|
168 |
-
if ( ! isset( $args['html_wrap_open'] ) )
|
169 |
-
$args['html_wrap_open'] = "";
|
170 |
-
if ( ! isset( $args['html_wrap_close'] ) )
|
171 |
-
$args['html_wrap_close'] = "";
|
172 |
-
|
173 |
-
$kit_html = ADDTOANY_SHARE_SAVE_ICONS( $args );
|
174 |
-
|
175 |
-
$args['html_container_close'] = $html_container_close; // Re-set because unset above for _ICONS
|
176 |
-
unset( $args['html_container_open'] ); // Avoid passing to ADDTOANY_SHARE_SAVE_BUTTON since set in _ICONS
|
177 |
-
|
178 |
-
$kit_html .= ADDTOANY_SHARE_SAVE_BUTTON( $args );
|
179 |
-
|
180 |
-
if ( true == $output_later )
|
181 |
-
return $kit_html;
|
182 |
-
else
|
183 |
-
echo $kit_html;
|
184 |
-
}
|
185 |
-
|
186 |
-
function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
|
187 |
-
// $args array: output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl
|
188 |
-
|
189 |
-
global $A2A_SHARE_SAVE_plugin_url_path,
|
190 |
-
$A2A_SHARE_SAVE_services,
|
191 |
-
$A2A_FOLLOW_services,
|
192 |
-
$A2A_SHARE_SAVE_amp_icons_css;
|
193 |
-
|
194 |
-
$options = get_option( 'addtoany_options', array() );
|
195 |
-
|
196 |
-
$linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
|
197 |
-
$linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
|
198 |
-
$linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
|
199 |
-
|
200 |
-
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $linkname, $linkurl, $linkmedia ) ); // linkname_enc, etc.
|
201 |
-
|
202 |
-
$defaults = array(
|
203 |
-
'linkname' => '',
|
204 |
-
'linkurl' => '',
|
205 |
-
'linkmedia' => '',
|
206 |
-
'linkname_enc' => '',
|
207 |
-
'linkurl_enc' => '',
|
208 |
-
'linkmedia_enc' => '',
|
209 |
-
'output_later' => false,
|
210 |
-
'html_container_open' => '',
|
211 |
-
'html_container_close' => '',
|
212 |
-
'html_wrap_open' => '',
|
213 |
-
'html_wrap_close' => '',
|
214 |
-
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
215 |
-
'is_follow' => false,
|
216 |
-
'no_universal_button' => false,
|
217 |
-
'buttons' => array(),
|
218 |
-
);
|
219 |
-
|
220 |
-
$args = wp_parse_args( $args, $defaults );
|
221 |
-
extract( $args );
|
222 |
-
|
223 |
-
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
|
224 |
-
$amp_css = '.a2a_dd img{background-color:#0166FF;}';
|
225 |
-
|
226 |
-
// Large icons except for AMP endpoint
|
227 |
-
$large_icons = $is_amp ? false : true;
|
228 |
-
|
229 |
-
// Directory of either custom icons or the packaged icons
|
230 |
-
if ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) {
|
231 |
-
// Custom icons expected at a specified URL, i.e. //example.com/blog/uploads/addtoany/icons/custom/
|
232 |
-
$icons_dir = $options['custom_icons_url'];
|
233 |
-
$icons_type = ( isset( $options['custom_icons_type'] ) ) ? $options['custom_icons_type'] : 'png';
|
234 |
-
$icons_width = ( isset( $options['custom_icons_width'] ) ) ? $options['custom_icons_width'] : '';
|
235 |
-
$icons_height = ( isset( $options['custom_icons_height'] ) ) ? $options['custom_icons_height'] : '';
|
236 |
-
$custom_icons = true;
|
237 |
-
} else {
|
238 |
-
// Default to local SVGs (not an option currently)
|
239 |
-
$icons_dir = $A2A_SHARE_SAVE_plugin_url_path . '/icons/';
|
240 |
-
$icons_type = 'svg';
|
241 |
-
}
|
242 |
-
|
243 |
-
// If Follow kit
|
244 |
-
if ( $is_follow ) {
|
245 |
-
// Make available services extensible via plugins, themes (functions.php), etc.
|
246 |
-
$services = apply_filters( 'A2A_FOLLOW_services', $A2A_FOLLOW_services );
|
247 |
-
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
|
248 |
-
|
249 |
-
// Services set by "buttons" arg
|
250 |
-
$active_services = ! empty ( $buttons ) ? array_keys( $buttons ) : array();
|
251 |
-
// Else Share kit
|
252 |
-
} else {
|
253 |
-
// Make available services extensible via plugins, themes (functions.php), etc.
|
254 |
-
$services = apply_filters( 'A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services );
|
255 |
-
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
|
256 |
-
|
257 |
-
// Include Facebook Like and Twitter Tweet etc. unless no_special_services arg is true
|
258 |
-
if ( ! isset( $no_special_services ) || false == $no_special_services ) {
|
259 |
-
array_unshift( $service_codes, 'facebook_like', 'twitter_tweet', 'google_plusone', 'google_plus_share', 'pinterest_pin' );
|
260 |
-
}
|
261 |
-
|
262 |
-
// Use default services if services have not been selected yet
|
263 |
-
$active_services = ( isset( $options['active_services'] ) ) ? $options['active_services'] : array( 'facebook', 'twitter', 'google_plus' );
|
264 |
-
// Services set by "buttons" arg? Then use "buttons" arg instead
|
265 |
-
$active_services = ! empty ( $buttons ) ? $buttons : $active_services;
|
266 |
-
}
|
267 |
-
|
268 |
-
$ind_html = "" . $html_container_open;
|
269 |
-
|
270 |
-
foreach( $active_services as $active_service ) {
|
271 |
-
|
272 |
-
$custom_service = false;
|
273 |
-
|
274 |
-
if ( ! in_array( $active_service, $service_codes ) )
|
275 |
-
continue;
|
276 |
-
|
277 |
-
if ( $active_service == 'facebook_like' || $active_service == 'twitter_tweet' || $active_service == 'google_plusone' || $active_service == 'google_plus_share' || $active_service == 'pinterest_pin' ) {
|
278 |
-
$special_args = $args;
|
279 |
-
$special_args['output_later'] = true;
|
280 |
-
$link = ADDTOANY_SHARE_SAVE_SPECIAL( $active_service, $special_args );
|
281 |
-
} else {
|
282 |
-
$service = $services[ $active_service ];
|
283 |
-
$safe_name = $active_service;
|
284 |
-
$name = $service['name'];
|
285 |
-
|
286 |
-
// If Follow kit and HREF specified
|
287 |
-
if ( $is_follow && isset( $service['href'] ) ) {
|
288 |
-
$follow_id = $buttons[ $active_service ]['id'];
|
289 |
-
$is_url = in_array( parse_url( $follow_id, PHP_URL_SCHEME ), array( 'http', 'https' ) );
|
290 |
-
|
291 |
-
// If it's a URL instead of a service ID
|
292 |
-
if ( $is_url ) {
|
293 |
-
// Just use the given URL instead of the URL template
|
294 |
-
$href = $follow_id;
|
295 |
-
} else {
|
296 |
-
// Replace the ID placeholder in the URL template
|
297 |
-
$href = str_replace( '${id}', $follow_id, $service['href'] );
|
298 |
-
}
|
299 |
-
$href = ( 'feed' == $safe_name ) ? $follow_id : $href;
|
300 |
-
|
301 |
-
// If icon_url is set, presume custom service
|
302 |
-
if ( isset( $service['icon_url'] ) ) {
|
303 |
-
$custom_service = true;
|
304 |
-
}
|
305 |
-
// Else if Share Kit and HREF specified, presume custom service
|
306 |
-
} elseif ( isset( $service['href'] ) ) {
|
307 |
-
$custom_service = true;
|
308 |
-
$href = $service['href'];
|
309 |
-
if ( isset( $service['href_js_esc'] ) ) {
|
310 |
-
$href_linkurl = str_replace( "'", "\'", $linkurl );
|
311 |
-
$href_linkname = str_replace( "'", "\'", $linkname );
|
312 |
-
} else {
|
313 |
-
$href_linkurl = $linkurl_enc;
|
314 |
-
$href_linkname = $linkname_enc;
|
315 |
-
}
|
316 |
-
$href = str_replace( "A2A_LINKURL", $href_linkurl, $href );
|
317 |
-
$href = str_replace( "A2A_LINKNAME", $href_linkname, $href );
|
318 |
-
$href = str_replace( " ", "%20", $href );
|
319 |
-
}
|
320 |
-
|
321 |
-
// AddToAny counter enabled?
|
322 |
-
$counter_enabled = ( ! $is_follow // Disable counters on Follow Kits
|
323 |
-
&& in_array( $active_service, array( 'facebook', 'pinterest', 'linkedin', 'reddit' ) )
|
324 |
-
&& isset( $options['special_' . $active_service . '_options'] )
|
325 |
-
&& isset( $options['special_' . $active_service . '_options']['show_count'] )
|
326 |
-
&& $options['special_' . $active_service . '_options']['show_count'] == '1'
|
327 |
-
) ? true : false;
|
328 |
-
|
329 |
-
$icon = isset( $service['icon'] ) ? $service['icon'] : 'default'; // Just the icon filename
|
330 |
-
$icon_url = isset( $service['icon_url'] ) ? $service['icon_url'] : false;
|
331 |
-
$icon_url = $is_amp && ! $icon_url ? 'https://static.addtoany.com/buttons/' . $icon . '.svg' : $icon_url;
|
332 |
-
$width_attr = isset( $service['icon_width'] ) ? ' width="' . $service['icon_width'] . '"' : ' width="16"';
|
333 |
-
$width_attr = $is_amp && ! empty( $icon_size ) ? ' width="' . $icon_size . '"' : $width_attr;
|
334 |
-
$height_attr = isset( $service['icon_height'] ) ? ' height="' . $service['icon_height'] . '"' : ' height="16"';
|
335 |
-
$height_attr = $is_amp && ! empty( $icon_size ) ? ' height="' . $icon_size . '"' : $height_attr;
|
336 |
-
|
337 |
-
$amp_css .= $is_amp && ! empty( $service['color'] ) ? '.a2a_button_' . $safe_name . ' img{background-color:#' . $service['color'] . ';}' : '';
|
338 |
-
|
339 |
-
$url = isset( $href ) ? $href : 'https://www.addtoany.com/add_to/' . $safe_name . '?linkurl=' . $linkurl_enc .'&linkname=' . $linkname_enc;
|
340 |
-
$src = $icon_url ? $icon_url : $icons_dir . $icon . '.' . $icons_type;
|
341 |
-
$counter = $counter_enabled ? ' a2a_counter' : '';
|
342 |
-
$class_attr = $custom_service ? '' : ' class="a2a_button_' . $safe_name . $counter . '"';
|
343 |
-
|
344 |
-
if ( isset( $service['target'] ) ) {
|
345 |
-
$target_attr = empty( $service['target'] ) ? '' : ' target="' . $service['target'] . '"';
|
346 |
-
} else {
|
347 |
-
$target_attr = ' target="_blank"';
|
348 |
-
}
|
349 |
-
|
350 |
-
// Use rel="noopener" for links that open in a new tab/window
|
351 |
-
$rel_noopener = $custom_service || ! $target_attr ? '' : ' noopener';
|
352 |
-
$rel_noopener_only = $rel_noopener || $target_attr ? ' rel="noopener"' : '';
|
353 |
-
$rel_attr = $is_follow ? $rel_noopener_only : ' rel="nofollow' . $rel_noopener . '"'; // ($is_follow indicates a Follow Kit. 'nofollow' is for search crawlers. Different things)
|
354 |
-
|
355 |
-
// Set dimension attributes if using custom icons and dimension is specified
|
356 |
-
if ( isset( $custom_icons ) ) {
|
357 |
-
$width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
|
358 |
-
$height_attr = ! empty( $icons_height ) ? ' height="' . $icons_height . '"' : '';
|
359 |
-
}
|
360 |
-
|
361 |
-
$link = $html_wrap_open . "<a$class_attr href=\"$url\" title=\"$name\"$rel_attr$target_attr>";
|
362 |
-
$link .= ( $large_icons && ! isset( $custom_icons ) && ! $custom_service ) ? "" : "<img src=\"$src\"" . $width_attr . $height_attr . " alt=\"$name\"/>";
|
363 |
-
$link .= "</a>" . $html_wrap_close;
|
364 |
-
}
|
365 |
-
|
366 |
-
$ind_html .= $link;
|
367 |
-
}
|
368 |
-
|
369 |
-
$ind_html .= $html_container_close;
|
370 |
-
|
371 |
-
if ( $is_amp ) {
|
372 |
-
$A2A_SHARE_SAVE_amp_icons_css = $amp_css;
|
373 |
-
add_action( 'amp_post_template_css', 'addtoany_amp_icons_css' );
|
374 |
-
}
|
375 |
-
|
376 |
-
if ( true == $output_later )
|
377 |
-
return $ind_html;
|
378 |
-
else
|
379 |
-
echo $ind_html;
|
380 |
-
}
|
381 |
-
|
382 |
-
function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
|
383 |
-
|
384 |
-
// $args array = output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl, no_universal_button
|
385 |
-
|
386 |
-
global $A2A_SHARE_SAVE_plugin_url_path;
|
387 |
-
|
388 |
-
$options = get_option( 'addtoany_options', array() );
|
389 |
-
|
390 |
-
$linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
|
391 |
-
$linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
|
392 |
-
$linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
|
393 |
-
|
394 |
-
$args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl, $linkmedia)); // linkname_enc, etc.
|
395 |
-
|
396 |
-
$defaults = array(
|
397 |
-
'linkname' => '',
|
398 |
-
'linkurl' => '',
|
399 |
-
'linkmedia' => '',
|
400 |
-
'linkname_enc' => '',
|
401 |
-
'linkurl_enc' => '',
|
402 |
-
'linkmedia_enc' => '',
|
403 |
-
'use_current_page' => false,
|
404 |
-
'output_later' => false,
|
405 |
-
'is_kit' => false,
|
406 |
-
'html_container_open' => '',
|
407 |
-
'html_container_close' => '',
|
408 |
-
'html_wrap_open' => '',
|
409 |
-
'html_wrap_close' => '',
|
410 |
-
'html_content' => '',
|
411 |
-
'button_additional_classes' => '',
|
412 |
-
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
413 |
-
'no_universal_button' => false,
|
414 |
-
);
|
415 |
-
|
416 |
-
$args = wp_parse_args( $args, $defaults );
|
417 |
-
extract( $args );
|
418 |
-
|
419 |
-
$is_feed = is_feed();
|
420 |
-
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
|
421 |
-
$button_class = '';
|
422 |
-
$button_data_media = $is_kit || empty( $linkmedia ) ? '' : ' data-a2a-media="' . $linkmedia . '"';
|
423 |
-
$button_data_title = $is_kit || empty( $linkname ) ? '' : ' data-a2a-title="' . $linkname . '"';
|
424 |
-
$button_data_url = $is_kit || empty( $linkurl ) ? '' : ' data-a2a-url="' . $linkurl . '"';
|
425 |
-
$button_target = $is_amp ? ' target="_blank"' : '';
|
426 |
-
$button_href_querystring = ($is_feed || $is_amp) ? '#url=' . $linkurl_enc . '&title=' . $linkname_enc : '';
|
427 |
-
|
428 |
-
// If universal button is enabled
|
429 |
-
if ( ! $args['no_universal_button'] ) {
|
430 |
-
|
431 |
-
if ( isset( $options['button'] ) && 'CUSTOM' == $options['button'] ) {
|
432 |
-
// Custom button
|
433 |
-
$button_src = $options['button_custom'];
|
434 |
-
$button_width = '';
|
435 |
-
$button_height = '';
|
436 |
-
} else if ( isset( $options['button'] ) && 'TEXT' == $options['button'] ) {
|
437 |
-
// Text-only button
|
438 |
-
$button_text = stripslashes( $options[ 'button_text'] );
|
439 |
-
// Do not display universal icon
|
440 |
-
$button_class .= ' addtoany_no_icon';
|
441 |
-
} else {
|
442 |
-
// Default AddToAny button
|
443 |
-
if ( $is_amp ) {
|
444 |
-
// AMP (Accelerated Mobile Page)
|
445 |
-
$button_src = 'https://static.addtoany.com/buttons/a2a.svg';
|
446 |
-
$button_width = ! empty( $icon_size ) ? ' width="' . $icon_size .'"' : ' width="32"';
|
447 |
-
$button_height = ! empty( $icon_size ) ? ' height="' . $icon_size .'"' : ' height="32"';
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
if ( ! empty( $html_content ) ) {
|
452 |
-
$button = $html_content;
|
453 |
-
} elseif ( ! empty( $button_text ) ) {
|
454 |
-
$button = $button_text;
|
455 |
-
} elseif ( ! empty( $button_src ) ) {
|
456 |
-
$button = '<img src="' . $button_src . '"' . $button_width . $button_height . ' alt="Share">';
|
457 |
-
} else {
|
458 |
-
$button = '';
|
459 |
-
}
|
460 |
-
|
461 |
-
// Add additional classNames to .a2a_dd
|
462 |
-
$button_additional_classes = ! empty( $args['button_additional_classes'] ) ? ' ' . $args['button_additional_classes'] : '';
|
463 |
-
|
464 |
-
if ( isset( $options['button_show_count'] ) && $options['button_show_count'] == '1' ) {
|
465 |
-
$button_class .= ' a2a_counter';
|
466 |
-
}
|
467 |
-
|
468 |
-
$button_html = $html_container_open . $html_wrap_open . '<a class="a2a_dd' . $button_class . $button_additional_classes . ' addtoany_share_save" href="https://www.addtoany.com/share' .$button_href_querystring . '"'
|
469 |
-
. $button_data_url . $button_data_title . $button_data_media . $button_target
|
470 |
-
. '>' . $button . '</a>';
|
471 |
-
|
472 |
-
} else {
|
473 |
-
// Universal button disabled
|
474 |
-
$button_html = '';
|
475 |
-
}
|
476 |
-
|
477 |
-
// Closing tags come after <script> to validate in case the container is a list element
|
478 |
-
$button_html .= $html_wrap_close . $html_container_close;
|
479 |
-
|
480 |
-
if ( isset( $output_later ) && $output_later == true )
|
481 |
-
return $button_html;
|
482 |
-
else
|
483 |
-
echo $button_html;
|
484 |
-
}
|
485 |
-
|
486 |
-
function ADDTOANY_SHARE_SAVE_SPECIAL( $special_service_code, $args = array() ) {
|
487 |
-
// $args array = output_later, linkname, linkurl
|
488 |
-
|
489 |
-
if ( is_feed() ) {
|
490 |
-
return;
|
491 |
-
}
|
492 |
-
|
493 |
-
$options = get_option( 'addtoany_options', array() );
|
494 |
-
|
495 |
-
$linkname = ( isset( $args['linkname'] ) ) ? $args['linkname'] : false;
|
496 |
-
$linkurl = ( isset( $args['linkurl'] ) ) ? $args['linkurl'] : false;
|
497 |
-
$linkmedia = ( isset( $args['linkmedia'] ) ) ? $args['linkmedia'] : false;
|
498 |
-
|
499 |
-
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $linkname, $linkurl, $linkmedia ) ); // linkname_enc, etc.
|
500 |
-
extract( $args );
|
501 |
-
|
502 |
-
$special_anchor_template = '<a class="a2a_button_%1$s addtoany_special_service"%2$s></a>';
|
503 |
-
$custom_attributes = '';
|
504 |
-
|
505 |
-
if ( $special_service_code == 'facebook_like' ) {
|
506 |
-
$custom_attributes .= ( $options['special_facebook_like_options']['verb'] == 'recommend' ) ? ' data-action="recommend"' : '';
|
507 |
-
$custom_attributes .= ' data-href="' . $linkurl . '"';
|
508 |
-
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
509 |
-
}
|
510 |
-
|
511 |
-
elseif ( $special_service_code == 'twitter_tweet' ) {
|
512 |
-
$custom_attributes .= ' data-url="' . $linkurl . '"';
|
513 |
-
$custom_attributes .= ' data-text="' . $linkname . '"';
|
514 |
-
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
515 |
-
}
|
516 |
-
|
517 |
-
elseif ( $special_service_code == 'google_plusone' ) {
|
518 |
-
$custom_attributes .= ( $options['special_google_plusone_options']['show_count'] == '1' ) ? '' : ' data-annotation="none"';
|
519 |
-
$custom_attributes .= ' data-href="' . $linkurl . '"';
|
520 |
-
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
521 |
-
}
|
522 |
-
|
523 |
-
elseif ( $special_service_code == 'google_plus_share' ) {
|
524 |
-
$custom_attributes .= ( $options['special_google_plus_share_options']['show_count'] == '1' ) ? '' : ' data-annotation="none"';
|
525 |
-
$custom_attributes .= ' data-href="' . $linkurl . '"';
|
526 |
-
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
527 |
-
}
|
528 |
-
|
529 |
-
elseif ( $special_service_code == 'pinterest_pin' ) {
|
530 |
-
$custom_attributes .= ( $options['special_pinterest_pin_options']['show_count'] == '1' ) ? '' : ' data-pin-config="none"';
|
531 |
-
$custom_attributes .= ' data-url="' . $linkurl . '"';
|
532 |
-
$custom_attributes .= ( ! empty( $linkmedia ) ) ? ' data-media="' . $linkmedia . '"' : '';
|
533 |
-
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
534 |
-
}
|
535 |
-
|
536 |
-
if ( isset( $output_later ) && $output_later == true )
|
537 |
-
return $special_html;
|
538 |
-
else
|
539 |
-
echo $special_html;
|
540 |
-
}
|
541 |
-
|
542 |
-
if ( ! function_exists( 'A2A_menu_locale' ) ) {
|
543 |
-
function A2A_menu_locale() {
|
544 |
-
global $A2A_locale;
|
545 |
-
$locale = get_locale();
|
546 |
-
if ( $locale == 'en_US' || $locale == 'en' || $A2A_locale != '' )
|
547 |
-
return false;
|
548 |
-
|
549 |
-
$A2A_locale = 'a2a_localize = {
|
550 |
-
Share: "' . __( "Share", 'add-to-any' ) . '",
|
551 |
-
Save: "' . __( "Save", 'add-to-any' ) . '",
|
552 |
-
Subscribe: "' . __( "Subscribe", 'add-to-any' ) . '",
|
553 |
-
Email: "' . __( "Email", 'add-to-any' ) . '",
|
554 |
-
Bookmark: "' . __( "Bookmark", 'add-to-any' ) . '",
|
555 |
-
ShowAll: "' . __( "Show all", 'add-to-any' ) . '",
|
556 |
-
ShowLess: "' . __( "Show less", 'add-to-any' ) . '",
|
557 |
-
FindServices: "' . __( "Find service(s)", 'add-to-any' ) . '",
|
558 |
-
FindAnyServiceToAddTo: "' . __( "Instantly find any service to add to", 'add-to-any' ) . '",
|
559 |
-
PoweredBy: "' . __( "Powered by", 'add-to-any' ) . '",
|
560 |
-
ShareViaEmail: "' . __( "Share via email", 'add-to-any' ) . '",
|
561 |
-
SubscribeViaEmail: "' . __( "Subscribe via email", 'add-to-any' ) . '",
|
562 |
-
BookmarkInYourBrowser: "' . __( "Bookmark in your browser", 'add-to-any' ) . '",
|
563 |
-
BookmarkInstructions: "' . __( "Press Ctrl+D or \u2318+D to bookmark this page", 'add-to-any' ) . '",
|
564 |
-
AddToYourFavorites: "' . __( "Add to your favorites", 'add-to-any' ) . '",
|
565 |
-
SendFromWebOrProgram: "' . __( "Send from any email address or email program", 'add-to-any' ) . '",
|
566 |
-
EmailProgram: "' . __( "Email program", 'add-to-any' ) . '",
|
567 |
-
More: "' . __( "More…", 'add-to-any' ) . '"
|
568 |
-
};
|
569 |
-
';
|
570 |
-
return $A2A_locale;
|
571 |
-
}
|
572 |
-
}
|
573 |
-
|
574 |
-
function ADDTOANY_FOLLOW_KIT( $args = array() ) {
|
575 |
-
$options = get_option( 'addtoany_options', array() );
|
576 |
-
|
577 |
-
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT
|
578 |
-
$defaults = array(
|
579 |
-
'buttons' => array(),
|
580 |
-
'linkname' => '',
|
581 |
-
'linkurl' => '',
|
582 |
-
'linkname_enc' => '',
|
583 |
-
'linkurl_enc' => '',
|
584 |
-
'use_current_page' => false,
|
585 |
-
'output_later' => false,
|
586 |
-
'is_follow' => true,
|
587 |
-
'is_kit' => true,
|
588 |
-
'no_special_services' => true,
|
589 |
-
'no_universal_button' => true,
|
590 |
-
'kit_additional_classes' => '',
|
591 |
-
'kit_style' => '',
|
592 |
-
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
593 |
-
'services' => array(),
|
594 |
-
);
|
595 |
-
|
596 |
-
$args = wp_parse_args( $args, $defaults );
|
597 |
-
|
598 |
-
// Add a2a_follow className to Kit classes
|
599 |
-
$args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_follow' );
|
600 |
-
|
601 |
-
// If $args['buttons']['feed']['id'] is set
|
602 |
-
$buttons = $args['buttons'];
|
603 |
-
if ( ! empty( $buttons['feed'] ) && ! empty( $buttons['feed']['id'] ) ) {
|
604 |
-
$args['linkurl'] = $buttons['feed']['id'];
|
605 |
-
$args['linkname'] = get_bloginfo( 'name' );
|
606 |
-
}
|
607 |
-
|
608 |
-
$follow_html = ADDTOANY_SHARE_SAVE_KIT( $args );
|
609 |
-
|
610 |
-
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
|
611 |
-
return $follow_html;
|
612 |
-
else
|
613 |
-
echo $follow_html;
|
614 |
-
}
|
615 |
-
|
616 |
-
function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
617 |
-
$options = get_option( 'addtoany_options', array() );
|
618 |
-
|
619 |
-
$floating_html = '';
|
620 |
-
|
621 |
-
// Overridable by args below
|
622 |
-
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] ) ? $options['floating_vertical'] : false;
|
623 |
-
$horizontal_type = ( isset( $options['floating_horizontal'] ) && 'none' != $options['floating_horizontal'] ) ? $options['floating_horizontal'] : false;
|
624 |
-
|
625 |
-
if ( is_singular() ) {
|
626 |
-
// Disabled for this singular post?
|
627 |
-
$sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
|
628 |
-
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
629 |
-
|
630 |
-
if ( ! empty( $sharing_disabled ) ) {
|
631 |
-
// Overridable by args below
|
632 |
-
$vertical_type = false;
|
633 |
-
$horizontal_type = false;
|
634 |
-
}
|
635 |
-
}
|
636 |
-
|
637 |
-
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT
|
638 |
-
$defaults = array(
|
639 |
-
'linkname' => '',
|
640 |
-
'linkurl' => '',
|
641 |
-
'linkname_enc' => '',
|
642 |
-
'linkurl_enc' => '',
|
643 |
-
'use_current_page' => true,
|
644 |
-
'output_later' => false,
|
645 |
-
'is_floating' => true,
|
646 |
-
'is_kit' => true,
|
647 |
-
'no_addtoany_list_classname' => true,
|
648 |
-
'no_special_services' => true,
|
649 |
-
'kit_additional_classes' => '',
|
650 |
-
'kit_style' => '',
|
651 |
-
);
|
652 |
-
|
653 |
-
$args = wp_parse_args( $args, $defaults );
|
654 |
-
|
655 |
-
// Individual floating type args can override saved options
|
656 |
-
if ( isset( $args['vertical_type'] ) && $args['vertical_type'] === true ) {
|
657 |
-
$vertical_type = true;
|
658 |
-
}
|
659 |
-
if ( isset( $args['horizontal_type'] ) && $args['horizontal_type'] === true ) {
|
660 |
-
$horizontal_type = true;
|
661 |
-
}
|
662 |
-
|
663 |
-
// If either floating type is enabled
|
664 |
-
// Expect either a string from options, or a boolean from args
|
665 |
-
if ( $vertical_type || $horizontal_type ) {
|
666 |
-
// Vertical type?
|
667 |
-
if ( $vertical_type ) {
|
668 |
-
// Prevent overwriting of $args
|
669 |
-
$vertical_args = $args;
|
670 |
-
|
671 |
-
// Top position
|
672 |
-
$position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
|
673 |
-
// Left or right offset
|
674 |
-
$offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
|
675 |
-
// Icon size
|
676 |
-
$vertical_args['icon_size'] = ( isset( $options['floating_vertical_icon_size'] ) ) ? $options['floating_vertical_icon_size'] : '32';
|
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 |
-
|
688 |
-
$floating_html .= ADDTOANY_SHARE_SAVE_KIT( $vertical_args );
|
689 |
-
}
|
690 |
-
|
691 |
-
// Horizontal type?
|
692 |
-
if ( $horizontal_type ) {
|
693 |
-
// Prevent overwriting of $args values
|
694 |
-
$horizontal_args = $args;
|
695 |
-
|
696 |
-
// Left or right position
|
697 |
-
$position = ( isset( $options['floating_horizontal_position'] ) ) ? $options['floating_horizontal_position'] . 'px' : '0px';
|
698 |
-
// Bottom offset
|
699 |
-
$offset = ( isset( $options['floating_horizontal_offset'] ) ) ? $options['floating_horizontal_offset'] . 'px' : '0px';
|
700 |
-
// Icon size
|
701 |
-
$horizontal_args['icon_size'] = ( isset( $options['floating_horizontal_icon_size'] ) ) ? $options['floating_horizontal_icon_size'] : '32';
|
702 |
-
|
703 |
-
// Add a2a_default_style className to Kit classes
|
704 |
-
$horizontal_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_default_style' );
|
705 |
-
|
706 |
-
// Add declarations to Kit style attribute
|
707 |
-
if ( 'left_docked' === $horizontal_type ) {
|
708 |
-
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:' . $position . ';';
|
709 |
-
} elseif ( 'right_docked' === $horizontal_type ) {
|
710 |
-
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';right:' . $position . ';';
|
711 |
-
}
|
712 |
-
|
713 |
-
$floating_html .= ADDTOANY_SHARE_SAVE_KIT( $horizontal_args );
|
714 |
-
}
|
715 |
-
}
|
716 |
-
|
717 |
-
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
|
718 |
-
return $floating_html;
|
719 |
-
else
|
720 |
-
echo $floating_html;
|
721 |
-
}
|
722 |
-
|
723 |
-
|
724 |
-
function A2A_SHARE_SAVE_head_script() {
|
725 |
-
// Hook to disable script output
|
726 |
-
// Example: add_filter( 'addtoany_script_disabled', '__return_true' );
|
727 |
-
$script_disabled = apply_filters( 'addtoany_script_disabled', false );
|
728 |
-
|
729 |
-
if ( is_admin() || is_feed() || $script_disabled )
|
730 |
-
return;
|
731 |
-
|
732 |
-
$options = get_option( 'addtoany_options', array() );
|
733 |
-
|
734 |
-
// Use local cache?
|
735 |
-
$cache = ( isset( $options['cache'] ) && '1' == $options['cache'] ) ? true : false;
|
736 |
-
$upload_dir = wp_upload_dir();
|
737 |
-
$static_server = ( $cache ) ? $upload_dir['baseurl'] . '/addtoany' : 'https://static.addtoany.com/menu';
|
738 |
-
|
739 |
-
// Enternal script call + initial JS + set-once variables
|
740 |
-
$additional_js = ( isset( $options['additional_js_variables'] ) ) ? $options['additional_js_variables'] : '' ;
|
741 |
-
$script_configs = ( ( $cache ) ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '' )
|
742 |
-
. ( ( isset( $options['onclick'] ) && '1' == $options['onclick'] ) ? "\n" . 'a2a_config.onclick=1;' : '' )
|
743 |
-
. ( ( $additional_js ) ? "\n" . stripslashes( $additional_js ) : '' );
|
744 |
-
$A2A_SHARE_SAVE_external_script_called = true;
|
745 |
-
|
746 |
-
$javascript_header = "\n" . '<script type="text/javascript">' . "\n"
|
747 |
-
|
748 |
-
. "var a2a_config=a2a_config||{};"
|
749 |
-
. "a2a_config.callbacks=a2a_config.callbacks||[];"
|
750 |
-
. "a2a_config.templates=a2a_config.templates||{};"
|
751 |
-
. A2A_menu_locale()
|
752 |
-
. $script_configs
|
753 |
-
|
754 |
-
. "\n</script>\n"
|
755 |
-
|
756 |
-
. '<script type="text/javascript" src="' . $static_server . '/page.js" async="async"></script>' . "\n";
|
757 |
-
|
758 |
-
echo $javascript_header;
|
759 |
-
}
|
760 |
-
|
761 |
-
add_action( 'wp_head', 'A2A_SHARE_SAVE_head_script' );
|
762 |
-
|
763 |
-
function A2A_SHARE_SAVE_footer_script() {
|
764 |
-
if ( is_admin() || is_feed() )
|
765 |
-
return;
|
766 |
-
|
767 |
-
$floating_html = ADDTOANY_SHARE_SAVE_FLOATING( array( 'output_later' => true ) );
|
768 |
-
|
769 |
-
echo $floating_html;
|
770 |
-
}
|
771 |
-
|
772 |
-
add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
|
773 |
-
|
774 |
-
|
775 |
-
function A2A_SHARE_SAVE_add_to_content( $content ) {
|
776 |
-
global $wp_current_filter;
|
777 |
-
|
778 |
-
// Don't add to get_the_excerpt because it's too early and strips tags (adding to the_excerpt is allowed)
|
779 |
-
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
|
780 |
-
// Return early
|
781 |
-
return $content;
|
782 |
-
}
|
783 |
-
|
784 |
-
$sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
|
785 |
-
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
786 |
-
|
787 |
-
if (
|
788 |
-
// Private post
|
789 |
-
get_post_status( get_the_ID() ) == 'private' ||
|
790 |
-
// Sharing disabled on post
|
791 |
-
! empty( $sharing_disabled )
|
792 |
-
) {
|
793 |
-
// Return early
|
794 |
-
return $content;
|
795 |
-
}
|
796 |
-
|
797 |
-
$is_feed = is_feed();
|
798 |
-
$options = get_option( 'addtoany_options', array() );
|
799 |
-
$post_type = get_post_type( get_the_ID() );
|
800 |
-
|
801 |
-
if (
|
802 |
-
(
|
803 |
-
// Legacy tags
|
804 |
-
// <!--sharesave--> tag
|
805 |
-
strpos( $content, '<!--sharesave-->' ) === false ||
|
806 |
-
// <!--nosharesave--> tag
|
807 |
-
strpos( $content, '<!--nosharesave-->' ) !== false
|
808 |
-
) &&
|
809 |
-
(
|
810 |
-
// Posts
|
811 |
-
// All posts
|
812 |
-
( is_singular('post') && isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) ||
|
813 |
-
// Front page posts
|
814 |
-
( is_home() && isset( $options['display_in_posts_on_front_page'] ) && $options['display_in_posts_on_front_page'] == '-1' ) ||
|
815 |
-
// Archive page posts (Category, Tag, Author and Date pages)
|
816 |
-
( is_archive() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
817 |
-
// Search results posts (same as Archive page posts option)
|
818 |
-
( is_search() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
819 |
-
// Excerpt (the_excerpt is the current filter)
|
820 |
-
( 'the_excerpt' == current_filter() && isset( $options['display_in_excerpts'] ) && $options['display_in_excerpts'] == '-1' ) ||
|
821 |
-
// Posts in feed
|
822 |
-
( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
|
823 |
-
|
824 |
-
// Custom post types
|
825 |
-
( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' ) ||
|
826 |
-
|
827 |
-
// Pages
|
828 |
-
// Individual pages
|
829 |
-
( is_page() && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
|
830 |
-
// Attachment (media) pages
|
831 |
-
( is_attachment() && isset( $options['display_in_attachments'] ) && $options['display_in_attachments'] == '-1' ) ||
|
832 |
-
// <!--nosharesave--> legacy tag
|
833 |
-
( (strpos( $content, '<!--nosharesave-->') !== false ) )
|
834 |
-
)
|
835 |
-
) {
|
836 |
-
// Return early
|
837 |
-
return $content;
|
838 |
-
}
|
839 |
-
|
840 |
-
$kit_args = array(
|
841 |
-
"output_later" => true,
|
842 |
-
"is_kit" => ( $is_feed ) ? false : true,
|
843 |
-
);
|
844 |
-
|
845 |
-
// If a Sharing Header is set
|
846 |
-
if ( isset( $options['header'] ) && '' != $options['header'] ) {
|
847 |
-
$html_header = '<div class="addtoany_header">' . stripslashes( $options['header'] ) . '</div>';
|
848 |
-
} else {
|
849 |
-
$html_header = '';
|
850 |
-
}
|
851 |
-
|
852 |
-
if ( $is_feed ) {
|
853 |
-
$container_wrap_open = '<p>';
|
854 |
-
$container_wrap_close = '</p>';
|
855 |
-
$kit_args['html_container_open'] = '';
|
856 |
-
$kit_args['html_container_close'] = '';
|
857 |
-
$kit_args['html_wrap_open'] = '';
|
858 |
-
$kit_args['html_wrap_close'] = '';
|
859 |
-
} else {
|
860 |
-
$container_wrap_open = '<div class="addtoany_share_save_container %s">'; // Contains placeholder
|
861 |
-
$container_wrap_open .= $html_header;
|
862 |
-
$container_wrap_close = '</div>';
|
863 |
-
}
|
864 |
-
|
865 |
-
$options['position'] = isset( $options['position'] ) ? $options['position'] : 'bottom';
|
866 |
-
|
867 |
-
if ($options['position'] == 'both' || $options['position'] == 'top') {
|
868 |
-
// Prepend to content
|
869 |
-
$content = sprintf( $container_wrap_open, 'addtoany_content_top' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close . $content;
|
870 |
-
}
|
871 |
-
if ( $options['position'] == 'bottom' || $options['position'] == 'both') {
|
872 |
-
// Append to content
|
873 |
-
$content .= sprintf( $container_wrap_open, 'addtoany_content_bottom' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close;
|
874 |
-
}
|
875 |
-
|
876 |
-
return $content;
|
877 |
-
}
|
878 |
-
|
879 |
-
|
880 |
-
function A2A_SHARE_SAVE_pre_get_posts( $query ) {
|
881 |
-
if ( $query->is_main_query() ) {
|
882 |
-
add_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content', 98 );
|
883 |
-
add_filter( 'the_excerpt', 'A2A_SHARE_SAVE_add_to_content', 98 );
|
884 |
-
}
|
885 |
-
}
|
886 |
-
|
887 |
-
add_action( 'pre_get_posts', 'A2A_SHARE_SAVE_pre_get_posts' );
|
888 |
-
|
889 |
-
|
890 |
-
// [addtoany url="https://www.example.com/page.html" title="Example Page"]
|
891 |
-
function A2A_SHARE_SAVE_shortcode( $attributes ) {
|
892 |
-
$attributes = shortcode_atts( array(
|
893 |
-
'url' => '',
|
894 |
-
'title' => '',
|
895 |
-
'media' => '',
|
896 |
-
'buttons' => '',
|
897 |
-
), $attributes, 'addtoany' );
|
898 |
-
|
899 |
-
$linkname = ! empty( $attributes['title'] ) ? $attributes['title'] : false;
|
900 |
-
$linkurl = ! empty( $attributes['url'] ) ? $attributes['url'] : false;
|
901 |
-
$linkmedia = ! empty( $attributes['media'] ) ? $attributes['media'] : false;
|
902 |
-
$buttons = ! empty( $attributes['buttons'] ) ? explode( ',', $attributes['buttons'] ) : array();
|
903 |
-
|
904 |
-
$output_later = true;
|
905 |
-
|
906 |
-
return '<div class="addtoany_shortcode">'
|
907 |
-
. ADDTOANY_SHARE_SAVE_KIT( compact( 'linkname', 'linkurl', 'linkmedia', 'output_later', 'buttons' ) )
|
908 |
-
. '</div>';
|
909 |
-
}
|
910 |
-
|
911 |
-
add_shortcode( 'addtoany', 'A2A_SHARE_SAVE_shortcode' );
|
912 |
-
|
913 |
-
|
914 |
-
function A2A_SHARE_SAVE_stylesheet() {
|
915 |
-
global $A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_url_path;
|
916 |
-
|
917 |
-
$options = $A2A_SHARE_SAVE_options;
|
918 |
-
|
919 |
-
// Use stylesheet?
|
920 |
-
if ( ! isset( $options['inline_css'] ) || $options['inline_css'] != '-1' && ! is_admin() ) {
|
921 |
-
|
922 |
-
wp_enqueue_style( 'A2A_SHARE_SAVE', $A2A_SHARE_SAVE_plugin_url_path . '/addtoany.min.css', false, '1.14' );
|
923 |
-
|
924 |
-
// wp_add_inline_style requires WP 3.3+
|
925 |
-
if ( '3.3' <= get_bloginfo( 'version' ) ) {
|
926 |
-
|
927 |
-
// Prepare inline CSS
|
928 |
-
$inline_css = '';
|
929 |
-
|
930 |
-
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] ) ? $options['floating_vertical'] : false;
|
931 |
-
$horizontal_type = ( isset( $options['floating_horizontal'] ) && 'none' != $options['floating_horizontal'] ) ? $options['floating_horizontal'] : false;
|
932 |
-
|
933 |
-
// If vertical bar is enabled
|
934 |
-
if ( $vertical_type &&
|
935 |
-
// and respsonsiveness is enabled
|
936 |
-
( ! isset( $options['floating_vertical_responsive'] ) || '-1' != $options['floating_vertical_responsive'] )
|
937 |
-
) {
|
938 |
-
|
939 |
-
// Get min-width for media query
|
940 |
-
$vertical_max_width = (
|
941 |
-
isset( $options['floating_vertical_responsive_max_width'] ) &&
|
942 |
-
is_numeric( $options['floating_vertical_responsive_max_width'] )
|
943 |
-
) ? $options['floating_vertical_responsive_max_width'] : '980';
|
944 |
-
|
945 |
-
// Set media query
|
946 |
-
$inline_css .= '@media screen and (max-width:' . $vertical_max_width . 'px){' . "\n"
|
947 |
-
. '.a2a_floating_style.a2a_vertical_style{display:none;}' . "\n"
|
948 |
-
. '}';
|
949 |
-
|
950 |
-
}
|
951 |
-
|
952 |
-
// If horizontal bar is enabled
|
953 |
-
if ( $horizontal_type &&
|
954 |
-
// and respsonsiveness is enabled
|
955 |
-
( ! isset( $options['floating_horizontal_responsive'] ) || '-1' != $options['floating_horizontal_responsive'] )
|
956 |
-
) {
|
957 |
-
|
958 |
-
// Get max-width for media query
|
959 |
-
$horizontal_min_width = (
|
960 |
-
isset( $options['floating_horizontal_responsive_min_width'] ) &&
|
961 |
-
is_numeric( $options['floating_horizontal_responsive_min_width'] )
|
962 |
-
) ? $options['floating_horizontal_responsive_min_width'] : '981';
|
963 |
-
|
964 |
-
// Insert newline if there is inline CSS already
|
965 |
-
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
966 |
-
|
967 |
-
// Set media query
|
968 |
-
$inline_css .= '@media screen and (min-width:' . $horizontal_min_width . 'px){' . "\n"
|
969 |
-
. '.a2a_floating_style.a2a_default_style{display:none;}' . "\n"
|
970 |
-
. '}';
|
971 |
-
|
972 |
-
}
|
973 |
-
|
974 |
-
// If additional CSS (custom CSS for AddToAny) is set
|
975 |
-
if ( ! empty( $options['additional_css'] ) ) {
|
976 |
-
$custom_css = stripslashes( $options['additional_css'] );
|
977 |
-
|
978 |
-
// Insert newline if there is inline CSS already
|
979 |
-
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
980 |
-
|
981 |
-
$inline_css .= $custom_css;
|
982 |
-
}
|
983 |
-
|
984 |
-
// If there is inline CSS
|
985 |
-
if ( 0 < strlen( $inline_css ) ) {
|
986 |
-
// Insert inline CSS
|
987 |
-
wp_add_inline_style( 'A2A_SHARE_SAVE', $inline_css );
|
988 |
-
}
|
989 |
-
|
990 |
-
}
|
991 |
-
|
992 |
-
}
|
993 |
-
|
994 |
-
}
|
995 |
-
|
996 |
-
add_action( '
|
997 |
-
|
998 |
-
function A2A_SHARE_SAVE_enqueue_script() {
|
999 |
-
global $A2A_SHARE_SAVE_plugin_url_path;
|
1000 |
-
|
1001 |
-
if ( wp_script_is( 'jquery', 'registered' ) ) {
|
1002 |
-
wp_enqueue_script( 'addtoany', $A2A_SHARE_SAVE_plugin_url_path . '/addtoany.min.js', array( 'jquery' ), '1.0' );
|
1003 |
-
}
|
1004 |
-
}
|
1005 |
-
|
1006 |
-
add_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' );
|
1007 |
-
|
1008 |
-
|
1009 |
-
/**
|
1010 |
-
* Cache AddToAny
|
1011 |
-
*/
|
1012 |
-
|
1013 |
-
function A2A_SHARE_SAVE_refresh_cache() {
|
1014 |
-
$contents = wp_remote_fopen( 'https://www.addtoany.com/ext/updater/files_list/' );
|
1015 |
-
$file_urls = explode( "\n", $contents, 20 );
|
1016 |
-
$upload_dir = wp_upload_dir();
|
1017 |
-
|
1018 |
-
// Make directory if needed
|
1019 |
-
if ( ! wp_mkdir_p( dirname( $upload_dir['basedir'] . '/addtoany/foo' ) ) ) {
|
1020 |
-
$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), dirname( $new_file ) );
|
1021 |
-
return array( 'error' => $message );
|
1022 |
-
}
|
1023 |
-
|
1024 |
-
if ( count( $file_urls ) > 0 ) {
|
1025 |
-
for ( $i = 0; $i < count( $file_urls ); $i++ ) {
|
1026 |
-
// Download files
|
1027 |
-
$file_url = trim( $file_urls[ $i ] );
|
1028 |
-
$file_name = substr( strrchr( $file_url, '/' ), 1, 99 );
|
1029 |
-
|
1030 |
-
// Place files in uploads/addtoany directory
|
1031 |
-
wp_remote_get( $file_url, array(
|
1032 |
-
'filename' => $upload_dir['basedir'] . '/addtoany/' . $file_name,
|
1033 |
-
'stream' => true, // Required to use `filename` arg
|
1034 |
-
) );
|
1035 |
-
}
|
1036 |
-
}
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
function A2A_SHARE_SAVE_schedule_cache() {
|
1040 |
-
// WP "Cron" requires WP version 2.1
|
1041 |
-
$timestamp = wp_next_scheduled( 'A2A_SHARE_SAVE_refresh_cache' );
|
1042 |
-
if ( ! $timestamp) {
|
1043 |
-
// Only schedule if currently unscheduled
|
1044 |
-
wp_schedule_event( time(), 'daily', 'A2A_SHARE_SAVE_refresh_cache' );
|
1045 |
-
}
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
function A2A_SHARE_SAVE_unschedule_cache() {
|
1049 |
-
$timestamp = wp_next_scheduled( 'A2A_SHARE_SAVE_refresh_cache' );
|
1050 |
-
wp_unschedule_event( $timestamp, 'A2A_SHARE_SAVE_refresh_cache' );
|
1051 |
-
}
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
/**
|
1056 |
-
* Admin Options
|
1057 |
-
*/
|
1058 |
-
|
1059 |
-
if ( is_admin() ) {
|
1060 |
-
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.admin.php';
|
1061 |
-
}
|
1062 |
-
|
1063 |
-
function A2A_SHARE_SAVE_add_menu_link() {
|
1064 |
-
$page = add_options_page(
|
1065 |
-
__( 'AddToAny Share Settings', 'add-to-any' ),
|
1066 |
-
__( 'AddToAny', 'add-to-any' ),
|
1067 |
-
'manage_options',
|
1068 |
-
'addtoany',
|
1069 |
-
'A2A_SHARE_SAVE_options_page'
|
1070 |
-
);
|
1071 |
-
|
1072 |
-
/* Using registered $page handle to hook script load, to only load in AddToAny admin */
|
1073 |
-
add_filter( 'admin_print_scripts-' . $page, 'A2A_SHARE_SAVE_scripts' );
|
1074 |
-
}
|
1075 |
-
|
1076 |
-
add_filter( 'admin_menu', 'A2A_SHARE_SAVE_add_menu_link' );
|
1077 |
-
|
1078 |
-
function A2A_SHARE_SAVE_widgets_init() {
|
1079 |
-
global $A2A_SHARE_SAVE_plugin_dir;
|
1080 |
-
|
1081 |
-
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.widgets.php';
|
1082 |
-
register_widget( 'A2A_SHARE_SAVE_Widget' );
|
1083 |
-
register_widget( 'A2A_Follow_Widget' );
|
1084 |
-
}
|
1085 |
-
|
1086 |
-
add_action( 'widgets_init', 'A2A_SHARE_SAVE_widgets_init' );
|
1087 |
-
|
1088 |
-
// Place in Option List on Settings > Plugins page
|
1089 |
-
function A2A_SHARE_SAVE_actlinks( $links, $file ) {
|
1090 |
-
// Static so we don't call plugin_basename on every plugin row.
|
1091 |
-
static $this_plugin;
|
1092 |
-
|
1093 |
-
if ( ! $this_plugin ) {
|
1094 |
-
$this_plugin = plugin_basename( __FILE__ );
|
1095 |
-
}
|
1096 |
-
|
1097 |
-
if ( $file == $this_plugin ) {
|
1098 |
-
$settings_link = '<a href="options-general.php?page=addtoany">' . __( 'Settings' ) . '</a>';
|
1099 |
-
array_unshift( $links, $settings_link ); // before other links
|
1100 |
-
}
|
1101 |
-
|
1102 |
-
return $links;
|
1103 |
-
}
|
1104 |
-
|
1105 |
-
add_filter( 'plugin_action_links', 'A2A_SHARE_SAVE_actlinks', 10, 2 );
|
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.15
|
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_plugin_basename, $A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url_path,
|
16 |
+
$A2A_SHARE_SAVE_services, $A2A_SHARE_SAVE_amp_icons_css;
|
17 |
+
|
18 |
+
$A2A_SHARE_SAVE_plugin_basename = plugin_basename( dirname( __FILE__ ) );
|
19 |
+
$A2A_SHARE_SAVE_plugin_dir = untrailingslashit( plugin_dir_path( __FILE__ ) );
|
20 |
+
$A2A_SHARE_SAVE_plugin_url_path = untrailingslashit( plugin_dir_url( __FILE__ ) );
|
21 |
+
|
22 |
+
// HTTPS?
|
23 |
+
$A2A_SHARE_SAVE_plugin_url_path = is_ssl() ? str_replace( 'http:', 'https:', $A2A_SHARE_SAVE_plugin_url_path ) : $A2A_SHARE_SAVE_plugin_url_path;
|
24 |
+
// Set AddToAny locale (JavaScript)
|
25 |
+
$A2A_locale = ! isset ( $A2A_locale ) ? '' : $A2A_locale;
|
26 |
+
// Set plugin options
|
27 |
+
$A2A_SHARE_SAVE_options = get_option( 'addtoany_options', array() );
|
28 |
+
|
29 |
+
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.compat.php';
|
30 |
+
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php';
|
31 |
+
|
32 |
+
function A2A_SHARE_SAVE_init() {
|
33 |
+
global $A2A_SHARE_SAVE_plugin_dir,
|
34 |
+
$A2A_SHARE_SAVE_plugin_basename,
|
35 |
+
$A2A_SHARE_SAVE_options;
|
36 |
+
|
37 |
+
// Load the textdomain for translations
|
38 |
+
load_plugin_textdomain( 'add-to-any', false, $A2A_SHARE_SAVE_plugin_basename . '/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',
|
44 |
+
'share_save_256_24.png|256|24', 'share_save_171_16.png|171|16', 'share_save_120_16.png|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();
|
52 |
+
}
|
53 |
+
}
|
54 |
+
add_filter( 'init', 'A2A_SHARE_SAVE_init' );
|
55 |
+
|
56 |
+
function A2A_SHARE_SAVE_link_vars( $linkname = false, $linkurl = false, $linkmedia = false, $use_current_page = false ) {
|
57 |
+
global $post;
|
58 |
+
|
59 |
+
// Set linkname
|
60 |
+
if ( ! $linkname ) {
|
61 |
+
if ( $use_current_page ) {
|
62 |
+
$linkname = is_home() || is_front_page() ? get_bloginfo( 'name' ) : rtrim( wp_title( '', false, 'right' ) );
|
63 |
+
} elseif ( isset( $post ) ) {
|
64 |
+
$linkname = html_entity_decode( strip_tags( get_the_title( $post->ID ) ), ENT_QUOTES, 'UTF-8' );
|
65 |
+
} else {
|
66 |
+
$linkname = '';
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
$linkname_enc = rawurlencode( $linkname );
|
71 |
+
|
72 |
+
// Set linkurl
|
73 |
+
if ( ! $linkurl ) {
|
74 |
+
if ( $use_current_page ) {
|
75 |
+
$linkurl = esc_url_raw( home_url( $_SERVER['REQUEST_URI'] ) );
|
76 |
+
} elseif ( isset( $post ) ) {
|
77 |
+
$linkurl = get_permalink( $post->ID );
|
78 |
+
} else {
|
79 |
+
$linkurl = '';
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
$linkurl_enc = rawurlencode( $linkurl );
|
84 |
+
|
85 |
+
// Set linkmedia (only applies to services that explicitly accept media; Pinterest does, most do not)
|
86 |
+
$linkmedia_enc = ! empty( $linkmedia ) ? rawurlencode( $linkmedia ) : false;
|
87 |
+
|
88 |
+
return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc', 'linkmedia', 'linkmedia_enc' );
|
89 |
+
}
|
90 |
+
|
91 |
+
// Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
|
92 |
+
function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
|
93 |
+
$options = get_option( 'addtoany_options', array() );
|
94 |
+
|
95 |
+
$linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
|
96 |
+
$linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
|
97 |
+
$linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
|
98 |
+
$use_current_page = isset( $args['use_current_page'] ) ? $args['use_current_page'] : false;
|
99 |
+
|
100 |
+
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $linkname, $linkurl, $linkmedia, $use_current_page ) ); // linkname_enc, etc.
|
101 |
+
|
102 |
+
$defaults = array(
|
103 |
+
'output_later' => false,
|
104 |
+
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
105 |
+
);
|
106 |
+
|
107 |
+
$args = wp_parse_args( $args, $defaults );
|
108 |
+
extract( $args );
|
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 |
+
|
117 |
+
// Custom icons enabled?
|
118 |
+
$custom_icons = ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) ? true : false;
|
119 |
+
|
120 |
+
$kit_additional_classes = '';
|
121 |
+
$kit_data_media = empty( $linkmedia ) ? '' : ' data-a2a-media="' . $linkmedia . '"';
|
122 |
+
$kit_data_title = empty( $linkname ) || $use_current_page ? '' : ' data-a2a-title="' . $linkname . '"';
|
123 |
+
$kit_data_url = empty( $linkurl ) || $use_current_page ? '' : ' data-a2a-url="' . $linkurl . '"';
|
124 |
+
$kit_style = '';
|
125 |
+
|
126 |
+
// Add additional classNames to .a2a_kit
|
127 |
+
if ( ! empty( $args['kit_additional_classes'] ) ) {
|
128 |
+
// Append space and className(s)
|
129 |
+
$kit_additional_classes .= ' ' . $args['kit_additional_classes'];
|
130 |
+
}
|
131 |
+
|
132 |
+
// Set a2a_kit_size_## class name
|
133 |
+
if ( $custom_icons ) {
|
134 |
+
// If vertical style (.a2a_vertical_style)
|
135 |
+
if ( strpos( $kit_additional_classes, 'a2a_vertical_style' ) !== false ) {
|
136 |
+
// Use width (if specified) for .a2a_kit_size_## class name to size default service counters
|
137 |
+
$icon_size_classname = isset( $options['custom_icons_width'] ) ? ' a2a_kit_size_' . $options['custom_icons_width'] : '';
|
138 |
+
} else {
|
139 |
+
// Use height (if specified) for .a2a_kit_size_## class name to size default service counters
|
140 |
+
$icon_size_classname = isset( $options['custom_icons_height'] ) ? ' a2a_kit_size_' . $options['custom_icons_height'] : '';
|
141 |
+
}
|
142 |
+
// a2a_kit_size_## icon size
|
143 |
+
} else {
|
144 |
+
$icon_size_classname = ' a2a_kit_size_' . $icon_size;
|
145 |
+
}
|
146 |
+
|
147 |
+
// Add addtoany_list className unless disabled (for floating buttons)
|
148 |
+
if ( ! isset( $args['no_addtoany_list_classname'] ) ) {
|
149 |
+
$kit_additional_classes .= ' addtoany_list';
|
150 |
+
}
|
151 |
+
|
152 |
+
// Add style attribute if set
|
153 |
+
if ( isset( $args['kit_style'] ) ) {
|
154 |
+
$kit_style = ' style="' . $args['kit_style'] . '"';
|
155 |
+
}
|
156 |
+
|
157 |
+
if ( ! isset( $args['html_container_open'] ) ) {
|
158 |
+
$args['html_container_open'] = '<div class="a2a_kit' . $icon_size_classname . $kit_additional_classes . '"'
|
159 |
+
. $kit_data_url . $kit_data_title . $kit_data_media . $kit_style . '>';
|
160 |
+
$args['is_kit'] = true;
|
161 |
+
}
|
162 |
+
if ( ! isset( $args['html_container_close'] ) )
|
163 |
+
$args['html_container_close'] = "</div>";
|
164 |
+
// Close container element in ADDTOANY_SHARE_SAVE_BUTTON, not prematurely in ADDTOANY_SHARE_SAVE_ICONS
|
165 |
+
$html_container_close = $args['html_container_close']; // Cache for _BUTTON
|
166 |
+
unset($args['html_container_close']); // Avoid passing to ADDTOANY_SHARE_SAVE_ICONS since set in _BUTTON
|
167 |
+
|
168 |
+
if ( ! isset( $args['html_wrap_open'] ) )
|
169 |
+
$args['html_wrap_open'] = "";
|
170 |
+
if ( ! isset( $args['html_wrap_close'] ) )
|
171 |
+
$args['html_wrap_close'] = "";
|
172 |
+
|
173 |
+
$kit_html = ADDTOANY_SHARE_SAVE_ICONS( $args );
|
174 |
+
|
175 |
+
$args['html_container_close'] = $html_container_close; // Re-set because unset above for _ICONS
|
176 |
+
unset( $args['html_container_open'] ); // Avoid passing to ADDTOANY_SHARE_SAVE_BUTTON since set in _ICONS
|
177 |
+
|
178 |
+
$kit_html .= ADDTOANY_SHARE_SAVE_BUTTON( $args );
|
179 |
+
|
180 |
+
if ( true == $output_later )
|
181 |
+
return $kit_html;
|
182 |
+
else
|
183 |
+
echo $kit_html;
|
184 |
+
}
|
185 |
+
|
186 |
+
function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
|
187 |
+
// $args array: output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl
|
188 |
+
|
189 |
+
global $A2A_SHARE_SAVE_plugin_url_path,
|
190 |
+
$A2A_SHARE_SAVE_services,
|
191 |
+
$A2A_FOLLOW_services,
|
192 |
+
$A2A_SHARE_SAVE_amp_icons_css;
|
193 |
+
|
194 |
+
$options = get_option( 'addtoany_options', array() );
|
195 |
+
|
196 |
+
$linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
|
197 |
+
$linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
|
198 |
+
$linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
|
199 |
+
|
200 |
+
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $linkname, $linkurl, $linkmedia ) ); // linkname_enc, etc.
|
201 |
+
|
202 |
+
$defaults = array(
|
203 |
+
'linkname' => '',
|
204 |
+
'linkurl' => '',
|
205 |
+
'linkmedia' => '',
|
206 |
+
'linkname_enc' => '',
|
207 |
+
'linkurl_enc' => '',
|
208 |
+
'linkmedia_enc' => '',
|
209 |
+
'output_later' => false,
|
210 |
+
'html_container_open' => '',
|
211 |
+
'html_container_close' => '',
|
212 |
+
'html_wrap_open' => '',
|
213 |
+
'html_wrap_close' => '',
|
214 |
+
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
215 |
+
'is_follow' => false,
|
216 |
+
'no_universal_button' => false,
|
217 |
+
'buttons' => array(),
|
218 |
+
);
|
219 |
+
|
220 |
+
$args = wp_parse_args( $args, $defaults );
|
221 |
+
extract( $args );
|
222 |
+
|
223 |
+
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
|
224 |
+
$amp_css = '.a2a_dd img{background-color:#0166FF;}';
|
225 |
+
|
226 |
+
// Large icons except for AMP endpoint
|
227 |
+
$large_icons = $is_amp ? false : true;
|
228 |
+
|
229 |
+
// Directory of either custom icons or the packaged icons
|
230 |
+
if ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) {
|
231 |
+
// Custom icons expected at a specified URL, i.e. //example.com/blog/uploads/addtoany/icons/custom/
|
232 |
+
$icons_dir = $options['custom_icons_url'];
|
233 |
+
$icons_type = ( isset( $options['custom_icons_type'] ) ) ? $options['custom_icons_type'] : 'png';
|
234 |
+
$icons_width = ( isset( $options['custom_icons_width'] ) ) ? $options['custom_icons_width'] : '';
|
235 |
+
$icons_height = ( isset( $options['custom_icons_height'] ) ) ? $options['custom_icons_height'] : '';
|
236 |
+
$custom_icons = true;
|
237 |
+
} else {
|
238 |
+
// Default to local SVGs (not an option currently)
|
239 |
+
$icons_dir = $A2A_SHARE_SAVE_plugin_url_path . '/icons/';
|
240 |
+
$icons_type = 'svg';
|
241 |
+
}
|
242 |
+
|
243 |
+
// If Follow kit
|
244 |
+
if ( $is_follow ) {
|
245 |
+
// Make available services extensible via plugins, themes (functions.php), etc.
|
246 |
+
$services = apply_filters( 'A2A_FOLLOW_services', $A2A_FOLLOW_services );
|
247 |
+
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
|
248 |
+
|
249 |
+
// Services set by "buttons" arg
|
250 |
+
$active_services = ! empty ( $buttons ) ? array_keys( $buttons ) : array();
|
251 |
+
// Else Share kit
|
252 |
+
} else {
|
253 |
+
// Make available services extensible via plugins, themes (functions.php), etc.
|
254 |
+
$services = apply_filters( 'A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services );
|
255 |
+
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
|
256 |
+
|
257 |
+
// Include Facebook Like and Twitter Tweet etc. unless no_special_services arg is true
|
258 |
+
if ( ! isset( $no_special_services ) || false == $no_special_services ) {
|
259 |
+
array_unshift( $service_codes, 'facebook_like', 'twitter_tweet', 'google_plusone', 'google_plus_share', 'pinterest_pin' );
|
260 |
+
}
|
261 |
+
|
262 |
+
// Use default services if services have not been selected yet
|
263 |
+
$active_services = ( isset( $options['active_services'] ) ) ? $options['active_services'] : array( 'facebook', 'twitter', 'google_plus' );
|
264 |
+
// Services set by "buttons" arg? Then use "buttons" arg instead
|
265 |
+
$active_services = ! empty ( $buttons ) ? $buttons : $active_services;
|
266 |
+
}
|
267 |
+
|
268 |
+
$ind_html = "" . $html_container_open;
|
269 |
+
|
270 |
+
foreach( $active_services as $active_service ) {
|
271 |
+
|
272 |
+
$custom_service = false;
|
273 |
+
|
274 |
+
if ( ! in_array( $active_service, $service_codes ) )
|
275 |
+
continue;
|
276 |
+
|
277 |
+
if ( $active_service == 'facebook_like' || $active_service == 'twitter_tweet' || $active_service == 'google_plusone' || $active_service == 'google_plus_share' || $active_service == 'pinterest_pin' ) {
|
278 |
+
$special_args = $args;
|
279 |
+
$special_args['output_later'] = true;
|
280 |
+
$link = ADDTOANY_SHARE_SAVE_SPECIAL( $active_service, $special_args );
|
281 |
+
} else {
|
282 |
+
$service = $services[ $active_service ];
|
283 |
+
$safe_name = $active_service;
|
284 |
+
$name = $service['name'];
|
285 |
+
|
286 |
+
// If Follow kit and HREF specified
|
287 |
+
if ( $is_follow && isset( $service['href'] ) ) {
|
288 |
+
$follow_id = $buttons[ $active_service ]['id'];
|
289 |
+
$is_url = in_array( parse_url( $follow_id, PHP_URL_SCHEME ), array( 'http', 'https' ) );
|
290 |
+
|
291 |
+
// If it's a URL instead of a service ID
|
292 |
+
if ( $is_url ) {
|
293 |
+
// Just use the given URL instead of the URL template
|
294 |
+
$href = $follow_id;
|
295 |
+
} else {
|
296 |
+
// Replace the ID placeholder in the URL template
|
297 |
+
$href = str_replace( '${id}', $follow_id, $service['href'] );
|
298 |
+
}
|
299 |
+
$href = ( 'feed' == $safe_name ) ? $follow_id : $href;
|
300 |
+
|
301 |
+
// If icon_url is set, presume custom service
|
302 |
+
if ( isset( $service['icon_url'] ) ) {
|
303 |
+
$custom_service = true;
|
304 |
+
}
|
305 |
+
// Else if Share Kit and HREF specified, presume custom service
|
306 |
+
} elseif ( isset( $service['href'] ) ) {
|
307 |
+
$custom_service = true;
|
308 |
+
$href = $service['href'];
|
309 |
+
if ( isset( $service['href_js_esc'] ) ) {
|
310 |
+
$href_linkurl = str_replace( "'", "\'", $linkurl );
|
311 |
+
$href_linkname = str_replace( "'", "\'", $linkname );
|
312 |
+
} else {
|
313 |
+
$href_linkurl = $linkurl_enc;
|
314 |
+
$href_linkname = $linkname_enc;
|
315 |
+
}
|
316 |
+
$href = str_replace( "A2A_LINKURL", $href_linkurl, $href );
|
317 |
+
$href = str_replace( "A2A_LINKNAME", $href_linkname, $href );
|
318 |
+
$href = str_replace( " ", "%20", $href );
|
319 |
+
}
|
320 |
+
|
321 |
+
// AddToAny counter enabled?
|
322 |
+
$counter_enabled = ( ! $is_follow // Disable counters on Follow Kits
|
323 |
+
&& in_array( $active_service, array( 'facebook', 'pinterest', 'linkedin', 'reddit' ) )
|
324 |
+
&& isset( $options['special_' . $active_service . '_options'] )
|
325 |
+
&& isset( $options['special_' . $active_service . '_options']['show_count'] )
|
326 |
+
&& $options['special_' . $active_service . '_options']['show_count'] == '1'
|
327 |
+
) ? true : false;
|
328 |
+
|
329 |
+
$icon = isset( $service['icon'] ) ? $service['icon'] : 'default'; // Just the icon filename
|
330 |
+
$icon_url = isset( $service['icon_url'] ) ? $service['icon_url'] : false;
|
331 |
+
$icon_url = $is_amp && ! $icon_url ? 'https://static.addtoany.com/buttons/' . $icon . '.svg' : $icon_url;
|
332 |
+
$width_attr = isset( $service['icon_width'] ) ? ' width="' . $service['icon_width'] . '"' : ' width="16"';
|
333 |
+
$width_attr = $is_amp && ! empty( $icon_size ) ? ' width="' . $icon_size . '"' : $width_attr;
|
334 |
+
$height_attr = isset( $service['icon_height'] ) ? ' height="' . $service['icon_height'] . '"' : ' height="16"';
|
335 |
+
$height_attr = $is_amp && ! empty( $icon_size ) ? ' height="' . $icon_size . '"' : $height_attr;
|
336 |
+
|
337 |
+
$amp_css .= $is_amp && ! empty( $service['color'] ) ? '.a2a_button_' . $safe_name . ' img{background-color:#' . $service['color'] . ';}' : '';
|
338 |
+
|
339 |
+
$url = isset( $href ) ? $href : 'https://www.addtoany.com/add_to/' . $safe_name . '?linkurl=' . $linkurl_enc .'&linkname=' . $linkname_enc;
|
340 |
+
$src = $icon_url ? $icon_url : $icons_dir . $icon . '.' . $icons_type;
|
341 |
+
$counter = $counter_enabled ? ' a2a_counter' : '';
|
342 |
+
$class_attr = $custom_service ? '' : ' class="a2a_button_' . $safe_name . $counter . '"';
|
343 |
+
|
344 |
+
if ( isset( $service['target'] ) ) {
|
345 |
+
$target_attr = empty( $service['target'] ) ? '' : ' target="' . $service['target'] . '"';
|
346 |
+
} else {
|
347 |
+
$target_attr = ' target="_blank"';
|
348 |
+
}
|
349 |
+
|
350 |
+
// Use rel="noopener" for links that open in a new tab/window
|
351 |
+
$rel_noopener = $custom_service || ! $target_attr ? '' : ' noopener';
|
352 |
+
$rel_noopener_only = $rel_noopener || $target_attr ? ' rel="noopener"' : '';
|
353 |
+
$rel_attr = $is_follow ? $rel_noopener_only : ' rel="nofollow' . $rel_noopener . '"'; // ($is_follow indicates a Follow Kit. 'nofollow' is for search crawlers. Different things)
|
354 |
+
|
355 |
+
// Set dimension attributes if using custom icons and dimension is specified
|
356 |
+
if ( isset( $custom_icons ) ) {
|
357 |
+
$width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
|
358 |
+
$height_attr = ! empty( $icons_height ) ? ' height="' . $icons_height . '"' : '';
|
359 |
+
}
|
360 |
+
|
361 |
+
$link = $html_wrap_open . "<a$class_attr href=\"$url\" title=\"$name\"$rel_attr$target_attr>";
|
362 |
+
$link .= ( $large_icons && ! isset( $custom_icons ) && ! $custom_service ) ? "" : "<img src=\"$src\"" . $width_attr . $height_attr . " alt=\"$name\"/>";
|
363 |
+
$link .= "</a>" . $html_wrap_close;
|
364 |
+
}
|
365 |
+
|
366 |
+
$ind_html .= $link;
|
367 |
+
}
|
368 |
+
|
369 |
+
$ind_html .= $html_container_close;
|
370 |
+
|
371 |
+
if ( $is_amp ) {
|
372 |
+
$A2A_SHARE_SAVE_amp_icons_css = $amp_css;
|
373 |
+
add_action( 'amp_post_template_css', 'addtoany_amp_icons_css' );
|
374 |
+
}
|
375 |
+
|
376 |
+
if ( true == $output_later )
|
377 |
+
return $ind_html;
|
378 |
+
else
|
379 |
+
echo $ind_html;
|
380 |
+
}
|
381 |
+
|
382 |
+
function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
|
383 |
+
|
384 |
+
// $args array = output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl, no_universal_button
|
385 |
+
|
386 |
+
global $A2A_SHARE_SAVE_plugin_url_path;
|
387 |
+
|
388 |
+
$options = get_option( 'addtoany_options', array() );
|
389 |
+
|
390 |
+
$linkname = isset( $args['linkname'] ) ? $args['linkname'] : false;
|
391 |
+
$linkurl = isset( $args['linkurl'] ) ? $args['linkurl'] : false;
|
392 |
+
$linkmedia = isset( $args['linkmedia'] ) ? $args['linkmedia'] : false;
|
393 |
+
|
394 |
+
$args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl, $linkmedia)); // linkname_enc, etc.
|
395 |
+
|
396 |
+
$defaults = array(
|
397 |
+
'linkname' => '',
|
398 |
+
'linkurl' => '',
|
399 |
+
'linkmedia' => '',
|
400 |
+
'linkname_enc' => '',
|
401 |
+
'linkurl_enc' => '',
|
402 |
+
'linkmedia_enc' => '',
|
403 |
+
'use_current_page' => false,
|
404 |
+
'output_later' => false,
|
405 |
+
'is_kit' => false,
|
406 |
+
'html_container_open' => '',
|
407 |
+
'html_container_close' => '',
|
408 |
+
'html_wrap_open' => '',
|
409 |
+
'html_wrap_close' => '',
|
410 |
+
'html_content' => '',
|
411 |
+
'button_additional_classes' => '',
|
412 |
+
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
413 |
+
'no_universal_button' => false,
|
414 |
+
);
|
415 |
+
|
416 |
+
$args = wp_parse_args( $args, $defaults );
|
417 |
+
extract( $args );
|
418 |
+
|
419 |
+
$is_feed = is_feed();
|
420 |
+
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
|
421 |
+
$button_class = '';
|
422 |
+
$button_data_media = $is_kit || empty( $linkmedia ) ? '' : ' data-a2a-media="' . $linkmedia . '"';
|
423 |
+
$button_data_title = $is_kit || empty( $linkname ) ? '' : ' data-a2a-title="' . $linkname . '"';
|
424 |
+
$button_data_url = $is_kit || empty( $linkurl ) ? '' : ' data-a2a-url="' . $linkurl . '"';
|
425 |
+
$button_target = $is_amp ? ' target="_blank"' : '';
|
426 |
+
$button_href_querystring = ($is_feed || $is_amp) ? '#url=' . $linkurl_enc . '&title=' . $linkname_enc : '';
|
427 |
+
|
428 |
+
// If universal button is enabled
|
429 |
+
if ( ! $args['no_universal_button'] ) {
|
430 |
+
|
431 |
+
if ( isset( $options['button'] ) && 'CUSTOM' == $options['button'] ) {
|
432 |
+
// Custom button
|
433 |
+
$button_src = $options['button_custom'];
|
434 |
+
$button_width = '';
|
435 |
+
$button_height = '';
|
436 |
+
} else if ( isset( $options['button'] ) && 'TEXT' == $options['button'] ) {
|
437 |
+
// Text-only button
|
438 |
+
$button_text = stripslashes( $options[ 'button_text'] );
|
439 |
+
// Do not display universal icon
|
440 |
+
$button_class .= ' addtoany_no_icon';
|
441 |
+
} else {
|
442 |
+
// Default AddToAny button
|
443 |
+
if ( $is_amp ) {
|
444 |
+
// AMP (Accelerated Mobile Page)
|
445 |
+
$button_src = 'https://static.addtoany.com/buttons/a2a.svg';
|
446 |
+
$button_width = ! empty( $icon_size ) ? ' width="' . $icon_size .'"' : ' width="32"';
|
447 |
+
$button_height = ! empty( $icon_size ) ? ' height="' . $icon_size .'"' : ' height="32"';
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
if ( ! empty( $html_content ) ) {
|
452 |
+
$button = $html_content;
|
453 |
+
} elseif ( ! empty( $button_text ) ) {
|
454 |
+
$button = $button_text;
|
455 |
+
} elseif ( ! empty( $button_src ) ) {
|
456 |
+
$button = '<img src="' . $button_src . '"' . $button_width . $button_height . ' alt="Share">';
|
457 |
+
} else {
|
458 |
+
$button = '';
|
459 |
+
}
|
460 |
+
|
461 |
+
// Add additional classNames to .a2a_dd
|
462 |
+
$button_additional_classes = ! empty( $args['button_additional_classes'] ) ? ' ' . $args['button_additional_classes'] : '';
|
463 |
+
|
464 |
+
if ( isset( $options['button_show_count'] ) && $options['button_show_count'] == '1' ) {
|
465 |
+
$button_class .= ' a2a_counter';
|
466 |
+
}
|
467 |
+
|
468 |
+
$button_html = $html_container_open . $html_wrap_open . '<a class="a2a_dd' . $button_class . $button_additional_classes . ' addtoany_share_save" href="https://www.addtoany.com/share' .$button_href_querystring . '"'
|
469 |
+
. $button_data_url . $button_data_title . $button_data_media . $button_target
|
470 |
+
. '>' . $button . '</a>';
|
471 |
+
|
472 |
+
} else {
|
473 |
+
// Universal button disabled
|
474 |
+
$button_html = '';
|
475 |
+
}
|
476 |
+
|
477 |
+
// Closing tags come after <script> to validate in case the container is a list element
|
478 |
+
$button_html .= $html_wrap_close . $html_container_close;
|
479 |
+
|
480 |
+
if ( isset( $output_later ) && $output_later == true )
|
481 |
+
return $button_html;
|
482 |
+
else
|
483 |
+
echo $button_html;
|
484 |
+
}
|
485 |
+
|
486 |
+
function ADDTOANY_SHARE_SAVE_SPECIAL( $special_service_code, $args = array() ) {
|
487 |
+
// $args array = output_later, linkname, linkurl
|
488 |
+
|
489 |
+
if ( is_feed() ) {
|
490 |
+
return;
|
491 |
+
}
|
492 |
+
|
493 |
+
$options = get_option( 'addtoany_options', array() );
|
494 |
+
|
495 |
+
$linkname = ( isset( $args['linkname'] ) ) ? $args['linkname'] : false;
|
496 |
+
$linkurl = ( isset( $args['linkurl'] ) ) ? $args['linkurl'] : false;
|
497 |
+
$linkmedia = ( isset( $args['linkmedia'] ) ) ? $args['linkmedia'] : false;
|
498 |
+
|
499 |
+
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $linkname, $linkurl, $linkmedia ) ); // linkname_enc, etc.
|
500 |
+
extract( $args );
|
501 |
+
|
502 |
+
$special_anchor_template = '<a class="a2a_button_%1$s addtoany_special_service"%2$s></a>';
|
503 |
+
$custom_attributes = '';
|
504 |
+
|
505 |
+
if ( $special_service_code == 'facebook_like' ) {
|
506 |
+
$custom_attributes .= ( $options['special_facebook_like_options']['verb'] == 'recommend' ) ? ' data-action="recommend"' : '';
|
507 |
+
$custom_attributes .= ' data-href="' . $linkurl . '"';
|
508 |
+
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
509 |
+
}
|
510 |
+
|
511 |
+
elseif ( $special_service_code == 'twitter_tweet' ) {
|
512 |
+
$custom_attributes .= ' data-url="' . $linkurl . '"';
|
513 |
+
$custom_attributes .= ' data-text="' . $linkname . '"';
|
514 |
+
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
515 |
+
}
|
516 |
+
|
517 |
+
elseif ( $special_service_code == 'google_plusone' ) {
|
518 |
+
$custom_attributes .= ( $options['special_google_plusone_options']['show_count'] == '1' ) ? '' : ' data-annotation="none"';
|
519 |
+
$custom_attributes .= ' data-href="' . $linkurl . '"';
|
520 |
+
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
521 |
+
}
|
522 |
+
|
523 |
+
elseif ( $special_service_code == 'google_plus_share' ) {
|
524 |
+
$custom_attributes .= ( $options['special_google_plus_share_options']['show_count'] == '1' ) ? '' : ' data-annotation="none"';
|
525 |
+
$custom_attributes .= ' data-href="' . $linkurl . '"';
|
526 |
+
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
527 |
+
}
|
528 |
+
|
529 |
+
elseif ( $special_service_code == 'pinterest_pin' ) {
|
530 |
+
$custom_attributes .= ( $options['special_pinterest_pin_options']['show_count'] == '1' ) ? '' : ' data-pin-config="none"';
|
531 |
+
$custom_attributes .= ' data-url="' . $linkurl . '"';
|
532 |
+
$custom_attributes .= ( ! empty( $linkmedia ) ) ? ' data-media="' . $linkmedia . '"' : '';
|
533 |
+
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
|
534 |
+
}
|
535 |
+
|
536 |
+
if ( isset( $output_later ) && $output_later == true )
|
537 |
+
return $special_html;
|
538 |
+
else
|
539 |
+
echo $special_html;
|
540 |
+
}
|
541 |
+
|
542 |
+
if ( ! function_exists( 'A2A_menu_locale' ) ) {
|
543 |
+
function A2A_menu_locale() {
|
544 |
+
global $A2A_locale;
|
545 |
+
$locale = get_locale();
|
546 |
+
if ( $locale == 'en_US' || $locale == 'en' || $A2A_locale != '' )
|
547 |
+
return false;
|
548 |
+
|
549 |
+
$A2A_locale = 'a2a_localize = {
|
550 |
+
Share: "' . __( "Share", 'add-to-any' ) . '",
|
551 |
+
Save: "' . __( "Save", 'add-to-any' ) . '",
|
552 |
+
Subscribe: "' . __( "Subscribe", 'add-to-any' ) . '",
|
553 |
+
Email: "' . __( "Email", 'add-to-any' ) . '",
|
554 |
+
Bookmark: "' . __( "Bookmark", 'add-to-any' ) . '",
|
555 |
+
ShowAll: "' . __( "Show all", 'add-to-any' ) . '",
|
556 |
+
ShowLess: "' . __( "Show less", 'add-to-any' ) . '",
|
557 |
+
FindServices: "' . __( "Find service(s)", 'add-to-any' ) . '",
|
558 |
+
FindAnyServiceToAddTo: "' . __( "Instantly find any service to add to", 'add-to-any' ) . '",
|
559 |
+
PoweredBy: "' . __( "Powered by", 'add-to-any' ) . '",
|
560 |
+
ShareViaEmail: "' . __( "Share via email", 'add-to-any' ) . '",
|
561 |
+
SubscribeViaEmail: "' . __( "Subscribe via email", 'add-to-any' ) . '",
|
562 |
+
BookmarkInYourBrowser: "' . __( "Bookmark in your browser", 'add-to-any' ) . '",
|
563 |
+
BookmarkInstructions: "' . __( "Press Ctrl+D or \u2318+D to bookmark this page", 'add-to-any' ) . '",
|
564 |
+
AddToYourFavorites: "' . __( "Add to your favorites", 'add-to-any' ) . '",
|
565 |
+
SendFromWebOrProgram: "' . __( "Send from any email address or email program", 'add-to-any' ) . '",
|
566 |
+
EmailProgram: "' . __( "Email program", 'add-to-any' ) . '",
|
567 |
+
More: "' . __( "More…", 'add-to-any' ) . '"
|
568 |
+
};
|
569 |
+
';
|
570 |
+
return $A2A_locale;
|
571 |
+
}
|
572 |
+
}
|
573 |
+
|
574 |
+
function ADDTOANY_FOLLOW_KIT( $args = array() ) {
|
575 |
+
$options = get_option( 'addtoany_options', array() );
|
576 |
+
|
577 |
+
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT
|
578 |
+
$defaults = array(
|
579 |
+
'buttons' => array(),
|
580 |
+
'linkname' => '',
|
581 |
+
'linkurl' => '',
|
582 |
+
'linkname_enc' => '',
|
583 |
+
'linkurl_enc' => '',
|
584 |
+
'use_current_page' => false,
|
585 |
+
'output_later' => false,
|
586 |
+
'is_follow' => true,
|
587 |
+
'is_kit' => true,
|
588 |
+
'no_special_services' => true,
|
589 |
+
'no_universal_button' => true,
|
590 |
+
'kit_additional_classes' => '',
|
591 |
+
'kit_style' => '',
|
592 |
+
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
|
593 |
+
'services' => array(),
|
594 |
+
);
|
595 |
+
|
596 |
+
$args = wp_parse_args( $args, $defaults );
|
597 |
+
|
598 |
+
// Add a2a_follow className to Kit classes
|
599 |
+
$args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_follow' );
|
600 |
+
|
601 |
+
// If $args['buttons']['feed']['id'] is set
|
602 |
+
$buttons = $args['buttons'];
|
603 |
+
if ( ! empty( $buttons['feed'] ) && ! empty( $buttons['feed']['id'] ) ) {
|
604 |
+
$args['linkurl'] = $buttons['feed']['id'];
|
605 |
+
$args['linkname'] = get_bloginfo( 'name' );
|
606 |
+
}
|
607 |
+
|
608 |
+
$follow_html = ADDTOANY_SHARE_SAVE_KIT( $args );
|
609 |
+
|
610 |
+
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
|
611 |
+
return $follow_html;
|
612 |
+
else
|
613 |
+
echo $follow_html;
|
614 |
+
}
|
615 |
+
|
616 |
+
function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
|
617 |
+
$options = get_option( 'addtoany_options', array() );
|
618 |
+
|
619 |
+
$floating_html = '';
|
620 |
+
|
621 |
+
// Overridable by args below
|
622 |
+
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] ) ? $options['floating_vertical'] : false;
|
623 |
+
$horizontal_type = ( isset( $options['floating_horizontal'] ) && 'none' != $options['floating_horizontal'] ) ? $options['floating_horizontal'] : false;
|
624 |
+
|
625 |
+
if ( is_singular() ) {
|
626 |
+
// Disabled for this singular post?
|
627 |
+
$sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
|
628 |
+
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
629 |
+
|
630 |
+
if ( ! empty( $sharing_disabled ) ) {
|
631 |
+
// Overridable by args below
|
632 |
+
$vertical_type = false;
|
633 |
+
$horizontal_type = false;
|
634 |
+
}
|
635 |
+
}
|
636 |
+
|
637 |
+
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT
|
638 |
+
$defaults = array(
|
639 |
+
'linkname' => '',
|
640 |
+
'linkurl' => '',
|
641 |
+
'linkname_enc' => '',
|
642 |
+
'linkurl_enc' => '',
|
643 |
+
'use_current_page' => true,
|
644 |
+
'output_later' => false,
|
645 |
+
'is_floating' => true,
|
646 |
+
'is_kit' => true,
|
647 |
+
'no_addtoany_list_classname' => true,
|
648 |
+
'no_special_services' => true,
|
649 |
+
'kit_additional_classes' => '',
|
650 |
+
'kit_style' => '',
|
651 |
+
);
|
652 |
+
|
653 |
+
$args = wp_parse_args( $args, $defaults );
|
654 |
+
|
655 |
+
// Individual floating type args can override saved options
|
656 |
+
if ( isset( $args['vertical_type'] ) && $args['vertical_type'] === true ) {
|
657 |
+
$vertical_type = true;
|
658 |
+
}
|
659 |
+
if ( isset( $args['horizontal_type'] ) && $args['horizontal_type'] === true ) {
|
660 |
+
$horizontal_type = true;
|
661 |
+
}
|
662 |
+
|
663 |
+
// If either floating type is enabled
|
664 |
+
// Expect either a string from options, or a boolean from args
|
665 |
+
if ( $vertical_type || $horizontal_type ) {
|
666 |
+
// Vertical type?
|
667 |
+
if ( $vertical_type ) {
|
668 |
+
// Prevent overwriting of $args
|
669 |
+
$vertical_args = $args;
|
670 |
+
|
671 |
+
// Top position
|
672 |
+
$position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
|
673 |
+
// Left or right offset
|
674 |
+
$offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
|
675 |
+
// Icon size
|
676 |
+
$vertical_args['icon_size'] = ( isset( $options['floating_vertical_icon_size'] ) ) ? $options['floating_vertical_icon_size'] : '32';
|
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 |
+
|
688 |
+
$floating_html .= ADDTOANY_SHARE_SAVE_KIT( $vertical_args );
|
689 |
+
}
|
690 |
+
|
691 |
+
// Horizontal type?
|
692 |
+
if ( $horizontal_type ) {
|
693 |
+
// Prevent overwriting of $args values
|
694 |
+
$horizontal_args = $args;
|
695 |
+
|
696 |
+
// Left or right position
|
697 |
+
$position = ( isset( $options['floating_horizontal_position'] ) ) ? $options['floating_horizontal_position'] . 'px' : '0px';
|
698 |
+
// Bottom offset
|
699 |
+
$offset = ( isset( $options['floating_horizontal_offset'] ) ) ? $options['floating_horizontal_offset'] . 'px' : '0px';
|
700 |
+
// Icon size
|
701 |
+
$horizontal_args['icon_size'] = ( isset( $options['floating_horizontal_icon_size'] ) ) ? $options['floating_horizontal_icon_size'] : '32';
|
702 |
+
|
703 |
+
// Add a2a_default_style className to Kit classes
|
704 |
+
$horizontal_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_default_style' );
|
705 |
+
|
706 |
+
// Add declarations to Kit style attribute
|
707 |
+
if ( 'left_docked' === $horizontal_type ) {
|
708 |
+
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:' . $position . ';';
|
709 |
+
} elseif ( 'right_docked' === $horizontal_type ) {
|
710 |
+
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';right:' . $position . ';';
|
711 |
+
}
|
712 |
+
|
713 |
+
$floating_html .= ADDTOANY_SHARE_SAVE_KIT( $horizontal_args );
|
714 |
+
}
|
715 |
+
}
|
716 |
+
|
717 |
+
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
|
718 |
+
return $floating_html;
|
719 |
+
else
|
720 |
+
echo $floating_html;
|
721 |
+
}
|
722 |
+
|
723 |
+
|
724 |
+
function A2A_SHARE_SAVE_head_script() {
|
725 |
+
// Hook to disable script output
|
726 |
+
// Example: add_filter( 'addtoany_script_disabled', '__return_true' );
|
727 |
+
$script_disabled = apply_filters( 'addtoany_script_disabled', false );
|
728 |
+
|
729 |
+
if ( is_admin() || is_feed() || $script_disabled )
|
730 |
+
return;
|
731 |
+
|
732 |
+
$options = get_option( 'addtoany_options', array() );
|
733 |
+
|
734 |
+
// Use local cache?
|
735 |
+
$cache = ( isset( $options['cache'] ) && '1' == $options['cache'] ) ? true : false;
|
736 |
+
$upload_dir = wp_upload_dir();
|
737 |
+
$static_server = ( $cache ) ? $upload_dir['baseurl'] . '/addtoany' : 'https://static.addtoany.com/menu';
|
738 |
+
|
739 |
+
// Enternal script call + initial JS + set-once variables
|
740 |
+
$additional_js = ( isset( $options['additional_js_variables'] ) ) ? $options['additional_js_variables'] : '' ;
|
741 |
+
$script_configs = ( ( $cache ) ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '' )
|
742 |
+
. ( ( isset( $options['onclick'] ) && '1' == $options['onclick'] ) ? "\n" . 'a2a_config.onclick=1;' : '' )
|
743 |
+
. ( ( $additional_js ) ? "\n" . stripslashes( $additional_js ) : '' );
|
744 |
+
$A2A_SHARE_SAVE_external_script_called = true;
|
745 |
+
|
746 |
+
$javascript_header = "\n" . '<script type="text/javascript">' . "\n"
|
747 |
+
|
748 |
+
. "var a2a_config=a2a_config||{};"
|
749 |
+
. "a2a_config.callbacks=a2a_config.callbacks||[];"
|
750 |
+
. "a2a_config.templates=a2a_config.templates||{};"
|
751 |
+
. A2A_menu_locale()
|
752 |
+
. $script_configs
|
753 |
+
|
754 |
+
. "\n</script>\n"
|
755 |
+
|
756 |
+
. '<script type="text/javascript" src="' . $static_server . '/page.js" async="async"></script>' . "\n";
|
757 |
+
|
758 |
+
echo $javascript_header;
|
759 |
+
}
|
760 |
+
|
761 |
+
add_action( 'wp_head', 'A2A_SHARE_SAVE_head_script' );
|
762 |
+
|
763 |
+
function A2A_SHARE_SAVE_footer_script() {
|
764 |
+
if ( is_admin() || is_feed() )
|
765 |
+
return;
|
766 |
+
|
767 |
+
$floating_html = ADDTOANY_SHARE_SAVE_FLOATING( array( 'output_later' => true ) );
|
768 |
+
|
769 |
+
echo $floating_html;
|
770 |
+
}
|
771 |
+
|
772 |
+
add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
|
773 |
+
|
774 |
+
|
775 |
+
function A2A_SHARE_SAVE_add_to_content( $content ) {
|
776 |
+
global $wp_current_filter;
|
777 |
+
|
778 |
+
// Don't add to get_the_excerpt because it's too early and strips tags (adding to the_excerpt is allowed)
|
779 |
+
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
|
780 |
+
// Return early
|
781 |
+
return $content;
|
782 |
+
}
|
783 |
+
|
784 |
+
$sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
|
785 |
+
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
|
786 |
+
|
787 |
+
if (
|
788 |
+
// Private post
|
789 |
+
get_post_status( get_the_ID() ) == 'private' ||
|
790 |
+
// Sharing disabled on post
|
791 |
+
! empty( $sharing_disabled )
|
792 |
+
) {
|
793 |
+
// Return early
|
794 |
+
return $content;
|
795 |
+
}
|
796 |
+
|
797 |
+
$is_feed = is_feed();
|
798 |
+
$options = get_option( 'addtoany_options', array() );
|
799 |
+
$post_type = get_post_type( get_the_ID() );
|
800 |
+
|
801 |
+
if (
|
802 |
+
(
|
803 |
+
// Legacy tags
|
804 |
+
// <!--sharesave--> tag
|
805 |
+
strpos( $content, '<!--sharesave-->' ) === false ||
|
806 |
+
// <!--nosharesave--> tag
|
807 |
+
strpos( $content, '<!--nosharesave-->' ) !== false
|
808 |
+
) &&
|
809 |
+
(
|
810 |
+
// Posts
|
811 |
+
// All posts
|
812 |
+
( is_singular('post') && isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) ||
|
813 |
+
// Front page posts
|
814 |
+
( is_home() && isset( $options['display_in_posts_on_front_page'] ) && $options['display_in_posts_on_front_page'] == '-1' ) ||
|
815 |
+
// Archive page posts (Category, Tag, Author and Date pages)
|
816 |
+
( is_archive() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
817 |
+
// Search results posts (same as Archive page posts option)
|
818 |
+
( is_search() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
|
819 |
+
// Excerpt (the_excerpt is the current filter)
|
820 |
+
( 'the_excerpt' == current_filter() && isset( $options['display_in_excerpts'] ) && $options['display_in_excerpts'] == '-1' ) ||
|
821 |
+
// Posts in feed
|
822 |
+
( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
|
823 |
+
|
824 |
+
// Custom post types
|
825 |
+
( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' ) ||
|
826 |
+
|
827 |
+
// Pages
|
828 |
+
// Individual pages
|
829 |
+
( is_page() && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
|
830 |
+
// Attachment (media) pages
|
831 |
+
( is_attachment() && isset( $options['display_in_attachments'] ) && $options['display_in_attachments'] == '-1' ) ||
|
832 |
+
// <!--nosharesave--> legacy tag
|
833 |
+
( (strpos( $content, '<!--nosharesave-->') !== false ) )
|
834 |
+
)
|
835 |
+
) {
|
836 |
+
// Return early
|
837 |
+
return $content;
|
838 |
+
}
|
839 |
+
|
840 |
+
$kit_args = array(
|
841 |
+
"output_later" => true,
|
842 |
+
"is_kit" => ( $is_feed ) ? false : true,
|
843 |
+
);
|
844 |
+
|
845 |
+
// If a Sharing Header is set
|
846 |
+
if ( isset( $options['header'] ) && '' != $options['header'] ) {
|
847 |
+
$html_header = '<div class="addtoany_header">' . stripslashes( $options['header'] ) . '</div>';
|
848 |
+
} else {
|
849 |
+
$html_header = '';
|
850 |
+
}
|
851 |
+
|
852 |
+
if ( $is_feed ) {
|
853 |
+
$container_wrap_open = '<p>';
|
854 |
+
$container_wrap_close = '</p>';
|
855 |
+
$kit_args['html_container_open'] = '';
|
856 |
+
$kit_args['html_container_close'] = '';
|
857 |
+
$kit_args['html_wrap_open'] = '';
|
858 |
+
$kit_args['html_wrap_close'] = '';
|
859 |
+
} else {
|
860 |
+
$container_wrap_open = '<div class="addtoany_share_save_container %s">'; // Contains placeholder
|
861 |
+
$container_wrap_open .= $html_header;
|
862 |
+
$container_wrap_close = '</div>';
|
863 |
+
}
|
864 |
+
|
865 |
+
$options['position'] = isset( $options['position'] ) ? $options['position'] : 'bottom';
|
866 |
+
|
867 |
+
if ($options['position'] == 'both' || $options['position'] == 'top') {
|
868 |
+
// Prepend to content
|
869 |
+
$content = sprintf( $container_wrap_open, 'addtoany_content_top' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close . $content;
|
870 |
+
}
|
871 |
+
if ( $options['position'] == 'bottom' || $options['position'] == 'both') {
|
872 |
+
// Append to content
|
873 |
+
$content .= sprintf( $container_wrap_open, 'addtoany_content_bottom' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close;
|
874 |
+
}
|
875 |
+
|
876 |
+
return $content;
|
877 |
+
}
|
878 |
+
|
879 |
+
|
880 |
+
function A2A_SHARE_SAVE_pre_get_posts( $query ) {
|
881 |
+
if ( $query->is_main_query() ) {
|
882 |
+
add_filter( 'the_content', 'A2A_SHARE_SAVE_add_to_content', 98 );
|
883 |
+
add_filter( 'the_excerpt', 'A2A_SHARE_SAVE_add_to_content', 98 );
|
884 |
+
}
|
885 |
+
}
|
886 |
+
|
887 |
+
add_action( 'pre_get_posts', 'A2A_SHARE_SAVE_pre_get_posts' );
|
888 |
+
|
889 |
+
|
890 |
+
// [addtoany url="https://www.example.com/page.html" title="Example Page"]
|
891 |
+
function A2A_SHARE_SAVE_shortcode( $attributes ) {
|
892 |
+
$attributes = shortcode_atts( array(
|
893 |
+
'url' => '',
|
894 |
+
'title' => '',
|
895 |
+
'media' => '',
|
896 |
+
'buttons' => '',
|
897 |
+
), $attributes, 'addtoany' );
|
898 |
+
|
899 |
+
$linkname = ! empty( $attributes['title'] ) ? $attributes['title'] : false;
|
900 |
+
$linkurl = ! empty( $attributes['url'] ) ? $attributes['url'] : false;
|
901 |
+
$linkmedia = ! empty( $attributes['media'] ) ? $attributes['media'] : false;
|
902 |
+
$buttons = ! empty( $attributes['buttons'] ) ? explode( ',', $attributes['buttons'] ) : array();
|
903 |
+
|
904 |
+
$output_later = true;
|
905 |
+
|
906 |
+
return '<div class="addtoany_shortcode">'
|
907 |
+
. ADDTOANY_SHARE_SAVE_KIT( compact( 'linkname', 'linkurl', 'linkmedia', 'output_later', 'buttons' ) )
|
908 |
+
. '</div>';
|
909 |
+
}
|
910 |
+
|
911 |
+
add_shortcode( 'addtoany', 'A2A_SHARE_SAVE_shortcode' );
|
912 |
+
|
913 |
+
|
914 |
+
function A2A_SHARE_SAVE_stylesheet() {
|
915 |
+
global $A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_url_path;
|
916 |
+
|
917 |
+
$options = $A2A_SHARE_SAVE_options;
|
918 |
+
|
919 |
+
// Use stylesheet?
|
920 |
+
if ( ! isset( $options['inline_css'] ) || $options['inline_css'] != '-1' && ! is_admin() ) {
|
921 |
+
|
922 |
+
wp_enqueue_style( 'A2A_SHARE_SAVE', $A2A_SHARE_SAVE_plugin_url_path . '/addtoany.min.css', false, '1.14' );
|
923 |
+
|
924 |
+
// wp_add_inline_style requires WP 3.3+
|
925 |
+
if ( '3.3' <= get_bloginfo( 'version' ) ) {
|
926 |
+
|
927 |
+
// Prepare inline CSS
|
928 |
+
$inline_css = '';
|
929 |
+
|
930 |
+
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] ) ? $options['floating_vertical'] : false;
|
931 |
+
$horizontal_type = ( isset( $options['floating_horizontal'] ) && 'none' != $options['floating_horizontal'] ) ? $options['floating_horizontal'] : false;
|
932 |
+
|
933 |
+
// If vertical bar is enabled
|
934 |
+
if ( $vertical_type &&
|
935 |
+
// and respsonsiveness is enabled
|
936 |
+
( ! isset( $options['floating_vertical_responsive'] ) || '-1' != $options['floating_vertical_responsive'] )
|
937 |
+
) {
|
938 |
+
|
939 |
+
// Get min-width for media query
|
940 |
+
$vertical_max_width = (
|
941 |
+
isset( $options['floating_vertical_responsive_max_width'] ) &&
|
942 |
+
is_numeric( $options['floating_vertical_responsive_max_width'] )
|
943 |
+
) ? $options['floating_vertical_responsive_max_width'] : '980';
|
944 |
+
|
945 |
+
// Set media query
|
946 |
+
$inline_css .= '@media screen and (max-width:' . $vertical_max_width . 'px){' . "\n"
|
947 |
+
. '.a2a_floating_style.a2a_vertical_style{display:none;}' . "\n"
|
948 |
+
. '}';
|
949 |
+
|
950 |
+
}
|
951 |
+
|
952 |
+
// If horizontal bar is enabled
|
953 |
+
if ( $horizontal_type &&
|
954 |
+
// and respsonsiveness is enabled
|
955 |
+
( ! isset( $options['floating_horizontal_responsive'] ) || '-1' != $options['floating_horizontal_responsive'] )
|
956 |
+
) {
|
957 |
+
|
958 |
+
// Get max-width for media query
|
959 |
+
$horizontal_min_width = (
|
960 |
+
isset( $options['floating_horizontal_responsive_min_width'] ) &&
|
961 |
+
is_numeric( $options['floating_horizontal_responsive_min_width'] )
|
962 |
+
) ? $options['floating_horizontal_responsive_min_width'] : '981';
|
963 |
+
|
964 |
+
// Insert newline if there is inline CSS already
|
965 |
+
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
966 |
+
|
967 |
+
// Set media query
|
968 |
+
$inline_css .= '@media screen and (min-width:' . $horizontal_min_width . 'px){' . "\n"
|
969 |
+
. '.a2a_floating_style.a2a_default_style{display:none;}' . "\n"
|
970 |
+
. '}';
|
971 |
+
|
972 |
+
}
|
973 |
+
|
974 |
+
// If additional CSS (custom CSS for AddToAny) is set
|
975 |
+
if ( ! empty( $options['additional_css'] ) ) {
|
976 |
+
$custom_css = stripslashes( $options['additional_css'] );
|
977 |
+
|
978 |
+
// Insert newline if there is inline CSS already
|
979 |
+
$inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
|
980 |
+
|
981 |
+
$inline_css .= $custom_css;
|
982 |
+
}
|
983 |
+
|
984 |
+
// If there is inline CSS
|
985 |
+
if ( 0 < strlen( $inline_css ) ) {
|
986 |
+
// Insert inline CSS
|
987 |
+
wp_add_inline_style( 'A2A_SHARE_SAVE', $inline_css );
|
988 |
+
}
|
989 |
+
|
990 |
+
}
|
991 |
+
|
992 |
+
}
|
993 |
+
|
994 |
+
}
|
995 |
+
|
996 |
+
add_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_stylesheet' );
|
997 |
+
|
998 |
+
function A2A_SHARE_SAVE_enqueue_script() {
|
999 |
+
global $A2A_SHARE_SAVE_plugin_url_path;
|
1000 |
+
|
1001 |
+
if ( wp_script_is( 'jquery', 'registered' ) ) {
|
1002 |
+
wp_enqueue_script( 'addtoany', $A2A_SHARE_SAVE_plugin_url_path . '/addtoany.min.js', array( 'jquery' ), '1.0' );
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
add_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' );
|
1007 |
+
|
1008 |
+
|
1009 |
+
/**
|
1010 |
+
* Cache AddToAny
|
1011 |
+
*/
|
1012 |
+
|
1013 |
+
function A2A_SHARE_SAVE_refresh_cache() {
|
1014 |
+
$contents = wp_remote_fopen( 'https://www.addtoany.com/ext/updater/files_list/' );
|
1015 |
+
$file_urls = explode( "\n", $contents, 20 );
|
1016 |
+
$upload_dir = wp_upload_dir();
|
1017 |
+
|
1018 |
+
// Make directory if needed
|
1019 |
+
if ( ! wp_mkdir_p( dirname( $upload_dir['basedir'] . '/addtoany/foo' ) ) ) {
|
1020 |
+
$message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), dirname( $new_file ) );
|
1021 |
+
return array( 'error' => $message );
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
if ( count( $file_urls ) > 0 ) {
|
1025 |
+
for ( $i = 0; $i < count( $file_urls ); $i++ ) {
|
1026 |
+
// Download files
|
1027 |
+
$file_url = trim( $file_urls[ $i ] );
|
1028 |
+
$file_name = substr( strrchr( $file_url, '/' ), 1, 99 );
|
1029 |
+
|
1030 |
+
// Place files in uploads/addtoany directory
|
1031 |
+
wp_remote_get( $file_url, array(
|
1032 |
+
'filename' => $upload_dir['basedir'] . '/addtoany/' . $file_name,
|
1033 |
+
'stream' => true, // Required to use `filename` arg
|
1034 |
+
) );
|
1035 |
+
}
|
1036 |
+
}
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
function A2A_SHARE_SAVE_schedule_cache() {
|
1040 |
+
// WP "Cron" requires WP version 2.1
|
1041 |
+
$timestamp = wp_next_scheduled( 'A2A_SHARE_SAVE_refresh_cache' );
|
1042 |
+
if ( ! $timestamp) {
|
1043 |
+
// Only schedule if currently unscheduled
|
1044 |
+
wp_schedule_event( time(), 'daily', 'A2A_SHARE_SAVE_refresh_cache' );
|
1045 |
+
}
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
function A2A_SHARE_SAVE_unschedule_cache() {
|
1049 |
+
$timestamp = wp_next_scheduled( 'A2A_SHARE_SAVE_refresh_cache' );
|
1050 |
+
wp_unschedule_event( $timestamp, 'A2A_SHARE_SAVE_refresh_cache' );
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
|
1054 |
+
|
1055 |
+
/**
|
1056 |
+
* Admin Options
|
1057 |
+
*/
|
1058 |
+
|
1059 |
+
if ( is_admin() ) {
|
1060 |
+
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.admin.php';
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
function A2A_SHARE_SAVE_add_menu_link() {
|
1064 |
+
$page = add_options_page(
|
1065 |
+
__( 'AddToAny Share Settings', 'add-to-any' ),
|
1066 |
+
__( 'AddToAny', 'add-to-any' ),
|
1067 |
+
'manage_options',
|
1068 |
+
'addtoany',
|
1069 |
+
'A2A_SHARE_SAVE_options_page'
|
1070 |
+
);
|
1071 |
+
|
1072 |
+
/* Using registered $page handle to hook script load, to only load in AddToAny admin */
|
1073 |
+
add_filter( 'admin_print_scripts-' . $page, 'A2A_SHARE_SAVE_scripts' );
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
add_filter( 'admin_menu', 'A2A_SHARE_SAVE_add_menu_link' );
|
1077 |
+
|
1078 |
+
function A2A_SHARE_SAVE_widgets_init() {
|
1079 |
+
global $A2A_SHARE_SAVE_plugin_dir;
|
1080 |
+
|
1081 |
+
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.widgets.php';
|
1082 |
+
register_widget( 'A2A_SHARE_SAVE_Widget' );
|
1083 |
+
register_widget( 'A2A_Follow_Widget' );
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
add_action( 'widgets_init', 'A2A_SHARE_SAVE_widgets_init' );
|
1087 |
+
|
1088 |
+
// Place in Option List on Settings > Plugins page
|
1089 |
+
function A2A_SHARE_SAVE_actlinks( $links, $file ) {
|
1090 |
+
// Static so we don't call plugin_basename on every plugin row.
|
1091 |
+
static $this_plugin;
|
1092 |
+
|
1093 |
+
if ( ! $this_plugin ) {
|
1094 |
+
$this_plugin = plugin_basename( __FILE__ );
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
if ( $file == $this_plugin ) {
|
1098 |
+
$settings_link = '<a href="options-general.php?page=addtoany">' . __( 'Settings' ) . '</a>';
|
1099 |
+
array_unshift( $links, $settings_link ); // before other links
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
return $links;
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
add_filter( 'plugin_action_links', 'A2A_SHARE_SAVE_actlinks', 10, 2 );
|