Automattic\WooCommerce\Blocks
AssetsController::get_prefetch_resource_hints()
Get resource hints during prefetch requests.
Метод класса: AssetsController{}
Хуков нет.
Возвращает
Массив
. Array of URLs.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_prefetch_resource_hints();
Код AssetsController::get_prefetch_resource_hints() AssetsController::get prefetch resource hints WC 8.7.0
private function get_prefetch_resource_hints() { $urls = array(); // 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; }