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