From 21164b56c0015a4d43d7a12d3c944f5adde31dfb Mon Sep 17 00:00:00 2001 From: Git Manager GUI Date: Tue, 5 May 2026 21:17:12 +0200 Subject: [PATCH] Upload via Git Manager GUI --- mc-player-history.php | 177 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 158 insertions(+), 19 deletions(-) diff --git a/mc-player-history.php b/mc-player-history.php index 3712bec..6203d60 100644 --- a/mc-player-history.php +++ b/mc-player-history.php @@ -3,7 +3,7 @@ Plugin Name: MC Player History Plugin URI: https://git.viper.ipv64.net/M_Viper/MC-Player-History---WordPress-Plugin Description: Spielerverlauf deines Minecraft Servers. -Version: 1.3.0 +Version: 1.4.0 Author: M_Viper Author URI: https://m-viper.de Requires at least: 6.8 @@ -745,6 +745,7 @@ function mcph_generate_player_html( $limit = 500, $only_online = false, $is_ajax ob_start(); echo '
'; $displayed_count = 0; + $ds = mcph_get_display_settings(); foreach ( $rows as $row ) { $is_online = $has_live_data ? isset( $live_online_uuids[ $row->uuid ] ) : ( $row->is_online == 1 ); @@ -775,7 +776,7 @@ function mcph_generate_player_html( $limit = 500, $only_online = false, $is_ajax echo '
'; echo '' . $username . ''; echo '
'; - if ( ! empty( $row->prefix ) ) echo '' . $prefix . ''; + if ( ! empty( $row->prefix ) && ! empty( $ds['show_prefix'] ) ) echo '' . $prefix . ''; echo '' . $username . ''; echo '
'; echo '
' . $status_html . '
'; @@ -797,6 +798,78 @@ add_action( 'admin_init', 'mcph_settings_init' ); function mcph_settings_init() { register_setting( 'mcph_plugin_options', 'mcph_statusapi_url' ); } + +// Display-Settings werden direkt per admin_post gespeichert (nicht über options.php), +// damit auch alle-deaktiviert korrekt als 0 gespeichert wird. +add_action( 'admin_post_mcph_save_display_settings', 'mcph_handle_save_display_settings' ); +function mcph_handle_save_display_settings() { + if ( ! current_user_can( 'manage_options' ) ) { + wp_die( 'Keine Berechtigung.' ); + } + check_admin_referer( 'mcph_display_settings_action' ); + + $defaults = mcph_default_display_settings(); + $input = isset( $_POST['mcph_display_settings'] ) && is_array( $_POST['mcph_display_settings'] ) + ? $_POST['mcph_display_settings'] + : array(); + + $output = array(); + foreach ( $defaults as $key => $default ) { + $output[ $key ] = isset( $input[ $key ] ) ? 1 : 0; + } + + update_option( 'mcph_display_settings', $output ); + wp_redirect( add_query_arg( + array( 'page' => 'mc_player_history', 'mcph_ds_saved' => '1' ), + admin_url( 'options-general.php' ) + ) ); + exit; +} + +function mcph_default_display_settings() { + return array( + 'show_prefix' => 1, + 'show_playtime' => 1, + 'show_balance' => 1, + 'show_joins' => 1, + 'show_kills' => 1, + 'show_deaths' => 1, + 'show_kd' => 1, + 'show_bans' => 1, + 'show_mutes' => 1, + 'show_warns' => 1, + 'show_first_seen'=> 1, + 'show_last_seen' => 1, + 'show_platform' => 1, + 'show_uuid' => 1, + ); +} + +function mcph_sanitize_display_settings( $input ) { + $defaults = mcph_default_display_settings(); + $output = array(); + foreach ( $defaults as $key => $default ) { + $output[ $key ] = isset( $input[ $key ] ) ? 1 : 0; + } + return $output; +} + +function mcph_get_display_settings() { + $saved = get_option( 'mcph_display_settings', null ); + $defaults = mcph_default_display_settings(); + // Wenn noch nie gespeichert wurde (null), Defaults zurückgeben. + // Wenn gespeichert (auch leeres Array = alle deaktiviert), gespeicherten Wert nehmen. + if ( $saved === null || ! is_array( $saved ) ) { + return $defaults; + } + // Fehlende Keys mit Default auffüllen (für neue Keys bei Plugin-Updates) + foreach ( $defaults as $key => $default ) { + if ( ! array_key_exists( $key, $saved ) ) { + $saved[ $key ] = $default; + } + } + return $saved; +} function mcph_options_page() { if ( isset( $_POST['mcph_cleanup_duplicates'] ) && check_admin_referer( 'mcph_cleanup_action' ) ) { global $wpdb; $table_name = $wpdb->prefix . 'mc_players'; @@ -813,9 +886,39 @@ function mcph_options_page() { delete_transient( 'mcph_api_cache_data' ); echo '

