'theme', 'limit' => 'limit', 'upcoming' => 'upcoming', 'recent' => 'recent', 'group' => 'group', 'status' => 'status', 'phase' => 'phase', 'groupBy' => 'group_by', 'order' => 'order', 'team' => 'team', 'sort' => 'sort', 'extend' => 'extend', 'form' => 'form', 'extra' => 'extra', 'diff' => 'diff', 'sections' => 'sections', 'header' => 'header', 'live' => 'live', 'apply' => 'apply', ]; public static function register(): void { add_action('init', [self::class, 'init'], 20); } public static function init(): void { if (!function_exists('register_block_type')) return; wp_register_script( 'blyzer-events-block', BLYZER_EVENTS_URL . 'blocks/event/index.js', ['wp-blocks', 'wp-element', 'wp-block-editor', 'wp-components', 'wp-server-side-render', 'wp-i18n', 'wp-api-fetch'], Plugin::assetVersion('blocks/event/index.js'), true ); wp_set_script_translations('blyzer-events-block', 'blyzer-events', BLYZER_EVENTS_PATH . 'languages'); register_block_type(BLYZER_EVENTS_PATH . 'blocks/event', [ 'render_callback' => [self::class, 'render'], ]); } public static function atts(array $attributes): array { $atts = ['id' => absint($attributes['eventId'] ?? 0)]; foreach (self::MAP as $from => $to) { $value = $attributes[$from] ?? ''; if (!is_scalar($value) || (string) $value === '') continue; if ((string) $value === '0' && in_array($from, ['limit', 'team'], true)) continue; $atts[$to] = (string) $value; } return $atts; } public static function render($attributes): string { $attributes = is_array($attributes) ? $attributes : []; $atts = self::atts($attributes); if ($atts['id'] === 0) return ''; $section = (string) ($attributes['section'] ?? 'tournament'); if (!in_array($section, Shortcodes::types(), true)) $section = 'tournament'; $html = Shortcodes::output($section, $atts); if ($html === '') return ''; return '