Advertisement
Guest User

MagPress Twitter Widget PHP

a guest
Jan 24th, 2013
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.58 KB | None | 0 0
  1. class My_THEME_Twitter_Widget extends WP_Widget {
  2. function My_THEME_Twitter_Widget() {
  3. //Constructor
  4. parent::WP_Widget(false, $name = TEMPLATE_DOMAIN . ' | Twitter', array(
  5. 'description' => __('Display your latest twitter.', TEMPLATE_DOMAIN)
  6. ));
  7. }
  8.  
  9. function widget($args, $instance) {
  10. // outputs the content of the widget
  11. extract($args); // Make before_widget, etc available.
  12.  
  13. $twitter_username = $instance['twitter_username'];
  14. $twitter_count = $instance['twitter_count'];
  15.  
  16. $twitter_title = empty($instance['title']) ? __('Twitter', TEMPLATE_DOMAIN) : apply_filters('widget_title', $instance['title']);
  17. $unique_id = $args['widget_id'];
  18.  
  19. echo $before_widget;
  20. echo $before_title . $twitter_title . $after_title; ?>
  21. <ul class="twitterbox" id="twitter_update_list_<?php echo $unique_id; ?>">
  22. <?php echo theme_twitter_js_handler($unique_id,$twitter_username,$twitter_count); //Javascript output function ?>
  23. <li class="followme"><?php echo '<a style="font-weight: normal; letter-spacing: normal; font-size: 11px;" href="http://twitter.com/' . $twitter_username . '">'; ?><?php printf( __( 'Follow %1$s in Twitter', TEMPLATE_DOMAIN ), ucfirst($twitter_username) ); ?><?php echo '</a>'; ?>
  24. </li>
  25. </ul>
  26.  
  27.  
  28.  
  29. <?php echo $after_widget;
  30. }
  31.  
  32. function update($new_instance, $old_instance) {
  33. //update and save the widget
  34. return $new_instance;
  35. }
  36.  
  37. function form($instance) {
  38. // Get the options into variables, escaping html characters on the way
  39. $twitter_username = $instance['twitter_username'];
  40. $twitter_title = $instance['title'];
  41. $twitter_count = $instance['twitter_count'];
  42. ?>
  43.  
  44. <p>
  45. <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e("Twitter Title:",TEMPLATE_DOMAIN); ?></label>
  46. <input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $twitter_title; ?>" />
  47. </p>
  48.  
  49. <p><label for="<?php echo $this->get_field_id('twitter_username'); ?>">
  50. <?php echo __('Twitter ID:', TEMPLATE_DOMAIN)?></label>
  51. <input class="widefat" type="text" id="<?php echo $this->get_field_id('twitter_username'); ?>" name="<?php echo $this->get_field_name('twitter_username'); ?>" value="<?php echo $twitter_username; ?>" />
  52. </p>
  53. <p>
  54. <label for="<?php echo $this->get_field_id('twitter_count'); ?>"><?php echo __('Number Of Tweets:', TEMPLATE_DOMAIN)?></label>
  55. <input class="widefat" type="text" id="<?php echo $this->get_field_id('twitter_count'); ?>" name="<?php echo $this->get_field_name('twitter_count'); ?>" value="<?php echo $twitter_count; ?>" />
  56. </p>
  57.  
  58. <?php
  59. }
  60. }
  61. register_widget('My_THEME_Twitter_Widget');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement