From 7807a6b748ad8109614dfac0b0434ee70b113d0f Mon Sep 17 00:00:00 2001 From: JuanMa Garrido Date: Wed, 11 Sep 2024 13:47:24 +0200 Subject: [PATCH 1/8] guide for plugin developers --- .../docs/main/guides/for-plugin-developers.md | 210 ++++++++++++++++++ packages/docs/site/sidebars.js | 2 +- 2 files changed, 211 insertions(+), 1 deletion(-) diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index f7c4b82668..83c67cd082 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -3,3 +3,213 @@ title: For Plugin Developers slug: /guides/for-plugin-developers description: WordPress Playground for Plugin Developers --- + +The WordPress Playground is an innovative tool that allows plugin developers to build, test and showcase their plugins directly in a browser environment. + +This guide will explore **how you can leverage the WordPress Playground to enhance your plugin development workflow, create live demos to showcase your WordPress plugin to the world, and streamline your plugin testing process**. + +:::info + +Discover how to [Build](/about/build), [Test](/about/test), and [Launch](/about/launch) your products with WordPress Playground in the [About Playground](/about) section. + +::: + +## Launching a Playground instance with a plugin + +### Plugin in the WordPress themes directory + +With WordPress Playground, you can quickly launch a WordPress installation with any plugin available in the [WordPress Plugins Directory](https://wordpress.org/plugins/) installed and activated. Simply pass the `plugin` [query parameter](/developers/apis/query-api) to the [Playground URL](https://playground.wordpress.net) like this: https://playground.wordpress.net/?plugin=gutenberg. + +:::tip +You can install and activate several plugins via query parameters by repeating the `plugin` parameter for every plugin you want to be installed and activated in the Playground instance. For example: https://playground.wordpress.net/?plugin=gutenberg&plugin=akismet&plugin=wordpress-seo. +::: + +You can also load any plugin from the WordPress plugins directory by setting the [`installPlugin` step](/blueprints/steps#InstallPluginStep) of a [Blueprint](/blueprints/getting-started) passed to the Playground instance. + +```json +{ + "landingPage": "/wp-admin/plugins.php", + "login": true, + "steps": [ + { + "step": "installPlugin", + "pluginZipFile": { + "resource": "wordpress.org/plugins", + "slug": "gutenberg" + } + } + ] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/plugins.php%22,%22login%22:true,%22steps%22:[{%22step%22:%22installPlugin%22,%22pluginZipFile%22:{%22resource%22:%22wordpress.org/plugins%22,%22slug%22:%22gutenberg%22}}]}) + +Blueprints can be passed to a Playground instance [in several ways](/blueprints/using-blueprints). + +### Plugin in a GitHub repository + +A plugin stored in a GitHub repository can also be loaded in a Playground instance via Blueprints. + +With the `pluginZipFile` property of the [`installPlugin` blueprint step](/blueprints/steps#installPlugin), you can define a [`url` resource](/blueprints/steps/resources#urlreference) that points to the location of the `.zip` file containing the plugin you want to load in the Playground instance. + +To avoid CORS issues, the Playground project provides a [GitHub proxy](https://playground.wordpress.net/proxy) that allows you to generate a `.zip` from a repository (or even a folder inside a repo) containing your plugin. + +:::info +[GitHub proxy](https://playground.wordpress.net/proxy) is an incredibly useful tool to load plugins from GitHub repositories as it allows you to load a plugin from a specific branch, a specific directory, a specific commit or a specific PR. +::: + +For example, the following `blueprint.json` installs a plugin from a GitHub repository leveraging the https://github-proxy.com tool: + +```json +{ + "landingPage": "/wp-admin/admin.php?page=add-media-from-third-party-service", + "login": true, + "steps": [ + { + "step": "installPlugin", + "pluginZipFile": { + "resource": "url", + "url": "https://github-proxy.com/proxy/?repo=wptrainingteam/devblog-dataviews-plugin" + } + } + ] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/admin.php?page=add-media-from-third-party-service%22,%22login%22:true,%22steps%22:[{%22step%22:%22installPlugin%22,%22pluginZipFile%22:{%22resource%22:%22url%22,%22url%22:%22https://github-proxy.com/proxy/?repo=wptrainingteam/devblog-dataviews-plugin%22}}]}) + +### Plugin code from a gist + +By combining the [`writeFile`](/blueprints/steps#WriteFileStep) and [`activatePlugin`](/blueprints/steps#activatePlugin) steps you can also launch a WP Playground instance with a plugin built on the fly from code stored on [a gist](https://gist.githubusercontent.com/ndiego/456b74b243d86c97cda89264c68cbdee/raw/ff00cf25e6eebe4f5a4eaecff10286f71e65340b/block-hooks-demo.php): + +```json +{ + "landingPage": "/wp-admin/plugins.php", + "login": true, + "steps": [ + { + "step": "login" + }, + { + "step": "writeFile", + "path": "/wordpress/wp-content/plugins/0-plugin.php", + "data": { + "resource": "url", + "url": "https://gist.githubusercontent.com/ndiego/456b74b243d86c97cda89264c68cbdee/raw/ff00cf25e6eebe4f5a4eaecff10286f71e65340b/block-hooks-demo.php" + } + }, + { + "step": "activatePlugin", + "pluginName": "Block Hooks Demo", + "pluginPath": "0-plugin.php" + } + ] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/plugins.php%22,%22login%22:true,%22steps%22:[{%22step%22:%22login%22},{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/plugins/0-plugin.php%22,%22data%22:{%22resource%22:%22url%22,%22url%22:%22https://gist.githubusercontent.com/ndiego/456b74b243d86c97cda89264c68cbdee/raw/ff00cf25e6eebe4f5a4eaecff10286f71e65340b/block-hooks-demo.php%22}},{%22step%22:%22activatePlugin%22,%22pluginName%22:%22Block%20Hooks%20Demo%22,%22pluginPath%22:%220-plugin.php%22}]}) + +## Setting up a demo for your plugin with Blueprints + +When providing a link to a WordPress Playground instance with some plugins activated, you may also want to customize the initial setup for that Playground instance using those plugins. With Playground's [Blueprints](/blueprints/getting-started) you can load/activate plugins and configure the Playground instance. + +:::tip + +Some useful tools and resources provided by the Playground project to work with blueprints are: + +- Check the [Blueprints Gallery](https://github.com/WordPress/blueprints/blob/trunk/GALLERY.md) to explore real-world code examples of using WordPress Playground to launch a WordPress site with a variety of setups. +- The [WordPress Playground Step Library](https://akirk.github.io/playground-step-library/#) tool provides a visual interface to drag or click the steps to create a blueprint for WordPress Playground. You can also create your own steps! +- The [Blueprints builder](https://playground.wordpress.net/builder/builder.html) tool allows you edit your blueprint online and run it directly in a Playground instance. + +::: + +Through properties and [`steps`](/blueprints/steps) in the Blueprint, you can configure the Playground instance's initial setup, providing your plugins with the content and configuration needed for proper showcasing. + +:::info + +One thing you may want to do to provide a good demo with WordPress Playground is to load default content to better showcase the features of your plugin or theme. Check out the [Providing content for your demo](/guides/providing-content-for-your-demo) guide to learn more + +::: + +### `plugins` + +If your plugin has dependencies on other plugins you can use the `plugins` shorthand to install yours along with any other needed plugins. + +```json +{ + "landingPage": "/wp-admin/plugins.php", + "plugins": ["gutenberg", "sql-buddy", "create-block-theme"], + "login": true +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/plugins.php%22,%22plugins%22:[%22gutenberg%22,%22sql-buddy%22,%22create-block-theme%22],%22login%22:true}) + +### `landingPage` + +If your plugin has a settings view or onboarding wizard, you can use the `landingPage` shorthand to automatically redirect to any page in the Playground instance upon loading. + +```json +{ + "landingPage": "/wp-admin/admin.php?page=my-custom-gutenberg-app", + "login": true, + "plugins": ["https://raw.githubusercontent.com/WordPress/block-development-examples/deploy/zips/data-basics-59c8f8.zip"] +} +``` + +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/admin.php?page=my-custom-gutenberg-app%22,%22login%22:true,%22plugins%22:[%22https://raw.githubusercontent.com/WordPress/block-development-examples/deploy/zips/data-basics-59c8f8.zip%22]}) + +### `writeFile` + +With the `writeFile` step you can create on the fly any plugin file taking the code from a file stored on a GitHub repo or a gist. + +Here’s an example of a **[plugin that generates Custom Post Types](https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/custom-post/books.php)**, placed in the `mu-plugins` folder to ensure the code runs automatically on load: + +```json +{ + "landingPage": "/wp-admin/", + "login": true, + "steps": [ + { + "step": "writeFile", + "path": "/wordpress/wp-content/mu-plugins/books.php", + "data": { + "resource": "url", + "url": "https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/custom-post/books.php" + } + } + ] +} +``` + +## Plugin Development + +### Local plugin development and testing with Playground + +From a plugins' folder in your local development environment, you can quickly load locally a Playground instance with that plugin loaded and activated. You can do that by launching, in the plugin's directory, the [`wp-now` command](/developers/local-development/wp-now) from your preferred command line program or the [Visual Code Studio extension](/developers/local-development/vscode-extension) from the [Visual Studio Code](https://code.visualstudio.com/) IDE. + +For example: + +```bash +git clone git@github.com:wptrainingteam/devblog-dataviews-plugin.git +cd devblog-dataviews-plugin +npx @wp-now/wp-now start +``` + +### See your local changes in a Playground instance and directly create PRs in a GitHub repo with your changes + +With Google Chrome (it only works with this browser, for now) you can synchronize a Playground instance with your local plugin's code and your plugin's GitHub repo. With this connection you can: + +- See live (in the Playground instance) your local changes +- Create PRs in the GitHub repo with your changes + +Here's a little demo of this workflow in action: + + +

