Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix lints
  • Loading branch information
sirreal committed Sep 17, 2024
commit adbfd46eed5aae2a518c2e7470b9cbaf872a70bc
29 changes: 16 additions & 13 deletions lib/interactivity-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ function gutenberg_reregister_interactivity_script_modules() {
'@wordpress/interactivity-router',
gutenberg_url( '/build-module/interactivity-router/index.min.js' ),
array(
array( 'id' => '@wordpress/a11y', 'import' => 'dynamic' ),
array(
'id' => '@wordpress/a11y',
'import' => 'dynamic',
),
'@wordpress/interactivity',
),
$default_version
Expand All @@ -34,18 +37,18 @@ function gutenberg_reregister_interactivity_script_modules() {
add_action( 'init', 'gutenberg_reregister_interactivity_script_modules' );

function gutenberg_register_interactivity_script_module_data_hooks() {
if ( ! has_filter( 'script_module_data_@wordpress/interactivity-router', array( wp_interactivity(), 'filter_script_module_interactivity_router_data' ) ) ) {
add_filter(
'script_module_data_@wordpress/interactivity-router',
function ( $data ) {
if ( ! isset( $data['i18n'] ) ) {
$data['i18n'] = array();
}
$data['i18n']['loading'] = __( 'Loading page, please wait.', 'default' );
$data['i18n']['loaded'] = __( 'Page Loaded.', 'default' );
return $data;
if ( ! has_filter( 'script_module_data_@wordpress/interactivity-router', array( wp_interactivity(), 'filter_script_module_interactivity_router_data' ) ) ) {
add_filter(
'script_module_data_@wordpress/interactivity-router',
function ( $data ) {
if ( ! isset( $data['i18n'] ) ) {
$data['i18n'] = array();
}
);
}
$data['i18n']['loading'] = __( 'Loading page, please wait.', 'default' );
$data['i18n']['loaded'] = __( 'Page Loaded.', 'default' );
return $data;
}
);
}
}
add_action( 'after_setup_theme', 'gutenberg_register_interactivity_script_module_data_hooks', 20 );
Copy link
Member Author

Choose a reason for hiding this comment

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

With the latest changes to use the localized fallback strings (passed via Interactivity API), if I disable this filter it correctly uses the those strings as a fallback.

#65129 proposes adding this filter to Core.