Esempio n. 1
0
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_plugin_url_path, $A2A_SHARE_SAVE_services;
    $linkname = isset($args['linkname']) ? $args['linkname'] : FALSE;
    $linkurl = isset($args['linkurl']) ? $args['linkurl'] : FALSE;
    $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl));
    // linkname_enc, etc.
    $defaults = array('linkname' => '', 'linkurl' => '', 'linkname_enc' => '', 'linkurl_enc' => '', 'output_later' => false, 'html_container_open' => '', 'html_container_close' => '', 'html_wrap_open' => '', 'html_wrap_close' => '', 'no_universal_button' => false);
    $args = wp_parse_args($args, $defaults);
    extract($args);
    // Make available services extensible via plugins, themes (functions.php), etc.
    $A2A_SHARE_SAVE_services = apply_filters('A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services);
    $service_codes = is_array($A2A_SHARE_SAVE_services) ? array_keys($A2A_SHARE_SAVE_services) : array();
    // Include Facebook Like and Twitter Tweet etc. unless no_special_services arg is true
    if (!isset($no_special_services) || false == $no_special_services) {
        array_unshift($service_codes, 'facebook_like', 'twitter_tweet', 'google_plusone', 'google_plus_share', 'pinterest_pin');
    }
    $options = get_option('addtoany_options');
    // False if "icon_size" is set to '16' or no_small_icons arg is true
    $large_icons = isset($options['icon_size']) && $options['icon_size'] == '16' && (!isset($no_small_icons) || false == $no_small_icons) ? false : true;
    // 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'];
        $custom_icons = true;
    } else {
        // Packaged 16px icons
        $icons_dir = $A2A_SHARE_SAVE_plugin_url_path . '/icons/';
    }
    // Use default services if services have not been selected yet
    $active_services = isset($options['active_services']) ? $options['active_services'] : array('facebook', 'twitter', 'google_plus');
    $ind_html = "" . $html_container_open;
    foreach ($active_services as $active_service) {
        if (!in_array($active_service, $service_codes)) {
            continue;
        }
        if ($active_service == 'facebook_like' || $active_service == 'twitter_tweet' || $active_service == 'google_plusone' || $active_service == 'google_plus_share' || $active_service == 'pinterest_pin') {
            $special_args = $args;
            $special_args['output_later'] = true;
            $link = ADDTOANY_SHARE_SAVE_SPECIAL($active_service, $special_args);
        } else {
            $service = $A2A_SHARE_SAVE_services[$active_service];
            $safe_name = $active_service;
            $name = $service['name'];
            // If HREF specified, presume custom service (except if it's "print")
            if (isset($service['href']) && $safe_name != 'print') {
                $custom_service = true;
                $href = $service['href'];
                if (isset($service['href_js_esc'])) {
                    $href_linkurl = str_replace("'", "\\'", $linkurl);
                    $href_linkname = str_replace("'", "\\'", $linkname);
                } else {
                    $href_linkurl = $linkurl_enc;
                    $href_linkname = $linkname_enc;
                }
                $href = str_replace("A2A_LINKURL", $href_linkurl, $href);
                $href = str_replace("A2A_LINKNAME", $href_linkname, $href);
                $href = str_replace(" ", "%20", $href);
            } else {
                $custom_service = false;
            }
            // AddToAny counter enabled?
            $counter_enabled = !isset($is_floating) && in_array($active_service, array('facebook', 'twitter', 'pinterest', 'linkedin', '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_url = isset($service['icon_url']) ? $service['icon_url'] : false;
            $icon = isset($service['icon']) ? $service['icon'] : 'default';
            // Just the icon filename
            $width = isset($service['icon_width']) ? $service['icon_width'] : '16';
            $height = isset($service['icon_height']) ? $service['icon_height'] : '16';
            $url = $custom_service ? $href : "http://www.addtoany.com/add_to/" . $safe_name . "?linkurl=" . $linkurl_enc . "&linkname=" . $linkname_enc;
            $src = $icon_url ? $icon_url : $icons_dir . $icon . ".png";
            $counter = $counter_enabled ? ' a2a_counter' : '';
            $class_attr = $custom_service ? '' : ' class="a2a_button_' . $safe_name . $counter . '"';
            // Remove all dimension values if using custom icons
            if (isset($custom_icons)) {
                $width = '';
                $height = '';
            }
            $link = $html_wrap_open . "<a{$class_attr} href=\"{$url}\" title=\"{$name}\" rel=\"nofollow\" target=\"_blank\">";
            $link .= $large_icons && !isset($custom_icons) && !$custom_service ? "" : "<img src=\"{$src}\" width=\"{$width}\" height=\"{$height}\" alt=\"{$name}\"/>";
            $link .= "</a>" . $html_wrap_close;
        }
        $ind_html .= $link;
    }
    $ind_html .= $html_container_close;
    if (isset($output_later) && $output_later == true) {
        return $ind_html;
    } else {
        echo $ind_html;
    }
}
Esempio n. 2
0
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_plugin_url_path, $A2A_SHARE_SAVE_services, $A2A_FOLLOW_services;
    $linkname = isset($args['linkname']) ? $args['linkname'] : FALSE;
    $linkurl = isset($args['linkurl']) ? $args['linkurl'] : FALSE;
    $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl));
    // linkname_enc, etc.
    $defaults = array('linkname' => '', 'linkurl' => '', 'linkname_enc' => '', 'linkurl_enc' => '', 'output_later' => false, 'html_container_open' => '', 'html_container_close' => '', 'html_wrap_open' => '', 'html_wrap_close' => '', 'is_follow' => false, 'no_universal_button' => false, 'buttons' => array());
    $args = wp_parse_args($args, $defaults);
    extract($args);
    $options = get_option('addtoany_options');
    // False if "icon_size" is set to '16' or no_small_icons arg is true
    $large_icons = isset($options['icon_size']) && $options['icon_size'] == '16' && (!isset($no_small_icons) || false == $no_small_icons) ? false : true;
    // 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';
        $custom_icons = true;
    } else {
        // Packaged 16px icons
        $icons_dir = $A2A_SHARE_SAVE_plugin_url_path . '/icons/';
        $icons_type = 'png';
    }
    // If Follow kit
    if ($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($buttons) ? array_keys($buttons) : array();
        // 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($no_special_services) || false == $no_special_services) {
            array_unshift($service_codes, 'facebook_like', 'twitter_tweet', 'google_plusone', 'google_plus_share', 'pinterest_pin');
        }
        // Use default services if services have not been selected yet
        $active_services = isset($options['active_services']) ? $options['active_services'] : array('facebook', 'twitter', 'google_plus');
        // Services set by "buttons" arg? Then use "buttons" arg instead
        $active_services = !empty($buttons) ? $buttons : $active_services;
    }
    $ind_html = "" . $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 == 'google_plusone' || $active_service == 'google_plus_share' || $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];
            $safe_name = $active_service;
            $name = $service['name'];
            // If Follow kit and HREF specified
            if ($is_follow && isset($service['href'])) {
                $follow_id = $buttons[$active_service]['id'];
                if ('feed' == $safe_name) {
                    // For "feed" service, stored ID value is actually the URL
                    $href = $follow_id;
                } else {
                    // For all other services, replace
                    $href = str_replace('${id}', $follow_id, $service['href']);
                }
                $href = 'feed' == $safe_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("'", "\\'", $linkurl);
                    $href_linkname = str_replace("'", "\\'", $linkname);
                } else {
                    $href_linkurl = $linkurl_enc;
                    $href_linkname = $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 = !$is_follow && !isset($is_floating) && in_array($active_service, array('facebook', 'twitter', 'pinterest', 'linkedin', '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_url = isset($service['icon_url']) ? $service['icon_url'] : false;
            $icon = isset($service['icon']) ? $service['icon'] : 'default';
            // Just the icon filename
            $width_attr = isset($service['icon_width']) ? ' width="' . $service['icon_width'] . '"' : ' width="16"';
            $height_attr = isset($service['icon_height']) ? ' height="' . $service['icon_height'] . '"' : ' height="16"';
            $url = isset($href) ? $href : "http://www.addtoany.com/add_to/" . $safe_name . "?linkurl=" . $linkurl_enc . "&amp;linkname=" . $linkname_enc;
            $src = $icon_url ? $icon_url : $icons_dir . $icon . '.' . $icons_type;
            $counter = $counter_enabled ? ' a2a_counter' : '';
            $class_attr = $custom_service ? '' : ' class="a2a_button_' . $safe_name . $counter . '"';
            $rel_nofollow = $is_follow ? '' : ' rel="nofollow"';
            // ($is_follow indicates a Follow Kit. 'nofollow' is for search crawlers. Different things)
            // Remove dimension attributes if using custom icons
            if (isset($custom_icons)) {
                $width_attr = '';
                $height_attr = '';
            }
            $link = $html_wrap_open . "<a{$class_attr} href=\"{$url}\" title=\"{$name}\"{$rel_nofollow} target=\"_blank\">";
            $link .= $large_icons && !isset($custom_icons) && !$custom_service ? "" : "<img src=\"{$src}\"" . $width_attr . $height_attr . " alt=\"{$name}\"/>";
            $link .= "</a>" . $html_wrap_close;
        }
        $ind_html .= $link;
    }
    $ind_html .= $html_container_close;
    if (isset($output_later) && $output_later == true) {
        return $ind_html;
    } else {
        echo $ind_html;
    }
}
Esempio n. 3
0
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_plugin_url_path, $A2A_SHARE_SAVE_services;
    $linkname = isset($args['linkname']) ? $args['linkname'] : FALSE;
    $linkurl = isset($args['linkurl']) ? $args['linkurl'] : FALSE;
    $args = array_merge($args, A2A_SHARE_SAVE_link_vars($linkname, $linkurl));
    // linkname_enc, etc.
    $defaults = array('linkname' => '', 'linkurl' => '', 'linkname_enc' => '', 'linkurl_enc' => '', 'output_later' => FALSE, 'html_container_open' => '', 'html_container_close' => '', 'html_wrap_open' => '', 'html_wrap_close' => '');
    $args = wp_parse_args($args, $defaults);
    extract($args);
    // Make available services extensible via plugins, themes (functions.php), etc.
    $A2A_SHARE_SAVE_services = apply_filters('A2A_SHARE_SAVE_services', $A2A_SHARE_SAVE_services);
    $service_codes = array_keys($A2A_SHARE_SAVE_services);
    // Include Facebook Like and Twitter Tweet
    array_unshift($service_codes, 'facebook_like', 'twitter_tweet', 'google_plusone');
    $options = get_option('addtoany_options');
    $active_services = $options['active_services'];
    $ind_html = "" . $html_container_open;
    if (!$active_services) {
        $active_services = array();
    }
    foreach ($active_services as $active_service) {
        if (!in_array($active_service, $service_codes)) {
            continue;
        }
        if ($active_service == 'facebook_like' || $active_service == 'twitter_tweet' || $active_service == 'google_plusone') {
            $link = ADDTOANY_SHARE_SAVE_SPECIAL($active_service, $args);
        } else {
            $service = $A2A_SHARE_SAVE_services[$active_service];
            $safe_name = $active_service;
            $name = $service['name'];
            if (isset($service['href'])) {
                $custom_service = TRUE;
                $href = $service['href'];
                if (isset($service['href_js_esc'])) {
                    $href_linkurl = str_replace("'", "\\'", $linkurl);
                    $href_linkname = str_replace("'", "\\'", $linkname);
                } else {
                    $href_linkurl = $linkurl_enc;
                    $href_linkname = $linkname_enc;
                }
                $href = str_replace("A2A_LINKURL", $href_linkurl, $href);
                $href = str_replace("A2A_LINKNAME", $href_linkname, $href);
                $href = str_replace(" ", "%20", $href);
            } else {
                $custom_service = FALSE;
            }
            $icon_url = isset($service['icon_url']) ? $service['icon_url'] : FALSE;
            $icon = isset($service['icon']) ? $service['icon'] : 'default';
            // Just the icon filename
            $width = isset($service['icon_width']) ? $service['icon_width'] : '16';
            $height = isset($service['icon_height']) ? $service['icon_height'] : '16';
            $url = $custom_service ? $href : "http://www.addtoany.com/add_to/" . $safe_name . "?linkurl=" . $linkurl_enc . "&amp;linkname=" . $linkname_enc;
            $src = $icon_url ? $icon_url : $A2A_SHARE_SAVE_plugin_url_path . "/icons/" . $icon . ".png";
            $class_attr = $custom_service ? "" : " class=\"a2a_button_{$safe_name}\"";
            $link = $html_wrap_open . "<a{$class_attr} href=\"{$url}\" title=\"{$name}\" rel=\"nofollow\" target=\"_blank\">";
            $link .= "<img src=\"{$src}\" width=\"{$width}\" height=\"{$height}\" alt=\"{$name}\"/>";
            $link .= "</a>" . $html_wrap_close;
        }
        $ind_html .= $link;
    }
    $ind_html .= $html_container_close;
    if ($output_later) {
        return $ind_html;
    } else {
        echo $ind_html;
    }
}