Ejemplo n.º 1
0
    /** @see WP_Widget::widget */
    function widget($args = array(), $instance)
    {
        global $A2A_SUBSCRIBE_plugin_url_path;
        $defaults = array('feedname' => get_bloginfo('name'), 'feedname_enc' => '', 'feedurl' => get_bloginfo('rss2_url'), '$feedurl_enc' => '', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '');
        $args = wp_parse_args($args, $defaults);
        extract($args);
        $feedname = $feedname == '' ? 'Blog' : $feedname;
        // Blog name cannot be blank for A2A
        $feedname_enc = rawurlencode($feedname);
        $feedurl_enc = rawurlencode($feedurl);
        $style = '';
        $button_target = get_option('A2A_SUBSCRIBE_button_opens_new_window') == '1' && get_option('A2A_SUBSCRIBE_onclick') != '1' ? ' target="_blank"' : '';
        if (!get_option('A2A_SUBSCRIBE_button')) {
            $button_fname = 'subscribe_120_16.png';
            $button_width = ' width="120"';
            $button_height = ' height="16"';
            $button_src = $A2A_SUBSCRIBE_plugin_url_path . '/' . $button_fname;
        } else {
            if (get_option('A2A_SUBSCRIBE_button') == 'CUSTOM') {
                $button_src = get_option('A2A_SUBSCRIBE_button_custom');
                $button_width = '';
                $button_height = '';
            } else {
                if (get_option('A2A_SUBSCRIBE_button') == 'TEXT') {
                    $button_text = stripslashes(get_option('A2A_SUBSCRIBE_button_text'));
                } else {
                    $button_attrs = explode('|', get_option('A2A_SUBSCRIBE_button'));
                    $button_fname = $button_attrs[0];
                    $button_width = ' width="' . $button_attrs[1] . '"';
                    $button_height = ' height="' . $button_attrs[2] . '"';
                    $button_src = $A2A_SUBSCRIBE_plugin_url_path . '/' . $button_fname;
                    $button_text = stripslashes(get_option('A2A_SUBSCRIBE_button_text'));
                }
            }
        }
        if (isset($button_fname) && $button_fname == 'subscribe_16_16.png') {
            if (!is_feed()) {
                $style_bg = 'background:url(' . $A2A_SUBSCRIBE_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 (isset($button_text) && (!isset($button_fname) || $button_fname == 'subscribe_16_16.png')) {
            $button = $button_text;
        } else {
            $style = '';
            $button = '<img src="' . $button_src . '"' . $button_width . $button_height . ' alt="Subscribe"/>';
        }
        echo $before_widget;
        if (trim(get_option('A2A_SUBSCRIBE_widget_title')) != "") {
            echo $before_title . stripslashes(get_option('A2A_SUBSCRIBE_widget_title')) . $after_title;
        }
        ?>


		<a class="a2a_dd addtoany_subscribe" href="http://www.addtoany.com/subscribe?linkname=<?php 
        echo $feedname_enc;
        ?>
&amp;linkurl=<?php 
        echo $feedurl_enc;
        ?>
"<?php 
        echo $style . $button_target;
        ?>
><?php 
        echo $button;
        ?>
</a>
		<?php 
        if (function_exists('is_ssl')) {
            // @since 2.6.0
            $http_or_https = is_ssl() ? 'https' : 'http';
        } else {
            $http_or_https = 'http';
        }
        global $A2A_SUBSCRIBE_external_script_called;
        if (!$A2A_SUBSCRIBE_external_script_called) {
            // Enternal script call + initial JS + set-once variables
            $initial_js = 'var a2a_config = a2a_config || {};' . "\n";
            $additional_js = get_option('A2A_SUBSCRIBE_additional_js_variables');
            $external_script_call = (get_option('A2A_SUBSCRIBE_onclick') == '1' ? 'a2a_config.onclick=1;' . "\n" : '') . (get_option('A2A_SUBSCRIBE_show_title') == '1' ? 'a2a_config.show_title=1;' . "\n" : '') . ($additional_js ? stripslashes($additional_js) . "\n" : '') . "//]]>" . '</script><script type="text/javascript" src="' . $http_or_https . '://static.addtoany.com/menu/feed.js"></script>';
            $A2A_SUBSCRIBE_external_script_called = true;
        } else {
            $external_script_call = 'a2a.init("feed");\\n//]]></script>';
            $initial_js = '';
        }
        $button_javascript = "\n" . '<script type="text/javascript">' . "//<![CDATA[\n" . $initial_js . A2A_menu_locale() . 'a2a_config.linkname="' . esc_js($feedname) . '";' . "\n" . 'a2a_config.linkurl="' . $feedurl . '";' . "\n" . $external_script_call . "\n\n";
        echo $button_javascript;
        echo $after_widget;
    }
Ejemplo n.º 2
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;
    }
}
Ejemplo n.º 3
0
function A2A_SHARE_SAVE_head_script()
{
    // Hook to disable script output
    // Example: add_filter( 'addtoany_script_disabled', '__return_true' );
    $script_disabled = apply_filters('addtoany_script_disabled', false);
    if (is_admin() || is_feed() || $script_disabled) {
        return;
    }
    $options = get_option('addtoany_options');
    $http_or_https = is_ssl() ? 'https' : 'http';
    global $A2A_SHARE_SAVE_external_script_called;
    if (!$A2A_SHARE_SAVE_external_script_called) {
        // Use local cache?
        $cache = isset($options['cache']) && '1' == $options['cache'] ? true : false;
        $upload_dir = wp_upload_dir();
        $static_server = $cache ? $upload_dir['baseurl'] . '/addtoany' : $http_or_https . '://static.addtoany.com/menu';
        // Enternal script call + initial JS + set-once variables
        $additional_js = isset($options['additional_js_variables']) ? $options['additional_js_variables'] : '';
        $script_configs = ($cache ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '') . (isset($options['onclick']) && '1' == $options['onclick'] ? "\n" . 'a2a_config.onclick=1;' : '') . (isset($options['show_title']) && '1' == $options['show_title'] ? "\n" . 'a2a_config.show_title=1;' : '') . ($additional_js ? "\n" . stripslashes($additional_js) : '');
        $A2A_SHARE_SAVE_external_script_called = true;
    } else {
        $script_configs = "";
    }
    $javascript_header = "\n" . '<script type="text/javascript">' . "<!--\n" . "var a2a_config=a2a_config||{}," . "wpa2a={done:false," . "html_done:false," . "script_ready:false," . "script_load:function(){" . "var a=document.createElement('script')," . "s=document.getElementsByTagName('script')[0];" . "a.type='text/javascript';a.async=true;" . "a.src='" . $static_server . "/page.js';" . "s.parentNode.insertBefore(a,s);" . "wpa2a.script_load=function(){};" . "}," . "script_onready:function(){" . "wpa2a.script_ready=true;" . "if(wpa2a.html_done)wpa2a.init();" . "}," . "init:function(){" . "for(var i=0,el,target,targets=wpa2a.targets,length=targets.length;i<length;i++){" . "el=document.getElementById('wpa2a_'+(i+1));" . "target=targets[i];" . "a2a_config.linkname=target.title;" . "a2a_config.linkurl=target.url;" . "if(el){" . "a2a.init('page',{target:el});" . "el.id='';" . "}" . "wpa2a.done=true;" . "}" . "wpa2a.targets=[];" . "}" . "};" . "a2a_config.callbacks=a2a_config.callbacks||[];" . "a2a_config.callbacks.push({ready:wpa2a.script_onready});" . A2A_menu_locale() . $script_configs . "\n//--></script>\n";
    echo $javascript_header;
}
Ejemplo n.º 4
0
function A2A_SHARE_SAVE_head_script()
{
    // Hook to disable script output
    // Example: add_filter( 'addtoany_script_disabled', '__return_true' );
    $script_disabled = apply_filters('addtoany_script_disabled', false);
    if (is_admin() || is_feed() || $script_disabled) {
        return;
    }
    $options = get_option('addtoany_options');
    $https_or_http = is_ssl() ? 'https' : 'http';
    // Use local cache?
    $cache = isset($options['cache']) && '1' == $options['cache'] ? true : false;
    $upload_dir = wp_upload_dir();
    $static_server = $cache ? $upload_dir['baseurl'] . '/addtoany' : $https_or_http . '://static.addtoany.com/menu';
    // Enternal script call + initial JS + set-once variables
    $additional_js = isset($options['additional_js_variables']) ? $options['additional_js_variables'] : '';
    $script_configs = ($cache ? "\n" . 'a2a_config.static_server="' . $static_server . '";' : '') . (isset($options['onclick']) && '1' == $options['onclick'] ? "\n" . 'a2a_config.onclick=1;' : '') . ($additional_js ? "\n" . stripslashes($additional_js) : '');
    $A2A_SHARE_SAVE_external_script_called = true;
    $javascript_header = "\n" . '<script type="text/javascript">' . "\n" . "var a2a_config=a2a_config||{};" . "a2a_config.callbacks=a2a_config.callbacks||[];" . "a2a_config.templates=a2a_config.templates||{};" . A2A_menu_locale() . $script_configs . "\n</script>\n" . '<script type="text/javascript" src="' . $static_server . '/page.js" async="async"></script>' . "\n";
    echo $javascript_header;
}