'Automatic','af'=>'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) */
);
$addthis_new_styles = array(
'small_toolbox' => array( 'src' => '
', 'img' => 'toolbox-small.png', 'name' => 'Small Toolbox', 'above' => 'hidden ', 'below' => ''
), // 32x32
'small_toolbox_with_share' => array( 'src' => '', 'img' => 'small-toolbox.jpg', 'name' => 'Small Toolbox with Share first', 'above' => '', 'below' => 'hidden'
), // Plus sign share | four buttons
'large_toolbox' => array( 'src' => '', 'img' => 'toolbox-large.png', 'name' => 'Large Toolbox', 'above' => 'hidden ', 'below' => ''
), // 32x32
'fb_tw_sc' => array( 'src' => '' , 'img' => 'fb-tw-sc.jpg' , 'name' => 'Like, Tweet, Counter', 'above' => '', 'below' => 'hidden'
), // facebook tweet share counter
'simple_button' => array('src' => '', 'img' => 'share.jpg', 'name' => 'Share Button', 'above' => 'hidden ', 'below' => 'hidden'
), // Plus sign share
'button' => array( 'src' => '
', 'img' => 'button.jpg', 'name' => 'Classic Share Button', 'above' => 'hidden ', 'below' => 'hidden'
), // classic
'share_counter' => array( 'src' => '', 'img' => 'share_counter.png', 'name' => 'Share Counter', 'above' => 'hidden ', 'below' => 'hidden'
),
);
define( 'addthis_style_default' , 'small_toolbox_with_share');
define( 'ADDTHIS_PLUGIN_VERSION', '2.0.1');
/**
* Converts our old many options in to one beautiful array
*
*/
function addthis_options_200()
{
global $current_user;
$user_id = $current_user->ID;
$addthis_new_options = array();
if ($username = get_option('addthis_username'))
$addthis_new_options['username'] = $username;
if ($password = get_option('addthis_password'))
$addthis_new_options['password'] = $password;
if ($show_stats = get_option('addthis_show_stats'))
$addthis_new_options['addthis_show_stats'] = $show_stats;
if ($append_data = get_option('addthis_append_data'))
$addthis_new_options['addthis_append_data'] = $append_data;
if ($showonhome = get_option('addthis_showonhome'))
$addthis_new_options['addthis_showonhome'] = $showonhome;
if ($showonpages = get_option('addthis_showonpages'))
$addthis_new_options['addthis_showonpages'] = $showonpages;
if ($showoncats = get_option('addthis_showoncats'))
$addthis_new_options['addthis_showoncats'] = $showoncats;
if ($showonarchives = get_option('addthis_showonarchives'))
$addthis_new_options['addthis_showonarchives'] = $showonarchives;
if (get_option('addthis_showonposts') != true)
$addthis_new_options['below'] = 'none';
elseif (get_option('addthis_sidebar_only') == true)
$addthis_new_options['below'] = 'none';
else
{
if ( ($menu_type = get_option('addthis_menu_type')) == 'toolbox' )
$addthis_new_options['below'] = 'small_toolbox_with_share';
else
$addthis_new_options['below'] = 'button';
}
if ($header_background = get_option('addthis_header_background'))
$addthis_new_options['addthis_header_background'] = $header_background;
if ($header_color = get_option('addthis_header_color'))
$addthis_new_options['addthis_header_color'] = $header_color;
if ($brand = get_option('addthis_brand'))
$addthis_new_options['addthis_brand'] = $brand;
if ($language = get_option('addthis_language'))
$addthis_new_options['addthis_language'] = $language;
// Above is new, set it to none
$addthis_new_options['above'] = 'none';
// Save option
add_option('addthis_settings', $addthis_new_options);
// if the option saved, delete the old options
delete_option('addthis_show_stats');
delete_option('addthis_password');
delete_option('addthis_fallback_username');
delete_option('addthis_options');
delete_option('addthis_product');
delete_option('addthis_isdropdown');
delete_option('addthis_menu_type');
delete_option('addthis_append_data');
delete_option('addthis_showonhome');
delete_option('addthis_showonposts');
delete_option('addthis_showonpages');
delete_option('addthis_showoncats');
delete_option('addthis_showonarchives');
delete_option('addthis_style');
delete_option('addthis_header_background');
delete_option('addthis_header_color');
delete_option('addthis_sidebar_only');
delete_option('addthis_brand');
delete_option('addthis_language');;
global $current_user;
$user_id = $current_user->ID;
add_user_meta($user_id, 'addthis_nag_updated_options', 'true', true);
}
/**
* 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;
}
define('ADDTHIS_FALLBACK_USERNAME', 'wp-'.cuid() );
/**
* Returns major.minor WordPress version.
*/
function addthis_get_wp_version() {
return (float)substr(get_bloginfo('version'),0,3);
}
/**
* For templates, we need a wrapper for printing out the code on demand.
*/
function addthis_print_widget($url=null, $title=null) {
echo addthis_social_widget('', true, $url, $title);
}
/**
* 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' );
}
add_action('admin_notices', 'addthis_admin_notices');
function addthis_admin_notices(){
if (! current_user_can('manage_options'))
return;
global $current_user;
$user_id = $current_user->ID;
$options = get_option('addthis_settings');
if ($options == false && ! get_user_meta($user_id, 'addthis_ignore_notices'))
{
echo '';
printf(__('Setup the AddThis plugin so you can start having your users share your content around the web
Setup options | Ignore this notice'), admin_url('options-general.php?page=addthis/addthis_social_widget.php'), '?addthis_nag_ignore=0');
echo "
";
}
elseif ( ( ! isset($options['username']) || $options['username'] == false) && ! get_user_meta($user_id, 'addthis_nag_username_ignore'))
{
echo '';
printf( __('Sign up for AddThis and add your username/password to recieve analytics about how people are sharing your content.
Enter username and password | Sign Up | Ignore this notice'), admin_url('options-general.php?page=addthis/addthis_social_widget.php'), 'https://www.addthis.com/register', '?addthis_nag_username_ignore=0');
echo "
";
}
elseif ( (get_user_meta($user_id, 'addthis_nag_updated_options') == true ) )
{
echo '';
printf( __('We have updated the options for the AddThis plugin. Check out the AddThis settings page to see the new styles and options.
See New Options | Ignore this notice'), admin_url('options-general.php?page=addthis/addthis_social_widget.php'), '?addthis_nag_updated_ignore=0');
echo "
";
}
}
add_action('admin_init', 'addthis_nag_ignore');
function addthis_nag_ignore()
{
global $current_user;
$user_id = $current_user->ID;
$options = get_option('addthis_settings');
if (isset($_GET['addthis_nag_ignore']) && '0' == $_GET['addthis_nag_ignore'])
add_user_meta($user_id, 'addthis_ignore_notices', 'true', true);
if (isset($_GET['addthis_nag_username_ignore']) && '0' == $_GET['addthis_nag_username_ignore'])
add_user_meta($user_id, 'addthis_nag_username_ignore', 'true', true);
if (isset($_GET['addthis_nag_updated_ignore']) && '0' == $_GET['addthis_nag_updated_ignore'])
delete_user_meta($user_id, 'addthis_nag_updated_options', 'true');
}
function addthis_plugin_useragent($userAgent)
{
return $userAgent . 'ATV/' . ADDTHIS_PLUGIN_VERSION;
}
add_action('wp_ajax_at_show_dashboard_widget', 'addthis_render_dashboard_widget');
/**
* 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() {
if (! current_user_can('manage_options'))
{
_e( 'Cheatin’ uh?' );
exit;
}
$_services = array(
'netvibes' => 'Netvibes',
'google' => 'Google Reader',
'yahoo' => 'Yahoo',
'rojo' => 'Rojo',
'aol' => 'AOL',
'newsgator-on' => 'Newsgator Online',
'pluck-on' => 'Pluck Online',
'bloglines' => 'Bloglines',
'feedlounge' => 'Feedlounge',
'newsburst' => 'Newsburst',
'msn' => 'MSN',
'winlive' => 'Windows Live',
'technorati' => 'Technorati',
'pageflakes' => 'Pageflakes',
'newsalloy' => 'News Alloy',
'feedreader' => 'FeedReader',
'mymsn' => 'My MSN',
'newsisfree' => 'Newsisfree',
'feeddemon' => 'FeedDemon',
'netnewswire' => 'NetNewWire',
'pluck' => 'Pluck',
'newsgator' => 'NewsGator',
'sharpreader' => 'SharpReader',
'awasu' => 'Awasu',
'myearthlink' => 'myEarthLink',
'rss' => 'Direct Feed Link',
'googlebuzz' => 'Google Buzz',
'youtube' => 'YouTube',
'facebook' => 'Facebook',
'flickr' => 'Flickr',
'twitter' => 'Twitter',
'linkedin' => 'LinkedIn'
);
global $addthis_settings;
$options = get_option('addthis_settings');
if (isset($options['username']))
$username = urlencode($options['username']);
else
{
echo 'No Username entered';
return false;
}
if (isset($options['password']))
$password = urlencode($options['password']);
else
{
echo 'No Passwrod entered';
return false;
}
$domain = get_home_url();
$domain = str_replace(array('http://', 'https://'), '', $domain);
$requests = array(
array('metric' => 'shares', 'dimension' => '', 'domain' => $domain, 'period' => 'day'),
array('metric' => 'shares', 'dimension' => '', 'domain' => $domain, 'period' => 'week'),
array('metric' => 'shares', 'dimension' => '', 'domain' => $domain, 'period' => 'month'),
array('metric' => 'clickbacks', 'dimension' => '', 'domain' => $domain, 'period' => 'day'),
array('metric' => 'clickbacks', 'dimension' => '', 'domain' => $domain, 'period' => 'week'),
array('metric' => 'clickbacks', 'dimension' => '', 'domain' => $domain, 'period' => 'month'),
array('metric' => 'shares', 'dimension' => 'service' , 'domain' => $domain, 'period' => 'month'),
array('metric' => 'clickbacks', 'dimension' => 'service', 'domain' => $domain, 'period' => 'month'),
);
if (! $stats = get_transient('addthis_dashboard_stats') )
{
add_filter('http_headers_useragent', 'addthis_plugin_useragent');
foreach ($requests as $request)
{
$dimension = $metric = $domain = $period = '';
extract($request);
$dimension = ($dimension != '') ? '/'.$dimension : '';
$url = 'http://api.addthis.com/analytics/1.0/pub/' . $metric . $dimension . '.json?'.
'domain='.$domain.'&period='.$period.
'&username='.$username.
'&password='.$password;
$stats[$metric.$dimension.$period] = wp_remote_get($url, array('period' => $period, 'domain' => $domain, 'password' => $password, 'username' => $username) );
}
if ($stats['sharesday']['response']['code'] == 200)
set_transient('addthis_dashboard_stats', $stats, '600');
}
if ($stats['sharesday']['response']['code'] == 200 && $stats['sharesmonth']['body'] != '[]' )
{
$yesterday['shares'] = json_decode($stats['sharesday']['body']);
$yesterday['shares'] = $yesterday['shares'][0]->shares;
$yesterday['clickbacks'] = json_decode($stats['clickbacksday']['body']);
$yesterday['clickbacks'] = $yesterday['clickbacks'][0]->clickbacks;
$yesterday['viral'] = ($yesterday['shares'] > 0 && $yesterday['clickbacks'] > 0 ) ? $yesterday['clickbacks'] / $yesterday['shares'] * 100 . '%' : 'n/a';
if (! $yesterday['clickbacks'] ) $yesterday['clickbacks'] = 0;
if (! $yesterday['shares'] ) $yesterday['shares'] = 0;
$decodedLastWeek = json_decode($stats['sharesweek']['body']);
$lastweek['shares'] = 0;
foreach ($decodedLastWeek as $share)
{
$lastweek['shares'] += $share->shares;
}
$decodedLastWeek = json_decode($stats['clickbacksweek']['body']);
$lastweek['clickbacks'] = 0;
foreach ($decodedLastWeek as $clickback)
{
$lastweek['clickbacks'] += $clickback->clickbacks;
}
$lastweek['viral'] = ($lastweek['shares'] > 0 && $lastweek['clickbacks'] > 0 ) ? $lastweek['clickbacks'] / $lastweek['shares'] * 100 . '%' : 'n/a';
$decodedLastMonth = json_decode($stats['sharesmonth']['body']);
$lastmonth['shares'] = 0;
foreach ($decodedLastMonth as $share)
{
$lastmonth['shares'] += $share->shares;
}
$decodedLastMonth = json_decode($stats['clickbacksmonth']['body']);
$lastmonth['clickbacks'] = 0;
foreach ($decodedLastMonth as $clickback)
{
$lastmonth['clickbacks'] += $clickback->clickbacks;
}
$lastmonth['viral'] = ($lastmonth['shares'] > 0 && $lastmonth['clickbacks'] ) ? $lastmonth['clickbacks'] / $lastmonth['shares'] * 100 . '%' : 'n/a';
$services['shares'] = json_decode($stats['shares/servicemonth']['body']);
$services['clickbacks'] = json_decode($stats['clickbacks/servicemonth']['body']);
foreach (array('shares', 'clickbacks') as $type)
{
$topServiceShare = array_shift($services[$type]);
$firstLabel = ( isset($_services[$topServiceShare->service])) ? $_services[$topServiceShare->service] : $topServiceShare->service;
$firstAmount = $topServiceShare->{$type};
$topServiceShare = array_shift($services[$type]);
$secondLabel = ( isset($_services[$topServiceShare->service])) ? $_services[$topServiceShare->service] : $topServiceShare->service;
$secondAmount = $topServiceShare->{$type};
$thirdLabel = 'Others';
$thirdAmount = 0;
foreach($services[$type] as $service )
{
$thirdAmount += $service->{$type};
}
$servicesCharts[$type] = 'http://chart.apis.google.com/chart?&chdlp=b&chs=118x145&cht=p3&chco=BA3A1C|F75C39|424242&'.
'chdl='.$firstLabel.'|'.$secondLabel.'|'.$thirdLabel.'&'.
'chd=t:'.$firstAmount.','.$secondAmount.','.$thirdAmount;
}
echo "";
echo "
";
$tab = 0;
foreach (array('yesterday', 'lastweek', 'lastmonth') as $timePeriod )
{
$stats = $$timePeriod;
$tab++;
$viral = ( $stats['viral'] != 'n/a' ) ? number_format( $stats['viral'],2) .'%' : $stats['viral'];
echo '
';
echo
'
';
echo ''. $stats['shares'].'Shares | ';
echo ''. $stats['clickbacks'].'Clicks | ';
echo ''. $viral .'Viral Lift | ';
echo '
';
echo '
';
echo '
';
}
echo "
";
echo "
";
echo "Top Services for shares(last month)
";
echo "
";
echo "";
echo 'Top Services for clicks(last month)";
echo "

";
echo "
";
echo "";
echo '
';
echo 'View More Analytics
';
}
elseif($stats['sharesday']['response']['code'] == 200){
echo
<<We haven't recorded any sharing events in the last month for this site. This could be because you just installed addthis. If you would like to increase your sharing,
If you want some ideas for increasing your sharing, check out: