|
1 <?php |
|
2 class ocmx_twitter_widget extends WP_Widget { |
|
3 /** constructor */ |
|
4 function ocmx_twitter_widget() { |
|
5 parent::WP_Widget(false, $name = 'OCMX Twitter Stream', $widget_options = 'Display your latest Flickr Photos.', $control_options ="TESTTESTETETETETE"); |
|
6 } |
|
7 |
|
8 /** @see WP_Widget::widget */ |
|
9 function widget($args, $instance) { |
|
10 extract( $args ); |
|
11 $twitter_key = $instance["twitter_id"]; |
|
12 $twitter_count = $instance["twitter_count"]; |
|
13 $twitter_src = "http://twitter.com/statuses/user_timeline/".$twitter_key.".json?callback=twitterCallback2&count=".$twitter_count; |
|
14 ?> |
|
15 <?php echo $before_widget; ?> |
|
16 <?php echo $before_title?> |
|
17 <a href="http://twitter.com/<?php echo $twitter_key; ?>" target="_blank" rel="nofollow"> |
|
18 <?php echo $instance['title']; ?> |
|
19 </a> |
|
20 <?php echo $after_title; ?> |
|
21 <ul id="twitter_update_list" class="rc_list"> |
|
22 <li>...loading Twitter Stream</li> |
|
23 </ul> |
|
24 <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script> |
|
25 <script type="text/javascript" src="<?php echo $twitter_src ?>"></script> |
|
26 <?php echo $after_widget; ?> |
|
27 <?php |
|
28 } |
|
29 |
|
30 /** @see WP_Widget::update */ |
|
31 function update($new_instance, $old_instance) { |
|
32 return $new_instance; |
|
33 } |
|
34 |
|
35 /** @see WP_Widget::form */ |
|
36 function form($instance) { |
|
37 $title = esc_attr($instance["title"]); |
|
38 $twitter_id = esc_attr($instance["twitter_id"]); |
|
39 $twitter_count = esc_attr($instance["twitter_count"]); |
|
40 |
|
41 ?> |
|
42 <p><label for="<?php echo $this->get_field_id('title'); ?>">Title<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; ?>" /></label></p> |
|
43 <p><label for="<?php echo $this->get_field_id('twitter_id'); ?>">Twitter ID<input class="widefat" id="<?php echo $this->get_field_id('twitter_id'); ?>" name="<?php echo $this->get_field_name('twitter_id'); ?>" type="text" value="<?php echo $twitter_id; ?>" /></label></p> |
|
44 <p> |
|
45 <label for="<?php echo $this->get_field_id('twitter_count'); ?>">Tweet Count |
|
46 <select size="1" class="widefat" id="<?php echo $this->get_field_id('twitter_count'); ?>" name="<?php echo $this->get_field_name('twitter_count'); ?>"> |
|
47 <option <?php if($twitter_count == "1") : ?>selected="selected"<?php endif; ?> value="1">1</option> |
|
48 <option <?php if($twitter_count == "2") : ?>selected="selected"<?php endif; ?> value="2">2</option> |
|
49 <option <?php if($twitter_count == "4") : ?>selected="selected"<?php endif; ?> value="4">4</option> |
|
50 <option <?php if($twitter_count == "6") : ?>selected="selected"<?php endif; ?> value="6">6</option> |
|
51 <option <?php if($twitter_count == "8") : ?>selected="selected"<?php endif; ?> value="8">8</option> |
|
52 <option <?php if($twitter_count == "10") : ?>selected="selected"<?php endif; ?> value="10">10</option> |
|
53 </select> |
|
54 </p> |
|
55 <?php |
|
56 } |
|
57 |
|
58 } // class FooWidget |
|
59 |
|
60 //This sample widget can then be registered in the widgets_init hook: |
|
61 |
|
62 // register FooWidget widget |
|
63 add_action('widgets_init', create_function('', 'return register_widget("ocmx_twitter_widget");')); |
|
64 |
|
65 ?> |