Automattic\WooCommerce\Blocks\BlockTypes
ClassicShortcode::render
Render method for the Classic Template block. This method will determine which template to render.
Метод класса: ClassicShortcode{}
Хуков нет.
Возвращает
Строку. | void Rendered block type output.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->render( $attributes, $content, $block );
- $attributes(массив) (обязательный)
- Block attributes.
- $content(строка) (обязательный)
- Block content.
- $block(WP_Block) (обязательный)
- Block instance.
Код ClassicShortcode::render() ClassicShortcode::render WC 10.6.2
protected function render( $attributes, $content, $block ) {
if ( ! isset( $attributes['shortcode'] ) ) {
return;
}
/**
* We need to load the scripts here because when using block templates wp_head() gets run after the block
* template. As a result we are trying to enqueue required scripts before we have even registered them.
*
* @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/5328#issuecomment-989013447
*/
if ( class_exists( 'WC_Frontend_Scripts' ) ) {
$frontend_scripts = new WC_Frontend_Scripts();
$frontend_scripts::load_scripts();
}
if ( 'cart' === $attributes['shortcode'] ) {
return $this->render_cart( $attributes );
}
if ( 'checkout' === $attributes['shortcode'] ) {
return $this->render_checkout( $attributes );
}
return "You're using the ClassicShortcode block";
}