woocommerce/plugins/woocommerce-blocks/src/Library.php

47 lines
887 B
PHP
Raw Normal View History

<?php
/**
* Initializes blocks in WordPress.
*
* @package WooCommerce/Blocks
*/
namespace Automattic\WooCommerce\Blocks;
defined( 'ABSPATH' ) || exit;
/**
* Library class.
*/
class Library {
/**
* Initialize block library features.
*/
public static function init() {
add_action( 'init', array( __CLASS__, 'register_blocks' ) );
}
/**
* Register blocks, hooking up assets and render functions as needed.
*/
public static function register_blocks() {
$blocks = [
'FeaturedCategory',
'FeaturedProduct',
'HandpickedProducts',
'ProductBestSellers',
'ProductCategories',
'ProductCategory',
'ProductNew',
'ProductOnSale',
'ProductsByAttribute',
'ProductTopRated',
];
foreach ( $blocks as $class ) {
$class = __NAMESPACE__ . '\\BlockTypes\\' . $class;
$instance = new $class();
$instance->register_block_type();
}
}
}