A WordPress plugin that integrates WordPress installations with the Wasmer platform, providing REST API endpoints, admin interface enhancements, and management features.
The WP Wasmer plugin enables seamless integration between WordPress sites and the Wasmer platform. It provides:
- REST API endpoints for health checks, configuration retrieval, and magic login
- Admin interface enhancements with Wasmer Control Panel access
- WordPress core update management (blocks manual updates, redirects to Wasmer)
- WP-CLI commands for automated installations
- Copy the plugin files to your WordPress installation's
wp-content/plugins/wp-wasmer/directory - Activate the plugin through the WordPress admin interface or via WP-CLI
The plugin requires the following environment variables to be set:
WASMER_WEBSITE_URL- The base URL for the Wasmer website (e.g.,https://wasmer.io)WASMER_GRAPHQL_URL- The GraphQL API endpoint URL (e.g.,https://registry.wasmer.io/graphql)WASMER_APP_ID- The unique identifier for your Wasmer app instanceWASMER_PERISHABLE_TIMESTAMP(optional) - Unix timestamp indicating when the app will expire
These can be set via:
- Environment variables in your hosting environment
- A must-use plugin (mu-plugin) that sets them via
putenv()
All endpoints are registered under the /wasmer/v1/ namespace and are accessible at:
/?rest_route=/wasmer/v1/{endpoint}
A simple health check endpoint to verify the plugin is active and responding.
Method: GET
URL: /?rest_route=/wasmer/v1/check
Response:
{
"status": "success"
}Headers:
Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0Pragma: no-cacheExpires: 0
Example:
curl "http://localhost:8080/?rest_route=/wasmer/v1/check"Returns comprehensive information about the WordPress installation, including plugins, themes, PHP configuration, MySQL version, and more.
Method: GET
URL: /?rest_route=/wasmer/v1/liveconfig
Response:
{
"liveconfig_version": "1",
"wasmer_plugin": {
"version": "0.3.0",
"dir": "/var/www/html/wp-content/plugins/wp-wasmer/",
"url": "http://localhost:8080/wp-content/plugins/wp-wasmer/"
},
"wordpress": {
"version": "6.7.1",
"latest_version": "6.8.2",
"url": "http://localhost:8080",
"language": "en_US",
"timezone": "UTC",
"debug": false,
"debug_log": false,
"is_main_site": true,
"plugins": [
{
"slug": "wp-wasmer",
"icon": null,
"url": null,
"name": "WP Wasmer",
"version": "0.3.0",
"description": "Wasmer Plugin for WordPress",
"is_active": true,
"latest_version": null
}
],
"themes": [
{
"slug": "twentytwentyfour",
"name": "Twenty Twenty-Four",
"version": "1.3",
"latest_version": "1.3",
"is_active": true
}
],
"users": {
"total": 1,
"admins": 1
},
"posts": {
"count": "1"
},
"pages": {
"count": "1"
}
},
"php": {
"version": "8.3.0-dev",
"architecture": "32",
"memory_limit": "128M",
"max_execution_time": "0",
"max_input_time": "-1",
"max_input_vars": "1000"
},
"mysql": {
"version": "8.0",
"server": "3.40.1"
}
}Headers:
Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0Pragma: no-cacheExpires: 0
Response Fields:
liveconfig_version- Version of the liveconfig API formatwasmer_plugin- Information about the Wasmer plugin itselfwordpress- WordPress installation details:version- Current WordPress versionlatest_version- Latest available WordPress versionplugins- Array of installed plugins with their detailsthemes- Array of installed themes with their detailsusers- User statistics (total users, admin count)posts/pages- Content counts
php- PHP configuration and version informationmysql- MySQL/MariaDB version information
Example:
curl "http://localhost:8080/?rest_route=/wasmer/v1/liveconfig"Provides token-based authentication that automatically logs in a user to the WordPress admin. The token is validated against the Wasmer GraphQL API.
Method: GET
URL: /?rest_route=/wasmer/v1/magiclogin&magiclogin={token}
Query Parameters:
magiclogin(required) - Authentication token to validate
How it works:
- The plugin validates the token by querying the Wasmer GraphQL API
- If valid, it retrieves the user's email from the GraphQL response
- It finds or creates an administrator user matching that email
- The user is automatically logged in via WordPress authentication cookies
- The user is redirected to the WordPress admin dashboard
GraphQL Query: The plugin executes the following GraphQL query to validate the token:
query ($appid: ID!) {
viewer {
email
}
node(id: $appid) {
... on DeployApp {
id
}
}
}Success Response:
- Status Code:
302(Redirect) - Location:
{admin_url}/?platform=wasmer - Set-Cookie: WordPress authentication cookies (
wordpress_logged_in_*) - Headers:
Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0Pragma: no-cache
Error Responses:
403- Invalid or expired token400- GraphQL query failed500- Missing token,WASMER_GRAPHQL_URL, orWASMER_APP_ID
User Selection Logic:
- First, searches for an administrator user with an email matching the GraphQL response
- If no match found, selects the first available administrator user
- If no administrators exist, the login fails
Example:
curl -L "http://localhost:8080/?rest_route=/wasmer/v1/magiclogin&magiclogin=your-token-here"Note: The -L flag follows redirects. Without it, you'll see the redirect headers but won't be logged in.
The plugin adds a "Wasmer" menu item to the WordPress admin top bar with:
- Wasmer Control Panel - Link to the Wasmer dashboard for the current app
- Claim App (if
WASMER_PERISHABLE_TIMESTAMPis set) - Link to claim the app before expiration, with a countdown notification
The menu displays a notification badge if the app has an expiration timestamp set.
The plugin implements several features to manage WordPress core updates:
- Blocks Manual Core Updates - Prevents users from manually updating WordPress core through the WordPress admin interface
- Disables Automatic Updates - Disables WordPress automatic background updates
- Admin Notices - Shows notices on the Updates page (
/wp-admin/update-core.php) directing users to use Wasmer WordPress Settings for updates - Error Messages - Displays user-friendly error messages when users attempt manual core updates
When a user attempts to update WordPress core manually, they'll see a message directing them to:
{wasmer_base_url}/id/{WASMER_APP_ID}/settings/wordpress
Automatic updates for plugins and themes are disabled by default. Manual updates through the WordPress admin interface remain available.
Prerequisites:
- Node.js (for running tests)
- pnpm (package manager)
- Access to
@wp-now/wp-nowfor local WordPress development
The plugin includes a comprehensive test suite located in wasmer/tests/wasmer.test.js. The tests use Node.js's built-in test runner and require a local WordPress instance.
- Install test dependencies:
cd wasmer/tests
pnpm install- Set environment variables (optional):
export WP_VERSION=6.7.1 # WordPress version to test (default: 6.7.1)
export PHP_VERSION=8.3 # PHP version to use (default: 8.3)
export PORT=8080 # Port for the test server (default: 8080)cd wasmer/tests
node wasmer.test.jsOr using Node.js test runner:
cd wasmer/tests
node --test wasmer.test.jsThe test suite includes:
-
Basic WordPress Functionality
- Verifies WordPress homepage loads correctly
-
Admin Interface Tests
- Verifies Wasmer Control Panel link appears in admin
- Tests WordPress upgrade notices
- Verifies Wasmer-specific update notices
-
REST API Tests
- Magic Login:
- Tests failure with wrong token (expects 403)
- Tests success with proper token (expects 302 redirect)
- Verifies authentication cookies are set
- Verifies cache-control headers
- Verifies redirect location
- Health Check:
- Tests
/wasmer/v1/checkendpoint - Verifies response format and cache headers
- Tests
- Live Config:
- Tests
/wasmer/v1/liveconfigendpoint - Verifies comprehensive configuration data structure
- Validates WordPress, PHP, and MySQL information
- Tests
- Magic Login:
The tests use a WordPress blueprint file (wp-blueprint-protected.json) that:
- Sets up environment variables for the plugin
- Installs and activates the
wp-force-loginplugin (to test password-protected scenarios) - Configures WordPress for testing
The test suite includes a mock GraphQL server running on port 4000 that:
- Validates Bearer tokens (expects
Bearer 123for successful authentication) - Returns mock user and app data for the magic login flow
For manual testing of endpoints:
- Start a local WordPress instance (using wp-now or similar):
npx @wp-now/wp-now start --wp=6.7.1 --php=8.3 --port=8080 --blueprint=wasmer/tests/wp-blueprint-protected.json- Set environment variables in a mu-plugin or via
putenv():
putenv("WASMER_WEBSITE_URL=http://wasmer.xyz");
putenv("WASMER_GRAPHQL_URL=http://localhost:4000/graphql");
putenv("WASMER_APP_ID=abc");- Test endpoints:
# Health check
curl "http://localhost:8080/?rest_route=/wasmer/v1/check"
# Live config
curl "http://localhost:8080/?rest_route=/wasmer/v1/liveconfig"
# Magic login (requires valid token from GraphQL)
curl -L "http://localhost:8080/?rest_route=/wasmer/v1/magiclogin&magiclogin=123"To test the magic login endpoint, you'll need:
- A GraphQL server that accepts Bearer token authentication
- The GraphQL server should implement the query structure expected by the plugin
- A valid token that returns user email and app ID in the GraphQL response
The test suite includes a mock GraphQL server for this purpose.
GPL-3.0
For issues, feature requests, or contributions, please visit the GitHub repository.