diff --git a/src/Internal/ProductAttributesLookup/DataRegenerator.php b/src/Internal/ProductAttributesLookup/DataRegenerator.php index ebc1758a0ff..e7a60bffd35 100644 --- a/src/Internal/ProductAttributesLookup/DataRegenerator.php +++ b/src/Internal/ProductAttributesLookup/DataRegenerator.php @@ -271,6 +271,10 @@ CREATE TABLE ' . $this->lookup_table_name . '( * @return array The tools array with the entry added. */ private function add_initiate_regeneration_entry_to_tools_array( array $tools_array ) { + if ( ! $this->data_store->is_feature_visible() ) { + return $tools_array; + } + $lookup_table_exists = $this->lookup_table_exists(); $generation_is_in_progress = $this->regeneration_is_in_progress(); diff --git a/src/Internal/ProductAttributesLookup/LookupDataStore.php b/src/Internal/ProductAttributesLookup/LookupDataStore.php index 9fceb95f41a..77cc2845238 100644 --- a/src/Internal/ProductAttributesLookup/LookupDataStore.php +++ b/src/Internal/ProductAttributesLookup/LookupDataStore.php @@ -22,12 +22,43 @@ class LookupDataStore { private $lookup_table_name; /** - * LookupDataStore constructor. + * Is the feature visible? + * + * @var bool + */ + private $is_feature_visible; + + /** + * LookupDataStore constructor. Makes the feature hidden by default. */ public function __construct() { global $wpdb; - $this->lookup_table_name = $wpdb->prefix . 'wc_product_attributes_lookup'; + $this->lookup_table_name = $wpdb->prefix . 'wc_product_attributes_lookup'; + $this->is_feature_visible = false; + } + + /** + * Checks if the feature is visible (so that dedicated entries will be added to the debug tools page). + * + * @return bool True if the feature is visible. + */ + public function is_feature_visible() { + return $this->is_feature_visible; + } + + /** + * Makes the feature visible, so that dedicated entries will be added to the debug tools page. + */ + public function show_feature() { + $this->is_feature_visible = true; + } + + /** + * Hides the feature, so that no entries will be added to the debug tools page. + */ + public function hide_feature() { + $this->is_feature_visible = false; } /**