Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
add logic for wp tag processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Aug 18, 2023
1 parent eff5e29 commit 5a8cb99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
17 changes: 17 additions & 0 deletions src/Domain/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ protected function init() {
$this->register_dependencies();
$this->register_payment_methods();
$this->load_interactivity_api();
add_filter(
'woocommerce_blocks_enable_interactivity_api',
array( $this, 'has_wp_html_tag_processor' ),
999
);

// 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() ) {
Expand Down Expand Up @@ -240,6 +245,18 @@ protected function load_interactivity_api() {
require_once '../Interactivity/load.php';
}
}
/**
* 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.
*/
protected function has_wp_html_tag_processor( $enabled ) {
return $enabled && class_exists( 'WP_HTML_Tag_Processor' );

}


/**
* Register core dependencies with the container.
Expand Down
24 changes: 0 additions & 24 deletions woocommerce-gutenberg-products-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,27 +293,3 @@ function woocommerce_blocks_plugin_outdated_notice() {
* @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' );

0 comments on commit 5a8cb99

Please sign in to comment.