<?php
/**
 * App sidebar navigation.
 *
 * @package Lucrativeit_Subscription_Recurring_Billing
 *
 * @var string $active  Active module key.
 * @var array  $modules Module map.
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Included template; variables are local to the including scope.

$icons = array(
	'grid'      => '&#9638;',
	'users'     => '&#128101;',
	'pin'       => '&#128205;',
	'card'      => '&#128179;',
	'tag'       => '&#127991;',
	'folder'    => '&#128193;',
	'invoice'   => '&#129534;',
	'briefcase' => '&#128188;',
	'shield'    => '&#128737;',
	'gear'      => '&#9881;',
	'chart'     => '&#128202;',
);

?>
<aside class="lucrsure-sidebar">
	<div class="lucrsure-brand">
		<div class="lucrsure-brand-mark">&#128179;</div>
		<div class="lucrsure-brand-text">
			<strong><?php echo esc_html( lucrsure_plugin_menu_label() ); ?></strong>
			<span><?php esc_html_e( 'for WordPress', 'lucrativeit-subscription-recurring-billing' ); ?></span>
		</div>
	</div>

	<nav class="lucrsure-nav">
		<?php
		foreach ( $modules as $nav_key => $nav_module ) {
			if ( empty( $nav_module['menu'] ) ) {
				continue;
			}
			$is_active = ( $active === $nav_key || ( 'dashboard' !== $nav_key && 0 === strpos( (string) $active, $nav_key ) ) );
			$icon      = isset( $icons[ $nav_module['icon'] ] ) ? $icons[ $nav_module['icon'] ] : '&#8226;';
			printf(
				'<a class="lucrsure-nav-item%s" href="%s"><span class="lucrsure-nav-icon">%s</span><span>%s</span></a>',
				$is_active ? ' is-active' : '',
				esc_url( lucrsure_admin_url( $nav_key ) ),
				wp_kses( $icon, array() ),
				esc_html( $nav_module['label'] )
			);
		}
		?>
		<div class="lucrsure-nav-cta">
			<a
				class="lucrsure-sidebar-cta"
				href="<?php echo esc_url( lucrsure_admin_nonce_url( 'subscriptions', array( 'action' => 'new' ) ) ); ?>"
				aria-label="<?php esc_attr_e( 'New Subscription', 'lucrativeit-subscription-recurring-billing' ); ?>"
			>
				<span class="lucrsure-sidebar-cta-icon" aria-hidden="true">+</span>
				<span><?php esc_html_e( 'New Subscription', 'lucrativeit-subscription-recurring-billing' ); ?></span>
			</a>
		</div>
	</nav>
</aside>
