Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/wpforms-.../includes/fields
File: class-checkbox.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Checkbox field.
[7] Fix | Delete
*
[8] Fix | Delete
* @since 1.0.0
[9] Fix | Delete
*/
[10] Fix | Delete
class WPForms_Field_Checkbox extends WPForms_Field {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Primary class constructor.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 1.0.0
[16] Fix | Delete
*/
[17] Fix | Delete
public function init() {
[18] Fix | Delete
[19] Fix | Delete
// Define field type information.
[20] Fix | Delete
$this->name = esc_html__( 'Checkboxes', 'wpforms-lite' );
[21] Fix | Delete
$this->keywords = esc_html__( 'choice', 'wpforms-lite' );
[22] Fix | Delete
$this->type = 'checkbox';
[23] Fix | Delete
$this->icon = 'fa-check-square-o';
[24] Fix | Delete
$this->order = 110;
[25] Fix | Delete
$this->defaults = [
[26] Fix | Delete
1 => [
[27] Fix | Delete
'label' => esc_html__( 'First Choice', 'wpforms-lite' ),
[28] Fix | Delete
'value' => '',
[29] Fix | Delete
'image' => '',
[30] Fix | Delete
'icon' => '',
[31] Fix | Delete
'icon_style' => '',
[32] Fix | Delete
'default' => '',
[33] Fix | Delete
],
[34] Fix | Delete
2 => [
[35] Fix | Delete
'label' => esc_html__( 'Second Choice', 'wpforms-lite' ),
[36] Fix | Delete
'value' => '',
[37] Fix | Delete
'image' => '',
[38] Fix | Delete
'icon' => '',
[39] Fix | Delete
'icon_style' => '',
[40] Fix | Delete
'default' => '',
[41] Fix | Delete
],
[42] Fix | Delete
3 => [
[43] Fix | Delete
'label' => esc_html__( 'Third Choice', 'wpforms-lite' ),
[44] Fix | Delete
'value' => '',
[45] Fix | Delete
'image' => '',
[46] Fix | Delete
'icon' => '',
[47] Fix | Delete
'icon_style' => '',
[48] Fix | Delete
'default' => '',
[49] Fix | Delete
],
[50] Fix | Delete
];
[51] Fix | Delete
[52] Fix | Delete
$this->default_settings = [
[53] Fix | Delete
'choices' => $this->defaults,
[54] Fix | Delete
];
[55] Fix | Delete
[56] Fix | Delete
$this->hooks();
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Hooks.
[61] Fix | Delete
*
[62] Fix | Delete
* @since 1.8.1
[63] Fix | Delete
*/
[64] Fix | Delete
private function hooks() {
[65] Fix | Delete
[66] Fix | Delete
// Customize HTML field values.
[67] Fix | Delete
add_filter( 'wpforms_html_field_value', [ $this, 'field_html_value' ], 10, 4 );
[68] Fix | Delete
[69] Fix | Delete
// Define additional field properties.
[70] Fix | Delete
add_filter( 'wpforms_field_properties_checkbox', [ $this, 'field_properties' ], 5, 3 );
[71] Fix | Delete
[72] Fix | Delete
// This field requires fieldset+legend instead of the field label.
[73] Fix | Delete
add_filter( "wpforms_frontend_modern_is_field_requires_fieldset_{$this->type}", '__return_true', PHP_INT_MAX, 2 );
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Define additional field properties.
[78] Fix | Delete
*
[79] Fix | Delete
* @since 1.4.5
[80] Fix | Delete
*
[81] Fix | Delete
* @param array $properties Field properties.
[82] Fix | Delete
* @param array $field Field settings.
[83] Fix | Delete
* @param array $form_data Form data and settings.
[84] Fix | Delete
*
[85] Fix | Delete
* @return array
[86] Fix | Delete
*/
[87] Fix | Delete
public function field_properties( $properties, $field, $form_data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.MaxExceeded
[88] Fix | Delete
[89] Fix | Delete
// Define data.
[90] Fix | Delete
$form_id = absint( $form_data['id'] );
[91] Fix | Delete
$field_id = wpforms_validate_field_id( $field['id'] );
[92] Fix | Delete
$choices = $field['choices'];
[93] Fix | Delete
$dynamic = wpforms_get_field_dynamic_choices( $field, $form_id, $form_data );
[94] Fix | Delete
[95] Fix | Delete
if ( $dynamic !== false ) {
[96] Fix | Delete
$choices = $dynamic;
[97] Fix | Delete
$field['show_values'] = true;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
// Remove primary input, unset for attribute for label.
[101] Fix | Delete
unset( $properties['inputs']['primary'], $properties['label']['attr']['for'] );
[102] Fix | Delete
[103] Fix | Delete
// Set input container (ul) properties.
[104] Fix | Delete
$properties['input_container'] = [
[105] Fix | Delete
'class' => [ ! empty( $field['random'] ) ? 'wpforms-randomize' : '' ],
[106] Fix | Delete
'data' => [],
[107] Fix | Delete
'attr' => [],
[108] Fix | Delete
'id' => "wpforms-{$form_id}-field_{$field_id}",
[109] Fix | Delete
];
[110] Fix | Delete
[111] Fix | Delete
$is_choice_limit_set = ! empty( $field['choice_limit'] ) && (int) $field['choice_limit'] > 0;
[112] Fix | Delete
[113] Fix | Delete
if ( $is_choice_limit_set ) {
[114] Fix | Delete
$properties['input_container']['data']['choice-limit'] = $field['choice_limit'];
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
// Set input properties.
[118] Fix | Delete
foreach ( $choices as $key => $choice ) {
[119] Fix | Delete
[120] Fix | Delete
// Used for dynamic choices.
[121] Fix | Delete
$depth = isset( $choice['depth'] ) ? absint( $choice['depth'] ) : 1;
[122] Fix | Delete
$label = isset( $choice['label'] ) ? $choice['label'] : '';
[123] Fix | Delete
[124] Fix | Delete
// Choice labels should not be left blank, but if they are we
[125] Fix | Delete
// provide a basic value.
[126] Fix | Delete
$value = isset( $field['show_values'] ) ? $choice['value'] : $label;
[127] Fix | Delete
[128] Fix | Delete
if ( '' === $value ) {
[129] Fix | Delete
if ( 1 === count( $choices ) ) {
[130] Fix | Delete
$value = esc_html__( 'Checked', 'wpforms-lite' );
[131] Fix | Delete
} else {
[132] Fix | Delete
/* translators: %s - choice number. */
[133] Fix | Delete
$value = sprintf( esc_html__( 'Choice %s', 'wpforms-lite' ), $key );
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
$properties['inputs'][ $key ] = [
[138] Fix | Delete
'container' => [
[139] Fix | Delete
'attr' => [],
[140] Fix | Delete
'class' => [ "choice-{$key}", "depth-{$depth}" ],
[141] Fix | Delete
'data' => [],
[142] Fix | Delete
'id' => '',
[143] Fix | Delete
],
[144] Fix | Delete
'label' => [
[145] Fix | Delete
'attr' => [
[146] Fix | Delete
'for' => "wpforms-{$form_id}-field_{$field_id}_{$key}",
[147] Fix | Delete
],
[148] Fix | Delete
'class' => [ 'wpforms-field-label-inline' ],
[149] Fix | Delete
'data' => [],
[150] Fix | Delete
'id' => '',
[151] Fix | Delete
'text' => $label,
[152] Fix | Delete
],
[153] Fix | Delete
'attr' => [
[154] Fix | Delete
'name' => "wpforms[fields][{$field_id}][]",
[155] Fix | Delete
'value' => $value,
[156] Fix | Delete
],
[157] Fix | Delete
'class' => [],
[158] Fix | Delete
'data' => [],
[159] Fix | Delete
'id' => "wpforms-{$form_id}-field_{$field_id}_{$key}",
[160] Fix | Delete
'icon' => isset( $choice['icon'] ) ? $choice['icon'] : '',
[161] Fix | Delete
'icon_style' => isset( $choice['icon_style'] ) ? $choice['icon_style'] : '',
[162] Fix | Delete
'image' => isset( $choice['image'] ) ? $choice['image'] : '',
[163] Fix | Delete
'required' => ! empty( $field['required'] ) ? 'required' : '',
[164] Fix | Delete
'default' => isset( $choice['default'] ),
[165] Fix | Delete
];
[166] Fix | Delete
[167] Fix | Delete
// Rule for validator only if needed.
[168] Fix | Delete
if ( $is_choice_limit_set ) {
[169] Fix | Delete
$properties['inputs'][ $key ]['data']['rule-check-limit'] = 'true';
[170] Fix | Delete
}
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
// Required class for pagebreak validation.
[174] Fix | Delete
if ( ! empty( $field['required'] ) ) {
[175] Fix | Delete
$properties['input_container']['class'][] = 'wpforms-field-required';
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
// Custom properties if image choices is enabled.
[179] Fix | Delete
if ( ! $dynamic && ! empty( $field['choices_images'] ) ) {
[180] Fix | Delete
[181] Fix | Delete
$properties['input_container']['class'][] = 'wpforms-image-choices';
[182] Fix | Delete
$properties['input_container']['class'][] = 'wpforms-image-choices-' . sanitize_html_class( $field['choices_images_style'] );
[183] Fix | Delete
[184] Fix | Delete
foreach ( $properties['inputs'] as $key => $inputs ) {
[185] Fix | Delete
$properties['inputs'][ $key ]['container']['class'][] = 'wpforms-image-choices-item';
[186] Fix | Delete
[187] Fix | Delete
if ( in_array( $field['choices_images_style'], [ 'modern', 'classic' ], true ) ) {
[188] Fix | Delete
$properties['inputs'][ $key ]['class'][] = 'wpforms-screen-reader-element';
[189] Fix | Delete
}
[190] Fix | Delete
}
[191] Fix | Delete
} elseif ( ! $dynamic && ! empty( $field['choices_icons'] ) ) {
[192] Fix | Delete
$properties = wpforms()->obj( 'icon_choices' )->field_properties( $properties, $field );
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
// Custom properties for disclaimer format display.
[196] Fix | Delete
if ( ! empty( $field['disclaimer_format'] ) ) {
[197] Fix | Delete
[198] Fix | Delete
$properties['description']['class'][] = 'wpforms-disclaimer-description';
[199] Fix | Delete
$properties['description']['value'] = nl2br( $properties['description']['value'] );
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
// Add selected class for choices with defaults.
[203] Fix | Delete
foreach ( $properties['inputs'] as $key => $inputs ) {
[204] Fix | Delete
if ( ! empty( $inputs['default'] ) ) {
[205] Fix | Delete
$properties['inputs'][ $key ]['container']['class'][] = 'wpforms-selected';
[206] Fix | Delete
}
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
return $properties;
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Field options panel inside the builder.
[214] Fix | Delete
*
[215] Fix | Delete
* @since 1.0.0
[216] Fix | Delete
*
[217] Fix | Delete
* @param array $field Field settings.
[218] Fix | Delete
*/
[219] Fix | Delete
public function field_options( $field ) {
[220] Fix | Delete
/*
[221] Fix | Delete
* Basic field options.
[222] Fix | Delete
*/
[223] Fix | Delete
[224] Fix | Delete
// Options open markup.
[225] Fix | Delete
$this->field_option(
[226] Fix | Delete
'basic-options',
[227] Fix | Delete
$field,
[228] Fix | Delete
[
[229] Fix | Delete
'markup' => 'open',
[230] Fix | Delete
]
[231] Fix | Delete
);
[232] Fix | Delete
[233] Fix | Delete
// Label.
[234] Fix | Delete
$this->field_option( 'label', $field );
[235] Fix | Delete
[236] Fix | Delete
// Choices.
[237] Fix | Delete
$this->field_option( 'choices', $field );
[238] Fix | Delete
[239] Fix | Delete
// AI Feature.
[240] Fix | Delete
$this->field_option(
[241] Fix | Delete
'ai_modal_button',
[242] Fix | Delete
$field,
[243] Fix | Delete
[
[244] Fix | Delete
'value' => esc_html__( 'Generate Choices', 'wpforms-lite' ),
[245] Fix | Delete
'type' => 'choices',
[246] Fix | Delete
]
[247] Fix | Delete
);
[248] Fix | Delete
[249] Fix | Delete
// Choices Images.
[250] Fix | Delete
$this->field_option( 'choices_images', $field );
[251] Fix | Delete
[252] Fix | Delete
// Choices Images Style (theme).
[253] Fix | Delete
$this->field_option( 'choices_images_style', $field );
[254] Fix | Delete
[255] Fix | Delete
// Choices Icons.
[256] Fix | Delete
$this->field_option( 'choices_icons', $field );
[257] Fix | Delete
[258] Fix | Delete
// Choices Icons Color.
[259] Fix | Delete
$this->field_option( 'choices_icons_color', $field );
[260] Fix | Delete
[261] Fix | Delete
// Choices Icons Size.
[262] Fix | Delete
$this->field_option( 'choices_icons_size', $field );
[263] Fix | Delete
[264] Fix | Delete
// Choices Icons Style.
[265] Fix | Delete
$this->field_option( 'choices_icons_style', $field );
[266] Fix | Delete
[267] Fix | Delete
// Description.
[268] Fix | Delete
$this->field_option( 'description', $field );
[269] Fix | Delete
[270] Fix | Delete
// Required toggle.
[271] Fix | Delete
$this->field_option( 'required', $field );
[272] Fix | Delete
[273] Fix | Delete
// Options close markup.
[274] Fix | Delete
$this->field_option(
[275] Fix | Delete
'basic-options',
[276] Fix | Delete
$field,
[277] Fix | Delete
[
[278] Fix | Delete
'markup' => 'close',
[279] Fix | Delete
]
[280] Fix | Delete
);
[281] Fix | Delete
[282] Fix | Delete
/*
[283] Fix | Delete
* Advanced field options
[284] Fix | Delete
*/
[285] Fix | Delete
[286] Fix | Delete
// Options open markup.
[287] Fix | Delete
$this->field_option(
[288] Fix | Delete
'advanced-options',
[289] Fix | Delete
$field,
[290] Fix | Delete
[
[291] Fix | Delete
'markup' => 'open',
[292] Fix | Delete
]
[293] Fix | Delete
);
[294] Fix | Delete
[295] Fix | Delete
// Randomize order of choices.
[296] Fix | Delete
$this->field_element(
[297] Fix | Delete
'row',
[298] Fix | Delete
$field,
[299] Fix | Delete
[
[300] Fix | Delete
'slug' => 'random',
[301] Fix | Delete
'content' => $this->field_element(
[302] Fix | Delete
'toggle',
[303] Fix | Delete
$field,
[304] Fix | Delete
[
[305] Fix | Delete
'slug' => 'random',
[306] Fix | Delete
'value' => isset( $field['random'] ) ? '1' : '0',
[307] Fix | Delete
'desc' => esc_html__( 'Randomize Choices', 'wpforms-lite' ),
[308] Fix | Delete
'tooltip' => esc_html__( 'Check this option to randomize the order of the choices.', 'wpforms-lite' ),
[309] Fix | Delete
],
[310] Fix | Delete
false
[311] Fix | Delete
),
[312] Fix | Delete
]
[313] Fix | Delete
);
[314] Fix | Delete
[315] Fix | Delete
// Show Values toggle option. This option will only show if already used
[316] Fix | Delete
// or if manually enabled by a filter.
[317] Fix | Delete
if ( ! empty( $field['show_values'] ) || wpforms_show_fields_options_setting() ) {
[318] Fix | Delete
$this->field_element(
[319] Fix | Delete
'row',
[320] Fix | Delete
$field,
[321] Fix | Delete
[
[322] Fix | Delete
'slug' => 'show_values',
[323] Fix | Delete
'content' => $this->field_element(
[324] Fix | Delete
'toggle',
[325] Fix | Delete
$field,
[326] Fix | Delete
[
[327] Fix | Delete
'slug' => 'show_values',
[328] Fix | Delete
'value' => isset( $field['show_values'] ) ? $field['show_values'] : '0',
[329] Fix | Delete
'desc' => esc_html__( 'Show Values', 'wpforms-lite' ),
[330] Fix | Delete
'tooltip' => esc_html__( 'Check this option to manually set form field values.', 'wpforms-lite' ),
[331] Fix | Delete
],
[332] Fix | Delete
false
[333] Fix | Delete
),
[334] Fix | Delete
]
[335] Fix | Delete
);
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
// Display format.
[339] Fix | Delete
$this->field_option( 'input_columns', $field );
[340] Fix | Delete
[341] Fix | Delete
// Choice Limit.
[342] Fix | Delete
$this->field_option( 'choice_limit', $field );
[343] Fix | Delete
[344] Fix | Delete
// Dynamic choice auto-populating toggle.
[345] Fix | Delete
$this->field_option( 'dynamic_choices', $field );
[346] Fix | Delete
[347] Fix | Delete
// Dynamic choice source.
[348] Fix | Delete
$this->field_option( 'dynamic_choices_source', $field );
[349] Fix | Delete
[350] Fix | Delete
// Custom CSS classes.
[351] Fix | Delete
$this->field_option( 'css', $field );
[352] Fix | Delete
[353] Fix | Delete
// Hide label.
[354] Fix | Delete
$this->field_option( 'label_hide', $field );
[355] Fix | Delete
[356] Fix | Delete
// Enable Disclaimer formatting.
[357] Fix | Delete
$this->field_element(
[358] Fix | Delete
'row',
[359] Fix | Delete
$field,
[360] Fix | Delete
[
[361] Fix | Delete
'slug' => 'disclaimer_format',
[362] Fix | Delete
'content' => $this->field_element(
[363] Fix | Delete
'toggle',
[364] Fix | Delete
$field,
[365] Fix | Delete
[
[366] Fix | Delete
'slug' => 'disclaimer_format',
[367] Fix | Delete
'value' => isset( $field['disclaimer_format'] ) ? '1' : '0',
[368] Fix | Delete
'desc' => esc_html__( 'Enable Disclaimer / Terms of Service Display', 'wpforms-lite' ),
[369] Fix | Delete
'tooltip' => esc_html__( 'Check this option to adjust the field styling to support Disclaimers and Terms of Service type agreements.', 'wpforms-lite' ),
[370] Fix | Delete
],
[371] Fix | Delete
false
[372] Fix | Delete
),
[373] Fix | Delete
]
[374] Fix | Delete
);
[375] Fix | Delete
[376] Fix | Delete
// Options close markup.
[377] Fix | Delete
$this->field_option(
[378] Fix | Delete
'advanced-options',
[379] Fix | Delete
$field,
[380] Fix | Delete
[
[381] Fix | Delete
'markup' => 'close',
[382] Fix | Delete
]
[383] Fix | Delete
);
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
/**
[387] Fix | Delete
* Field preview inside the builder.
[388] Fix | Delete
*
[389] Fix | Delete
* @since 1.0.0
[390] Fix | Delete
*
[391] Fix | Delete
* @param array $field Field settings.
[392] Fix | Delete
*/
[393] Fix | Delete
public function field_preview( $field ) {
[394] Fix | Delete
[395] Fix | Delete
// Label.
[396] Fix | Delete
$this->field_preview_option( 'label', $field );
[397] Fix | Delete
[398] Fix | Delete
// Choices.
[399] Fix | Delete
$this->field_preview_option( 'choices', $field );
[400] Fix | Delete
[401] Fix | Delete
// Description.
[402] Fix | Delete
$this->field_preview_option(
[403] Fix | Delete
'description',
[404] Fix | Delete
$field,
[405] Fix | Delete
[
[406] Fix | Delete
'class' => ! empty( $field['disclaimer_format'] ) ? 'disclaimer nl2br' : false,
[407] Fix | Delete
]
[408] Fix | Delete
);
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
/**
[412] Fix | Delete
* Field display on the form front-end and admin entry edit page.
[413] Fix | Delete
*
[414] Fix | Delete
* @since 1.0.0
[415] Fix | Delete
*
[416] Fix | Delete
* @param array $field Field settings.
[417] Fix | Delete
* @param array $deprecated Deprecated array.
[418] Fix | Delete
* @param array $form_data Form data and settings.
[419] Fix | Delete
*/
[420] Fix | Delete
public function field_display( $field, $deprecated, $form_data ) {
[421] Fix | Delete
[422] Fix | Delete
$using_image_choices = empty( $field['dynamic_choices'] ) && ! empty( $field['choices_images'] );
[423] Fix | Delete
$using_icon_choices = empty( $field['dynamic_choices'] ) && empty( $field['choices_images'] ) && ! empty( $field['choices_icons'] );
[424] Fix | Delete
[425] Fix | Delete
// Define data.
[426] Fix | Delete
$container = $field['properties']['input_container'];
[427] Fix | Delete
$choices = $field['properties']['inputs'];
[428] Fix | Delete
[429] Fix | Delete
// Do not display the field with empty choices on the frontend.
[430] Fix | Delete
if ( ! $choices && ! is_admin() ) {
[431] Fix | Delete
return;
[432] Fix | Delete
}
[433] Fix | Delete
[434] Fix | Delete
// Display a warning message on Entry Edit page.
[435] Fix | Delete
if ( ! $choices && is_admin() ) {
[436] Fix | Delete
$this->display_empty_dynamic_choices_message( $field );
[437] Fix | Delete
[438] Fix | Delete
return;
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
$amp_state_id = '';
[442] Fix | Delete
[443] Fix | Delete
if ( wpforms_is_amp() && ( $using_image_choices || $using_icon_choices ) ) {
[444] Fix | Delete
$amp_state_id = str_replace( '-', '_', sanitize_key( $container['id'] ) ) . '_state';
[445] Fix | Delete
$state = [];
[446] Fix | Delete
[447] Fix | Delete
foreach ( $choices as $key => $choice ) {
[448] Fix | Delete
$state[ $choice['id'] ] = ! empty( $choice['default'] );
[449] Fix | Delete
}
[450] Fix | Delete
printf(
[451] Fix | Delete
'<amp-state id="%s"><script type="application/json">%s</script></amp-state>',
[452] Fix | Delete
esc_attr( $amp_state_id ),
[453] Fix | Delete
wp_json_encode( $state )
[454] Fix | Delete
);
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
printf(
[458] Fix | Delete
'<ul %s>',
[459] Fix | Delete
wpforms_html_attributes( $container['id'], $container['class'], $container['data'], $container['attr'] )
[460] Fix | Delete
);
[461] Fix | Delete
[462] Fix | Delete
foreach ( $choices as $key => $choice ) {
[463] Fix | Delete
$label = $this->get_choices_label( $choice['label']['text'] ?? '', $key, $field );
[464] Fix | Delete
[465] Fix | Delete
if ( wpforms_is_amp() && ( $using_image_choices || $using_icon_choices ) ) {
[466] Fix | Delete
$choice['container']['attr']['[class]'] = sprintf(
[467] Fix | Delete
'%s + ( %s[%s] ? " wpforms-selected" : "")',
[468] Fix | Delete
wp_json_encode( implode( ' ', $choice['container']['class'] ) ),
[469] Fix | Delete
$amp_state_id,
[470] Fix | Delete
wp_json_encode( $choice['id'] )
[471] Fix | Delete
);
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
// If the field is required, has the label hidden, and has
[475] Fix | Delete
// disclaimer mode enabled, so the required status in choice
[476] Fix | Delete
// label.
[477] Fix | Delete
$required = '';
[478] Fix | Delete
[479] Fix | Delete
if ( ! empty( $field['disclaimer_format'] ) && ! empty( $choice['required'] ) && ! empty( $field['label_hide'] ) ) {
[480] Fix | Delete
$required = wpforms_get_field_required_label();
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
printf(
[484] Fix | Delete
'<li %s>',
[485] Fix | Delete
wpforms_html_attributes( $choice['container']['id'], $choice['container']['class'], $choice['container']['data'], $choice['container']['attr'] )
[486] Fix | Delete
);
[487] Fix | Delete
[488] Fix | Delete
// The required constraint in HTML5 form validation does not work with checkbox groups, so omit in AMP.
[489] Fix | Delete
$required_attr = wpforms_is_amp() && count( $choices ) > 1 ? '' : $choice['required'];
[490] Fix | Delete
[491] Fix | Delete
if ( $using_image_choices ) {
[492] Fix | Delete
[493] Fix | Delete
// Make sure the image choices are keyboard-accessible.
[494] Fix | Delete
$choice['label']['attr']['tabindex'] = 0;
[495] Fix | Delete
[496] Fix | Delete
if ( wpforms_is_amp() ) {
[497] Fix | Delete
$choice['label']['attr']['on'] = sprintf(
[498] Fix | Delete
'tap:AMP.setState({ %s: { %s: ! %s[%s] } })',
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function