Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 984ca0a367 | |||
| 65e1921da1 | |||
| 7f5efe273d | |||
| d6c3faa42c |
43
README.md
43
README.md
@@ -11,12 +11,11 @@ Die Daten werden live über eine externe **StatusAPI** aus deinem Minecraft-Netz
|
|||||||
|
|
||||||
### Pflichtvoraussetzung:
|
### Pflichtvoraussetzung:
|
||||||
- Ein **BungeeCord-Server**
|
- Ein **BungeeCord-Server**
|
||||||
- Das Plugin **StatusAPI**
|
- Das Plugin **[StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)**
|
||||||
- **StatusAPI MUSS im BungeeCord-Ordner `/plugins` liegen**
|
- **StatusAPI MUSS im BungeeCord-Ordner `/plugins` liegen**
|
||||||
|
|
||||||
❗ **NICHT** auf Spigot / Paper / Velocity
|
❗ **NICHT** auf Spigot / Paper / Velocity
|
||||||
❗ **NUR** im **BungeeCord-Server unter `/plugins`**
|
❗ **NUR** im **BungeeCord-Server unter `/plugins`**
|
||||||
|
|
||||||
```text
|
```text
|
||||||
BungeeCord/
|
BungeeCord/
|
||||||
├─ plugins/
|
├─ plugins/
|
||||||
@@ -24,8 +23,12 @@ BungeeCord/
|
|||||||
└─ config.yml
|
└─ config.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🔗 StatusAPI
|
## 🔗 StatusAPI
|
||||||
|
|
||||||
|
**Download:** [https://git.viper.ipv64.net/M_Viper/StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)
|
||||||
|
|
||||||
Die **StatusAPI** stellt einen HTTP-Endpunkt bereit (z. B. `http://localhost:9191`),
|
Die **StatusAPI** stellt einen HTTP-Endpunkt bereit (z. B. `http://localhost:9191`),
|
||||||
der von diesem WordPress-Plugin **regelmäßig abgefragt** wird, um Spieler- und Online-Daten zu synchronisieren.
|
der von diesem WordPress-Plugin **regelmäßig abgefragt** wird, um Spieler- und Online-Daten zu synchronisieren.
|
||||||
|
|
||||||
@@ -54,30 +57,30 @@ Die StatusAPI **MUSS** auf dem **BungeeCord-Server** installiert sein und sich i
|
|||||||
## 📦 Installation (WordPress)
|
## 📦 Installation (WordPress)
|
||||||
|
|
||||||
1. Plugin-Dateien hochladen nach:
|
1. Plugin-Dateien hochladen nach:
|
||||||
```text
|
```text
|
||||||
wp-content/plugins/mc-player-history/
|
wp-content/plugins/mc-player-history/
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Plugin im WordPress-Admin aktivieren
|
2. Plugin im WordPress-Admin aktivieren
|
||||||
|
|
||||||
5. Unter **Einstellungen → MC Player History** die **StatusAPI URL** eintragen
|
3. Unter **Einstellungen → MC Player History** die **StatusAPI URL** eintragen
|
||||||
Beispiel:
|
Beispiel:
|
||||||
```text
|
```text
|
||||||
http://localhost:9191
|
http://localhost:9191
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Einstellungen speichern
|
4. Einstellungen speichern
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔗 Verbindung zur StatusAPI
|
## 🔗 Verbindung zur StatusAPI
|
||||||
|
|
||||||
- Die **StatusAPI** läuft auf dem **BungeeCord-Server**
|
- Die **[StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)** läuft auf dem **BungeeCord-Server**
|
||||||
- WordPress ruft diese URL per **HTTP** ab
|
- WordPress ruft diese URL per **HTTP** ab
|
||||||
- Standard-Fallback:
|
- Standard-Fallback:
|
||||||
```text
|
```text
|
||||||
http://localhost:9191
|
http://localhost:9191
|
||||||
```
|
```
|
||||||
|
|
||||||
❗ Stelle sicher, dass:
|
❗ Stelle sicher, dass:
|
||||||
|
|
||||||
@@ -88,7 +91,6 @@ Die StatusAPI **MUSS** auf dem **BungeeCord-Server** installiert sein und sich i
|
|||||||
---
|
---
|
||||||
|
|
||||||
## 🧩 Shortcode
|
## 🧩 Shortcode
|
||||||
|
|
||||||
```shortcode
|
```shortcode
|
||||||
[mc_player_history]
|
[mc_player_history]
|
||||||
```
|
```
|
||||||
@@ -102,15 +104,15 @@ Die StatusAPI **MUSS** auf dem **BungeeCord-Server** installiert sein und sich i
|
|||||||
| only_online | Nur Online-Spieler anzeigen | false |
|
| only_online | Nur Online-Spieler anzeigen | false |
|
||||||
|
|
||||||
### Beispiel
|
### Beispiel
|
||||||
|
|
||||||
```shortcode
|
```shortcode
|
||||||
[mc_player_history limit="50" interval="5" only_online="true"]
|
[mc_player_history limit="50" interval="5" only_online="true"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🎨 Anzeige-Reihenfolge (fix)
|
## 🎨 Anzeige-Reihenfolge (fix)
|
||||||
|
|
||||||
Die Struktur ist **fest definiert** und kann **nicht verändert** werden:
|
Die Struktur ist **fest definiert** und kann **nicht verändert** werden:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
Avatar
|
Avatar
|
||||||
Prefix
|
Prefix
|
||||||
@@ -119,6 +121,8 @@ Name
|
|||||||
Status (unten)
|
Status (unten)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🛠 Cron & Caching
|
## 🛠 Cron & Caching
|
||||||
|
|
||||||
- WordPress-Cron läuft alle **2 Minuten**
|
- WordPress-Cron läuft alle **2 Minuten**
|
||||||
@@ -131,7 +135,7 @@ Status (unten)
|
|||||||
|
|
||||||
### ❌ Keine Spieler sichtbar?
|
### ❌ Keine Spieler sichtbar?
|
||||||
|
|
||||||
- StatusAPI nicht erreichbar
|
- **[StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)** nicht erreichbar
|
||||||
- StatusAPI **nicht im `BungeeCord/plugins/`**
|
- StatusAPI **nicht im `BungeeCord/plugins/`**
|
||||||
- Falsche URL (z. B. `http://` vergessen)
|
- Falsche URL (z. B. `http://` vergessen)
|
||||||
- Firewall blockiert den API-Port
|
- Firewall blockiert den API-Port
|
||||||
@@ -141,3 +145,10 @@ Status (unten)
|
|||||||
- StatusAPI liefert keine `players`
|
- StatusAPI liefert keine `players`
|
||||||
- BungeeCord-Server nicht gestartet
|
- BungeeCord-Server nicht gestartet
|
||||||
- Falscher API-Port konfiguriert
|
- Falscher API-Port konfiguriert
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 Weitere Informationen
|
||||||
|
|
||||||
|
Für detaillierte Informationen zur Installation und Konfiguration der StatusAPI besuche das Repository:
|
||||||
|
**[https://git.viper.ipv64.net/M_Viper/StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)**
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Plugin Name: MC Player History
|
Plugin Name: MC Player History
|
||||||
Description: Strikte Reihenfolge: Bild -> Prefix -> Name -> Status (unten).
|
Description: Spielerverlauf deines Minecraft Servers.
|
||||||
Version: 1.1.0
|
Version: 1.1.2
|
||||||
Author: Dein Name
|
Author: M_Viper
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
@@ -53,11 +53,11 @@ function mcph_parse_minecraft_colors( $text ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. Tabelle beim Aktivieren anlegen
|
* 1. Tabelle beim Aktivieren anlegen + Playtime Spalte
|
||||||
*/
|
*/
|
||||||
register_activation_hook( __FILE__, 'mcph_install' );
|
register_activation_hook( __FILE__, 'mcph_install' );
|
||||||
function mcph_install() {
|
function mcph_install() {
|
||||||
global $wpdb;
|
global $wpdb, $mc_player_history_db_version; // FIX: Variable global verfügbar machen
|
||||||
$table_name = $wpdb->prefix . 'mc_players';
|
$table_name = $wpdb->prefix . 'mc_players';
|
||||||
$charset_collate = $wpdb->get_charset_collate();
|
$charset_collate = $wpdb->get_charset_collate();
|
||||||
$sql = "CREATE TABLE $table_name (
|
$sql = "CREATE TABLE $table_name (
|
||||||
@@ -68,10 +68,12 @@ function mcph_install() {
|
|||||||
first_seen datetime NOT NULL,
|
first_seen datetime NOT NULL,
|
||||||
last_seen datetime NOT NULL,
|
last_seen datetime NOT NULL,
|
||||||
is_online tinyint(1) NOT NULL DEFAULT 0,
|
is_online tinyint(1) NOT NULL DEFAULT 0,
|
||||||
|
playtime_seconds INT NOT NULL DEFAULT 0,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
UNIQUE KEY uuid (uuid),
|
UNIQUE KEY uuid (uuid),
|
||||||
KEY username (username),
|
KEY username (username),
|
||||||
KEY is_online (is_online)
|
KEY is_online (is_online),
|
||||||
|
KEY playtime_seconds (playtime_seconds)
|
||||||
) $charset_collate;";
|
) $charset_collate;";
|
||||||
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
||||||
dbDelta( $sql );
|
dbDelta( $sql );
|
||||||
@@ -83,6 +85,22 @@ function mcph_deactivate() {
|
|||||||
wp_clear_scheduled_hook( 'mcph_sync_event' );
|
wp_clear_scheduled_hook( 'mcph_sync_event' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NEU: Playtime Spalte hinzufügen (wird beim Laden geprüft)
|
||||||
|
*/
|
||||||
|
add_action( 'init', 'mcph_add_playtime_column' );
|
||||||
|
function mcph_add_playtime_column() {
|
||||||
|
global $wpdb;
|
||||||
|
$table_name = $wpdb->prefix . 'mc_players';
|
||||||
|
|
||||||
|
// Prüfen, ob Spalte existiert
|
||||||
|
$column_exists = $wpdb->get_var( "SHOW COLUMNS FROM $table_name LIKE 'playtime_seconds'" );
|
||||||
|
|
||||||
|
if ( empty( $column_exists ) ) {
|
||||||
|
$wpdb->query( "ALTER TABLE $table_name ADD COLUMN playtime_seconds INT NOT NULL DEFAULT 0 AFTER last_seen" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2. Cron-Job
|
* 2. Cron-Job
|
||||||
*/
|
*/
|
||||||
@@ -113,22 +131,79 @@ function mcph_sync_from_statusapi() {
|
|||||||
$table_name = $wpdb->prefix . 'mc_players';
|
$table_name = $wpdb->prefix . 'mc_players';
|
||||||
if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) != $table_name ) { return; }
|
if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) != $table_name ) { return; }
|
||||||
|
|
||||||
|
// 1. Alle Spieler auf Offline setzen (Reset)
|
||||||
$wpdb->query( "UPDATE $table_name SET is_online = 0" );
|
$wpdb->query( "UPDATE $table_name SET is_online = 0" );
|
||||||
$players = isset( $json->players ) && is_array( $json->players ) ? $json->players : array();
|
$players = isset( $json->players ) && is_array( $json->players ) ? $json->players : array();
|
||||||
|
|
||||||
|
// 2. Spieler durchgehen
|
||||||
foreach ( $players as $p ) {
|
foreach ( $players as $p ) {
|
||||||
$name = isset( $p->name ) ? sanitize_text_field( $p->name ) : '';
|
$name = isset( $p->name ) ? sanitize_text_field( $p->name ) : '';
|
||||||
$prefix = isset( $p->prefix ) ? sanitize_text_field( $p->prefix ) : '';
|
$prefix = isset( $p->prefix ) ? sanitize_text_field( $p->prefix ) : '';
|
||||||
|
|
||||||
|
// UUID aus API übernehmen, falls vorhanden, sonst legacy-Hash
|
||||||
|
if ( isset( $p->uuid ) && !empty( $p->uuid ) ) {
|
||||||
|
$uuid = sanitize_text_field( $p->uuid );
|
||||||
|
} else {
|
||||||
$uuid = 'legacy-' . md5( strtolower( trim( $name ) ) );
|
$uuid = 'legacy-' . md5( strtolower( trim( $name ) ) );
|
||||||
|
}
|
||||||
if ( empty( $name ) ) continue;
|
if ( empty( $name ) ) continue;
|
||||||
|
|
||||||
|
// Prüfe ob Spieler bereits existiert (nach UUID)
|
||||||
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $table_name WHERE uuid = %s", $uuid ) );
|
$exists = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $table_name WHERE uuid = %s", $uuid ) );
|
||||||
|
|
||||||
|
// Fallback: Falls nicht per UUID gefunden, prüfe nach Username
|
||||||
|
if ( ! $exists ) {
|
||||||
|
$old_entry = $wpdb->get_row( $wpdb->prepare( "SELECT id, uuid FROM $table_name WHERE username = %s", $name ) );
|
||||||
|
if ( $old_entry ) {
|
||||||
|
// FIX: Basis-Daten für Update (ohne Prefix)
|
||||||
|
$update_data = array(
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'last_seen' => current_time( 'mysql' ),
|
||||||
|
'is_online' => 1
|
||||||
|
);
|
||||||
|
$update_format = array( '%s', '%s', '%d' );
|
||||||
|
|
||||||
|
// FIX: Prefix nur aktualisieren, wenn API einen Wert liefert (nicht leer)
|
||||||
|
if ( ! empty( $prefix ) ) {
|
||||||
|
$update_data['prefix'] = $prefix;
|
||||||
|
$update_format[] = '%s';
|
||||||
|
}
|
||||||
|
|
||||||
|
$wpdb->update(
|
||||||
|
$table_name,
|
||||||
|
$update_data,
|
||||||
|
array( 'id' => $old_entry->id ),
|
||||||
|
$update_format,
|
||||||
|
array( '%d' )
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NEU: Playtime erhöhen (2 Minuten = 120 Sekunden pro Sync)
|
||||||
|
$wpdb->query( $wpdb->prepare( "UPDATE $table_name SET playtime_seconds = playtime_seconds + 120 WHERE uuid = %s", $uuid ) );
|
||||||
|
|
||||||
$now = current_time( 'mysql' );
|
$now = current_time( 'mysql' );
|
||||||
|
|
||||||
if ( $exists ) {
|
if ( $exists ) {
|
||||||
$wpdb->update( $table_name, array( 'username' => $name, 'prefix' => $prefix, 'last_seen' => $now, 'is_online' => 1 ), array( 'uuid' => $uuid ), array( '%s', '%s', '%s', '%d' ), array( '%s' ) );
|
// FIX: Basis-Daten für Update (ohne Prefix)
|
||||||
|
$update_data = array(
|
||||||
|
'username' => $name,
|
||||||
|
'last_seen' => $now,
|
||||||
|
'is_online' => 1
|
||||||
|
);
|
||||||
|
$update_format = array( '%s', '%s', '%d' );
|
||||||
|
|
||||||
|
// FIX: Prefix nur aktualisieren, wenn API einen Wert liefert (nicht leer)
|
||||||
|
if ( ! empty( $prefix ) ) {
|
||||||
|
$update_data['prefix'] = $prefix;
|
||||||
|
$update_format[] = '%s';
|
||||||
|
}
|
||||||
|
|
||||||
|
$wpdb->update( $table_name, $update_data, array( 'uuid' => $uuid ), $update_format, array( '%s' ) );
|
||||||
} else {
|
} else {
|
||||||
$wpdb->insert( $table_name, array( 'uuid' => $uuid, 'username' => $name, 'prefix' => $prefix, 'first_seen' => $now, 'last_seen' => $now, 'is_online' => 1 ), array( '%s', '%s', '%s', '%s', '%s', '%d' ) );
|
// Bei neuen Spielern fügen wir das Prefix ein (auch wenn es leer ist)
|
||||||
|
$wpdb->insert( $table_name, array( 'uuid' => $uuid, 'username' => $name, 'prefix' => $prefix, 'first_seen' => $now, 'last_seen' => $now, 'is_online' => 1, 'playtime_seconds' => 0 ), array( '%s', '%s', '%s', '%s', '%s', '%d', '%d' ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,13 +256,18 @@ function mcph_generate_player_html( $limit = 500, $only_online = false, $is_ajax
|
|||||||
$has_live_data = true;
|
$has_live_data = true;
|
||||||
foreach ( $api_response as $p ) {
|
foreach ( $api_response as $p ) {
|
||||||
if ( isset( $p->name ) ) {
|
if ( isset( $p->name ) ) {
|
||||||
|
// UUID aus API übernehmen, falls vorhanden, sonst legacy-Hash
|
||||||
|
if ( isset( $p->uuid ) && !empty( $p->uuid ) ) {
|
||||||
|
$uuid = sanitize_text_field( $p->uuid );
|
||||||
|
} else {
|
||||||
$uuid = 'legacy-' . md5( strtolower( trim( $p->name ) ) );
|
$uuid = 'legacy-' . md5( strtolower( trim( $p->name ) ) );
|
||||||
|
}
|
||||||
$live_online_uuids[ $uuid ] = true;
|
$live_online_uuids[ $uuid ] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql_limit = $only_online ? ($limit * 2) : $limit;
|
$sql_limit = $only_online ? ( $limit * 2 ) : $limit;
|
||||||
$rows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table_name ORDER BY last_seen DESC LIMIT %d", $sql_limit ) );
|
$rows = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $table_name ORDER BY last_seen DESC LIMIT %d", $sql_limit ) );
|
||||||
|
|
||||||
if ( empty( $rows ) ) {
|
if ( empty( $rows ) ) {
|
||||||
@@ -218,11 +298,22 @@ function mcph_generate_player_html( $limit = 500, $only_online = false, $is_ajax
|
|||||||
|
|
||||||
$username = esc_html( $row->username );
|
$username = esc_html( $row->username );
|
||||||
$prefix = mcph_parse_minecraft_colors( $row->prefix );
|
$prefix = mcph_parse_minecraft_colors( $row->prefix );
|
||||||
$avatar = 'https://minotar.net/avatar/' . $username . '/80';
|
|
||||||
|
// Avatar-Logik: Moderne 3D-Köpfe (alle in gleiche Richtung)
|
||||||
|
$avatar = '';
|
||||||
|
if ( strpos( $username, '.' ) !== false || ( isset($row->uuid) && strpos($row->uuid, 'xuid') === 0 ) ) {
|
||||||
|
// Bedrock: mc-heads.net mit 3D Head
|
||||||
|
$avatar = isset($row->uuid) && !empty($row->uuid)
|
||||||
|
? 'https://mc-heads.net/head/' . esc_attr($row->uuid) . '/100'
|
||||||
|
: 'https://mc-heads.net/head/' . $username . '/100';
|
||||||
|
} else {
|
||||||
|
// Java: mc-heads.net mit 3D Head (gleiche Richtung wie Bedrock)
|
||||||
|
$avatar = 'https://mc-heads.net/head/' . $username . '/100';
|
||||||
|
}
|
||||||
|
|
||||||
$anim_style = '';
|
$anim_style = '';
|
||||||
if ( ! $is_ajax ) {
|
if ( ! $is_ajax ) {
|
||||||
$anim_style = 'animation: fadeInUp 0.5s ease forwards; opacity: 0; animation-delay: ' . ($displayed_count * 0.05) . 's;';
|
$anim_style = 'animation: fadeInUp 0.5s ease forwards; opacity: 0; animation-delay: ' . ( $displayed_count * 0.05 ) . 's;';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $is_online ) {
|
if ( $is_online ) {
|
||||||
@@ -235,7 +326,7 @@ function mcph_generate_player_html( $limit = 500, $only_online = false, $is_ajax
|
|||||||
|
|
||||||
// STRUKTUR: Bild -> Prefix -> Name -> Spacer -> Status
|
// STRUKTUR: Bild -> Prefix -> Name -> Spacer -> Status
|
||||||
echo '<div class="mc-player-card" style="' . $anim_style . '">';
|
echo '<div class="mc-player-card" style="' . $anim_style . '">';
|
||||||
echo '<img src="' . $avatar . '" class="mc-avatar" alt="' . $username . '">';
|
echo '<img src="' . $avatar . '" class="mc-avatar" alt="' . $username . '" loading="lazy">';
|
||||||
|
|
||||||
echo '<div class="mc-info-stack">';
|
echo '<div class="mc-info-stack">';
|
||||||
|
|
||||||
@@ -275,6 +366,33 @@ function mcph_settings_init() {
|
|||||||
register_setting( 'mcph_plugin_options', 'mcph_statusapi_url' );
|
register_setting( 'mcph_plugin_options', 'mcph_statusapi_url' );
|
||||||
}
|
}
|
||||||
function mcph_options_page() {
|
function mcph_options_page() {
|
||||||
|
// Duplikate bereinigen
|
||||||
|
if ( isset( $_POST['mcph_cleanup_duplicates'] ) && check_admin_referer( 'mcph_cleanup_action' ) ) {
|
||||||
|
global $wpdb;
|
||||||
|
$table_name = $wpdb->prefix . 'mc_players';
|
||||||
|
|
||||||
|
// Finde Duplikate (gleicher Username, verschiedene UUIDs)
|
||||||
|
$duplicates = $wpdb->get_results(
|
||||||
|
"SELECT username, COUNT(*) as count, GROUP_CONCAT(id ORDER BY last_seen DESC) as ids
|
||||||
|
FROM $table_name
|
||||||
|
GROUP BY username
|
||||||
|
HAVING count > 1"
|
||||||
|
);
|
||||||
|
|
||||||
|
$cleaned = 0;
|
||||||
|
foreach ( $duplicates as $dup ) {
|
||||||
|
$ids = explode( ',', $dup->ids );
|
||||||
|
// Behalte den neuesten (ersten), lösche die anderen
|
||||||
|
array_shift( $ids );
|
||||||
|
foreach ( $ids as $id ) {
|
||||||
|
$wpdb->delete( $table_name, array( 'id' => $id ), array( '%d' ) );
|
||||||
|
$cleaned++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div class="notice notice-success"><p>' . $cleaned . ' Duplikate wurden entfernt.</p></div>';
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $_POST['mcph_manual_sync'] ) && check_admin_referer( 'mcph_manual_sync_action' ) ) {
|
if ( isset( $_POST['mcph_manual_sync'] ) && check_admin_referer( 'mcph_manual_sync_action' ) ) {
|
||||||
mcph_sync_from_statusapi();
|
mcph_sync_from_statusapi();
|
||||||
delete_transient( 'mcph_api_cache_data' );
|
delete_transient( 'mcph_api_cache_data' );
|
||||||
@@ -296,6 +414,14 @@ function mcph_options_page() {
|
|||||||
</table>
|
</table>
|
||||||
<?php submit_button(); ?>
|
<?php submit_button(); ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<h2>Duplikate bereinigen</h2>
|
||||||
|
<form method="post">
|
||||||
|
<?php wp_nonce_field( 'mcph_cleanup_action' ); ?>
|
||||||
|
<p class="description">Entfernt doppelte Spieler-Einträge aus der Datenbank.</p>
|
||||||
|
<input type="submit" name="mcph_cleanup_duplicates" class="button button-secondary" value="Duplikate jetzt entfernen" />
|
||||||
|
</form>
|
||||||
|
|
||||||
<h2>Manueller Sync</h2>
|
<h2>Manueller Sync</h2>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<?php wp_nonce_field( 'mcph_manual_sync_action' ); ?>
|
<?php wp_nonce_field( 'mcph_manual_sync_action' ); ?>
|
||||||
@@ -328,10 +454,10 @@ function mcph_shortcode( $atts ) {
|
|||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
const intervalSeconds = <?php echo intval($atts['interval']); ?>;
|
const intervalSeconds = <?php echo intval( $atts['interval'] ); ?>;
|
||||||
const wrapperId = "<?php echo $container_id; ?>";
|
const wrapperId = "<?php echo $container_id; ?>";
|
||||||
const limit = <?php echo intval($atts['limit']); ?>;
|
const limit = <?php echo intval( $atts['limit'] ); ?>;
|
||||||
const onlyOnline = "<?php echo ($atts['only_online'] === 'true') ? 'true' : 'false'; ?>";
|
const onlyOnline = "<?php echo ( $atts['only_online'] === 'true' ) ? 'true' : 'false'; ?>";
|
||||||
|
|
||||||
function refreshList() {
|
function refreshList() {
|
||||||
fetch('<?php echo admin_url('admin-ajax.php'); ?>', {
|
fetch('<?php echo admin_url('admin-ajax.php'); ?>', {
|
||||||
@@ -379,34 +505,41 @@ function mcph_shortcode( $atts ) {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px; /* Weniger Abstand dazwischen */
|
gap: 8px;
|
||||||
padding: 20px 10px;
|
padding: 20px 10px;
|
||||||
background: #fff;
|
background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
|
||||||
border: 1px solid #eee;
|
border: 1px solid #e0e0e0;
|
||||||
border-radius: 8px;
|
border-radius: 12px;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
cursor: default;
|
cursor: default;
|
||||||
position: relative; /* Fallback */
|
position: relative;
|
||||||
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mc-player-card:hover {
|
.mc-player-card:hover {
|
||||||
transform: translateY(-5px);
|
transform: translateY(-8px) scale(1.02);
|
||||||
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
|
box-shadow: 0 12px 24px rgba(0,0,0,0.15);
|
||||||
border-color: #ddd;
|
border-color: #667eea;
|
||||||
|
background: linear-gradient(145deg, #ffffff 0%, #f0f2ff 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mc-avatar {
|
.mc-avatar {
|
||||||
border-radius: 4px;
|
border-radius: 8px;
|
||||||
border: 3px solid #ddd;
|
border: 3px solid #e0e0e0;
|
||||||
background: #fff;
|
background: transparent;
|
||||||
width: 60px;
|
width: 80px;
|
||||||
height: 60px;
|
height: 80px;
|
||||||
transition: border-color 0.3s;
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||||
|
object-fit: contain;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mc-player-card:hover .mc-avatar {
|
.mc-player-card:hover .mc-avatar {
|
||||||
border-color: #bbb;
|
border-color: #667eea;
|
||||||
|
transform: scale(1.15) rotateY(10deg);
|
||||||
|
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* INFOS BEREICH */
|
/* INFOS BEREICH */
|
||||||
@@ -415,10 +548,10 @@ function mcph_shortcode( $atts ) {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex-grow: 1; /* Füllt den Rest der Karte */
|
flex-grow: 1;
|
||||||
position: relative; /* Referenz für absoluten Status */
|
position: relative;
|
||||||
padding-bottom: 35px; /* Platz für Status unten */
|
padding-bottom: 35px;
|
||||||
justify-content: flex-start; /* Oben ausrichten */
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 1. PREFIX */
|
/* 1. PREFIX */
|
||||||
@@ -429,22 +562,24 @@ function mcph_shortcode( $atts ) {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
|
text-shadow: 0 1px 2px rgba(0,0,0,0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2. NAME */
|
/* 2. NAME */
|
||||||
.mc-name {
|
.mc-name {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
color: #333;
|
color: #2d3748;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
text-shadow: 0 1px 2px rgba(0,0,0,0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3. SPACER */
|
/* 3. SPACER */
|
||||||
.mc-spacer {
|
.mc-spacer {
|
||||||
flex-grow: 1; /* Nimmt ALLEN leeren Platz zwischen Name und Status ein */
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 4. STATUS (UNTEN) */
|
/* 4. STATUS (UNTEN) */
|
||||||
@@ -460,20 +595,42 @@ function mcph_shortcode( $atts ) {
|
|||||||
|
|
||||||
.mc-status {
|
.mc-status {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 4px 12px;
|
padding: 5px 14px;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mc-online {
|
||||||
|
background: linear-gradient(135deg, #d4f8e8 0%, #b8f2d9 100%);
|
||||||
|
color: #0a7340;
|
||||||
|
border: 1px solid #81e6b8;
|
||||||
|
box-shadow: 0 2px 4px rgba(10, 115, 64, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mc-offline {
|
||||||
|
background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
|
||||||
|
color: #c53030;
|
||||||
|
border: 1px solid #fbb6b6;
|
||||||
|
box-shadow: 0 2px 4px rgba(197, 48, 48, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mc-player-card:hover .mc-status {
|
||||||
|
transform: scale(1.05);
|
||||||
}
|
}
|
||||||
.mc-online { background-color: #e6fffa; color: #28a745; border: 1px solid #b2f5ea; }
|
|
||||||
.mc-offline { background-color: #fff5f5; color: #e53e3e; border: 1px solid #feb2b2; }
|
|
||||||
|
|
||||||
.mc-update-time {
|
.mc-update-time {
|
||||||
font-size: 0.8em;
|
font-size: 0.85em;
|
||||||
color: #999;
|
color: #718096;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 15px;
|
margin-top: 20px;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
padding: 8px;
|
||||||
|
background: rgba(102, 126, 234, 0.05);
|
||||||
|
border-radius: 6px;
|
||||||
|
display: inline-block;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
@@ -481,12 +638,290 @@ function mcph_shortcode( $atts ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.mc-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
|
.mc-grid {
|
||||||
.mc-avatar { width: 50px; height: 50px; }
|
grid-template-columns: repeat(2, 1fr);
|
||||||
.mc-name { font-size: 1em; }
|
gap: 12px;
|
||||||
.mc-player-card { padding: 10px 5px; }
|
}
|
||||||
|
.mc-avatar {
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
}
|
||||||
|
.mc-name {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
.mc-player-card {
|
||||||
|
padding: 15px 8px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>';
|
</style>';
|
||||||
|
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ================= SIDEBAR WIDGET: TOP SPIELZEIT (1/2 Spalten + sichere Inline-Farben) ================= */
|
||||||
|
class MC_Top_Playtime_Widget extends WP_Widget {
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
parent::__construct(
|
||||||
|
'mc_top_playtime_widget',
|
||||||
|
'MC Top Spieler',
|
||||||
|
array( 'description' => 'Zeigt die 6 Spieler mit der meisten Spielzeit an. Wahl: 1 oder 2 Spieler pro Zeile.' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zeitformatierung
|
||||||
|
public static function format_duration( $seconds ) {
|
||||||
|
if ( $seconds < 60 ) {
|
||||||
|
return $seconds . 's';
|
||||||
|
} elseif ( $seconds < 3600 ) {
|
||||||
|
$minutes = floor( $seconds / 60 );
|
||||||
|
return $minutes . 'm';
|
||||||
|
} elseif ( $seconds < 86400 ) {
|
||||||
|
$hours = floor( $seconds / 3600 );
|
||||||
|
$minutes = floor( ( $seconds % 3600 ) / 60 );
|
||||||
|
return $hours . 'h ' . $minutes . 'm';
|
||||||
|
} else {
|
||||||
|
$days = floor( $seconds / 86400 );
|
||||||
|
$hours = floor( ( $seconds % 86400 ) / 3600 );
|
||||||
|
return $days . 'd ' . $hours . 'h';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Konvertiert Minecraft-Farbcodes (&0-&f, &r) in inline <span style="color:#...">Text</span>
|
||||||
|
private static function parse_minecraft_color_codes_inline( $text ) {
|
||||||
|
if ( $text === null || $text === '' ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mapping Minecraft color codes -> HEX
|
||||||
|
$map = array(
|
||||||
|
'0' => '#000000',
|
||||||
|
'1' => '#0000AA',
|
||||||
|
'2' => '#00AA00',
|
||||||
|
'3' => '#00AAAA',
|
||||||
|
'4' => '#AA0000',
|
||||||
|
'5' => '#AA00AA',
|
||||||
|
'6' => '#FFAA00',
|
||||||
|
'7' => '#AAAAAA',
|
||||||
|
'8' => '#555555',
|
||||||
|
'9' => '#5555FF',
|
||||||
|
'a' => '#55FF55',
|
||||||
|
'b' => '#55FFFF',
|
||||||
|
'c' => '#FF5555',
|
||||||
|
'd' => '#FF55FF',
|
||||||
|
'e' => '#FFFF55',
|
||||||
|
'f' => '#FFFFFF',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Ersetze alternative §-Codes durch & falls nötig
|
||||||
|
$text = str_replace('§', '&', $text);
|
||||||
|
|
||||||
|
// Teile so, dass die Codes erhalten bleiben
|
||||||
|
$parts = preg_split('/(&[0-9a-frk-or])/i', $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
|
$out = '';
|
||||||
|
$open = false;
|
||||||
|
|
||||||
|
foreach ( $parts as $part ) {
|
||||||
|
// Ist es ein Code?
|
||||||
|
if ( preg_match('/^&([0-9a-frk-orA-FK-OR])$/', $part, $m) ) {
|
||||||
|
$code = strtolower( $m[1] );
|
||||||
|
|
||||||
|
// Reset
|
||||||
|
if ( $code === 'r' ) {
|
||||||
|
if ( $open ) {
|
||||||
|
$out .= '</span>';
|
||||||
|
$open = false;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Farbe
|
||||||
|
if ( isset( $map[$code] ) ) {
|
||||||
|
if ( $open ) {
|
||||||
|
$out .= '</span>';
|
||||||
|
$open = false;
|
||||||
|
}
|
||||||
|
$hex = $map[$code];
|
||||||
|
$out .= '<span style="color: ' . esc_attr( $hex ) . ';">';
|
||||||
|
$open = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatcodes: &l &o &n &m &k -> wir implementieren nur fett (&l) &o kursiv optional
|
||||||
|
if ( $code === 'l' ) { // fett
|
||||||
|
$out .= '<strong>';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( $code === 'o' ) { // italic
|
||||||
|
$out .= '<em>';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( in_array( $code, array('m','n','k'), true) ) {
|
||||||
|
// durchgestrichen / underline / obfuscated - ignorieren oder erweitern falls gewünscht
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normaler Text: escapen
|
||||||
|
$escaped = esc_html( $part );
|
||||||
|
$out .= $escaped;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schließe eventuell offene Tags: zuerst format, dann color spans
|
||||||
|
// (Wir schlossen format tags nicht oben -> vereinfachung: entfernen ungeschlossene format-tags)
|
||||||
|
// Schließe color span falls offen
|
||||||
|
if ( $open ) {
|
||||||
|
$out .= '</span>';
|
||||||
|
$open = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hinweis: Wir benutzten esc_html pro Textteil; das ist sicher.
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Backend-Form
|
||||||
|
public function form( $instance ) {
|
||||||
|
$title = isset( $instance['title'] ) ? $instance['title'] : 'Top 6 Spielzeit';
|
||||||
|
$columns = isset( $instance['columns'] ) ? intval( $instance['columns'] ) : 1;
|
||||||
|
?>
|
||||||
|
<p>
|
||||||
|
<label for="<?php echo $this->get_field_id( 'title' ); ?>">Titel:</label>
|
||||||
|
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
|
||||||
|
name="<?php echo $this->get_field_name( 'title' ); ?>" type="text"
|
||||||
|
value="<?php echo esc_attr( $title ); ?>">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="<?php echo $this->get_field_id( 'columns' ); ?>">Spieler pro Zeile:</label>
|
||||||
|
<select id="<?php echo $this->get_field_id( 'columns' ); ?>"
|
||||||
|
name="<?php echo $this->get_field_name( 'columns' ); ?>">
|
||||||
|
<option value="1" <?php selected( $columns, 1 ); ?>>1 Spieler (mit Rang + Zeit)</option>
|
||||||
|
<option value="2" <?php selected( $columns, 2 ); ?>>2 Spieler (kompakt, kein Rang, keine Zeit)</option>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
public function update( $new_instance, $old_instance ) {
|
||||||
|
$instance = array();
|
||||||
|
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : 'Top 6 Spielzeit';
|
||||||
|
$instance['columns'] = isset( $new_instance['columns'] ) && in_array( intval( $new_instance['columns'] ), array(1,2), true ) ? intval( $new_instance['columns'] ) : 1;
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Frontend-Ausgabe
|
||||||
|
public function widget( $args, $instance ) {
|
||||||
|
echo $args['before_widget'];
|
||||||
|
|
||||||
|
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Top 6 Spielzeit';
|
||||||
|
$columns = isset( $instance['columns'] ) ? intval( $instance['columns'] ) : 1;
|
||||||
|
|
||||||
|
if ( ! empty( $title ) ) {
|
||||||
|
echo $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title'];
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$table_name = $wpdb->prefix . 'mc_players';
|
||||||
|
|
||||||
|
// Top 6 Spieler abfragen
|
||||||
|
$top_players = $wpdb->get_results(
|
||||||
|
"SELECT * FROM $table_name WHERE playtime_seconds > 0 ORDER BY playtime_seconds DESC LIMIT 6"
|
||||||
|
);
|
||||||
|
|
||||||
|
$container_class = 'mc-top-list' . ( $columns === 2 ? ' mc-two-columns' : ' mc-one-column' );
|
||||||
|
?>
|
||||||
|
<div class="<?php echo esc_attr( $container_class ); ?>">
|
||||||
|
<?php if ( empty( $top_players ) ): ?>
|
||||||
|
<p style="text-align:center; color:#888; font-size:13px; padding:10px;">Noch keine Daten.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php
|
||||||
|
$rank = 1;
|
||||||
|
foreach ( $top_players as $row ):
|
||||||
|
$username = esc_html( $row->username );
|
||||||
|
$time_string = self::format_duration( $row->playtime_seconds );
|
||||||
|
|
||||||
|
// Rohes Prefix aus DB (z.B. "&7Member")
|
||||||
|
$raw_prefix = isset( $row->prefix ) ? $row->prefix : '';
|
||||||
|
$prefix_html = self::parse_minecraft_color_codes_inline( $raw_prefix );
|
||||||
|
|
||||||
|
// Avatar URL (UUID bevorzugt)
|
||||||
|
if ( isset( $row->uuid ) && ! empty( $row->uuid ) ) {
|
||||||
|
$avatar = 'https://mc-heads.net/head/' . esc_attr( $row->uuid ) . '/50';
|
||||||
|
} else {
|
||||||
|
$avatar = 'https://mc-heads.net/head/' . rawurlencode( $username ) . '/50';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<?php if ( $columns === 1 ): ?>
|
||||||
|
<!-- Einzelne Zeile: mit Rang und Zeit -->
|
||||||
|
<div class="mc-top-item">
|
||||||
|
<div class="mc-top-rank"><?php echo esc_html( $rank ); ?></div>
|
||||||
|
|
||||||
|
<img src="<?php echo esc_url( $avatar ); ?>" class="mc-top-avatar" alt="<?php echo $username; ?>">
|
||||||
|
|
||||||
|
<div class="mc-top-info">
|
||||||
|
<?php if ( ! empty( $prefix_html ) ): ?>
|
||||||
|
<div class="mc-top-prefix"><?php echo wp_kses_post( $prefix_html ); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="mc-top-name"><?php echo $username; ?></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mc-top-time"><?php echo esc_html( $time_string ); ?></div>
|
||||||
|
</div>
|
||||||
|
<?php $rank++; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<!-- Kompaktes Grid-Item: vertikal (kein Rang, keine Zeit) -->
|
||||||
|
<div class="mc-top-item mc-compact">
|
||||||
|
<img src="<?php echo esc_url( $avatar ); ?>" class="mc-top-avatar" alt="<?php echo $username; ?>">
|
||||||
|
|
||||||
|
<?php if ( ! empty( $prefix_html ) ): ?>
|
||||||
|
<div class="mc-top-prefix"><?php echo wp_kses_post( $prefix_html ); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="mc-top-name"><?php echo $username; ?></div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* Basis */
|
||||||
|
.mc-top-list { width:100%; box-sizing:border-box; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial; }
|
||||||
|
|
||||||
|
/* 1 Spalte */
|
||||||
|
.mc-one-column { display:flex; flex-direction:column; gap:8px; }
|
||||||
|
.mc-one-column .mc-top-item { display:flex; align-items:center; background:#f8f9fa; border:1px solid #e9ecef; border-radius:8px; padding:8px 10px; transition:all .18s ease; }
|
||||||
|
.mc-one-column .mc-top-item:hover { background:#e9ecef; transform:translateX(3px); border-color:#ced4da; }
|
||||||
|
.mc-top-rank { font-weight:800; color:#adb5bd; font-size:1.2rem; width:28px; text-align:center; margin-right:8px; }
|
||||||
|
.mc-one-column .mc-top-avatar { width:34px; height:34px; margin-right:10px; background:#fff; border-radius:4px; box-shadow:0 2px 4px rgba(0,0,0,0.06); object-fit:cover; }
|
||||||
|
.mc-top-info { flex-grow:1; display:flex; flex-direction:column; line-height:1.2; }
|
||||||
|
.mc-top-name { font-weight:600; color:#333; font-size:0.95rem; }
|
||||||
|
.mc-top-time { font-size:0.8rem; font-weight:700; color:#6f42c1; background:rgba(111,66,193,0.08); padding:4px 8px; border-radius:10px; margin-left:8px; white-space:nowrap; }
|
||||||
|
|
||||||
|
/* 2 Spalten kompakt */
|
||||||
|
.mc-two-columns { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
|
||||||
|
.mc-two-columns .mc-top-item.mc-compact { display:flex; flex-direction:column; align-items:center; background:#f8f9fa; border:1px solid #e9ecef; border-radius:8px; padding:10px 6px; text-align:center; transition:all .18s ease; }
|
||||||
|
.mc-two-columns .mc-top-item.mc-compact:hover { background:#e9ecef; transform:translateY(-2px); border-color:#ced4da; }
|
||||||
|
.mc-two-columns .mc-top-avatar { width:44px; height:44px; margin-bottom:6px; background:#fff; border-radius:6px; box-shadow:0 2px 6px rgba(0,0,0,0.06); object-fit:cover; }
|
||||||
|
.mc-two-columns .mc-top-name { font-weight:700; color:#222; font-size:0.9rem; }
|
||||||
|
|
||||||
|
/* WICHTIG: KEINE feste color; Inline-styles haben Vorrang.
|
||||||
|
Leichter Schatten verbessert Lesbarkeit heller Farben. */
|
||||||
|
.mc-top-prefix { font-size:0.75rem; font-weight:600; line-height:1.1; text-shadow:0 1px 1px rgba(0,0,0,0.18); display:inline-block; }
|
||||||
|
|
||||||
|
@media (max-width:360px) { .mc-two-columns { grid-template-columns:1fr; } }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo $args['after_widget'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registrierung
|
||||||
|
add_action( 'widgets_init', function(){
|
||||||
|
register_widget( 'MC_Top_Playtime_Widget' );
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user