开发者 | GYatesIII |
---|---|
更新时间 | 2014年10月17日 11:51 |
PHP版本: | 3.3 及以上 |
WordPress版本: | 3.5.2 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
STF_Tweet
An array of these objects is returned by the template tag instead of the WP_Post
object, or an individual can be constructed by passing the post ID of the Tweet to the object constructor.
The object provides a number of useful methods when working with Tweets. This object has the following accessible properties:
is_retweet
- This boolean will be true
when the Tweet is a Retweetis_reply
- This boolean will be true
when the Tweet is a Reply to another Tweetcontent
- The content of the Tweet, this will be automatically formatted to link other referenced Twitter users, hashtags, and inline linkstime
- A timestamp of the Tweet, timezoned to the WP install, in Y-m-d H:i:s formattime_gmt
- A timestamp of the Tweet, timezoned to GMT, in Y-m-d H:i:s formattime_str
- The string that represents how long it's been since the Tweet, in the way that Twitter usually dates its Tweets, good for an international audience since this isn't timezone specicificget_source()
- Returns the string representing the device used to Tweet this statusget_raw_tweet()
- Returns the cached raw response from the API as an object, this should rarely be used as almost all information on the Tweet is accessible without loading this objectget_author_link()
- Returns a string that is the link to the Tweet's author's page on Twitterget_retweet_info()
- Returns the info on the original Tweet of a Retweet, or false if the Tweet is not a Retweet, the object returned contains:username
- The Twitter username of the original Tweetscreenname
- The Twitter screenname of the original Tweetcontent
- The unformatted content of the original Tweettime_gmt
- The GMT time of the Retweeturl
- A direct link to the original Tweetuser_url
- A direct link to the profile of the original Twitter userget_reply_info()
- Returns the info on the original status that this Tweet is replying to, the info is as follows:url
- The direct link to the original statusin_reply_to_name
- The screenname of the original Twitter userin_reply_to_user_url
- The direct link to the original Twitter user's profileget_author_info()
- Gets the raw object response from the Twitter API scrape, there are a lot of variables in the raw object, but here's the main attributes:id_str
- The id of the username
- The nice name of the author accountscreen_name
- The username of the author accountdescription
- The self-provided description of the author on Twittercreated_at
- The creation date of the Twitter author accountprofile_image_url
- Link to the profile image of the Twitter author accountprofile_image_url_https
- Secure link to the profile image of the Twitter author accountstf_get_tweets($args)
This will be the main function used to get Tweets from the DB. This function takes an array of parameters as follows:
$args['num']
- This tells us how many Tweets to get from the DB, defaults to 5$args['offset']
- This tells us how many Tweets to skip over when selecting our Tweets, defaults to 0$args['retweets']
- This tells us whether or not to get Retweets, defaults to true
$args['replies']
- This tells us whether or not to get Replies, defaults to true
This function returns an array of STF_Tweet objects, the use of these objects is described aboveSimpleTwit
to the /wp-content/plugins/
directoryThis plugin is intended entirely for developers and therefore there's no prebuilt Twitter feed box or widget. Instead, this plugin provides the stf_get_tweets()
function that will return an array of Tweet objects that can be easily looped through and used to build a custom Twitter feed. Making it easy for anyone with familiarity with PHP, HTML and CSS to create the perfect custom Twitter feed they were looking for.
STF_Tweet->get_author()
method to provide detailed information on the Tweet's authorSTF_Tweet->get_raw_tweet()
to return an object instead of associative arraySTF_Tweet->get_author_link()
to get the direct link to the Tweet author's pagestf_get_tweets()
get_tweet_link()
method to STF_Tweet
object to return the direct link to statusstf_get_tweets()
function so that it takes a single array of parameters argument rather than a list of arugmentsstf_
instead of no namespacing or st_
function_exists()
checks to prevent fatal conflicts with other plugins