registerBlocksOnInit(); } else { add_action('init', [$this, 'registerBlocksOnInit'], 100); } // Register Yatra block category add_filter('block_categories_all', [$this, 'registerBlockCategory'], 10, 2); } /** * Register blocks on init hook */ public function registerBlocksOnInit(): void { // Initialize all blocks new TourBlock(); new ActivityBlock(); new DestinationBlock(); } /** * Register Yatra block category * * @param array $categories Existing block categories * @param \WP_Block_Editor_Context $context Block editor context * @return array Modified categories */ public function registerBlockCategory(array $categories, \WP_Block_Editor_Context $context): array { // Add Yatra category at the beginning array_unshift($categories, [ 'slug' => 'yatra', 'title' => __('Yatra', 'yatra'), 'icon' => '', ]); return $categories; } }