Plugin Directory

Changeset 739242


Ignore:
Timestamp:
07/11/2013 03:55:49 PM (12 years ago)
Author:
prasannasp
Message:

Made plugin compatible with Twitter API 1.1, not ready to release for the public yet

Location:
twiget/trunk
Files:
8 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • twiget/trunk/css/twiget.css

    r652292 r739242  
    1 .twiget-widget ul li {
    2     border-bottom: 1px solid #E3E3E3;
    3     padding: 6px 0;
     1#twiget-feed {
     2    margin: auto;
     3    padding: 5px 5px 5px 0px;
     4    overflow:auto;
     5}
     6.twiget-article {
     7    border-bottom: 1px solid #CCC;
     8    float:left;
     9    padding: 5px 0px;
     10}
     11#twiget-ajax-loading {
     12    padding: 5px 0px;
     13    text-align: center;
     14}
     15.twiget-pic {
     16    float: left;
     17}
     18 
     19.twiget-pic img {
     20    float: left;
     21    border-radius: 5px;
     22    border: none;
     23    margin-right: 5px;
     24 
     25}
     26
     27.twiget-status {
     28    display: block;
     29}
     30 
     31.twiget-text {
     32    padding: 3px 0;
     33    float: left;
     34}
     35 
     36.twiget-time {
     37    font-size: 10px;
     38    float: left;
    439}
    540
    641#twigetfollow {
    7     margin-top: 10px;
     42    margin-top: 5px;
    843    text-align: right;
    944}
  • twiget/trunk/readme.txt

    r652292 r739242  
    44Tags: twitter, widget, tweets, twitter widget, sidebar
    55Requires at least: 2.5
    6 Tested up to: 3.5
     6Tested up to: 3.6
    77Stable tag: 1.0
    88License: GPLv3
     
    2121* Option to show followers count
    2222* Option to open links in a new window
    23 * Option to hide @replies
     23* Option to show twitter client used. Eg: via Twitter for Android
    2424* Linkified @usernames
    2525* Linkified #hashtags
    2626
    27 TwiGet is a clone of the Twitter Widget in the [Graphene Theme](http://wordpress.org/extend/themes/graphene/) developed by [Syahir Hakim](http://www.khairul-syahir.com/). The plugin is developed by [Prasanna SP](http://www.prasannasp.net/).
     27TwiGet is a clone of the Twitter Widget in the [Graphene Theme](http://www.graphene-theme.com/) developed by [Syahir Hakim](http://www.khairul-syahir.com/). The plugin is developed by [Prasanna SP](http://www.prasannasp.net/).
    2828
    2929**Translation**: If you want to translate this plugin to your language, please find the twiget.pot file in /languages/ folder.
     
    3535Visit [this page](http://www.prasannasp.net/wordpress-plugins/) for more **WordPress Plugins** by the developer.
    3636
     37This plugin uses Abraham's [twitteroauth library] (https://github.com/abraham/twitteroauth‎/).
     38
    3739== Installation ==
    3840
    39411. Upload `twiget` folder to the `/wp-content/plugins/` directory
    40 1. Activate the plugin through the 'Plugins' menu in WordPress
    41 1. Go to Appearance --> Widgets and add TwiGet Twitter Widget to any of the widgetized areas
     422. Activate the plugin through the 'Plugins' menu in WordPress
     433. Go to Settings --> Twiget Settings and enter your twitter username, number of tweets to show and Twitter API Credentials
     444. Go to Appearance --> Widgets and add TwiGet Twitter Widget to any of the widgetized areas
    4245
    4346== Frequently asked questions ==
     
    4750Post your questions or report issue in the [support forum](http://forum.prasannasp.net/forum/plugin-support/twiget/). You can directly contact the developer using this [contact form](http://www.prasannasp.net/contact/).
    4851
    49 = How to style the widget? =
    50 
    51 The widget is bundled with a stylesheet. If you want to use your own styles, dequeue `twiget-widget-css` and then style it using `.twiget-widget` css class. The follow @ button is wrapped in twigetfollow ID. So, use `#twigetfollow` in your Custom CSS to style it.
    52 
    53 Dequeuing bundled stylesheet:
    54 
    55 `wp_dequeue_style( 'twiget-widget-css' );`
    56 
    5752== Screenshots ==
    5853
    59 1. TwiGet Twitter Widget configuration
    60 2. TwiGet Twitter Widget in twentytwelve theme
    61 3. TwiGet Twitter Widget in Graphene Theme
     541. TwiGet Twitter Widget with profile picture and username in Graphene Theme
     552. TwiGet Twitter Widget without profile picture and username in Graphene Theme
     563. TwiGet Twitter Widget in twentytwelve theme
     574. Twiget Twitter Plugin Settings
     585. TwiGet Twitter Widget configuration
    6259
    6360== Changelog ==
     61
     62= 1.1 =
     63
     64* Made the plugin compatible with Twitter API 1.1
     65* Added option to show profile picture, username, twitter client used along with each tweet
    6466
    6567= 1.0 =
  • twiget/trunk/twiget.php

    r652292 r739242  
    22/*
    33Plugin Name: TwiGet Twitter Widget
    4 Plugin URI: http://www.prasannasp.net/wordpress-plugins/twiget-twitter-widget/
     4Plugin URI: http://www.prasannasp.net/wordpress-plugins/twiget/
    55Description: A widget to display the latest Twitter status updates.
    66Author: Prasanna SP
    7 Version: 1.0
     7Version: 1.1
    88Author URI: http://www.prasannasp.net/
    99*/
     
    3030
    3131function load_twiget_plugin_textdomain() {
    32   load_plugin_textdomain( 'twiget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
     32  load_plugin_textdomain( 'twiget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    3333}
    3434add_action('plugins_loaded', 'load_twiget_plugin_textdomain');
     35
     36define( 'TWIGET_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
     37require_once TWIGET_PLUGIN_PATH . 'twiget-functions.php';
     38require_once TWIGET_PLUGIN_PATH . 'twiget-options-form.php';
    3539
    3640/**
    3741 * Register custom Twitter widgets.
    3842*/
    39 global $twiget_username;
    40 global $twiget_tweetcount;
    41 $twiget_username = '';
    42 $twiget_tweetcount = 1;
    4343
    4444class Twiget_Twitter_Widget extends WP_Widget{
     
    5353        // Create the widget
    5454        $this->WP_Widget( 'twiget-widget', 'TwiGet Twitter Widget', $widget_ops, $control_ops);
    55        
    56         /* Enqueue the twitter script and css if widget is active */
    57         if ( is_active_widget( false, false, $this->id_base, true ) && ! is_admin() )
    58             wp_enqueue_script( 'twiget-widget-js', plugins_url( '/js/twitter.js' , __FILE__ ), array(), '', false );
    59             wp_enqueue_style( 'twiget-widget-css', plugins_url( '/css/twiget.css' , __FILE__ ), array(), '', false );
     55           
    6056    }
    6157   
    6258    function widget( $args, $instance ){        // This function displays the widget
    6359        extract( $args );
    64 
    65         // User selected settings
    66         global $twiget_username;
    67         global $twiget_tweetcount;
    68         global $twiget_followercount;
    69         global $twiget_hide_replies;
    70         global $twiget_twitter_newwindow;
     60   
     61        $twiget_options = get_option('twiget_options');
     62        $twiget_username = $twiget_options['user_name'];
     63        if (isset($twiget_options['followers_count'])) { $followers_count = $twiget_options['followers_count']; }
    7164
    7265        $twiget_title = apply_filters( 'twiget_widget_title', empty($instance['twiget_title']) ? __( 'Latest tweets', 'twiget' ) : $instance['twiget_title'], $instance, $this->id_base);   
    73         $twiget_username = $instance['twiget_username'];
    74         $twiget_tweetcount = $instance['twiget_tweetcount'];
    75         $twiget_followercount = $instance['twiget_followercount'];
    76         $twiget_hide_replies = ( array_key_exists( 'twiget_hide_replies', $instance ) ) ? $instance['twiget_hide_replies'] : false ;
    77         $twiget_new_window = $instance['twiget_new_window'];
    78         $twiget_twitter_newwindow = $twiget_new_window;
     66       
    7967        $wrapper_id = 'tweet-wrap-' . $args['widget_id'];
    8068       
    81         $twiget_follower_count_attr = ( $twiget_followercount ) ? 'data-show-count="true"' : 'data-show-count="false"';
    82         $hide_replies_attr = ( $twiget_hide_replies ) ? 'exclude_replies=true' : 'exclude_replies=false';
    83        
     69        $twiget_follower_count_attr = (isset($followers_count) == 1) ? 'data-show-count="true"' : 'data-show-count="false"';
     70
    8471        echo $args['before_widget'].$args['before_title'].$twiget_title.$args['after_title'];
    8572        ?>
    86             <ul id="<?php echo $wrapper_id; ?>">
    87                 <li><img src="<?php echo '' .plugins_url( '/images/ajax-loader.gif' , __FILE__ ). ''; ?>" width="16" height="16" alt="" /> <?php _e( 'Loading tweets...', 'twiget' ); ?></li>
    88             </ul>
    89             <p id="twigetfollow">
    90                 <a href="https://twitter.com/<?php echo $twiget_username; ?>" class="twitter-follow-button" <?php echo $twiget_follower_count_attr; ?> data-width="100%" data-align="right"><?php printf( __( 'Follow %s', 'twiget' ), '@' . $twiget_username ); ?></a>
    91             <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
    92             </p>
    93            
    94             <script src="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=<?php echo $twiget_username; ?>&count=<?php echo $twiget_tweetcount; ?>&page=1&include_rts=true&<?php echo $hide_replies_attr; ?>&include_entities=true&callback=twigetGetTweet" type="text/javascript"></script>
    95             <script type="text/javascript">             
    96                 twigetTwitter( '<?php echo $wrapper_id; ?>',
    97                                     {
    98                                         <?php if ( $twiget_new_window ) echo 'newwindow: true,' ?>
    99                                         id: '<?php echo $twiget_username; ?>',
    100                                         count: <?php echo $twiget_tweetcount; ?>
    101                                     });
    102             </script>
    103            
     73            <div id="twiget-feed"></div>
     74             <p id="twigetfollow">
     75<a href="https://twitter.com/<?php echo $twiget_username; ?>" class="twitter-follow-button" <?php echo $twiget_follower_count_attr; ?> data-width="100%" data-align="right"><?php printf( __( 'Follow %s', 'twiget' ), '@' . $twiget_username ); ?></a>
     76<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
     77</p>
    10478            <?php do_action( 'twiget_twitter_widget' ); ?>
    10579        <?php echo $args['after_widget']; ?>
     
    11286       
    11387        // Strip tags (if needed) and update the widget settings
    114         $instance['twiget_username'] = strip_tags( $new_instance['twiget_username']);
    115         $instance['twiget_tweetcount'] = strip_tags( $new_instance['twiget_tweetcount']);
    11688        $instance['twiget_title'] = strip_tags( $new_instance['twiget_title'] );
    117         $instance['twiget_followercount'] = ( isset( $new_instance['twiget_followercount'] ) ) ? true : false ;
    118         $instance['twiget_hide_replies'] = ( isset( $new_instance['twiget_hide_replies'] ) ) ? true : false ;
    119         $instance['twiget_new_window'] = ( isset( $new_instance['twiget_new_window'] ) ) ? true : false ;
    12089   
    12190        return $instance;
     
    12594       
    12695        // Set up default widget settings
    127         $defaults = array( 'twiget_username' => '',
    128                         'twiget_tweetcount' => 5,
    129                         'twiget_title' => __( 'Latest tweets', 'twiget' ),
    130                         'twiget_followercount' => false,
    131                         'twiget_hide_replies' => false,
    132                         'twiget_new_window' => false,
    133                         );
     96        $defaults = array( 'twiget_title' => __( 'Latest tweets', 'twiget' ) );
    13497        $instance = wp_parse_args( (array) $instance, $defaults );
    13598        ?>
    13699        <p>
    137             <label for="<?php echo $this->get_field_id( 'twiget_title' ); ?>"><?php _e( 'Title:', 'twiget' ); ?></label>
     100            <label for="<?php echo $this->get_field_id( 'twiget_title' ); ?>"><?php _e( 'Widget Title:', 'twiget' ); ?></label>
    138101            <input id="<?php echo $this->get_field_id( 'twiget_title' ); ?>" type="text" name="<?php echo $this->get_field_name( 'twiget_title' ); ?>" value="<?php echo $instance['twiget_title']; ?>" class="widefat" />
    139         </p>
    140         <p>
    141             <label for="<?php echo $this->get_field_id( 'twiget_username' ); ?>"><?php _e( 'Twitter Username:', 'twiget' ); ?></label>
    142             <input id="<?php echo $this->get_field_id( 'twiget_username' ); ?>" type="text" name="<?php echo $this->get_field_name( 'twiget_username' ); ?>" value="<?php echo $instance['twiget_username']; ?>" class="widefat" />
    143         </p>
    144         <p>
    145             <label for="<?php echo $this->get_field_id( 'twiget_tweetcount' ); ?>"><?php _e( 'Number of tweets to display:', 'twiget' ); ?></label>
    146             <input id="<?php echo $this->get_field_id( 'twiget_tweetcount' ); ?>" type="text" name="<?php echo $this->get_field_name( 'twiget_tweetcount' ); ?>" value="<?php echo $instance['twiget_tweetcount']; ?>" size="1" />
    147         </p>
    148         <p>
    149             <label for="<?php echo $this->get_field_id( 'twiget_followercount' ); ?>"><?php _e( 'Show followers count', 'twiget' ); ?></label>
    150             <input id="<?php echo $this->get_field_id( 'twiget_followercount' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'twiget_followercount' ); ?>" value="true" <?php checked( $instance['twiget_followercount'] ); ?> />
    151         </p>
    152          <p>
    153             <label for="<?php echo $this->get_field_id( 'twiget_hide_replies' ); ?>"><?php _e( 'Hide @replies', 'twiget' ); ?></label>
    154             <input id="<?php echo $this->get_field_id( 'twiget_hide_replies' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'twiget_hide_replies' ); ?>" value="true" <?php checked( $instance['twiget_hide_replies'] ); ?> /><br />
    155             <span class="description"><?php $showtweetcount = $instance['twiget_tweetcount']; printf( __('Note: Selecting this sometimes result in showing less than %s tweets', 'twiget' ), $showtweetcount ); ?></span>
    156         </p>
    157         <p>
    158             <label for="<?php echo $this->get_field_id( 'twiget_new_window' ); ?>"><?php _e( 'Open links in new window', 'twiget' ); ?></label>
    159             <input id="<?php echo $this->get_field_id( 'twiget_new_window' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'twiget_new_window' ); ?>" value="true" <?php checked( $instance['twiget_new_window'] ); ?> />
    160102        </p>
    161103        <?php
    162104    }
    163105}
    164 
    165106
    166107/**
     
    173114add_action( 'widgets_init', 'twiget_load_widgets' );
    174115
    175 // Display a Support forum link on the main Plugins page
    176 function twiget_plugin_action_links( $links, $file ) {
     116/*
     117** Thanks David Gwyer for Plugin Options Starter Kit plugin!
     118*/
    177119
    178     if ( $file == plugin_basename( __FILE__ ) ) {
    179         $twiget_link = '<a href="http://forum.prasannasp.net/forum/plugin-support/twiget/" title="'.esc_attr__('TwiGet Twitter Widget support', 'twiget').'" target="_blank">'.__('Support', 'twiget').'</a>';
     120// Delete options table entries ONLY when plugin deactivated AND deleted
     121function twiget_delete_plugin_options() {
     122    delete_option('twiget_options');
     123}
     124register_uninstall_hook(__FILE__, 'twiget_delete_plugin_options');
    180125
    181         array_unshift( $links, $twiget_link );
     126// Define default option settings
     127function twiget_add_defaults() {
     128    $tmp = get_option('twiget_options');
     129    if(($tmp['twiget_default_options_db']=='1')||(!is_array($tmp))) {
     130        delete_option('twiget_options');
     131        $arr = array(   "link_target" => "1",
     132                "show_client" => "1",
     133                "twiget_default_options_db" => ""
     134        );
     135        update_option('twiget_options', $arr);
    182136    }
     137}
     138register_activation_hook(__FILE__, 'twiget_add_defaults');
    183139
    184     return $links;
     140// Init plugin options to white list our options
     141function twiget_init() {
     142    register_setting( 'twiget_plugin_options', 'twiget_options', 'twiget_validate_options' );
    185143}
    186 add_filter('plugin_action_links', 'twiget_plugin_action_links', 10, 2 );
     144add_action('admin_init', 'twiget_init' );
     145
     146// Add menu page
     147function twiget_add_options_page() {
     148    add_options_page('Twiget Twitter Plugin Settings', 'Twiget Settings', 'manage_options', __FILE__, 'twiget_render_form');
     149}
     150add_action('admin_menu', 'twiget_add_options_page');
     151
     152// Sanitize and validate input. Accepts an array, return a sanitized array.
     153function twiget_validate_options($input) {
     154     // strip html from textboxes
     155    $input['user_name'] =  wp_filter_nohtml_kses($input['user_name']); // Sanitize textbox input (strip html tags, and escape characters)
     156    $input['tweet_count'] =  wp_filter_nohtml_kses($input['tweet_count']);
     157    $input['consumer_key'] =  wp_filter_nohtml_kses($input['consumer_key']);
     158    $input['consumer_secret'] =  wp_filter_nohtml_kses($input['consumer_secret']);
     159    $input['access_token'] =  wp_filter_nohtml_kses($input['access_token']);
     160    $input['access_token_secret'] =  wp_filter_nohtml_kses($input['access_token_secret']);
     161    return $input;
     162}
    187163
    188164// Donate link on manage plugin page
    189165function twiget_pluginspage_links( $links, $file ) {
    190166
    191 $plugin = plugin_basename(__FILE__);
     167$plugin = plugin_basename (__FILE__);
    192168
    193169// create links
     
    205181    }
    206182add_filter( 'plugin_row_meta', 'twiget_pluginspage_links', 10, 2 );
    207 ?>
     183
     184// Display a Support forum link on the main Plugins page
     185function twiget_plugin_action_links( $links, $file ) {
     186
     187    if ( $file == plugin_basename( __FILE__ ) ) {
     188        $twiget_link1 = '<a href="http://forum.prasannasp.net/forum/plugin-support/twiget/" title="'.esc_attr__('TwiGet Twitter Widget support', 'twiget').'" target="_blank">'.__('Support', 'twiget').'</a>';
     189        $twiget_link2 = '<a href="'.get_admin_url().'options-general.php?page=twiget/twiget.php">'.__('Settings', 'twiget').'</a>';
     190
     191        array_unshift( $links, $twiget_link1, $twiget_link2 );
     192    }
     193
     194    return $links;
     195}
     196add_filter('plugin_action_links', 'twiget_plugin_action_links', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.