<?php
/**
 * This template displaying timepicker field addon item.
 * This template can be overridden by copying it to yourtheme/eopfw-templates/epofw-timepicker.php
 * NOTE, on occasion Extra Product Options for WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @package Extra_Product_Options_For_WooCommerce/Templates
 * @version 2.5
 */

defined( 'ABSPATH' ) || exit;

$epofw_args               = array();
$epofw_field_type         = isset( $args['epofwtwp_args']['attr_data']['type'] ) ? $args['epofwtwp_args']['attr_data']['type'] : 'timepicker';
$epofw_sanitize_attr_data = array(
	'input' => array(
		'data-default' => true, // For repeater field support.
	),
);
if ( ! empty( $args['epofwtwp_args']['attr_data'] ) ) {
	foreach ( $args['epofwtwp_args']['attr_data'] as $epofw_attr_name => $epofw_attr_value ) {
		$epofw_sanitize_attr_data['input'][ $epofw_attr_name ] = true;
		if ( 'name' === $epofw_attr_name ) {
			if ( strpos( $epofw_attr_value, 'epofw_field_' ) === false ) {
				$epofw_attr_value = 'epofw_field_' . $epofw_attr_value;
			}
			/**
			 * Apply filters for timepicker name field property.
			 *
			 * @since 2.5
			 */
			$epofw_args['name'] = apply_filters( 'epofw_field_property_' . $epofw_field_type . '_' . $epofw_attr_name, $epofw_attr_value . '[value]', $args );
		} elseif ( 'type' === $epofw_attr_name ) {
			/**
			 * Apply filters for timepicker type field property.
			 *
			 * @since 2.5
			 */
			$epofw_args[ $epofw_attr_name ] = apply_filters( 'epofw_field_property_' . $epofw_field_type . '_' . $epofw_attr_name, 'text', $args );
		} elseif ( 'class' === $epofw_attr_name ) {
			$epofw_attr_value = $epofw_attr_value . ' epofw_dft_' . $epofw_field_type;
			/**
			 * Apply filters for timepicker css field property.
			 *
			 * @since 2.5
			 */
			$epofw_args[ $epofw_attr_name ] = apply_filters( 'epofw_field_property_' . $epofw_field_type . '_' . $epofw_attr_name, $epofw_attr_value, $args );
		} elseif ( ! empty( $epofw_attr_value ) ) {
			/**
			 * Apply filters for timepicker field property.
			 *
			 * @since 2.5
			 */
			$epofw_args[ $epofw_attr_name ] = apply_filters( 'epofw_field_property_' . $epofw_field_type . '_' . $epofw_attr_name, $epofw_attr_value, $args );
		}
	}
}
$epofw_html = '';
if ( ! empty( $epofw_args ) ) {
	$epofw_html .= '<input ';
	foreach ( $epofw_args as $epofw_attr_name => $epofw_attr_value ) {
		if ( ! isset( $epofw_sanitize_attr_data['input'][ $epofw_attr_name ] ) ) {
			continue;
		}

		$epofw_html .= ' ' . sanitize_key( $epofw_attr_name ) . EPOFW_EQUAL . '"' . esc_attr( sanitize_text_field( $epofw_attr_value ) ) . '"';
	}
	$epofw_html .= '/>';
}
/**
 * Fire action before timepicker addon field.
 *
 * @since 2.5
 */
do_action( 'epofw_before_addon_field_' . $epofw_field_type );
echo wp_kses( $epofw_html, $epofw_sanitize_attr_data );
/**
 * Fire action after timepicker addon field.
 *
 * @since 2.5
 */
do_action( 'epofw_after_addon_field_' . $epofw_field_type );
