| 1 |
<?php |
| 2 |
/** |
| 3 |
* Interactivity API functions specific for the Gutenberg editor plugin. |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Adds script data to the interactivity-router script module. |
| 10 |
* |
| 11 |
* This filter is registered conditionally anticipating a WordPress Core change to add the script module data. |
| 12 |
* The filter runs on 'after_setup_theme' (when Core registers Interactivity and Script Modules hooks) |
| 13 |
* to ensure that the conditional registration happens after Core and correctly determine whether |
| 14 |
* the filter should be added. |
| 15 |
* |
| 16 |
* @see https://github.com/WordPress/wordpress-develop/pull/7304 |
| 17 |
*/ |
| 18 |
function gutenberg_register_interactivity_script_module_data_hooks() { |
| 19 |
if ( ! has_filter( 'script_module_data_@wordpress/interactivity-router', array( wp_interactivity(), 'filter_script_module_interactivity_router_data' ) ) ) { |
| 20 |
add_filter( |
| 21 |
'script_module_data_@wordpress/interactivity-router', |
| 22 |
function ( $data ) { |
| 23 |
if ( ! isset( $data['i18n'] ) ) { |
| 24 |
$data['i18n'] = array(); |
| 25 |
} |
| 26 |
$data['i18n']['loading'] = __( 'Loading page, please wait.', 'default' ); |
| 27 |
$data['i18n']['loaded'] = __( 'Page Loaded.', 'default' ); |
| 28 |
return $data; |
| 29 |
} |
| 30 |
); |
| 31 |
} |
| 32 |
} |
| 33 |
add_action( 'after_setup_theme', 'gutenberg_register_interactivity_script_module_data_hooks', 20 ); |
| 34 |
|