1 | <?php |
---|
2 | |
---|
3 | class example_widget extends WP_Widget { |
---|
4 | public function __construct() { |
---|
5 | $widget_ops = array('classname' => 'My_Widget', 'description' => My widget demonstration' ); |
---|
6 | $this->WP_Widget('My_Widget', 'My Widget', $widget_ops); |
---|
7 | } |
---|
8 | |
---|
9 | function update($new_instance, $old_instance) { |
---|
10 | $instance = $old_instance; |
---|
11 | |
---|
12 | $instance['title'] = strip_tags(stripslashes($new_instance['title'])); |
---|
13 | $instance['message'] = $new_instance['message']; |
---|
14 | |
---|
15 | return $instance; |
---|
16 | } |
---|
17 | |
---|
18 | function form($instance) { |
---|
19 | $defaults = array( |
---|
20 | 'title' => 'My Widget', |
---|
21 | 'message' => '<i class="icon"></i> This I tag is the source of the problem' |
---|
22 | ); |
---|
23 | |
---|
24 | $instance = wp_parse_args($instance, $defaults); |
---|
25 | |
---|
26 | $title = esc_attr($instance['title']); |
---|
27 | $message = esc_attr($instance['message']); |
---|
28 | |
---|
29 | ?> |
---|
30 | <p> |
---|
31 | <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> |
---|
32 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> |
---|
33 | </p> |
---|
34 | <p> |
---|
35 | <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Message'); ?></label> |
---|
36 | <input class="widefat" id="<?php echo $this->get_field_id('message'); ?>" name="<?php echo $this->get_field_name('message'); ?>" type="text" value="<?php echo $message; ?>" /> |
---|
37 | </p> |
---|
38 | <?php |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | ?> |
---|