<?php

namespace CarDealerPress\Templates\Admin\Theme\Navigation;

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

use CarDealerPress\includes\helpers\helpers as helpers;
use CarDealerPress\Templates\Admin as templates;
use CarDealerPress\templates\partials\admin\Display;

function list_nav(): string {
	// @codingStandardsIgnoreStart
	$safe = helpers::sanitize_get( $_GET );
	// @codingStandardsIgnoreEnd
	$section1 = $safe['section1'] ?? 'general';

	$content = '<div id="cdp-detail-wrapper" class="settings-wrapper display">';
	$content .= '<div class="wrap">';
	$content .= '<nav class="nav-tab-wrapper">';
	$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=general" class="nav-tab ' . ( 'general' === $section1 ? 'nav-tab-active' : '' ) . '">General</a>';
	$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=search_filters&section2=general" class="nav-tab ' . ( 'search_filters' === $section1 ? 'nav-tab-active' : '' ) . '">Search Filters</a>';
	$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=keywords" class="nav-tab ' . ( 'keywords' === $section1 ? 'nav-tab-active' : '' ) . '">Keywords</a>';
	$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=sort" class="nav-tab ' . ( 'sort' === $section1 ? 'nav-tab-active' : '' ) . '">Sort</a>';
	if ( Display::theme_check() ) {
		$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=extra_boxes" class="nav-tab ' . ( 'extra_boxes' === $section1 ? 'nav-tab-active' : '' ) . '">Extra Boxes</a>';
		$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=vehicle_attributes" class="nav-tab ' . ( 'vehicle_attributes' === $section1 ? 'nav-tab-active' : '' ) . '">Vehicle Attributes</a>';
	}
	$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=scripts" class="nav-tab ' . ( 'scripts' === $section1 ? 'nav-tab-active' : '' ) . '">Scripts</a>';
	$content .= '<a href="?page=cardealerpress_theme&tab=inventory_display&section=list&section1=styles" class="nav-tab ' . ( 'styles' === $section1 ? 'nav-tab-active' : '' ) . '">Styles</a>';

	$content .= '</nav>';
	$content .= '<div class="tab-content">';
	switch ( $section1 ) :
		case 'general':
			$content .= templates\Theme\Inventory_Display\List_Page\list_general();
			break;
		case 'search_filters':
			$content .= templates\Theme\Navigation\search_filters_nav();
			break;
		case 'keywords':
			$content .= templates\Theme\keywords();
			break;
		case 'sort':
			$content .= templates\Theme\Inventory_Display\List_Page\sort();
			break;
		case 'extra_boxes':
			$content .= templates\Theme\Inventory_Display\extra_boxes( array( 'location' => 'list' ) );
			break;
		case 'vehicle_attributes':
			$content .= templates\Theme\inventory_display\vehicle_attributes( array( 'page' => 'list' ) );
			break;
		case 'scripts':
			$content .= templates\Theme\injector_scripts_list();
			break;
		case 'styles':
			$content .= templates\Theme\injector_style( array( 'location' => 'list' ) );
			break;
	endswitch;
	$content .= '</div>';

	return $content;
}
