Skip to content

Commit

Permalink
Fix php lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Nov 20, 2023
1 parent a324d55 commit a50746e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions lib/block-supports/pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

$gutenberg_experiments = get_option( 'gutenberg-experiments' );
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-connections', $gutenberg_experiments ) ) {
/**
* Registers the dynamicContent context for block types that support it.
*
* @param WP_Block_Type $block_type Block Type.
*/
function gutenberg_register_pattern_support( $block_type ) {
$pattern_support = property_exists( $block_type, 'supports' ) ? _wp_array_get( $block_type->supports, array( '__experimentalConnections' ), false ) : false;

Expand Down
6 changes: 3 additions & 3 deletions lib/experimental/connection-sources/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
*/

return array(
'name' => 'meta',
'meta_fields' => function ( $block_instance, $meta_field ) {
'name' => 'meta',
'meta_fields' => function ( $block_instance, $meta_field ) {
// We should probably also check if the meta field exists but for now it's okay because
// if it doesn't, `get_post_meta()` will just return an empty string.
return get_post_meta( $block_instance->context['postId'], $meta_field, true );
},
'pattern_attributes' => function ( $block_instance, $meta_field ) {
return _wp_array_get( $block_instance->context, array( 'dynamicContent', $meta_field ), false );
}
},
);
14 changes: 11 additions & 3 deletions packages/block-library/src/block/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function render_block_core_block( $attributes ) {
* rendering via do_blocks given it only receives the inner content.
*/
if ( isset( $attributes['dynamicContent'] ) ) {
$filter_block_context = static function( $context ) use ( $attributes ) {
$filter_block_context = static function ( $context ) use ( $attributes ) {
$context['dynamicContent'] = $attributes['dynamicContent'];
return $context;
};
Expand Down Expand Up @@ -84,7 +84,14 @@ function register_block_core_block() {

$gutenberg_experiments = get_option( 'gutenberg-experiments' );
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-connections', $gutenberg_experiments ) ) {
add_filter( 'register_block_type_args', function( $args, $block_name ) {
/**
* Registers the dynamicContent attribute for core/block.
*
* @param array $args Array of arguments for registering a block type.
* @param string $block_name Block name including namespace.
* @return array $args
*/
function register_block_core_block_args( $args, $block_name ) {
if ( 'core/block' === $block_name ) {
$args['attributes'] = array_merge(
$args['attributes'],
Expand All @@ -96,5 +103,6 @@ function register_block_core_block() {
);
}
return $args;
}, 10, 2 );
}
add_filter( 'register_block_type_args', 'register_block_core_block_args', 10, 2 );
}

0 comments on commit a50746e

Please sign in to comment.