caldera_forms_escape_field_attributes_array

Escape an array of HTML attributes.

Description

(array) caldera_forms_escape_field_attributes_array( (array) array $attrs, (null) $prefix = null ); 

Returns (array)

Parameters (2)

0. $attrs (array) => array $attrs
Array of attributes, $name => $value
1. $prefix — Optional. (null) => null
The prefix.

Usage

  1. if ( !function_exists( 'caldera_forms_escape_field_attributes_array' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'caldera-forms/includes/functions.php'; 
  3.  
  4. // Array of attributes, $name => $value 
  5. $attrs = array(); 
  6.  
  7. // The prefix. 
  8. $prefix = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = caldera_forms_escape_field_attributes_array($attrs, $prefix); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/functions.php  
  1. function caldera_forms_escape_field_attributes_array( array $attrs, $prefix = null ) { 
  2. $out = array(); 
  3. foreach ( $attrs as $attr => $value ) { 
  4. if( $prefix ) { 
  5. $attr = $prefix . $attr; 
  6.  
  7. if( is_array( $value ) ) { 
  8. $_value = ''; 
  9. foreach ( $value as $v ) { 
  10. $_value .= ' ' . esc_attr( $v ); 
  11. $out[ $attr ] = $_value; 
  12. }else{ 
  13. $out[ $attr ] = esc_attr( $value ); 
  14.  
  15. return $out;