Skip to content

Commit

Permalink
Remove old filter
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Feb 9, 2024
1 parent 6cb23c5 commit 1dbf2c4
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions lib/compat/wordpress-6.5/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,38 +219,3 @@ function gutenberg_process_block_bindings( $block_content, $parsed_block, $block
}

add_filter( 'render_block', 'gutenberg_process_block_bindings', 20, 3 );

/**
* Add `postId` and `postType` context to blocks that can use block bindings.
*
* @param string $args Array of arguments for registering a block type.
* @param string $block_name The name of the block to process.
* @return array The modified arguments for registering a block type.
*/
function gutenberg_add_context_for_block_bindings( $args, $block_name ) {
$allowed_blocks = array(
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text' ),
);

if ( ! isset( $allowed_blocks[ $block_name ] ) ) {
return $args;
}
if ( ! isset( $args['uses_context'] ) ) {
$args['uses_context'] = array( 'postId', 'postType' );
} else {
// Check if 'postId' exists in 'uses_context' and add it if it doesn't.
if ( ! in_array( 'postId', $args['uses_context'], true ) ) {
$args['uses_context'][] = 'postId';
}
// Check if 'postType' exists in 'uses_context' and add it if it doesn't.
if ( ! in_array( 'postType', $args['uses_context'], true ) ) {
$args['uses_context'][] = 'postType';
}
}

return $args;
}
add_filter( 'register_block_type_args', 'gutenberg_add_context_for_block_bindings', 10, 2 );

0 comments on commit 1dbf2c4

Please sign in to comment.