"; } return $content; } function jquery() { } function ass_loadjs(){ DEFINE('get_plugin_directory_uri', get_bloginfo('wpurl') . '/wp-content/plugins/active-share-by-orangesoda/'); if(is_single()||is_page()){ $options = get_option('as_options'); wp_register_script('active-share', get_plugin_directory_uri . 'active-share.js', array('jquery'),'1.0'); wp_enqueue_script('active-share'); if($options['as-digg']==1){ wp_register_script('as-digg', get_plugin_directory_uri . 'digg.js', array('jquery', 'active-share'),'1.0'); wp_enqueue_script('as-digg'); } } } 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){ $title = get_the_title($id); $options = get_option('as_options'); $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 "
"; if($options['as-tweetmeme']==1){ ?> Share
'', 'as-buzzwidget'=>'', 'as-facebook'=>'', 'as-stumbleupon'=>'', 'as-digg'=>'', 'as-message'=>$_POST['as-message'], 'as-width'=>'', 'as-level'=>'' ); //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; } $checkboxes = array( //all the checkboxes on the page 'as-tweetmeme'=>'', 'as-buzzwidget'=>'', 'as-facebook'=>'', 'as-stumbleupon'=>'', 'as-digg'=>'', ); //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 ?>
">

Active Share Settings

Active Share is a free plugin provided by OrangeSoda and written by Dan Garfield. For marketing tips follow OrangeSoda on twitter. This plugin was inspired by a similar feature on okcupid's blog. Their blog is awesome and you should check it out.

Sharing Services

Show TweetMeme checkboxes($option['as-tweetmeme']); ?> name="checks[]" value="as-tweetmeme" />
Show Google Buzz checkboxes($option['as-buzzwidget']); ?> name="checks[]" value="as-buzzwidget" />
Show Facebook checkboxes($option['as-facebook']); ?> name="checks[]" value="as-facebook" />
Show stumbleupon checkboxes($option['as-stumbleupon']); ?>name="checks[]" value="as-stumbleupon" />
Show Digg checkboxes($option['as-digg']); ?> name="checks[]" value="as-digg" />

Style Settings

Background Color
Background Opacity (0=transparent, 100=opaque)
Text Color
Message Color
Message Text
Width (between 600 and 1500

1, 'as-buzzwidget'=>1, 'as-facebook'=>1, 'as-stumbleupon'=>0, 'as-digg'=>0, 'as-bgcolor'=>'#000000', 'as-color'=>'#FFFFFF', 'as-opacity'=>'100', 'as-twocolor'=>'#9F9F9F', 'as-message'=>'be a pal and share this would ya?', 'as-width'=>800, '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' )); } ?>