Accordion
1 year ago
AddToCartWithOptions
1 week 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
NextPreviousButtons.php
104 lines
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Blocks\BlockTypes; |
| 4 | |
| 5 | use Automattic\WooCommerce\Blocks\Utils\ProductGalleryUtils; |
| 6 | use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils; |
| 7 | |
| 8 | /** |
| 9 | * NextPreviousButtons class. |
| 10 | */ |
| 11 | class NextPreviousButtons extends AbstractBlock { |
| 12 | |
| 13 | use EnableBlockJsonAssetsTrait; |
| 14 | |
| 15 | /** |
| 16 | * Block name. Block has been initially created for Product Gallery Viewer block |
| 17 | * hence the slug is related to this block. But it can be used for other blocks as well. |
| 18 | * |
| 19 | * @var string |
| 20 | */ |
| 21 | protected $block_name = 'product-gallery-large-image-next-previous'; |
| 22 | |
| 23 | /** |
| 24 | * Include and render the block. |
| 25 | * |
| 26 | * @param array $attributes Block attributes. Default empty array. |
| 27 | * @param string $content Block content. Default empty string. |
| 28 | * @param WP_Block $block Block instance. |
| 29 | * @return string Rendered block type output. |
| 30 | */ |
| 31 | protected function render( $attributes, $content, $block ) { |
| 32 | $iapi_provider = $block->context['iapi/provider'] ?? null; |
| 33 | |
| 34 | if ( empty( $iapi_provider ) ) { |
| 35 | return ''; |
| 36 | } |
| 37 | |
| 38 | $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'align' ) ); |
| 39 | $vertical_alignment = StyleAttributesUtils::get_align_class_and_style( $attributes ); |
| 40 | |
| 41 | $left_arrow_path = 'M6.445 12.005.986 6 6.445-.005l1.11 1.01L3.014 6l4.54 4.995-1.109 1.01Z'; |
| 42 | $right_arrow_path = 'M1.555-.004 7.014 6l-5.459 6.005-1.11-1.01L4.986 6 .446 1.005l1.109-1.01Z'; |
| 43 | |
| 44 | ob_start(); |
| 45 | ?> |
| 46 | <div |
| 47 | class="wc-block-next-previous-buttons <?php echo esc_attr( $vertical_alignment['class'] ); ?>" |
| 48 | data-wp-interactive="<?php echo esc_attr( $iapi_provider ); ?>" |
| 49 | data-wp-bind--hidden="context.hideNextPreviousButtons" |
| 50 | > |
| 51 | <button |
| 52 | class="wc-block-next-previous-buttons__button <?php echo esc_attr( $classes_and_styles['classes'] ); ?>" |
| 53 | style="<?php echo esc_attr( $classes_and_styles['styles'] ); ?>" |
| 54 | data-wp-on--click="actions.onClickPrevious" |
| 55 | data-wp-on--keydown="actions.onKeyDownPrevious" |
| 56 | data-wp-bind--aria-disabled="context.isDisabledPrevious" |
| 57 | data-wp-bind--aria-label="context.ariaLabelPrevious" |
| 58 | > |
| 59 | <svg |
| 60 | class="wc-block-next-previous-buttons__icon wc-block-next-previous-buttons__icon--left" |
| 61 | xmlns="http://www.w3.org/2000/svg" |
| 62 | width="8" |
| 63 | height="12" |
| 64 | fill="none" |
| 65 | > |
| 66 | <path |
| 67 | fill="currentColor" |
| 68 | fillRule="evenodd" |
| 69 | d="<?php echo is_rtl() ? esc_attr( $right_arrow_path ) : esc_attr( $left_arrow_path ); ?>" |
| 70 | clipRule="evenodd" |
| 71 | /> |
| 72 | </svg> |
| 73 | </button> |
| 74 | <button |
| 75 | class="wc-block-next-previous-buttons__button <?php echo esc_attr( $classes_and_styles['classes'] ); ?>" |
| 76 | style="<?php echo esc_attr( $classes_and_styles['styles'] ); ?>" |
| 77 | data-wp-on--click="actions.onClickNext" |
| 78 | data-wp-on--keydown="actions.onKeyDownNext" |
| 79 | data-wp-bind--aria-disabled="context.isDisabledNext" |
| 80 | data-wp-bind--aria-label="context.ariaLabelNext" |
| 81 | > |
| 82 | <svg |
| 83 | class="wc-block-next-previous-buttons__icon wc-block-next-previous-buttons__icon--right" |
| 84 | xmlns="http://www.w3.org/2000/svg" |
| 85 | width="8" |
| 86 | height="12" |
| 87 | fill="none" |
| 88 | > |
| 89 | <path |
| 90 | fill="currentColor" |
| 91 | fillRule="evenodd" |
| 92 | d="<?php echo is_rtl() ? esc_attr( $left_arrow_path ) : esc_attr( $right_arrow_path ); ?>" |
| 93 | clipRule="evenodd" |
| 94 | /> |
| 95 | </svg> |
| 96 | </button> |
| 97 | </div> |
| 98 | <?php |
| 99 | $template = ob_get_clean(); |
| 100 | |
| 101 | return $template; |
| 102 | } |
| 103 | } |
| 104 |