-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add profile images for account and @replies. #6
Comments
Should be possible with some custom code. The plugin was developed really for developers, allowing them the freedom to modify things as they wish using the various WordPress actions and filters included within the code. My blog post regarding the plugin shows how you can overwrite the tweet HTML with your own. The $tweet variable is the JSON response from Twitter, which will include profile image URL, amongst all the other values. You could use this within your own HTML to display each tweet as desired :) |
Hi Matthew, Thanks for the reply. Yeah I saw the blog post and that should be really easy in theory yet I haven't been able to get any custom html to work properly. Maybe if you could give me a simple example so I can get an idea. Here is what I was using for the 1.0 API and would like to achieve something similar for Display Tweets: results; // Valid data now with just the tweet result. // Printing out the feed's data in our required format. if ($valid_data) { ``` foreach ($valid_data as $key=>$value) { print ''; print ''; print ''; print ''; print '' . twitter_status_links($value->text) . ''; print ' '; } ``` } else { echo 'Cannot get tweets right now. Please refresh the page or try again later. '; } Thanks! Joshua On Jun 24, 2013, at 7:40 AM, MatthewRuddy [email protected] wrote: > Should be possible with some custom code. The plugin was developed really for developers, allowing them the freedom to modify things as they wish using the various WordPress actions and filters included within the code. > > My blog post regarding the plugin show how you can overwrite the tweet HTML with your own. The $tweet variable is the JSON response from Twitter, which will include profile image URL, amongst all the other values. You could use this within your own HTML to display each tweet as desired :) > > http://matthewruddy.com/display-tweets-plugin/ > > — > Reply to this email directly or view it on GitHub. |
It should be as simple as this added to your theme's functions.php file. function custom_tweet_template( $tweet ) { echo "<p>{$tweet->text}</p>"; } add_action( 'displaytweets_tweet_template', 'custom_tweet_template' ); |
Thanks Matthew, I can get that but separating out any of the json data like profile image, hashtags, etc loses all the links even if they are added in that function. Not really sure how to proceed but thanks for the help. j On Jun 24, 2013, at 12:26 PM, MatthewRuddy [email protected] wrote:
|
If you want to re-add the links, the following preg_replace's should do the trick. $text = preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $text );
$text = preg_replace( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $text );
$text = preg_replace( "/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $text );
$text = preg_replace( "/#(\w+)/", "<a href=\"http://twitter.com/search?q=%23\\1&src=hash\" target=\"_blank\">#\\1</a>", $text ); |
Thanks for this but getting an error: Warning: preg_replace() expects at least 3 parameters, 2 given in /nfs/c02/h05/mnt/43011/domains/uw-mc.org/html/wp-content/themes/uwchilipepper/functions.php on line 262 Where exactly should this go in this function: function custom_tweet_template( $tweet ) { On Jun 24, 2013, at 3:47 PM, MatthewRuddy [email protected] wrote:
|
I've just edited the code there now - the syntax highlighting wasn't done correctly so the code wasn't correct either. Sorry about that, try it again now. |
Re-download the plugin? On Jun 25, 2013, at 4:24 AM, MatthewRuddy [email protected] wrote:
|
No no, retry the code from my previous post. It should work if used correctly this time (when you last tried there was a mistake within it): $text = preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $text );
$text = preg_replace( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $text );
$text = preg_replace( "/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $text );
$text = preg_replace( "/#(\w+)/", "<a href=\"http://twitter.com/search?q=%23\\1&src=hash\" target=\"_blank\">#\\1</a>", $text ); |
Posted this on WordPress.org as well but it would be great to be able to include the Twitter profile image(s) for the main account as well as @replies and have that link to the respective profiles.
I looked through the code and couldn't find a simple way to add it...
The text was updated successfully, but these errors were encountered: