Enable Widget | Settings] Version: .9.10.0 Author: AddToAny Author URI: https://www.addtoany.com/ */ // Explicitly globalize to support bootstrapped WordPress global $A2A_locale, $A2A_SUBSCRIBE_plugin_url_path, $A2A_SUBSCRIBE_plugin_basename, $A2A_SUBSCRIBE_external_script_called; if ( ! isset( $A2A_locale ) ) $A2A_locale = ''; // WordPress MU? if ( basename( dirname(__FILE__) ) == 'mu-plugins' ) $A2A_wpmu = true; else $A2A_wpmu = false; // Pre-2.6 compatibility if ( ! defined('WP_CONTENT_URL') ) define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content'); if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); $A2A_SUBSCRIBE_plugin_basename = plugin_basename( dirname( __FILE__ ) ); if ( $A2A_wpmu ) $A2A_SUBSCRIBE_plugin_url_path = WPMU_PLUGIN_URL.'/add-to-any-subscribe'; else $A2A_SUBSCRIBE_plugin_url_path = WP_PLUGIN_URL . '/' . $A2A_SUBSCRIBE_plugin_basename; // /wp-content/plugins/add-to-any-subscribe // Fix SSL if ( function_exists( 'is_ssl' ) && is_ssl() ) // @since 2.6.0 $A2A_SUBSCRIBE_plugin_url_path = str_replace( 'http:', 'https:', $A2A_SUBSCRIBE_plugin_url_path ); function A2A_SUBSCRIBE_textdomain() { global $A2A_SUBSCRIBE_plugin_url_path, $A2A_SUBSCRIBE_plugin_basename; load_plugin_textdomain( 'add-to-any-subscribe', $A2A_SUBSCRIBE_plugin_url_path . '/languages', $A2A_SUBSCRIBE_plugin_basename . '/languages' ); } add_action( 'init', 'A2A_SUBSCRIBE_textdomain' ); class Add_to_Any_Subscribe_Widget extends WP_Widget { /** constructor */ function __construct() { $widget_ops = array( 'description' => 'Subscribe button to help people subscribe to your blog using any service.' ); parent::__construct( '', 'AddToAny Subscribe', $widget_ops ); } /** Backwards compatibility for Add_to_Any_Subscribe_Widget::display(); usage */ function display( $args = false ) { self::widget( $args, null ); } /** * @param array $args * @param array $instance */ 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 = 'Subscribe'; } echo $before_widget; if ( trim(get_option('A2A_SUBSCRIBE_widget_title')) != "" ) { echo $before_title . stripslashes(get_option('A2A_SUBSCRIBE_widget_title')) . $after_title; } ?> > \n" . 'var a2a_config = a2a_config || {};' . "\n" . get_option( 'A2A_SUBSCRIBE_additional_js_variables' ) . A2A_menu_locale() . ( ( get_option( 'A2A_SUBSCRIBE_onclick' ) == '1' ) ? 'a2a_config.onclick=1;' . "\n" : '' ) . ( ( $additional_js ) ? stripslashes( $additional_js ) . "\n" : '' ) . "\n" . '\n"; echo $A2A_SUBSCRIBE_external_script_called ? '' : $button_javascript; $A2A_SUBSCRIBE_external_script_called = true; echo $after_widget; } /** * @param array $instance */ function form( $instance ) { A2A_SUBSCRIBE_options_widget(); } } // register AddToAny Subscribe widget add_action('widgets_init', create_function('', 'return register_widget("Add_to_Any_Subscribe_Widget");')); if (!function_exists('A2A_menu_locale')) { function A2A_menu_locale() { global $A2A_locale; $locale = get_locale(); if ($locale == 'en_US' || $locale == 'en' || $A2A_locale != '' ) return false; $A2A_locale = 'a2a_localize = { Share: "' . __("Share", "add-to-any") . '", Save: "' . __("Save", "add-to-any") . '", Subscribe: "' . __("Subscribe", "add-to-any") . '", Email: "' . __("E-mail") . '", Bookmark: "' . __("Bookmark") . '", ShowAll: "' . __("Show all", "add-to-any") . '", ShowLess: "' . __("Show less", "add-to-any") . '", FindServices: "' . __("Find service(s)", "add-to-any") . '", FindAnyServiceToAddTo: "' . __("Instantly find any service to add to", "add-to-any") . '", PoweredBy: "' . __("Powered by", "add-to-any") . '", ShareViaEmail: "' . __("Share via e-mail", "add-to-any") . '", SubscribeViaEmail: "' . __("Subscribe via e-mail", "add-to-any") . '", BookmarkInYourBrowser: "' . __("Bookmark in your browser", "add-to-any") . '", BookmarkInstructions: "' . __("Press Ctrl+D or Cmd+D to bookmark this page", "add-to-any") . '", AddToYourFavorites: "' . __("Add to your favorites", "add-to-any") . '", SendFromWebOrProgram: "' . __("Send from any e-mail address or e-mail program") . '", EmailProgram: "' . __("E-mail program") . '" }; '; return $A2A_locale; } } function A2A_SUBSCRIBE_button_css() { ?> Widgets ) *************************************************/ // This function outputs the options control panel under the admin screen. function A2A_SUBSCRIBE_options_widget() { global $A2A_SUBSCRIBE_plugin_url_path; if ( isset($_POST['A2A_SUBSCRIBE_submit_hidden']) ) { update_option( 'A2A_SUBSCRIBE_button', $_POST['A2A_SUBSCRIBE_button'] ); update_option( 'A2A_SUBSCRIBE_button_custom', $_POST['A2A_SUBSCRIBE_button_custom'] ); update_option( 'A2A_SUBSCRIBE_widget_title', $_POST['A2A_SUBSCRIBE_widget_title'] ); // Store desired text if 16 x 16px button or text-only is chosen: if ( get_option('A2A_SUBSCRIBE_button') == 'subscribe_16_16.png|16|16' ) update_option( 'A2A_SUBSCRIBE_button_text', $_POST['A2A_SUBSCRIBE_button_subscribe_16_16_text'] ); else update_option( 'A2A_SUBSCRIBE_button_text', ( trim($_POST['A2A_SUBSCRIBE_button_text']) != '' ) ? $_POST['A2A_SUBSCRIBE_button_text'] : "Subscribe" ); } // Which is checked $subscribe_16_16 = ( get_option('A2A_SUBSCRIBE_button')=='subscribe_16_16.png|16|16' ) ? ' checked="checked" ' : ' '; $subscribe_120_16 = ( !get_option('A2A_SUBSCRIBE_button') || get_option('A2A_SUBSCRIBE_button')=='subscribe_120_16.png|120|16' ) ? ' checked="checked" ' : ' '; $subscribe_171_16 = ( get_option('A2A_SUBSCRIBE_button')=='subscribe_171_16.png|171|16' ) ? ' checked="checked" ' : ' '; $subscribe_256_24 = ( get_option('A2A_SUBSCRIBE_button')=='subscribe_256_24.png|256|24' ) ? ' checked="checked" ' : ' '; $subscribe_custom = ( get_option('A2A_SUBSCRIBE_button')=='CUSTOM' ) ? ' checked="checked" ' : ' '; $subscribe_text = ( get_option('A2A_SUBSCRIBE_button')=='TEXT' ) ? ' checked="checked" ' : ' '; ?>

