Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/wpforms-.../src/Forms/Fields/PaymentC...
File: Field.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace WPForms\Forms\Fields\PaymentCheckbox;
[2] Fix | Delete
[3] Fix | Delete
use WPForms_Field;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Checkbox payment field.
[7] Fix | Delete
*
[8] Fix | Delete
* @since 1.8.2
[9] Fix | Delete
*/
[10] Fix | Delete
class Field extends WPForms_Field {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Primary class constructor.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 1.8.2
[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__( 'Checkbox Items', 'wpforms-lite' );
[21] Fix | Delete
$this->keywords = esc_html__( 'product, store, ecommerce, pay, payment', 'wpforms-lite' );
[22] Fix | Delete
$this->type = 'payment-checkbox';
[23] Fix | Delete
$this->icon = 'fa-check-square-o';
[24] Fix | Delete
$this->order = 50;
[25] Fix | Delete
$this->group = 'payment';
[26] Fix | Delete
$this->defaults = [
[27] Fix | Delete
1 => [
[28] Fix | Delete
'label' => esc_html__( 'First Item', 'wpforms-lite' ),
[29] Fix | Delete
'value' => '10',
[30] Fix | Delete
'image' => '',
[31] Fix | Delete
'icon' => '',
[32] Fix | Delete
'icon_style' => '',
[33] Fix | Delete
'default' => '',
[34] Fix | Delete
],
[35] Fix | Delete
2 => [
[36] Fix | Delete
'label' => esc_html__( 'Second Item', 'wpforms-lite' ),
[37] Fix | Delete
'value' => '25',
[38] Fix | Delete
'image' => '',
[39] Fix | Delete
'icon' => '',
[40] Fix | Delete
'icon_style' => '',
[41] Fix | Delete
'default' => '',
[42] Fix | Delete
],
[43] Fix | Delete
3 => [
[44] Fix | Delete
'label' => esc_html__( 'Third Item', 'wpforms-lite' ),
[45] Fix | Delete
'value' => '50',
[46] Fix | Delete
'image' => '',
[47] Fix | Delete
'icon' => '',
[48] Fix | Delete
'icon_style' => '',
[49] Fix | Delete
'default' => '',
[50] Fix | Delete
],
[51] Fix | Delete
];
[52] Fix | Delete
[53] Fix | Delete
$this->default_settings = [
[54] Fix | Delete
'choices' => $this->defaults,
[55] Fix | Delete
];
[56] Fix | Delete
[57] Fix | Delete
$this->hooks();
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Register hooks.
[62] Fix | Delete
*
[63] Fix | Delete
* @since 1.8.1
[64] Fix | Delete
*/
[65] Fix | Delete
private function hooks() {
[66] Fix | Delete
[67] Fix | Delete
// Customize HTML field values.
[68] Fix | Delete
add_filter( 'wpforms_html_field_value', [ $this, 'field_html_value' ], 10, 4 );
[69] Fix | Delete
add_filter( "wpforms_{$this->type}_field_html_value_images", [ $this, 'field_html_value_images' ], 10, 3 );
[70] Fix | Delete
[71] Fix | Delete
// Define additional field properties.
[72] Fix | Delete
add_filter( "wpforms_field_properties_{$this->type}", [ $this, 'field_properties' ], 5, 3 );
[73] Fix | Delete
[74] Fix | Delete
// This field requires fieldset+legend instead of the field label.
[75] Fix | Delete
add_filter( "wpforms_frontend_modern_is_field_requires_fieldset_{$this->type}", '__return_true', PHP_INT_MAX, 2 );
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Define additional field properties.
[80] Fix | Delete
*
[81] Fix | Delete
* @since 1.8.2
[82] Fix | Delete
*
[83] Fix | Delete
* @param array $properties Field properties.
[84] Fix | Delete
* @param array $field Field settings.
[85] Fix | Delete
* @param array $form_data Form data and settings.
[86] Fix | Delete
*
[87] Fix | Delete
* @return array
[88] Fix | Delete
*/
[89] Fix | Delete
public function field_properties( $properties, $field, $form_data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
[90] Fix | Delete
[91] Fix | Delete
// Define data.
[92] Fix | Delete
$form_id = absint( $form_data['id'] );
[93] Fix | Delete
$field_id = absint( $field['id'] );
[94] Fix | Delete
$choices = $field['choices'];
[95] Fix | Delete
[96] Fix | Delete
// Remove primary input, unset for attribute for label.
[97] Fix | Delete
unset( $properties['inputs']['primary'], $properties['label']['attr']['for'] );
[98] Fix | Delete
[99] Fix | Delete
// Set input container (ul) properties.
[100] Fix | Delete
$properties['input_container'] = [
[101] Fix | Delete
'class' => [],
[102] Fix | Delete
'data' => [],
[103] Fix | Delete
'attr' => [],
[104] Fix | Delete
'id' => "wpforms-{$form_id}-field_{$field_id}",
[105] Fix | Delete
];
[106] Fix | Delete
[107] Fix | Delete
$is_choice_limit_set = ! empty( $field['choice_limit'] ) && (int) $field['choice_limit'] > 0;
[108] Fix | Delete
[109] Fix | Delete
if ( $is_choice_limit_set ) {
[110] Fix | Delete
$properties['input_container']['data']['choice-limit'] = $field['choice_limit'];
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
// Set input properties.
[114] Fix | Delete
foreach ( $choices as $key => $choice ) {
[115] Fix | Delete
[116] Fix | Delete
// Choice labels should not be left blank, but if they are, we provide a basic value.
[117] Fix | Delete
$label = $choice['label'];
[118] Fix | Delete
[119] Fix | Delete
if ( $label === '' ) {
[120] Fix | Delete
if ( 1 === count( $choices ) ) {
[121] Fix | Delete
$label = esc_html__( 'Checked', 'wpforms-lite' );
[122] Fix | Delete
} else {
[123] Fix | Delete
/* translators: %s - item number. */
[124] Fix | Delete
$label = sprintf( esc_html__( 'Item %s', 'wpforms-lite' ), $key );
[125] Fix | Delete
}
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
$properties['inputs'][ $key ] = [
[129] Fix | Delete
'container' => [
[130] Fix | Delete
'attr' => [],
[131] Fix | Delete
'class' => [ "choice-{$key}" ],
[132] Fix | Delete
'data' => [],
[133] Fix | Delete
'id' => '',
[134] Fix | Delete
],
[135] Fix | Delete
'label' => [
[136] Fix | Delete
'attr' => [
[137] Fix | Delete
'for' => "wpforms-{$form_id}-field_{$field_id}_{$key}",
[138] Fix | Delete
],
[139] Fix | Delete
'class' => [ 'wpforms-field-label-inline' ],
[140] Fix | Delete
'data' => [],
[141] Fix | Delete
'id' => '',
[142] Fix | Delete
'text' => $label,
[143] Fix | Delete
],
[144] Fix | Delete
'attr' => [
[145] Fix | Delete
'name' => "wpforms[fields][{$field_id}][]",
[146] Fix | Delete
'value' => $key,
[147] Fix | Delete
],
[148] Fix | Delete
'class' => [ 'wpforms-payment-price' ],
[149] Fix | Delete
'data' => [
[150] Fix | Delete
'amount' => wpforms_format_amount( wpforms_sanitize_amount( $choice['value'] ) ),
[151] Fix | Delete
],
[152] Fix | Delete
'id' => "wpforms-{$form_id}-field_{$field_id}_{$key}",
[153] Fix | Delete
'icon' => $choice['icon'] ?? '',
[154] Fix | Delete
'icon_style' => $choice['icon_style'] ?? '',
[155] Fix | Delete
'image' => $choice['image'] ?? '',
[156] Fix | Delete
'required' => ! empty( $field['required'] ) ? 'required' : '',
[157] Fix | Delete
'default' => isset( $choice['default'] ),
[158] Fix | Delete
];
[159] Fix | Delete
[160] Fix | Delete
// Rule for validator only if needed.
[161] Fix | Delete
if ( $is_choice_limit_set ) {
[162] Fix | Delete
$properties['inputs'][ $key ]['data']['rule-check-limit'] = 'true';
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
// Required class for pagebreak validation.
[167] Fix | Delete
if ( ! empty( $field['required'] ) ) {
[168] Fix | Delete
$properties['input_container']['class'][] = 'wpforms-field-required';
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
// Custom properties if image choices are enabled.
[172] Fix | Delete
if ( ! empty( $field['choices_images'] ) ) {
[173] Fix | Delete
[174] Fix | Delete
$properties['input_container']['class'][] = 'wpforms-image-choices';
[175] Fix | Delete
$properties['input_container']['class'][] = 'wpforms-image-choices-' . sanitize_html_class( $field['choices_images_style'] );
[176] Fix | Delete
[177] Fix | Delete
foreach ( $properties['inputs'] as $key => $inputs ) {
[178] Fix | Delete
$properties['inputs'][ $key ]['container']['class'][] = 'wpforms-image-choices-item';
[179] Fix | Delete
[180] Fix | Delete
if ( in_array( $field['choices_images_style'], [ 'modern', 'classic' ], true ) ) {
[181] Fix | Delete
$properties['inputs'][ $key ]['class'][] = 'wpforms-screen-reader-element';
[182] Fix | Delete
}
[183] Fix | Delete
}
[184] Fix | Delete
} elseif ( ! empty( $field['choices_icons'] ) ) {
[185] Fix | Delete
$properties = wpforms()->obj( 'icon_choices' )->field_properties( $properties, $field );
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
// Add selected class for choices with defaults.
[189] Fix | Delete
foreach ( $properties['inputs'] as $key => $inputs ) {
[190] Fix | Delete
if ( ! empty( $inputs['default'] ) ) {
[191] Fix | Delete
$properties['inputs'][ $key ]['container']['class'][] = 'wpforms-selected';
[192] Fix | Delete
}
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
return $properties;
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
/**
[199] Fix | Delete
* Get field populated single property value.
[200] Fix | Delete
*
[201] Fix | Delete
* @since 1.8.2
[202] Fix | Delete
*
[203] Fix | Delete
* @param string $raw_value Value from a GET param, always a string.
[204] Fix | Delete
* @param string $input Represent a subfield inside the field. May be empty.
[205] Fix | Delete
* @param array $properties Field properties.
[206] Fix | Delete
* @param array $field Current field specific data.
[207] Fix | Delete
*
[208] Fix | Delete
* @return array Modified field properties.
[209] Fix | Delete
*/
[210] Fix | Delete
protected function get_field_populated_single_property_value( $raw_value, $input, $properties, $field ) {
[211] Fix | Delete
/*
[212] Fix | Delete
* When the form is submitted, we get only choice values from the Fallback.
[213] Fix | Delete
* As payment-checkbox (checkboxes) field doesn't support 'show_values' option -
[214] Fix | Delete
* we should transform that into label to check against using general logic in parent method.
[215] Fix | Delete
*/
[216] Fix | Delete
[217] Fix | Delete
if (
[218] Fix | Delete
! is_string( $raw_value ) ||
[219] Fix | Delete
empty( $field['choices'] ) ||
[220] Fix | Delete
! is_array( $field['choices'] )
[221] Fix | Delete
) {
[222] Fix | Delete
return $properties;
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
// The form submits only the sum, so shortcut for Dynamic.
[226] Fix | Delete
if ( ! is_numeric( $raw_value ) ) {
[227] Fix | Delete
return parent::get_field_populated_single_property_value( $raw_value, $input, $properties, $field );
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
$get_value = wpforms_format_amount( wpforms_sanitize_amount( $raw_value ) );
[231] Fix | Delete
[232] Fix | Delete
foreach ( $field['choices'] as $choice ) {
[233] Fix | Delete
if (
[234] Fix | Delete
isset( $choice['label'], $choice['value'] ) &&
[235] Fix | Delete
wpforms_format_amount( wpforms_sanitize_amount( $choice['value'] ) ) === $get_value
[236] Fix | Delete
) {
[237] Fix | Delete
$trans_value = $choice['label'];
[238] Fix | Delete
// Stop iterating over choices.
[239] Fix | Delete
break;
[240] Fix | Delete
}
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
if ( empty( $trans_value ) ) {
[244] Fix | Delete
return $properties;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
return parent::get_field_populated_single_property_value( $trans_value, $input, $properties, $field );
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Field options panel inside the builder.
[252] Fix | Delete
*
[253] Fix | Delete
* @since 1.8.2
[254] Fix | Delete
*
[255] Fix | Delete
* @param array $field Field settings.
[256] Fix | Delete
*/
[257] Fix | Delete
public function field_options( $field ) {
[258] Fix | Delete
/*
[259] Fix | Delete
* Basic field options.
[260] Fix | Delete
*/
[261] Fix | Delete
[262] Fix | Delete
// Options open markup.
[263] Fix | Delete
$this->field_option(
[264] Fix | Delete
'basic-options',
[265] Fix | Delete
$field,
[266] Fix | Delete
[
[267] Fix | Delete
'markup' => 'open',
[268] Fix | Delete
]
[269] Fix | Delete
);
[270] Fix | Delete
[271] Fix | Delete
// Label.
[272] Fix | Delete
$this->field_option( 'label', $field );
[273] Fix | Delete
[274] Fix | Delete
// Choices option.
[275] Fix | Delete
$this->field_option( 'choices_payments', $field );
[276] Fix | Delete
[277] Fix | Delete
// Show price after item labels.
[278] Fix | Delete
$fld = $this->field_element(
[279] Fix | Delete
'toggle',
[280] Fix | Delete
$field,
[281] Fix | Delete
[
[282] Fix | Delete
'slug' => 'show_price_after_labels',
[283] Fix | Delete
'value' => isset( $field['show_price_after_labels'] ) ? '1' : '0',
[284] Fix | Delete
'desc' => esc_html__( 'Show Price After Item Labels', 'wpforms-lite' ),
[285] Fix | Delete
'tooltip' => esc_html__( 'Check this option to show price of the item after the label.', 'wpforms-lite' ),
[286] Fix | Delete
],
[287] Fix | Delete
false
[288] Fix | Delete
);
[289] Fix | Delete
$args = [
[290] Fix | Delete
'slug' => 'show_price_after_labels',
[291] Fix | Delete
'content' => $fld,
[292] Fix | Delete
];
[293] Fix | Delete
[294] Fix | Delete
$this->field_element( 'row', $field, $args );
[295] Fix | Delete
[296] Fix | Delete
// Choices Images.
[297] Fix | Delete
$this->field_option( 'choices_images', $field );
[298] Fix | Delete
[299] Fix | Delete
// Hide Choices Images.
[300] Fix | Delete
$this->field_option( 'choices_images_hide', $field );
[301] Fix | Delete
[302] Fix | Delete
// Choice Images Style (theme).
[303] Fix | Delete
$this->field_option( 'choices_images_style', $field );
[304] Fix | Delete
[305] Fix | Delete
// Choices Icons.
[306] Fix | Delete
$this->field_option( 'choices_icons', $field );
[307] Fix | Delete
[308] Fix | Delete
// Choices Icons Color.
[309] Fix | Delete
$this->field_option( 'choices_icons_color', $field );
[310] Fix | Delete
[311] Fix | Delete
// Choices Icons Size.
[312] Fix | Delete
$this->field_option( 'choices_icons_size', $field );
[313] Fix | Delete
[314] Fix | Delete
// Choices Icons Style.
[315] Fix | Delete
$this->field_option( 'choices_icons_style', $field );
[316] Fix | Delete
[317] Fix | Delete
// Description.
[318] Fix | Delete
$this->field_option( 'description', $field );
[319] Fix | Delete
[320] Fix | Delete
// Required toggle.
[321] Fix | Delete
$this->field_option( 'required', $field );
[322] Fix | Delete
[323] Fix | Delete
// Options close markup.
[324] Fix | Delete
$this->field_option(
[325] Fix | Delete
'basic-options',
[326] Fix | Delete
$field,
[327] Fix | Delete
[
[328] Fix | Delete
'markup' => 'close',
[329] Fix | Delete
]
[330] Fix | Delete
);
[331] Fix | Delete
[332] Fix | Delete
/*
[333] Fix | Delete
* Advanced field options.
[334] Fix | Delete
*/
[335] Fix | Delete
[336] Fix | Delete
// Options open markup.
[337] Fix | Delete
$this->field_option(
[338] Fix | Delete
'advanced-options',
[339] Fix | Delete
$field,
[340] Fix | Delete
[
[341] Fix | Delete
'markup' => 'open',
[342] Fix | Delete
]
[343] Fix | Delete
);
[344] Fix | Delete
[345] Fix | Delete
// Input columns.
[346] Fix | Delete
$this->field_option( 'input_columns', $field );
[347] Fix | Delete
[348] Fix | Delete
// Choice Limit.
[349] Fix | Delete
$this->field_option( 'choice_limit', $field );
[350] Fix | Delete
[351] Fix | Delete
// Custom CSS classes.
[352] Fix | Delete
$this->field_option( 'css', $field );
[353] Fix | Delete
[354] Fix | Delete
// Hide label.
[355] Fix | Delete
$this->field_option( 'label_hide', $field );
[356] Fix | Delete
[357] Fix | Delete
// Options close markup.
[358] Fix | Delete
$this->field_option(
[359] Fix | Delete
'advanced-options',
[360] Fix | Delete
$field,
[361] Fix | Delete
[
[362] Fix | Delete
'markup' => 'close',
[363] Fix | Delete
]
[364] Fix | Delete
);
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
/**
[368] Fix | Delete
* Field preview inside the builder.
[369] Fix | Delete
*
[370] Fix | Delete
* @since 1.8.2
[371] Fix | Delete
*
[372] Fix | Delete
* @param array $field Field settings.
[373] Fix | Delete
*/
[374] Fix | Delete
public function field_preview( $field ) {
[375] Fix | Delete
[376] Fix | Delete
// Label.
[377] Fix | Delete
$this->field_preview_option( 'label', $field );
[378] Fix | Delete
[379] Fix | Delete
// Choices.
[380] Fix | Delete
$this->field_preview_option( 'choices', $field );
[381] Fix | Delete
[382] Fix | Delete
// Description.
[383] Fix | Delete
$this->field_preview_option( 'description', $field );
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
/**
[387] Fix | Delete
* Field display on the form front-end.
[388] Fix | Delete
*
[389] Fix | Delete
* @since 1.8.2
[390] Fix | Delete
*
[391] Fix | Delete
* @param array $field Field settings.
[392] Fix | Delete
* @param array $deprecated Deprecated array.
[393] Fix | Delete
* @param array $form_data Form data and settings.
[394] Fix | Delete
*
[395] Fix | Delete
* @noinspection HtmlUnknownAttribute
[396] Fix | Delete
* @noinspection HtmlUnknownTarget
[397] Fix | Delete
*/
[398] Fix | Delete
public function field_display( $field, $deprecated, $form_data ) {
[399] Fix | Delete
[400] Fix | Delete
// Define data.
[401] Fix | Delete
$container = $field['properties']['input_container'];
[402] Fix | Delete
$choices = $field['properties']['inputs'];
[403] Fix | Delete
[404] Fix | Delete
printf(
[405] Fix | Delete
'<ul %s>',
[406] Fix | Delete
wpforms_html_attributes( $container['id'], $container['class'], $container['data'], $container['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[407] Fix | Delete
);
[408] Fix | Delete
[409] Fix | Delete
foreach ( $choices as $key => $choice ) {
[410] Fix | Delete
[411] Fix | Delete
$label = $choice['label']['text'] ?? '';
[412] Fix | Delete
[413] Fix | Delete
/* translators: %s - item number. */
[414] Fix | Delete
$label = $label !== '' ? $label : sprintf( esc_html__( 'Item %s', 'wpforms-lite' ), $key );
[415] Fix | Delete
[416] Fix | Delete
$label .= ! empty( $field['show_price_after_labels'] ) && isset( $choice['data']['amount'] ) ? $this->get_price_after_label( $choice['data']['amount'] ) : '';
[417] Fix | Delete
[418] Fix | Delete
printf(
[419] Fix | Delete
'<li %s>',
[420] Fix | Delete
wpforms_html_attributes( $choice['container']['id'], $choice['container']['class'], $choice['container']['data'], $choice['container']['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[421] Fix | Delete
);
[422] Fix | Delete
[423] Fix | Delete
if ( empty( $field['dynamic_choices'] ) && ! empty( $field['choices_images'] ) ) {
[424] Fix | Delete
[425] Fix | Delete
// Image choices.
[426] Fix | Delete
printf(
[427] Fix | Delete
'<label %s>',
[428] Fix | Delete
wpforms_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[429] Fix | Delete
);
[430] Fix | Delete
[431] Fix | Delete
echo '<span class="wpforms-image-choices-image">';
[432] Fix | Delete
[433] Fix | Delete
if ( ! empty( $choice['image'] ) ) {
[434] Fix | Delete
printf(
[435] Fix | Delete
'<img src="%s" alt="%s"%s>',
[436] Fix | Delete
esc_url( $choice['image'] ),
[437] Fix | Delete
esc_attr( $choice['label']['text'] ),
[438] Fix | Delete
! empty( $choice['label']['text'] ) ? ' title="' . esc_attr( $choice['label']['text'] ) . '"' : ''
[439] Fix | Delete
);
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
echo '</span>';
[443] Fix | Delete
[444] Fix | Delete
if ( $field['choices_images_style'] === 'none' ) {
[445] Fix | Delete
echo '<br>';
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
printf(
[449] Fix | Delete
'<input type="checkbox" %s %s %s>',
[450] Fix | Delete
wpforms_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[451] Fix | Delete
esc_attr( $choice['required'] ),
[452] Fix | Delete
checked( '1', $choice['default'], false )
[453] Fix | Delete
);
[454] Fix | Delete
[455] Fix | Delete
echo '<span class="wpforms-image-choices-label">' . wp_kses_post( $label ) . '</span>';
[456] Fix | Delete
[457] Fix | Delete
echo '</label>';
[458] Fix | Delete
[459] Fix | Delete
} elseif ( empty( $field['dynamic_choices'] ) && ! empty( $field['choices_icons'] ) ) {
[460] Fix | Delete
// Icon Choices.
[461] Fix | Delete
wpforms()->obj( 'icon_choices' )->field_display( $field, $choice, 'checkbox', $label );
[462] Fix | Delete
[463] Fix | Delete
} else {
[464] Fix | Delete
[465] Fix | Delete
// Normal display.
[466] Fix | Delete
printf(
[467] Fix | Delete
'<input type="checkbox" %s %s %s>',
[468] Fix | Delete
wpforms_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[469] Fix | Delete
esc_attr( $choice['required'] ),
[470] Fix | Delete
checked( '1', $choice['default'], false )
[471] Fix | Delete
);
[472] Fix | Delete
[473] Fix | Delete
printf(
[474] Fix | Delete
'<label %s>%s</label>',
[475] Fix | Delete
wpforms_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[476] Fix | Delete
wp_kses_post( $label )
[477] Fix | Delete
);
[478] Fix | Delete
}
[479] Fix | Delete
[480] Fix | Delete
echo '</li>';
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
echo '</ul>';
[484] Fix | Delete
}
[485] Fix | Delete
[486] Fix | Delete
/**
[487] Fix | Delete
* Validate field on submitting the form.
[488] Fix | Delete
*
[489] Fix | Delete
* @since 1.8.2
[490] Fix | Delete
*
[491] Fix | Delete
* @param int $field_id Field ID.
[492] Fix | Delete
* @param array $field_submit Submitted field value (raw data).
[493] Fix | Delete
* @param array $form_data Form data and settings.
[494] Fix | Delete
*/
[495] Fix | Delete
public function validate( $field_id, $field_submit, $form_data ) {
[496] Fix | Delete
[497] Fix | Delete
$field_id = (int) $field_id;
[498] Fix | Delete
$error = '';
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function