WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана

Automattic\WooCommerce\Internal\ProductAttributesLookup

DataRegenerator::add_initiate_regeneration_entry_to_tools_array() private WC 1.0

Add a 'Regenerate product attributes lookup table' entry to the Status - Tools page.

{} Это метод класса: DataRegenerator{}

Хуков нет.

Возвращает

Массив. The tools array with the entry added.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->add_initiate_regeneration_entry_to_tools_array( $tools_array );
$tools_array(массив) (обязательный)
The tool definitions array that is passed ro the woocommerce_debug_tools filter.

Код DataRegenerator::add_initiate_regeneration_entry_to_tools_array() WC 5.4.1

<?php
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();

	// Regenerate table.

	if ( $lookup_table_exists ) {
		$generate_item_name   = __( 'Regenerate the product attributes lookup table', 'woocommerce' );
		$generate_item_desc   = __( 'This tool will regenerate the product attributes lookup table data from existing products data. This process may take a while.', 'woocommerce' );
		$generate_item_return = __( 'Product attributes lookup table data is regenerating', 'woocommerce' );
		$generate_item_button = __( 'Regenerate', 'woocommerce' );
	} else {
		$generate_item_name   = __( 'Create and fill product attributes lookup table', 'woocommerce' );
		$generate_item_desc   = __( 'This tool will create the product attributes lookup table data and fill it with existing products data. This process may take a while.', 'woocommerce' );
		$generate_item_return = __( 'Product attributes lookup table is being filled', 'woocommerce' );
		$generate_item_button = __( 'Create', 'woocommerce' );
	}

	$entry = array(
		'name'             => $generate_item_name,
		'desc'             => $generate_item_desc,
		'requires_refresh' => true,
		'callback'         => function() use ( $generate_item_return ) {
			$this->initiate_regeneration_from_tools_page();
			return $generate_item_return;
		},
	);

	if ( $generation_is_in_progress ) {
		$entry['button'] = sprintf(
			/* translators: %d: How many products have been processed so far. */
			__( 'Filling in progress (%d)', 'woocommerce' ),
			get_option( 'woocommerce_attribute_lookup__last_products_page_processed', 0 ) * self::PRODUCTS_PER_GENERATION_STEP
		);
		$entry['disabled'] = true;
	} else {
		$entry['button'] = $generate_item_button;
	}

	$tools_array['regenerate_product_attributes_lookup_table'] = $entry;

	if ( $lookup_table_exists ) {

		// Delete the table.

		$tools_array['delete_product_attributes_lookup_table'] = array(
			'name'             => __( 'Delete the product attributes lookup table', 'woocommerce' ),
			'desc'             => sprintf(
				'<strong class="red">%1$s</strong> %2$s',
				__( 'Note:', 'woocommerce' ),
				__( 'This will delete the product attributes lookup table. You can create it again with the "Create and fill product attributes lookup table" tool.', 'woocommerce' )
			),
			'button'           => __( 'Delete', 'woocommerce' ),
			'requires_refresh' => true,
			'callback'         => function () {
				$this->delete_all_attributes_lookup_data();
				return __( 'Product attributes lookup table has been deleted.', 'woocommerce' );
			},
		);
	}

	if ( $lookup_table_exists && ! $generation_is_in_progress ) {

		// Enable or disable table usage.

		if ( 'yes' === get_option( 'woocommerce_attribute_lookup__enabled' ) ) {
			$tools_array['disable_product_attributes_lookup_table_usage'] = array(
				'name'             => __( 'Disable the product attributes lookup table usage', 'woocommerce' ),
				'desc'             => __( 'The product attributes lookup table usage is currently enabled, use this tool to disable it.', 'woocommerce' ),
				'button'           => __( 'Disable', 'woocommerce' ),
				'requires_refresh' => true,
				'callback'         => function () {
					$this->enable_or_disable_lookup_table_usage( false );
					return __( 'Product attributes lookup table usage has been disabled.', 'woocommerce' );
				},
			);
		} else {
			$tools_array['enable_product_attributes_lookup_table_usage'] = array(
				'name'             => __( 'Enable the product attributes lookup table usage', 'woocommerce' ),
				'desc'             => __( 'The product attributes lookup table usage is currently disabled, use this tool to enable it.', 'woocommerce' ),
				'button'           => __( 'Enable', 'woocommerce' ),
				'requires_refresh' => true,
				'callback'         => function () {
					$this->enable_or_disable_lookup_table_usage( true );
					return __( 'Product attributes lookup table usage has been enabled.', 'woocommerce' );
				},
			);
		}
	}

	return $tools_array;
}