Submit
Path:
~
/
home
/
getwphos
/
www
/
twinkletown
/
wp-content
/
backup
/
plugins
/
woocommerce
/
src
/
Blocks
/
BlockTypes
/
File Content:
ClassicTemplate.php
<?php namespace Automattic\WooCommerce\Blocks\BlockTypes; use Automattic\WooCommerce\Blocks\Templates\ProductAttributeTemplate; use Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate; use Automattic\WooCommerce\Blocks\Templates\ProductCategoryTemplate; use Automattic\WooCommerce\Blocks\Templates\ProductTagTemplate; use Automattic\WooCommerce\Blocks\Templates\ProductSearchResultsTemplate; use Automattic\WooCommerce\Blocks\Templates\OrderConfirmationTemplate; use Automattic\WooCommerce\Blocks\Utils\StyleAttributesUtils; use WC_Shortcode_Checkout; use WC_Frontend_Scripts; /** * Classic Template class * * @internal */ class ClassicTemplate extends AbstractDynamicBlock { /** * Block name. * * @var string */ protected $block_name = 'legacy-template'; /** * API version. * * @var string */ protected $api_version = '3'; /** * Initialize this block. */ protected function initialize() { parent::initialize(); add_filter( 'render_block', array( $this, 'add_alignment_class_to_wrapper' ), 10, 2 ); add_action( 'enqueue_block_assets', array( $this, 'enqueue_block_assets' ) ); } /** * 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 = array() ) { parent::enqueue_data( $attributes ); // Indicate to interactivity powered components that this block is on the page // and needs refresh to update data. wp_interactivity_config( 'woocommerce', array( 'needsRefreshForInteractivityAPI' => true, ) ); } /** * Enqueue assets used for rendering the block in editor context. * * This is needed if a block is not yet within the post content--`render` and `enqueue_assets` may not have ran. */ public function enqueue_block_assets() { // Ensures frontend styles for blocks exist in the site editor iframe. if ( class_exists( 'WC_Frontend_Scripts' ) && is_admin() ) { $frontend_scripts = new WC_Frontend_Scripts(); $styles = $frontend_scripts::get_styles(); foreach ( $styles as $handle => $style ) { wp_enqueue_style( $handle, set_url_scheme( $style['src'] ), $style['deps'], $style['version'], $style['media'] ); } } } /** * Enqueue assets specific to this block. * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. */ protected function enqueue_assets( $attributes, $content, $block ) { parent::enqueue_assets( $attributes, $content, $block ); if ( is_product() ) { add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_legacy_assets' ], 20 ); } } /** * Enqueue legacy assets when this block is used as we don't enqueue them for block themes anymore. * * Note: This enqueue logic is intentionally duplicated in ProductImageGallery.php * to keep legacy blocks independent and allow for separate deprecation paths. * * @see https://github.com/woocommerce/woocommerce/pull/60223 */ public function enqueue_legacy_assets() { // Legacy script dependencies for backward compatibility. if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) { wp_enqueue_script( 'wc-zoom' ); } if ( current_theme_supports( 'wc-product-gallery-slider' ) ) { wp_enqueue_script( 'wc-flexslider' ); } if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) { wp_enqueue_script( 'wc-photoswipe-ui-default' ); wp_enqueue_style( 'photoswipe-default-skin' ); add_action( 'wp_footer', function () { wc_get_template( 'single-product/photoswipe.php' ); } ); } wp_enqueue_script( 'wc-single-product' ); } /** * Render method for the Classic Template block. This method will determine which template to render. * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. * @return string | void Rendered block type output. */ protected function render( $attributes, $content, $block ) { if ( ! isset( $attributes['template'] ) ) { return; } /** * We need to load the scripts here because when using block templates wp_head() gets run after the block * template. As a result we are trying to enqueue required scripts before we have even registered them. * * @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/5328#issuecomment-989013447 */ if ( class_exists( 'WC_Frontend_Scripts' ) ) { $frontend_scripts = new WC_Frontend_Scripts(); $frontend_scripts::load_scripts(); } if ( OrderConfirmationTemplate::SLUG === $attributes['template'] ) { return $this->render_order_received(); } if ( is_product() ) { add_filter( 'woocommerce_single_product_zoom_enabled', '__return_true' ); add_filter( 'woocommerce_single_product_photoswipe_enabled', '__return_true' ); add_filter( 'woocommerce_single_product_flexslider_enabled', '__return_true' ); return $this->render_single_product(); } $valid = false; $archive_templates = array( ProductCatalogTemplate::SLUG, ProductCategoryTemplate::SLUG, ProductTagTemplate::SLUG, ProductAttributeTemplate::SLUG, ProductSearchResultsTemplate::SLUG, ); // Set selected template when we directly find template base slug. if ( in_array( $attributes['template'], $archive_templates, true ) ) { $valid = true; } // Set selected template when we find template base slug as prefix for a specific term. foreach ( $archive_templates as $template ) { if ( 0 === strpos( $attributes['template'], $template ) ) { $valid = true; } } if ( $valid ) { // Set this so that our product filters can detect if it's a PHP template. $this->asset_data_registry->add( 'isRenderingPhpTemplate', true ); // Set this so filter blocks being used as widgets know when to render. $this->asset_data_registry->add( 'hasFilterableProducts', true ); $this->asset_data_registry->add( 'pageUrl', html_entity_decode( get_pagenum_link() ) ); return $this->render_archive_product(); } ob_start(); echo "You're using the ClassicTemplate block"; wp_reset_postdata(); return ob_get_clean(); } /** * Render method for rendering the order confirmation template. * * @return string Rendered block type output. */ protected function render_order_received() { ob_start(); echo '<div class="wp-block-group">'; printf( '<%1$s %2$s>%3$s</%1$s>', 'h1', get_block_wrapper_attributes(), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped esc_html__( 'Order confirmation', 'woocommerce' ) ); WC_Shortcode_Checkout::output( array() ); echo '</div>'; return ob_get_clean(); } /** * Render method for the single product template and parts. * * @return string Rendered block type output. */ protected function render_single_product() { ob_start(); /** * Hook: woocommerce_before_main_content * * Called before rendering the main content for a product. * * @see woocommerce_output_content_wrapper() Outputs opening DIV for the content (priority 10) * @see woocommerce_breadcrumb() Outputs breadcrumb trail to the current product (priority 20) * @see WC_Structured_Data::generate_website_data() Outputs schema markup (priority 30) * * @since 6.3.0 */ do_action( 'woocommerce_before_main_content' ); $product_query = new \WP_Query( array( 'post_type' => 'product', 'p' => get_the_ID(), ) ); while ( $product_query->have_posts() ) : $product_query->the_post(); wc_get_template_part( 'content', 'single-product' ); endwhile; /** * Hook: woocommerce_after_main_content * * Called after rendering the main content for a product. * * @see woocommerce_output_content_wrapper_end() Outputs closing DIV for the content (priority 10) * * @since 6.3.0 */ do_action( 'woocommerce_after_main_content' ); wp_reset_postdata(); return ob_get_clean(); } /** * Render method for the archive product template and parts. * * @return string Rendered block type output. */ protected function render_archive_product() { ob_start(); /** * Hook: woocommerce_before_main_content * * Called before rendering the main content for a product. * * @see woocommerce_output_content_wrapper() Outputs opening DIV for the content (priority 10) * @see woocommerce_breadcrumb() Outputs breadcrumb trail to the current product (priority 20) * @see WC_Structured_Data::generate_website_data() Outputs schema markup (priority 30) * * @since 6.3.0 */ do_action( 'woocommerce_before_main_content' ); ?> <header class="woocommerce-products-header"> <?php /** * Hook: woocommerce_show_page_title * * Allows controlling the display of the page title. * * @since 6.3.0 */ if ( apply_filters( 'woocommerce_show_page_title', true ) ) { ?> <h1 class="woocommerce-products-header__title page-title"> <?php woocommerce_page_title(); ?> </h1> <?php } /** * Hook: woocommerce_archive_description. * * @see woocommerce_taxonomy_archive_description() Renders the taxonomy archive description (priority 10) * @see woocommerce_product_archive_description() Renders the product archive description (priority 10) * * @since 6.3.0 */ do_action( 'woocommerce_archive_description' ); ?> </header> <?php if ( woocommerce_product_loop() ) { /** * Hook: woocommerce_before_shop_loop. * * @see woocommerce_output_all_notices() Render error notices (priority 10) * @see woocommerce_result_count() Show number of results found (priority 20) * @see woocommerce_catalog_ordering() Show form to control sort order (priority 30) * * @since 6.3.0 */ do_action( 'woocommerce_before_shop_loop' ); woocommerce_product_loop_start(); if ( wc_get_loop_prop( 'total' ) ) { while ( have_posts() ) { the_post(); /** * Hook: woocommerce_shop_loop. * * @since 6.3.0 */ do_action( 'woocommerce_shop_loop' ); wc_get_template_part( 'content', 'product' ); } } woocommerce_product_loop_end(); /** * Hook: woocommerce_after_shop_loop. * * @see woocommerce_pagination() Renders pagination (priority 10) * * @since 6.3.0 */ do_action( 'woocommerce_after_shop_loop' ); } else { /** * Hook: woocommerce_no_products_found. * * @see wc_no_products_found() Default no products found content (priority 10) * * @since 6.3.0 */ do_action( 'woocommerce_no_products_found' ); } /** * Hook: woocommerce_after_main_content * * Called after rendering the main content for a product. * * @see woocommerce_output_content_wrapper_end() Outputs closing DIV for the content (priority 10) * * @since 6.3.0 */ do_action( 'woocommerce_after_main_content' ); wp_reset_postdata(); return ob_get_clean(); } /** * Get HTML markup with the right classes by attributes. * This function appends the classname at the first element that have the class attribute. * Based on the experience, all the wrapper elements have a class attribute. * * @param string $content Block content. * @param array $block Parsed block data. * @return string Rendered block type output. */ public function add_alignment_class_to_wrapper( string $content, array $block ) { if ( ( 'woocommerce/' . $this->block_name ) !== $block['blockName'] ) { return $content; } $attributes = (array) $block['attrs']; // Set the default alignment to wide. if ( ! isset( $attributes['align'] ) ) { $attributes['align'] = 'wide'; } $align_class_and_style = StyleAttributesUtils::get_align_class_and_style( $attributes ); if ( ! isset( $align_class_and_style['class'] ) ) { return $content; } // Find the first tag. $first_tag = '<[^<>]+>'; $matches = array(); preg_match( $first_tag, $content, $matches ); // If there is a tag, but it doesn't have a class attribute, add the class attribute. if ( isset( $matches[0] ) && strpos( $matches[0], ' class=' ) === false ) { $pattern_before_tag_closing = '/.+?(?=>)/'; return preg_replace( $pattern_before_tag_closing, '$0 class="' . $align_class_and_style['class'] . '"', $content, 1 ); } // If there is a tag, and it has a class already, add the class attribute. $pattern_get_class = '/(?<=class=\"|\')[^"|\']+(?=\"|\')/'; return preg_replace( $pattern_get_class, '$0 ' . $align_class_and_style['class'], $content, 1 ); } }
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