Revert changes in woocommerce/woocommerce-blocks#9332 and instead enqueue assets in correct place depending on admin vs frontend (https://github.com/woocommerce/woocommerce-blocks/pull/9495)

This commit is contained in:
Mike Jolley 2023-05-18 10:46:17 +01:00 committed by GitHub
parent 86bb06a9a8
commit 715e63fbfd
1 changed files with 2 additions and 17 deletions

View File

@ -66,23 +66,8 @@ class AssetDataRegistry {
* Hook into WP asset registration for enqueueing asset data.
*/
protected function init() {
if ( $this->is_site_editor() ) {
add_action( 'enqueue_block_editor_assets', array( $this, 'register_data_script' ) );
} else {
add_action( 'init', array( $this, 'register_data_script' ) );
}
add_action( 'wp_print_footer_scripts', array( $this, 'enqueue_asset_data' ), 2 );
add_action( 'admin_print_footer_scripts', array( $this, 'enqueue_asset_data' ), 2 );
}
/**
* Checks if the current URL is the Site Editor.
*
* @return boolean
*/
protected function is_site_editor() {
$url_path = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
return str_contains( $url_path, 'site-editor.php' );
add_action( 'init', array( $this, 'register_data_script' ) );
add_action( is_admin() ? 'admin_print_footer_scripts' : 'wp_print_footer_scripts', array( $this, 'enqueue_asset_data' ), 2 );
}
/**