Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update get-started-with-wp-scripts.md #67119

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion docs/getting-started/devenv/get-started-with-wp-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,23 @@ A `build/index.asset.php` file will also be created in the build process, which

### Enqueuing assets

If you register a block via `register_block_type` the scripts defined in `block.json` will be automatically enqueued (see [example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/minimal-block-ca6eda))
If you register a block via `register_block_type` the scripts defined in `block.json` will be automatically enqueued:

```php
/**
* Register the block.
*/
function example_register_block() {
// The build folder contains the block.json file.
register_block_type( __DIR__ . '/build' );
}

add_action( 'init', 'example_register_block' );
```

View the complete [example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/minimal-block-ca6eda) in context.

Using this approach will register the block on the server. More information regarding the registering of a block can be found in [Registration of a block](https://developer.wordpress.org/block-editor/getting-started/fundamentals/registration-of-a-block/).

To manually enqueue files in the editor, in any other context, you can refer to the [Enqueueing assets in the Editor](https://developer.wordpress.org/block-editor/how-to-guides/enqueueing-assets-in-the-editor/) guide for more information, but here's a typical implementation.

Expand Down
Loading