various improvements to make release 1 complete

This commit is contained in:
Reindl David (IT-PTR-CEN2-SL10)
2026-03-27 13:59:28 +01:00
parent 9ea962131a
commit 6b9c3fefa1
37 changed files with 7695 additions and 1803 deletions
+34 -16
View File
@@ -31,6 +31,7 @@ class Swi_Foot_Admin
register_setting('swi_foot_settings', 'swi_foot_verein_id');
register_setting('swi_foot_settings', 'swi_foot_season_id');
register_setting('swi_foot_settings', 'swi_foot_match_cache_duration');
register_setting('swi_foot_settings', 'swi_foot_api_language');
add_settings_section(
'swi_foot_api_section',
@@ -44,6 +45,7 @@ class Swi_Foot_Admin
add_settings_field('swi_foot_api_password', __('API Password (Application Pass)', 'swi_foot_matchdata'), array($this, 'password_render'), 'swi_foot_settings', 'swi_foot_api_section');
add_settings_field('swi_foot_verein_id', __('Verein ID (Club ID)', 'swi_foot_matchdata'), array($this, 'verein_id_render'), 'swi_foot_settings', 'swi_foot_api_section');
add_settings_field('swi_foot_season_id', __('Season ID', 'swi_foot_matchdata'), array($this, 'season_id_render'), 'swi_foot_settings', 'swi_foot_api_section');
add_settings_field('swi_foot_api_language', __('API Response Language', 'swi_foot_matchdata'), array($this, 'language_render'), 'swi_foot_settings', 'swi_foot_api_section');
add_settings_section(
'swi_foot_cache_section',
@@ -107,6 +109,17 @@ class Swi_Foot_Admin
echo '<p class="description">' . __('How long to cache match data in seconds (10-300)', 'swi_foot_matchdata') . '</p>';
}
public function language_render()
{
$language = get_option('swi_foot_api_language', '1');
echo '<select name="swi_foot_api_language">';
echo '<option value="1" ' . selected($language, '1', false) . '>' . __('German', 'swi_foot_matchdata') . '</option>';
echo '<option value="2" ' . selected($language, '2', false) . '>' . __('French', 'swi_foot_matchdata') . '</option>';
echo '<option value="3" ' . selected($language, '3', false) . '>' . __('Italian', 'swi_foot_matchdata') . '</option>';
echo '</select>';
echo '<p class="description">' . __('Select the language for API responses (German, French, or Italian)', 'swi_foot_matchdata') . '</p>';
}
public function admin_scripts($hook)
{
if ($hook === 'settings_page_swiss-football-matchdata') {
@@ -248,23 +261,21 @@ class Swi_Foot_Admin
<div class="wrap">
<h1><?php _e('Swiss Football Matchdata Settings', 'swi_foot_matchdata'); ?></h1>
<form action="options.php" method="post">
<form action="options.php" method="post" id="swi-foot-settings-form">
<?php
settings_fields('swi_foot_settings');
do_settings_sections('swi_foot_settings');
submit_button();
?>
</form>
<div class="swi-foot-admin-section">
<h2><?php _e('Connection Test', 'swi_foot_matchdata'); ?></h2>
<p>
<button type="button" id="test-connection" class="button">
<?php _e('Test API Connection', 'swi_foot_matchdata'); ?>
<div class="swi-foot-form-actions">
<button type="submit" name="swi_foot_action" value="save_and_test" class="button button-primary">
<?php _e('Save and Test', 'swi_foot_matchdata'); ?>
</button>
<span id="connection-status"></span>
</p>
</div>
<button type="submit" name="swi_foot_action" value="save_only" class="button">
<?php _e('Save without Test', 'swi_foot_matchdata'); ?>
</button>
</div>
<span id="connection-status"></span>
</form>
<div class="swi-foot-admin-section">
<h2><?php _e('Team Management', 'swi_foot_matchdata'); ?></h2>
@@ -325,7 +336,11 @@ class Swi_Foot_Admin
if (is_wp_error($teams)) {
echo '<p class="notice notice-error">' .
sprintf(__('Error loading teams: %s', 'swi_foot_matchdata'), $teams->get_error_message()) .
sprintf(
/* translators: %s is the error message from the API */
__('Error loading teams: %s', 'swi_foot_matchdata'),
$teams->get_error_message()
) .
'</p>';
return;
}
@@ -357,7 +372,12 @@ class Swi_Foot_Admin
$cache_count = is_array($keys) ? count($keys) : 0;
$cache_duration = get_option('swi_foot_match_cache_duration', 30);
echo '<p>' . sprintf(__('Currently caching %d match records with %d second cache duration.', 'swi_foot_matchdata'), $cache_count, $cache_duration) . '</p>';
echo '<p>' . 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
) . '</p>';
if ($cache_count > 0) {
$timestamps = array();
@@ -460,7 +480,5 @@ class Swi_Foot_Admin
<?php
}
}
?>