Skip to content

Commit

Permalink
Adds clarifications and clears up inaccuracies (#46283)
Browse files Browse the repository at this point in the history
* Adds clarifications and clears up inaccuracies

* Add word: 'subsequently'

* Fixes typo

* Update docs/getting-started/create-block/attributes.md

Co-authored-by: Ryan Welcher <[email protected]>

Co-authored-by: Ryan Welcher <[email protected]>
  • Loading branch information
mburridge and ryanwelcher authored Dec 9, 2022
1 parent 157127d commit b333d1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started/create-block/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Note: The text portion is equivalent to `innerText` attribute of a DOM element.

## Edit and Save

The **attributes** are passed to the `edit` and `save` functions, along with a **setAttributes** function to set the values. Additional parameters are also passed in to these functions, see [the edit/save documentation](/docs/reference-guides/block-api/block-edit-save.md) for more details.
The **attributes** are passed to both the `edit` and `save` functions. The **setAttributes** function is also passed, but only to the `edit` function. The **setAttributes** function is used to set the values. Additional parameters are also passed in to the `edit` and `save` functions, see [the edit/save documentation](/docs/reference-guides/block-api/block-edit-save.md) for more details.

The `attributes` is a JavaScript object containing the values of each attribute, or default values if defined. The `setAttributes` is a function to update an attribute.

Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/create-block/block-anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ registerBlockType( metadata.name, {
} );
```

The first parameter in the **registerBlockType** function is the block name, this should match exactly to the name registered in the PHP file.
The first parameter in the **registerBlockType** function is the block name, this should match exactly to the `name` property in the `block.json` file. By importing the metadata from `block.json` and referencing the `name` property in the first parameter we ensure that they will match, and continue to match even if the name is subsequently changed in `block.json`.

The second parameter to the function is the block object. See the [block registration documentation](/docs/reference-guides/block-api/block-registration.md) for full details.

The last two block object properties are **edit** and **save**, these are the key parts of a block. Both properties are functions that are included via the import above.

The results of the edit function is what the editor will render to the editor page when the block is inserted.

The results of the save function is what the editor will insert into the **post_content** field when the post is saved. The post_content field is the field in the WordPress database used to store the content of the post.
The results of the save function is what the editor will insert into the **post_content** field when the post is saved. The post_content field is the field in the **wp_posts** table in the WordPress database that is used to store the content of the post.

Most of the properties are set in the `src/block.json` file.

Expand Down

0 comments on commit b333d1d

Please sign in to comment.