Automattic\WooCommerce\Blocks

AssetsController::get_prefetch_resource_hints()privateWC 1.0

Get resource hints during prefetch requests.

Метод класса: AssetsController{}

Хуков нет.

Возвращает

Массив. Array of URLs.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_prefetch_resource_hints();

Код AssetsController::get_prefetch_resource_hints() WC 7.3.0

private function get_prefetch_resource_hints() {
	$urls = [];

	// Core page IDs.
	$cart_page_id     = wc_get_page_id( 'cart' );
	$checkout_page_id = wc_get_page_id( 'checkout' );

	// Checks a specific page (by ID) to see if it contains the named block.
	$has_block_cart     = $cart_page_id && has_block( 'woocommerce/cart', $cart_page_id );
	$has_block_checkout = $checkout_page_id && has_block( 'woocommerce/checkout', $checkout_page_id );

	// Checks the current page to see if it contains the named block.
	$is_block_cart     = has_block( 'woocommerce/cart' );
	$is_block_checkout = has_block( 'woocommerce/checkout' );

	if ( $has_block_cart && ! $is_block_cart ) {
		$urls = array_merge( $urls, $this->get_block_asset_resource_hints( 'cart-frontend' ) );
	}

	if ( $has_block_checkout && ! $is_block_checkout ) {
		$urls = array_merge( $urls, $this->get_block_asset_resource_hints( 'checkout-frontend' ) );
	}

	return $urls;
}