Make the debug tools page entries for attribute filtering hidden by default.

To show the entries the following needs to be run:

wc_get_container()
->get(\Automattic\WooCommerce\Internal\ProductAttributesLookup\LookupDataStore::class)
->show_feature();
This commit is contained in:
Nestor Soriano 2021-05-10 11:32:39 +02:00
parent cdc55bf846
commit eb2e67d17d
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
2 changed files with 37 additions and 2 deletions

View File

@ -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();

View File

@ -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;
}
/**