<?php
/**
 * CPT Builder - section navigation (Post Types | Taxonomies).
 *
 * @package CptBuilder
 *
 * @var string $current_section Active section ('' for post types, 'taxonomies').
 */

namespace CptBuilder;

use WP_PowerSuite\Core\NetworkScope;

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

$current_section = isset( $current_section ) ? (string) $current_section : '';

$sections = [
	''           => [
		'label' => __( 'Post Types', 'wp-powersuite' ),
		'icon'  => 'dashicons-screenoptions',
		'url'   => NetworkScope::adminUrl( 'admin.php', [ 'page' => Admin::PAGE_SLUG ] ),
	],
	'taxonomies' => [
		'label' => __( 'Taxonomies', 'wp-powersuite' ),
		'icon'  => 'dashicons-category',
		'url'   => NetworkScope::adminUrl( 'admin.php', [ 'page' => Admin::PAGE_SLUG, 'section' => 'taxonomies' ] ),
	],
];
?>
<nav class="cptb-section-nav" aria-label="<?php esc_attr_e( 'Builder sections', 'wp-powersuite' ); ?>">
	<?php foreach ( $sections as $section_id => $section ) : ?>
		<a
			href="<?php echo esc_url( $section['url'] ); ?>"
			class="cptb-section-nav__item<?php echo $current_section === $section_id ? ' is-active' : ''; ?>"
			<?php echo $current_section === $section_id ? 'aria-current="page"' : ''; ?>
		>
			<span class="dashicons <?php echo esc_attr( $section['icon'] ); ?>" aria-hidden="true"></span>
			<?php echo esc_html( $section['label'] ); ?>
		</a>
	<?php endforeach; ?>
</nav>
<?php
