Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class My_THEME_Twitter_Widget extends WP_Widget {
- function My_THEME_Twitter_Widget() {
- //Constructor
- parent::WP_Widget(false, $name = TEMPLATE_DOMAIN . ' | Twitter', array(
- 'description' => __('Display your latest twitter.', TEMPLATE_DOMAIN)
- ));
- }
- function widget($args, $instance) {
- // outputs the content of the widget
- extract($args); // Make before_widget, etc available.
- $twitter_username = $instance['twitter_username'];
- $twitter_count = $instance['twitter_count'];
- $twitter_title = empty($instance['title']) ? __('Twitter', TEMPLATE_DOMAIN) : apply_filters('widget_title', $instance['title']);
- $unique_id = $args['widget_id'];
- echo $before_widget;
- echo $before_title . $twitter_title . $after_title; ?>
- <ul class="twitterbox" id="twitter_update_list_<?php echo $unique_id; ?>">
- <?php echo theme_twitter_js_handler($unique_id,$twitter_username,$twitter_count); //Javascript output function ?>
- <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>'; ?>
- </li>
- </ul>
- <?php echo $after_widget;
- }
- function update($new_instance, $old_instance) {
- //update and save the widget
- return $new_instance;
- }
- function form($instance) {
- // Get the options into variables, escaping html characters on the way
- $twitter_username = $instance['twitter_username'];
- $twitter_title = $instance['title'];
- $twitter_count = $instance['twitter_count'];
- ?>
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e("Twitter Title:",TEMPLATE_DOMAIN); ?></label>
- <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; ?>" />
- </p>
- <p><label for="<?php echo $this->get_field_id('twitter_username'); ?>">
- <?php echo __('Twitter ID:', TEMPLATE_DOMAIN)?></label>
- <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; ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('twitter_count'); ?>"><?php echo __('Number Of Tweets:', TEMPLATE_DOMAIN)?></label>
- <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; ?>" />
- </p>
- <?php
- }
- }
- register_widget('My_THEME_Twitter_Widget');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement