init_hooks(); $this->include_files(); } private function include_files() { } /** * Initialize WordPress hooks. * * @return void */ private function init_hooks() { add_action('init', [$this, 'register_blocks']); } /** * Register all blocks. */ public function register_blocks() { if (function_exists('wp_register_block_types_from_metadata_collection')) { wp_register_block_types_from_metadata_collection( ACCORD_BLOCKS_DIR . 'blocks/build', ACCORD_BLOCKS_DIR . 'blocks/build/blocks-manifest.php' ); return; } if (function_exists('wp_register_block_metadata_collection')) { wp_register_block_metadata_collection( ACCORD_BLOCKS_DIR . 'blocks/build', ACCORD_BLOCKS_DIR . 'blocks/build/blocks-manifest.php' ); } $manifest_data = require ACCORD_BLOCKS_DIR . 'blocks/build/blocks-manifest.php'; foreach (array_keys($manifest_data) as $block_type) { register_block_type(ACCORD_BLOCKS_DIR . "blocks/build/{$block_type}"); } } /** * Prevent cloning of the instance. * * @return void */ private function __clone() {} /** * Prevent unserializing of the instance. * * @return void */ public function __wakeup() { throw new \Exception("Cannot unserialize singleton"); } }