Load Interactivity API in `bootstrap.php` (https://github.com/woocommerce/woocommerce-blocks/pull/10657)
* load Interactivity API in Bootstrap.php file * fix comment * update visibility function * remove blank line * remove comment * remove logic to not load Interactivity API
This commit is contained in:
parent
601adc6e1f
commit
d1a1b9d5f9
|
@ -100,6 +100,7 @@ class Bootstrap {
|
|||
protected function init() {
|
||||
$this->register_dependencies();
|
||||
$this->register_payment_methods();
|
||||
$this->load_interactivity_api();
|
||||
|
||||
// This is just a temporary solution to make sure the migrations are run. We have to refactor this. More details: https://github.com/woocommerce/woocommerce-blocks/issues/10196.
|
||||
if ( $this->package->get_version() !== $this->package->get_version_stored_on_db() ) {
|
||||
|
@ -225,6 +226,13 @@ class Bootstrap {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and set up the Interactivity API if enabled.
|
||||
*/
|
||||
protected function load_interactivity_api() {
|
||||
require_once __DIR__ . '/../Interactivity/load.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register core dependencies with the container.
|
||||
*/
|
||||
|
|
|
@ -285,35 +285,3 @@ function woocommerce_blocks_plugin_outdated_notice() {
|
|||
}
|
||||
|
||||
add_action( 'admin_notices', 'woocommerce_blocks_plugin_outdated_notice' );
|
||||
|
||||
/**
|
||||
* Disable the Interactivity API if the required `WP_HTML_Tag_Processor` class
|
||||
* doesn't exist, regardless of whether it was enabled manually.
|
||||
*
|
||||
* @param bool $enabled Current filter value.
|
||||
* @return bool True if _also_ the `WP_HTML_Tag_Processor` class was found.
|
||||
*/
|
||||
function woocommerce_blocks_has_wp_html_tag_processor( $enabled ) {
|
||||
return $enabled && class_exists( 'WP_HTML_Tag_Processor' );
|
||||
}
|
||||
add_filter(
|
||||
'woocommerce_blocks_enable_interactivity_api',
|
||||
'woocommerce_blocks_has_wp_html_tag_processor',
|
||||
999
|
||||
);
|
||||
|
||||
/**
|
||||
* Load and set up the Interactivity API if enabled.
|
||||
*/
|
||||
function woocommerce_blocks_interactivity_setup() {
|
||||
// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||
$is_enabled = apply_filters(
|
||||
'woocommerce_blocks_enable_interactivity_api',
|
||||
true
|
||||
);
|
||||
|
||||
if ( $is_enabled ) {
|
||||
require_once __DIR__ . '/src/Interactivity/load.php';
|
||||
}
|
||||
}
|
||||
add_action( 'plugins_loaded', 'woocommerce_blocks_interactivity_setup' );
|
||||
|
|
Loading…
Reference in New Issue