';
- 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
+
+
+
+
🎛️ Anzeige-Einstellungen
+
Wähle aus, welche Felder im Spieler-Profil und in den Statistik-Karten angezeigt werden sollen.
+
+
+
+
Duplikate bereinigen
+
Manueller Sync
';
$profile_id = 'mc-profile-' . substr( $container_id, -6 );
echo '
';
+ $ds_js = mcph_get_display_settings();
?>
+