Changeset 1329022
- Timestamp:
- 01/15/2016 01:56:46 PM (10 years ago)
- File:
-
- 1 edited
-
banner-manager/trunk/widget.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
banner-manager/trunk/widget.php
r1328988 r1329022 3 3 class banner_widget extends WP_Widget 4 4 { 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 ); 9 11 } 10 12 11 13 function widget($args, $instance) { 12 14 extract( $args ); 15 echo $args['before_widget']; 13 16 $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 } 14 20 echo '<div style="text-align: center" class="widget widget-banner-manager">'; 15 21 wp_banner_manager( $category ); 16 22 echo '</div>'; 23 echo $args['after_widget']; 17 24 } 18 25 … … 20 27 $instance = $old_instance; 21 28 $instance['category'] = strip_tags($new_instance['category']); 29 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 22 30 return $instance; 23 31 } 24 32 25 33 function form($instance) { 34 $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; 26 35 $selected_category = isset($instance['category'])? esc_attr($instance['category']) : 0; 27 36 28 37 $categories = data::get_categories(); 29 38 ?> 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> 30 43 <p> 31 44 <label for="<?php echo $this->get_field_id('category'); ?>"> 32 <?php _e('Category' ); ?>45 <?php _e('Category', 'banner-manager'); ?> 33 46 <?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'); ?>"> 35 48 <?php foreach($categories as $category): ?> 36 49 <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.