' . __('Configure your Swiss Football API credentials here.', 'swi_foot_matchdata') . '
'; } public function cache_section_callback() { echo '' . __('Configure caching settings for match data.', 'swi_foot_matchdata') . '
'; } public function base_url_render() { $base_url = get_option('swi_foot_api_base_url', 'https://stg-club-api-services.football.ch'); echo ''; echo '' . __('The base URL for the Swiss Football API', 'swi_foot_matchdata') . '
'; } public function username_render() { $username = get_option('swi_foot_api_username'); echo ''; echo '' . __('Your API application key', 'swi_foot_matchdata') . '
'; } public function password_render() { $password = get_option('swi_foot_api_password'); echo ''; echo '' . __('Your API application password', 'swi_foot_matchdata') . '
'; } public function verein_id_render() { $verein_id = get_option('swi_foot_verein_id'); echo ''; echo '' . __('Enter your club\'s Verein ID (Club ID)', 'swi_foot_matchdata') . '
'; } public function season_id_render() { $season_id = get_option('swi_foot_season_id', date('Y')); echo ''; echo '' . __('Current season ID (usually the year)', 'swi_foot_matchdata') . '
'; } public function cache_duration_render() { $duration = get_option('swi_foot_match_cache_duration', 30); echo ''; echo '' . __('How long to cache match data in seconds (10-300)', 'swi_foot_matchdata') . '
'; } public function language_render() { $language = get_option('swi_foot_api_language', '1'); echo ''; echo '' . __('Select the language for API responses (German, French, or Italian)', 'swi_foot_matchdata') . '
'; } public function admin_scripts($hook) { if ($hook === 'settings_page_swiss-football-matchdata') { wp_enqueue_script('swi-foot-admin', SWI_FOOT_PLUGIN_URL . 'assets/admin.js', array('jquery'), SWI_FOOT_PLUGIN_VERSION, true); wp_localize_script('swi-foot-admin', 'swi_foot_ajax', array( 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('swi_foot_nonce'), 'rest_url' => esc_url_raw(rest_url('swi-foot/v1')), 'rest_nonce' => wp_create_nonce('wp_rest') )); wp_enqueue_style('swi-foot-admin', SWI_FOOT_PLUGIN_URL . 'assets/admin.css', array(), SWI_FOOT_PLUGIN_VERSION); } // Add shortcode help to post/page editors global $pagenow; if (in_array($pagenow, array('post.php', 'post-new.php', 'edit.php'))) { // Enqueue the registered editor bundle so WordPress picks the built asset when available. // The script handle `swi-foot-editor-blocks` is registered in `register_blocks()`. wp_enqueue_script('swi-foot-editor-blocks'); // Add admin footer debug output to help diagnose missing script tags. add_action('admin_footer', array($this, 'print_editor_script_debug')); // Post context editor panel: allow editor to set per-post season/team/match wp_enqueue_script('swi-foot-post-context', SWI_FOOT_PLUGIN_URL . 'assets/post-context.js', array('wp-plugins','wp-edit-post','wp-element','wp-data','wp-components'), SWI_FOOT_PLUGIN_VERSION, true); wp_localize_script('swi-foot-post-context', 'swi_foot_post_context', array( 'rest_url' => esc_url_raw(rest_url('swi-foot/v1')), 'rest_nonce' => wp_create_nonce('wp_rest'), 'default_season' => get_option('swi_foot_season_id', date('Y')) )); wp_enqueue_style('swi-foot-admin', SWI_FOOT_PLUGIN_URL . 'assets/admin.css', array(), SWI_FOOT_PLUGIN_VERSION); } } public function print_editor_script_debug() { // Only show on post editor pages $pagenow = isset($GLOBALS['pagenow']) ? $GLOBALS['pagenow'] : ''; if (!in_array($pagenow, array('post.php', 'post-new.php', 'edit.php'))) return; // Check registration/enqueue status and attempt to find the resolved src $registered = false; $enqueued = false; $src = ''; global $wp_scripts; if (isset($wp_scripts) && is_object($wp_scripts)) { $registered = wp_script_is('swi-foot-editor-blocks', 'registered'); $enqueued = wp_script_is('swi-foot-editor-blocks', 'enqueued'); $handle = $wp_scripts->query('swi-foot-editor-blocks', 'registered'); if ($handle && isset($wp_scripts->registered['swi-foot-editor-blocks']->src)) { $src = $wp_scripts->registered['swi-foot-editor-blocks']->src; } } $msg = array( 'registered' => $registered ? 'yes' : 'no', 'enqueued' => $enqueued ? 'yes' : 'no', 'src' => $src ); echo ""; } public function add_match_meta_boxes() { add_meta_box( 'swi-foot-shortcodes', __('Swiss Football Shortcodes', 'swi_foot_matchdata'), array($this, 'shortcodes_meta_box'), array('post', 'page'), 'side', 'default' ); } public function shortcodes_meta_box($post) { ?>[swi_foot_match match_id="12345"]
[swi_foot_match team_id="67" show_next="true"]
[swi_foot_match_home_team match_id="12345"]
[swi_foot_match_away_team match_id="12345"]
[swi_foot_match_date match_id="12345" format="d.m.Y"]
[swi_foot_match_time match_id="12345" format="H:i"]
[swi_foot_match_venue match_id="12345"]
[swi_foot_match_score match_id="12345" separator=":"]
[swi_foot_match_status match_id="12345"]
[swi_foot_match_league match_id="12345"]
[swi_foot_match_round match_id="12345"]
match_id - Specific match IDteam_id - Team ID (for next match)show_next - Show next match (true/false)format - Date/time formatseparator - Score separator
display_cache_info(); ?>
[swi_foot_match match_id="12345"]
[swi_foot_match team_id="67" show_next="true"]
[swi_foot_match_home_team match_id="12345"] [swi_foot_match_away_team match_id="12345"] [swi_foot_match_date match_id="12345"]
' . sprintf( /* translators: %s is the error message from the API */ __('Error loading teams: %s', 'swi_foot_matchdata'), $teams->get_error_message() ) . '
'; return; } if (empty($teams)) { echo '' . __('No teams found. Please check your API configuration.', 'swi_foot_matchdata') . '
'; return; } echo '' . sprintf( /* translators: %1$d is the number of cached match records, %2$d is the cache duration in seconds */ __('Currently caching %1$d match records with %2$d second cache duration.', 'swi_foot_matchdata'), $cache_count, $cache_duration ) . '
'; if ($cache_count > 0) { $timestamps = array(); foreach ($keys as $k) { $payload = get_transient('swi_foot_match_' . $k); if (is_array($payload) && isset($payload['cached_at'])) { $timestamps[] = (int) $payload['cached_at']; } } if (!empty($timestamps)) { $oldest_timestamp = min($timestamps); $newest_timestamp = max($timestamps); echo '' . __('Cache Range:', 'swi_foot_matchdata') . '
';
echo __('Oldest:', 'swi_foot_matchdata') . ' ' . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $oldest_timestamp) . '
';
echo __('Newest:', 'swi_foot_matchdata') . ' ' . date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $newest_timestamp) . '
' . __('No finished match data stored.', 'swi_foot_matchdata') . '
'; return; } echo '| ' . __('Match ID', 'swi_foot_matchdata') . ' | ' . __('Saved At', 'swi_foot_matchdata') . ' | ' . __('Players', 'swi_foot_matchdata') . ' | ' . __('Bench', 'swi_foot_matchdata') . ' | ' . __('Events', 'swi_foot_matchdata') . ' | |
|---|---|---|---|---|---|
| ' . esc_html($mid) . ' | ' . esc_html($saved) . ' | ' . esc_html($players) . ' | ' . esc_html($bench) . ' | ' . esc_html($events) . ' |