Plugin Directory

Changeset 1329022


Ignore:
Timestamp:
01/15/2016 01:56:46 PM (10 years ago)
Author:
karrikas
Message:

Fixed widget class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • banner-manager/trunk/widget.php

    r1328988 r1329022  
    33class banner_widget extends WP_Widget
    44{
    5     public function banner_widget()
    6     {
    7         $widget_ops = array('description' => __( "Your banners", 'banner-manager' ) );
    8         parent::WP_Widget(false, $name = 'Banners', $widget_ops);
     5    public function __construct() {
     6        $widget_ops = array(
     7            'class_name' => 'banner_widget',
     8            'description' => __( "Your banners", 'banner-manager' ),
     9        );
     10        parent::__construct( 'banner_widget', 'Banner Manager', $widget_ops );
    911    }
    1012
    1113    function widget($args, $instance) {
    1214        extract( $args );
     15        echo $args['before_widget'];
    1316        $category = apply_filters('widget_title', $instance['category']);
     17        if ( ! empty( $instance['title'] ) ) {
     18            echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
     19        }
    1420        echo '<div style="text-align: center" class="widget widget-banner-manager">';
    1521        wp_banner_manager( $category );
    1622        echo '</div>';
     23        echo $args['after_widget'];
    1724    }
    1825
     
    2027        $instance = $old_instance;
    2128        $instance['category'] = strip_tags($new_instance['category']);
     29        $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
    2230        return $instance;
    2331    }
    2432
    2533    function form($instance) {
     34        $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
    2635        $selected_category = isset($instance['category'])? esc_attr($instance['category']) : 0;
    2736
    2837        $categories = data::get_categories();
    2938        ?>
     39        <p>
     40            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'banner-manager'); ?></label>
     41            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
     42        </p>
    3043            <p>
    3144                <label for="<?php echo $this->get_field_id('category'); ?>">
    32                     <?php _e('Category'); ?>
     45                    <?php _e('Category', 'banner-manager'); ?>
    3346                    <?php if($categories):?>
    34                     <select name="<?php echo $this->get_field_name('category'); ?>">
     47                    <select class="widefat" name="<?php echo $this->get_field_name('category'); ?>">
    3548                        <?php foreach($categories as $category): ?>
    3649                        <option value="<?php echo $category->id; ?>" <?php echo ($selected_category==$category->id)? 'selected="selected"' : '';?>><?php echo $category->groups; ?></option>
Note: See TracChangeset for help on using the changeset viewer.