Description
Instead of relying on heavy third-party embeds or exposing Spotify API keys to visitors’ browsers (a critical security risk), this plugin provides a clean, native, and highly performant way to show your website visitors what you are currently listening to on Spotify.
The Now Playing Widget for Spotify was built strictly according to WordPress Coding Standards, optimal front-end performance, and frictionless UX. It presents a modern, floating Glassmorphism UI using the [npwfs_now_playing] shortcode.
Features
- 1-Click OAuth2 Setup: Connect your Spotify account securely through the WordPress admin dashboard with a single button click. No terminal commands, curl scripts, or manual token handling required.
- CSRF-Protected Handshake: OAuth state parameters are validated using WordPress cryptographic nonces to protect your administration session.
- Zero Credential Exposure: Communication with the Spotify API occurs strictly server-to-server. Client Secrets and Refresh Tokens are stored safely in your database and are never delivered to visitor browsers.
- Intelligent Two-Tier Caching: Spotify access tokens are cached server-side until near expiration. Public track requests use WordPress Transients (30-second TTL by default) to keep page loads instant and stay safely within Spotify rate limits.
- Idle / Last Played State: When you are not playing music, the widget seamlessly displays the last track from your playback history with subtle visual styling.
- Battery & Network Friendly: The front-end polling pauses automatically when visitors switch to another browser tab using the HTML5 Page Visibility API.
- Accessible & Responsive: Fully responsive floating bar with reduced-motion support (
prefers-reduced-motion) and subtle animated equalizer bars. - Appearance Customizer & Live Preview: Customize accent color, glass backdrop, opacity, border shape (pill, rounded, square), floating screen position, and hover state effects with an interactive real-time preview in the admin panel.
- Spinning Vinyl Record Effect: Option to display the album artwork as a spinning vinyl record with realistic groove borders during active playback, or as a classic static album sleeve.
- Clean Uninstallation: Includes an
uninstall.phphandler to clean all stored options and transients from the database upon deletion.
External services
This plugin connects to external services provided by Spotify to authenticate the site owner and retrieve playback information:
- Spotify Accounts Service (https://accounts.spotify.com)
* Purpose: Handles the OAuth2 authorization code exchange and token refresh so the plugin can securely communicate with Spotify on the site owner’s behalf without storing passwords.
* Data sent and conditions: The site administrator’s Spotify API client credentials (Client ID and Client Secret), authorization code, and refresh token are transmitted server-to-server over HTTPS during initial setup and token refreshes. No website visitor data is ever sent to this service.
* Terms of service: Spotify Developer Terms and Spotify Terms of Use
* Privacy policy: Spotify Privacy Policy
- Spotify Web API (https://api.spotify.com/v1)
* Purpose: Fetches the site owner’s currently playing track (/v1/me/player/currently-playing) or recently played track history (/v1/me/player/recently-played).
* Data sent and conditions: An OAuth2 Bearer Access Token is sent in the HTTP Authorization header by your WordPress server when requesting listening activity. Requests are cached server-side using WordPress Transients (30-second TTL by default) to minimize calls. No user, visitor, or tracking data is ever collected or sent to Spotify.
* Terms of service: Spotify Developer Terms and Spotify Terms of Use
* Privacy policy: Spotify Privacy Policy
Screenshots

![The Spotify Connection settings tab showing the 3-step OAuth2 setup, connection status, and the [npwfs_now_playing] shortcode.](https://ps.w.org/now-playing-widget-for-spotify/assets/screenshot-2.png?rev=3821423)

Installation
- Upload the plugin folder
now-playing-widget-for-spotifyto your/wp-content/plugins/directory, or install the.ziparchive via Plugins > Add New > Upload Plugin. - Activate the plugin through the Plugins screen in WordPress.
- Navigate to Settings > Now Playing for Spotify in your dashboard.
- Follow the 3-Step Setup:
- Create a free developer application in the Spotify Developer Dashboard.
- Copy the exact Redirect URI provided on the settings page and save it in your Spotify App settings.
- Paste your Client ID and Client Secret, then click Save credentials.
- Click the green Connect with Spotify button. Accept the prompt on Spotify’s authorization screen.
- Place the shortcode
[npwfs_now_playing]anywhere on your site (posts, pages, block themes, Elementor, or footer widget areas).
(Note: The widget stays hidden until an account is connected and a track is found, keeping your site layout clean).
FAQ
-
Does this plugin track website visitors?
-
No. In strict compliance with WordPress.org Guidelines 7 & 9, this plugin does not track website visitors, does not store tracking cookies, and does not send any visitor data to Spotify or any third party. All external API requests are performed strictly server-to-server between your WordPress host and Spotify to display the site owner’s playback, which is then served sanitized to visitors via a local WordPress REST endpoint.
-
Does this plugin slow down my site?
-
No. Assets (CSS/JS) are only enqueued when the shortcode is actually rendered on the current page. Track data is cached via WordPress Transients, and front-end polling is throttled and paused when the user switches tabs.
-
Will my Spotify credentials be exposed to visitors?
-
Never. All requests to the Spotify Accounts API and Web API are executed by your WordPress server in PHP. The browser only receives the public track metadata (song name, artist, cover image URL, Spotify link).
-
What happens when I pause my playback?
-
The plugin automatically detects the idle state and queries your recently played history, displaying your last track with a “Last played” label.
-
Can I customize the polling interval or cache duration?
-
Yes. You can use standard WordPress filters in your theme’s
functions.php:
*add_filter('npwfs_cache_ttl', function() { return 60; });(server cache seconds)
*add_filter('npwfs_poll_interval', function() { return 20; });(frontend refresh seconds) -
What happens when I deactivate or delete the plugin?
-
Deactivation preserves your credentials so you can reactivate without repeating setup. Deleting the plugin through WordPress triggers
uninstall.php, which permanently deletes all stored options and transients.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“Now Playing Widget for Spotify” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “Now Playing Widget for Spotify” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
1.1.0
- Major refactor adhering to WordPress.org Plugin Coding Standards and Review Guidelines.
- Added Appearance & Live Preview customizer tab for colors, glass opacity, border shapes, screen positions, and hover effects.
- Added Spinning Vinyl Record animation effect with realistic groove styling and classic cover toggle.
- Documented external Spotify Accounts and Web API services in strict compliance with Guideline 6.
- Structured modular codebase: separated options, Spotify API client, REST API controller, shortcode and admin logic.
- Added CSRF state parameter validation via
wp_create_nonceduring OAuth2 flow. - Upgraded shortcode to properly prefixed
[npwfs_now_playing]with multi-instance DOM support. - Implemented access token transient caching to avoid redundant token grant requests on every poll.
- Added Page Visibility API support to pause front-end polling on inactive browser tabs.
- Added animated audio equalizer bars and
prefers-reduced-motionaccessibility support. - Added
uninstall.phpto completely clean up database options and transients on deletion. - Added automatic migration from legacy 1.0.0 option names (
tsw_*).
1.0.0
- Initial release.
- 1-Click OAuth2 flow setup.
- Fallback to recently played history.
- Glassmorphism UI styling.
