/*
Plugin Name: Add to Any: Share/Save/Bookmark Button
Plugin URI: http://www.addtoany.com/buttons/
Description: Lets readers share, save, and bookmark your posts using any service and browser. [Settings]
Version: .9
Author: MicroPat
Author URI: http://www.addtoany.com/contact/
*/
// Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv)
if (!function_exists('A2A_SHARE_SAVE_code2utf')) {
function A2A_SHARE_SAVE_code2utf($num)
{
if ($num < 128) return chr($num);
if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
return '';
}
}
// Since UTF-8 does not work in PHP4 ( http://us2.php.net/manual/en/function.html-entity-decode.php ) :
if (!function_exists('A2A_SHARE_SAVE_html_entity_decode_utf8')) {
function A2A_SHARE_SAVE_html_entity_decode_utf8($string)
{
static $trans_tbl;
// replace numeric entities
$string = preg_replace('~([0-9a-f]+);~ei', 'A2A_SHARE_SAVE_code2utf(hexdec("\\1"))', $string);
$string = preg_replace('~([0-9]+);~e', 'A2A_SHARE_SAVE_code2utf(\\1)', $string);
// replace literal entities
if (!isset($trans_tbl))
{
$trans_tbl = array();
foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key)
$trans_tbl[$key] = utf8_encode($val);
}
return strtr($string, $trans_tbl);
}
}
function ADDTOANY_SHARE_SAVE_BUTTON($output_buffering=false) {
if($output_buffering)ob_start();
$sitename_enc = rawurlencode( get_bloginfo('name') );
$siteurl_enc = rawurlencode( trailingslashit( get_bloginfo('url') ) );
$linkname = A2A_SHARE_SAVE_html_entity_decode_utf8( get_the_title() );
$linkname_enc = rawurlencode( $linkname );
$linkurl = get_permalink($post->ID);
$linkurl_enc = rawurlencode( $linkurl );
?>
if($output_buffering) {
$button = ob_get_contents();
ob_end_clean();
return $button;
}
}
function A2A_SHARE_SAVE_to_bottom_of_content($content) {
if (
( (strpos($content, '')===false) ) && ( //
( !is_page() && get_option('A2A_SHARE_SAVE_display_in_posts')=='-1' ) || // All posts
( !is_page() && !is_single() && get_option('A2A_SHARE_SAVE_display_in_posts_on_front_page')=='-1' ) || // Front page posts
( is_page() && get_option('A2A_SHARE_SAVE_display_in_pages')=='-1' ) || // Pages
( (strpos($content, '')!==false ) ) //
)
)
return $content;
$content .= '
'.ADDTOANY_SHARE_SAVE_BUTTON(true).'
'; return $content; } add_action('the_content', 'A2A_SHARE_SAVE_to_bottom_of_content'); /***************************** OPTIONS ******************************/ function A2A_SHARE_SAVE_options_page() { if( $_POST[ 'A2A_SHARE_SAVE_submit_hidden' ] == 'Y' ) { update_option( 'A2A_SHARE_SAVE_display_in_posts_on_front_page', ($_POST['A2A_SHARE_SAVE_display_in_posts_on_front_page']=='1') ? '1':'-1' ); update_option( 'A2A_SHARE_SAVE_display_in_posts', ($_POST['A2A_SHARE_SAVE_display_in_posts']=='1') ? '1':'-1' ); update_option( 'A2A_SHARE_SAVE_display_in_pages', ($_POST['A2A_SHARE_SAVE_display_in_pages']=='1') ? '1':'-1' ); ?>