Skip to content

Commit

Permalink
Use better name for context in block registration
Browse files Browse the repository at this point in the history
  • Loading branch information
noahtallen committed Jun 17, 2020
1 parent 9c256e3 commit b1e27ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/class-wp-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public function __construct( $block, $available_context = array(), $registry = n

$this->available_context = $available_context;

if ( ! empty( $this->block_type->context ) ) {
foreach ( $this->block_type->context as $context_name ) {
if ( ! empty( $this->block_type->requiresContext ) ) {
foreach ( $this->block_type->requiresContext as $context_name ) {
if ( array_key_exists( $context_name, $this->available_context ) ) {
$this->context[ $context_name ] = $this->available_context[ $context_name ];
}
Expand Down
23 changes: 12 additions & 11 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,18 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {

$settings = array();
$property_mappings = array(
'title' => 'title',
'category' => 'category',
'context' => 'context',
'parent' => 'parent',
'icon' => 'icon',
'description' => 'description',
'keywords' => 'keywords',
'attributes' => 'attributes',
'supports' => 'supports',
'styles' => 'styles',
'example' => 'example',
'title' => 'title',
'category' => 'category',
'context' => 'requiresContext',
'providesContext' => 'providesContext',
'parent' => 'parent',
'icon' => 'icon',
'description' => 'description',
'keywords' => 'keywords',
'attributes' => 'attributes',
'supports' => 'supports',
'styles' => 'styles',
'example' => 'example',
);

foreach ( $property_mappings as $key => $mapped_key ) {
Expand Down

0 comments on commit b1e27ae

Please sign in to comment.