Plugin Directory

Changeset 836605


Ignore:
Timestamp:
01/11/2014 11:20:10 AM (12 years ago)
Author:
mdjekic
Message:

Switching to version 2.0

Location:
inline-tweets
Files:
41 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • inline-tweets/trunk/inline-tweets.php

    r714432 r836605  
    1919// =============================================================================
    2020
     21// =============================================================================
     22// Plugin Main File
     23// =============================================================================
     24
    2125/*
    2226  Plugin Name: Inline Tweets
    23   Plugin URI: http://projects.djekic.net/inline-tweets
     27  Plugin URI: http://milos.djekic.net/my-software/inline-tweets
    2428  Description: Embed latest tweet(s) or a specific tweet in any page, post or text widget and apply your custom styles.
    25   Version: 1.1.2
     29  Version: 2.0
    2630  Author: Miloš Đekić
    2731  Author URI: http://milos.djekic.net
    2832 */
    2933
    30 // timeout in minutes for caching API responses
    31 define('INLINE_TWEETS_CACHE_TIMEOUT',5);
    32 
    33 /**
    34  * Determines time difference in minutes
    35  *
    36  * @param $to current time
    37  * @param $from starting point in time
    38  *
    39  * @return float
    40  */
    41 function inline_tweets_time_diff_in_minutes($to,$from) {
    42     return round(abs($to - $from) / 60,2);
     34// check if direct access attempted
     35if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF']))
     36{
     37    // forbid access
     38    header('HTTP/1.1 403 Forbidden');
     39    exit('Direct access not allowed.');
     40}
     41
     42// define inline tweets version
     43define('INLINE_TWEETS','2.0');
     44
     45// load configuration
     46$inline_tweets_config = json_decode(file_get_contents(__DIR__ . '/config.json'));
     47
     48// ---------------------------------------------------------------------------------------------------------------------
     49// Functions
     50// ---------------------------------------------------------------------------------------------------------------------
     51
     52/**
     53 * Loads options
     54 *
     55 * @return stdClass
     56 */
     57function inline_tweets_loadOptions()
     58{
     59    // load options from database
     60    $options = get_option('inline_tweets_options');
     61
     62    // render json
     63    $json = @json_decode($options);
     64
     65    // return options
     66    return ($json === false || empty($json)) ? new stdClass() : $json;
     67}
     68
     69/**
     70 * Saves options
     71 *
     72 * @param stdClass $options
     73 */
     74function inline_tweets_saveOptions($options)
     75{
     76    // update options in the database
     77    update_option('inline_tweets_options',json_encode($options));
    4378}
    4479
     
    4984 * @return string HTML
    5085 */
    51 function inline_tweets_inline_error($error = "Error") {
     86function inline_tweets_inline_error($error = "Error")
     87{
    5288    return '<div class="inline_tweets_error">'.$error.'</div>';
    5389}
    5490
    5591/**
    56  * Embeds tweet into an HTML entity
    57  *
    58  * @param $tweet
    59  * @return string HTML
    60  */
    61 function inline_tweets_embed_tweet($tweet) {
    62     // get tweet content
    63     $content = $tweet['text'];
    64 
    65     // append tweet author
    66     $content = '<a class="inline_tweets_author" href="http://twitter.com/'.$tweet['user']['screen_name'].'" target="_blank">'."@{$tweet['user']['screen_name']}".'</a> ' . $content;
    67 
    68     // render tags
    69     foreach($tweet["entities"]["hashtags"] as $tag) {
    70         $content = str_replace("#{$tag['text']}",'<span class="inline_tweets_tag">'."#{$tag['text']}".'</span>',$content);
    71     }
    72 
    73     // render URLs
    74     foreach($tweet["entities"]["urls"] as $url) {
    75         $content = str_replace($url["url"],'<a class="inline_tweets_url" href="'.$url["expanded_url"].'" target="_blank">'.$url["url"].'</a>',$content);
    76     }
    77 
    78     // render mentions
    79     foreach($tweet["entities"]["user_mentions"] as $mention) {
    80         $content = str_replace("@{$mention['screen_name']}",'<a class="inline_tweets_mention" href="http://twitter.com/'.$mention['screen_name'].'" target="_blank">'."@{$mention['screen_name']}".'</a>',$content);
    81     }
    82 
    83     // add timestamp
    84     $content .= ' <span class="inline_tweets_timestamp">' . date('M d',strtotime($tweet['created_at'])) . '</span>';
    85 
    86     // return rendered tweet content
    87     return $content;
    88 }
    89 
    90 /**
    91  * Performs a curl request to Twitter API to fetch tweet(s)
    92  *
    93  * @param $url
    94  * @return mixed
    95  */
    96 function inline_tweets_curl($url) {
    97     // init curl
    98     $ch = curl_init();
    99 
    100     // parametrize curl calls
    101     curl_setopt($ch, CURLOPT_URL,$url);
    102     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    103 
    104     // @since 1.0.1 - handle SSL issue
    105     curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
    106     curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
    107 
    108     // get result
    109     $result = curl_exec($ch);
    110 
    111     // close curl stream
    112     curl_close($ch);
     92 * Checks if Twitter is configured
     93 *
     94 * @param stdClass $options
     95 * @return bool
     96 */
     97function inline_tweets_twitterConfigured($options)
     98{
     99    // go trough all configuration items
     100    foreach(array('consumer_key','consumer_secret','oauth_token','oauth_token_secret') as $item)
     101    {
     102        // make sure item is present
     103        if(!isset($options->{$item})) return false;
     104
     105        // make sure item is not blank
     106        if(empty($options->{$item})) return false;
     107    }
     108
     109    // all configuration items are present
     110    return true;
     111}
     112
     113/**
     114 * Handles an inline tweet snippet
     115 *
     116 * @return stdClass result
     117 */
     118function inline_tweets_action_handleSnippet()
     119{
     120    // get snippet text
     121    $snippet_text = isset($_REQUEST['snippet']) ? $_REQUEST['snippet'] : '';
     122
     123    // init result
     124    $result = new stdClass();
     125
     126    // load options
     127    $options = inline_tweets_loadOptions();
     128
     129    // make sure Twitter is configured
     130    if(!inline_tweets_twitterConfigured($options))
     131    {
     132        // set error text
     133        $result->html = inline_tweets_inline_error('Inline Tweets not configured!');
     134
     135        // stop execution and return result
     136        return $result;
     137    }
     138
     139    // include dependencies
     140    include(__DIR__ . '/lib/twitteroauth/OAuth.php');
     141    include(__DIR__ . '/lib/twitteroauth/twitteroauth.php');
     142    include(__DIR__ . '/core/Snippet.php');
     143
     144    // init Twitter library
     145    $twitter = new TwitterOAuth($options->consumer_key,$options->consumer_secret,$options->oauth_token,$options->oauth_token_secret);
     146
     147    try
     148    {
     149        // create a snippet
     150        $snippet = \InlineTweets\Snippet::create($snippet_text,$twitter,$options);
     151
     152        // render the snippet
     153        $result->html = $snippet->render();
     154    }
     155    catch (RuntimeException $e)
     156    {
     157        // set error text
     158        $result->html = inline_tweets_inline_error($e->getMessage());
     159
     160        // stop execution and return result
     161        return $result;
     162    }
    113163
    114164    // return result
     
    117167
    118168/**
    119  * Request handler intercepts requests to admin.php and checks if any actions
    120  * should be performed ('inline_tweets_action' parameter is in the request array)
    121  */
    122 function inline_tweets_request_handler() {
    123     // check if inline_tweets action is to be performed
     169 * Saves settings for inline tweets
     170 *
     171 * @return stdClass result
     172 */
     173function inline_tweets_action_saveSettings()
     174{
     175    // load current settings
     176    $settings = inline_tweets_loadOptions();
     177
     178    // override from request
     179    foreach($_REQUEST['settings'] as $key => $value) $settings->{$key} = $value;
     180
     181    // save settings
     182    inline_tweets_saveOptions($settings);
     183
     184    // respond
     185    return $settings;
     186}
     187
     188// ---------------------------------------------------------------------------------------------------------------------
     189// Behaviour
     190// ---------------------------------------------------------------------------------------------------------------------
     191
     192/**
     193 * Intercepts all requests made to index.php and checks if an action should be performed
     194 * (when 'inline_tweets_snippet' parameter exists in the request array)
     195 */
     196function inline_tweets_ajaxAction()
     197{
     198    // make sure action is requested
    124199    if(empty($_REQUEST['inline_tweets_action'])) return;
    125200
    126     // handle tweet
    127     $result = inline_tweets_handle($_REQUEST['inline_tweets_action']);
    128 
    129     // send response
     201    // define action
     202    $action = 'inline_tweets_action_' . $_REQUEST['inline_tweets_action'];
     203
     204    // make sure action exists
     205    if(!function_exists($action)) return;
     206
     207    // perform action
     208    $result = $action();
     209
     210    // respond
    130211    header('Content-type: application/json');
    131212    echo json_encode($result);
     213
     214    // stop execution
    132215    die;
    133 }
    134 
    135 /**
    136  * Handles an inline tweet
    137  *
    138  * @param $inline_tweet [account:action:param]
    139  * @return stdClass data[url,result]
    140  */
    141 function inline_tweets_handle($inline_tweet) {
    142     // clear tags
    143     $inline_tweet = str_replace('[tweet]','',$inline_tweet);
    144     $inline_tweet = str_replace('[/tweet]','',$inline_tweet);
    145 
    146     // get embed data
    147     $embed_data = explode(':',$inline_tweet);
    148 
    149     // check data structure
    150     if(count($embed_data) < 2) return inline_tweets_inline_error("Invalid structure.");
    151 
    152     // init result
    153     $result = new stdClass();
    154     $result->url = "n/a";
    155  
    156     // check action
    157     switch($embed_data[0]) {
    158         case 'latest':
    159             // check structure
    160             if(count($embed_data) < 3) {
    161                 $result->html = inline_tweets_inline_error("Invalid structure.");
    162                 break;
    163             }
    164 
    165             // determine screen name
    166             $screen_name = $embed_data[1];
    167 
    168             // check screen name
    169             if(!preg_match('/^[A-Za-z0-9_]{1,15}$/', $screen_name)) {
    170                 $result->html = inline_tweets_inline_error("Invalid Twitter username.");
    171                 break;
    172             }
    173 
    174             // determine count
    175             $count = intval($embed_data[2]);
    176 
    177             // check count
    178             if($count == 0) {
    179                 $result->html = inline_tweets_inline_error("Invalid tweets count.");
    180                 break;
    181             }
    182 
    183             // form cache handle
    184             $result->cache_handle = "inline_tweets_latest_{$screen_name}_{$count}";
    185 
    186             // get cache entry
    187             $cache_entry = wp_cache_get($result->cache_handle);
    188 
    189             // check if cache entry exists and is young enough
    190             if($cache_entry !== false && inline_tweets_time_diff_in_minutes(time(),$cache_entry['timestamp']) <= INLINE_TWEETS_CACHE_TIMEOUT) {
    191                 // get data from cache
    192                 $data = $cache_entry['data'];
    193 
    194                 // set from cache flag
    195                 $result->from_cache = true;
    196             }
    197             else {
    198                 // form URL
    199                 $result->url = "https://api.twitter.com/1/statuses/user_timeline.json"
    200                     ."?include_entities=true&include_rts=true&screen_name={$screen_name}&count={$count}";
    201 
    202                 // get response from Twitter API
    203                 $response = inline_tweets_curl($result->url);
    204 
    205                 // decode from JSON to array
    206                 $data = @json_decode($response,true);
    207 
    208                 // check data and return inline error if data is false
    209                 if($data == false) {
    210                     $result->html = inline_tweets_inline_error("Unable to fetch tweet(s)");
    211                     break;
    212                 }
    213 
    214                 // check if there was an API error
    215                 if(isset($data["error"])) {
    216                     $result->html = inline_tweets_inline_error($data["error"]);
    217                     break;
    218                 }
    219 
    220                 // save to cache
    221                 wp_cache_set($result->cache_handle,array('timestamp' => time(), 'data' => $data));
    222 
    223                 // set from cache flag
    224                 $result->from_cache = false;
    225             }
    226 
    227             // start creating content
    228             $content = ($count == 1) ? '' : '<ul class="inline_tweets_ul">';
    229 
    230             // go trough all fetched tweets
    231             foreach($data as $tweet) {
    232                 // input embedded tweet
    233                 $content .= ($count == 1) ? '<div class="inline_tweet">' : '<li class="inline_tweet inline_tweets_li">';
    234                 $content .= inline_tweets_embed_tweet($tweet);
    235                 $content .= ($count == 1) ? '</div>' : '</li>';
    236             }
    237 
    238             // finish content
    239             $content .= ($count == 1) ? '' : '</ul>';
    240 
    241             // save created content
    242             $result->html = $content; break;
    243         case 'status':
    244             // determine status id
    245             $id = ($embed_data[1]);
    246 
    247             // form cache handle
    248             $result->cache_handle = "inline_tweets_status_{$id}";
    249 
    250             // get cache entry
    251             $cache_entry = wp_cache_get($result->cache_handle);
    252 
    253             // check if cache entry exists and is young enough
    254             if($cache_entry !== false && inline_tweets_time_diff_in_minutes(time(),$cache_entry['timestamp']) <= INLINE_TWEETS_CACHE_TIMEOUT) {
    255                 // get data from cache
    256                 $data = $cache_entry['data'];
    257 
    258                 // set from cache flag
    259                 $result->from_cache = true;
    260             }
    261             else {
    262                 // form URL
    263                 $result->url = "https://api.twitter.com/1/statuses/show.json?id={$id}&include_entities=true";
    264 
    265                 // get response from Twitter API
    266                 $response = inline_tweets_curl($result->url);
    267 
    268                 // decode from JSON to array
    269                 $data = @json_decode($response,true);
    270 
    271                 // check data and return inline error if data is false
    272                 if($data == false) {
    273                     $result->html = inline_tweets_inline_error("Unable to fetch tweet.");
    274                     break;
    275                 }
    276 
    277                 // check if there was an API error
    278                 if(isset($data["error"])) {
    279                     $result->html = inline_tweets_inline_error($data["error"]);
    280                     break;
    281                 }
    282 
    283                 // save to cache
    284                 wp_cache_set($result->cache_handle,array('timestamp' => time(), 'data' => $data));
    285 
    286                 // set from cache flag
    287                 $result->from_cache = false;
    288             }
    289 
    290             // save tweet
    291             $result->html = '<div class="inline_tweet">' . inline_tweets_embed_tweet($data) . '</div>'; break;
    292         default: $result->html = inline_tweets_inline_error();
    293     }
    294 
    295     // return result
    296     return $result;
    297216}
    298217
     
    303222 * @return String rendered content
    304223 */
    305 function inline_tweets_render($content) {
     224function inline_tweets_render($content)
     225{
    306226    // define regex for searching for inline tweets
    307227    $regex = '/\[tweet\](.*?)\[\/tweet\]/ism';
     
    314234
    315235    // handle all matches
    316     if(isset($inline_tweets[0])) foreach($inline_tweets[0] as $inline_tweets_data) {
    317         // wrap inline tweet in placeholder div
    318         $content = str_replace($inline_tweets_data,'<div class="inline_tweets_placeholder">'.$inline_tweets_data.'</div>',$content);
     236    if(isset($inline_tweets[0])) foreach($inline_tweets[0] as $snippet)
     237    {
     238        // remove tags from the snippet
     239        $cleared_snippet = str_replace('[tweet]','',$snippet);
     240        $cleared_snippet = str_replace('[/tweet]','',$cleared_snippet);
     241
     242        // wrap inline tweet in placeholder div with a loader
     243        $content = str_replace($snippet,'<div class="inline_tweets_placeholder" snippet="'.$cleared_snippet.'"><img src="'. plugins_url('/img/loader.gif',__FILE__) . '" /></div>',$content);
    319244    }
    320245
     
    324249
    325250/**
    326  * Loads Inline Tweets script in header
    327  */
    328 function inline_tweets_load_js_in_header() {
    329     // load basic css styles
    330     echo '<style type="text/css">div.inline_tweets_placeholder{text-align: center;}</style>';
    331 
    332     // set url param for the loader image
     251 * Loads Inline Tweets front-end dependencies in header
     252 */
     253function inline_tweets_loadHeader()
     254{
     255    global $inline_tweets_config;
     256
     257    // load options
     258    $options = inline_tweets_loadOptions();
     259
     260    // define styles
     261    $styles = array_merge(array('shared'),$inline_tweets_config->styles);
     262
     263    // register styles
     264    foreach($styles as $style)
     265        wp_register_style("inline_tweets_{$style}", plugins_url("/css/{$style}.css", __FILE__ ), array(), INLINE_TWEETS, 'all');
     266
     267    // set inline tweets url base
    333268    echo '<script type="text/javascript">var INLINE_TWEETS_BASE_URL = "' . get_bloginfo('siteurl') . '";</script>';
    334  
    335     // set url param for the loader image
    336     echo '<script type="text/javascript">var INLINE_TWEETS_LOADER_URL = "' . plugins_url('/loader.gif',__FILE__) . '";</script>';
    337 
    338     // load handling script
    339     wp_enqueue_script('inline_tweets', plugins_url('/inline_tweets.js',__FILE__));
    340 }
    341 
    342 // register request handler
    343 add_action('init', 'inline_tweets_request_handler', 9999);
     269
     270    // load shared style
     271    wp_enqueue_style('inline_tweets_shared');
     272
     273    // load style set in options (if not "none")
     274    if(isset($options->style) && $options->style != 'none' && in_array($options->style,$inline_tweets_config->styles))
     275        wp_enqueue_style("inline_tweets_{$options->style}");
     276
     277    // load the handling script
     278    wp_enqueue_script('inline_tweets', plugins_url('/js/handler.js',__FILE__));
     279}
     280
     281/**
     282 * Adds a menu item for accessing the settings page
     283 */
     284function inline_tweets_menuItem()
     285{
     286    add_submenu_page(
     287        'options-general.php', // parent
     288        'Inline Tweets Settings', // page title
     289        'Inline Tweets', // menu item title
     290        'administrator', // permission
     291        'inline-tweets-settings', // unique page name
     292        'inline_tweets_renderSettingsPage' // rendering function
     293    );
     294}
     295
     296/**
     297 * Renders the settings page
     298 */
     299function inline_tweets_renderSettingsPage()
     300{
     301    global $inline_tweets_config;
     302
     303    // load options
     304    $options = inline_tweets_loadOptions();
     305
     306    // set inline tweets url base
     307    echo '<script type="text/javascript">var INLINE_TWEETS_BASE_URL = "' . get_bloginfo('siteurl') . '";</script>';
     308
     309    // load the settings script
     310    wp_enqueue_script('inline_tweets', plugins_url('/js/settings.js',__FILE__));
     311
     312    // render the page
     313    include(__DIR__ . '/php/settings.php');
     314}
     315
     316/**
     317 * Adds a plugin action for accessing the settings page
     318 *
     319 * @param $links
     320 * @return $links
     321 */
     322function inlineTweets_addPluginActionLink($links) {
     323    // form the link
     324    $link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=inline-tweets-settings">Settings</a>';
     325
     326    // append the link
     327    array_unshift($links, $link);
     328
     329    // return the action links
     330    return $links;
     331}
     332
     333// ---------------------------------------------------------------------------------------------------------------------
     334// Commands
     335// ---------------------------------------------------------------------------------------------------------------------
     336
     337// register options
     338add_option('inline_tweets_options','');
     339
     340// register request handler for ajax calls
     341add_action('init', 'inline_tweets_ajaxAction', 9999);
    344342
    345343// add rendering filter for posts/pages
     
    350348
    351349// add head action to include inline-tweets script
    352 add_action('wp_head', 'inline_tweets_load_js_in_header');
     350add_action('wp_head', 'inline_tweets_loadHeader');
     351
     352// register menu item for settings
     353add_action('admin_menu', 'inline_tweets_menuItem');
     354
     355// add plugin action for accessing the settings page
     356add_action('plugin_action_links_'.plugin_basename(__FILE__),'inlineTweets_addPluginActionLink');
  • inline-tweets/trunk/readme.txt

    r714432 r836605  
    22
    33Contributors: mdjekic
    4 Donate link: http://projects.djekic.net/inline-tweets
     4Donate link: http://milos.djekic.net/my-software/inline-tweets
    55Tags: tweeter,tweets,inline,embed,styles
    66License: GPLv2
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
    88Requires at least: 2.7
    9 Tested up to: 3.5.1
    10 Stable tag: 1.1.2
     9Tested up to: 3.8
     10Stable tag: 2.0
    1111
    1212Embed latest tweet(s) or a specific tweet in any page, post or text widget and apply your custom styles.
    1313
     14
     15
     16
    1417== Description ==
    1518
    16 This simple plugin will help you embed tweets into your posts, pages and text widgets and apply your custom styles.
    17 Just enter this simple syntax into your post, page or widget content:
    18 
    19 = Latest Tweet(s) =
    20 
    21 [tweet]latest:twitter_user:count[/tweet]
    22 
    23 Replace "twitter_user" with a Twitter username and "count" with the number of latest tweets to fetch. Example:
    24 
    25 [tweet]latest:milos_djekic:5[/tweet]
    26 
    27 = Specific Tweet =
    28 
    29 [tweet]status:status_id[/tweet]
    30 
    31 Replace "status_id" with a Twitter status id. Example:
    32 
    33 [tweet]status:316942284857962497[/tweet]
    34 
    35 = Styling =
    36 
    37 Inline tweets are displayed with a set of CSS class attributes that you can customise in your own
    38 style sheets. Some basic classes are:
    39 
    40 * "inline_tweets_author" - rendered when displaying tweet author - <a href="http://twitter.com/twitter" class="inline_tweets_author">@twitter</a>
    41 * "inline_tweets_tag" - rendered when displaying hashtags - <span class="inline_tweets_tag">#hashtag</span>
    42 * "inline_tweets_url" rendered when displaying URLs - <a href="http://google.com" class="inline_tweets_url">google.com</a>
    43 * "inline_tweets_mention" - rendered when displaying mentions - <a href="http://twitter.com/twitter" class="inline_tweets_mention">@twitter</a>
    44 * "inline_tweets_timestamp" - rendered when displaying tweet timestamp - <span class="inline_tweets_timestamp">Mar 12</span>
    45 
    46 Tweets are contained in a "div" element with a class attribute "inline_tweet". If there is more than one tweet,
    47 they are contained in a "li" element with the same class (and an extra class - "inline_tweets_li"). All "li" elements
    48 are contained in a "ul" element with a class "inline_tweets_ul". If there were errors, they will be displayed in a "div"
    49 element with a class "inline_tweets_error".
    50 
    51 If you wish to exclude some information from the display - for example: tweet timestamp - all you have to do is
    52 set "display" property to "none" for the class "inline_tweets_timestamp" in your custom style sheet.
     19This simple plugin will enable you to embed tweets into your posts, pages and text widgets and apply YOUR CUSTOM STYLES. It comes down to adding a simple snippet into your post, page or text widget content. Here's an example:
     20
     21`[tweet]latest|user=WordPress,count=5[/tweet]`
     22
     23This snippet will display five last tweets made by @WordPress with an intuitive HTML markup to which you can easily apply your custom CSS:
     24
     25`.inline_tweet { background-color: whitesmoke; border: 2px solid black; }`
     26
     27Fetching tweets will be done in the background and will not slow down the displaying of your website or blog. You will see an unobtrusive transition placeholder before the tweets are loaded.
     28
     29You like that? Take a look at the [How to use](http://wordpress.org/plugins/inline-tweets/how-to-use/) and [Markup and Styling](http://wordpress.org/plugins/inline-tweets/markup-and-styling/) pages to learn what you can do.
    5330
    5431= Caching =
    5532
    56 Caching will improve performance when fetching tweets and ensure the plugin operates within Twitter API limits.
    57 To enable caching, please install [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/) and enable
    58 'Object Cache' in plugin settings.
    59 
    60 Visit the [project page](http://projects.djekic.net/inline-tweets/) to learn more on styling inline tweets.
     33Caching will improve performance when fetching tweets and ensure that the plugin operates within Twitter API limits. To enable caching, please install [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/) and enable 'Object Cache' in plugin settings.
     34
     35= Configuration =
     36
     37SinceTwitter introduced it's API version 1.1 you need to create a Twitter application to be able to use it and thus to use this plugin. It's not hard, you will spend a couple of minutes to create an app and obtain tokens and keys you will use for configuring Inline Tweets. You will have to do that only once, so no problem.
    6138
    6239= Author =
    6340
    64 [Miloš Đekić](http://milos.djekic.net) is a software enthusiast from Belgrade,
    65 Serbia. He loves to create useful software.
     41[Miloš Đekić](http://milos.djekic.net) is a software solutions architect from Belgrade, Serbia. He loves to create useful software.
     42
     43= Credits =
     44
     45Credits should be given when credits are due. Inline tweets use a great Twitter API wrapper library created by [Abraham Williams](https://abrah.am/) to communicate with Twitter. You can find it [here](https://github.com/abraham/twitteroauth)
     46
     47
     48
    6649
    6750== Installation ==
     
    6952Just follow this simple guidelines.
    7053
    71 = Installation steps =
     54Installation steps
    7255
    73561. Upload 'inline-tweets' to the '/wp-content/plugins/' directory
    74571. Activate the plugin through the 'Plugins' menu in WordPress
    75 1. Include inline tweet syntax in your pages or posts
    76 1. Customize inline tweets with your custom CSS
     581. Visit plugin settings page to configure your Twitter keys and tokens
     591. Include inline tweet snippets in your pages, posts or widgets
     601. Customize inline tweets with your own CSS
    77611. That's it. Enjoy!
     62
     63
     64
     65
     66== How to use ==
     67
     68The usage depends on what you want to display. Only a couple of ways of displaying tweets exists but the list of applications will be expanded in the future. Make sure you take a look at the "Snippet Options" and learn how to take control over what is displayed and how.
     69
     70= Single Tweet =
     71
     72This is useful when you want to embed a tweet in your blog article or page.  Just use this snippet:
     73
     74`[tweet]single|id=tweet_id[/tweet]`
     75
     76Replace "tweet_id" with the ID of the Twitter status you want to display. That's it.
     77
     78= Latest Tweets =
     79
     80This will probably be the most common application of the plugin. If you want to display a list of your (or someone elses) latest tweets in your sidebar and/or pages/articles, use this snippet
     81
     82`[tweet]latest|user=twitter_user[/tweet]`
     83
     84Replace "twitter_user" with the username of the account whose tweets you want to display. You can limit the number of tweets that will be fetched and displayed by adding a "count" param. Take a look at the following example:
     85
     86`[tweet]latest|user=twitter_user,count=10[/tweet]`
     87
     88Note: Default number of tweets that will be fetched is 5 and the maximum you can set is 25. If you set more that the maximum you will get the default 5 tweets.
     89
     90= Display Options =
     91
     92There are various options to help you customise what will be displayed by the plugin for a particular snippet. You can include a custom option by adding the option string after a comma sign.
     93
     94Here's a list of all options with examples:
     95
     96**time_format**
     97
     98You can select the time format inline. Have in mind that if the format you set is not supported the time will be displayed in default format Here's an example:
     99
     100`[tweet]latest|user=twitter_user,time_format=M Y[/tweet]`
     101
     102**hide_author**
     103
     104You can easily remove the author from display by simply adding the option:
     105
     106`[tweet]single|id=tweet_id,hide_author[/tweet]`
     107
     108**hide_avatar**
     109
     110You can easily remove the avatar from display by simply adding the option:
     111
     112`[tweet]single|id=tweet_id,hide_avatar[/tweet]`
     113
     114**hide_timestamp**
     115
     116You can easily remove the timestamp from display by simply adding the option:
     117
     118`[tweet]single|id=tweet_id,hide_timestamp[/tweet]`
     119
     120**full_names**
     121
     122By default tweets are displayed with their authors Twitter names. If "full_names" param is set they will be displayed with their full names:
     123
     124`[tweet]latest|user=twitter_user,count=15,full_names[/tweet]`
     125
     126
     127
     128
     129== Markup and Styling ==
     130
     131Inline tweets are rendered with a reckognizable HTML markup that you can use to display them in virtually every way possible using CSS. For starters, every tweet is wrapped in an element with class "inline_tweet". Then every displayed element has it's own class and rules.
     132
     133= Tweet Content =
     134
     135**Author**
     136
     137Author's Twitter name or full name is displayed as a link to his/her Twitter page:
     138
     139<a class="inline_tweets_author" href="http://twitter.com/author" target="_blank">@author</a>
     140
     141You can style the link by referencing the "inline_tweets_author" class (e.g. different color for plugin author than other users mentions).
     142
     143**Avatar**
     144
     145If displayed, the avatar is rendered as a link to author's Twitter page also, with the addition of an image element:
     146
     147`<a class="inline_tweets_avatar" href="http://twitter.com/author" target="_blank">
     148    <img src="http://pbs.twimg.com/profile_images/author_image.jpeg">
     149</a>`
     150
     151You can style the link in terms of positioning and the image display by referencing the "inline_tweets_avatar" class.
     152
     153**Mentions**
     154
     155Mentions are also displayed as link to author Twitter pages and you cal easily style them by referencing the "inline_tweets_mention" class:
     156
     157`<a class="inline_tweets_mention" href="http://twitter.com/mention" target="_blank">@mention</a`
     158
     159**Hashtags**
     160
     161Hashtags are wrapped in span elements enabling you to apply your custom styles (e.g. display in bold or italic) by referencing the "inline_tweets_tag" class:
     162
     163`<span class="inline_tweets_tag">#tag</span>`
     164
     165**Timestamp**
     166
     167If you decide to display the timestamp, you can easily style it - in terms of positioning for starters - by referencing the "inline_tweets_timestamp" class. Here's how the timestamp is rendered:
     168
     169`<span class="inline_tweets_timestamp">Jan 2014</span>`
     170
     171= Single Tweet =
     172
     173Here's an example of how a single tweet is displayed:
     174
     175`<div class="inline_tweet">
     176    <a class="inline_tweets_author" href="http://twitter.com/ArchdukeM" target="_blank">@ArchdukeM</a>
     177    <a class="inline_tweets_avatar" href="http://twitter.com/ArchdukeM" target="_blank">
     178        <img src="http://pbs.twimg.com/profile_images/image.jpeg">
     179    </a>
     180    "She represented everything I loved about the English. She was totally deranged."
     181    <span class="inline_tweets_timestamp">Jan 2014</span>
     182</div>`
     183
     184= Multiple Tweets =
     185
     186When more that one tweet is displayed it is rendered as a list. To cut it short, here's an example markup:
     187
     188`<ul class="inline_tweets_ul">
     189    <li class="inline_tweet">
     190        CONTENT
     191    </li>
     192</ul>`
     193
     194Let's analyse the differences and the advantages. You have a ul element with a class "inline_tweets_ul" that you can use if you want to position the entire list, enable scrolling or whatever you want. Instead of a div element, there's a li element with the "inline_tweet" class for wrapping the tweet. Tweet content is rendered in the same way as single tweets.
     195
     196
     197
    78198
    79199== Screenshots ==
     
    822022. Latest tweets displayed in the sidebar
    83203
     204
     205
     206
    84207== Changelog ==
     208
     209= 2.0 =
     210* A complete rewrite to support Twitter API 1.1
     211* User avatars in tweets
     212* Inline options in snippet (show/hide: author, avatar, timestamp; different timestamp formats, full author names)
    85213
    86214= 1.1.2 =
     
    102230= 1.0 =
    103231* First version - inline tweets on.
     232
     233
     234
     235
     236== Upgrade Notice ==
     237
     238Inline Tweets now work with Twitter API 1.1! Upgrade to continue using the plugin with a lot of additional options.
Note: See TracChangeset for help on using the changeset viewer.