<?php
/**
 * Job Orderby Form Template
 *
 * Override this in your theme by copying it to /wp-content/themes/{yourtheme}/matador/parts/jobs-orderby.php.
 *
 * @link        https://matadorjobs.com/
 *
 * @since       3.9.0
 *
 * @package     Matador Jobs
 * @subpackage  Templates/Parts
 * @author      Matador Software LLC, Jeremy Scott, Paul Bearne
 * @copyright   (c) 2018-2024, Matador Software, LLC
 *
 * @license     https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
 */

use matador\Matador;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * (Possibly) Defined before include:
 *
 * @var array $class
 * @var array $options
 * @var string $default_value
 * @var string $selected_value
 */

?>

<div class="<?php matador_build_classes( $class ); ?>">

	<form role="complementary" method="get" class="matador-orderby-form">
		
		<label for="matador-jobs-orderby-select" aria-label="<?php echo esc_attr__( 'Order results by', 'matador-jobs' ); ?>">
			<?php if ( isset( $label_text ) ) : ?>
				<?php echo esc_html( $label_text ); ?>
			<?php else : ?>
				<?php echo esc_html__( 'Order results by', 'matador-jobs' ); ?>
			<?php endif; ?>
		</label>

		<select 
			name="matador-jobs-orderby-select"
			id="matador-jobs-orderby-select" 
			aria-label="<?php echo esc_attr__( 'Select an option to order the job results', 'matador-jobs' ); ?>"
			title="<?php echo esc_html_e( 'Select an option to order the job results', 'matador-jobs' ); ?>"
			>

			<?php foreach ( $options as $key => $mapping ) : ?>

				<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $selected_value, true ); ?>>
					<?php echo esc_html( $mapping['label'] ); ?>
				</option>

			<?php endforeach; ?>	

		</select>
				<?php // @todosam - use button classes here ?>
		<button id='re-order-submit' aria-label="Re-order the job results based on the selected option">
			<?php __( 'Re-order Jobs', 'matador-jobs' ); ?>
		</button>
		
	</form>

</div>
