Evolved_Twitter_Widget

The Evolved Evolved Twitter Widget class.

Defined (1)

The class is defined in the following location(s).

/admin/widgets/twitter-widget.php  
  1. class Evolved_Twitter_Widget extends WP_Widget { 
  2.  
  3. /** 
  4. * Widget setup. 
  5. */ 
  6. function Evolved_Twitter_Widget() { 
  7. /** Widget settings. */ 
  8. $widget_ops = array( 'classname' => 'evolved_twitter_widget', 'description' => __('A widget that displays your latest tweets', 'evolved_twitter_widget') ); 
  9.  
  10. /** Widget control settings. */ 
  11. $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'evolved_twitter_widget' ); 
  12.  
  13. /** Create the widget. */ 
  14. $this->WP_Widget( 'evolved_twitter_widget', __('Evolved: Twitter Stream', 'evolved_twitter_widget'), $widget_ops, $control_ops ); 
  15.  
  16. /** 
  17. * How to display the widget on the screen. 
  18. */ 
  19. function widget( $args, $instance ) { 
  20. extract( $args ); 
  21.  
  22. /** Our variables from the widget settings. */ 
  23. $title = apply_filters('widget_title', $instance['title'] ); 
  24. $username = $instance['username']; 
  25. $number = $instance['number']; 
  26. $text = $instance['text']; 
  27.  
  28. /** Before widget (defined by themes). */ 
  29. echo $before_widget; 
  30. echo '<div class="widget twitter-feed">'; 
  31.  
  32. /** Display the widget title if one was input (before and after defined by themes). */ 
  33. if ( $title ) 
  34. echo $before_title . $title . $after_title; 
  35.  
  36. ?> 
  37.  
  38. <div class="tweet" id="twitter_div"> 
  39. <ul id="twitter_update_list"></ul> 
  40. </div> 
  41. <a href="http://twitter.com/<?php echo $username ?>" id="twitter-link"><?php echo $text ?></a> 
  42. <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script> 
  43. <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/<?php echo $username ?>.json?callback=twitterCallback2&count=<?php echo $number ?>"></script> 
  44.  
  45.  
  46. <?php 
  47.  
  48. /** After widget (defined by themes). */ 
  49. echo '</div>'; 
  50. echo $after_widget; 
  51.  
  52. /** 
  53. * Update the widget settings. 
  54. */ 
  55. function update( $new_instance, $old_instance ) { 
  56. $instance = $old_instance; 
  57.  
  58. /** Strip tags for title and name to remove HTML (important for text inputs). */ 
  59. $instance['title'] = strip_tags( $new_instance['title'] ); 
  60. $instance['username'] = strip_tags( $new_instance['username'] ); 
  61. $instance['number'] = strip_tags( $new_instance['number'] ); 
  62. $instance['text'] = strip_tags( $new_instance['text'] ); 
  63.  
  64. return $instance; 
  65.  
  66.  
  67. function form( $instance ) { 
  68.  
  69. /** Set up some default widget settings. */ 
  70. $defaults = array( 'title' => __('From Twitter', 'evolved'), 'number' => '3', 'text' => __('Follow us on Twitter', 'evolved')); 
  71. $instance = wp_parse_args( (array) $instance, $defaults ); ?> 
  72.  
  73. <!-- Widget Title: Text Input --> 
  74. <p> 
  75. <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'evolved'); ?></label> 
  76. <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:90%;" /> 
  77. </p> 
  78.  
  79. <!-- Twitter username --> 
  80. <p> 
  81. <label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php _e('Twitter username:', 'evolved'); ?></label> 
  82. <input id="<?php echo $this->get_field_id( 'username' ); ?>" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $instance['username']; ?>" style="width:90%;" /> 
  83. </p> 
  84.  
  85. <!-- Number of posts --> 
  86. <p> 
  87. <label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e('Number of tweets to show:', 'evolved'); ?></label> 
  88. <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>" size="3" /> 
  89. </p> 
  90.  
  91. <!-- Follow text --> 
  92. <p> 
  93. <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e('Follow Text:', 'evolved'); ?></label> 
  94. <input id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" value="<?php echo $instance['text']; ?>" style="width:90%;" /> 
  95. </p> 
  96.  
  97.  
  98. <?php