"Twitter",
"id" => "as-twitter",
"js" => "",
"style" => "float:left; margin: 0 5px; padding: 3px 0 0 0;",
"code" => ''
),
array(
"name" => "Tweetmeme",
"id" => "as-tweetmeme",
"js" => "",
"style" => "float:left; margin: 0 5px; padding: 3px 0 0 0;",
"code" => ''),
array(
"name" => "Google Buzz",
"id" => "as-buzzwidget",
"js" => "",
"style" => "float: left; margin: 0 5px;",
"code" => ""
),
array(
"name" => "Plus one",
"id" => "as-plusone",
"js" => "",
"style" => "float:left; padding-top: 4px; margin: 0 5px;",
"code" => ''
),
array(
"name" => "Facebook Share",
"id" => "as-facebook",
"js" => "",
"style" => "float: left; margin: 0 5px; padding: 4px 0 0;",
"code" => 'Share
'
),
array(
"name" => "Facebook Like",
"id" => "as-fblike",
"js" => "",
"style" => "float: left; margin: 0 5px; padding: 4px 0 0; width: 50px; overflow: hidden;",
"code" => '
'
),
array(
"name" => "LinkedIn",
"id" => "as-linkedin",
"js" => "",
"style" => "float: left; padding-top: 2px; margin: 0 5px;",
"code" => ''
),
array(
"name" => "StumbleUpon",
"id" => "as-stumbleupon",
"js" => "",
"style" => "float: left; margin: 0 5px; padding: 4px 0px 0px;",
"code" => ""
),
array(
"name" => "Reddit",
"id" => "as-reddit",
"js" => "",
"style" => "float: left; margin: 0 5px; padding: 0px 0px 0px;",
"code" => ''
),
array(
"name" => "Digg",
"id" => "as-digg",
"js" => "digg.js",
"style" => "float: left; margin: 0 5px; padding: 3px 0px 0px;",
"code" => '
'
),
);
function active_share() {
}
//****************************************************************************************
//Set Functions
//****************************************************************************************
//output functions
function comment_marker($content=''){
$options = get_option('as_options');
if($options['as-posts']==1&&is_single()){
$content .= "";
}
else if($options['as-pages']==1&&is_page()){
$content .= "";
}
return $content;
}
function jquery() {
}
function ass_loadjs(){
DEFINE('get_plugin_directory_uri', get_bloginfo('wpurl') . '/wp-content/plugins/active-share-by-orangesoda/');
$options = get_option('as_options');
if(($options['as-posts']==1&&is_single())||($options['as-pages']==1&&is_page())){
wp_register_script('active-share',
get_plugin_directory_uri . 'active-share.js', array('jquery'),'1.0');
wp_enqueue_script('active-share');
}
// if(is_single()||is_page()){
//
// wp_register_script('active-share',
// get_plugin_directory_uri . 'active-share.js', array('jquery'),'1.0');
// wp_enqueue_script('active-share');
//
// }
}
function html2rgb($color)
{
if ($color[0] == '#')
$color = substr($color, 1);
if (strlen($color) == 6)
list($r, $g, $b) = array($color[0].$color[1],
$color[2].$color[3],
$color[4].$color[5]);
elseif (strlen($color) == 3)
list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
else
return false;
$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
return "$r, $g, $b";
}
function print_shares($id){
if (function_exists('wp_reset_postdata')){
wp_reset_postdata();
}
$options = get_option('as_options');
if(($options['as-posts']==1&&is_single())||($options['as-pages']==1&&is_page())){
$as_tshares = $this->as_tshares;
$title = get_the_title($id);
$bgcolor = "rgba(" . $this->html2rgb($options['as-bgcolor']) . ", " . $options['as-opacity']/100 . ")";
$color = $options['as-color'];
$twocolor = $options['as-twocolor'];
$width = $options['as-width'];
$message = $options['as-message'];
print "";
foreach ($as_tshares AS $theshare){
if($options[$theshare['id']]==1) {
print "
" . $theshare['code'] . "";
}
}
?>
'',
'as-pages'=>'',
'as-message'=>$_POST['as-message'],
'as-width'=>'',
'as-level'=>'');
$checkboxes = array(
'as-posts'=>'',
'as-pages'=>''
);
foreach ($this->as_tshares AS $theshare){
$update[$theshare['id']]='';
$checkboxes[$theshare['id']]='';
}
//validation, old change color if a valid hex colorcode
if(preg_match('(#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?)', $_POST['as-bgcolor'])) {
$update['as-bgcolor'] = $_POST['as-bgcolor'];
}
else {
$update['as-bgcolor'] = $oldoptions['as-bgcolor'];
}
if(preg_match('(#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?)', $_POST['as-color'])) {
$update['as-color'] = $_POST['as-color'];
}
else {
$update['as-color'] = $oldoptions['as-color'];
}
if(preg_match('(#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?)', $_POST['as-twocolor'])) {
$update['as-twocolor'] = $_POST['as-twocolor'];
}
else {
$update['as-color'] = $oldoptions['as-color'];
}
if($_POST['as-width'] < 1500 && $_POST['as-width'] > 600) {
$update['as-width'] = $_POST['as-width'];
}
else {
$update['as-width'] = 800;
}
if($_POST['as-opacity'] <= 100 && $_POST['as-opacity'] >= 0) {
$update['as-opacity'] = $_POST['as-opacity'];
}
else {
$update['as-opacity'] = 80;
}
//check if a checkbox is present, if so mark it as 1 in the DB else mark as 0
$checked = array_flip($_POST['checks']);
foreach($checkboxes AS $check => $null){
if(isset($checked[$check])){
$update[$check] = 1;
}
else {
$update[$check] = 0;
}
}
update_option('as_options', $update); //update options
}
$option = get_option('as_options'); //load options for form display
?>
as_tshares;
$as_option = array();
$i = 0;
$en = 1;
foreach ($as_tshare AS $theshare){
if ($i == 0){ $en = 0; $i++; }
else if($i<4){ $en = 1; $i++; }
else { $en = 0; }
$as_option[$theshare['id']] = $en;
}
$as_option['as-posts'] = 1;
$as_option['as-pages'] = 1;
$as_option['as-bgcolor'] = '#000000';
$as_option['as-color'] = '#FFFFFF';
$as_option['as-opacity'] = '100';
$as_option['as-twocolor'] = '#9F9F9F';
$as_option['as-message'] = 'be a pal and share this would ya?';
$as_option['as-width'] = 800;
$as_option['as-level'] = 1;
add_option("as_options", $as_option);
}
}
global $as_share;
$as_share = new active_share();
function active_share_menu() {
global $as_share;
add_options_page(__('Active Share Settings','active-share-settings'), __('Active Share Settings','active-share-settings'), 'manage_options', 'active_share', array(&$as_share, 'active_share_settings'));
}
//****************************************************************************************
//add filters and actions
//****************************************************************************************
//function actions and filters
add_filter('the_content', array(&$as_share, 'comment_marker'));
add_action('wp_print_scripts', array(&$as_share, 'ass_loadjs'), 10, 1);
add_action('wp_footer', array(&$as_share, 'print_shares'), 1, 1);
//options actions and filters
if ( is_admin() ){ // admin actions
add_action('admin_menu', 'active_share_menu');
add_action( 'admin_init', array(&$as_share, 'as_add_options' ));
}
?>