wpcf7_date_form_tag_handler()
Хуков нет.
Возвращает
null. Ничего (null).
Использование
wpcf7_date_form_tag_handler( $tag );
- $tag(обязательный)
- .
Код wpcf7_date_form_tag_handler() wpcf7 date form tag handler CF7 6.1.6
function wpcf7_date_form_tag_handler( $tag ) {
if ( empty( $tag->name ) ) {
return '';
}
$validation_error = wpcf7_get_validation_error( $tag->name );
$class = wpcf7_form_controls_class( $tag->type );
$class .= ' wpcf7-validates-as-date';
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
}
$atts = array();
$atts['class'] = $tag->get_class_option( $class );
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
$atts['min'] = $tag->get_date_option( 'min' );
$atts['max'] = $tag->get_date_option( 'max' );
$atts['step'] = $tag->get_option( 'step', 'int', true );
$atts['readonly'] = $tag->has_option( 'readonly' );
$atts['autocomplete'] = $tag->get_autocomplete_option();
if ( $tag->is_required() ) {
$atts['aria-required'] = 'true';
}
if ( $validation_error ) {
$atts['aria-invalid'] = 'true';
$atts['aria-describedby'] = wpcf7_get_validation_error_reference(
$tag->name
);
} else {
$atts['aria-invalid'] = 'false';
}
$value = (string) reset( $tag->values );
if ( $tag->has_option( 'placeholder' ) or $tag->has_option( 'watermark' ) ) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option( $value );
if ( $value ) {
$datetime_obj = date_create_immutable(
preg_replace( '/[_]+/', ' ', $value ),
wp_timezone()
);
if ( $datetime_obj ) {
$value = $datetime_obj->format( 'Y-m-d' );
}
}
$value = wpcf7_get_hangover( $tag->name, $value );
$atts['value'] = $value;
$atts['type'] = $tag->basetype;
$atts['name'] = $tag->name;
$html = sprintf(
'<span class="wpcf7-form-control-wrap" data-name="%1$s"><input %2$s />%3$s</span>',
esc_attr( $tag->name ),
wpcf7_format_atts( $atts ),
$validation_error
);
return $html;
}