<?php
/**
 * Admin partial: the plugin's own navigation bar.
 *
 * WordPress already lists these screens down the left, and that list stays —
 * this does not replace it. It sits on top of every BitForgeNet Guest Tickets page so the whole
 * plugin can be walked sideways without going back to the sidebar, which is what
 * you actually want while working: confirm a payment, look at the tickets it
 * issued, open the door station, all without leaving the page you are reading.
 *
 * The bar is a row of ordinary links. There is no JavaScript, no state to get
 * out of step, and a screen a user's role cannot open is simply not drawn.
 *
 * @package BitForgeNet_Guest_Tickets
 */

defined( 'ABSPATH' ) || exit;

// This file is a template: it is included from a method -- never at file
// scope -- so everything declared here belongs to that method's variable
// scope and not to the global one. PHPCS reads each file on its own and has
// no way to see where the include happens, so it reads these as globals.
// Stated once, for the whole file, per this plugin's suppression rule.
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

$bfnet_sections = array(
	array( 'bitforgenet-guest-tickets', __( 'Dashboard', 'bitforgenet-guest-tickets' ), __( 'Revenue, pipeline and what is coming up.', 'bitforgenet-guest-tickets' ), 'dashboard', 'bfnet_view_reports' ),
	array( 'bitforgenet-guest-tickets-events', __( 'Events', 'bitforgenet-guest-tickets' ), __( 'Create an event, set its prices, open and close registration.', 'bitforgenet-guest-tickets' ), 'calendar-alt', 'bfnet_manage_events' ),
	array( 'bitforgenet-guest-tickets-orders', __( 'Subscribers', 'bitforgenet-guest-tickets' ), __( 'Every booking. Confirm a payment and the tickets go out.', 'bitforgenet-guest-tickets' ), 'groups', 'bfnet_manage_orders' ),
	array( 'bitforgenet-guest-tickets-tickets', __( 'Tickets', 'bitforgenet-guest-tickets' ), __( 'Issued tickets, who holds them, and who has walked in.', 'bitforgenet-guest-tickets' ), 'tickets-alt', 'bfnet_manage_tickets' ),
	array( 'bitforgenet-guest-tickets-scanner', __( 'Door', 'bitforgenet-guest-tickets' ), __( 'Open a station, issue the door code, print the paper list.', 'bitforgenet-guest-tickets' ), 'visibility', 'bfnet_scan_tickets' ),
	array( 'bitforgenet-guest-tickets-templates', __( 'Designs', 'bitforgenet-guest-tickets' ), __( 'The artwork the QR code is printed on.', 'bitforgenet-guest-tickets' ), 'art', 'bfnet_manage_templates' ),
	array( 'bitforgenet-guest-tickets-venues', __( 'Venues', 'bitforgenet-guest-tickets' ), __( 'Rooms, addresses and the map link guests follow.', 'bitforgenet-guest-tickets' ), 'location', 'bfnet_manage_events' ),
	array( 'bitforgenet-guest-tickets-organizers', __( 'Organizers', 'bitforgenet-guest-tickets' ), __( 'Who is presenting the night, and under whose colours.', 'bitforgenet-guest-tickets' ), 'businessman', 'bfnet_manage_events' ),
	array( 'bitforgenet-guest-tickets-settings', __( 'Settings', 'bitforgenet-guest-tickets' ), __( 'Branding, money, email, the form, the door.', 'bitforgenet-guest-tickets' ), 'admin-generic', 'bfnet_manage_settings' ),
	array( 'bitforgenet-guest-tickets-tools', __( 'Tools & data', 'bitforgenet-guest-tickets' ), __( 'Exports, archiving and the database repair.', 'bitforgenet-guest-tickets' ), 'database', 'bfnet_manage_settings' ),
	array( 'bitforgenet-guest-tickets-logs', __( 'Activity', 'bitforgenet-guest-tickets' ), __( 'Who changed what, and when.', 'bitforgenet-guest-tickets' ), 'list-view', 'bfnet_manage_settings' ),
);

// phpcs:ignore WordPress.Security.NonceVerification -- reading which screen we are on.
$bfnet_here = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : 'bitforgenet-guest-tickets';
?>
<nav class="bfnet-sections" aria-label="<?php esc_attr_e( 'BitForgeNet Guest Tickets sections', 'bitforgenet-guest-tickets' ); ?>">
	<?php foreach ( $bfnet_sections as $bfnet_section ) : ?>
		<?php if ( BFNET_Security::can( $bfnet_section[4] ) ) : ?>
			<a class="bfnet-sections__link <?php echo $bfnet_here === $bfnet_section[0] ? 'is-here' : ''; ?>"
				href="<?php echo esc_url( BFNET_Util::admin_url( $bfnet_section[0] ) ); ?>"
				title="<?php echo esc_attr( $bfnet_section[2] ); ?>"
				<?php echo $bfnet_here === $bfnet_section[0] ? 'aria-current="page"' : ''; ?>>
				<span class="dashicons dashicons-<?php echo esc_attr( $bfnet_section[3] ); ?>" aria-hidden="true"></span>
				<span><?php echo esc_html( $bfnet_section[1] ); ?></span>
			</a>
		<?php endif; ?>
	<?php endforeach; ?>
</nav>
