Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Merge branch 'trunk' into update/change_feedback_link_on_cart_and_che…
Browse files Browse the repository at this point in the history
…ckout
  • Loading branch information
wavvves committed Dec 1, 2023
2 parents d32c9e1 + 3c0776e commit 4c9e51d
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Taxonomy } from '@wordpress/core-data/src/entity-types';
import { useState, useMemo, useRef } from '@wordpress/element';
import { useDebounce } from '@wordpress/compose';
import { FormTokenField } from '@wordpress/components';
import { decodeEntities } from '@wordpress/html-entities';

type Term = {
id: number;
Expand Down Expand Up @@ -250,6 +251,10 @@ const TaxonomyItem = ( { taxonomy, termIds, onChange }: TaxonomyItemProps ) => {
onChange( newTermIds );
};

const decodeHTMLEntities = ( value: string ) => {
return decodeEntities( value ) || '';
};

return (
<div className="wc-block-editor-product-collection-inspector__taxonomy-control">
<FormTokenField
Expand All @@ -261,6 +266,7 @@ const TaxonomyItem = ( { taxonomy, termIds, onChange }: TaxonomyItemProps ) => {
disabled={ isResolvingTermMaps }
// @ts-expect-error Using experimental features
__experimentalShowHowTo={ false }
displayTransform={ decodeHTMLEntities }
/>
</div>
);
Expand Down
10 changes: 1 addition & 9 deletions images/block-placeholders/product-image-gallery.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion patterns/featured-category-focus.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Automattic\WooCommerce\Blocks\Patterns\PatternsHelper;

$category_title = $content['titles'][0]['default'] ?? '';

$button = $content['buttons'][0]['default'] ?? '';
?>

<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"var:preset|spacing|70","right":"var:preset|spacing|70","bottom":"var:preset|spacing|70","left":"var:preset|spacing|70"}}},"layout":{"type":"flex","orientation":"vertical","justifyContent":"center","flexWrap":"wrap"}} -->
Expand All @@ -26,7 +28,7 @@
<div class="wp-block-buttons">
<!-- wp:button {"style":{"color":{"text":"#ffffff","background":"#000000"},"border":{"width":"0px","style":"none"}}} -->
<div class="wp-block-button">
<a href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>" class="wp-block-button__link has-text-color has-background wp-element-button" style="border-style:none;border-width:0px;color:#ffffff;background-color:#000000">Shop now</a>
<a href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>" class="wp-block-button__link has-text-color has-background wp-element-button" style="border-style:none;border-width:0px;color:#ffffff;background-color:#000000"><?php echo esc_html( $button ); ?></a>
</div>
<!-- /wp:button -->
</div>
Expand Down
4 changes: 3 additions & 1 deletion patterns/hero-product-chessboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
$first_description = $content['descriptions'][0]['default'] ?? '';
$second_description = $content['descriptions'][1]['default'] ?? '';
$third_description = $content['descriptions'][2]['default'] ?? '';

$button = $content['buttons'][0]['default'] ?? '';
?>

<!-- wp:group {"align":"full","style":{"spacing":{"margin":{"top":"0px","bottom":"80px"}}},"layout":{"type":"constrained"}} -->
Expand Down Expand Up @@ -54,7 +56,7 @@
<div class="wp-block-buttons" style="margin-top:64px">
<!-- wp:button {"textAlign":"left"} -->
<div class="wp-block-button has-custom-font-size">
<a class="wp-block-button__link has-text-align-left wp-element-button" href="<?php echo esc_url( get_permalink( wc_get_page_id( 'shop' ) ) ); ?>">Shop now</a>
<a class="wp-block-button__link has-text-align-left wp-element-button" href="<?php echo esc_url( get_permalink( wc_get_page_id( 'shop' ) ) ); ?>"><?php echo esc_html( $button ); ?></a>
</div>
<!-- /wp:button -->
</div>
Expand Down
4 changes: 2 additions & 2 deletions patterns/hero-product-split.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
<div class="wp-block-buttons" style="margin-bottom:var(--wp--preset--spacing--40)">
<!-- wp:button -->
<div class="wp-block-button">
<a href="<?php echo esc_url( get_permalink( wc_get_page_id( 'shop' ) ) ); ?>" class="wp-block-button__link wp-element-button"><?php esc_html_e( 'Shop now', 'woo-gutenberg-products-block' ); ?></a>
<a href="<?php echo esc_url( get_permalink( wc_get_page_id( 'shop' ) ) ); ?>" class="wp-block-button__link wp-element-button"><?php esc_html_e( 'Shop the sale', 'woo-gutenberg-products-block' ); ?></a>
</div>
<!-- /wp:button -->
</div>
<!-- /wp:buttons -->
</div>