+ +:::info + +Check [About Playground > Build > Synchronize your playground instance with a local folder and create Github Pull Requests](/about/build#synchronize-your-playground-instance-with-a-local-folder-and-create-github-pull-requests) for more info. + +::: diff --git a/packages/docs/site/sidebars.js b/packages/docs/site/sidebars.js index 75eaa76e56..fc93d769c1 100644 --- a/packages/docs/site/sidebars.js +++ b/packages/docs/site/sidebars.js @@ -46,7 +46,7 @@ const sidebars = { items: [ 'main/guides/wordpress-native-ios-app', // 'main/guides/for-theme-developers', - // 'main/guides/for-plugin-developers', + 'main/guides/for-plugin-developers', ], }, { From 93befa04ca0320165827a9b1e30fda54c569c73d Mon Sep 17 00:00:00 2001 From: JuanMa Date: Wed, 11 Sep 2024 16:38:58 +0100 Subject: [PATCH 2/8] Update packages/docs/site/docs/main/guides/for-plugin-developers.md Co-authored-by: Birgit Pauli-Haack --- packages/docs/site/docs/main/guides/for-plugin-developers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index 83c67cd082..5d282b531e 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -198,7 +198,7 @@ npx @wp-now/wp-now start ### See your local changes in a Playground instance and directly create PRs in a GitHub repo with your changes -With Google Chrome (it only works with this browser, for now) you can synchronize a Playground instance with your local plugin's code and your plugin's GitHub repo. With this connection you can: +With Google Chrome you can synchronize a Playground instance with your local plugin's code and your plugin's GitHub repo. With this connection you can: - See live (in the Playground instance) your local changes - Create PRs in the GitHub repo with your changes From bb496a13c3264e703aaae1525371af6755bb7fdd Mon Sep 17 00:00:00 2001 From: JuanMa Date: Wed, 11 Sep 2024 16:39:14 +0100 Subject: [PATCH 3/8] Update packages/docs/site/docs/main/guides/for-plugin-developers.md Co-authored-by: Birgit Pauli-Haack --- packages/docs/site/docs/main/guides/for-plugin-developers.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index 5d282b531e..2b346637bc 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -207,7 +207,8 @@ Here's a little demo of this workflow in action:

- +:::note +This feature is only available for Google Chrome for now. It won't work with other browsers, yet. :::info Check [About Playground > Build > Synchronize your playground instance with a local folder and create Github Pull Requests](/about/build#synchronize-your-playground-instance-with-a-local-folder-and-create-github-pull-requests) for more info. From 4d4257543fa8d4d742005d52757ccb2bcabf1618 Mon Sep 17 00:00:00 2001 From: JuanMa Garrido Date: Wed, 11 Sep 2024 17:43:12 +0200 Subject: [PATCH 4/8] Feedback by Birgit addressed --- .../site/docs/main/guides/for-plugin-developers.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index 83c67cd082..ce470e9645 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -18,7 +18,7 @@ Discover how to [Build](/about/build), [Test](/about/test), and [Launch](/about/ ### Plugin in the WordPress themes directory -With WordPress Playground, you can quickly launch a WordPress installation with any plugin available in the [WordPress Plugins Directory](https://wordpress.org/plugins/) installed and activated. Simply pass the `plugin` [query parameter](/developers/apis/query-api) to the [Playground URL](https://playground.wordpress.net) like this: https://playground.wordpress.net/?plugin=gutenberg. +With WordPress Playground, you can quickly launch a WordPress installation with any plugin available in the [WordPress Plugins Directory](https://wordpress.org/plugins/) installed and activated. All you need to do is to add the `plugin` [query parameter](/developers/apis/query-api) to the [Playground URL](https://playground.wordpress.net) and use the slug of the plugin from the WordPress directory as a value. For example: https://playground.wordpress.net/?plugin=create-block-theme :::tip You can install and activate several plugins via query parameters by repeating the `plugin` parameter for every plugin you want to be installed and activated in the Playground instance. For example: https://playground.wordpress.net/?plugin=gutenberg&plugin=akismet&plugin=wordpress-seo. @@ -123,11 +123,11 @@ Some useful tools and resources provided by the Playground project to work with ::: -Through properties and [`steps`](/blueprints/steps) in the Blueprint, you can configure the Playground instance's initial setup, providing your plugins with the content and configuration needed for proper showcasing. +Through properties and [`steps`](/blueprints/steps) in the Blueprint, you can configure the Playground instance's initial setup, providing your plugins with the content and configuration needed for showcasing your plugin's compelling features and functionality. :::info -One thing you may want to do to provide a good demo with WordPress Playground is to load default content to better showcase the features of your plugin or theme. Check out the [Providing content for your demo](/guides/providing-content-for-your-demo) guide to learn more +A great demo with WordPress Playground, might require that you load default content for your plugin and theme, including images and other assets. Check out the [Providing content for your demo](/guides/providing-content-for-your-demo) guide to learn more about this. ::: @@ -186,7 +186,11 @@ Here’s an example of a **[plugin that generates Custom Post Types](https://raw ### Local plugin development and testing with Playground -From a plugins' folder in your local development environment, you can quickly load locally a Playground instance with that plugin loaded and activated. You can do that by launching, in the plugin's directory, the [`wp-now` command](/developers/local-development/wp-now) from your preferred command line program or the [Visual Code Studio extension](/developers/local-development/vscode-extension) from the [Visual Studio Code](https://code.visualstudio.com/) IDE. +From a plugins' folder in your local development environment, you can quickly load locally a Playground instance with that plugin loaded and activated. + +Use the [`wp-now` command](/developers/local-development/wp-now) from your plugin's root directory using your preferred command line program. + +With [Visual Studio Code](https://code.visualstudio.com/) IDE, you can also use the [Visual Studio Code extension](/developers/local-development/vscode-extension) while working in the root directory of your plugin. For example: From 870ff510b74d0f8debaa18295887658a753e1dde Mon Sep 17 00:00:00 2001 From: JuanMa Garrido Date: Wed, 11 Sep 2024 17:45:15 +0200 Subject: [PATCH 5/8] note about Google Chrome to build --- packages/docs/site/docs/main/about/build.md | 6 +++++- .../docs/site/docs/main/guides/for-plugin-developers.md | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/docs/site/docs/main/about/build.md b/packages/docs/site/docs/main/about/build.md index 36d3e80ff0..8ed06c67f4 100644 --- a/packages/docs/site/docs/main/about/build.md +++ b/packages/docs/site/docs/main/about/build.md @@ -31,11 +31,15 @@ Some more examples of this workflow: ![Storage Type Device Snaphsot](../_assets/storage-type-device.png) -With Google Chrome (it only works with this browser, for now) you can synchronize your Playground instance with a local directory, that can be either: +With Google Chrome you can synchronize your Playground instance with a local directory, that can be either: - And empty directory – to save this Playground and start syncing - An existing directory – to load it here and start syncing +:::warning +This feature is only available for Google Chrome for now. It won't work with other browsers, yet. +::: + Regarding changes done on both sides of the connection: - Files changed in Playground will be synchronized to on your computer. diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index af5ea9d30c..832d36a42e 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -211,8 +211,7 @@ Here's a little demo of this workflow in action:

-:::note -This feature is only available for Google Chrome for now. It won't work with other browsers, yet. + :::info Check [About Playground > Build > Synchronize your playground instance with a local folder and create Github Pull Requests](/about/build#synchronize-your-playground-instance-with-a-local-folder-and-create-github-pull-requests) for more info. From 2e3163ab51b047131c2581bec2b05f30287f5322 Mon Sep 17 00:00:00 2001 From: JuanMa Garrido Date: Thu, 12 Sep 2024 09:14:40 +0200 Subject: [PATCH 6/8] fine tuning based on feedback received --- packages/docs/site/docs/main/about/build.md | 4 ++- .../docs/main/guides/for-plugin-developers.md | 25 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/docs/site/docs/main/about/build.md b/packages/docs/site/docs/main/about/build.md index 8ed06c67f4..4174972c20 100644 --- a/packages/docs/site/docs/main/about/build.md +++ b/packages/docs/site/docs/main/about/build.md @@ -36,8 +36,10 @@ With Google Chrome you can synchronize your Playground instance with a local dir - And empty directory – to save this Playground and start syncing - An existing directory – to load it here and start syncing -:::warning +:::info + This feature is only available for Google Chrome for now. It won't work with other browsers, yet. + ::: Regarding changes done on both sides of the connection: diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index 832d36a42e..8aa3ac3142 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -6,7 +6,7 @@ description: WordPress Playground for Plugin Developers The WordPress Playground is an innovative tool that allows plugin developers to build, test and showcase their plugins directly in a browser environment. -This guide will explore **how you can leverage the WordPress Playground to enhance your plugin development workflow, create live demos to showcase your WordPress plugin to the world, and streamline your plugin testing process**. +This guide will explore how you can leverage the WordPress Playground to enhance your plugin development workflow, create live demos to showcase your WordPress plugin to the world, and streamline your plugin testing process. :::info @@ -18,7 +18,7 @@ Discover how to [Build](/about/build), [Test](/about/test), and [Launch](/about/ ### Plugin in the WordPress themes directory -With WordPress Playground, you can quickly launch a WordPress installation with any plugin available in the [WordPress Plugins Directory](https://wordpress.org/plugins/) installed and activated. All you need to do is to add the `plugin` [query parameter](/developers/apis/query-api) to the [Playground URL](https://playground.wordpress.net) and use the slug of the plugin from the WordPress directory as a value. For example: https://playground.wordpress.net/?plugin=create-block-theme +With WordPress Playground, you can quickly launch a WordPress installation with almost any plugin available in the [WordPress Plugins Directory](https://wordpress.org/plugins/) installed and activated. All you need to do is to add the `plugin` [query parameter](/developers/apis/query-api) to the [Playground URL](https://playground.wordpress.net) and use the slug of the plugin from the WordPress directory as a value. For example: https://playground.wordpress.net/?plugin=create-block-theme :::tip You can install and activate several plugins via query parameters by repeating the `plugin` parameter for every plugin you want to be installed and activated in the Playground instance. For example: https://playground.wordpress.net/?plugin=gutenberg&plugin=akismet&plugin=wordpress-seo. @@ -78,9 +78,9 @@ For example, the following `blueprint.json` installs a plugin from a GitHub repo [   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/admin.php?page=add-media-from-third-party-service%22,%22login%22:true,%22steps%22:[{%22step%22:%22installPlugin%22,%22pluginZipFile%22:{%22resource%22:%22url%22,%22url%22:%22https://github-proxy.com/proxy/?repo=wptrainingteam/devblog-dataviews-plugin%22}}]}) -### Plugin code from a gist +### Plugin from code in a file or gist in GitHub -By combining the [`writeFile`](/blueprints/steps#WriteFileStep) and [`activatePlugin`](/blueprints/steps#activatePlugin) steps you can also launch a WP Playground instance with a plugin built on the fly from code stored on [a gist](https://gist.githubusercontent.com/ndiego/456b74b243d86c97cda89264c68cbdee/raw/ff00cf25e6eebe4f5a4eaecff10286f71e65340b/block-hooks-demo.php): +By combining the [`writeFile`](/blueprints/steps#WriteFileStep) and [`activatePlugin`](/blueprints/steps#activatePlugin) steps you can also launch a WP Playground instance with a plugin built on the fly from code stored on a gist or [a file in GitHub](https://raw.githubusercontent.com/WordPress/blueprints/trunk/blueprints/custom-post/books.php): ```json { @@ -92,22 +92,27 @@ By combining the [`writeFile`](/blueprints/steps#WriteFileStep) and [`activatePl }, { "step": "writeFile", - "path": "/wordpress/wp-content/plugins/0-plugin.php", + "path": "/wordpress/wp-content/plugins/cpt-books.php", "data": { "resource": "url", - "url": "https://gist.githubusercontent.com/ndiego/456b74b243d86c97cda89264c68cbdee/raw/ff00cf25e6eebe4f5a4eaecff10286f71e65340b/block-hooks-demo.php" + "url": "https://raw.githubusercontent.com/WordPress/blueprints/trunk/blueprints/custom-post/books.php" } }, { "step": "activatePlugin", - "pluginName": "Block Hooks Demo", - "pluginPath": "0-plugin.php" + "pluginPath": "cpt-books.php" } ] } ``` -[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/plugins.php%22,%22login%22:true,%22steps%22:[{%22step%22:%22login%22},{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/plugins/0-plugin.php%22,%22data%22:{%22resource%22:%22url%22,%22url%22:%22https://gist.githubusercontent.com/ndiego/456b74b243d86c97cda89264c68cbdee/raw/ff00cf25e6eebe4f5a4eaecff10286f71e65340b/block-hooks-demo.php%22}},{%22step%22:%22activatePlugin%22,%22pluginName%22:%22Block%20Hooks%20Demo%22,%22pluginPath%22:%220-plugin.php%22}]}) +[   Run Blueprint   ](https://playground.wordpress.net/builder/builder.html#{%22landingPage%22:%22/wp-admin/plugins.php%22,%22login%22:true,%22steps%22:[{%22step%22:%22login%22},{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/plugins/cpt-books.php%22,%22data%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/WordPress/blueprints/trunk/blueprints/custom-post/books.php%22}},{%22step%22:%22activatePlugin%22,%22pluginPath%22:%22cpt-books.php%22}]}) + +:::info + +The [Install plugin from a gist](https://playground.wordpress.net/builder/builder.html?blueprint-url=https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/install-plugin-from-gist/blueprint.json#{%22meta%22:{%22title%22:%22Install%20plugin%20from%20a%20gist%22,%22author%22:%22zieladam%22,%22description%22:%22Install%20and%20activate%20a%20WordPress%20plugin%20from%20a%20.php%20file%20stored%20in%20a%20gist.%22,%22categories%22:[%22plugins%22]},%22landingPage%22:%22/wp-admin/plugins.php%22,%22preferredVersions%22:{%22wp%22:%22beta%22,%22php%22:%228.0%22},%22steps%22:[{%22step%22:%22login%22},{%22step%22:%22writeFile%22,%22path%22:%22/wordpress/wp-content/plugins/0-plugin.php%22,%22data%22:{%22resource%22:%22url%22,%22url%22:%22https://gist.githubusercontent.com/ndiego/456b74b243d86c97cda89264c68cbdee/raw/ff00cf25e6eebe4f5a4eaecff10286f71e65340b/block-hooks-demo.php%22}},{%22step%22:%22activatePlugin%22,%22pluginName%22:%22Block%20Hooks%20Demo%22,%22pluginPath%22:%220-plugin.php%22}]}) example in the [Blueprints Gallery](https://github.com/WordPress/blueprints/blob/trunk/GALLERY.md) shows how to load a plugin from code in a gist + +::: ## Setting up a demo for your plugin with Blueprints @@ -161,7 +166,7 @@ If your plugin has a settings view or onboarding wizard, you can use the `landin ### `writeFile` -With the `writeFile` step you can create on the fly any plugin file taking the code from a file stored on a GitHub repo or a gist. +With the [`writeFile` step](/blueprints/steps#writeFile) you can create any plugin file on the fly, referencing code from a \*.php file stored on a GitHub or Gist. Here’s an example of a **[plugin that generates Custom Post Types](https://raw.githubusercontent.com/wordpress/blueprints/trunk/blueprints/custom-post/books.php)**, placed in the `mu-plugins` folder to ensure the code runs automatically on load: From e9676a53976e671de993e960c2d4c692dd6733dc Mon Sep 17 00:00:00 2001 From: JuanMa Garrido Date: Thu, 12 Sep 2024 09:56:37 +0200 Subject: [PATCH 7/8] Playground for Plugin Developers title --- packages/docs/site/docs/main/guides/for-plugin-developers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index 8aa3ac3142..40b9fc7a66 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -1,5 +1,5 @@ --- -title: For Plugin Developers +title: Playground for Plugin Developers slug: /guides/for-plugin-developers description: WordPress Playground for Plugin Developers --- From c4a4cc3f03b948b80d56bcfef4d8057fc87c610f Mon Sep 17 00:00:00 2001 From: JuanMa Date: Thu, 12 Sep 2024 09:46:34 +0100 Subject: [PATCH 8/8] Update packages/docs/site/docs/main/guides/for-plugin-developers.md Co-authored-by: Birgit Pauli-Haack --- packages/docs/site/docs/main/guides/for-plugin-developers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs/site/docs/main/guides/for-plugin-developers.md b/packages/docs/site/docs/main/guides/for-plugin-developers.md index 40b9fc7a66..2fb6307857 100644 --- a/packages/docs/site/docs/main/guides/for-plugin-developers.md +++ b/packages/docs/site/docs/main/guides/for-plugin-developers.md @@ -132,7 +132,7 @@ Through properties and [`steps`](/blueprints/steps) in the Blueprint, you can co :::info -A great demo with WordPress Playground, might require that you load default content for your plugin and theme, including images and other assets. Check out the [Providing content for your demo](/guides/providing-content-for-your-demo) guide to learn more about this. +A great demo with WordPress Playground might require that you load default content for your plugin and theme, including images and other assets. Check out the [Providing content for your demo](/guides/providing-content-for-your-demo) guide to learn more about this. :::