=== ThinkTwit === Contributors: stephen.pickett Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=B693F67QHAT8E Author URI: http://www.thepicketts.org Tags: twitter, tweet, thinktwit, hashtag, multiple, caching, ajax, shortcode, css Requires at least: 3.2 Tested up to: 5.8 Stable tag: 1.7.1 Outputs tweets from any Twitter users, hashtag or keyword through the Widget interface. Can be called via shortcode or PHP function call and supports i18n for multiple languages == Description == ThinkTwit is a highly customisable plugin that can output tweets from multiple users (something that very few other plugins can do successfully), #hashtag or keyword. It uses the Twitter Search JSON API v1.1 to access tweets which can be cached. It is very simple, yet flexible and easily customised. It can be placed on your Wordpress page simply through drag and drop on the Widgets interface or through the use of Shortcode or Output Anywhere (PHP function call). Supports i18n! **Support:** http://www.thepicketts.org/thinktwit/ or on Twitter **@stephenpickett** Features: -------- * Can be configured from Widgets settings (if displayed in sidebar) * Can be implemented using shortcode or Output Anywhere (PHP function call) * Contains default slimline CSS for integrated look and feel (can be turned off) * Easy to configure and customise (through settings and CSS) * Multiple instances can be deployed (like other widgets/plugins) * JavaScript is not required (unless no-caching is activated) * Can specify multiple usernames * Tweets can be filtered by #hashtag or keyword * You can select to filter between an AND or OR filter to either show tweets only containing specified usernames and hashtags or any of them * Can specify maximum number of tweets to display * Can specify maximum number of days back to display * Supports no-caching, to prevent caching of tweets by caching engines such as WP Super Cache * Supports cURL as a fallback method, if necessary * Supports optional caching of tweets and avatars * Cache can be manually cleared and will automatically update if the cache is empty * Can display the avatar of the Twitter user * Output can be filtered (using apply_filters) * Can optionally output "Follow @username" links * Automated cleanup process that runs periodically according to user setting * Internationalised using i18n meaning that if it isn't in your language it's easy to translate! See Other Notes for more details * Gracefully deals with Twitter errors and adds them to the PHP error log * Supports live updates of tweets when using no-caching (AJAX) Requirements/Restrictions: ------------------------- * Works with Wordpress 3.2 to 5.7.2, not tested with other versions nor re-tested on older versions than most current * Can be installed using the widgets sidebar * Can also be used via shortcode or Output Anywhere (PHP function call) * Uses Twitter REST API v1.1 Application-only authentication and therefore requires an application key (see installation) I am looking for more people to translate ThinkTwit in to other languages, if you are interested please see "Internationalisation (i18n)" under "Other Notes". == Installation == = Obtaining a Twitter authentication key = 1. Go to https://dev.twitter.com/apps/new 1. Login using your standard Twitter credentials 1. Complete the form: * Name: ThinkTwit - [site name] * Description: ThinkTwit plugin * Website: [url of your website] * Callback URL: [url of your website] 1. Make a note of your "Consumer key" and "Consumer secret" = Installing plugin = 1. Unpack the zip file and upload the `thinktwit` folder to the `/wp-content/plugins/` directory, or download through the `Plugins` menu in WordPress 1. Activate the plugin through the `Plugins` menu in WordPress 1. Navigate to Settings->ThinkTwit from the Wordpress Dashboard 1. Enter the "Consumer key" and "Consumer secret" obtained earlier and save your settings Updates are automatic. Click on `Upgrade Automatically` if prompted from the admin menu. If you ever have to manually upgrade, simply replace the files with those from the new version. = Configuring widget = 1. Go to `Appearance` and then `Widgets` and drag `ThinkTwit` to your sidebar 1. Fill in the options as required and then save = Configuring shortcode = ThinkTwit can be used in any page or post, or anywhere else configured to use shortcodes, using the following syntax: `[thinktwit widget_id=0 usernames="stephenpickett" hashtags="thinktwit" hashtag_filter=0 username_suffix=" said: " limit=5 max_days=7 update_frequency=-1 show_username="username" show_avatar=1 show_published=1 show_follow=1 links_new_window=1 no_cache=0 live_update_freq=0 debug=0 time_this_happened="This happened " time_less_min="less than a minute ago" time_min="about a minute ago" time_more_mins=" minutes ago" time_1_hour="about an hour ago" time_2_hours="a couple of hours ago" time_precise_hours="about =x= hours ago" time_1_day="a day ago" time_2_days="almost 2 days ago" time_many_days=" days ago" time_no_recent="There have been no recent tweets" ]` = Configuring Output Anywhere = ThinkTwit can be called within templates and other areas where you can use PHP using the following syntax: ` 0, 'usernames' => "stephenpickett", 'hashtags' => "thinktwit", 'hashtag_filter' => 0, 'username_suffix' => " said: ", 'limit' => 5, 'max_days' => 7, 'update_frequency' => 0, 'show_username' => "name", 'show_avatar' => 1, 'show_published' => 1, 'show_follow' => 1, 'links_new_window' => 1, 'no_cache' => 0, 'live_update_freq' => 0, 'debug' => 0, 'time_this_happened' => "This happened ", 'time_less_min' => "less than a minute ago", 'time_min' => "about a minute ago", 'time_more_mins' => " minutes ago", 'time_1_hour' => "about an hour ago", 'time_2_hours' => "a couple of hours ago", 'time_precise_hours' => "about =x= hours ago", 'time_1_day' => "a day ago", 'time_2_days' => "almost 2 days ago", 'time_many_days' => " days ago", 'time_no_recent' => "There have been no recent tweets"); echo ThinkTwit::output_anywhere($args); ?>` = Shortcode/Output Anywhere Parameters = **widget_id**: *integer* - You should give this a unique id for caching or styling. **usernames**: *string* - The list of Twitter usernames to output tweets for. **hashtags**: *string* - The list of hashtags to output tweets for. **hashtag_filter**: *string* - 1 indicates that usernames AND hashtags must both exist in a tweet, 0 indicates that either can exist. **username_suffix**: *string* - The text that should appear after a username e.g. " said: ". **limit**: *int* - The maximum number of tweets to display. **max_days**: *int* - The maximum age in days of the tweets to be displayed. **update_frequency**: *int* - Minus 1 indicates live (uncached), minus 2 indicates paused, 0 indicates live (cached), and anything else indicates the number of hours between getting updates from Twitter. **show_username**: *string* - None indicates no username should be shown, name indicates the user's full name should be shown and username indicates the user's username should be shown. **show_avatar**: *boolean* - Indicates whether the Twitter user's avatar should be displayed - 1 for true and 0 for false. **show_published**: *boolean* - Indicates whether the time the tweet was made should be displayed e.g. "This happened a day ago" - 1 for true and 0 for false. **show_follow**: *boolean* - Indicates whether or not to show a "Follow @username" link for each username. **links_new_window**: *boolean* - Indicates whether links should be opened in a new window - 1 for true and 0 for false. **no_cache**: *boolean* - Indicates whether or not to use no-caching - 1 for true and 0 for false. **live_update_freq**: *int* - The frequency of live updates (zero for off). **debug**: *boolean* - Indicates whether to turn on debugging mode - 1 for true and 0 for false. **time_this_happened**: *string* - Time prefix (default: "This happened"). **time_less_min**: *string* - Time less than 1 minute (default: "less than a minute ago"). **time_min**: *string* - Time approximately 1 minute ago (default: "about a minute ago"). **time_more_mins**: *string* - Time more than 1 minute ago (default: " minutes ago"). **time_1_hour**: *string* - Time approximately 1 hour ago (default: "about an hour ago"). **time_2_hours**: *string* - Time approximately 2 hours ago (default: "a couple of hours ago"). **time_precise_hours**: *string* - Time more than 2 hours ago (default: "about =x= hours ago"). NOTE: =x= should be used to insert the number of hours. **time_1_day**: *string* - Time approximately 1 day ago (default: "a day ago"). **time_2_days**: *string* - Time approximately 2 days ago (default: "almost 2 days ago"). **time_many_days**: *string* - Time more than 2 days ago (default: " days ago"). **time_no_recent**: *string* - Output when there are no tweets to display (default: "There have been no recent tweets"). NOTE: You can leave out any parameter to use the default, but be aware to change the unique id if you are using Output Anywhere in more than one place. == Uninstall == To uninstall simply deactivate and then delete through the Plugins admin interface. All options and files will be automatically removed. == Frequently Asked Questions == = When I add the widget I cannot expand the menus, what is wrong? = There is a known issue where the ThinkTwit sub menus will not expand after you add a widget for the first time. Please simply reload the widgets page and it will now work going forwards. = How many tweets will be shown? = This is determined by your settings within the widget or your custom call. The default is set to 5. = How long back will tweets be shown for? = If using the update frequency "Live (uncached)" ThinkTwit will show tweets that have occurred as far back as "max days" (up to the last 7 days, due to restrictions in the Twitter API). However, any other option will utilise ThinkTwit's own cache and will therefore display anything within the cache (up to "max days"). The exception to this is when the "Paused" option is selected - this will retain tweets (and display those tweets) indefinitely (until the update frequency is changed from "Paused"). = What will happen if I haven't tweeted in the last 7 days? = If you aren't caching tweets then a message will be shown stating: "There have been no tweets for the past 7 days", but if you are caching tweets then it will simply show the tweets stored in the cache, even if they are older than 7 days. This message can be customised within the settings. = How can I style ThinkTwit? = ThinkTwit uses the widget API so should be styled correctly by your theme. It has some default CSS but you may, however, wish to turn this off (in the ThinkTwit Settings) and add your own. If so you should find the following information handy: * ThinkTwit essentially outputs tweets as a list * The list container can be accessed using `ol.thinkTwitTweets` * All tweets can be accessed using `ol.thinkTwitTweets li.thinkTwitTweet` * Individual tweets can be accessed using `ol.thinkTwitTweets #tweet-n` where n is the number of the tweet * Odd and even tweets can be accessed using `ol.thinkTwitTweets li.thinkTwitOdd` and `ol.thinkTwitTweets li.thinkTwitEven` accordingly * The author within a tweet can be accessed using `ol.thinkTwitTweets li.thinkTwitTweet a.thinkTwitAuthor` * The author suffix within a tweet can be accessed using `ol.thinkTwitTweets li.thinkTwitTweet a.thinkTwitSuffix` * The content of a tweet can be accessed using `ol.thinkTwitTweets li.thinkTwitTweet a.thinkTwitContent` * The published time within a tweet can be accessed using `ol.thinkTwitTweets li.thinkTwitTweet span.thinkTwitPublished` * The "no tweets" message can be accessed using `ol.thinkTwitTweets li.thinkTwitNoTweets` * The AJAX error message ("Error: Unable to display tweets") can be accessed using `p.thinkTwitError' NOTE: Be sure to use the id to access each style in order to over-write the default CSS. = How do I stop caching in caching engines such as WP Super Cache? = Turn on no-caching in the widget settings. = How does no-caching work? = Instead of outputting HTML it outputs Javascript. The Javascript uses AJAX (via jQuery) to make a call to a method that returns the HTML which is then inserted in to the correct location. = I'm using no-caching but nothing appears below the title = Your theme is probably not setup properly. AJAX requires a location to insert the returned data from the server-side call. ThinkTwit puts it in to the div that contains the widget. A Wordpress theme written correctly should output a unique id for each widget that is output. Inform the developer of your theme to have the following (or something similar) in their register_sidebar function: `'before_widget' => '