Automattic\WooCommerce\Blocks\BlockTypes
MiniCartContents::enqueue_assets()
Enqueue frontend assets for this block, just in time for rendering.
Метод класса: MiniCartContents{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->enqueue_assets( $attributes, $content, $block );
- $attributes(массив) (обязательный)
- Any attributes that currently are available from the block.
- $content(строка) (обязательный)
- The block content.
- $block(WP_Block) (обязательный)
- The block object.
Код MiniCartContents::enqueue_assets() MiniCartContents::enqueue assets WC 9.3.3
protected function enqueue_assets( array $attributes, $content, $block ) { parent::enqueue_assets( $attributes, $content, $block ); $text_color = StyleAttributesUtils::get_text_color_class_and_style( $attributes ); $bg_color = StyleAttributesUtils::get_background_color_class_and_style( $attributes ); $styles = array( array( 'selector' => array( '.wc-block-mini-cart__footer .wc-block-mini-cart__footer-actions .wc-block-mini-cart__footer-checkout', '.wc-block-mini-cart__footer .wc-block-mini-cart__footer-actions .wc-block-mini-cart__footer-checkout:hover', '.wc-block-mini-cart__footer .wc-block-mini-cart__footer-actions .wc-block-mini-cart__footer-checkout:focus', '.wc-block-mini-cart__footer .wc-block-mini-cart__footer-actions .wc-block-mini-cart__footer-cart.wc-block-components-button:hover', '.wc-block-mini-cart__footer .wc-block-mini-cart__footer-actions .wc-block-mini-cart__footer-cart.wc-block-components-button:focus', '.wc-block-mini-cart__shopping-button a:hover', '.wc-block-mini-cart__shopping-button a:focus', ), 'properties' => array( array( 'property' => 'color', 'value' => $bg_color ? $bg_color['value'] : false, ), array( 'property' => 'border-color', 'value' => $text_color ? $text_color['value'] : false, ), array( 'property' => 'background-color', 'value' => $text_color ? $text_color['value'] : false, ), ), ), ); $parsed_style = ''; if ( array_key_exists( 'width', $attributes ) ) { $parsed_style .= ':root{--drawer-width: ' . esc_html( $attributes['width'] ) . '}'; } foreach ( $styles as $style ) { $selector = is_array( $style['selector'] ) ? implode( ',', $style['selector'] ) : $style['selector']; $properties = array_filter( $style['properties'], function( $property ) { return $property['value']; } ); if ( ! empty( $properties ) ) { $parsed_style .= $selector . '{'; foreach ( $properties as $property ) { $parsed_style .= sprintf( '%1$s:%2$s;', $property['property'], $property['value'] ); } $parsed_style .= '}'; } } wp_add_inline_style( 'wc-blocks-style', $parsed_style ); }