stefanbohacek / tweet-embeds-wordpress-plugin

Embed Tweets without compromising your users’ privacy and your site’s performance.

Home Page:https://stefanbohacek.com/project/alternative-tweet-embeds/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preview of multiple Tweets embedded with the Tweet Embeds plugin

Tweet Embeds

Embed tweets without compromising your users' privacy and your site's performance.

Learn more on fourtonfish.com.

How to use

  1. Install the plugin.
  2. Create a new Twitter app and get your API keys.
  3. 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 

About

Embed Tweets without compromising your users’ privacy and your site’s performance.

https://stefanbohacek.com/project/alternative-tweet-embeds/

License:MIT License


Languages

Language:SCSS 65.3%Language:PHP 28.7%Language:JavaScript 6.0%