WP-CLI Commands
bash# Show PWA status (HTTPS, manifest, SW, VAPID)
wp opwa status
# Generate VAPID key pair
wp opwa vapid generate
# Send a push notification to all subscribers
wp opwa push send --title="Hello" --body="World" --url="https://example.com"
# List all push subscribers
wp opwa subscribers list
# Clear all subscribers
wp opwa subscribers clear
# Rebuild service worker cache config
wp opwa sw rebuild
REST API Endpoints
| Method | Endpoint | Auth | Description |
| GET | /wp-json/opwa/v1/manifest | None | Web App Manifest JSON |
| POST | /wp-json/opwa/v1/push/subscribe | None | Subscribe to push |
| DELETE | /wp-json/opwa/v1/push/subscribe | None | Unsubscribe |
| POST | /wp-json/opwa/v1/analytics/beacon | None | Send analytics beacon |
| GET | /wp-json/opwa/v1/sw-config | None | SW config for dynamic SW |
Developer Filters
php// Modify the manifest before output
add_filter( 'opwa_manifest', function( array $manifest ): array {
$manifest['categories'] = ['news', 'productivity'];
return $manifest;
} );
// Modify service worker config
add_filter( 'opwa_sw_config', function( array $config ): array {
$config['custom_routes'][] = [
'pattern' => '/api/*',
'strategy' => 'network-only',
];
return $config;
} );
// Extend precache URL list
add_filter( 'opwa_precache_urls', function( array $urls ): array {
$urls[] = '/offline-page/';
return $urls;
} );
// Modify push payload before send
add_filter( 'opwa_push_payload', function( array $payload, string $endpoint ): array {
return $payload;
}, 10, 2 );
Developer Actions
phpadd_action( 'opwa_push_sent', function( int $campaign_id, int $count ) {} );
add_action( 'opwa_subscriber_added', function( string $endpoint ) {} );
add_action( 'opwa_subscriber_removed', function( string $endpoint ) {} );
add_action( 'opwa_sw_registered', function() {} );