post_content, $shortcode ) ) { return true; } } } // Check for WooCommerce blocks in post content. if ( $post && is_a( $post, 'WP_Post' ) ) { $wc_blocks = array( 'woocommerce/cart', 'woocommerce/checkout', 'woocommerce/mini-cart', 'woocommerce/all-products', 'woocommerce/product-collection', 'woocommerce/products-by-attribute', ); foreach ( $wc_blocks as $block ) { if ( has_block( $block, $post ) ) { return true; } } } return false; } /** * Check if WooCommerce is active. * * @return bool */ public static function is_woocommerce_active() { return class_exists( 'WooCommerce' ); } }