$automatic, 'yes' => __('Show', 'blyzer-events'), 'no' => __('Hide', 'blyzer-events')]; $with = fn(array $sections) => ['section' => $sections]; $this->start_controls_section('content', ['label' => __('Blyzer event', 'blyzer-events')]); $this->add_control('eventId', [ 'label' => __('Event', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => Elementor::eventOptions(), 'default' => '0', ]); $this->add_control('section', [ 'label' => __('What to show', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => [ 'tournament' => __('Whole event with tabs', 'blyzer-events'), 'event' => __('Event info', 'blyzer-events'), 'groups' => __('Groups', 'blyzer-events'), 'playoff_rounds' => __('Playoff', 'blyzer-events'), 'matches' => __('Matches', 'blyzer-events'), 'teams' => __('Teams', 'blyzer-events'), 'players' => __('Players', 'blyzer-events'), 'race_stages' => __('Race stages', 'blyzer-events'), 'race_standings' => __('Race standings', 'blyzer-events'), ], 'default' => 'tournament', ]); $this->add_control('theme', [ 'label' => __('Colour scheme', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => [ '' => __('Default (from the settings)', 'blyzer-events'), 'light' => __('Light', 'blyzer-events'), 'dark' => __('Dark', 'blyzer-events'), 'auto' => __('Automatic (by website colours)', 'blyzer-events'), ], 'default' => '', ]); $this->add_control('header', [ 'label' => __('Show event info above the tabs', 'blyzer-events'), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', 'condition' => $with(['tournament']), ]); $this->add_control('apply', [ 'label' => __('Show “Register a team” when registration is open', 'blyzer-events'), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'auto', 'default' => 'auto', 'condition' => $with(['tournament', 'event']), ]); $this->add_control('limit', [ 'label' => __('Show only the first', 'blyzer-events'), 'description' => __('0 = all', 'blyzer-events'), 'type' => Controls_Manager::NUMBER, 'min' => 0, 'max' => 1000, 'default' => 0, 'condition' => $with(['teams', 'groups', 'matches', 'players', 'race_standings']), ]); $this->add_control('group', [ 'label' => __('Only group', 'blyzer-events'), 'description' => __('For example A. Empty = all groups.', 'blyzer-events'), 'type' => Controls_Manager::TEXT, 'default' => '', 'condition' => $with(['groups', 'matches']), ]); $this->add_control('extend', [ 'label' => __('Part', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => ['' => __('All', 'blyzer-events'), '0' => __('Main only', 'blyzer-events'), '1' => __('Additional only', 'blyzer-events')], 'default' => '', 'condition' => $with(['groups', 'playoff_rounds']), ]); foreach (['form' => __('Form column', 'blyzer-events'), 'extra' => __('Overtime columns', 'blyzer-events'), 'diff' => __('Goal difference column', 'blyzer-events')] as $key => $label) { $this->add_control($key, [ 'label' => $label, 'type' => Controls_Manager::SELECT, 'options' => $showHide, 'default' => '', 'condition' => $with(['groups']), ]); } $this->add_control('status', [ 'label' => __('Matches', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => ['' => __('All', 'blyzer-events'), 'played' => __('Played', 'blyzer-events'), 'upcoming' => __('Upcoming', 'blyzer-events'), 'live' => __('Live', 'blyzer-events')], 'default' => '', 'condition' => $with(['matches']), ]); $this->add_control('phase', [ 'label' => __('Phase', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => ['' => __('All', 'blyzer-events'), 'groups' => __('Groups', 'blyzer-events'), 'playoff' => __('Playoff', 'blyzer-events'), 'friendly' => __('Friendly', 'blyzer-events')], 'default' => '', 'condition' => $with(['matches']), ]); $this->add_control('groupBy', [ 'label' => __('Group by', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => ['' => $automatic, 'round' => __('Round', 'blyzer-events'), 'group' => __('Group', 'blyzer-events'), 'day' => __('Day', 'blyzer-events'), 'none' => __('No grouping', 'blyzer-events')], 'default' => '', 'condition' => $with(['matches']), ]); $this->add_control('order', [ 'label' => __('Order', 'blyzer-events'), 'type' => Controls_Manager::SELECT, 'options' => ['' => __('Oldest first', 'blyzer-events'), 'desc' => __('Newest first', 'blyzer-events')], 'default' => '', 'condition' => $with(['matches']), ]); $this->add_control('sort', [ 'label' => __('Sort by statistic', 'blyzer-events'), 'description' => __('For example g for goals. Empty = total.', 'blyzer-events'), 'type' => Controls_Manager::TEXT, 'default' => '', 'condition' => $with(['players']), ]); $this->add_control('team', [ 'label' => __('Only team (Blyzer ID)', 'blyzer-events'), 'description' => __('0 = all teams', 'blyzer-events'), 'type' => Controls_Manager::NUMBER, 'min' => 0, 'default' => 0, 'condition' => $with(['matches', 'players']), ]); $this->add_control('live', [ 'label' => __('Live updates', 'blyzer-events'), 'description' => __('Refresh results automatically while the event is in progress.', 'blyzer-events'), 'type' => Controls_Manager::SWITCHER, 'return_value' => 'auto', 'default' => 'auto', ]); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $settings = is_array($settings) ? $settings : []; foreach (['header' => 'no', 'apply' => 'no', 'live' => 'no'] as $key => $off) { if (array_key_exists($key, $settings) && ($settings[$key] === '' || $settings[$key] === null)) $settings[$key] = $off; } $atts = Block::atts($settings); if ($atts['id'] === 0) { if (class_exists('\Elementor\Plugin') && isset(\Elementor\Plugin::$instance->editor) && \Elementor\Plugin::$instance->editor->is_edit_mode()) { echo '
' . esc_html__('Choose which event to show.', 'blyzer-events') . '
'; } return; } $section = (string) ($settings['section'] ?? 'tournament'); if (!in_array($section, Shortcodes::types(), true)) $section = 'tournament'; echo wp_kses(Shortcodes::output($section, $atts), Shortcodes::outputHtml(), ['http', 'https']); } }