diff --git a/src/api/ApiClient.ts b/src/api/ApiClient.ts index feec9df8..54b8f78d 100644 --- a/src/api/ApiClient.ts +++ b/src/api/ApiClient.ts @@ -21,6 +21,21 @@ export class ApiClient { return this._siteUrl; } + async createPost(): Promise< void > { + const response = await this.playgroundClient.request( { + url: `/index.php?rest_route=/wp/v2/posts`, + method: 'POST', + body: { + title: + 'New Post from API Client - ' + + ( Math.random() + 1 ).toString( 36 ).substring( 7 ), + content: 'This is a new post created via the API client.', + status: 'publish', + }, + } ); + console.log( response, response.json ); + } + async getPosts(): Promise< Post[] > { const response = ( await this.get( '/wp/v2/posts' diff --git a/src/ui/preview/Playground.tsx b/src/ui/preview/Playground.tsx index 7f58903e..c18ec2f0 100644 --- a/src/ui/preview/Playground.tsx +++ b/src/ui/preview/Playground.tsx @@ -100,9 +100,25 @@ function steps(): StepDefinition[] { pluginName: 'Try WordPress', pluginPath: '/wordpress/wp-content/plugins/try-wordpress', }, + { + step: 'mkdir', + path: '/wordpress/wp-content/mu-plugins', + }, + { + step: 'writeFile', + path: '/wordpress/wp-content/mu-plugins/authenticate-rest-request.php', + data: authenticateRestRequest(), + }, ]; } +function authenticateRestRequest(): string { + return `