<?php
/**
 * Template: Jobs Search Form Submit Button Block
 *
 * @link        https://matadorjobs.com/
 * @since       3.9.0
 *
 * @package     Matador Jobs
 * @subpackage  Blocks
 * @author      Matador Software LLC, Jeremy Scott, Paul Bearne
 * @copyright   (c) 2018-2025, Matador Software, LLC
 *
 * @license     https://opensource.org/licenses/GPL-3.0 GNU General Public License version 3
 */

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

use matador\MatadorJobs\Editors\Blocks\Blocks;

/**
 * @var array  $attributes - associative array of block attributes
 * @var WP_Block  $block - all the block settings and attributes
 */

$css_var_mappings = [
	'matador-jobs/searchFieldInputsPadding' => [
		'top'    => '--matador-search-input-padding-top',
		'bottom' => '--matador-search-input-padding-bottom',
		'left'   => '--matador-search-input-padding-left',
		'right'  => '--matador-search-input-padding-right',
	],
	'matador-jobs/searchFieldInputsMargin' => [
		'top'    => '--matador-search-input-margin-top',
		'bottom' => '--matador-search-input-margin-bottom',
		'left'   => '--matador-search-input-margin-left',
		'right'  => '--matador-search-input-margin-right',
	],
];

$style = Blocks::generate_css_variables( $css_var_mappings, $block );

/**
 * Action: Matador Search From Before Submit
 *
 * Fires after opening markup and before the form for the [matador_search] shortcode and matador_search()
 * function.
 *
 * @since 3.3.0
 */
do_action( 'matador_search_form_before_submit' );

/**
 * Action: Matador Search Submit Button Class
 *
 * Filters the class attribute of the submit button for the Matador Search form.
 *
 * @since 3.3.0
 * @deprecated 3.6.0 please use matador_template_button_classes with context 'primary'
 *
 * @param string $class
 *
 * @return string
 */
$button_class = apply_filters( 'matador_search_form_submit_button_class', 'matador-search-submit' );
?>
<div <?php echo get_block_wrapper_attributes( [ 'class' => 'matador-search-form-field-group matador-search-form-field-submit', 'style' => $style ] ); ?>>

	<button type="submit" id="matador-search-submit" class="<?php matador_button_classes( [ $button_class, 'matador-button wp-element-button' ] ); ?>">
		<?php
		/**
		 * Filter: Matador Search From Submit Label
		 *
		 * Modifies the text of the Submit button
		 *
		 * @since 3.3.0
		 */
		echo wp_kses_post( apply_filters( 'matador_search_form_submit_label', $attributes['buttonText'] ) );
		?>
	</button>

</div>
