<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

// Don't load directly
if (!defined('ABSPATH')) { exit; }

if (function_exists('r34ics_admin_access') && !r34ics_admin_access()) { return; }

$cs = get_current_screen();

// phpcs:disable WordPress.Security.NonceVerification.Recommended

$request_page = !empty($_REQUEST['page']) ? sanitize_text_field(wp_unslash($_REQUEST['page'])) : '';
$request_uri = !empty($_SERVER['REQUEST_URI']) ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])) : '';
?>
<div id="r34icspro-admin-header" class="r34ics">
	<span id="r34icspro-admin-header-icon"><img src="<?php echo esc_url(plugin_dir_url(dirname(dirname(__FILE__))) . '/assets/ics-calendar-pro-logo-inverted-2026.svg'); ?>" alt="ICS Calendar Pro" width="116" height="40" style="width: 116px; height: 40px;" /></span>
	<nav class="r34icspro-admin-header-nav"><ul>
		<li>
			<a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar')); ?>"<?php
				if (@$cs->post_type == 'r34icspro_calendar' && !in_array($request_page, array('r34icspro-illustrations-library', 'ics-calendar-pro-settings'))) { echo ' class="current"'; }
			?>><?php esc_html_e('Calendar Builder', 'ics-calendar-pro'); ?></a>
			<a href="<?php echo esc_url(admin_url('post-new.php?post_type=r34icspro_calendar')); ?>" title="<?php esc_attr_e('Add New Calendar', 'ics-calendar-pro'); ?>"><span class="dashicons dashicons-plus-alt"></span></a>
		</li>
		<?php
		if (get_option('r34icspro_enable_event_cpt')) {
			?>
			<li>
				<a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_event&page=ics-events-calendar-view')); ?>"<?php
					if (@$cs->post_type == 'r34icspro_event' || strpos($request_uri, 'ics-events-calendar-view') !== false) { echo ' class="current"'; }
				?>><?php esc_html_e('ICS Events', 'ics-calendar-pro'); ?></a>
				<a href="<?php echo esc_url(admin_url('post-new.php?post_type=r34icspro_event')); ?>" title="<?php esc_attr_e('Add New Event', 'ics-calendar-pro'); ?>"><span class="dashicons dashicons-plus-alt"></span></a>
			</li>
			<?php
		}
		?>
		<li><a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar&page=r34icspro-illustrations-library')); ?>"<?php
			if (strpos($request_uri, 'r34icspro-illustrations-library') !== false) { echo '  class="current"'; }
		?>><span class="dashicons dashicons-format-image" style="margin-right: 0.5rem;"></span><?php esc_html_e('Illustrations Library', 'ics-calendar-pro'); ?></a></li>
	</ul></nav>
	<nav class="r34icspro-admin-header-tools<?php
		if (strpos($request_uri, 'ics-calendar-pro-settings') !== false) {
			echo ' current';
		}
	?>"><ul>
		<li><a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar&page=ics-calendar-pro-settings#getting-started')); ?>" title="<?php esc_attr_e('Getting Started', 'ics-calendar-pro'); ?>" onclick="if (jQuery('a[href^=#getting-started]').length > 0) { jQuery('a[href^=#getting-started]').trigger('click'); return false; }"><span class="dashicons dashicons-sos"></span></a></li>
		<?php
		if (function_exists('r34ics_admin_full_access') && r34ics_admin_full_access()) {
			?>
			<li><a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar&page=ics-calendar-pro-settings#settings')); ?>" title="<?php esc_attr_e('Settings', 'ics-calendar-pro'); ?>" onclick="if (jQuery('a[href^=#settings]').length > 0) { jQuery('a[href^=#settings]').trigger('click'); return false; }"><span class="dashicons dashicons-admin-settings"></span></a></li>
			<?php
			?>
			<li><a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar&page=ics-calendar-pro-settings#appearance')); ?>" title="<?php esc_attr_e('Appearance', 'ics-calendar-pro'); ?>" onclick="if (jQuery('a[href^=#appearance]').length > 0) { jQuery('a[href^=#appearance]').trigger('click'); return false; }"><span class="dashicons dashicons-admin-appearance"></span></a></li>
			<?php
		}
		?>
		<li><a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar&page=ics-calendar-pro-settings#utilities')); ?>" title="<?php esc_attr_e('Utilities', 'ics-calendar-pro'); ?>" onclick="if (jQuery('a[href^=#utilities]').length > 0) { jQuery('a[href^=#utilities]').trigger('click'); return false; }"><span class="dashicons dashicons-admin-tools"></span></a></li>
		<?php
		if (function_exists('r34ics_admin_full_access') && r34ics_admin_full_access()) {
			?>
			<li><a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar&page=ics-calendar-pro-settings#system-report')); ?>" title="<?php esc_attr_e('System Report', 'ics-calendar-pro'); ?>" onclick="if (jQuery('a[href^=#system-report]').length > 0) { jQuery('a[href^=#system-report]').trigger('click'); return false; }"><span class="dashicons dashicons-clipboard"></span></a></li>
			<li><a href="<?php echo esc_url(admin_url('edit.php?post_type=r34icspro_calendar&page=ics-calendar-pro-settings#license')); ?>" title="<?php esc_attr_e('License', 'ics-calendar-pro'); ?>" onclick="if (jQuery('a[href^=#license]').length > 0) { jQuery('a[href^=#license]').trigger('click'); return false; }"><span class="dashicons dashicons-admin-network"></span></a></li>
			<?php
		}
		?>
		<li><a href="https://icscalendar.com/support/" target="_blank" title="<?php esc_attr_e('Support', 'ics-calendar-pro'); ?>"><span class="dashicons dashicons-email-alt"></span></a></li>
	</ul></nav>
</div>
<?php

// phpcs:enable