Ir al contenido principal

Blueprints Functions and the API Client

Every Blueprint step you can declare in the JSON object also provides a handler function that can be used directly.

For example:

import { startPlaygroundWeb, login, installPlugin } from 'https://playground.wordpress.net/client/index.js';

const client = await startPlaygroundWeb({
iframe: document.getElementById('wp'),
remoteUrl: `https://playground.wordpress.net/remote.html`,
});
await client.isReady();

await login(client, {
username: 'admin',
});

// The URL of your plugin's ZIP file.
const pluginUrl = 'https://example.com/my-plugin.zip';
const response = await fetch(pluginUrl);
await installPlugin(client, {
// Resources can only be used with JSON Blueprints.
// If you use functions, you must provide the resolved
// file.
pluginData: new File([await response.blob()], 'my-plugin.zip'),
});

For more information and live examples visit the Blueprints Steps page.