Skip to content

Commit

Permalink
Docs: Add page explaining how to scaffold blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jan 11, 2018
1 parent 02e6e0f commit 75bf4ab
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs/blocks-scaffolding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Scaffolding blocks

It is also possible to generate PHP, JS and CSS code for registering a Gutenberg block for a plugin or theme.

## Installing WP-CLI

Before installing `WP-CLI`, please make sure your environment meets the minimum requirements:

* UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment
* PHP 5.3.29 or later
* WordPress 3.7 or later

Once you’ve verified requirements, you should follow the [installation instructions](http://wp-cli.org/#installing). Downloading the Phar file is the recommended installation method for most users. Should you need, see also the documentation on [alternative installation methods](https://make.wordpress.org/cli/handbook/installing/).

_Important_: To use scaffolding command for blocks you temporary need to run `wp cli update --nightly` to use the latest nightly build of WP-CLI. The nightly build is more or less stable enough for you to use in your development environment, and always includes the latest and greatest WP-CLI features.

## Using `wp scaffold block`

```bash
wp scaffold block <slug> [--title=<title>] [--dashicon=<dashicon>] [--category=<category>] [--theme] [--plugin=<plugin>] [--force]
```

Please refer to the [command documentation](https://github.com/wp-cli/scaffold-command#wp-scaffold-block) to learn more about the block subcommand options.

When you scaffold a block you must provide at least a `slug` name and either the `theme` or `plugin` name. We strongly recommended using blocks with plugins rather than themes.

### Examples

```bash
# Generate a 'movie' block for the 'movies' plugin
$ wp scaffold block movie --title="Movie block" --plugin=movies
Success: Created block 'Movie block'.

# Generate a 'movie' block for the 'simple-life' theme
$ wp scaffold block movie --title="Movie block" --theme=simple-life
Success: Created block 'Movie block'.

# Create a new plugin and add two blocks
# Create plugin called books
$ wp scaffold plugin books
# Add a block called book to plugin books
$ wp scaffold block book --title="Book" --plugin=books
# Add a second block to plugin called books.
$ wp scaffold block books --title="Book List" --plugin=books
```
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
"markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks-dynamic.md",
"parent": "blocks"
},
{
"title": "Scaffolding blocks",
"slug": "scaffolding-blocks",
"markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks-scaffolding.md",
"parent": "blocks"
},
{
"title": "Reference",
"slug": "reference",
Expand Down

0 comments on commit 75bf4ab

Please sign in to comment.