PluginProbe
Gutenberg / 16.2.0
Gutenberg v16.2.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / lib / experimental / interactivity-api / blocks.php

blocks.php in Gutenberg 16.2.0, at lib/experimental/interactivity-api/blocks.php

28 lines 835 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Extend WordPress core blocks to use the Interactivity API.
4 *
5 * @package Gutenberg
6 * @subpackage Interactivity API
7 */
8
9 /**
10 * Replaces view script for the Image block with version using Interactivity API.
11 *
12 * @param array $metadata Block metadata as read in via block.json.
13 *
14 * @return array Filtered block type metadata.
15 */
16 function gutenberg_block_update_interactive_view_script( $metadata ) {
17 if (
18 array_key_exists( 'name', $metadata ) &&
19 in_array( $metadata['name'], array( 'core/image' ), true ) &&
20 array_key_exists( 'file', $metadata ) &&
21 str_contains( $metadata['file'], 'build/block-library/blocks' )
22 ) {
23 $metadata['viewScript'] = array( 'file:./view-interactivity.min.js' );
24 }
25 return $metadata;
26 }
27 add_filter( 'block_type_metadata', 'gutenberg_block_update_interactive_view_script', 10, 1 );
28