Blueprints em JSON e o cliente da API
Você pode inicializar o cliente da API do Playground com um Blueprint em JSON. Assim, você pode pré-configurar o Playground como quiser, sem precisar gerenciar barras de progresso nem baixar arquivos remotos.
Adicione à sua página um iframe com o ID wp:
<iframe id="wp"></iframe>
import { startPlaygroundWeb } from 'https://playground.wordpress.net/client/index.js';
const iframe = document.querySelector<HTMLIFrameElement>('iframe#wp');
if (!iframe) {
throw new Error('Could not find <iframe id="wp"> on the page.');
}
const client = await startPlaygroundWeb({
iframe,
remoteUrl: `https://playground.wordpress.net/remote.html`,
blueprint: {
preferredVersions: {
wp: 'latest',
php: '8.3',
},
steps: [
{ step: 'login' },
{
step: 'installPlugin',
pluginData: {
resource: 'wordpress.org/plugins',
slug: 'gutenberg',
},
},
],
},
});
await client.isReady();
Para executar um Blueprint em JSON durante a inicialização, passe-o na opção blueprint de startPlaygroundWeb().
Se essa abordagem atender às suas necessidades, saiba mais sobre Blueprints em JSON.
Se precisar trabalhar com um cliente já inicializado, consulte as funções de Blueprint.