wpcf7_acceptance_form_tag_handler() CF7 1.0
Хуков нет.
Возвращает
Null. Ничего.
Использование
wpcf7_acceptance_form_tag_handler( $tag );
- $tag (обязательный)
- -
Код wpcf7_acceptance_form_tag_handler() wpcf7 acceptance form tag handler CF7 5.4
function wpcf7_acceptance_form_tag_handler( $tag ) {
if ( empty( $tag->name ) ) {
return '';
}
$validation_error = wpcf7_get_validation_error( $tag->name );
$class = wpcf7_form_controls_class( $tag->type );
if ( $validation_error ) {
$class .= ' wpcf7-not-valid';
}
if ( $tag->has_option( 'invert' ) ) {
$class .= ' invert';
}
if ( $tag->has_option( 'optional' ) ) {
$class .= ' optional';
}
$atts = array(
'class' => trim( $class ),
);
$item_atts = array();
$item_atts['type'] = 'checkbox';
$item_atts['name'] = $tag->name;
$item_atts['value'] = '1';
$item_atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
if ( $validation_error ) {
$item_atts['aria-invalid'] = 'true';
$item_atts['aria-describedby'] = wpcf7_get_validation_error_reference(
$tag->name
);
} else {
$item_atts['aria-invalid'] = 'false';
}
if ( $tag->has_option( 'default:on' ) ) {
$item_atts['checked'] = 'checked';
}
$item_atts['class'] = $tag->get_class_option();
$item_atts['id'] = $tag->get_id_option();
$item_atts = wpcf7_format_atts( $item_atts );
$content = empty( $tag->content )
? (string) reset( $tag->values )
: $tag->content;
$content = trim( $content );
if ( $content ) {
if ( $tag->has_option( 'label_first' ) ) {
$html = sprintf(
'<span class="wpcf7-list-item-label">%2$s</span><input %1$s />',
$item_atts, $content );
} else {
$html = sprintf(
'<input %1$s /><span class="wpcf7-list-item-label">%2$s</span>',
$item_atts, $content );
}
$html = sprintf(
'<span class="wpcf7-list-item"><label>%s</label></span>',
$html
);
} else {
$html = sprintf(
'<span class="wpcf7-list-item"><input %1$s /></span>',
$item_atts );
}
$atts = wpcf7_format_atts( $atts );
$html = sprintf(
'<span class="wpcf7-form-control-wrap %1$s"><span %2$s>%3$s</span>%4$s</span>',
sanitize_html_class( $tag->name ), $atts, $html, $validation_error );
return $html;
}