2019-07-01 12:52:44 +00:00
|
|
|
<?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() {
|
2019-07-01 14:26:06 +00:00
|
|
|
$blocks = [
|
|
|
|
'FeaturedProduct',
|
|
|
|
'HandpickedProducts',
|
|
|
|
'ProductBestSellers',
|
|
|
|
'ProductCategories',
|
|
|
|
'ProductCategory',
|
|
|
|
'ProductNew',
|
|
|
|
'ProductOnSale',
|
|
|
|
'ProductsByAttribute',
|
|
|
|
'ProductTopRated',
|
|
|
|
];
|
|
|
|
foreach ( $blocks as $class ) {
|
|
|
|
$class = __NAMESPACE__ . '\\BlockTypes\\' . $class;
|
|
|
|
$instance = new $class();
|
|
|
|
$instance->register_block_type();
|
|
|
|
}
|
2019-07-01 12:52:44 +00:00
|
|
|
}
|
|
|
|
}
|