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