<figure class="wp-block-media-text__media">
<img src="<?php echo esc_url( PatternsHelper::get_image_url( $images, 0, 'images/pattern-placeholders/man-person-winter-photography-guy-statue.jpg' ) ); ?>" alt="<?php esc_attr_e( 'Placeholder image used to represent a product being showcased in a hero section.', 'woo-gutenberg-products-block' ); ?>" />
<img src="<?php echo esc_url( PatternsHelper::get_image_url( $images, 0, 'images/pattern-placeholders/man-person-winter-photography-statue-coat.png' ) ); ?>" alt="<?php esc_attr_e( 'Placeholder image used to represent a product being showcased in a hero section.', 'woo-gutenberg-products-block' ); ?>" />
</figure>
</div>
<!-- /wp:media-text -->
34 changes: 13 additions & 21 deletions patterns/product-query-large-image-product-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@
* Block Types: core/query/woocommerce/product-query
*/
?>
<!-- wp:query {"query":{"perPage":"4","pages":0,"offset":0,"postType":"product","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"__woocommerceStockStatus":["instock","outofstock","onbackorder"]},"displayLayout":{"type":"flex","columns":2},"namespace":"woocommerce/product-query"} -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:woocommerce/product-image {"saleBadgeAlign":"left","isDescendentOfQueryLoop":true} /-->
<!-- wp:group {"style":{"spacing":{"margin":{"top":"0px","bottom":"80px"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="margin-top:0px;margin-bottom:80px">
<!-- wp:query {"query":{"perPage":"4","pages":0,"offset":0,"postType":"product","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"__woocommerceStockStatus":["instock","outofstock","onbackorder"]},"displayLayout":{"type":"flex","columns":2},"namespace":"woocommerce/product-query"} -->
<div class="wp-block-query">
<!-- wp:post-template -->
<!-- wp:woocommerce/product-image {"aspectRatio":"2/3","saleBadgeAlign":"left","isDescendentOfQueryLoop":true} /-->

<!-- wp:post-title {"textAlign":"center","level":3,"isLink":true,"style":{"spacing":{"margin":{"bottom":"0.75rem","top":"0"}}},"fontSize":"medium","__woocommerceNamespace":"woocommerce/product-query/product-title"} /-->
<!-- wp:post-title {"textAlign":"center","level":3,"isLink":true,"style":{"spacing":{"margin":{"bottom":"0.75rem","top":"0"}}},"fontSize":"medium","__woocommerceNamespace":"woocommerce/product-query/product-title"} /-->

<!-- wp:woocommerce/product-price {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small","style":{"spacing":{"margin":{"bottom":"0.75rem"}}}} /-->
<!-- /wp:post-template -->

<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"center"}} -->
<!-- wp:query-pagination-previous /-->

<!-- wp:query-pagination-numbers /-->

<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->

<!-- wp:query-no-results -->
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
<p></p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results --></div>
<!-- /wp:query -->
<!-- wp:woocommerce/product-price {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small","style":{"spacing":{"margin":{"bottom":"0.75rem"}}}} /-->
<!-- /wp:post-template -->
</div>
<!-- /wp:query -->
</div>
<!-- /wp:group -->
2 changes: 1 addition & 1 deletion patterns/social-follow-us-in-social-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<!-- wp:social-links {"iconColor":"primary","openInNewTab":true,"style":{"spacing":{"blockGap":{"top":"0","left":"16px"}}},"className":"has-icon-color is-style-logos-only","layout":{"type":"flex","justifyContent":"space-between","orientation":"horizontal"}} -->
<ul class="wp-block-social-links has-icon-color is-style-logos-only">
<!-- wp:social-link {"url":"https://twitter.com/","service":"twitter"} /-->
<!-- wp:social-link {"url":"https://x.com","service":"x"} /-->

<!-- wp:social-link {"url":"https://www.instagram.com/","service":"instagram"} /-->

Expand Down
30 changes: 27 additions & 3 deletions patterns/store-info-alt-image-and-text.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

$first_description = $content['descriptions'][0]['default'] ?? '';
$second_description = $content['descriptions'][1]['default'] ?? '';
$list1 = $content['descriptions'][2]['default'] ?? '';
$list2 = $content['descriptions'][3]['default'] ?? '';
$list3 = $content['descriptions'][4]['default'] ?? '';
$list4 = $content['descriptions'][5]['default'] ?? '';

$button = $content['buttons'][0]['default'] ?? '';
?>
Expand All @@ -39,7 +43,7 @@
<!-- wp:column {"verticalAlignment":"center","width":"50%"} -->
<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:50%">
<!-- wp:paragraph {"placeholder":"Content…","style":{"typography":{"textTransform":"uppercase"}}} -->
<p style="text-transform:uppercase"><?php esc_html_e( 'The goods', 'woo-gutenberg-products-block' ); ?></p>
<p style="text-transform:uppercase"><?php echo esc_html( $first_title ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3,"style":{"spacing":{"margin":{"top":"0","bottom":"0"}}}} -->
Expand All @@ -49,6 +53,26 @@
<!-- wp:paragraph -->
<p><?php echo esc_html( $first_description ); ?></p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul>
<!-- wp:list-item -->
<li><?php echo esc_html( $list1 ); ?></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><?php echo esc_html( $list2 ); ?></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><?php echo esc_html( $list3 ); ?></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li><?php echo esc_html( $list4 ); ?></li>
<!-- /wp:list-item -->
</ul>
<!-- /wp:list -->
</div>
<!-- /wp:column -->
</div>
Expand All @@ -72,8 +96,8 @@

<!-- wp:buttons {"style":{"spacing":{"blockGap":"0"}},"fontSize":"small"} -->
<div class="wp-block-buttons has-custom-font-size has-small-font-size">
<!-- wp:button {"className":"is-style-outline"} -->
<div class="wp-block-button is-style-outline">
<!-- wp:button {"className":"is-style-fill"} -->
<div class="wp-block-button is-style-fill">
<a class="wp-block-button__link wp-element-button"><?php echo esc_html( $button ); ?></a>
</div>
<!-- /wp:button -->
Expand Down
6 changes: 3 additions & 3 deletions patterns/testimonials-3-columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>~ Tanner P.</p>
<p>~ Sophia K.</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
Expand All @@ -52,7 +52,7 @@
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>~ Abigail N.</p>
<p>~ Liam M.</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
Expand All @@ -68,7 +68,7 @@
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>~ Albert L.</p>
<p>~ Ava L.</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
Expand Down
2 changes: 1 addition & 1 deletion patterns/testimonials-single.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>~ Anna W.</p>
<p>– Monica P.</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
Expand Down
18 changes: 10 additions & 8 deletions src/BlockTypes/ProductGallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ protected function render( $attributes, $content, $block ) {
$classname_single_image = 'is-single-product-gallery-image';
}

$number_of_thumbnails = $block->attributes['thumbnailsNumberOfThumbnails'] ?? 0;
$classname = $attributes['className'] ?? '';
$dialog = isset( $attributes['mode'] ) && 'full' !== $attributes['mode'] ? $this->render_dialog() : '';
$post_id = $block->context['postId'] ?? '';
$product = wc_get_product( $post_id );
$product_id = strval( $product->get_id() );
$number_of_thumbnails = $block->attributes['thumbnailsNumberOfThumbnails'] ?? 0;
$classname = $attributes['className'] ?? '';
$dialog = isset( $attributes['mode'] ) && 'full' !== $attributes['mode'] ? $this->render_dialog() : '';
$post_id = $block->context['postId'] ?? '';
$product = wc_get_product( $post_id );
$product_gallery_first_image = ProductGalleryUtils::get_product_gallery_image_ids( $product, 1 );
$product_gallery_first_image_id = reset( $product_gallery_first_image );
$product_id = strval( $product->get_id() );

$html = $this->inject_dialog( $content, $dialog );
$p = new \WP_HTML_Tag_Processor( $html );
Expand All @@ -137,8 +139,8 @@ protected function render( $attributes, $content, $block ) {
'data-wc-context',
wp_json_encode(
array(
'selectedImage' => $product->get_image_id(),
'firstMainImageId' => $product->get_image_id(),
'selectedImage' => $product_gallery_first_image_id,
'firstMainImageId' => $product_gallery_first_image_id,
'isDialogOpen' => false,
'visibleImagesIds' => ProductGalleryUtils::get_product_gallery_image_ids( $product, $number_of_thumbnails, true ),
'dialogVisibleImagesIds' => ProductGalleryUtils::get_product_gallery_image_ids( $product, null, false ),
Expand Down
3 changes: 1 addition & 2 deletions src/BlockTypes/ProductGalleryThumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ protected function render( $attributes, $content, $block ) {
$product = wc_get_product( $post_id );

if ( $product ) {
$post_thumbnail_id = $product->get_image_id();
$crop_images = $block->context['cropImages'] ?? false;
$product_gallery_images = ProductGalleryUtils::get_product_gallery_images( $post_id, 'full', array(), 'wc-block-product-gallery-thumbnails__thumbnail', $crop_images );

if ( $product_gallery_images && count( $product_gallery_images ) > 1 && $post_thumbnail_id ) {
if ( $product_gallery_images && count( $product_gallery_images ) > 1 ) {
$html = '';
$number_of_thumbnails = isset( $block->context['thumbnailsNumberOfThumbnails'] ) ? $block->context['thumbnailsNumberOfThumbnails'] : 3;
$mode = $block->context['mode'] ?? '';
Expand Down
Loading

0 comments on commit 4c9e51d

Please sign in to comment.