Example #1
0
function ADDTOANY_SHARE_SAVE_SPECIAL($special_service_code, $args = array())
{
    // $args array = output_later, linkname, linkurl
    $options = get_option('addtoany_options');
    $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.
    extract($args);
    $http_or_https = is_ssl() ? 'https' : 'http';
    $iframe_template_begin = '<iframe';
    $iframe_template_end = ' class="addtoany_special_service %1$s" src="%2$s" scrolling="no" style="border:none;overflow:hidden;width:%3$dpx;height:%4$dpx"></iframe>';
    $iframe_template = $iframe_template_begin . $iframe_template_end;
    // IE ridiculousness to support transparent iframes while maintaining W3C validity
    $iframe_template = '<!--[if IE]>' . $iframe_template_begin . ' frameborder="0" allowTransparency="true"' . $iframe_template_end . '<![endif]--><!--[if !IE]><!-->' . $iframe_template . '<!--<![endif]-->';
    if ($special_service_code == 'facebook_like') {
        if ($options['special_facebook_like_options']['verb'] == 'recommend') {
            $action_param_value = 'recommend';
        } else {
            $action_param_value = 'like';
        }
        $special_html = sprintf($iframe_template, $special_service_code, $http_or_https . '://www.facebook.com/plugins/like.php?href=' . $linkurl_enc . '&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=' . $action_param_value . '&amp;colorscheme=light&amp;height=20&amp;ref=addtoany', 90, 21);
    } elseif ($special_service_code == 'twitter_tweet') {
        if ($options['special_twitter_tweet_options']['show_count'] == '1') {
            $count_param_value = 'horizontal';
            $width = 130;
        } else {
            $count_param_value = 'none';
            $width = 55;
        }
        $special_html = sprintf($iframe_template, $special_service_code, $http_or_https . '://platform.twitter.com/widgets/tweet_button.html?url=' . $linkurl_enc . '&amp;counturl=' . $linkurl_enc . '&amp;count=' . $count_param_value . '&amp;text=' . $linkname_enc, $width, 20);
    } elseif ($special_service_code == 'google_plusone') {
        if ($options['special_google_plusone_options']['show_count'] == '1') {
            $count_param_value = 'true';
            $width = 90;
        } else {
            $count_param_value = 'false';
            $width = 32;
        }
        $special_html = sprintf($iframe_template, $special_service_code, 'https://plusone.google.com/u/0/_/%2B1/fastbutton?url=' . $linkurl_enc . '&amp;size=medium&amp;count=' . $count_param_value, $width, 20);
    }
    if ($output_later) {
        return $special_html;
    } else {
        echo $special_html;
    }
}
Example #2
0
function ADDTOANY_SHARE_SAVE_SPECIAL($special_service_code, $args = array())
{
    // $args array = output_later, linkname, linkurl
    if (is_feed()) {
        return;
    }
    $options = get_option('addtoany_options');
    $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.
    extract($args);
    $special_anchor_template = '<a class="a2a_button_%1$s addtoany_special_service"%2$s></a>';
    $custom_attributes = '';
    if ($special_service_code == 'facebook_like') {
        $custom_attributes .= $options['special_facebook_like_options']['verb'] == 'recommend' ? ' data-action="recommend"' : '';
        $custom_attributes .= ' data-href="' . $linkurl . '"';
        $special_html = sprintf($special_anchor_template, $special_service_code, $custom_attributes);
    } elseif ($special_service_code == 'twitter_tweet') {
        $custom_attributes .= $options['special_twitter_tweet_options']['show_count'] == '1' ? ' data-count="horizontal"' : ' data-count="none"';
        $custom_attributes .= ' data-url="' . $linkurl . '"';
        $custom_attributes .= ' data-text="' . $linkname . '"';
        $special_html = sprintf($special_anchor_template, $special_service_code, $custom_attributes);
    } elseif ($special_service_code == 'google_plusone') {
        $custom_attributes .= $options['special_google_plusone_options']['show_count'] == '1' ? '' : ' data-annotation="none"';
        $custom_attributes .= ' data-href="' . $linkurl . '"';
        $special_html = sprintf($special_anchor_template, $special_service_code, $custom_attributes);
    } elseif ($special_service_code == 'google_plus_share') {
        $custom_attributes .= $options['special_google_plus_share_options']['show_count'] == '1' ? '' : ' data-annotation="none"';
        $custom_attributes .= ' data-href="' . $linkurl . '"';
        $special_html = sprintf($special_anchor_template, $special_service_code, $custom_attributes);
    } elseif ($special_service_code == 'pinterest_pin') {
        $custom_attributes .= $options['special_pinterest_pin_options']['show_count'] == '1' ? '' : ' data-pin-config="none"';
        $custom_attributes .= ' data-url="' . $linkurl . '"';
        $special_html = sprintf($special_anchor_template, $special_service_code, $custom_attributes);
    }
    if (isset($output_later) && $output_later == true) {
        return $special_html;
    } else {
        echo $special_html;
    }
}
Example #3
0
function ADDTOANY_SHARE_SAVE_BUTTON($args = false)
{
    global $A2A_SHARE_SAVE_plugin_url_path, $A2A_SHARE_SAVE_services;
    if ($args) {
        extract($args);
    }
    // output_later, html_wrap_open, html_wrap_close
    extract(A2A_SHARE_SAVE_link_vars());
    // linkname_enc, etc.
    /* Add to Any button */
    $button_target = get_option('A2A_SHARE_SAVE_button_opens_new_window') == '1' && get_option('A2A_SHARE_SAVE_onclick') != '1' ? ' target="_blank"' : '';
    if (!get_option('A2A_SHARE_SAVE_button')) {
        $button_fname = 'share_save_171_16.png';
        $button_width = ' width="171"';
        $button_height = ' height="16"';
        $button_src = $A2A_SHARE_SAVE_plugin_url_path . '/' . $button_fname;
    } else {
        if (get_option('A2A_SHARE_SAVE_button') == 'CUSTOM') {
            $button_src = get_option('A2A_SHARE_SAVE_button_custom');
            $button_width = '';
            $button_height = '';
        } else {
            if (get_option('A2A_SHARE_SAVE_button') == 'TEXT') {
                $button_text = stripslashes(get_option('A2A_SHARE_SAVE_button_text'));
            } else {
                $button_attrs = explode('|', get_option('A2A_SHARE_SAVE_button'));
                $button_fname = $button_attrs[0];
                $button_width = ' width="' . $button_attrs[1] . '"';
                $button_height = ' height="' . $button_attrs[2] . '"';
                $button_src = $A2A_SHARE_SAVE_plugin_url_path . '/' . $button_fname;
                $button_text = stripslashes(get_option('A2A_SHARE_SAVE_button_text'));
            }
        }
    }
    if ($button_fname == 'favicon.png' || $button_fname == 'share_16_16.png') {
        if (!is_feed()) {
            $style_bg = 'background:url(' . $A2A_SHARE_SAVE_plugin_url_path . '/' . $button_fname . ') no-repeat scroll 9px 0px';
            // padding-left:9 (9=other icons padding)
            $style_bg = ';' . $style_bg . ' !important;';
            $style = ' style="' . $style_bg . 'padding:0 0 0 30px;display:inline-block;height:16px;line-height:16px;vertical-align:middle;"';
            // padding-left:30+9 (9=other icons padding)
        }
    }
    if ($button_text && (!$button_fname || $button_fname == 'favicon.png' || $button_fname == 'share_16_16.png')) {
        $button = $button_text;
    } else {
        $style = '';
        $button = '<img src="' . $button_src . '"' . $button_width . $button_height . ' alt="Share/Bookmark"/>';
    }
    $button_html = $html_wrap_open . '<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?' . 'linkurl=' . $linkurl_enc . '&amp;linkname=' . $linkname_enc . '"' . $style . $button_target . '>' . $button . '</a>' . $html_wrap_close;
    // If not a feed
    if (!is_feed()) {
        global $A2A_javascript, $A2A_SHARE_SAVE_external_script_called;
        if ($A2A_javascript == '' || !$A2A_SHARE_SAVE_external_script_called) {
            $external_script_call = '</script><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>';
            $A2A_SHARE_SAVE_external_script_called = true;
        } else {
            $external_script_call = 'a2a_init("page");</script>';
        }
        $A2A_javascript .= '<script type="text/javascript">' . "\n" . A2A_menu_locale() . 'a2a_linkname="' . js_escape($linkname) . '";' . "\n" . 'a2a_linkurl="' . $linkurl . '";' . "\n" . (get_option('A2A_SHARE_SAVE_onclick') == '1' ? 'a2a_onclick=1;' . "\n" : '') . (get_option('A2A_SHARE_SAVE_hide_embeds') == '-1' ? 'a2a_hide_embeds=0;' . "\n" : '') . (get_option('A2A_SHARE_SAVE_show_title') == '1' ? 'a2a_show_title=1;' . "\n" : '') . ($A2A_javascript == '' || !$A2A_SHARE_SAVE_external_script_called ? stripslashes(get_option('A2A_SHARE_SAVE_additional_js_variables')) . "\n" : '') . $external_script_call . "\n\n";
        remove_action('wp_footer', 'A2A_menu_javascript');
        add_action('wp_footer', 'A2A_menu_javascript');
    }
    if ($output_later) {
        return $button_html;
    } else {
        echo $button_html;
    }
}