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

Block library: Use block.json consistently for FSE blocks #20717

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
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
12 changes: 9 additions & 3 deletions packages/block-library/src/post-author/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ function render_block_core_post_author() {
* Registers the `core/post-author` block on the server.
*/
function register_block_core_post_author() {
$path = __DIR__ . '/post-author/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-author',
array(
'render_callback' => 'render_block_core_post_author',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_author',
)
)
);
}
Expand Down
20 changes: 13 additions & 7 deletions packages/block-library/src/post-comments-count/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ function render_block_core_post_comments_count( $attributes ) {
* Registers the `core/post-comments-count` block on the server.
*/
function register_block_core_post_comments_count() {
$path = __DIR__ . '/post-comments-count/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-comments-count',
array(
'attributes' => array(
'className' => array(
'type' => 'string',
$metadata['name'],
array_merge(
$metadata,
array(
'attributes' => array(
'className' => array(
'type' => 'string',
),
),
),
'render_callback' => 'render_block_core_post_comments_count',
'render_callback' => 'render_block_core_post_comments_count',
)
)
);
}
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/post-comments-form/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ function render_block_core_post_comments_form() {
* Registers the `core/post-comments-form` block on the server.
*/
function register_block_core_post_comments_form() {
$path = __DIR__ . '/post-comments-form/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-comments-form',
array(
'render_callback' => 'render_block_core_post_comments_form',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_comments_form',
)
)
);
}
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/post-content/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ function render_block_core_post_content() {
* Registers the `core/post-content` block on the server.
*/
function register_block_core_post_content() {
$path = __DIR__ . '/post-content/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-content',
array(
'render_callback' => 'render_block_core_post_content',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_content',
)
)
);
}
Expand Down
17 changes: 9 additions & 8 deletions packages/block-library/src/post-date/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ function render_block_core_post_date( $attributes ) {
* Registers the `core/post-date` block on the server.
*/
function register_block_core_post_date() {
$path = __DIR__ . '/post-date/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-date',
array(
'attributes' => array(
'format' => array(
'type' => 'string',
),
),
'render_callback' => 'render_block_core_post_date',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_date',
)
)
);
}
Expand Down
25 changes: 9 additions & 16 deletions packages/block-library/src/post-excerpt/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,16 @@ function render_block_core_post_excerpt( $attributes ) {
* Registers the `core/post-excerpt` block on the server.
*/
function register_block_core_post_excerpt() {
$path = __DIR__ . '/post-excerpt/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-excerpt',
array(
'attributes' => array(
'wordCount' => array(
'type' => 'number',
'default' => 55,
),
'moreText' => array(
'type' => 'string',
),
'showMoreOnNewLine' => array(
'type' => 'boolean',
'default' => true,
),
),
'render_callback' => 'render_block_core_post_excerpt',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_excerpt',
)
)
);
}
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/post-featured-image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ function render_block_core_post_featured_image() {
* Registers the `core/post-featured-image` block on the server.
*/
function register_block_core_post_featured_image() {
$path = __DIR__ . '/post-featured-image/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-featured-image',
array(
'render_callback' => 'render_block_core_post_featured_image',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_featured_image',
)
)
);
}
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/post-tags/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ function render_block_core_post_tags() {
* Registers the `core/post-tags` block on the server.
*/
function register_block_core_post_tags() {
$path = __DIR__ . '/post-tags/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-tags',
array(
'render_callback' => 'render_block_core_post_tags',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_tags',
)
)
);
}
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/post-title/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ function render_block_core_post_title() {
* Registers the `core/post-title` block on the server.
*/
function register_block_core_post_title() {
$path = __DIR__ . '/post-title/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/post-title',
array(
'render_callback' => 'render_block_core_post_title',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_post_title',
)
)
);
}
Expand Down
12 changes: 9 additions & 3 deletions packages/block-library/src/site-title/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ function render_block_core_site_title( $attributes ) {
* Registers the `core/site-title` block on the server.
*/
function register_block_core_site_title() {
$path = __DIR__ . '/site-title/block.json';
$metadata = json_decode( file_get_contents( $path ), true );

register_block_type(
'core/site-title',
array(
'render_callback' => 'render_block_core_site_title',
$metadata['name'],
array_merge(
$metadata,
array(
'render_callback' => 'render_block_core_site_title',
)
)
);
}
Expand Down