Accordion
1 year ago
AddToCartWithOptions
2 weeks ago
OrderConfirmation
2 months ago
ProductCollection
3 weeks ago
Reviews
2 months ago
AbstractBlock.php
4 weeks ago
AbstractDynamicBlock.php
2 years ago
AbstractInnerBlock.php
1 year ago
AbstractProductGrid.php
3 months ago
ActiveFilters.php
2 years ago
AddToCartForm.php
4 weeks ago
AddToWishlistButton.php
4 weeks ago
AllProducts.php
2 years ago
AllReviews.php
2 years ago
AtomicBlock.php
2 years ago
AttributeFilter.php
1 year ago
Breadcrumbs.php
1 year ago
Cart.php
2 months ago
CartAcceptedPaymentMethodsBlock.php
2 years ago
CartCrossSellsBlock.php
2 years ago
CartCrossSellsProductsBlock.php
2 years ago
CartExpressPaymentBlock.php
1 year ago
CartItemsBlock.php
2 years ago
CartLineItemsBlock.php
2 years ago
CartLink.php
2 months ago
CartOrderSummaryBlock.php
2 years ago
CartOrderSummaryCouponFormBlock.php
2 years ago
CartOrderSummaryDiscountBlock.php
2 years ago
CartOrderSummaryFeeBlock.php
2 years ago
CartOrderSummaryHeadingBlock.php
2 years ago
CartOrderSummaryShippingBlock.php
2 years ago
CartOrderSummarySubtotalBlock.php
2 years ago
CartOrderSummaryTaxesBlock.php
2 years ago
CartOrderSummaryTotalsBlock.php
2 years ago
CartTotalsBlock.php
2 years ago
CatalogSorting.php
4 weeks ago
CategoryDescription.php
2 months ago
CategoryTitle.php
2 months ago
Checkout.php
2 months ago
CheckoutActionsBlock.php
1 year ago
CheckoutAdditionalInformationBlock.php
2 years ago
CheckoutBillingAddressBlock.php
2 years ago
CheckoutContactInformationBlock.php
2 years ago
CheckoutExpressPaymentBlock.php
9 months ago
CheckoutFieldsBlock.php
2 years ago
CheckoutOrderNoteBlock.php
2 years ago
CheckoutOrderSummaryBlock.php
2 years ago
CheckoutOrderSummaryCartItemsBlock.php
2 years ago
CheckoutOrderSummaryCouponFormBlock.php
2 years ago
CheckoutOrderSummaryDiscountBlock.php
2 years ago
CheckoutOrderSummaryFeeBlock.php
2 years ago
CheckoutOrderSummaryShippingBlock.php
2 years ago
CheckoutOrderSummarySubtotalBlock.php
2 years ago
CheckoutOrderSummaryTaxesBlock.php
2 years ago
CheckoutOrderSummaryTotalsBlock.php
2 years ago
CheckoutPaymentBlock.php
2 years ago
CheckoutPickupOptionsBlock.php
2 years ago
CheckoutShippingAddressBlock.php
2 years ago
CheckoutShippingMethodBlock.php
2 years ago
CheckoutShippingMethodsBlock.php
2 years ago
CheckoutTermsBlock.php
2 years ago
CheckoutTotalsBlock.php
2 years ago
ClassicShortcode.php
1 year ago
ClassicTemplate.php
4 months ago
ComingSoon.php
1 year ago
CouponCode.php
2 months ago
CustomerAccount.php
3 months ago
Dropdown.php
4 weeks ago
EmailContent.php
5 months ago
EmptyCartBlock.php
2 years ago
EmptyMiniCartContentsBlock.php
11 months ago
EnableBlockJsonAssetsTrait.php
1 year ago
FeaturedCategory.php
7 months ago
FeaturedItem.php
7 months ago
FeaturedProduct.php
7 months ago
FilledCartBlock.php
2 years ago
FilledMiniCartContentsBlock.php
4 months ago
FilterWrapper.php
2 years ago
HandpickedProducts.php
1 year ago
MiniCart.php
4 weeks ago
MiniCartCartButtonBlock.php
11 months ago
MiniCartCheckoutButtonBlock.php
11 months ago
MiniCartContents.php
3 months ago
MiniCartFooterBlock.php
4 weeks ago
MiniCartItemsBlock.php
11 months ago
MiniCartProductsTableBlock.php
4 weeks ago
MiniCartShoppingButtonBlock.php
9 months ago
MiniCartTitleBlock.php
11 months ago
MiniCartTitleItemsCounterBlock.php
11 months ago
MiniCartTitleLabelBlock.php
11 months ago
NextPreviousButtons.php
5 months ago
PageContentWrapper.php
2 years ago
PaymentMethodIcons.php
11 months ago
PriceFilter.php
1 year ago
ProceedToCheckoutBlock.php
2 years ago
ProductAverageRating.php
1 year ago
ProductBestSellers.php
2 years ago
ProductButton.php
2 months ago
ProductCategories.php
4 weeks ago
ProductCategory.php
2 years ago
ProductDescription.php
9 months ago
ProductDetails.php
5 months ago
ProductFilterActive.php
4 weeks ago
ProductFilterAttribute.php
4 weeks ago
ProductFilterCheckboxList.php
4 weeks ago
ProductFilterChips.php
4 weeks ago
ProductFilterClearButton.php
4 weeks ago
ProductFilterPrice.php
4 weeks ago
ProductFilterPriceSlider.php
4 weeks ago
ProductFilterRating.php
4 weeks ago
ProductFilterRemovableChips.php
4 weeks ago
ProductFilterStatus.php
4 weeks ago
ProductFilterTaxonomy.php
4 weeks ago
ProductFilters.php
3 weeks ago
ProductGallery.php
4 weeks ago
ProductGalleryLargeImage.php
4 weeks ago
ProductGalleryThumbnails.php
4 weeks ago
ProductImage.php
4 weeks ago
ProductImageGallery.php
7 months ago
ProductMeta.php
1 year ago
ProductNew.php
2 years ago
ProductOnSale.php
2 years ago
ProductPrice.php
2 months ago
ProductQuery.php
4 weeks ago
ProductRating.php
1 year ago
ProductRatingCounter.php
1 year ago
ProductRatingStars.php
1 year ago
ProductResultsCount.php
2 months ago
ProductSKU.php
2 months ago
ProductSaleBadge.php
1 year ago
ProductSearch.php
10 months ago
ProductSpecifications.php
2 months ago
ProductStockIndicator.php
2 months ago
ProductSummary.php
7 months ago
ProductTag.php
2 years ago
ProductTemplate.php
2 months ago
ProductTitle.php
1 year ago
ProductTopRated.php
2 years ago
ProductsByAttribute.php
2 years ago
RatingFilter.php
2 years ago
RelatedProducts.php
3 months ago
ReviewsByCategory.php
2 years ago
ReviewsByProduct.php
2 years ago
SavedForLater.php
4 weeks ago
SingleProduct.php
2 months ago
StockFilter.php
2 years ago
StoreNotices.php
1 year ago
Wishlist.php
4 weeks ago
ComingSoon.php
116 lines
| 1 | <?php |
| 2 | namespace Automattic\WooCommerce\Blocks\BlockTypes; |
| 3 | |
| 4 | use Automattic\Jetpack\Constants; |
| 5 | |
| 6 | /** |
| 7 | * ComingSoon class. |
| 8 | */ |
| 9 | class ComingSoon extends AbstractBlock { |
| 10 | /** |
| 11 | * Block name. |
| 12 | * |
| 13 | * @var string |
| 14 | */ |
| 15 | protected $block_name = 'coming-soon'; |
| 16 | |
| 17 | /** |
| 18 | * It is necessary to register and enqueue assets during the render phase because we want to load assets only if the block has the content. |
| 19 | */ |
| 20 | protected function register_block_type_assets() { |
| 21 | parent::register_block_type_assets(); |
| 22 | $this->register_chunk_translations( [ $this->block_name ] ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Initialize. |
| 27 | */ |
| 28 | public function initialize() { |
| 29 | parent::initialize(); |
| 30 | add_filter( 'enqueue_block_assets', array( $this, 'enqueue_block_assets' ), 10, 2 ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Enqueue frontend assets for this block, just in time for rendering. |
| 35 | * |
| 36 | * @internal This prevents the block script being enqueued on all pages. It is only enqueued as needed. Note that |
| 37 | * we intentionally do not pass 'script' to register_block_type. |
| 38 | * |
| 39 | * @param array $attributes Any attributes that currently are available from the block. |
| 40 | * @param string $content The block content. |
| 41 | * @param WP_Block $block The block object. |
| 42 | */ |
| 43 | protected function enqueue_assets( array $attributes, $content, $block ) { |
| 44 | parent::enqueue_assets( $attributes, $content, $block ); |
| 45 | |
| 46 | if ( isset( $attributes['style']['color']['background'] ) ) { |
| 47 | wp_add_inline_style( |
| 48 | 'wc-blocks-style', |
| 49 | ':root{--woocommerce-coming-soon-color: ' . esc_html( $attributes['style']['color']['background'] ) . '}' |
| 50 | ); |
| 51 | } elseif ( isset( $attributes['color'] ) ) { |
| 52 | // Deprecated: To support coming soon templates created before WooCommerce 9.8.0. |
| 53 | wp_add_inline_style( |
| 54 | 'wc-blocks-style', |
| 55 | ':root{--woocommerce-coming-soon-color: ' . esc_html( $attributes['color'] ) . '}' |
| 56 | ); |
| 57 | wp_enqueue_style( |
| 58 | 'woocommerce-coming-soon', |
| 59 | WC()->plugin_url() . '/assets/css/coming-soon-entire-site-deprecated' . ( is_rtl() ? '-rtl' : '' ) . '.css', |
| 60 | array(), |
| 61 | Constants::get_constant( 'WC_VERSION' ) |
| 62 | ); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Enqueue coming soon deprecated styles in site editor to support |
| 68 | * coming soon templates created before WooCommerce 9.8.0. |
| 69 | */ |
| 70 | public function enqueue_block_assets() { |
| 71 | if ( ! is_admin() ) { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | $current_screen = get_current_screen(); |
| 76 | if ( $current_screen instanceof \WP_Screen && 'site-editor' !== $current_screen->base ) { |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | $post_id = isset( $_REQUEST['postId'] ) ? wc_clean( wp_unslash( $_REQUEST['postId'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 81 | if ( 'woocommerce/woocommerce//coming-soon' !== $post_id ) { |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | $block_template = get_block_template( $post_id ); |
| 86 | if ( $block_template ) { |
| 87 | $parsed_blocks = parse_blocks( $block_template->content ); |
| 88 | foreach ( $parsed_blocks as $block ) { |
| 89 | if ( isset( $block['blockName'] ) && 'woocommerce/coming-soon' === $block['blockName'] ) { |
| 90 | // Color attribute is deprecated in WooCommerce 9.8.0. |
| 91 | if ( isset( $block['attrs']['color'] ) && ! empty( $block['attrs']['color'] ) ) { |
| 92 | wp_enqueue_style( |
| 93 | 'woocommerce-coming-soon', |
| 94 | WC()->plugin_url() . '/assets/css/coming-soon-entire-site-deprecated' . ( is_rtl() ? '-rtl' : '' ) . '.css', |
| 95 | array(), |
| 96 | Constants::get_constant( 'WC_VERSION' ) |
| 97 | ); |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Get the frontend script handle for this block type. |
| 107 | * |
| 108 | * @see $this->register_block_type() |
| 109 | * @param string $key Data to get, or default to everything. |
| 110 | * @return array|string|null |
| 111 | */ |
| 112 | protected function get_block_type_script( $key = null ) { |
| 113 | return null; |
| 114 | } |
| 115 | } |
| 116 |