Skip to content

Commit

Permalink
Filter to switch from the Interactivity API to the old implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz committed Jul 12, 2023
1 parent ee5482c commit d762b95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/block-library/src/file/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package WordPress
*/

if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
if ( apply_filters( 'gutenberg_block_core_file_use_interactivity_api', true ) ) {
/**
* Replaces view script for the File block with version using Interactivity API.
*
Expand Down Expand Up @@ -71,7 +71,7 @@ static function ( $matches ) {
);

// If it uses the Interactivity API, add the directives.
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
if ( apply_filters( 'gutenberg_block_core_file_use_interactivity_api', true ) && $should_load_view_script ) {
$processor = new WP_HTML_Tag_Processor( $content );
$processor->next_tag();
$processor->set_attribute( 'data-wp-interactive', '' );
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// These functions are used for the __unstableLocation feature and only active
// when the gutenberg plugin is active.
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
if ( apply_filters( 'gutenberg_block_core_navigation_use_interactivity_api', true ) ) {
/**
* Returns the menu items for a WordPress menu location.
*
Expand Down Expand Up @@ -471,7 +471,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
// - we don't have a relationship to a `wp_navigation` Post (via `ref`).
// ...then create inner blocks from the classic menu assigned to that location.
if (
defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN &&
apply_filters( 'gutenberg_block_core_navigation_use_interactivity_api', true ) &&
array_key_exists( '__unstableLocation', $attributes ) &&
! array_key_exists( 'ref', $attributes ) &&
! empty( block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] ) )
Expand Down Expand Up @@ -685,7 +685,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
}

// Add directives to the submenu if needed.
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $has_submenus && $should_load_view_script ) {
if ( apply_filters( 'gutenberg_block_core_navigation_use_interactivity_api', true ) && $has_submenus && $should_load_view_script ) {
$w = new WP_HTML_Tag_Processor( $inner_blocks_html );
$inner_blocks_html = block_core_navigation_add_directives_to_submenu( $w, $attributes );
}
Expand Down Expand Up @@ -733,7 +733,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$responsive_container_directives = '';
$responsive_dialog_directives = '';
$close_button_directives = '';
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
if ( apply_filters( 'gutenberg_block_core_navigation_use_interactivity_api', true ) && $should_load_view_script ) {
$nav_element_directives = '
data-wp-interactive
data-wp-context=\'{ "core": { "navigation": { "overlayOpenedBy": {}, "type": "overlay", "roleAttribute": "" } } }\'
Expand Down

0 comments on commit d762b95

Please sign in to comment.