} } if ( $is_list_open ) { $inner_blocks_html .= '</ul>';
} // If the script already exists, there is no point in removing it from viewScript.
$should_load_view_script =
( $is_responsive_menu || ( $has_submenus && ( $attributes['openSubmenusOnClick'
] ||
$attributes['showSubmenuIcon'
] ) ) );
$view_js_file = 'wp-block-navigation-view';
if ( !
wp_script_is( $view_js_file ) ) { $script_handles =
$block->block_type->view_script_handles;
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
if ( !
$should_load_view_script &&
in_array( $view_js_file,
$script_handles, true
) ) { $block->block_type->view_script_handles =
array_diff( $script_handles, array
( $view_js_file, 'wp-block-navigation-view-2'
) );
} // If the script is needed, but it was previously removed, add it again.
if ( $should_load_view_script && !
in_array( $view_js_file,
$script_handles, true
) ) { $block->block_type->view_script_handles =
array_merge( $script_handles, array
( $view_js_file, 'wp-block-navigation-view-2'
) );
} }