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

49 lines
924 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',
'ProductSearch',
Introduce a new Products by Tag(s) block (https://github.com/woocommerce/woocommerce-blocks/pull/554) * Introduced WGPB_Extend_Core class to modify shortcodes and API requests of core * Require the new class * WC_REST_Blocks_Products_Controller_V2 to override the wc-blocks API to support new tags properties * Register new products by tag block type * Modify utils to support tags and tag_operators * Add ProductTagControl to handle tag searching * Add the actual products by tag block * Set limitTags to 100 * Create Package class and use in main plugin file * Move and refactor library class - split asset methods into new Assets class. * Add jetpack autoloader dependency * fix tests * Update from master * AbstractBlock class for general block registration * remove test autoloader so tests do not break * Create AbstractProductGrid * FeaturedProduct * HandpickedProducts * ProductBestSellers * ProductCategory * ProductNew * ProductOnSale * ProductTopRated * ProductsByAttribute * Remove old base and render functions * Allow non-dynamic blocks and register category block * Fix products-by-attribute due to wrong naming * Remove no dev * test phpunit dir * Update testing framework * Update with new abstract classes and build in API * Undo edit to attribute block * Move edit mode * No need to support shortcodes * correct linting errors * Update tests/bootstrap.php Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com> * Update code comment to make more sense. * Correct test package * docblock * Fix cancel button class * Fix classname schema * Set loading state so spinner is shown * Add placeholder element when no tags are selected * No tags placeholder * Update rest endpoints
2019-07-09 13:42:22 +00:00
'ProductTag',
];
foreach ( $blocks as $class ) {
$class = __NAMESPACE__ . '\\BlockTypes\\' . $class;
$instance = new $class();
$instance->register_block_type();
}
}
}