Image
Image

WP-jTweets

Description

A widget that shows a user’s recent posts from X (formerly Twitter). It can fade the posts in and out one at a time using the jQuery that ships with WordPress, or simply list them. You choose how many posts to show and how long each stays. It is simple, but if you know CSS you can make it look very nice.

Important: reading posts requires an X developer account and an X API plan that allows reading posts. X controls which plans include this and what they cost. See https://docs.x.com/ for current details.

Getting a Bearer Token

  1. Sign in to the X developer portal.
  2. Create a project and an app, on a plan that allows reading posts.
  3. Open the app’s “Keys and tokens” tab and generate a Bearer Token.
  4. Paste it into the widget’s “X API Bearer Token” field.

External services

This plugin connects to the X API (https://api.x.com/2/) to retrieve the recent posts, display name and avatar of the X user you enter in the widget. This is needed to show the feed.

Each time the feed is not already cached (results are cached for 30 minutes, the user lookup for one day) your server sends: the X username you entered, the number of posts requested and your own Bearer Token (as the Authorization header, to authenticate your app). No data about your site’s visitors is sent. Your server’s IP address is visible to X as part of the normal request.

The service is provided by X Corp.: Developer Agreement and Policy, Terms of Service and Privacy Policy.

The avatar image, if you enable “Show avatar / user”, is loaded by your visitors’ browsers from X’s image servers (pbs.twimg.com).

Screenshots

Installation

  1. Upload the plugin to the /wp-content/plugins/ directory and activate it.
  2. Go to Appearance > Widgets and add the “WP jTweets” widget to a sidebar.
  3. Enter the X username to display.
  4. Enter your X API Bearer Token (see “Getting a Bearer Token” below).

FAQ

Why do I need a Bearer Token now?

X retired the old v1.1 API that earlier versions of this plugin used. Version 2.0 uses the X API v2, which needs only a Bearer Token. The old API key, secret and access token fields are no longer used.

The widget says “No tweets to display”

If you are logged in as an administrator, the widget also shows the reason (for example a bad token, or an API plan that does not allow reading posts). Failed requests are cached for 5 minutes.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“WP-jTweets” is open source software. The following people have contributed to this plugin.

Contributors

Translate “WP-jTweets” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

2.0.0

  • Uses the X API v2 with a Bearer Token (the v1.1 API no longer works). The old key/secret/token fields are removed.
  • Replaced the bundled TwitterOAuth library with the WordPress HTTP API. cURL is no longer required, and SSL certificates are now verified.
  • Output is escaped. Tweet text, usernames and links are sanitized.
  • Widget settings are sanitized when saved.
  • “Show retweets” and “Open links in new window” now work.
  • The stylesheet and script only load on pages that show the widget.
  • Fixed duplicate class attribute and misspelled avatar CSS classes.
  • Documented the external service. Declared the license in the readme.
  • Compatible with PHP 7.2 to 8.5.

1.1.5

  • Changed some of the naming to match what Twitter now calls the fields.

1.1.4

  • Standardizes the code to be more “The WP Way”

1.1.3

  • Added classes (in addition to IDs for backwards compatibility) to display multiple Twitter IDs on the same page
  • Styling and JS now run off of classes
  • Added option to allow resizing on fading tweets

1.1.2

  • Adds option to display or not to retweets

1.1.1

  • Adds an option to show “header” section to show the user’s name and avatar
  • Adds linking for @usernames, #hashtags and URLs
  • Adds basic theming options
  • Adds transient for “caching” of the feed

1.1.0

  • Uses the Twitter API version 1.1

1.0.6

  • Wraps the LI’s into a UL for better HTML validation

1.0.5

  • Adds the ability to disable the fade in/out and just display the feed without jQuery
  • Calls in a style.css within the plugin so you don’t have to drop in the CSS in a theme

1.0.4

  • Uses jQuery ‘data’ method to pass time rotation instead of showing in the HTML
  • Adds some error checking in case the Twitter user doesn’t exist or the feed doesn’t pull

1.0.3

  • Changes to use the new Twitter API which caused an “array_slice” error

1.0.2

  • Removed redundant Javascript in the front end

1.0.1

  • Readme and notes changes

1.0

  • Initial release