-
Notifications
You must be signed in to change notification settings - Fork 4
/
add-to-any.php
1324 lines (1100 loc) · 52 KB
/
add-to-any.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
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
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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
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
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
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
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
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
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Plugin Name: AddToAny Share Buttons
* Plugin URI: https://www.addtoany.com/
* Description: Share buttons for your pages including AddToAny's universal sharing button, Facebook, Twitter, LinkedIn, Pinterest, WhatsApp and many more.
* Version: 1.7.44
* Author: AddToAny
* Author URI: https://www.addtoany.com/
* Text Domain: add-to-any
* Domain Path: /languages
*/
// Explicitly globalize to support bootstrapped WordPress.
global $A2A_locale, $A2A_FOLLOW_services,
$A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url,
$A2A_SHARE_SAVE_services;
$A2A_SHARE_SAVE_plugin_dir = untrailingslashit( plugin_dir_path( __FILE__ ) );
$A2A_SHARE_SAVE_plugin_url = untrailingslashit( plugin_dir_url( __FILE__ ) );
// Set AddToAny locale (JavaScript).
$A2A_locale = ! isset ( $A2A_locale ) ? '' : $A2A_locale;
// Set plugin options.
$A2A_SHARE_SAVE_options = get_option( 'addtoany_options', array() );
// Require PHP 5.3 as a bare minimum for compatibility features that use anonymous functions (PHP 5.3+).
if ( version_compare( phpversion(), '5.3.0', '>=' ) ) {
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.compat.php';
}
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php';
function A2A_SHARE_SAVE_init() {
global $A2A_SHARE_SAVE_plugin_dir,
$A2A_SHARE_SAVE_options;
// Load the textdomain for translations.
load_plugin_textdomain( 'add-to-any', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
// Update plugin options.
$options = $A2A_SHARE_SAVE_options;
$old_buttons = array(
'share_save_256_24.gif|256|24', 'share_save_171_16.gif|171|16', 'share_save_120_16.gif|120|16',
'share_save_256_24.png|256|24', 'share_save_171_16.png|171|16', 'share_save_120_16.png|120|16',
'share_16_16.png|16|16', 'favicon.png|16|16',
);
// If old button enabled.
if ( ! empty( $options['button'] ) && in_array( $options['button'], $old_buttons ) ) {
include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.update.php';
addtoany_update_options();
}
}
// XTEC ************ MODIFICAT - Add language support before the class to instantiate
// 2017.02.07 @xaviernietosanchez
add_filter( 'plugins_loaded', 'A2A_SHARE_SAVE_init' );
// ************ ORIGINAL
/*
add_filter( 'init', 'A2A_SHARE_SAVE_init' );
*/
// ************ FI
function A2A_SHARE_SAVE_link_vars( $args = array() ) {
global $post;
$linkname = empty( $args['linkname'] ) ? '' : $args['linkname'];
$linkurl = empty( $args['linkurl'] ) ? '' : $args['linkurl'];
$linkmedia = empty( $args['linkmedia'] ) ? '' : $args['linkmedia'];
$use_current_page = isset( $args['use_current_page'] ) ? $args['use_current_page'] : false;
// Set linkname if needed, and not a Follow kit.
if ( ! $linkname && empty( $args['is_follow'] ) ) {
if ( $use_current_page ) {
$linkname = is_home() || is_front_page() ? get_bloginfo( 'name' ) : rtrim( wp_title( '', false, 'right' ) );
} elseif ( isset( $post ) ) {
$linkname = html_entity_decode( strip_tags( get_the_title( $post->ID ) ), ENT_QUOTES, 'UTF-8' );
} else {
$linkname = '';
}
}
$linkname_enc = rawurlencode( $linkname );
// Set linkurl if needed, and not a Follow kit.
if ( ! $linkurl && empty( $args['is_follow'] ) ) {
if ( $use_current_page ) {
$linkurl = esc_url_raw( home_url( $_SERVER['REQUEST_URI'] ) );
} elseif ( isset( $post ) ) {
$linkurl = get_permalink( $post->ID );
} else {
$linkurl = '';
}
}
$linkurl_enc = rawurlencode( $linkurl );
// Set linkmedia (only applies to services that explicitly accept media; Pinterest does, most do not).
$linkmedia_enc = ! empty( $args['linkmedia'] ) ? rawurlencode( $args['linkmedia'] ) : '';
return compact( 'linkname', 'linkname_enc', 'linkurl', 'linkurl_enc', 'linkmedia', 'linkmedia_enc', 'use_current_page' );
}
// Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON.
function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
$options = get_option( 'addtoany_options', array() );
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $args ) ); // linkname_enc, etc.
$defaults = array(
'output_later' => false,
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
'is_follow' => false,
);
$args = wp_parse_args( $args, $defaults );
// If universal button disabled, and not manually disabled through args.
if ( isset( $options['button'] ) && $options['button'] == 'NONE' && ! isset( $args['no_universal_button'] ) ) {
// Pass this setting on to ADDTOANY_SHARE_SAVE_BUTTON,
// and only via this ADDTOANY_SHARE_SAVE_KIT function because it is used for automatic placement.
$args['no_universal_button'] = true;
}
// Custom icons enabled?
$custom_icons = ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) ? true : false;
$kit_additional_classes = '';
$kit_data_media = empty( $args['linkmedia'] ) ? '' : ' data-a2a-media="' . esc_attr( $args['linkmedia'] ) . '"';
$kit_data_title = empty( $args['linkname'] ) || $args['use_current_page'] ? '' : ' data-a2a-title="' . esc_attr( $args['linkname'] ) . '"';
$kit_data_url = empty( $args['linkurl'] ) || $args['use_current_page'] ? '' : ' data-a2a-url="' . esc_attr( $args['linkurl'] ) . '"';
$kit_data_scroll_show = empty( $args['scroll_show'] ) ? '' : ' data-a2a-scroll-show="' . esc_attr( $args['scroll_show'] ) . '"';
$kit_style = '';
// Add additional classNames to .a2a_kit.
if ( ! empty( $args['kit_additional_classes'] ) ) {
// Append space and className(s).
$kit_additional_classes .= ' ' . $args['kit_additional_classes'];
}
// Set a2a_kit_size_## class name.
if ( $custom_icons ) {
// If vertical style (.a2a_vertical_style)
if ( strpos( $kit_additional_classes, 'a2a_vertical_style' ) !== false ) {
// Use width (if specified) for .a2a_kit_size_## class name to size default service counters.
$icon_size_classname = isset( $options['custom_icons_width'] ) ? ' a2a_kit_size_' . $options['custom_icons_width'] : '';
} else {
// Use height (if specified) for .a2a_kit_size_## class name to size default service counters.
$icon_size_classname = isset( $options['custom_icons_height'] ) ? ' a2a_kit_size_' . $options['custom_icons_height'] : '';
}
// Set a2a_kit_size_## icon size.
} else {
$icon_size_classname = ' a2a_kit_size_' . $args['icon_size'];
}
// Add addtoany_list className unless disabled (for floating buttons).
if ( ! isset( $args['no_addtoany_list_classname'] ) ) {
$kit_additional_classes .= ' addtoany_list';
}
// Add style attribute if set.
if ( ! empty( $args['kit_style'] ) ) {
$kit_style = ' style="' . esc_attr( $args['kit_style'] ) . '"';
}
if ( ! isset( $args['html_container_open'] ) ) {
$args['html_container_open'] = '<div class="a2a_kit' . esc_attr( $icon_size_classname . $kit_additional_classes ) . '"'
. $kit_data_url . $kit_data_title . $kit_data_media . $kit_data_scroll_show . $kit_style . '>';
$args['is_kit'] = true;
}
if ( ! isset( $args['html_container_close'] ) )
$args['html_container_close'] = "</div>";
// Close container element in ADDTOANY_SHARE_SAVE_BUTTON, not prematurely in ADDTOANY_SHARE_SAVE_ICONS.
// Cache for _BUTTON.
$html_container_close = $args['html_container_close'];
// Avoid passing to ADDTOANY_SHARE_SAVE_ICONS since set in _BUTTON.
unset($args['html_container_close']);
if ( ! isset( $args['html_wrap_open'] ) )
$args['html_wrap_open'] = "";
if ( ! isset( $args['html_wrap_close'] ) )
$args['html_wrap_close'] = "";
$kit_html = ADDTOANY_SHARE_SAVE_ICONS( $args );
// Set again because it was unset above for _ICONS.
$args['html_container_close'] = $html_container_close;
// Avoid passing to ADDTOANY_SHARE_SAVE_BUTTON since set in _ICONS.
unset( $args['html_container_open'] );
$kit_html .= ADDTOANY_SHARE_SAVE_BUTTON( $args );
if ( true == $args['output_later'] )
return $kit_html;
else
echo $kit_html;
}
function ADDTOANY_SHARE_SAVE_ICONS( $args = array() ) {
// $args array: output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl
global $A2A_SHARE_SAVE_services,
$A2A_FOLLOW_services;
$options = get_option( 'addtoany_options', array() );
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $args ) ); // linkname_enc, etc.
$defaults = array(
'linkname' => '',
'linkurl' => '',
'linkmedia' => '',
'linkname_enc' => '',
'linkurl_enc' => '',
'linkmedia_enc' => '',
'output_later' => false,
'html_container_open' => '',
'html_container_close' => '',
'html_wrap_open' => '',
'html_wrap_close' => '',
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
'is_follow' => false,
'no_universal_button' => false,
'basic_html' => false,
'buttons' => array(),
);
$args = wp_parse_args( $args, $defaults );
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
// Use large icons except for AMP.
$large_icons = $is_amp ? false : true;
// Make the color of the icons extensible, primariliy for AMP use cases.
$icon_bg_color_filtered = apply_filters( 'addtoany_icons_bg_color', '' );
// Directory of either custom icons or the packaged icons
if ( isset( $options['custom_icons'] ) && $options['custom_icons'] == 'url' && isset( $options['custom_icons_url'] ) ) {
// Custom icons expected at a specified URL, i.e. //example.com/blog/uploads/addtoany/icons/custom/
$icons_dir = $options['custom_icons_url'];
$icons_type = ( isset( $options['custom_icons_type'] ) ) ? $options['custom_icons_type'] : 'png';
$icons_width = ( isset( $options['custom_icons_width'] ) ) ? $options['custom_icons_width'] : '';
$icons_height = ( isset( $options['custom_icons_height'] ) ) ? $options['custom_icons_height'] : '';
$custom_icons = true;
} else {
// Default to local SVGs.
$icons_dir = plugins_url('/icons/', __FILE__ );
$icons_type = 'svg';
}
// If Follow kit
if ( $args['is_follow'] ) {
// Make available services extensible via plugins, themes (functions.php), etc.
$services = apply_filters( 'A2A_FOLLOW_services', $A2A_FOLLOW_services );
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
// Services set by "buttons" arg
$active_services = empty( $args['buttons'] ) ? array() : array_keys( $args['buttons'] );
// Else Share kit
} else {
// Make available services extensible via plugins, themes (functions.php), etc.
$services = apply_filters( 'A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services );
$service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
// Include Facebook Like and Twitter Tweet etc. unless no_special_services arg is true.
if ( ! isset( $args['no_special_services'] ) || false == $args['no_special_services'] ) {
array_unshift( $service_codes, 'facebook_like', 'twitter_tweet', 'pinterest_pin' );
}
// Use default services if services have not been selected yet.
$active_services = isset( $options['active_services'] ) ? $options['active_services'] : array( 'facebook', 'twitter', 'email' );
// Services set by "buttons" arg? Then use "buttons" arg instead.
$active_services = empty( $args['buttons'] ) ? $active_services : $args['buttons'];
}
$ind_html = "" . $args['html_container_open'];
foreach( $active_services as $active_service ) {
$custom_service = false;
if ( ! in_array( $active_service, $service_codes ) )
continue;
if ( $active_service == 'facebook_like' || $active_service == 'twitter_tweet' || $active_service == 'pinterest_pin' ) {
$special_args = $args;
$special_args['output_later'] = true;
$link = ADDTOANY_SHARE_SAVE_SPECIAL( $active_service, $special_args );
} else {
$service = $services[ $active_service ];
$code_name = $active_service;
$name = $service['name'];
// If Follow kit and HREF specified
if ( $args['is_follow'] && isset( $service['href'] ) ) {
$follow_id = $args['buttons'][ $active_service ]['id'];
$is_url = in_array( parse_url( $follow_id, PHP_URL_SCHEME ), array( 'http', 'https' ) );
// If it's a URL instead of a service ID
if ( $is_url ) {
// Just use the given URL instead of the URL template.
$href = $follow_id;
} else {
// Replace the ID placeholder in the URL template.
$href = str_replace( '${id}', $follow_id, $service['href'] );
}
$href = ( 'feed' == $code_name ) ? $follow_id : $href;
// If icon_url is set, presume custom service.
if ( isset( $service['icon_url'] ) ) {
$custom_service = true;
}
// Else if Share Kit and HREF specified, presume custom service.
} elseif ( isset( $service['href'] ) ) {
$custom_service = true;
$href = $service['href'];
if ( isset( $service['href_js_esc'] ) ) {
$href_linkurl = str_replace( "'", "\'", $args['linkurl'] );
$href_linkname = str_replace( "'", "\'", $args['linkname'] );
} else {
$href_linkurl = $args['linkurl_enc'];
$href_linkname = $args['linkname_enc'];
}
$href = str_replace( "A2A_LINKURL", $href_linkurl, $href );
$href = str_replace( "A2A_LINKNAME", $href_linkname, $href );
$href = str_replace( " ", "%20", $href );
}
// AddToAny counter enabled?
$counter_enabled = ( ! $args['is_follow'] // Disable counters on Follow Kits
&& in_array( $active_service, array( 'facebook', 'pinterest', 'reddit' ) )
&& isset( $options['special_' . $active_service . '_options'] )
&& isset( $options['special_' . $active_service . '_options']['show_count'] )
&& $options['special_' . $active_service . '_options']['show_count'] == '1'
) ? true : false;
$icon = isset( $service['icon'] ) ? $service['icon'] : 'default'; // Just the icon filename
$icon_url = isset( $service['icon_url'] ) ? $service['icon_url'] : false;
$icon_url = $is_amp && ! $icon_url ? 'https://static.addtoany.com/buttons/' . $icon . '.svg' : $icon_url;
$width_attr = isset( $service['icon_width'] ) ? ' width="' . esc_attr( $service['icon_width'] ) . '"' : ' width="16"';
$width_attr = $is_amp && ! empty( $args['icon_size'] ) ? ' width="' . esc_attr( $args['icon_size'] ) . '"' : $width_attr;
$height_attr = isset( $service['icon_height'] ) ? ' height="' . esc_attr( $service['icon_height'] ) . '"' : ' height="16"';
$height_attr = $is_amp && ! empty( $args['icon_size'] ) ? ' height="' . esc_attr( $args['icon_size'] ) . '"' : $height_attr;
$img_style_attr_bg_color = ! empty( $service['color'] ) ? '#' . $service['color'] : '';
$img_style_attr_bg_color = ! empty( $icon_bg_color_filtered ) ? $icon_bg_color_filtered : $img_style_attr_bg_color;
$img_style_attr = $is_amp && ! empty( $img_style_attr_bg_color ) ? ' style="background-color:' . esc_attr( $img_style_attr_bg_color ) . ';"' : '';
$url = isset( $href ) ? $href : 'https://www.addtoany.com/add_to/' . $code_name . '?linkurl=' . $args['linkurl_enc'] .'&linkname=' . $args['linkname_enc'];
$src = $icon_url ? $icon_url : $icons_dir . $icon . '.' . $icons_type;
$counter = $counter_enabled ? ' a2a_counter' : '';
$class_attr = $custom_service ? '' : ' class="a2a_button_' . esc_attr( $code_name ) . $counter . '"';
$href_attr = $args['basic_html'] && ! isset( $href ) ? '' : ' href="' . esc_attr( $url ) . '"';
$title_attr = $args['basic_html'] ? '' : ' title="' . esc_attr( $name ) . '"';
if ( isset( $service['target'] ) ) {
$target_attr = empty( $service['target'] ) ? '' : ' target="' . esc_attr( $service['target'] ) . '"';
} elseif ( ! $args['basic_html'] ) {
$target_attr = ' target="_blank"';
} else {
$target_attr = '';
}
// Use rel="noopener" for links that open in a new tab/window.
$rel_noopener = $custom_service || ! $target_attr ? '' : ' noopener';
$rel_noopener_only = $rel_noopener || $target_attr ? ' rel="noopener"' : '';
$rel_attr = $args['is_follow'] ? $rel_noopener_only : ' rel="nofollow' . $rel_noopener . '"'; // ($args['is_follow'] indicates a Follow Kit. 'nofollow' is for search crawlers. Different things)
$rel_attr = $args['basic_html'] ? '' : $rel_attr;
// Use AMP's "print" action.
if ( $is_amp && 'print' === $code_name ) {
$amp_on_attr = 'on="tap:AMP.print()"';
$href_attr = '#';
} else {
$amp_on_attr = '';
}
// Set dimension attributes if using custom icons and dimension is specified.
if ( isset( $custom_icons ) ) {
$width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
$height_attr = ! empty( $icons_height ) ? ' height="' . $icons_height . '"' : '';
}
$link = $args['html_wrap_open'] . "<a$class_attr$href_attr$title_attr$rel_attr$target_attr$amp_on_attr>";
$link .= ( $large_icons && ! isset( $custom_icons ) && ! $custom_service ) ? '' : '<img' . $img_style_attr . ' src="' . esc_attr( $src ) . '"' . $width_attr . $height_attr . ' alt="' . esc_attr( $name ) . '">';
$link .= "</a>" . $args['html_wrap_close'];
}
$ind_html .= $link;
}
$ind_html .= $args['html_container_close'];
if ( true == $args['output_later'] )
return $ind_html;
else
echo $ind_html;
}
function ADDTOANY_SHARE_SAVE_BUTTON( $args = array() ) {
// $args array = output_later, html_container_open, html_container_close, html_wrap_open, html_wrap_close, linkname, linkurl, no_universal_button
$options = get_option( 'addtoany_options', array() );
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $args ) ); // linkname_enc, etc.
$defaults = array(
'linkname' => '',
'linkurl' => '',
'linkmedia' => '',
'linkname_enc' => '',
'linkurl_enc' => '',
'linkmedia_enc' => '',
'use_current_page' => false,
'output_later' => false,
'is_kit' => false,
'html_container_open' => '',
'html_container_close' => '',
'html_wrap_open' => '',
'html_wrap_close' => '',
'html_content' => '',
'button_additional_classes' => '',
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
'no_universal_button' => false,
);
$args = wp_parse_args( $args, $defaults );
$is_feed = is_feed();
$is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
// Make the color of the icons extensible, primariliy for AMP use cases.
$icon_bg_color_filtered = apply_filters( 'addtoany_icons_bg_color', '#0166ff' );
$button_class = '';
$button_data_media = $args['is_kit'] || empty( $args['linkmedia'] ) ? '' : ' data-a2a-media="' . esc_attr( $args['linkmedia'] ) . '"';
$button_data_title = $args['is_kit'] || empty( $args['linkname'] ) ? '' : ' data-a2a-title="' . esc_attr( $args['linkname'] ) . '"';
$button_data_url = $args['is_kit'] || empty( $args['linkurl'] ) ? '' : ' data-a2a-url="' . esc_attr( $args['linkurl'] ) . '"';
$button_target = $is_amp ? ' target="_blank"' : '';
$button_href_querystring = ($is_feed || $is_amp) ? '#url=' . $args['linkurl_enc'] . '&title=' . $args['linkname_enc'] : '';
// If universal button is enabled
if ( ! $args['no_universal_button'] ) {
if ( isset( $options['button'] ) && 'CUSTOM' == $options['button'] ) {
// Custom button.
$button_src = $options['button_custom'];
$button_width = '';
$button_height = '';
$button_style = '';
} else if ( isset( $options['button'] ) && 'TEXT' == $options['button'] ) {
// Text-only button.
$button_text = stripslashes( $options[ 'button_text'] );
// Do not display universal icon.
$button_class .= ' addtoany_no_icon';
} else {
// Default AddToAny button.
if ( $is_amp ) {
// AMP (Accelerated Mobile Page).
$button_src = 'https://static.addtoany.com/buttons/a2a.svg';
$button_width = ! empty( $args['icon_size'] ) ? ' width="' . $args['icon_size'] .'"' : ' width="32"';
$button_height = ! empty( $args['icon_size'] ) ? ' height="' . $args['icon_size'] .'"' : ' height="32"';
$button_style = ! empty( $icon_bg_color_filtered ) ? ' style="background-color:' . esc_attr( $icon_bg_color_filtered ) . '"' : '';
}
}
if ( ! empty( $html_content ) ) {
$button = $html_content;
} elseif ( ! empty( $button_text ) ) {
$button = $button_text;
} elseif ( ! empty( $button_src ) ) {
$button = '<img src="' . $button_src . '"' . $button_width . $button_height . $button_style . ' alt="Share">';
} else {
$button = '';
}
// Add additional classNames to .a2a_dd.
$button_additional_classes = ! empty( $args['button_additional_classes'] ) ? ' ' . $args['button_additional_classes'] : '';
if ( isset( $options['button_show_count'] ) && $options['button_show_count'] == '1' ) {
$button_class .= ' a2a_counter';
}
$button_html = $args['html_container_open'] . $args['html_wrap_open'] . '<a class="a2a_dd' . $button_class . $button_additional_classes . ' addtoany_share_save addtoany_share" href="'
. esc_url( 'https://www.addtoany.com/share' .$button_href_querystring ) . '"'
. $button_data_url . $button_data_title . $button_data_media . $button_target
. '>' . $button . '</a>';
} else {
// Universal button disabled.
$button_html = '';
}
// Closing tags come after <script> to validate in case the container is a list element.
$button_html .= $args['html_wrap_close'] . $args['html_container_close'];
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
return $button_html;
else
echo $button_html;
}
function ADDTOANY_SHARE_SAVE_SPECIAL( $special_service_code, $args = array() ) {
// $args array = output_later, linkname, linkurl
if ( is_feed() ) {
return;
}
$options = get_option( 'addtoany_options', array() );
$args = array_merge( $args, A2A_SHARE_SAVE_link_vars( $args ) ); // linkname_enc, etc.
$special_anchor_template = '<a class="a2a_button_%1$s addtoany_special_service"%2$s></a>';
$custom_attributes = '';
if ( $special_service_code == 'facebook_like' ) {
$custom_attributes .= ( isset( $options['special_facebook_like_options']['verb'] )
&& 'recommend' == $options['special_facebook_like_options']['verb'] ) ? ' data-action="recommend"' : '';
$custom_attributes .= ( isset( $options['special_facebook_like_options']['show_count'] )
&& $options['special_facebook_like_options']['show_count'] == '1' ) ? '' : ' data-layout="button"';
$custom_attributes .= ' data-href="' . esc_attr( $args['linkurl'] ) . '"';
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
}
elseif ( $special_service_code == 'twitter_tweet' ) {
$custom_attributes .= ' data-url="' . esc_attr( $args['linkurl'] ) . '"';
$custom_attributes .= ' data-text="' . esc_attr( $args['linkname'] ) . '"';
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
}
elseif ( $special_service_code == 'pinterest_pin' ) {
$custom_attributes .= ( isset( $options['special_pinterest_pin_options']['show_count'] )
&& $options['special_pinterest_pin_options']['show_count'] == '1' ) ? '' : ' data-pin-config="none"';
$custom_attributes .= ' data-url="' . esc_attr( $args['linkurl'] ) . '"';
$custom_attributes .= ( empty( $args['linkmedia'] ) ) ? '' : ' data-media="' . esc_attr( $args['linkmedia'] ) . '"';
$special_html = sprintf( $special_anchor_template, $special_service_code, $custom_attributes );
}
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
return $special_html;
else
echo $special_html;
}
if ( ! function_exists( 'A2A_menu_locale' ) ) {
function A2A_menu_locale() {
global $A2A_locale;
$locale = get_locale();
if ( $locale == 'en_US' || $locale == 'en' || $A2A_locale != '' )
return false;
$A2A_locale = 'a2a_localize = {
Share: "' . __( "Share", 'add-to-any' ) . '",
Save: "' . __( "Save", 'add-to-any' ) . '",
Subscribe: "' . __( "Subscribe", 'add-to-any' ) . '",
Email: "' . __( "Email", 'add-to-any' ) . '",
Bookmark: "' . __( "Bookmark", 'add-to-any' ) . '",
ShowAll: "' . __( "Show all", 'add-to-any' ) . '",
ShowLess: "' . __( "Show less", 'add-to-any' ) . '",
FindServices: "' . __( "Find service(s)", 'add-to-any' ) . '",
FindAnyServiceToAddTo: "' . __( "Instantly find any service to add to", 'add-to-any' ) . '",
PoweredBy: "' . __( "Powered by", 'add-to-any' ) . '",
ShareViaEmail: "' . __( "Share via email", 'add-to-any' ) . '",
SubscribeViaEmail: "' . __( "Subscribe via email", 'add-to-any' ) . '",
BookmarkInYourBrowser: "' . __( "Bookmark in your browser", 'add-to-any' ) . '",
BookmarkInstructions: "' . __( "Press Ctrl+D or \u2318+D to bookmark this page", 'add-to-any' ) . '",
AddToYourFavorites: "' . __( "Add to your favorites", 'add-to-any' ) . '",
SendFromWebOrProgram: "' . __( "Send from any email address or email program", 'add-to-any' ) . '",
EmailProgram: "' . __( "Email program", 'add-to-any' ) . '",
More: "' . __( "More…", 'add-to-any' ) . '",
ThanksForSharing: "' . __( "Thanks for sharing!", 'add-to-any' ) . '",
ThanksForFollowing: "' . __( "Thanks for following!", 'add-to-any' ) . '"
};
';
return $A2A_locale;
}
}
function ADDTOANY_FOLLOW_KIT( $args = array() ) {
$options = get_option( 'addtoany_options', array() );
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT.
$defaults = array(
'buttons' => array(),
'linkname' => '',
'linkurl' => '',
'linkname_enc' => '',
'linkurl_enc' => '',
'use_current_page' => false,
'output_later' => false,
'is_follow' => true,
'is_kit' => true,
'no_special_services' => true,
'no_universal_button' => true,
'kit_additional_classes' => '',
'kit_style' => '',
'icon_size' => isset( $options['icon_size'] ) ? $options['icon_size'] : '32',
'services' => array(),
);
$args = wp_parse_args( $args, $defaults );
// Add a2a_follow className to Kit classes.
$args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_follow' );
// If $args['buttons']['feed']['id'] is set.
$buttons = $args['buttons'];
if ( ! empty( $buttons['feed'] ) && ! empty( $buttons['feed']['id'] ) ) {
$args['linkurl'] = $buttons['feed']['id'];
$args['linkname'] = get_bloginfo( 'name' );
}
$follow_html = ADDTOANY_SHARE_SAVE_KIT( $args );
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
return $follow_html;
else
echo $follow_html;
}
function ADDTOANY_SHARE_SAVE_FLOATING( $args = array() ) {
$options = get_option( 'addtoany_options', array() );
$floating_html = '';
// Overridable by args below.
$vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical']
&& ! in_array( $options['floating_vertical'], array( 'left_attached', 'right_attached' ) )
) ? $options['floating_vertical'] : false;
$horizontal_type = ( isset( $options['floating_horizontal'] ) && 'none' != $options['floating_horizontal'] ) ? $options['floating_horizontal'] : false;
if ( is_singular() ) {
// Sharing disabled for this singular post?
$sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
if ( ! empty( $sharing_disabled ) ) {
// Overridable by args below.
$vertical_type = false;
$horizontal_type = false;
}
}
// Args are passed on to ADDTOANY_SHARE_SAVE_KIT.
$defaults = array(
'linkname' => '',
'linkurl' => '',
'linkname_enc' => '',
'linkurl_enc' => '',
'use_current_page' => true,
'output_later' => false,
'is_floating' => true,
'is_kit' => true,
'no_addtoany_list_classname' => true,
'no_special_services' => true,
'kit_additional_classes' => '',
'kit_style' => '',
);
$args = wp_parse_args( $args, $defaults );
// Individual floating type args can override saved options.
if ( isset( $args['vertical_type'] ) && $args['vertical_type'] === true ) {
$vertical_type = true;
}
if ( isset( $args['horizontal_type'] ) && $args['horizontal_type'] === true ) {
$horizontal_type = true;
}
// If either floating type is enabled,
// expect either a string from options, or a boolean from args.
if ( $vertical_type || $horizontal_type ) {
// Vertical type?
if ( $vertical_type ) {
// Prevent overwriting of $args.
$vertical_args = $args;
// Top position.
$position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
// Left or right offset.
$offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
// Icon size.
$vertical_args['icon_size'] = ( isset( $options['floating_vertical_icon_size'] ) ) ? $options['floating_vertical_icon_size'] : '32';
// Show on scroll value from the top.
$vertical_scroll_show_top = isset( $options['floating_vertical_scroll_top'] ) && '1' == $options['floating_vertical_scroll_top']
&& isset( $options['floating_vertical_scroll_top_pixels'] )
&& is_numeric( $options['floating_vertical_scroll_top_pixels'] ) ? $options['floating_vertical_scroll_top_pixels'] : '';
// Show on scroll value from the bottom.
$vertical_scroll_show_bottom = isset( $options['floating_vertical_scroll_bottom'] ) && '1' == $options['floating_vertical_scroll_bottom']
&& isset( $options['floating_vertical_scroll_bottom_pixels'] )
&& is_numeric( $options['floating_vertical_scroll_bottom_pixels'] ) ? $options['floating_vertical_scroll_bottom_pixels'] : '';
// Merge values as required.
if ( ! empty( $vertical_scroll_show_bottom ) ) {
$vertical_args['scroll_show'] = empty( $vertical_scroll_show_top ) ? '0,' . $vertical_scroll_show_bottom : $vertical_scroll_show_top . ',' . $vertical_scroll_show_bottom;
} elseif ( ! empty( $vertical_scroll_show_top ) ) {
$vertical_args['scroll_show'] = $vertical_scroll_show_top;
}
// Add a2a_vertical_style className to Kit classes.
$vertical_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_vertical_style' );
// Add declarations to Kit style attribute.
if ( 'left_docked' === $vertical_type ) {
$vertical_args['kit_style'] = 'left:' . $offset . ';top:' . $position . ';';
} elseif ( 'right_docked' === $vertical_type ) {
$vertical_args['kit_style'] = 'right:' . $offset . ';top:' . $position . ';';
}
// Set background color.
if ( ! empty( $options['floating_vertical_bg'] ) && 'custom' === $options['floating_vertical_bg'] ) {
$vertical_args['kit_style'] .= ! empty( $options['floating_vertical_bg_color'] ) ? 'background-color:' . $options['floating_vertical_bg_color'] . ';' : '';
} else {
$vertical_args['kit_style'] .= 'background-color:transparent;';
}
$floating_html .= ADDTOANY_SHARE_SAVE_KIT( $vertical_args );
}
// Horizontal type?
if ( $horizontal_type ) {
// Prevent overwriting of $args values.
$horizontal_args = $args;
// Left or right position.
$position = ( isset( $options['floating_horizontal_position'] ) ) ? $options['floating_horizontal_position'] . 'px' : '0px';
// Bottom offset.
$offset = ( isset( $options['floating_horizontal_offset'] ) ) ? $options['floating_horizontal_offset'] . 'px' : '0px';
// Icon size.
$horizontal_args['icon_size'] = ( isset( $options['floating_horizontal_icon_size'] ) ) ? $options['floating_horizontal_icon_size'] : '32';
// Show on scroll value from the top.
$horizontal_scroll_show_top = isset( $options['floating_horizontal_scroll_top'] ) && '1' == $options['floating_horizontal_scroll_top']
&& isset( $options['floating_horizontal_scroll_top_pixels'] )
&& is_numeric( $options['floating_horizontal_scroll_top_pixels'] ) ? $options['floating_horizontal_scroll_top_pixels'] : '';
// Show on scroll value from the bottom.
$horizontal_scroll_show_bottom = isset( $options['floating_horizontal_scroll_bottom'] ) && '1' == $options['floating_horizontal_scroll_bottom']
&& isset( $options['floating_horizontal_scroll_bottom_pixels'] )
&& is_numeric( $options['floating_horizontal_scroll_bottom_pixels'] ) ? $options['floating_horizontal_scroll_bottom_pixels'] : '';
// Merge values as required.
if ( ! empty( $horizontal_scroll_show_bottom ) ) {
$horizontal_args['scroll_show'] = empty( $horizontal_scroll_show_top ) ? '0,' . $horizontal_scroll_show_bottom : $horizontal_scroll_show_top . ',' . $horizontal_scroll_show_bottom;
} elseif ( ! empty( $horizontal_scroll_show_top ) ) {
$horizontal_args['scroll_show'] = $horizontal_scroll_show_top;
}
// Add a2a_default_style className to Kit classes.
$horizontal_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_default_style' );
// Add declarations to Kit style attribute.
if ( 'left_docked' === $horizontal_type ) {
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:' . $position . ';';
} elseif ( 'right_docked' === $horizontal_type ) {
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';right:' . $position . ';';
} elseif ( 'center_docked' === $horizontal_type ) {
$horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:50%;transform:translateX(-50%);';
}
// Background color.
if ( ! empty( $options['floating_horizontal_bg'] ) && 'custom' === $options['floating_horizontal_bg'] ) {
$horizontal_args['kit_style'] .= ! empty( $options['floating_horizontal_bg_color'] ) ? 'background-color:' . $options['floating_horizontal_bg_color'] . ';' : '';
} else {
$horizontal_args['kit_style'] .= 'background-color:transparent;';
}
$floating_html .= ADDTOANY_SHARE_SAVE_KIT( $horizontal_args );
}
}
if ( isset( $args['output_later'] ) && $args['output_later'] == true )
return $floating_html;
else
echo $floating_html;
}
function A2A_SHARE_SAVE_head_script() {
// Hook to disable script output.
// Example: add_filter( 'addtoany_script_disabled', '__return_true' );
$script_disabled = apply_filters( 'addtoany_script_disabled', false );
if ( is_admin() || is_feed() || $script_disabled )
return;
if ( is_singular() ) {
// Sharing disabled for this singular post?
$sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
}
$options = get_option( 'addtoany_options', array() );
// Use local cache?
$cache = ! empty( $options['cache'] ) && '1' == $options['cache'] ? true : false;
$upload_dir = wp_upload_dir();
$cached_file = ! empty( $upload_dir['basedir'] ) && file_exists( $upload_dir['basedir'] . '/addtoany/page.js' ) ? $upload_dir['basedir'] . '/addtoany/page.js' : false;
$querystring = '';
// Is page.js actually cached?
if ( $cache && $cached_file ) {
// Is page.js recently cached, within 2 days (172800 seconds)?
$modified_time = filemtime( $cached_file );
$cache = $modified_time && time() - $modified_time < 172800 ? true : false;
// If cache is recent
if ( $cache ) {
// Set a "ver" parameter's value to the file's modified time for cache management.
$querystring = '?ver=' . $modified_time;
} else {
// Revert the cache option.
A2A_SHARE_SAVE_revert_cache();
}
}
// Set static server.
$static_server = $cache ? $upload_dir['baseurl'] . '/addtoany' : 'https://static.addtoany.com/menu';
// Icon colors.
$icon_bg = ! empty( $options['icon_bg'] ) && in_array( $options['icon_bg'], array( 'custom', 'transparent' ) ) ? $options['icon_bg'] : false;
$icon_bg_color = 'custom' === $icon_bg && ! empty( $options['icon_bg_color'] ) ? $options['icon_bg_color'] : '';
$icon_bg_color = 'transparent' === $icon_bg ? 'transparent' : $icon_bg_color;
$icon_fg = ! empty( $options['icon_fg'] ) && 'custom' === $options['icon_fg'] ? true : false;
$icon_fg_color = $icon_fg && ! empty( $options['icon_fg_color'] ) ? ',' . $options['icon_fg_color'] : '';
// Use "unset" keyword for background if only the foreground is set.
$icon_bg_color = empty( $icon_bg_color ) && ! empty( $icon_fg_color ) ? 'unset' : $icon_bg_color;
$icon_color = $icon_bg_color . $icon_fg_color;
// Floating vertical relative to content.
$floating_js = '';
if (
isset( $options['floating_vertical'] )
&& in_array( $options['floating_vertical'], array( 'left_attached', 'right_attached' ) )
&& ! empty( $options['floating_vertical_attached_to'] )
&& empty( $sharing_disabled )
) {
// Top position.
$floating_js_position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
// Left or right offset.
$floating_js_offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
// Style attribute (accepts "left" attached only).
$floating_js_kit_style = 'left_attached' === $options['floating_vertical'] ? 'margin-left:' . $floating_js_offset . ';' : '';
$floating_js_kit_style .= 'top:' . $floating_js_position . ';';
$floating_js = "\n"
. 'a2a_config.callbacks.push({'
. 'ready: function(){'
. 'var d=document;'
. 'function a(){'
. 'var c,e=d.createElement("div");'
. 'e.innerHTML=' . wp_json_encode( ADDTOANY_SHARE_SAVE_FLOATING( array(
'output_later' => true,
'basic_html' => true,
'kit_style' => $floating_js_kit_style,
'vertical_type' => true,
) ) ) . ';'
. 'c=d.querySelector(' . wp_json_encode( stripslashes( $options['floating_vertical_attached_to'] ) ) . ');'
. 'if(c)c.appendChild(e.firstChild);'
. 'a2a.init("page");'
. '}'
. 'if("loading"!==d.readyState)a();else d.addEventListener("DOMContentLoaded",a,false);'
. '}'
. '});';
}
// Enternal script call + initial JS + set-once variables.
$additional_js = ( isset( $options['additional_js_variables'] ) ) ? $options['additional_js_variables'] : '' ;
$script_configs = ( ( $cache ) ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '' )
. ( $icon_color ? "\n" . 'a2a_config.icon_color="' . $icon_color . '";' : '' )
. ( isset( $options['onclick'] ) && '1' == $options['onclick'] ? "\n" . 'a2a_config.onclick=1;' : '' )
. ( $additional_js ? "\n" . stripslashes( $additional_js ) : '' );
$javascript_header = "\n"
. '<script data-cfasync="false">' . "\n"
. 'window.a2a_config=window.a2a_config||{};'
. 'a2a_config.callbacks=[];a2a_config.overlays=[];'
. 'a2a_config.templates={};'
. A2A_menu_locale()
. $floating_js
. $script_configs
. "\n"
. '(function(d,s,a,b){'
. 'a=d.createElement(s);'
. 'b=d.getElementsByTagName(s)[0];'
. 'a.async=1;'
. 'a.src="' . $static_server . '/page.js' . $querystring . '";'
. 'b.parentNode.insertBefore(a,b);'
. '})(document,"script");'
. "\n</script>\n";
echo $javascript_header;
}
add_action( 'wp_head', 'A2A_SHARE_SAVE_head_script' );
function A2A_SHARE_SAVE_footer_script() {
if ( is_admin() || is_feed() )
return;
$floating_html = ADDTOANY_SHARE_SAVE_FLOATING( array( 'output_later' => true ) );
echo $floating_html;
}
add_action( 'wp_footer', 'A2A_SHARE_SAVE_footer_script' );
function A2A_SHARE_SAVE_add_to_content( $content ) {
global $wp_current_filter;
// Don't add to get_the_excerpt because it's too early and strips tags (adding to the_excerpt is allowed).
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
// Return early.
return $content;
}
$sharing_disabled = get_post_meta( get_the_ID(), 'sharing_disabled', true );
$sharing_disabled = apply_filters( 'addtoany_sharing_disabled', $sharing_disabled );
if (
// Private post?
get_post_status( get_the_ID() ) == 'private' ||
// Sharing disabled on post?
! empty( $sharing_disabled )
) {
// Return early
return $content;
}
$is_feed = is_feed();
$options = get_option( 'addtoany_options', array() );
$post_type = get_post_type( get_the_ID() );
if (
(
// Legacy tags?
// <!--sharesave--> tag
strpos( $content, '<!--sharesave-->' ) === false ||
// <!--nosharesave--> tag
strpos( $content, '<!--nosharesave-->' ) !== false
) &&
(
// Posts
// All posts.
( is_singular('post') && isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) ||
// Front page posts.
( is_home() && isset( $options['display_in_posts_on_front_page'] ) && $options['display_in_posts_on_front_page'] == '-1' ) ||
// Archive page posts (Category, Tag, Author and Date pages).
( is_archive() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
// Search results posts (same as Archive page posts option).
( is_search() && isset( $options['display_in_posts_on_archive_pages'] ) && $options['display_in_posts_on_archive_pages'] == '-1' ) ||
// Excerpt (the_excerpt is the current filter).
// XTEC ************ MODIFICAT - If not defined, not display in excerpt
// 2016.03.16 @sarjona
( 'the_excerpt' == current_filter() && (!isset( $options['display_in_excerpts'] ) || $options['display_in_excerpts'] == '-1' )) ||
//************ ORIGINAL
/*
( 'the_excerpt' == current_filter() && isset( $options['display_in_excerpts'] ) && $options['display_in_excerpts'] == '-1' ) ||
*/
//************ FI
// Posts in feed.
( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
// Custom post types.
( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' ) ||
// Pages
// Individual pages.
// XTEC ************ MODIFICAT - If not defined, not display in pages
// 2016.03.16 @sarjona
( is_page() && (!isset( $options['display_in_pages']) || $options['display_in_pages'] == '-1' )) ||
//************ ORIGINAL
/*
( is_singular('page') && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
*/
//************ FI
// Attachment (media) pages.
( is_attachment() && isset( $options['display_in_attachments'] ) && $options['display_in_attachments'] == '-1' ) ||
// <!--nosharesave--> legacy tag.
( (strpos( $content, '<!--nosharesave-->') !== false ) )
)
) {
// Return early.
return $content;
}
$kit_args = array(
"output_later" => true,
"is_kit" => ( $is_feed ) ? false : true,
);
// If a Sharing Header is set
if ( ! empty( $options['header'] ) ) {
$html_header = '<div class="addtoany_header">' . stripslashes( $options['header'] ) . '</div>';
} else {
$html_header = '';
}
if ( $is_feed ) {
$container_wrap_open = '<p>';
$container_wrap_close = '</p>';
$kit_args['html_container_open'] = '';
$kit_args['html_container_close'] = '';