@anywhere javascript code to your blog. Built by @TheFrosty. * Version: 0.4.3 * Author: Austin Passy * Author URI: http://frostywebdesigns.com * * @copyright 2010 * @author Austin Passy * @link http://frostywebdesigns.com/ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @package Anywhere */ if ( !class_exists( 'Frostys_Anywhere' ) ) { class Frostys_Anywhere { static $anywhere; const version = '0.4.3'; const domain = 'anywhere'; /* PHP4 constructor */ function Frostys_Anywhere() { $this->__construct(); } /* PHP5 constructor */ function __construct() { global $anywhere; $anywhere = get_option( 'anywhere_settings' ); add_action( 'plugins_loaded', array( __CLASS__, 'define' ) ); add_action( 'admin_init', array( __CLASS__, 'admin_required' ) ); add_action( 'init', array( __CLASS__, 'required' ) ); add_action( 'admin_init', array( __CLASS__, 'admin_warnings' ) ); add_action( 'admin_init', array( __CLASS__, 'wp_register_style' ) ); add_action( 'admin_menu', array( __CLASS__, 'add_options_page' ) ); add_action( 'wp_print_scripts', array( __CLASS__, 'wp_print_scripts' ) ); add_action( 'wp_head', array( __CLASS__, 'options' ) ); add_action( 'wp_head', array( __CLASS__, 'tweet_box' ) ); add_filter( 'plugin_action_links', array( __CLASS__, 'plugin_actions' ), 10, 2 ); //Add a settings page to the plugin menu add_filter( 'the_content', array( __CLASS__, 'tweet_box_div' ) ); } /** * Define constant paths to the plugin folder. * @since 0.1 */ function define() { define( 'ANYWHERE', plugin_dir_path( __FILE__ ) ); define( 'ANYWHERE_URL', plugin_dir_url( __FILE__ ) ); define( 'ANYWHERE_ADMIN', trailingslashit( ANYWHERE ) . 'library/admin' ); define( 'ANYWHERE_INCLUDES', trailingslashit( ANYWHERE ) . 'library/includes' ); define( 'ANYWHERE_CSS', plugins_url( 'library/css', __FILE__ ) ); define( 'ANYWHERE_JS', plugins_url( 'library/js', __FILE__ ) ); } function admin_required() { require_once( ANYWHERE_ADMIN . '/settings-admin.php' ); require_once( ANYWHERE_ADMIN . '/dashboard.php' ); } function required() { require_once( ANYWHERE_INCLUDES . '/shortcodes.php' ); } /** * WordPress 3.x check * * @since 0.3.5 */ public function is_version( $version = '3.0' ) { global $wp_version; if ( version_compare( $wp_version, $version, '<' ) ) { return false; } return true; } /** * Load the stylesheet * @since 0.1 */ function wp_register_style() { wp_register_style( 'anywhere-tabs', ANYWHERE_CSS . '/tabs.css' ); wp_register_style( 'anywhere-admin', ANYWHERE_CSS . '/anywhere-admin.css' ); } /** * Function to add the settings page * @since 0.1 */ function add_options_page() { $page = add_options_page( 'Anywhere Settings', '@Anywhere', 'activate_plugins', 'anywhere.php', 'anywhere_page' ); add_action( 'admin_print_styles-' . $page, array( __CLASS__, 'wp_enqueue_style' ) ); add_action( 'admin_print_scripts-' . $page, array( __CLASS__, 'wp_enqueue_script' ) ); } /** * Function to add the style to the settings page * @since 0.1 */ function wp_enqueue_style() { wp_enqueue_style( 'thickbox' ); wp_enqueue_style( 'anywhere-tabs' ); wp_enqueue_style( 'anywhere-admin' ); } /** * Function to add the script to the settings page * @since 0.1 */ function wp_enqueue_script() { wp_enqueue_script( 'thickbox' ); wp_enqueue_script( 'theme-preview' ); wp_enqueue_script( 'anywhere-admin', ANYWHERE_JS . '/anywhere.js', array( 'jquery' ), '0.1', false ); } /** * Adds the @anywhere script * @since 0.1 */ function wp_print_scripts() { global $anywhere; $api = $anywhere['api']; $ver = $anywhere['version']; if ( !is_admin() ) { if ( ( !empty( $api ) && $api != '' ) && is_singular() ) wp_enqueue_script( self::domain, 'http://platform.twitter.com/anywhere.js?id=' . $api . '&v=' . $ver, false, $ver, false ); } } /** * Adds @anywhere options * @since 0.1 */ function options() { global $anywhere; $api = $anywhere['api']; $users = $anywhere['linkifyusers']; $cards = $anywhere['hovercards']; if ( ( $api != '' && ( $users != false || $cards != false ) ) && is_singular() ) { ?> @Anywhere plugin made by @TheFrosty'; else $ll = false; if ( $box != false ) : $tb = '
@anywhere plugin is not configured yet. It will not load until you enter your api.