" />

...

Subscribe Button ) *************************************************/ function A2A_SUBSCRIBE_options_page() { global $A2A_SUBSCRIBE_plugin_url_path; if ( isset( $_POST['Submit'] ) ) { // Nonce verification check_admin_referer('add-to-any-subscribe-update-options'); update_option( 'A2A_SUBSCRIBE_onclick', ($_POST['A2A_SUBSCRIBE_onclick']=='1') ? '1':'-1' ); update_option( 'A2A_SUBSCRIBE_button_opens_new_window', ($_POST['A2A_SUBSCRIBE_button_opens_new_window']=='1') ? '1':'-1' ); update_option( 'A2A_SUBSCRIBE_button', $_POST['A2A_SUBSCRIBE_button'] ); update_option( 'A2A_SUBSCRIBE_button_custom', $_POST['A2A_SUBSCRIBE_button_custom'] ); update_option( 'A2A_SUBSCRIBE_additional_js_variables', trim($_POST['A2A_SUBSCRIBE_additional_js_variables']) ); // Store desired text if 16 x 16px button or text-only is chosen: if ( get_option('A2A_SUBSCRIBE_button') == 'subscribe_16_16.png|16|16' ) update_option( 'A2A_SUBSCRIBE_button_text', $_POST['A2A_SUBSCRIBE_button_subscribe_16_16_text'] ); else update_option( 'A2A_SUBSCRIBE_button_text', ( trim($_POST['A2A_SUBSCRIBE_button_text']) != '' ) ? $_POST['A2A_SUBSCRIBE_button_text'] : "Subscribe" ); ?>

" />




" />

widgets page to place the button where you want in your sidebar.", "add-to-any-subscribe"); ?>

your template pages (within sidebar.php, index.php, single.php, and/or page.php)", "add-to-any-subscribe"); ?>:
<?php if ( class_exists( 'Add_to_Any_Subscribe_Widget' ) ) { Add_to_Any_Subscribe_Widget::display(); } ?>

Additional Options box below.", "add-to-any-subscribe"); ?>

" target="_blank" onclick="document.getElementById('A2A_SUBSCRIBE_additional_js_variables').focus(); document.getElementById('A2A_SUBSCRIBE_menu_styler_note').style.display='';">


' . __('Settings') . ''; $widgets_link = '' . __('Widgets') . ''; array_unshift( $links, $settings_link, $widgets_link ); // before other links } return $links; } add_filter("plugin_action_links", 'A2A_SUBSCRIBE_actlinks', 10, 2);