From 435a84cdbb51b5dc44f7a5f4a18c2fb4cb119f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alba=20Rinc=C3=B3n?= Date: Mon, 23 May 2022 11:27:52 +0200 Subject: [PATCH 1/3] Add `Fixed/Repeated background` to the `Featured Category` block --- .../featured-category/block.json | 8 ++ src/BlockTypes/FeaturedCategory.php | 112 +++++++++++++++--- 2 files changed, 105 insertions(+), 15 deletions(-) diff --git a/assets/js/blocks/featured-items/featured-category/block.json b/assets/js/blocks/featured-items/featured-category/block.json index 5cca01685d9..da1da21ae70 100644 --- a/assets/js/blocks/featured-items/featured-category/block.json +++ b/assets/js/blocks/featured-items/featured-category/block.json @@ -57,6 +57,14 @@ "type": "string", "default": "none" }, + "hasParallax": { + "type": "boolean", + "default": false + }, + "isRepeated": { + "type": "boolean", + "default": false + }, "mediaId": { "type": "number", "default": 0 diff --git a/src/BlockTypes/FeaturedCategory.php b/src/BlockTypes/FeaturedCategory.php index 00e7d7b0393..5859f54f5e5 100644 --- a/src/BlockTypes/FeaturedCategory.php +++ b/src/BlockTypes/FeaturedCategory.php @@ -79,7 +79,6 @@ protected function get_block_type_attributes() { * @return string Rendered block type output. */ protected function render( $attributes, $content ) { - $id = absint( isset( $attributes['categoryId'] ) ? $attributes['categoryId'] : 0 ); $category = get_term( $id, 'product_cat' ); @@ -101,13 +100,21 @@ protected function render( $attributes, $content ) { wc_format_content( wp_kses_post( $category->description ) ) ); + $image_url = esc_url( $this->get_image_url( $attributes, $category ) ); + $styles = $this->get_styles( $attributes ); $classes = $this->get_classes( $attributes ); $output = sprintf( '