'
. ''
. ''
. '';
return 'data:image/svg+xml;base64,' . base64_encode( $svg );
}
public function add_menu() {
add_menu_page(
__( 'Adventura', 'adventura-interactive-advent-calendar' ),
__( 'Adventura', 'adventura-interactive-advent-calendar' ),
'manage_options',
self::SLUG,
array( $this, 'render_page' ),
$this->menu_icon(),
26
);
// Rename the auto-generated first submenu entry to "Übersicht".
add_submenu_page(
self::SLUG,
__( 'Übersicht', 'adventura-interactive-advent-calendar' ),
__( 'Übersicht', 'adventura-interactive-advent-calendar' ),
'manage_options',
self::SLUG,
array( $this, 'render_page' )
);
}
public function assets( $hook ) {
// Load the admin stylesheet on every Adventskalender screen.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only screen detection for enqueueing assets; no state change.
$post_type = isset( $_GET['post_type'] ) ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) : '';
// Also detect the door editor reliably — editing an existing door uses
// post.php (no post_type in the URL), so fall back to the current screen.
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
$is_door_screen = $screen && isset( $screen->post_type ) && ADVK_Doors_CPT::POST_TYPE === $screen->post_type;
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection.
$page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
// Only Adventura's own screens — NOT other "advk-*" plugins such as the
// License Server ("advk-ls"), which must keep the default WP admin chrome.
if ( in_array( $page, self::screens(), true )
|| ADVK_Doors_CPT::POST_TYPE === $post_type
|| $is_door_screen ) {
// Print the admin stylesheet INLINE in the
instead of enqueuing
// a file. This is bulletproof against caching / CSS-combine optimizer
// plugins (WP Rocket, LiteSpeed, Autoptimize, …) that were serving a
// stale admin.css and breaking the redesign. The file has no url()
// references, so inlining is safe.
add_action( 'admin_head', array( $this, 'print_inline_admin_css' ), 99 );
}
}
/** Output the admin stylesheet inline (see assets()). */
public function print_inline_admin_css() {
$css_path = ADVK_DIR . 'assets/css/admin.css';
if ( ! file_exists( $css_path ) ) {
return;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents, WordPress.Security.EscapeOutput.OutputNotEscaped -- Reading and printing our own trusted CSS file (no user input, no url()).
echo "\n\n";
}
public function render_page() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$stats = ADVK_Entries::stats();
$per_day = $stats['per_day'];
$max = max( 1, max( $per_day ) );
$count = ADVK_Data::door_count();
$today = ADVK_Data::today_day();
$opts = ADVK_Settings::get_options();
// Sponsor name per day (default calendar).
$sponsor = array();
foreach ( ADVK_Data::get_calendar() as $d ) {
$sponsor[ (int) $d['day'] ] = (string) $d['sponsor'];
}
// Winners: which days are drawn + how many winners are not notified yet.
$winner_days = array();
$unnotified = 0;
$win_total = 0;
$winner_rows = ADVK_Entries::query( array( 'per_page' => 100000, 'offset' => 0, 'winners_only' => true ) );
foreach ( $winner_rows as $w ) {
$winner_days[ (int) $w->day ] = true;
$win_total++;
if ( class_exists( 'ADVK_Winners' ) && '' === ADVK_Winners::notified_at( (int) $w->id ) ) {
$unnotified++;
}
}
// "To-do" list from real state.
$todos = array();
if ( $today > 1 ) {
for ( $d = min( $count, $today - 1 ); $d >= 1; $d-- ) {
$c = ( $d >= 1 && $d <= 24 ) ? (int) $per_day[ $d ] : 0;
if ( $c > 0 && empty( $winner_days[ $d ] ) ) {
$todos[] = array(
/* translators: %d: door day number. */
'title' => sprintf( __( 'Türchen %d auslosen', 'adventura-interactive-advent-calendar' ), $d ),
/* translators: %d: number of participations. */
'sub' => sprintf( __( '%d Teilnahmen · bereits geschlossen', 'adventura-interactive-advent-calendar' ), $c ),
'cta' => __( 'Jetzt ziehen', 'adventura-interactive-advent-calendar' ),
'url' => admin_url( 'admin.php?page=advk-winners' ),
);
break;
}
}
}
if ( $unnotified > 0 ) {
$todos[] = array(
/* translators: %d: number of winners not yet notified. */
'title' => sprintf( _n( '%d Gewinner nicht benachrichtigt', '%d Gewinner nicht benachrichtigt', $unnotified, 'adventura-interactive-advent-calendar' ), $unnotified ),
'sub' => __( 'In der Auslosung benachrichtigen', 'adventura-interactive-advent-calendar' ),
'cta' => __( 'Öffnen', 'adventura-interactive-advent-calendar' ),
'url' => admin_url( 'admin.php?page=advk-winners' ),
);
}
if ( empty( $opts['turnstile_enabled'] ) ) {
$todos[] = array(
'title' => __( 'Spam-Schutz erweitern', 'adventura-interactive-advent-calendar' ),
'sub' => __( 'Cloudflare Turnstile ist noch nicht aktiv', 'adventura-interactive-advent-calendar' ),
'cta' => __( 'Einrichten', 'adventura-interactive-advent-calendar' ),
'url' => admin_url( 'admin.php?page=advk-settings' ),
);
}
$month_label = wp_date( 'F Y' );
$today_sub = $today && isset( $sponsor[ $today ] ) && '' !== $sponsor[ $today ]
? $sponsor[ $today ]
: ( $today ? __( 'aktiv', 'adventura-interactive-advent-calendar' ) : __( 'außerhalb des Zeitraums', 'adventura-interactive-advent-calendar' ) );
?>
%
0
/* translators: %d: winners not yet notified. */
? sprintf( __( '%d noch nicht benachrichtigt', 'adventura-interactive-advent-calendar' ), $unnotified )
: __( 'alle benachrichtigt', 'adventura-interactive-advent-calendar' ) ); ?>
= 1 && $d <= 24 ) ? (int) $per_day[ $d ] : 0;
$cls = 'advk-doortile' . ( 'today' === $st ? ' is-today' : ( 'plan' === $st ? ' is-plan' : '' ) );
$sub = 'today' === $st ? __( 'heute', 'adventura-interactive-advent-calendar' ) : ( 'plan' === $st ? '' : (string) $c );
?>
0 ? max( 4, (int) round( $c / $max * 100 ) ) . '%' : '3px';
$bc = ( $d === $today ) ? ' is-today' : ( 0 === $c ? ' is-empty' : '' );
?>
1...