is_screen() ) {
return;
}
echo "\n";
}
/** Whether the current admin screen belongs to Adventura. */
private function is_screen() {
if ( ! function_exists( 'get_current_screen' ) ) {
return false;
}
$screen = get_current_screen();
if ( ! $screen ) {
return false;
}
// Match ONLY Adventura's own pages — not other "advk-*" plugins such as the
// License Server ("advk-ls"), which must keep the default WP admin chrome.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection.
$page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
$screens = class_exists( 'ADVK_Dashboard' ) ? ADVK_Dashboard::screens() : array();
if ( in_array( $page, $screens, true ) ) {
return true;
}
$post_type = ( class_exists( 'ADVK_Doors_CPT' ) ) ? ADVK_Doors_CPT::POST_TYPE : 'advk_door';
if ( isset( $screen->post_type ) && $post_type === $screen->post_type ) {
return true;
}
return false;
}
public function body_class( $classes ) {
if ( $this->is_screen() ) {
$classes .= ' advk-admin-screen';
}
return $classes;
}
public function fonts( $hook ) {
if ( ! $this->is_screen() ) {
return;
}
// Admin-only webfonts for the redesigned chrome. Loaded here (not on the
// public frontend, which bundles its fonts locally for DSGVO compliance).
wp_enqueue_style(
'advk-admin-fonts',
'https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800;900&family=Hanken+Grotesk:wght@400;500;600;700;800&display=swap',
array(),
null // versionless external stylesheet
);
}
/** The plugin's own navigation items: [ key, label, url, count ]. */
private function nav_items() {
$doors = number_format_i18n( ADVK_Data::door_count() );
$entries = class_exists( 'ADVK_Entries' ) ? number_format_i18n( ADVK_Entries::count() ) : '';
$items = array(
array( 'dashboard', __( 'Übersicht', 'adventura-interactive-advent-calendar' ), admin_url( 'admin.php?page=advk-dashboard' ), '' ),
array( 'doors', __( 'Türchen', 'adventura-interactive-advent-calendar' ), admin_url( 'admin.php?page=advk-doors' ), $doors ),
array( 'entries', __( 'Teilnahmen', 'adventura-interactive-advent-calendar' ), admin_url( 'admin.php?page=advk-entries' ), $entries ),
array( 'winners', __( 'Auslosung', 'adventura-interactive-advent-calendar' ), admin_url( 'admin.php?page=advk-winners' ), '' ),
array( 'settings', __( 'Einstellungen', 'adventura-interactive-advent-calendar' ), admin_url( 'admin.php?page=advk-settings' ), '' ),
);
if ( defined( 'ADVK_PRO_VERSION' ) ) {
$items[] = array( 'pro', __( 'Pro', 'adventura-interactive-advent-calendar' ), admin_url( 'admin.php?page=advk-pro' ), '' );
} else {
// No Pro add-on installed → point at the upsell page instead.
$items[] = array( 'pro', '✨ ' . __( 'Pro', 'adventura-interactive-advent-calendar' ), admin_url( 'admin.php?page=advk-pro-upsell' ), '' );
}
return $items;
}
/** Which nav key matches the current screen. */
private function current_key() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection, no state change.
$page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
if ( 'advk-dashboard' === $page ) {
return 'dashboard';
}
if ( 'advk-doors' === $page || 'advk-door-edit' === $page ) {
return 'doors';
}
if ( 'advk-entries' === $page ) {
return 'entries';
}
if ( 'advk-winners' === $page ) {
return 'winners';
}
if ( 'advk-settings' === $page ) {
return 'settings';
}
if ( 0 === strpos( $page, 'advk-pro' ) ) {
return 'pro';
}
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
$post_type = class_exists( 'ADVK_Doors_CPT' ) ? ADVK_Doors_CPT::POST_TYPE : 'advk_door';
if ( $screen && isset( $screen->post_type ) && $post_type === $screen->post_type ) {
return 'doors';
}
return '';
}
public function render_nav() {
if ( ! $this->is_screen() || ! current_user_can( 'manage_options' ) ) {
return;
}
$current = $this->current_key();
$pro = defined( 'ADVK_PRO_VERSION' );
$today = ADVK_Data::today_day();
$count = ADVK_Data::door_count();
?>