Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter to switch from the Interactivity API to the old implementation #52580

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? The code in here is not all related to Interactivity API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, but let's use your PR instead: #52579

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