array( 'label' => __( 'Theme patterns', 'abnomize' ) ), 'woocommerce' => array( 'label' => __( 'WooCommerce Patterns', 'abnomize' ) ) // Add WooCommerce pattern category ); // Apply any filters for block pattern categories. $block_pattern_categories = apply_filters( 'abnomize_block_pattern_categories', $block_pattern_categories ); // Register each block pattern category. foreach ( $block_pattern_categories as $name => $properties ) { if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) { register_block_pattern_category( $name, $properties ); } } /** * Register WooCommerce-specific block pattern. */ if ( class_exists( 'WooCommerce' ) ) { // Check if WooCommerce is active register_block_pattern( 'abnomize/woocommerce-product-pattern', array( 'title' => __( 'WooCommerce Product Pattern', 'abnomize' ), 'description' => __( 'A block pattern for WooCommerce product pages.', 'abnomize' ), 'content' => '
', 'categories' => array( 'woocommerce' ), // Assign to the WooCommerce category 'postTypes' => array( 'product' ), // Available only for WooCommerce Products ) ); } } add_action( 'init', 'abnomize_register_block_patterns', 9 ); /** * This is an example of how to unregister a core block pattern and a block pattern category. * Must be called after the patterns and pattern categories that you want to unregister have been added. * * @see https://developer.wordpress.org/reference/functions/unregister_block_pattern/ * @see https://developer.wordpress.org/reference/functions/unregister_block_pattern_category/ * * @since 1.0.0 * * @return void */ function abnomize_unregister_patterns() { unregister_block_pattern( 'core/query-small-posts' ); unregister_block_pattern( 'core/query-large-title-posts' ); unregister_block_pattern( 'core/query-offset-posts' ); unregister_block_pattern_category( 'featured' ); } add_action( 'init', 'abnomize_unregister_patterns', 10 );