Plugin Directory

Changeset 2274521

Timestamp:
04/02/2020 10:45:09 PM (6 years ago)
Author:
micropat
Message:
  • Require PHP 5.3 as a bare minimum for compatibility features
Location:
add-to-any/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • add-to-any/trunk/README.txt

    r2174023 r2274521  
    33Tags: 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
    44Requires at least: 3.7
    5 Tested up to: 5.3
     5Tested up to: 5.
    66Requires PHP: 5.6
    7 Stable tag: 1.7.39
     7Stable tag: 1.7.
    88
    99Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, WhatsApp, Pinterest, Reddit, many more, and follow icons too.
     
    346346
    347347== Changelog ==
     348
     349
     350
    348351
    349352= 1.7.39 =
  • add-to-any/trunk/add-to-any.php

    r2174023 r2274521  
    11<?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.39
    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
     2/*
     3Plugin Name: AddToAny Share Buttons
     4Plugin URI: https://www.addtoany.com/
     5Description: Share buttons for your pages including AddToAny's universal sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp and many more.
     6 * Version: 1.7.40
     7Author: AddToAny
     8Author URI: https://www.addtoany.com/
     9Text Domain: add-to-any
     10Domain Path: /languages
     11*/
     12
     13// Explicitly globalize to support bootstrapped WordPress
    1414global $A2A_locale, $A2A_FOLLOW_services,
    1515    $A2A_SHARE_SAVE_options, $A2A_SHARE_SAVE_plugin_dir, $A2A_SHARE_SAVE_plugin_url,
     
    1919$A2A_SHARE_SAVE_plugin_url = untrailingslashit( plugin_dir_url( __FILE__ ) );
    2020
    21 // Set AddToAny locale (JavaScript)
     21// Set AddToAny locale (JavaScript)
    2222$A2A_locale = ! isset ( $A2A_locale ) ? '' : $A2A_locale;
    23 // Set plugin options
     23// Set plugin options
    2424$A2A_SHARE_SAVE_options = get_option( 'addtoany_options', array() );
    2525
    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+).
     27if ( version_compare( phpversion(), '5.3.0', '>=' ) ) {
     28    include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.compat.php';
     29}
     30
    2731include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.services.php';
    2832
     
    3135        $A2A_SHARE_SAVE_options;
    3236   
    33     // Load the textdomain for translations
     37    // Load the textdomain for translations
    3438    load_plugin_textdomain( 'add-to-any', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
    3539   
    36     // Update plugin options   
     40    // Update plugin options
    3741    $options = $A2A_SHARE_SAVE_options;
    3842    $old_buttons = array(
     
    4246    );
    4347   
    44     // If old button enabled
     48    // If old button enabled
    4549    if ( ! empty( $options['button'] ) && in_array( $options['button'], $old_buttons ) ) {
    4650        include_once $A2A_SHARE_SAVE_plugin_dir . '/addtoany.update.php';
     
    5862    $use_current_page = isset( $args['use_current_page'] ) ? $args['use_current_page'] : false;
    5963
    60     // Set linkname if needed, and not a Follow kit
     64    // Set linkname if needed, and not a Follow kit
    6165    if ( ! $linkname && empty( $args['is_follow'] ) ) {
    6266        if ( $use_current_page ) {
     
    7175    $linkname_enc = rawurlencode( $linkname );
    7276   
    73     // Set linkurl if needed, and not a Follow kit
     77    // Set linkurl if needed, and not a Follow kit
    7478    if ( ! $linkurl && empty( $args['is_follow'] ) ) {
    7579        if ( $use_current_page ) {
     
    8488    $linkurl_enc = rawurlencode( $linkurl );
    8589   
    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)
    8791    $linkmedia_enc = ! empty( $args['linkmedia'] ) ? rawurlencode( $args['linkmedia'] ) : '';
    8892   
     
    9094}
    9195
    92 // Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
     96// Combine ADDTOANY_SHARE_SAVE_ICONS and ADDTOANY_SHARE_SAVE_BUTTON
    9397function ADDTOANY_SHARE_SAVE_KIT( $args = array() ) {
    9498    $options = get_option( 'addtoany_options', array() );
     
    104108    $args = wp_parse_args( $args, $defaults );
    105109   
    106     // If universal button disabled, and not manually disabled through args
     110    // If universal button disabled, and not manually disabled through args
    107111    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        //
    110114        $args['no_universal_button'] = true;
    111115    }
     
    121125    $kit_style = '';
    122126   
    123     // Add additional classNames to .a2a_kit
     127    // Add additional classNames to .a2a_kit
    124128    if ( ! empty( $args['kit_additional_classes'] ) ) {
    125         // Append space and className(s)
     129        // Append space and className(s)
    126130        $kit_additional_classes .= ' ' . $args['kit_additional_classes'];
    127131    }
    128132   
    129     // Set a2a_kit_size_## class name
     133    // Set a2a_kit_size_## class name
    130134    if ( $custom_icons ) {
    131135        // If vertical style (.a2a_vertical_style)
    132136        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
    134138            $icon_size_classname = isset( $options['custom_icons_width'] ) ? ' a2a_kit_size_' . $options['custom_icons_width'] : '';
    135139        } 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
    137141            $icon_size_classname = isset( $options['custom_icons_height'] ) ? ' a2a_kit_size_' . $options['custom_icons_height'] : '';
    138142        }
    139     // a2a_kit_size_## icon size
     143    //
    140144    } else {
    141145        $icon_size_classname = ' a2a_kit_size_' . $args['icon_size'];
    142146    }
    143147   
    144     // Add addtoany_list className unless disabled (for floating buttons)
     148    // Add addtoany_list className unless disabled (for floating buttons)
    145149    if ( ! isset( $args['no_addtoany_list_classname'] ) ) {
    146150        $kit_additional_classes .= ' addtoany_list';
    147151    }
    148152   
    149     // Add style attribute if set
     153    // Add style attribute if set
    150154    if ( ! empty( $args['kit_style'] ) ) {
    151155        $kit_style = ' style="' . esc_attr( $args['kit_style'] ) . '"';
     
    159163    if ( ! isset( $args['html_container_close'] ) )
    160164        $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']);
    164170               
    165171    if ( ! isset( $args['html_wrap_open'] ) )
     
    170176    $kit_html = ADDTOANY_SHARE_SAVE_ICONS( $args );
    171177   
    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'] );
    174182   
    175183    $kit_html .= ADDTOANY_SHARE_SAVE_BUTTON( $args );
     
    214222    $is_amp = function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ? true : false;
    215223   
    216     // Large icons except for AMP endpoint
     224    //
    217225    $large_icons = $is_amp ? false : true;
    218226   
     
    226234        $custom_icons = true;
    227235    } else {
    228         // Default to local SVGs (not an option currently)
     236        // Default to local SVGs
    229237        $icons_dir = plugins_url('/icons/', __FILE__ );
    230238        $icons_type = 'svg';
     
    245253        $service_codes = ( is_array( $services ) ) ? array_keys( $services ) : array();
    246254       
    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
    248256        if ( ! isset( $args['no_special_services'] ) || false == $args['no_special_services'] ) {
    249257            array_unshift( $service_codes, 'facebook_like', 'twitter_tweet', 'pinterest_pin' );
    250258        }
    251259   
    252         // Use default services if services have not been selected yet
     260        // Use default services if services have not been selected yet
    253261        $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
    255263        $active_services = empty( $args['buttons'] ) ? $active_services : $args['buttons'];
    256264    }
     
    281289                // If it's a URL instead of a service ID
    282290                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
    284292                    $href = $follow_id;
    285293                } else {
    286                     // Replace the ID placeholder in the URL template
     294                    // Replace the ID placeholder in the URL template
    287295                    $href = str_replace( '${id}', $follow_id, $service['href'] );
    288296                }
    289297                $href = ( 'feed' == $code_name ) ? $follow_id : $href;
    290298               
    291                 // If icon_url is set, presume custom service
     299                // If icon_url is set, presume custom service
    292300                if ( isset( $service['icon_url'] ) ) {
    293301                    $custom_service = true;
    294302                }
    295             // Else if Share Kit and HREF specified, presume custom service
     303            // Else if Share Kit and HREF specified, presume custom service
    296304            } elseif ( isset( $service['href'] ) ) {
    297305                $custom_service = true;
     
    342350            }
    343351           
    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
    345353            $rel_noopener = $custom_service || ! $target_attr ? '' : ' noopener';
    346354            $rel_noopener_only = $rel_noopener || $target_attr ? ' rel="noopener"' : '';
     
    348356            $rel_attr = $args['basic_html'] ? '' : $rel_attr;
    349357
    350             // Set dimension attributes if using custom icons and dimension is specified
     358            // Set dimension attributes if using custom icons and dimension is specified
    351359            if ( isset( $custom_icons ) ) {
    352360                $width_attr = ! empty( $icons_width ) ? ' width="' . $icons_width . '"' : '';
     
    413421       
    414422        if ( isset( $options['button'] ) && 'CUSTOM' == $options['button'] ) {
    415             // Custom button
     423            // Custom button
    416424            $button_src     = $options['button_custom'];
    417425            $button_width   = '';
     
    419427            $button_style   = '';
    420428        } else if ( isset( $options['button'] ) && 'TEXT' == $options['button'] ) {
    421             // Text-only button
     429            // Text-only button
    422430            $button_text    = stripslashes( $options[ 'button_text'] );
    423             // Do not display universal icon
     431            // Do not display universal icon
    424432            $button_class  .= ' addtoany_no_icon';
    425433        } else {
    426             // Default AddToAny button
     434            // Default AddToAny button
    427435            if ( $is_amp ) {
    428                 // AMP (Accelerated Mobile Page)
     436                // AMP (Accelerated Mobile Page)
    429437                $button_src    = 'https://static.addtoany.com/buttons/a2a.svg';
    430438                $button_width  = ! empty( $args['icon_size'] ) ? ' width="' . $args['icon_size'] .'"'  : ' width="32"';
     
    444452        }
    445453       
    446         // Add additional classNames to .a2a_dd
     454        // Add additional classNames to .a2a_dd
    447455        $button_additional_classes = ! empty( $args['button_additional_classes'] ) ? ' ' . $args['button_additional_classes'] : '';
    448456       
     
    457465   
    458466    } else {
    459         // Universal button disabled
     467        // Universal button disabled
    460468        $button_html = '';
    461469    }
    462470   
    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
    464472    $button_html .= $args['html_wrap_close'] . $args['html_container_close'];
    465473   
     
    550558    $options = get_option( 'addtoany_options', array() );
    551559   
    552     // Args are passed on to ADDTOANY_SHARE_SAVE_KIT
     560    // Args are passed on to ADDTOANY_SHARE_SAVE_KIT
    553561    $defaults = array(
    554562        'buttons' => array(),
     
    571579    $args = wp_parse_args( $args, $defaults );
    572580   
    573     // Add a2a_follow className to Kit classes
     581    // Add a2a_follow className to Kit classes
    574582    $args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_follow' );
    575583   
    576     // If $args['buttons']['feed']['id'] is set
     584    // If $args['buttons']['feed']['id'] is set
    577585    $buttons = $args['buttons'];
    578586    if ( ! empty( $buttons['feed'] ) && ! empty( $buttons['feed']['id'] ) ) {
     
    594602    $floating_html = '';
    595603
    596     // Overridable by args below
     604    // Overridable by args below
    597605    $vertical_type = ( isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical']
    598606        && ! in_array( $options['floating_vertical'], array( 'left_attached', 'right_attached' ) )
     
    606614       
    607615        if ( ! empty( $sharing_disabled ) ) {
    608             // Overridable by args below
     616            // Overridable by args below
    609617            $vertical_type   = false;
    610618            $horizontal_type = false;
     
    612620    }
    613621
    614     // Args are passed on to ADDTOANY_SHARE_SAVE_KIT
     622    // Args are passed on to ADDTOANY_SHARE_SAVE_KIT
    615623    $defaults = array(
    616624        'linkname' => '',
     
    630638    $args = wp_parse_args( $args, $defaults );
    631639   
    632     // Individual floating type args can override saved options
     640    // Individual floating type args can override saved options
    633641    if ( isset( $args['vertical_type'] ) && $args['vertical_type'] === true ) {
    634642        $vertical_type = true;
     
    638646    }
    639647
    640     // If either floating type is enabled
    641     // Expect either a string from options, or a boolean from args
     648    // If either floating type is enabled
     649    //
    642650    if ( $vertical_type || $horizontal_type ) {
    643651        // Vertical type?
    644652        if ( $vertical_type ) {
    645             // Prevent overwriting of $args
     653            // Prevent overwriting of $args
    646654            $vertical_args = $args;
    647655           
    648             // Top position
     656            // Top position
    649657            $position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
    650             // Left or right offset
     658            // Left or right offset
    651659            $offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
    652             // Icon size
     660            // Icon size
    653661            $vertical_args['icon_size'] = ( isset( $options['floating_vertical_icon_size'] ) ) ? $options['floating_vertical_icon_size'] : '32';
    654662           
    655             // Show on scroll value from the top
     663            // Show on scroll value from the top
    656664            $vertical_scroll_show_top = isset( $options['floating_vertical_scroll_top'] ) && '1' == $options['floating_vertical_scroll_top']
    657665                && isset( $options['floating_vertical_scroll_top_pixels'] )
    658666                && 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
    660668            $vertical_scroll_show_bottom = isset( $options['floating_vertical_scroll_bottom'] ) && '1' == $options['floating_vertical_scroll_bottom']
    661669                && isset( $options['floating_vertical_scroll_bottom_pixels'] )
    662670                && is_numeric( $options['floating_vertical_scroll_bottom_pixels'] ) ? $options['floating_vertical_scroll_bottom_pixels'] : '';
    663             // Merge values as required
     671            // Merge values as required
    664672            if ( ! empty( $vertical_scroll_show_bottom ) ) {
    665673                $vertical_args['scroll_show'] = empty( $vertical_scroll_show_top ) ? '0,' . $vertical_scroll_show_bottom : $vertical_scroll_show_top . ',' . $vertical_scroll_show_bottom;
     
    668676            }
    669677       
    670             // Add a2a_vertical_style className to Kit classes
     678            // Add a2a_vertical_style className to Kit classes
    671679            $vertical_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_vertical_style' );
    672680           
    673             // Add declarations to Kit style attribute
     681            // Add declarations to Kit style attribute
    674682            if ( 'left_docked' === $vertical_type ) {
    675683                $vertical_args['kit_style'] = 'left:' . $offset . ';top:' . $position . ';';
     
    677685                $vertical_args['kit_style'] = 'right:' . $offset . ';top:' . $position . ';';
    678686            }
    679             // Background color
     687            //
    680688            if ( ! empty( $options['floating_vertical_bg'] ) && 'custom' === $options['floating_vertical_bg'] ) {
    681689                $vertical_args['kit_style'] .= ! empty( $options['floating_vertical_bg_color'] ) ? 'background-color:' . $options['floating_vertical_bg_color'] . ';' : '';
     
    689697        // Horizontal type?
    690698        if ( $horizontal_type ) {
    691             // Prevent overwriting of $args values
     699            // Prevent overwriting of $args values
    692700            $horizontal_args = $args;
    693701           
    694             // Left or right position
     702            // Left or right position
    695703            $position = ( isset( $options['floating_horizontal_position'] ) ) ? $options['floating_horizontal_position'] . 'px' : '0px';
    696             // Bottom offset
     704            // Bottom offset
    697705            $offset = ( isset( $options['floating_horizontal_offset'] ) ) ? $options['floating_horizontal_offset'] . 'px' : '0px';
    698             // Icon size
     706            // Icon size
    699707            $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
    701709            $horizontal_scroll_show_top = isset( $options['floating_horizontal_scroll_top'] ) && '1' == $options['floating_horizontal_scroll_top']
    702710                && isset( $options['floating_horizontal_scroll_top_pixels'] )
    703711                && 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
    705713            $horizontal_scroll_show_bottom = isset( $options['floating_horizontal_scroll_bottom'] ) && '1' == $options['floating_horizontal_scroll_bottom']
    706714                && isset( $options['floating_horizontal_scroll_bottom_pixels'] )
    707715                && is_numeric( $options['floating_horizontal_scroll_bottom_pixels'] ) ? $options['floating_horizontal_scroll_bottom_pixels'] : '';
    708             // Merge values as required
     716            // Merge values as required
    709717            if ( ! empty( $horizontal_scroll_show_bottom ) ) {
    710718                $horizontal_args['scroll_show'] = empty( $horizontal_scroll_show_top ) ? '0,' . $horizontal_scroll_show_bottom : $horizontal_scroll_show_top . ',' . $horizontal_scroll_show_bottom;
     
    713721            }
    714722
    715             // Add a2a_default_style className to Kit classes
     723            // Add a2a_default_style className to Kit classes
    716724            $horizontal_args['kit_additional_classes'] = trim( $args['kit_additional_classes'] . ' a2a_floating_style a2a_default_style' );
    717725           
    718             // Add declarations to Kit style attribute
     726            // Add declarations to Kit style attribute
    719727            if ( 'left_docked' === $horizontal_type ) {
    720728                $horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:' . $position . ';';
     
    724732                $horizontal_args['kit_style'] = 'bottom:' . $offset . ';left:50%;transform:translateX(-50%);';
    725733            }
    726             // Background color
     734            // Background color
    727735            if ( ! empty( $options['floating_horizontal_bg'] ) && 'custom' === $options['floating_horizontal_bg'] ) {
    728736                $horizontal_args['kit_style'] .= ! empty( $options['floating_horizontal_bg_color'] ) ? 'background-color:' . $options['floating_horizontal_bg_color'] . ';' : '';
     
    743751
    744752function A2A_SHARE_SAVE_head_script() {
    745     // Hook to disable script output
     753    // Hook to disable script output
    746754    // Example: add_filter( 'addtoany_script_disabled', '__return_true' );
    747755    $script_disabled = apply_filters( 'addtoany_script_disabled', false );
     
    770778        // If cache is recent
    771779        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
    773781            $querystring = '?ver=' . $modified_time;
    774782        } else {
    775             // Revert the cache option
     783            // Revert the cache option
    776784            A2A_SHARE_SAVE_revert_cache();
    777785        }
    778786    }
    779787   
    780     // Set static server
     788    // Set static server
    781789    $static_server = $cache ? $upload_dir['baseurl'] . '/addtoany' : 'https://static.addtoany.com/menu';
    782790   
    783     // Icon colors
     791    // Icon colors
    784792    $icon_bg = ! empty( $options['icon_bg'] ) && in_array( $options['icon_bg'], array( 'custom', 'transparent' ) ) ? $options['icon_bg'] : false;
    785793    $icon_bg_color = 'custom' === $icon_bg && ! empty( $options['icon_bg_color'] ) ? $options['icon_bg_color'] : '';
     
    787795    $icon_fg = ! empty( $options['icon_fg'] ) && 'custom' === $options['icon_fg'] ? true : false;
    788796    $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
    790798    $icon_bg_color = empty( $icon_bg_color ) && ! empty( $icon_fg_color ) ? 'unset' : $icon_bg_color;
    791799    $icon_color = $icon_bg_color . $icon_fg_color;
    792800
    793     // Floating vertical relative to content
     801    // Floating vertical relative to content
    794802    $floating_js = '';
    795803    if (
     
    799807        && empty( $sharing_disabled )
    800808    ) {
    801         // Top position
     809        // Top position
    802810        $floating_js_position = ( isset( $options['floating_vertical_position'] ) ) ? $options['floating_vertical_position'] . 'px' : '100px';
    803         // Left or right offset
     811        // Left or right offset
    804812        $floating_js_offset = ( isset( $options['floating_vertical_offset'] ) ) ? $options['floating_vertical_offset'] . 'px' : '0px';
    805813       
    806         // Style attribute (accepts "left" attached only)
     814        // Style attribute (accepts "left" attached only)
    807815        $floating_js_kit_style = 'left_attached' === $options['floating_vertical'] ? 'margin-left:' . $floating_js_offset . ';' : '';
    808816        $floating_js_kit_style .= 'top:' . $floating_js_position . ';';
     
    828836    }
    829837   
    830     // Enternal script call + initial JS + set-once variables
     838    // Enternal script call + initial JS + set-once variables
    831839    $additional_js = ( isset( $options['additional_js_variables'] ) ) ? $options['additional_js_variables'] : '' ;
    832840    $script_configs = ( ( $cache ) ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '' )
     
    873881    global $wp_current_filter;
    874882   
    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)
    876884    if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
    877         // Return early
     885        // Return early
    878886        return $content;
    879887    }
     
    883891   
    884892    if (
    885         // Private post
     893        // Private post
    886894        get_post_status( get_the_ID() ) == 'private' ||
    887         // Sharing disabled on post
     895        // Sharing disabled on post
    888896        ! empty( $sharing_disabled )
    889897    ) {
     
    898906    if (
    899907        (
    900             // Legacy tags
     908            // Legacy tags
    901909            // <!--sharesave--> tag
    902910            strpos( $content, '<!--sharesave-->' ) === false ||
     
    906914        (
    907915            // Posts
    908             // All posts
     916            // All posts
    909917            ( is_singular('post') && isset( $options['display_in_posts'] ) && $options['display_in_posts'] == '-1' ) ||
    910             // Front page posts     
     918            // Front page posts
    911919            ( 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)
    913921            ( 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)
    915923            ( 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)
    917925            ( 'the_excerpt' == current_filter() && isset( $options['display_in_excerpts'] ) && $options['display_in_excerpts'] == '-1' ) ||
    918             // Posts in feed
     926            // Posts in feed
    919927            ( $is_feed && isset( $options['display_in_feed'] ) && $options['display_in_feed'] == '-1' ) ||
    920928           
    921             // Custom post types
     929            // Custom post types
    922930            ( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' ) ||
    923931           
    924932            // Pages
    925             // Individual pages
     933            // Individual pages
    926934            ( is_singular('page') && isset( $options['display_in_pages'] ) && $options['display_in_pages'] == '-1' ) ||
    927             // Attachment (media) pages
     935            // Attachment (media) pages
    928936            ( is_attachment() && isset( $options['display_in_attachments'] ) && $options['display_in_attachments'] == '-1' ) ||
    929             // <!--nosharesave--> legacy tag
     937            // <!--nosharesave--> legacy tag
    930938            ( (strpos( $content, '<!--nosharesave-->') !== false ) )
    931939        )
    932940    ) {
    933         // Return early
     941        // Return early
    934942        return $content;
    935943    }
     
    963971   
    964972    if ($options['position'] == 'both' || $options['position'] == 'top') {
    965         // Prepend to content
     973        // Prepend to content
    966974        $content = sprintf( $container_wrap_open, 'addtoany_content_top' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close . $content;
    967975    }
    968976    if ( $options['position'] == 'bottom' || $options['position'] == 'both') {
    969         // Append to content
     977        // Append to content
    970978        $content .= sprintf( $container_wrap_open, 'addtoany_content_bottom' ) . ADDTOANY_SHARE_SAVE_KIT($kit_args) . $container_wrap_close;
    971979    }
     
    977985function A2A_SHARE_SAVE_pre_get_posts( $query ) {
    978986    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
    980988        // Example: add_filter( 'addtoany_content_priority', 20 );
    981989        $priority = apply_filters( 'addtoany_content_priority', 98 );
     
    10211029        wp_enqueue_style( 'addtoany', plugins_url('/addtoany.min.css', __FILE__ ), false, '1.15' );
    10221030       
    1023         // Prepare inline CSS
     1031        // Prepare inline CSS
    10241032        $inline_css = '';
    10251033       
     
    10321040            ( ! isset( $options['floating_vertical_responsive'] ) || '-1' != $options['floating_vertical_responsive'] )
    10331041        ) {
    1034             // Get min-width for media query
     1042            // Get min-width for media query
    10351043            $vertical_max_width = (
    10361044                isset( $options['floating_vertical_responsive_max_width'] ) &&
     
    10381046            ) ? $options['floating_vertical_responsive_max_width'] : '980';
    10391047           
    1040             // Set media query
     1048            // Set media query
    10411049            $inline_css .= '@media screen and (max-width:' . $vertical_max_width . 'px){' . "\n"
    10421050                . '.a2a_floating_style.a2a_vertical_style{display:none;}' . "\n"
     
    10491057            ( ! isset( $options['floating_horizontal_responsive'] ) || '-1' != $options['floating_horizontal_responsive'] )
    10501058        ) {
    1051             // Get max-width for media query
     1059            // Get max-width for media query
    10521060            $horizontal_min_width = (
    10531061                isset( $options['floating_horizontal_responsive_min_width'] ) &&
     
    10551063            ) ? $options['floating_horizontal_responsive_min_width'] : '981';
    10561064           
    1057             // Insert newline if there is inline CSS already
     1065            // Insert newline if there is inline CSS already
    10581066            $inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
    10591067           
    1060             // Set media query
     1068            // Set media query
    10611069            $inline_css .= '@media screen and (min-width:' . $horizontal_min_width . 'px){' . "\n"
    10621070                . '.a2a_floating_style.a2a_default_style{display:none;}' . "\n"
     
    10681076            $custom_css = stripslashes( $options['additional_css'] );
    10691077           
    1070             // Insert newline if there is inline CSS already
     1078            // Insert newline if there is inline CSS already
    10711079            $inline_css = 0 < strlen( $inline_css ) ? $inline_css . "\n" : $inline_css;
    10721080           
     
    10761084        // If there is inline CSS
    10771085        if ( 0 < strlen( $inline_css ) ) {
    1078             // Insert inline CSS
     1086            // Insert inline CSS
    10791087            wp_add_inline_style( 'addtoany', $inline_css );
    10801088        }
     
    10931101
    10941102/**
    1095  * Cache AddToAny
     1103 *
    10961104 */
    10971105
     
    11011109    $upload_dir = wp_upload_dir();
    11021110   
    1103     // Try to create directory if it doesn't already exist
     1111    // Try to create directory if it doesn't already exist
    11041112    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
    11071115        A2A_SHARE_SAVE_revert_cache();
    11081116    }
     
    11101118    if ( count( $file_urls ) > 0 ) {
    11111119        for ( $i = 0; $i < count( $file_urls ); $i++ ) {
    1112             // Download files
     1120            // Download files
    11131121            $file_url = trim( $file_urls[ $i ] );
    11141122            $file_name = substr( strrchr( $file_url, '/' ), 1, 99 );
    11151123           
    1116             // Place files in uploads/addtoany directory
     1124            // Place files in uploads/addtoany directory
    11171125            $response = wp_remote_get( $file_url, array(
    11181126                'filename' => $upload_dir['basedir'] . '/addtoany/' . $file_name,
    1119                 'stream'   => true, // Required to use `filename` arg
     1127                'stream'   => true, // Required to use `filename` arg
    11201128            ) );
    11211129
    1122             // Handle error
     1130            // Handle error
    11231131            if ( is_wp_error( $response ) ) {
    1124                 // Revert cache option
     1132                // Revert cache option
    11251133                A2A_SHARE_SAVE_revert_cache();
    11261134            }
     
    11321140
    11331141function A2A_SHARE_SAVE_schedule_cache() {
    1134     // Unschedule if already scheduled
     1142    // Unschedule if already scheduled
    11351143    A2A_SHARE_SAVE_unschedule_cache();
    11361144
    1137     // Try to schedule daily cache refreshes, running once now
     1145    // Try to schedule daily cache refreshes, running once now
    11381146    $result = wp_schedule_event( time(), 'daily', 'addtoany_refresh_cache' );
    11391147
    1140     // Revert cache option if the event didn't get scheduled
     1148    // Revert cache option if the event didn't get scheduled
    11411149    if ( false === $result ) {
    11421150        A2A_SHARE_SAVE_revert_cache();
     
    11451153
    11461154function A2A_SHARE_SAVE_unschedule_cache() {
    1147     // Unschedule if scheduled
     1155    // Unschedule if scheduled
    11481156    wp_clear_scheduled_hook( 'addtoany_refresh_cache' );
    11491157}
    11501158
    11511159function A2A_SHARE_SAVE_revert_cache() {
    1152     // Unschedule
     1160    // Unschedule
    11531161    A2A_SHARE_SAVE_unschedule_cache();
    11541162
    1155     // Get all existing AddToAny options
     1163    // Get all existing AddToAny options
    11561164    $options = get_option( 'addtoany_options', array() );
    11571165
    1158     // Revert cache option
     1166    // Revert cache option
    11591167    $options['cache'] = '-1';   
    11601168    update_option( 'addtoany_options', $options );
     
    11621170
    11631171/**
    1164  * Activation hook
     1172 * Activation hook
    11651173 */
    11661174
     
    11791187
    11801188/**
    1181  * Deactivation hook
     1189 * Deactivation hook
    11821190 */
    11831191
     
    11901198
    11911199/**
    1192  * Admin Options
     1200 * Admin Options
    11931201 */
    11941202
     
    12191227add_action( 'widgets_init', 'A2A_SHARE_SAVE_widgets_init' );
    12201228
    1221 // Place in Option List on Settings > Plugins page 
     1229// Place in Option List on Settings > Plugins page
    12221230function A2A_SHARE_SAVE_actlinks( $links, $file ) {
    12231231    // Static so we don't call plugin_basename on every plugin row.
     
    12301238    if ( $file == $this_plugin ) {
    12311239        $settings_link = '<a href="options-general.php?page=addtoany">' . __( 'Settings' ) . '</a>';
    1232         array_unshift( $links, $settings_link ); // before other links
     1240        array_unshift( $links, $settings_link ); //
    12331241    }
    12341242   
  • add-to-any/trunk/addtoany.compat.php

    r2174023 r2274521  
    22   
    33/**
    4  * Load theme compatibility functions
     4 * Load theme compatibility functions
    55 */
    66function addtoany_load_theme_compat() {
     
    1111
    1212/**
    13  * Remove from excerpts where buttons could be redundant or awkward
     13 * Remove from excerpts where buttons could be redundant or awkward
    1414 */
    1515function addtoany_excerpt_remove() {
    1616    // If Twenty Sixteen theme
    1717    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"
    1919        if ( is_single() || is_archive() || is_home() ) {
    2020            remove_filter( 'the_excerpt', 'A2A_SHARE_SAVE_add_to_content', 98 );
     
    2424
    2525/**
    26  * Load AMP (Accelerated Mobile Pages) compatibility functions
     26 * Load AMP (Accelerated Mobile Pages) compatibility functions
    2727 */
    2828
     
    3030
    3131function addtoany_amp_additional_css_styles( $amp_template ) {
    32     // CSS only
     32    // CSS only
    3333    ?>
    3434    .addtoany_list a {
     
    5050function addtoany_priority_for_amp_jetpack() {
    5151    // 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
    5353    if ( class_exists( 'AMP_Autoloader' ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'related-posts' ) ) {
    54         // Change priority to 20
     54        // Change priority to 20
    5555        add_filter( 'addtoany_content_priority', function() { return 20; } );
    5656    }
     
    5858
    5959/**
    60  * Move buttons from WooCommerce product description to WooCommerce's sharing block
     60 * Move buttons from WooCommerce product description to WooCommerce's sharing block
    6161 */
    6262add_action( 'woocommerce_share', 'addtoany_woocommerce_share', 10 );
     
    7272   
    7373    if (
    74         // Private post
     74        // Private post
    7575        get_post_status( get_the_ID() ) == 'private' ||
    76         // Sharing disabled on post
     76        // Sharing disabled on post
    7777        ! empty( $sharing_disabled ) ||
    78         // Custom post type (usually "product") disabled
     78        // Custom post type (usually "product") disabled
    7979        ( $post_type && isset( $options['display_in_cpt_' . $post_type] ) && $options['display_in_cpt_' . $post_type] == '-1' )
    8080    ) {
    8181        return;
    8282    } else {
    83         // If a Sharing Header is set
     83        // If a Sharing Header is set
    8484        if ( ! empty( $options['header'] ) ) {
    8585            echo '<div class="addtoany_header">' . stripslashes( $options['header'] ) . '</div>';
     
    8888        }
    8989       
    90         // Display share buttons
     90        // Display share buttons
    9191        ADDTOANY_SHARE_SAVE_KIT();
    9292    }
  • add-to-any/trunk/addtoany.update.php

    r1655520 r2274521  
    22   
    33/**
    4  * Migrate old AddToAny options
     4 * Migrate old AddToAny options
    55 */
    66function addtoany_update_options() {
     
    1717    // If old button enabled
    1818    if ( ! empty( $options_old['button'] ) && in_array( $options_old['button'], $old_buttons) ) {
    19         // Switch to custom button URL
     19        // Switch to custom button URL
    2020        $options_new['button'] = 'CUSTOM';
    2121        $options_new['button_custom'] = 'https://static.addtoany.com/buttons/' . current( explode( '|', $options_old['button'] ) );
  • add-to-any/trunk/addtoany.widgets.php

    r1963900 r2274521  
    1212class A2A_SHARE_SAVE_Widget extends WP_Widget {
    1313   
    14     /** constructor */
     14    /** onstructor */
    1515    function __construct() {
    1616        $widget_ops = array(
     
    3131    }
    3232   
    33     /** Backwards compatibility for A2A_SHARE_SAVE_Widget::display(); usage */
     33    /** Backwards compatibility for A2A_SHARE_SAVE_Widget::display(); usage */
    3434    public function display( $args = false ) {
    3535        self::widget( $args, NULL );
     
    100100class A2A_Follow_Widget extends WP_Widget {
    101101   
    102     /** constructor */
     102    /** onstructor */
    103103    function __construct() {
    104104        $widget_ops = array(
     
    147147        $active_services = array();
    148148       
    149         // See which services have IDs set
     149        // See which services have IDs set
    150150        $services = $this->get_follow_services();
    151151        foreach ( $services as $code => $service ) {
    152152            $code_id = $code . '_id';
    153153            if ( ! empty( $instance[ $code_id ] ) ) {
    154                 // Set ID value
     154                // Set ID value
    155155                $active_services[ $code ] = array( 'id' => $instance[ $code_id ] );
    156156            }
     
    175175        $instance['icon_size'] = sanitize_text_field( $new_instance['icon_size'] );
    176176       
    177         // Accept service IDs
     177        // Accept service IDs
    178178        $services = $this->get_follow_services();
    179179        foreach ( $services as $code => $service ) {
     
    200200            $icon_size = $instance['icon_size'];
    201201        } elseif ( ! empty( $options['icon_size'] ) ) {
    202             // Fallback to standard icon size if saved
     202            // Fallback to standard icon size if saved
    203203            $icon_size = $options['icon_size'];
    204204        } else {
Note: See TracChangeset for help on using the changeset viewer.