Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-conte.../plugins/wpforms-.../includes/fields
File: class-base.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// phpcs:ignore WPForms.PHP.UseStatement.UnusedUseStatement
[2] Fix | Delete
use \WPForms\Forms\Fields\Base\Frontend as FrontendBase;
[3] Fix | Delete
use WPForms\Forms\Fields\Helpers\RequirementsAlerts;
[4] Fix | Delete
use WPForms\Forms\IconChoices;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Base field template.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 1.0.0
[10] Fix | Delete
*/
[11] Fix | Delete
abstract class WPForms_Field {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Full name of the field type, eg "Paragraph Text".
[15] Fix | Delete
*
[16] Fix | Delete
* @since 1.0.0
[17] Fix | Delete
*
[18] Fix | Delete
* @var string
[19] Fix | Delete
*/
[20] Fix | Delete
public $name;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Type of the field, eg "textarea".
[24] Fix | Delete
*
[25] Fix | Delete
* @since 1.0.0
[26] Fix | Delete
*
[27] Fix | Delete
* @var string
[28] Fix | Delete
*/
[29] Fix | Delete
public $type;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Font Awesome Icon used for the editor button, eg "fa-list".
[33] Fix | Delete
*
[34] Fix | Delete
* @since 1.0.0
[35] Fix | Delete
*
[36] Fix | Delete
* @var mixed
[37] Fix | Delete
*/
[38] Fix | Delete
public $icon = false;
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Field keywords for search, eg "checkbox, file, icon, upload".
[42] Fix | Delete
*
[43] Fix | Delete
* @since 1.8.3
[44] Fix | Delete
*
[45] Fix | Delete
* @var string
[46] Fix | Delete
*/
[47] Fix | Delete
public $keywords = '';
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Priority order the field button should show inside the "Add Fields" tab.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 1.0.0
[53] Fix | Delete
*
[54] Fix | Delete
* @var int
[55] Fix | Delete
*/
[56] Fix | Delete
public $order = 1;
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Field group the field belongs to.
[60] Fix | Delete
*
[61] Fix | Delete
* @since 1.0.0
[62] Fix | Delete
*
[63] Fix | Delete
* @var string
[64] Fix | Delete
*/
[65] Fix | Delete
public $group = 'standard';
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Placeholder to hold default value(s) for some field types.
[69] Fix | Delete
*
[70] Fix | Delete
* @since 1.0.0
[71] Fix | Delete
*
[72] Fix | Delete
* @var mixed
[73] Fix | Delete
*/
[74] Fix | Delete
public $defaults;
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Current form ID in the admin builder.
[78] Fix | Delete
*
[79] Fix | Delete
* @since 1.1.1
[80] Fix | Delete
*
[81] Fix | Delete
* @var int|bool
[82] Fix | Delete
*/
[83] Fix | Delete
public $form_id;
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* Current field ID.
[87] Fix | Delete
*
[88] Fix | Delete
* @since 1.5.6
[89] Fix | Delete
*
[90] Fix | Delete
* @var int
[91] Fix | Delete
*/
[92] Fix | Delete
public $field_id;
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Current form data.
[96] Fix | Delete
*
[97] Fix | Delete
* @since 1.1.1
[98] Fix | Delete
*
[99] Fix | Delete
* @var array
[100] Fix | Delete
*/
[101] Fix | Delete
public $form_data;
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Current field data.
[105] Fix | Delete
*
[106] Fix | Delete
* @since 1.5.6
[107] Fix | Delete
*
[108] Fix | Delete
* @var array
[109] Fix | Delete
*/
[110] Fix | Delete
public $field_data;
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Instance of the Frontend class.
[114] Fix | Delete
*
[115] Fix | Delete
* @since 1.8.1
[116] Fix | Delete
*
[117] Fix | Delete
* @var FrontendBase
[118] Fix | Delete
*/
[119] Fix | Delete
protected $frontend_obj;
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* Primary class constructor.
[123] Fix | Delete
*
[124] Fix | Delete
* @since 1.0.0
[125] Fix | Delete
*
[126] Fix | Delete
* @param bool $init Pass false to allow to shortcut the whole initialization, if needed.
[127] Fix | Delete
*/
[128] Fix | Delete
public function __construct( $init = true ) {
[129] Fix | Delete
[130] Fix | Delete
if ( ! $init ) {
[131] Fix | Delete
return;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification
[135] Fix | Delete
$this->form_id = false;
[136] Fix | Delete
[137] Fix | Delete
if ( isset( $_GET['form_id'] ) ) {
[138] Fix | Delete
$this->form_id = absint( $_GET['form_id'] );
[139] Fix | Delete
} elseif ( isset( $_POST['id'] ) ) {
[140] Fix | Delete
$this->form_id = absint( $_POST['id'] );
[141] Fix | Delete
}
[142] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification
[143] Fix | Delete
[144] Fix | Delete
// Bootstrap.
[145] Fix | Delete
$this->init();
[146] Fix | Delete
[147] Fix | Delete
// Initialize field's Frontend class.
[148] Fix | Delete
$this->frontend_obj = $this->get_object( 'Frontend' );
[149] Fix | Delete
[150] Fix | Delete
// Temporary solution to get an object of the field class.
[151] Fix | Delete
add_filter(
[152] Fix | Delete
"wpforms_fields_get_field_object_{$this->type}",
[153] Fix | Delete
function () {
[154] Fix | Delete
[155] Fix | Delete
return $this;
[156] Fix | Delete
}
[157] Fix | Delete
);
[158] Fix | Delete
[159] Fix | Delete
// Field data.
[160] Fix | Delete
add_filter( 'wpforms_field_data', [ $this, 'field_data' ], 10, 2 );
[161] Fix | Delete
[162] Fix | Delete
// Add fields tab.
[163] Fix | Delete
add_filter( 'wpforms_builder_fields_buttons', [ $this, 'field_button' ], 15 );
[164] Fix | Delete
[165] Fix | Delete
// Add field keywords to the template fields.
[166] Fix | Delete
add_filter( 'wpforms_setup_template_fields', [ $this, 'enhance_template_fields_with_keywords' ] );
[167] Fix | Delete
[168] Fix | Delete
// Field options tab.
[169] Fix | Delete
add_action( "wpforms_builder_fields_options_{$this->type}", [ $this, 'field_options' ], 10 );
[170] Fix | Delete
[171] Fix | Delete
// Preview fields.
[172] Fix | Delete
add_action( "wpforms_builder_fields_previews_{$this->type}", [ $this, 'field_preview' ], 10 );
[173] Fix | Delete
[174] Fix | Delete
// AJAX Add new field.
[175] Fix | Delete
add_action( "wp_ajax_wpforms_new_field_{$this->type}", [ $this, 'field_new' ] );
[176] Fix | Delete
[177] Fix | Delete
// Display field input elements on front-end.
[178] Fix | Delete
add_action( "wpforms_display_field_{$this->type}", [ $this, 'field_display_proxy' ], 10, 3 );
[179] Fix | Delete
[180] Fix | Delete
// Display field on back-end.
[181] Fix | Delete
add_filter( "wpforms_pro_admin_entries_edit_is_field_displayable_{$this->type}", '__return_true', 9 );
[182] Fix | Delete
[183] Fix | Delete
// Validation on submit.
[184] Fix | Delete
add_action( "wpforms_process_validate_{$this->type}", [ $this, 'validate' ], 10, 3 );
[185] Fix | Delete
[186] Fix | Delete
// Format.
[187] Fix | Delete
add_action( "wpforms_process_format_{$this->type}", [ $this, 'format' ], 10, 3 );
[188] Fix | Delete
[189] Fix | Delete
// Prefill.
[190] Fix | Delete
add_filter( 'wpforms_field_properties', [ $this, 'field_prefill_value_property' ], 10, 3 );
[191] Fix | Delete
[192] Fix | Delete
// Change the choice's value while saving entries.
[193] Fix | Delete
add_filter( 'wpforms_process_before_form_data', [ $this, 'field_fill_empty_choices' ] );
[194] Fix | Delete
[195] Fix | Delete
// Change field name for ajax error.
[196] Fix | Delete
add_filter( 'wpforms_process_ajax_error_field_name', [ $this, 'ajax_error_field_name' ], 10, 4 );
[197] Fix | Delete
[198] Fix | Delete
// Add HTML line breaks before all newlines in Entry Preview.
[199] Fix | Delete
add_filter( "wpforms_pro_fields_entry_preview_get_field_value_{$this->type}_field_after", 'nl2br', 100 );
[200] Fix | Delete
[201] Fix | Delete
// Add allowed HTML tags for the field label.
[202] Fix | Delete
add_filter( 'wpforms_builder_strings', [ $this, 'add_allowed_label_html_tags' ] );
[203] Fix | Delete
[204] Fix | Delete
// Exclude empty dynamic choices from Entry Preview.
[205] Fix | Delete
add_filter( 'wpforms_pro_fields_entry_preview_print_entry_preview_exclude_field', [ $this, 'exclude_empty_dynamic_choices' ], 10, 3 );
[206] Fix | Delete
[207] Fix | Delete
// Add classes to the builder field preview.
[208] Fix | Delete
add_filter( 'wpforms_field_preview_class', [ $this, 'preview_field_class' ], 10, 2 );
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* All systems go. Used by subclasses. Required.
[213] Fix | Delete
*
[214] Fix | Delete
* @since 1.0.0
[215] Fix | Delete
* @since 1.5.0 Converted to abstract method, as it's required for all fields.
[216] Fix | Delete
*/
[217] Fix | Delete
abstract public function init();
[218] Fix | Delete
[219] Fix | Delete
/**
[220] Fix | Delete
* Prefill field value with either fallback or dynamic data.
[221] Fix | Delete
* This needs to be public (although internal) to be used in WordPress hooks.
[222] Fix | Delete
*
[223] Fix | Delete
* @since 1.5.0
[224] Fix | Delete
*
[225] Fix | Delete
* @param array $properties Field properties.
[226] Fix | Delete
* @param array $field Current field specific data.
[227] Fix | Delete
* @param array $form_data Prepared form data/settings.
[228] Fix | Delete
*
[229] Fix | Delete
* @return array Modified field properties.
[230] Fix | Delete
*/
[231] Fix | Delete
public function field_prefill_value_property( $properties, $field, $form_data ) {
[232] Fix | Delete
[233] Fix | Delete
// Process only for current field.
[234] Fix | Delete
if ( $this->type !== $field['type'] ) {
[235] Fix | Delete
return $properties;
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
// Set the form data, so we can reuse it later, even on front-end.
[239] Fix | Delete
$this->form_data = $form_data;
[240] Fix | Delete
[241] Fix | Delete
// Dynamic data.
[242] Fix | Delete
if ( ! empty( $this->form_data['settings']['dynamic_population'] ) ) {
[243] Fix | Delete
$properties = $this->field_prefill_value_property_dynamic( $properties, $field );
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
// Fallback data, rewrites dynamic because user-submitted data is more important.
[247] Fix | Delete
$properties = $this->field_prefill_value_property_fallback( $properties, $field );
[248] Fix | Delete
[249] Fix | Delete
return $properties;
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
/**
[253] Fix | Delete
* As we are processing user submitted data - ignore all admin-defined defaults.
[254] Fix | Delete
* Preprocess choices-related fields only.
[255] Fix | Delete
*
[256] Fix | Delete
* @since 1.5.0
[257] Fix | Delete
*
[258] Fix | Delete
* @param array $field Field data and settings.
[259] Fix | Delete
* @param array $properties Properties we are modifying.
[260] Fix | Delete
*/
[261] Fix | Delete
public function field_prefill_remove_choices_defaults( $field, &$properties ) {
[262] Fix | Delete
[263] Fix | Delete
// Skip this step on admin page.
[264] Fix | Delete
if ( is_admin() && ! wpforms_is_admin_page( 'entries', 'edit' ) ) {
[265] Fix | Delete
return;
[266] Fix | Delete
}
[267] Fix | Delete
if (
[268] Fix | Delete
! empty( $field['dynamic_choices'] ) ||
[269] Fix | Delete
! empty( $field['choices'] )
[270] Fix | Delete
) {
[271] Fix | Delete
array_walk_recursive(
[272] Fix | Delete
$properties['inputs'],
[273] Fix | Delete
function ( &$value, $key ) {
[274] Fix | Delete
[275] Fix | Delete
if ( 'default' === $key ) {
[276] Fix | Delete
$value = false;
[277] Fix | Delete
}
[278] Fix | Delete
if ( 'wpforms-selected' === $value ) {
[279] Fix | Delete
$value = '';
[280] Fix | Delete
}
[281] Fix | Delete
}
[282] Fix | Delete
);
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
/**
[287] Fix | Delete
* Whether current field can be populated dynamically.
[288] Fix | Delete
*
[289] Fix | Delete
* @since 1.5.0
[290] Fix | Delete
*
[291] Fix | Delete
* @param array $properties Field properties.
[292] Fix | Delete
* @param array $field Current field specific data.
[293] Fix | Delete
*
[294] Fix | Delete
* @return bool
[295] Fix | Delete
*/
[296] Fix | Delete
public function is_dynamic_population_allowed( $properties, $field ) {
[297] Fix | Delete
[298] Fix | Delete
$allowed = true;
[299] Fix | Delete
[300] Fix | Delete
// Allow population on front-end only.
[301] Fix | Delete
if ( is_admin() ) {
[302] Fix | Delete
$allowed = false;
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
// For dynamic population we require $_GET.
[306] Fix | Delete
if ( empty( $_GET ) ) { // phpcs:ignore
[307] Fix | Delete
$allowed = false;
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
return apply_filters( 'wpforms_field_is_dynamic_population_allowed', $allowed, $properties, $field );
[311] Fix | Delete
}
[312] Fix | Delete
[313] Fix | Delete
/**
[314] Fix | Delete
* Prefill the field value with a dynamic value, that we get from $_GET.
[315] Fix | Delete
* The pattern is: wpf4_12_primary, where:
[316] Fix | Delete
* 4 - form_id,
[317] Fix | Delete
* 12 - field_id,
[318] Fix | Delete
* first - input key.
[319] Fix | Delete
* As 'primary' is our default input key, "wpf4_12_primary" and "wpf4_12" are the same.
[320] Fix | Delete
*
[321] Fix | Delete
* @since 1.5.0
[322] Fix | Delete
*
[323] Fix | Delete
* @param array $properties Field properties.
[324] Fix | Delete
* @param array $field Current field specific data.
[325] Fix | Delete
*
[326] Fix | Delete
* @return array Modified field properties.
[327] Fix | Delete
*/
[328] Fix | Delete
protected function field_prefill_value_property_dynamic( $properties, $field ) {
[329] Fix | Delete
[330] Fix | Delete
if ( ! $this->is_dynamic_population_allowed( $properties, $field ) ) {
[331] Fix | Delete
return $properties;
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
// Iterate over each GET key, parse, and scrap data from there.
[335] Fix | Delete
foreach ( $_GET as $key => $raw_value ) { // phpcs:ignore
[336] Fix | Delete
preg_match( '/wpf(\d+)_(\d+)(.*)/i', $key, $matches );
[337] Fix | Delete
[338] Fix | Delete
if ( empty( $matches ) || ! is_array( $matches ) ) {
[339] Fix | Delete
continue;
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
// Required.
[343] Fix | Delete
$form_id = absint( $matches[1] );
[344] Fix | Delete
$field_id = absint( $matches[2] );
[345] Fix | Delete
$input = 'primary';
[346] Fix | Delete
[347] Fix | Delete
// Optional.
[348] Fix | Delete
if ( ! empty( $matches[3] ) ) {
[349] Fix | Delete
$input = sanitize_key( trim( $matches[3], '_' ) );
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
// Both form and field IDs should be the same as current form/field.
[353] Fix | Delete
if (
[354] Fix | Delete
(int) $this->form_data['id'] !== $form_id ||
[355] Fix | Delete
(int) $field['id'] !== $field_id
[356] Fix | Delete
) {
[357] Fix | Delete
// Go to the next GET param.
[358] Fix | Delete
continue;
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
if ( ! empty( $raw_value ) ) {
[362] Fix | Delete
$this->field_prefill_remove_choices_defaults( $field, $properties );
[363] Fix | Delete
}
[364] Fix | Delete
[365] Fix | Delete
/*
[366] Fix | Delete
* Some fields (like checkboxes) support multiple selection.
[367] Fix | Delete
* We do not support nested values, so omit them.
[368] Fix | Delete
* Example: ?wpf771_19_wpforms[fields][19][address1]=test
[369] Fix | Delete
* In this case:
[370] Fix | Delete
* $input = wpforms
[371] Fix | Delete
* $raw_value = [fields=>[]]
[372] Fix | Delete
* $single_value = [19=>[]]
[373] Fix | Delete
* There is no reliable way to clean those things out.
[374] Fix | Delete
* So we will ignore the value altogether if it's an array.
[375] Fix | Delete
* We support only single value numeric arrays, like these:
[376] Fix | Delete
* ?wpf771_19[]=test1&wpf771_19[]=test2
[377] Fix | Delete
* ?wpf771_19_value[]=test1&wpf771_19_value[]=test2
[378] Fix | Delete
* ?wpf771_41_r3_c2[]=1&wpf771_41_r1_c4[]=1
[379] Fix | Delete
*/
[380] Fix | Delete
if ( is_array( $raw_value ) ) {
[381] Fix | Delete
foreach ( $raw_value as $single_value ) {
[382] Fix | Delete
$properties = $this->get_field_populated_single_property_value( $single_value, $input, $properties, $field );
[383] Fix | Delete
}
[384] Fix | Delete
} else {
[385] Fix | Delete
$properties = $this->get_field_populated_single_property_value( $raw_value, $input, $properties, $field );
[386] Fix | Delete
}
[387] Fix | Delete
}
[388] Fix | Delete
[389] Fix | Delete
return $properties;
[390] Fix | Delete
}
[391] Fix | Delete
[392] Fix | Delete
/**
[393] Fix | Delete
* Public version of get_field_populated_single_property_value() to use by external classes.
[394] Fix | Delete
*
[395] Fix | Delete
* @since 1.6.0.1
[396] Fix | Delete
*
[397] Fix | Delete
* @param string $raw_value Value from a GET param, always a string.
[398] Fix | Delete
* @param string $input Represent a subfield inside the field. May be empty.
[399] Fix | Delete
* @param array $properties Field properties.
[400] Fix | Delete
* @param array $field Current field specific data.
[401] Fix | Delete
*
[402] Fix | Delete
* @return array Modified field properties.
[403] Fix | Delete
*/
[404] Fix | Delete
public function get_field_populated_single_property_value_public( $raw_value, $input, $properties, $field ) {
[405] Fix | Delete
[406] Fix | Delete
return $this->get_field_populated_single_property_value( $raw_value, $input, $properties, $field );
[407] Fix | Delete
}
[408] Fix | Delete
[409] Fix | Delete
/**
[410] Fix | Delete
* Get the value, that is used to prefill via dynamic or fallback population.
[411] Fix | Delete
* Based on field data and current properties.
[412] Fix | Delete
*
[413] Fix | Delete
* @since 1.5.0
[414] Fix | Delete
*
[415] Fix | Delete
* @param string $raw_value Value from a GET param, always a string.
[416] Fix | Delete
* @param string $input Represent a subfield inside the field. May be empty.
[417] Fix | Delete
* @param array $properties Field properties.
[418] Fix | Delete
* @param array $field Current field specific data.
[419] Fix | Delete
*
[420] Fix | Delete
* @return array Modified field properties.
[421] Fix | Delete
*/
[422] Fix | Delete
protected function get_field_populated_single_property_value( $raw_value, $input, $properties, $field ) {
[423] Fix | Delete
[424] Fix | Delete
if ( ! is_string( $raw_value ) ) {
[425] Fix | Delete
return $properties;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
$get_value = stripslashes( sanitize_text_field( $raw_value ) );
[429] Fix | Delete
[430] Fix | Delete
// For fields that have dynamic choices we need to add extra logic.
[431] Fix | Delete
if ( ! empty( $field['dynamic_choices'] ) ) {
[432] Fix | Delete
[433] Fix | Delete
$properties = $this->get_field_populated_single_property_value_dynamic_choices( $get_value, $properties );
[434] Fix | Delete
[435] Fix | Delete
} elseif ( ! empty( $field['choices'] ) && is_array( $field['choices'] ) ) {
[436] Fix | Delete
[437] Fix | Delete
$properties = $this->get_field_populated_single_property_value_normal_choices( $get_value, $properties, $field );
[438] Fix | Delete
[439] Fix | Delete
} else {
[440] Fix | Delete
/*
[441] Fix | Delete
* For other types of fields we need to check that
[442] Fix | Delete
* the key is registered for the defined field in inputs array.
[443] Fix | Delete
*/
[444] Fix | Delete
if (
[445] Fix | Delete
! empty( $input ) &&
[446] Fix | Delete
isset( $properties['inputs'][ $input ] )
[447] Fix | Delete
) {
[448] Fix | Delete
$properties['inputs'][ $input ]['attr']['value'] = $get_value;
[449] Fix | Delete
}
[450] Fix | Delete
}
[451] Fix | Delete
[452] Fix | Delete
return $properties;
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
/**
[456] Fix | Delete
* Get the value, that is used to prefill via dynamic or fallback population.
[457] Fix | Delete
* Based on field data and current properties.
[458] Fix | Delete
* Dynamic choices section.
[459] Fix | Delete
*
[460] Fix | Delete
* @since 1.6.0
[461] Fix | Delete
*
[462] Fix | Delete
* @param string $get_value Value from a GET param, always a string, sanitized, stripped slashes.
[463] Fix | Delete
* @param array $properties Field properties.
[464] Fix | Delete
*
[465] Fix | Delete
* @return array Modified field properties.
[466] Fix | Delete
*/
[467] Fix | Delete
protected function get_field_populated_single_property_value_dynamic_choices( $get_value, $properties ) {
[468] Fix | Delete
[469] Fix | Delete
$default_key = null;
[470] Fix | Delete
[471] Fix | Delete
foreach ( $properties['inputs'] as $input_key => $input_arr ) {
[472] Fix | Delete
// Dynamic choices support only integers in its values.
[473] Fix | Delete
if ( absint( $get_value ) === $input_arr['attr']['value'] ) {
[474] Fix | Delete
$default_key = $input_key;
[475] Fix | Delete
// Stop iterating over choices.
[476] Fix | Delete
break;
[477] Fix | Delete
}
[478] Fix | Delete
}
[479] Fix | Delete
[480] Fix | Delete
// Redefine default choice only if dynamic value has changed anything.
[481] Fix | Delete
if ( null !== $default_key ) {
[482] Fix | Delete
foreach ( $properties['inputs'] as $input_key => $choice_arr ) {
[483] Fix | Delete
if ( $input_key === $default_key ) {
[484] Fix | Delete
$properties['inputs'][ $input_key ]['default'] = true;
[485] Fix | Delete
$properties['inputs'][ $input_key ]['container']['class'][] = 'wpforms-selected';
[486] Fix | Delete
// Stop iterating over choices.
[487] Fix | Delete
break;
[488] Fix | Delete
}
[489] Fix | Delete
}
[490] Fix | Delete
}
[491] Fix | Delete
[492] Fix | Delete
return $properties;
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
/**
[496] Fix | Delete
* Fill choices without labels.
[497] Fix | Delete
*
[498] Fix | Delete
* @since 1.6.2
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function