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