Manueller Sync ausgeführt.

'; } + + if ( isset( $_GET['mcph_ds_saved'] ) ) { + echo '

Anzeige-Einstellungen gespeichert.

'; + } + + $ds = mcph_get_display_settings(); + + $toggle_labels = array( + 'show_prefix' => array( 'label' => 'Rang / Prefix', 'group' => 'Spielerkarte & Profil-Header' ), + 'show_platform' => array( 'label' => 'Plattform (Java/Bedrock)', 'group' => 'Spielerkarte & Profil-Header' ), + 'show_uuid' => array( 'label' => 'UUID (im Profil)', 'group' => 'Spielerkarte & Profil-Header' ), + 'show_playtime' => array( 'label' => 'Spielzeit ⏱️', 'group' => 'Statistik-Karten' ), + 'show_balance' => array( 'label' => 'Kontostand 💰', 'group' => 'Statistik-Karten' ), + 'show_joins' => array( 'label' => 'Joins 🚀', 'group' => 'Statistik-Karten' ), + 'show_kills' => array( 'label' => 'Kills ⚔️', 'group' => 'Statistik-Karten' ), + 'show_deaths' => array( 'label' => 'Tode 💀', 'group' => 'Statistik-Karten' ), + 'show_kd' => array( 'label' => 'K/D Ratio 📊', 'group' => 'Statistik-Karten' ), + 'show_bans' => array( 'label' => 'Bans 🚫', 'group' => 'Strafen' ), + 'show_mutes' => array( 'label' => 'Mutes 🔇', 'group' => 'Strafen' ), + 'show_warns' => array( 'label' => 'Warns ⚠️', 'group' => 'Strafen' ), + 'show_first_seen'=> array( 'label' => 'Zuerst gesehen 📅', 'group' => 'Zeitangaben' ), + 'show_last_seen' => array( 'label' => 'Zuletzt online 🕐', 'group' => 'Zeitangaben' ), + ); + + // Toggles nach Gruppe gruppieren + $groups = array(); + foreach ( $toggle_labels as $key => $info ) { + $groups[ $info['group'] ][ $key ] = $info['label']; + } ?>

MC Player History Einstellungen

+
@@ -827,13 +930,45 @@ function mcph_options_page() {
- +
+ +
+

🎛️ Anzeige-Einstellungen

+

Wähle aus, welche Felder im Spieler-Profil und in den Statistik-Karten angezeigt werden sollen.

+ +
+ + +
+ $fields ) : ?> +
+

+ $label ) : ?> + + +
+ +
+

+ +

+
+ +

Duplikate bereinigen

Entfernt doppelte Spieler-Einträge aus der Datenbank.

+

Manueller Sync

@@ -855,7 +990,11 @@ function mcph_shortcode( $atts ) { echo '
'; $profile_id = 'mc-profile-' . substr( $container_id, -6 ); echo ''; + $ds_js = mcph_get_display_settings(); ?> +