'Afrikaaner', 'ar'=>'Arabic', 'zh'=>'Chinese', 'cs'=>'Czech', 'da'=>'Danish', 'nl'=>'Dutch', 'en'=>'English', 'fa'=>'Farsi', 'fi'=>'Finnish', 'fr'=>'French', 'ga'=>'Gaelic', 'de'=>'German', 'el'=>'Greek', 'he'=>'Hebrew', 'hi'=>'Hindi', 'it'=>'Italian', 'ja'=>'Japanese', 'ko'=>'Korean', 'lv'=>'Latvian', 'lt'=>'Lithuanian', 'no'=>'Norwegian', 'pl'=>'Polish', 'pt'=>'Portugese', 'ro'=>'Romanian', 'ru'=>'Russian', 'sk'=>'Slovakian', 'sl'=>'Slovenian', 'es'=>'Spanish', 'sv'=>'Swedish', 'th'=>'Thai', 'ur'=>'Urdu', 'cy'=>'Welsh', 'vi'=>'Vietnamese'); $addthis_menu_types = array('static', 'dropdown', 'toolbox'); $addthis_styles = array( 'share' => array('img'=>'lg-share-%lang%.gif', 'w'=>125, 'h'=>16), 'bookmark' => array('img'=>'lg-bookmark-en.gif', 'w'=>125, 'h'=>16), 'addthis' => array('img'=>'lg-addthis-en.gif', 'w'=>125, 'h'=>16), 'share-small' => array('img'=>'sm-share-%lang%.gif', 'w'=>83, 'h'=>16), 'bookmark-small' => array('img'=>'sm-bookmark-en.gif', 'w'=>83, 'h'=>16), 'plus' => array('img'=>'sm-plus.gif', 'w'=>16, 'h'=>16) /* Add your own style here, like this: , 'custom' => array('img'=>'http://example.com/button.gif', 'w'=>16, 'h'=>16) */ ); // Pre-2.6 compatibility if ( ! defined( 'WP_CONTENT_URL' ) ) define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); if ( ! defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); if ( ! defined( 'WP_PLUGIN_DIR' ) ) define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); /** * Generates unique IDs */ function cuid() { $mt = dechex(mt_rand(0,min(0xffffffff,mt_getrandmax()))); $now = dechex(time()); $cuid = $now . str_pad($mt, 8, '0', STR_PAD_LEFT); return $cuid; } /** * Returns major.minor WordPress version. */ function get_wp_version() { return (float)substr(get_bloginfo('version'),0,3); } /** * Adds AddThis CSS to page. Only used for admin dashboard in WP 2.7 and higher. */ function addthis_print_style() { wp_enqueue_style( 'addthis' ); } /** * Adds AddThis script to page. Only used for admin dashboard in WP 2.7 and higher. */ function addthis_print_script() { wp_enqueue_script( 'addthis' ); } /** * Our admin dashboard widget shows yesterday's top shared content and top shared-to services. * Data is fetched via AJAX. We assume jQuery is available on any WP install supporting * dashboard widgets. * * @see js/addthis.js * @see js/addthis.css */ function addthis_render_dashboard_widget() { global $addthis_settings; $username = urlencode($addthis_settings['username']); $password = urlencode($addthis_settings['password']); echo <<Loading...

