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 ); } /** * Get the frontend style handle for this block type. * * @return null */ protected function get_block_type_style() { return null; } }