Playground Client
Provides a PlaygroundClient that can be used to control a WordPress Playground iframe:
import { startPlaygroundWeb } from '@wp-playground/client';
const client = await startPlaygroundWeb({
iframe: document.getElementById('wp'),
remoteUrl: `https://playground.wordpress.net/remote.html`,
});
const response = await client.run({
code: '<?php require_once "/wordpress/wp-load.php"; $posts = get_posts(); echo "Post Title: " . $posts[0]->post_title;',
});
console.log(response.text);
Using TypeScript is highly recommended as this package ships with comprehensive types – hit ctrl+space in your IDE after client.
and you'll see all the available methods.
Once you have a PlaygroundClient instance, you can use it to control the playground:
await client.writeFile('/index.php', '<?php echo "Hi!"; ');
await client.run({
scriptPath: '/index.php',
});
console.log(await client.readFileAsText('/index.php'));
await client.request({
url: '/index.php',
method: 'POST',
body: {
foo: 'bar',
},
});
To see all the available methods, check out the PlaygroundClient interface.
[v3.0.8] (2025-10-02)
Documentation
- [i18n] Added Gujarati Translation for Documentation Contributions. (#2610)
Website
- [PHP Playground] Attach client to https://playground.wordpress.net/remote.html. (#2717)
Internal
- Add name to Playground Website and Website extras cli packages. (#2716)
Various
- [i18n] Fixing typos in French translation of quick-start-guide.md. (#2712)
Contributors
The following contributors merged PRs in this release:
@adamziel @beryl-dlg @dilipom13