Skip to content

Commit

Permalink
REST API: Assign default for block renderer attributes
Browse files Browse the repository at this point in the history
Previously we would pass `NULL` to `render`. While `render` provides a default `array()` value, since an explicit value is provided, it would not take effect. With this change, the endpoint assures a default value to be provided as a parameter to get the `get_item` callback that is compatible with the function signature of `WP_BlockType::render`.

Alternatively, it could be considered to have separate invocations of `render`, depending on whether the request parameter is set.
  • Loading branch information
aduth committed Nov 16, 2018
1 parent fab97d1 commit c7bb6d6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/class-wp-rest-block-renderer-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function register_routes() {
'type' => 'object',
'additionalProperties' => false,
'properties' => $block_type->get_attributes(),
'default' => array(),
),
'post_id' => array(
'description' => __( 'ID of the post context.', 'gutenberg' ),
Expand Down

0 comments on commit c7bb6d6

Please sign in to comment.