ENDHTML; } /** * Initialize the dashboard widget. */ function addthis_dashboard_init() { wp_add_dashboard_widget('dashboard_addthis', 'AddThis', 'addthis_render_dashboard_widget'); } /** * Formally registers AddThis settings. Only called in WP 2.7+. */ function register_addthis_settings() { register_setting('addthis', 'addthis_username'); register_setting('addthis', 'addthis_fallback_username'); register_setting('addthis', 'addthis_password'); register_setting('addthis', 'addthis_show_stats'); register_setting('addthis', 'addthis_style'); register_setting('addthis', 'addthis_sidebar_only'); register_setting('addthis', 'addthis_isdropdown'); register_setting('addthis', 'addthis_menu_type'); register_setting('addthis', 'addthis_showonpages'); register_setting('addthis', 'addthis_showoncats'); register_setting('addthis', 'addthis_showonhome'); register_setting('addthis', 'addthis_showonarchives'); register_setting('addthis', 'addthis_language'); register_setting('addthis', 'addthis_brand'); register_setting('addthis', 'addthis_options'); register_setting('addthis', 'addthis_header_background'); register_setting('addthis', 'addthis_header_color'); } /** * Adds WP filter so we can append the AddThis button to post content. */ function addthis_init() { global $addthis_settings; if (get_wp_version() >= 2.7) { if ( is_admin() ) { add_action( 'admin_init', 'register_addthis_settings' ); } } if (function_exists('wp_register_style')) { wp_register_style( 'addthis', WP_PLUGIN_URL . '/addthis/css/addthis.css'); wp_register_script( 'addthis', WP_PLUGIN_URL . '/addthis/js/addthis.js'); add_action('admin_print_styles', 'addthis_print_style'); add_action('admin_print_scripts', 'addthis_print_script'); } add_filter('the_content', 'addthis_social_widget'); add_filter('admin_menu', 'addthis_admin_menu'); add_option('addthis_username'); add_option('addthis_show_stats', 'false'); add_option('addthis_password'); add_option('addthis_fallback_username', 'wp-'.cuid()); add_option('addthis_options'); // no default value, so that we can update as times change add_option('addthis_product', 'menu'); add_option('addthis_isdropdown', 'true'); add_option('addthis_menu_type', (get_option('addthis_isdropdown') !== 'true' ? 'static' : 'dropdown')); add_option('addthis_showonhome', 'true'); add_option('addthis_showonpages', 'false'); add_option('addthis_showoncats', 'false'); add_option('addthis_showonarchives', 'false'); add_option('addthis_style'); add_option('addthis_header_background'); add_option('addthis_header_color'); add_option('addthis_sidebar_only', 'false'); add_option('addthis_brand'); add_option('addthis_language', 'en'); $addthis_settings['sidebar_only'] = get_option('addthis_sidebar_only') === 'true'; $addthis_settings['showstats'] = get_option('addthis_show_stats') === 'true'; $addthis_settings['showonhome'] = !(get_option('addthis_showonhome') !== 'true'); $addthis_settings['showonpages'] = get_option('addthis_showonpages') === 'true'; $addthis_settings['showonarchives'] = get_option('addthis_showonarchives') === 'true'; $addthis_settings['showoncats'] = get_option('addthis_showoncats') === 'true'; $product = get_option('addthis_product'); $style = get_option('addthis_style'); if (strlen($style) == 0) $style = 'share'; $addthis_settings['style'] = $style; $addthis_settings['menu_type'] = get_option('addthis_menu_type'); $addthis_settings['username'] = get_option('addthis_username'); $addthis_settings['fallback_username'] = get_option('addthis_fallback_username'); $addthis_settings['password'] = get_option('addthis_password'); $language = get_option('addthis_language'); $addthis_settings['language'] = $language; $advopts = array('brand', 'language', 'header_background', 'header_color'); $addthis_settings['customization'] = ''; for ($i = 0; $i < count($advopts); $i++) { $opt = $advopts[$i]; $val = get_option("addthis_$opt"); if (isset($val) && strlen($val)) $addthis_settings['customization'] .= "var addthis_$opt = '$val';"; } $addthis_settings['options'] = get_option('addthis_options'); add_action('widgets_init', 'addthis_widget_init'); if (get_wp_version() >= 2.7 && $addthis_settings['showstats']) { add_action('wp_dashboard_setup', 'addthis_dashboard_init' ); } } function addthis_widget_init() { if ( function_exists('register_sidebar_widget') ) register_sidebar_widget('AddThis Widget', 'addthis_sidebar_widget'); } function addthis_sidebar_widget($args) { extract($args); echo $before_widget; echo $before_title . $after_title . addthis_social_widget('', true); echo $after_widget; } /** * Appends AddThis button to post content. */ function addthis_social_widget($content, $sidebar = false) { global $addthis_settings; // add nothing to RSS feed or search results; control adding to static/archive/category pages if (!$sidebar) { if ($addthis_settings['sidebar_only'] == 'true') return $content; else if (is_feed()) return $content; else if (is_search()) return $content; else if (is_home() && !$addthis_settings['showonhome']) return $content; else if (is_page() && !$addthis_settings['showonpages']) return $content; else if (is_archive() && !$addthis_settings['showonarchives']) return $content; else if (is_category() && !$addthis_settings['showoncats']) return $content; } $pub = ($addthis_settings['username']); if (!$pub) { $pub = ($addthis_settings['fallback_username']); } $pub = urlencode($pub); $link = urlencode($sidebar ? get_bloginfo('url') : get_permalink()); $title = urlencode($sidebar ? get_bloginfo('title') : the_title('', '', false)); $addthis_options = $addthis_settings['options']; $content .= "\n\n".'
EOF; $content .= addthis_get_button_img() . '
'; } else if ($addthis_settings['menu_type'] === 'toolbox') { $content .= "\n\n"; $content .= <<Share| EOF; if (!strlen($addthis_options)) $addthis_options = 'email,favorites,print,facebook,twitter'; $addthis_options = split(',', $addthis_options); foreach ($addthis_options as $option) { $option = trim($option); if ($option != 'more') { $content .= ''; } } $content .= ''; } else { $content .= << '; } $content .= "\n"; return $content; } /** * Generates img tag for share/bookmark button. */ function addthis_get_button_img() { global $addthis_settings; global $addthis_styles; $btnStyle = $addthis_settings['style']; if ($addthis_settings['language'] != 'en') { // We use a translation of the word 'share' for all verbal buttons switch ($btnStyle) { case 'bookmark': case 'addthis': case 'bookmark-sm': $btnStyle = 'share'; } } if (!isset($addthis_styles[$btnStyle])) $btnStyle = 'share'; $btnRecord = $addthis_styles[$btnStyle]; $btnUrl = (strpos(trim($btnRecord['img']), 'http://') !== 0 ? "http://s7.addthis.com/static/btn/v2/" : "") . $btnRecord['img']; if (strpos($btnUrl, '%lang%') !== false) { $btnUrl = str_replace('%lang%',$addthis_settings['language'], $btnUrl); } $btnWidth = $btnRecord['w']; $btnHeight = $btnRecord['h']; return << EOF; } function addthis_admin_menu() { add_options_page('AddThis Plugin Options', 'AddThis', 8, __FILE__, 'addthis_plugin_options_php4'); } function addthis_plugin_options_php4() { global $addthis_styles; global $addthis_languages; global $addthis_settings; global $addthis_menu_types; ?>

AddThis

Required


(sidebar widget must be enabled)
/>



Advanced

= 2.7) { ?>
/>

(required for displaying stats)
/>
pages:", 'addthis_trans_domain' ); ?> />
/>
/>
For more details on the following options, see our customization docs.

(comma-separated)