* @copyright Copyright (c) 2009-2013, Edward Caissie * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 2, as published by the * Free Software Foundation. * * You may NOT assume that you can use any other version of the GPL. * * 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. See the GNU General Public License for more details * * You should have received a copy of the GNU General Public License along with * this program; if not, write to: * * Free Software Foundation, Inc. * 51 Franklin St, Fifth Floor * Boston, MA 02110-1301 USA * * The license for this software can also likely be found here: * http://www.gnu.org/licenses/gpl-2.0.html * * @version 1.8 * @date February 12, 2013 * Removed `load_textdomain` as redundant * Move all code into class structure * * @version 1.8.2 * @date May 21, 2013 */ class BNS_Corner_Logo_Widget extends WP_Widget { /** * BNS Corner Logo Widget * Used to extend WP_Widget class * * @package BNS_Corner_Logo * @since 0.1 * * @uses WP_Widget * * @return void */ function BNS_Corner_Logo_Widget() { /** Widget settings */ $widget_ops = array( 'classname' => 'bns-corner-logo', 'description' => __( 'Widget to display a logo; or, used as a plugin displays image fixed in one of the four corners.', 'bns-cl' ) ); /** Widget control settings */ $control_ops = array( 'width' => 200, 'id_base' => 'bns-corner-logo' ); /** Create the widget */ $this->WP_Widget( 'bns-corner-logo', 'BNS Corner Logo', $widget_ops, $control_ops ); /** * Check installed WordPress version for compatibility * * @package BNS_Corner_Logo * @since 1.0 * @internal Version 3.0 being used in reference to home_url() * * @uses (global) wp_version * * @version 1.6 * @date November 18, 2011. * Re-written to be i18n compatible */ global $wp_version; $exit_message = __( 'BNS Corner Logo requires WordPress version 3.0 or newer. Please Update!', 'bns-cl' ); if ( version_compare( $wp_version, "3.0", "<" ) ) { exit( $exit_message ); } /** End if = version compare */ /** Add widget */ add_action( 'widgets_init', array( $this, 'load_bnscl_widget' ) ); /** Add scripts and style */ add_action( 'wp_enqueue_scripts', array( $this, 'scripts_and_styles') ); } /** End function - bns corner logo widget */ /** * Override widget method of class WP_Widget * * @param $args * @param $instance * * @uses apply_filters * @uses get_avatar * @uses get_userdata * * @return void */ function widget( $args, $instance ) { extract( $args ); /** User-selected settings */ $title = apply_filters( 'widget_title', $instance['title'] ); $use_gravatar = $instance['use_gravatar']; $gravatar_user_id = $instance['gravatar_user_id']; $gravatar_size = $instance['gravatar_size']; $image_url = $instance['image_url']; $image_alt_text = $instance['image_alt_text']; $image_link = $instance['image_link']; $new_window = $instance['new_window']; $widget_plugin = $instance['widget_plugin']; $logo_location = $instance['logo_location']; if ( ! $widget_plugin ) { /** @var $before_widget string - define by theme */ echo $before_widget; /* Title of widget (before and after defined by themes). */ if ( $title ) { /** * @var $before_title string - defined by theme * @var $after_title string - defined by theme */ echo $before_title . $title . $after_title; } /** End if - title */ /** Display image based on widget settings */ ?>
__( 'My Logo Image', 'bns-cl' ), 'use_gravatar' => false, 'gravatar_user_id' => '1', 'gravatar_size' => '96', 'image_url' => '', 'image_alt_text' => '', 'image_link' => '', 'new_window' => false, 'widget_plugin' => false, 'logo_location' => 'Bottom-Right' ); $instance = wp_parse_args( ( array ) $instance, $defaults ); ?>
id="get_field_id( 'use_gravatar' ); ?>" name="get_field_name( 'use_gravatar' ); ?>" />
id="get_field_id( 'new-window' ); ?>" name="get_field_name( 'new_window' ); ?>" />
id="get_field_id( 'widget_plugin' ); ?>" name="get_field_name( 'widget_plugin' ); ?>" />