Submit
Path:
~
/
home
/
getwphos
/
www
/
techniquetechs
/
wp-content
/
plugins
/
woocommerce
/
src
/
Blocks
/
BlockTypes
/
File Content:
FeaturedItem.php
<?php namespace Automattic\WooCommerce\Blocks\BlockTypes; use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils; /** * FeaturedItem class. */ abstract class FeaturedItem extends AbstractDynamicBlock { /** * Block name. * * @var string */ protected $block_name; /** * Default attribute values. * * @var array */ protected $defaults = array( 'align' => 'none', ); /** * Global style enabled for this block. * * @var array */ protected $global_style_wrapper = array( 'background_color', 'border_color', 'border_radius', 'border_width', 'font_size', 'padding', 'text_color', 'extra_classes', ); /** * Returns the featured item. * * @param array $attributes Block attributes. Default empty array. * @return \WP_Term|\WC_Product|null */ abstract protected function get_item( $attributes ); /** * Returns the name of the featured item. * * @param \WP_Term|\WC_Product $item Item object. * @return string */ abstract protected function get_item_title( $item ); /** * Returns the featured item image URL. * * @param \WP_Term|\WC_Product $item Item object. * @param string $size Image size, defaults to 'full'. * @return string */ abstract protected function get_item_image( $item, $size = 'full' ); /** * Renders the featured item attributes. * * @param \WP_Term|\WC_Product $item Item object. * @param array $attributes Block attributes. Default empty array. * @return string */ abstract protected function render_attributes( $item, $attributes ); /** * Render the featured item block. * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. * @return string Rendered block type output. */ protected function render( $attributes, $content, $block ) { $item = $this->get_item( $attributes ); if ( ! $item ) { return ''; } $attributes = wp_parse_args( $attributes, $this->defaults ); $attributes['height'] = $attributes['height'] ?? wc_get_theme_support( 'featured_block::default_height', 500 ); $image_url = esc_url( $this->get_image_url( $attributes, $item ) ); $styles = $this->get_styles( $attributes ); $classes = $this->get_classes( $attributes ); $output = sprintf( '<div class="%1$s wp-block-woocommerce-%2$s" style="%3$s">', esc_attr( trim( $classes ) ), $this->block_name, esc_attr( $styles ) ); $output .= sprintf( '<div class="wc-block-%s__wrapper">', $this->block_name ); $output .= $this->render_overlay( $attributes ); if ( ! $attributes['isRepeated'] && ! $attributes['hasParallax'] ) { $output .= $this->render_image( $attributes, $item, $image_url ); } else { $output .= $this->render_bg_image( $attributes, $image_url ); } $output .= $this->render_attributes( $item, $attributes ); $output .= sprintf( '<div class="wc-block-%s__link">%s</div>', $this->block_name, $content ); $output .= '</div>'; $output .= '</div>'; return $output; } /** * Returns the url the item's image * * @param array $attributes Block attributes. Default empty array. * @param \WP_Term|\WC_Product $item Item object. * * @return string */ private function get_image_url( $attributes, $item ) { $image_size = 'large'; if ( 'none' !== $attributes['align'] || $attributes['height'] > 800 ) { $image_size = 'full'; } if ( $attributes['mediaId'] ) { return wp_get_attachment_image_url( $attributes['mediaId'], $image_size ); } return $this->get_item_image( $item, $image_size ); } /** * Renders the featured image as a div background. * * @param array $attributes Block attributes. Default empty array. * @param string $image_url Item image url. * * @return string */ private function render_bg_image( $attributes, $image_url ) { $styles = $this->get_bg_styles( $attributes, $image_url ); $classes = [ "wc-block-{$this->block_name}__background-image" ]; if ( $attributes['hasParallax'] ) { $classes[] = ' has-parallax'; } return sprintf( '<div class="%1$s" style="%2$s" /></div>', esc_attr( implode( ' ', $classes ) ), esc_attr( $styles ) ); } /** * Get the styles for the wrapper element (background image, color). * * @param array $attributes Block attributes. Default empty array. * @param string $image_url Item image url. * * @return string */ public function get_bg_styles( $attributes, $image_url ) { $style = ''; if ( $attributes['isRepeated'] || $attributes['hasParallax'] ) { $style .= "background-image: url($image_url);"; } if ( ! $attributes['isRepeated'] ) { $style .= 'background-repeat: no-repeat;'; $bg_size = 'cover' === $attributes['imageFit'] ? $attributes['imageFit'] : 'auto'; $style .= 'background-size: ' . $bg_size . ';'; } if ( $this->hasFocalPoint( $attributes ) ) { $style .= sprintf( 'background-position: %s%% %s%%;', $attributes['focalPoint']['x'] * 100, $attributes['focalPoint']['y'] * 100 ); } $global_style_style = StyleAttributesUtils::get_styles_by_attributes( $attributes, $this->global_style_wrapper ); $style .= $global_style_style; return $style; } /** * Renders the featured image * * @param array $attributes Block attributes. Default empty array. * @param \WC_Product|\WP_Term $item Item object. * @param string $image_url Item image url. * * @return string */ private function render_image( $attributes, $item, string $image_url ) { $style = sprintf( 'object-fit: %s;', esc_attr( $attributes['imageFit'] ) ); $img_alt = $attributes['alt'] ?: $this->get_item_title( $item ); if ( $this->hasFocalPoint( $attributes ) ) { $style .= sprintf( 'object-position: %s%% %s%%;', $attributes['focalPoint']['x'] * 100, $attributes['focalPoint']['y'] * 100 ); } if ( ! empty( $image_url ) ) { return sprintf( '<img alt="%1$s" class="wc-block-%2$s__background-image" src="%3$s" style="%4$s" />', esc_attr( $img_alt ), $this->block_name, esc_url( $image_url ), esc_attr( $style ) ); } return ''; } /** * Get the styles for the wrapper element (background image, color). * * @param array $attributes Block attributes. Default empty array. * @return string */ public function get_styles( $attributes ) { $style = ''; $min_height = $attributes['minHeight'] ?? wc_get_theme_support( 'featured_block::default_height', 500 ); if ( isset( $attributes['minHeight'] ) ) { $style .= sprintf( 'min-height:%dpx;', intval( $min_height ) ); } $global_style_style = StyleAttributesUtils::get_styles_by_attributes( $attributes, $this->global_style_wrapper ); $style .= $global_style_style; return $style; } /** * Get class names for the block container. * * @param array $attributes Block attributes. Default empty array. * @return string */ public function get_classes( $attributes ) { $classes = array( 'wc-block-' . $this->block_name ); if ( isset( $attributes['align'] ) ) { $classes[] = "align{$attributes['align']}"; } if ( isset( $attributes['dimRatio'] ) && ( 0 !== $attributes['dimRatio'] ) ) { $classes[] = 'has-background-dim'; if ( 50 !== $attributes['dimRatio'] ) { $classes[] = 'has-background-dim-' . 10 * round( $attributes['dimRatio'] / 10 ); } } if ( isset( $attributes['contentAlign'] ) && 'center' !== $attributes['contentAlign'] ) { $classes[] = "has-{$attributes['contentAlign']}-content"; } $global_style_classes = StyleAttributesUtils::get_classes_by_attributes( $attributes, $this->global_style_wrapper ); $classes[] = $global_style_classes; return implode( ' ', $classes ); } /** * Renders the block overlay * * @param array $attributes Block attributes. Default empty array. * * @return string */ private function render_overlay( $attributes ) { if ( isset( $attributes['overlayGradient'] ) ) { $overlay_styles = sprintf( 'background-image: %s', $attributes['overlayGradient'] ); } elseif ( isset( $attributes['overlayColor'] ) ) { $overlay_styles = sprintf( 'background-color: %s', $attributes['overlayColor'] ); } else { $overlay_styles = 'background-color: #000000'; } return sprintf( '<div class="background-dim__overlay" style="%s"></div>', esc_attr( $overlay_styles ) ); } /** * Returns whether the focal point is defined for the block. * * @param array $attributes Block attributes. Default empty array. * * @return bool */ private function hasFocalPoint( $attributes ): bool { return is_array( $attributes['focalPoint'] ) && 2 === count( $attributes['focalPoint'] ); } /** * Extra data passed through from server to client for block. * * @param array $attributes Any attributes that currently are available from the block. * Note, this will be empty in the editor context when the block is * not in the post content on editor load. */ protected function enqueue_data( array $attributes = [] ) { parent::enqueue_data( $attributes ); $this->asset_data_registry->add( 'defaultHeight', wc_get_theme_support( 'featured_block::default_height', 500 ) ); } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
Name
Size
Permission
Action
Accordion
---
0755
OrderConfirmation
---
0755
ProductCollection
---
0755
AbstractBlock.php
16619 bytes
0644
AbstractDynamicBlock.php
1892 bytes
0644
AbstractInnerBlock.php
1785 bytes
0644
AbstractProductGrid.php
22632 bytes
0644
ActiveFilters.php
226 bytes
0644
AddToCartForm.php
7581 bytes
0644
AddToCartWithOptions.php
6715 bytes
0644
AddToCartWithOptionsGroupedProductSelector.php
1053 bytes
0644
AddToCartWithOptionsGroupedProductSelectorItemTemplate.php
2598 bytes
0644
AddToCartWithOptionsQuantitySelector.php
7191 bytes
0644
AddToCartWithOptionsVariationSelector.php
9363 bytes
0644
AllProducts.php
2040 bytes
0644
AllReviews.php
1317 bytes
0644
AtomicBlock.php
910 bytes
0644
AttributeFilter.php
1536 bytes
0644
BlockifiedProductDetails.php
739 bytes
0644
Breadcrumbs.php
1306 bytes
0644
Cart.php
13502 bytes
0644
CartAcceptedPaymentMethodsBlock.php
288 bytes
0644
CartCrossSellsBlock.php
251 bytes
0644
CartCrossSellsProductsBlock.php
276 bytes
0644
CartExpressPaymentBlock.php
507 bytes
0644
CartItemsBlock.php
235 bytes
0644
CartLineItemsBlock.php
248 bytes
0644
CartLink.php
1588 bytes
0644
CartOrderSummaryBlock.php
2736 bytes
0644
CartOrderSummaryCouponFormBlock.php
289 bytes
0644
CartOrderSummaryDiscountBlock.php
282 bytes
0644
CartOrderSummaryFeeBlock.php
267 bytes
0644
CartOrderSummaryHeadingBlock.php
279 bytes
0644
CartOrderSummaryShippingBlock.php
282 bytes
0644
CartOrderSummarySubtotalBlock.php
282 bytes
0644
CartOrderSummaryTaxesBlock.php
273 bytes
0644
CartOrderSummaryTotalsBlock.php
276 bytes
0644
CartTotalsBlock.php
238 bytes
0644
CatalogSorting.php
1518 bytes
0644
Checkout.php
26115 bytes
0644
CheckoutActionsBlock.php
1003 bytes
0644
CheckoutAdditionalInformationBlock.php
296 bytes
0644
CheckoutBillingAddressBlock.php
275 bytes
0644
CheckoutContactInformationBlock.php
287 bytes
0644
CheckoutExpressPaymentBlock.php
4271 bytes
0644
CheckoutFieldsBlock.php
250 bytes
0644
CheckoutOrderNoteBlock.php
260 bytes
0644
CheckoutOrderSummaryBlock.php
2807 bytes
0644
CheckoutOrderSummaryCartItemsBlock.php
298 bytes
0644
CheckoutOrderSummaryCouponFormBlock.php
301 bytes
0644
CheckoutOrderSummaryDiscountBlock.php
294 bytes
0644
CheckoutOrderSummaryFeeBlock.php
279 bytes
0644
CheckoutOrderSummaryShippingBlock.php
294 bytes
0644
CheckoutOrderSummarySubtotalBlock.php
294 bytes
0644
CheckoutOrderSummaryTaxesBlock.php
285 bytes
0644
CheckoutOrderSummaryTotalsBlock.php
288 bytes
0644
CheckoutPaymentBlock.php
253 bytes
0644
CheckoutPickupOptionsBlock.php
272 bytes
0644
CheckoutShippingAddressBlock.php
278 bytes
0644
CheckoutShippingMethodBlock.php
275 bytes
0644
CheckoutShippingMethodsBlock.php
278 bytes
0644
CheckoutTermsBlock.php
247 bytes
0644
CheckoutTotalsBlock.php
250 bytes
0644
ClassicShortcode.php
3105 bytes
0644
ClassicTemplate.php
11371 bytes
0644
ComingSoon.php
3516 bytes
0644
CustomerAccount.php
8790 bytes
0644
EmptyCartBlock.php
235 bytes
0644
EmptyMiniCartContentsBlock.php
273 bytes
0644
FeaturedCategory.php
2304 bytes
0644
FeaturedItem.php
9332 bytes
0644
FeaturedProduct.php
2803 bytes
0644
FilledCartBlock.php
238 bytes
0644
FilledMiniCartContentsBlock.php
276 bytes
0644
FilterWrapper.php
376 bytes
0644
HandpickedProducts.php
1936 bytes
0644
MiniCart.php
21100 bytes
0644
MiniCartCartButtonBlock.php
264 bytes
0644
MiniCartCheckoutButtonBlock.php
276 bytes
0644
MiniCartContents.php
5148 bytes
0644
MiniCartFooterBlock.php
251 bytes
0644
MiniCartItemsBlock.php
248 bytes
0644
MiniCartProductsTableBlock.php
273 bytes
0644
MiniCartShoppingButtonBlock.php
276 bytes
0644
MiniCartTitleBlock.php
248 bytes
0644
MiniCartTitleItemsCounterBlock.php
286 bytes
0644
MiniCartTitleLabelBlock.php
264 bytes
0644
PageContentWrapper.php
705 bytes
0644
PriceFilter.php
1275 bytes
0644
ProceedToCheckoutBlock.php
783 bytes
0644
ProductAverageRating.php
3024 bytes
0644
ProductBestSellers.php
444 bytes
0644
ProductButton.php
10313 bytes
0644
ProductCategories.php
13059 bytes
0644
ProductCategory.php
733 bytes
0644
ProductDetails.php
2934 bytes
0644
ProductFilterActive.php
2170 bytes
0644
ProductFilterAttribute.php
12950 bytes
0644
ProductFilterCheckboxList.php
4755 bytes
0644
ProductFilterChips.php
4084 bytes
0644
ProductFilterClearButton.php
1955 bytes
0644
ProductFilterPrice.php
7328 bytes
0644
ProductFilterPriceSlider.php
6616 bytes
0644
ProductFilterRating.php
7246 bytes
0644
ProductFilterRemovableChips.php
4326 bytes
0644
ProductFilterStatus.php
6934 bytes
0644
ProductFilters.php
7999 bytes
0644
ProductGallery.php
5315 bytes
0644
ProductGalleryLargeImage.php
6070 bytes
0644
ProductGalleryLargeImageNextPrevious.php
4435 bytes
0644
ProductGalleryPager.php
2110 bytes
0644
ProductGalleryThumbnails.php
6905 bytes
0644
ProductImage.php
7243 bytes
0644
ProductImageGallery.php
1928 bytes
0644
ProductMeta.php
1009 bytes
0644
ProductNew.php
448 bytes
0644
ProductOnSale.php
761 bytes
0644
ProductPrice.php
2857 bytes
0644
ProductQuery.php
28449 bytes
0644
ProductRating.php
7112 bytes
0644
ProductRatingCounter.php
6488 bytes
0644
ProductRatingStars.php
4733 bytes
0644
ProductResultsCount.php
1812 bytes
0644
ProductReviews.php
1081 bytes
0644
ProductSKU.php
2494 bytes
0644
ProductSaleBadge.php
3644 bytes
0644
ProductSearch.php
4601 bytes
0644
ProductStockIndicator.php
3777 bytes
0644
ProductSummary.php
8171 bytes
0644
ProductTag.php
2284 bytes
0644
ProductTemplate.php
5759 bytes
0644
ProductTitle.php
1610 bytes
0644
ProductTopRated.php
424 bytes
0644
ProductsByAttribute.php
2104 bytes
0644
RatingFilter.php
704 bytes
0644
RelatedProducts.php
4809 bytes
0644
ReviewsByCategory.php
1339 bytes
0644
ReviewsByProduct.php
1336 bytes
0644
SingleProduct.php
5629 bytes
0644
StockFilter.php
1370 bytes
0644
StoreNotices.php
1742 bytes
0644
N4ST4R_ID | Naxtarrr