Submit
Path:
~
/
home
/
getwphos
/
www
/
twinkletown
/
wp-content
/
backup
/
plugins
/
woocommerce
/
src
/
Blocks
/
BlockTypes
/
File Content:
CustomerAccount.php
<?php namespace Automattic\WooCommerce\Blocks\BlockTypes; use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils; use Automattic\WooCommerce\Blocks\Utils\BlockHooksTrait; /** * CustomerAccount class. */ class CustomerAccount extends AbstractBlock { use BlockHooksTrait; const TEXT_ONLY = 'text_only'; const ICON_ONLY = 'icon_only'; const DISPLAY_ALT = 'alt'; const DISPLAY_LINE = 'line'; /** * Block name. * * @var string */ protected $block_name = 'customer-account'; /** * Block Hook API placements. * * @var array */ protected $hooked_block_placements = array( array( 'position' => 'after', 'anchor' => 'core/navigation', 'area' => 'header', 'callback' => 'should_unhook_block', 'version' => '8.4.0', ), ); /** * Initialize this block type. */ protected function initialize() { parent::initialize(); /** * The hooked_block_{$hooked_block_type} filter was added in WordPress 6.5. * We are the only code adding the filter 'hooked_block_woocommerce/customer-account'. * Using has_filter() for a compatibility check won't work because add_filter() is used in the same file. */ if ( version_compare( get_bloginfo( 'version' ), '6.5', '>=' ) ) { add_filter( 'hooked_block_woocommerce/customer-account', array( $this, 'modify_hooked_block_attributes' ), 10, 5 ); add_filter( 'hooked_block_types', array( $this, 'register_hooked_block' ), 9, 4 ); } } /** * Callback for the Block Hooks API to modify the attributes of the hooked block. * * @param array|null $parsed_hooked_block The parsed block array for the given hooked block type, or null to suppress the block. * @param string $hooked_block_type The hooked block type name. * @param string $relative_position The relative position of the hooked block. * @param array $parsed_anchor_block The anchor block, in parsed block array format. * @param WP_Block_Template|WP_Post|array $context The block template, template part, `wp_navigation` post type, * or pattern that the anchor block belongs to. * @return array|null */ public function modify_hooked_block_attributes( $parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context ) { $parsed_hooked_block['attrs']['displayStyle'] = 'icon_only'; $parsed_hooked_block['attrs']['iconStyle'] = 'line'; $parsed_hooked_block['attrs']['iconClass'] = 'wc-block-customer-account__account-icon'; $customer_account_block_font_size = wp_get_global_styles( array( 'blocks', 'woocommerce/customer-account', 'typography', 'fontSize' ) ); if ( ! is_string( $customer_account_block_font_size ) ) { $navigation_block_font_size = wp_get_global_styles( array( 'blocks', 'core/navigation', 'typography', 'fontSize' ) ); if ( is_string( $navigation_block_font_size ) ) { $parsed_hooked_block['attrs']['style']['typography']['fontSize'] = $navigation_block_font_size; } } return $parsed_hooked_block; } /** * Callback for the Block Hooks API to determine if the block should be auto-inserted. * * @param array $hooked_blocks An array of block slugs hooked into a given context. * @param string $position Position of the block insertion point. * @param string $anchor_block The block acting as the anchor for the inserted block. * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. * * @return array */ protected function should_unhook_block( $hooked_blocks, $position, $anchor_block, $context ) { $block_name = $this->namespace . '/' . $this->block_name; $block_is_hooked = in_array( $block_name, $hooked_blocks, true ); if ( $block_is_hooked ) { $active_theme = wp_get_theme()->get( 'Name' ); $exclude_themes = array( 'Twenty Twenty-Two', 'Twenty Twenty-Three' ); if ( in_array( $active_theme, $exclude_themes, true ) ) { $key = array_search( $block_name, $hooked_blocks, true ); unset( $hooked_blocks[ $key ] ); } } return $hooked_blocks; } /** * Render the block. * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. * * @return string Rendered block output. */ protected function render( $attributes, $content, $block ) { $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); $account_link = get_option( 'woocommerce_myaccount_page_id' ) ? wc_get_account_endpoint_url( 'dashboard' ) : wp_login_url(); $allowed_svg = array( 'svg' => array( 'class' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, ), 'path' => array( 'd' => true, 'fill' => true, 'fill-rule' => true, 'clip-rule' => true, ), 'circle' => array( 'cx' => true, 'cy' => true, 'r' => true, 'stroke' => true, 'stroke-width' => true, 'fill' => true, ), ); // Only provide aria-label if the display style is icon only. $aria_label = self::ICON_ONLY === $attributes['displayStyle'] ? 'aria-label="' . esc_attr( $this->render_label() ) . '"' : ''; $label_markup = self::ICON_ONLY === $attributes['displayStyle'] ? '' : '<span class="label">' . wp_kses( $this->render_label(), array() ) . '</span>'; return "<div class='wp-block-woocommerce-customer-account " . esc_attr( $classes_and_styles['classes'] ) . "' style='" . esc_attr( $classes_and_styles['styles'] ) . "'> <a " . $aria_label . " href='" . esc_attr( $account_link ) . "'> " . wp_kses( $this->render_icon( $attributes ), $allowed_svg ) . $label_markup . ' </a> </div>'; } /** * Gets the icon to render depending on the iconStyle and displayStyle. * * @param array $attributes Block attributes. * * @return string Label to render on the block */ private function render_icon( $attributes ) { if ( self::TEXT_ONLY === $attributes['displayStyle'] ) { return ''; } if ( self::DISPLAY_LINE === $attributes['iconStyle'] ) { return '<svg class="' . $attributes['iconClass'] . '" viewBox="1 1 29 29" fill="none" xmlns="http://www.w3.org/2000/svg"> <circle cx="16" cy="10.5" r="3.5" stroke="currentColor" stroke-width="2" fill="none" /> <path fill-rule="evenodd" clip-rule="evenodd" d="M11.5 18.5H20.5C21.8807 18.5 23 19.6193 23 21V25.5H25V21C25 18.5147 22.9853 16.5 20.5 16.5H11.5C9.01472 16.5 7 18.5147 7 21V25.5H9V21C9 19.6193 10.1193 18.5 11.5 18.5Z" fill="currentColor" /> </svg>'; } if ( self::DISPLAY_ALT === $attributes['iconStyle'] ) { return '<svg class="' . $attributes['iconClass'] . '" xmlns="http://www.w3.org/2000/svg" viewBox="-4 -4 25 25"> <path d="M9 0C4.03579 0 0 4.03579 0 9C0 13.9642 4.03579 18 9 18C13.9642 18 18 13.9642 18 9C18 4.03579 13.9642 0 9 0ZM9 4.32C10.5347 4.32 11.7664 5.57056 11.7664 7.08638C11.7664 8.62109 10.5158 9.85277 9 9.85277C7.4653 9.85277 6.23362 8.60221 6.23362 7.08638C6.23362 5.57056 7.46526 4.32 9 4.32ZM9 10.7242C11.1221 10.7242 12.96 12.2021 13.7937 14.4189C12.5242 15.5559 10.8379 16.238 9 16.238C7.16207 16.238 5.49474 15.5369 4.20632 14.4189C5.05891 12.2021 6.87793 10.7242 9 10.7242Z" fill="currentColor" /> </svg>'; } return '<svg class="' . $attributes['iconClass'] . '" xmlns="http://www.w3.org/2000/svg" viewBox="-5 -5 25 25"> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.00009 8.34785C10.3096 8.34785 12.1819 6.47909 12.1819 4.17393C12.1819 1.86876 10.3096 0 8.00009 0C5.69055 0 3.81824 1.86876 3.81824 4.17393C3.81824 6.47909 5.69055 8.34785 8.00009 8.34785ZM0.333496 15.6522C0.333496 15.8444 0.489412 16 0.681933 16H15.3184C15.5109 16 15.6668 15.8444 15.6668 15.6522V14.9565C15.6668 12.1428 13.7821 9.73911 10.0912 9.73911H5.90931C2.21828 9.73911 0.333645 12.1428 0.333645 14.9565L0.333496 15.6522Z" fill="currentColor" /> </svg>'; } /** * Gets the label to render depending on the displayStyle. * * @return string Label to render on the block. */ private function render_label() { return get_current_user_id() ? __( 'My Account', 'woocommerce' ) : __( 'Login', 'woocommerce' ); } /** * Get the frontend script handle for this block type. * * @param string $key Data to get, or default to everything. * * @return null This block has no frontend script. */ protected function get_block_type_script( $key = null ) { return null; } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
Accordion
---
0755
AddToCartWithOptions
---
0755
OrderConfirmation
---
0755
ProductCollection
---
0755
Reviews
---
0755
AbstractBlock.php
15979 bytes
0644
AbstractDynamicBlock.php
1892 bytes
0644
AbstractInnerBlock.php
1785 bytes
0644
AbstractProductGrid.php
22632 bytes
0644
ActiveFilters.php
226 bytes
0644
AddToCartForm.php
9508 bytes
0644
AllProducts.php
2040 bytes
0644
AllReviews.php
1317 bytes
0644
AtomicBlock.php
910 bytes
0644
AttributeFilter.php
1536 bytes
0644
Breadcrumbs.php
2761 bytes
0644
Cart.php
13291 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
CategoryDescription.php
1743 bytes
0644
CategoryTitle.php
2412 bytes
0644
Checkout.php
26683 bytes
0644
CheckoutActionsBlock.php
1003 bytes
0644
CheckoutAdditionalInformationBlock.php
296 bytes
0644
CheckoutBillingAddressBlock.php
275 bytes
0644
CheckoutContactInformationBlock.php
287 bytes
0644
CheckoutExpressPaymentBlock.php
4232 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
12937 bytes
0644
ComingSoon.php
3670 bytes
0644
CustomerAccount.php
8790 bytes
0644
EmailContent.php
2982 bytes
0644
EmptyCartBlock.php
235 bytes
0644
EmptyMiniCartContentsBlock.php
1834 bytes
0644
EnableBlockJsonAssetsTrait.php
775 bytes
0644
FeaturedCategory.php
2781 bytes
0644
FeaturedItem.php
14212 bytes
0644
FeaturedProduct.php
3406 bytes
0644
FilledCartBlock.php
238 bytes
0644
FilledMiniCartContentsBlock.php
3329 bytes
0644
FilterWrapper.php
376 bytes
0644
HandpickedProducts.php
1936 bytes
0644
MiniCart.php
35341 bytes
0644
MiniCartCartButtonBlock.php
2296 bytes
0644
MiniCartCheckoutButtonBlock.php
2016 bytes
0644
MiniCartContents.php
6680 bytes
0644
MiniCartFooterBlock.php
5762 bytes
0644
MiniCartItemsBlock.php
1548 bytes
0644
MiniCartProductsTableBlock.php
13824 bytes
0644
MiniCartShoppingButtonBlock.php
2073 bytes
0644
MiniCartTitleBlock.php
1534 bytes
0644
MiniCartTitleItemsCounterBlock.php
2331 bytes
0644
MiniCartTitleLabelBlock.php
1587 bytes
0644
NextPreviousButtons.php
3448 bytes
0644
PageContentWrapper.php
705 bytes
0644
PaymentMethodIcons.php
6319 bytes
0644
PriceFilter.php
1275 bytes
0644
ProceedToCheckoutBlock.php
783 bytes
0644
ProductAverageRating.php
2130 bytes
0644
ProductBestSellers.php
444 bytes
0644
ProductButton.php
12769 bytes
0644
ProductCategories.php
13059 bytes
0644
ProductCategory.php
733 bytes
0644
ProductDescription.php
2541 bytes
0644
ProductDetails.php
14486 bytes
0644
ProductFilterActive.php
2567 bytes
0644
ProductFilterAttribute.php
13041 bytes
0644
ProductFilterCheckboxList.php
5782 bytes
0644
ProductFilterChips.php
4801 bytes
0644
ProductFilterClearButton.php
1488 bytes
0644
ProductFilterPrice.php
7135 bytes
0644
ProductFilterPriceSlider.php
5485 bytes
0644
ProductFilterRating.php
7270 bytes
0644
ProductFilterRemovableChips.php
3879 bytes
0644
ProductFilterStatus.php
6782 bytes
0644
ProductFilterTaxonomy.php
15966 bytes
0644
ProductFilters.php
9973 bytes
0644
ProductGallery.php
6920 bytes
0644
ProductGalleryLargeImage.php
8074 bytes
0644
ProductGalleryThumbnails.php
4097 bytes
0644
ProductImage.php
8196 bytes
0644
ProductImageGallery.php
3638 bytes
0644
ProductMeta.php
1009 bytes
0644
ProductNew.php
448 bytes
0644
ProductOnSale.php
761 bytes
0644
ProductPrice.php
4267 bytes
0644
ProductQuery.php
28484 bytes
0644
ProductRating.php
6240 bytes
0644
ProductRatingCounter.php
5593 bytes
0644
ProductRatingStars.php
3855 bytes
0644
ProductResultsCount.php
1812 bytes
0644
ProductSKU.php
3391 bytes
0644
ProductSaleBadge.php
2753 bytes
0644
ProductSearch.php
3569 bytes
0644
ProductSpecifications.php
5817 bytes
0644
ProductStockIndicator.php
6187 bytes
0644
ProductSummary.php
7512 bytes
0644
ProductTag.php
2284 bytes
0644
ProductTemplate.php
5929 bytes
0644
ProductTitle.php
619 bytes
0644
ProductTopRated.php
424 bytes
0644
ProductsByAttribute.php
2104 bytes
0644
RatingFilter.php
704 bytes
0644
RelatedProducts.php
4878 bytes
0644
ReviewsByCategory.php
1339 bytes
0644
ReviewsByProduct.php
1336 bytes
0644
SingleProduct.php
6756 bytes
0644
StockFilter.php
1370 bytes
0644
StoreNotices.php
1742 bytes
0644
N4ST4R_ID | Naxtarrr