Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- /* ---------------------------- */
- /* -------- Twitter Feeds Widget -------- */
- /* ---------------------------- */
- add_action( 'widgets_init', 'trt_twt_widgets' );
- /*
- * Register widget.
- */
- function trt_twt_widgets() {
- register_widget( 'trt_twt_Widget' );
- }
- /*
- * Widget class.
- */
- class trt_twt_widget extends WP_Widget {
- /* ---------------------------- */
- /* -------- Widget setup -------- */
- /* ---------------------------- */
- function trt_twt_Widget() {
- /* Widget settings */
- $widget_ops = array( 'classname' => 'trt_twt_widget', 'description' => __('A Triton widget that displays the Twitter Feeds from your twitter account', 'Triton') );
- /* Widget control settings */
- /* Create the widget */
- $this->WP_Widget( 'trt_twt_widget', __('Twitter Feeds Widget', 'Triton'), $widget_ops );
- }
- /* ---------------------------- */
- /* ------- Display Widget -------- */
- /* ---------------------------- */
- function widget( $args, $instance ) {
- extract( $args );
- /* Our variables from the widget settings. */
- $title = apply_filters('widget_title', $instance['title'] );
- $count = $instance['count'];
- $cat = $instance['cat'];
- /* Before widget (defined by themes). */
- echo $before_widget;
- /* Display the widget title if one was input (before and after defined by themes). */
- if ( $title )
- echo $before_title . $title . $after_title;
- /* Display a containing div */
- echo '<div class="trt_twitter"><ul id="twitter_update_list"></ul><script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script><script type="text/javascript" src="http://twitter.com/statuses/user_timeline/' . $cat . '.json?callback=twitterCallback2&count=' . $count . '"></script>';
- echo '</div>';
- /* After widget (defined by themes). */
- echo $after_widget;
- }
- /* ---------------------------- */
- /* ------- Update Widget -------- */
- /* ---------------------------- */
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- /* Strip tags for title and name to remove HTML (important for text inputs). */
- $instance['title'] = strip_tags( $new_instance['title'] );
- /* No need to strip tags */
- $instance['count'] = $new_instance['count'];
- $instance['cat'] = $new_instance['cat'];
- return $instance;
- }
- /* ---------------------------- */
- /* ------- Widget Settings ------- */
- /* ---------------------------- */
- /**
- * Displays the widget settings controls on the widget panel.
- * Make use of the get_field_id() and get_field_name() function
- * when creating your form elements. This handles the confusing stuff.
- */
- function form( $instance ) {
- /* Set up some default widget settings. */
- $defaults = array(
- 'title' => '',
- 'count' => '5',
- 'cat' => 'towfiqi',
- );
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
- <!-- Widget Title: Text Input -->
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'Triton') ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
- </p>
- <!-- Category of Posts: Text Input -->
- <p>
- <label for="<?php echo $this->get_field_id( 'cat' ); ?>"><?php _e('Account ID:', 'Triton') ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id( 'cat' ); ?>" name="<?php echo $this->get_field_name( 'cat' ); ?>" value="<?php echo $instance['cat']; ?>" />
- </p>
- <!-- Number of Posts: Text Input -->
- <p>
- <label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e('Number of Posts:', 'Triton') ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" value="<?php echo $instance['count']; ?>" />
- </p>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement