Tweet Button. It lets your users share links directly from the page they’re on. When they click on the Tweet Button, a Tweet box will appear -- pre-populated with a shortened link that points to the item that they’re sharing. Version: 0.1-RC1 Author: Pete Mall Author URI: http://developersmind.com/ License: GPLv2 */ if ( !class_exists( 'WP_Tweet' ) ) : /** * Base class. * * @package WP_Tweet */ class WP_Tweet { /** * Constructor. Adds hooks. */ function WP_Tweet() { //Bail without 3.0 if ( ! function_exists( '__return_false' ) ) return; // Initialize default options and register the uninstall hook. register_activation_hook( __FILE__, array( 'WP_Tweet', 'on_activation' ) ); // Textdomain and whitlist options. add_action( 'admin_init', array( &$this, 'action_admin_init') ); // Add Tweet Button. add_action( 'the_content', array( &$this, 'action_the_content' ) ); // Add settings page. add_action( 'admin_menu', array( &$this, 'action_admin_menu' ) ); } /** * Runs on activation. Initializes the default options if they don't exist and registers the uninstallation hook. */ function on_activation() { $options = get_option( 'wp-tweet_options' ); if ( ! $options ) { $options = array( 'data-count' => 'horizontal', 'data-text' => 'title', 'data-url' => 'page', 'data-lang' => 'en', 'align' => 'left' ); update_option( 'wp-tweet_options', $options ); } // Register uninstall hook. register_uninstall_hook( __FILE__, array( 'WP_Tweet', 'on_uninstall' ) ); } /** * Runs on uninstall. Removes all options. */ function on_uninstall() { delete_option( 'wp-tweet_options' ); delete_option( 'wp-tweet_show' ); } /** * Attached to admin_init. Loads the textdomain and whitelist options. */ function action_admin_init() { load_plugin_textdomain( 'wp-tweet', null, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); register_setting( 'wp-tweet_settings', 'wp-tweet_options' ); register_setting( 'wp-tweet_settings', 'wp-tweet_show' ); } /** * Attached to the_content. Adds the Tweet Button. */ function action_the_content( $content ) { $show_options = get_option( 'wp-tweet_show' ); if ( ( is_front_page() && $show_options['home'] ) || ( is_single() && $show_options['post'] ) || ( is_page() && $show_options['page'] ) ) { $options = get_option( 'wp-tweet_options' ); $button = "
"; $button .= "'; } return $content; } /** * Attached to admin_menu. Adds the Tweet Button Settings Page under the Settings Menu. */ function action_admin_menu() { add_options_page( 'WP Tweet', 'WP Tweet', 'manage_options', 'wp-tweet-settings', array( &$this, 'settings_page' ) ); } /** * Displays the settings page. */ function settings_page() { ?>

This user will be @ mentioned in the suggested Tweet

Related account

Related account description

CSS style for the div container for the Tweet Button. Eg: float: left;