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

Add the block registration RFC #13693

Merged
merged 33 commits into from
Jun 18, 2019
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7a6de97
Add the block registration RFC
youknowriad Feb 6, 2019
5392e90
Update docs/rfc/block-registration.md
danielbachhuber Feb 8, 2019
a3724a5
Fix typo in WordPress name
gziolo Feb 21, 2019
25a2e6c
Clarify some points in requirements
gziolo Feb 21, 2019
dcf374a
Update the note about REST API
gziolo Feb 21, 2019
00eab25
Removed comments from json based examples
gziolo Feb 25, 2019
56d859e
Fix icon examples
gziolo Mar 5, 2019
94d882b
Add missing comma in JSON example
gziolo Mar 5, 2019
05c8fc3
A few smaller tweaks
gziolo Mar 5, 2019
fb143e4
Fix to deprecated versions example
gziolo Mar 5, 2019
7a23923
Update block-registration.md
gziolo Mar 15, 2019
eb580a5
Update block-registration.md
gziolo Apr 8, 2019
e6c1208
Update block-registration.md
gziolo Apr 8, 2019
f2aa6d7
Update block-registration.md
gziolo Apr 8, 2019
152326f
Update block-registration.md
gziolo Apr 8, 2019
f87879a
Apply suggestions from code review
aduth Apr 8, 2019
8a18390
Update docs/rfc/block-registration.md
aduth Apr 8, 2019
a8faacb
Update block-registration.md
gziolo Apr 8, 2019
e1f90ba
Add missing `parent` attribute
gziolo Apr 14, 2019
503a194
Update block-registration.md
gziolo Apr 14, 2019
2fbfb2e
Add backward compatibility section
gziolo Apr 19, 2019
9d7478a
Apply suggestions from code review
gziolo Apr 19, 2019
11a816a
Align the name of style variations with the existing usage
gziolo Apr 23, 2019
54557fc
Update RFC with all details about handling scripts and styles
gziolo May 21, 2019
9a8fd0b
Apply suggestions from code review
gziolo May 24, 2019
0bd7793
Replace spaces with tabs for identation
gziolo May 24, 2019
8092c19
Update docs/rfc/block-registration.md
gziolo May 28, 2019
dcf6b63
Remove debugging code from test plugin
gziolo May 28, 2019
4c7ec7f
Try simplify the way WPDefinedAsset is defined
gziolo May 28, 2019
ea11bf7
Docs: Remove `render_callback` property from the initial version of RFC
gziolo Jun 6, 2019
94e0f22
Further simplify the definition of assets and clarify how it works wi…
gziolo Jun 10, 2019
edade13
Apply suggestions from code review
gziolo Jun 13, 2019
f3456fe
Remove the section about PHP runtime
gziolo Jun 18, 2019
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
Prev Previous commit
Next Next commit
Update block-registration.md
  • Loading branch information
gziolo committed Jun 18, 2019
commit f2aa6d7a1cc1d64db6550f9e0120d4a986acda0c
32 changes: 31 additions & 1 deletion docs/rfc/block-registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,40 @@ This property is a pointer to CSS files containing the CSS used for the block in

## Internationalization
gziolo marked this conversation as resolved.
Show resolved Hide resolved

Localized properties are automatically wrapped in `__` function calls on the backend and the frontend of WordPress. These translations are added as an inline script to the `wp-block-library` script handle.
Localized properties are automatically wrapped in `_x` function calls on the backend and the frontend of WordPress. These translations are added as an inline script to the `wp-block-library` script handle in WordPress core or to the plugin's script handle which defines block when loading metadata defintion.

WordPress string discovery automatically includes these strings to the plugin's or core's domain name.
gziolo marked this conversation as resolved.
Show resolved Hide resolved

**Example:**

```json
{
"title": "My block",
"description": "My block is fantastic",
"keywords": [ "fanstastic" ]
}
```

in JavScript with help of Babel plugin becomes:
gziolo marked this conversation as resolved.
Show resolved Hide resolved

```js
const metadata = {
title: _x( 'My block', 'block title', 'my-plugin' ),
description: _x( 'My block is fantastic', 'block description', 'my-plugin' ),
keywords: [ _x( 'fanstastic', 'block keywords', 'my-plugin' ) ],
}
```

in PHP it gets transformed on the fly to code close to:
gziolo marked this conversation as resolved.
Show resolved Hide resolved

```php
$metadata = array(
'title' => _x( 'My block', 'block title', 'my-plugin' ),
'description': _x( 'My block is fantastic', 'block description', 'my-plugin' ),
'keywords': array( _x( 'fanstastic', 'block keywords', 'my-plugin' ) ),
);
```

## PHP Runtime

WordPress automatically discovers all the block.json files in the plugin/core `blocks` folder and registers the corresponding block types. These block types are made available through the [block registry](https://developer.wordpress.org/reference/classes/wp_block_type_registry/) PHP class and the blocks scripts and styles are added as dependencies to the `wp-block-library` script and style handles.
gziolo marked this conversation as resolved.
Show resolved Hide resolved
gziolo marked this conversation as resolved.
Show resolved Hide resolved
Expand Down