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