Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Wpf_Tokens::get_non_dynamic_choice_index( mixed $value, array $field )
Retrieves the checkbox value ( index of choice ).
Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825
Parameters Parameters
- $value
(Required) The value.
- $field
(Required) The current field config.
Return Return
(string) The selected value.
Source Source
File: src/integrations/wpforms/tokens/wpf-tokens.php
private function get_non_dynamic_choice_index( $value, $field ) { // Skip if payment field. if ( strpos( $field['type'], 'payment' ) === 0 ) { return apply_filters( 'automator_wpforms_non_dynamic_choice_value', $value, $field ); } $choices = $field['choices']; $value_array = array_map( 'trim', explode( ', ', $value ) ); $selected = array(); foreach ( $choices as $key => $choice ) { // Strip whitespace for single space. $label = preg_replace( '/\s+/', ' ', $choice['label'] ); // Check if label is in value array. if ( in_array( $label, $value_array, true ) ) { $selected[] = $key; } } $value = ! empty( $selected ) ? implode( ', ', $selected ) : ''; return apply_filters( 'automator_wpforms_non_dynamic_choice_value', $value, $field ); }
Expand full source code Collapse full source code View on Github