Tweet Embeds
Embed tweets without compromising your users' privacy and your site's performance.
Learn more on fourtonfish.com.
How to use
- Install the plugin.
- Create a new Twitter app and get your API keys.
- Go to the plugin's settings page and add your Twitter API keys.
If you don't provide the API keys, the plugin will still work, but some data will be missing (profile pictures, number of likes and retweets) and media (images, GIFs, videos) will not render.
Technical details
Process tweets manually
If you need to process tweets that are added to the page dynamically, use the ftfHelpers.processTweets()
function. Be sure to check if the function exists before using it to avoid errors in your script.
Wait for tweets to be processed
If you need to perform an action after all tweets on the page are processed, add a listener for the tembeds_tweets_processed
event.
document.addEventListener('tembeds_tweets_processed', function(){
const tweets = document.querySelectorAll('.twitter-tweet');
console.log('tweets are ready', tweets);
});
Here's an example using jQuery.
$(document).on('tembeds_tweets_processed', function(){
const $tweets = $('.twitter-tweet');
console.log('tweets are ready', $tweets);
});
Development
# install dependencies
npm install
# build front-end scripts and styles
gulp
# when adding new PHP classes inside `includes`
composer dumpautoload -o