$v ) { // String (but don't trim value). if( is_string($v) && ($k !== 'value') ) { $v = trim($v); // Boolean } elseif( is_bool($v) ) { $v = $v ? 1 : 0; // Object } elseif( is_array($v) || is_object($v) ) { $v = json_encode($v); } // Generate HTML. $html .= sprintf( ' %s="%s"', esc_attr($k), esc_attr($v) ); } // Return trimmed. return trim( $html ); } if ( defined('ACF_EXPERIMENTAL_ESC_HTML') && ACF_EXPERIMENTAL_ESC_HTML ) { /** * Sanitizes text content and strips out disallowed HTML. * * This function emulates `wp_kses_post()` with a context of "acf" for extensibility. * * @date 16/4/21 * @since 5.9.6 * * @param string $string * @return string */ function acf_esc_html( $string = '' ) { return wp_kses( (string) $string, 'acf' ); } /** * Private callback for the "wp_kses_allowed_html" filter used to return allowed HTML for "acf" context. * * @date 16/4/21 * @since 5.9.6 * * @param array $tags An array of allowed tags. * @param string $context The context name. * @return array. */ function _acf_kses_allowed_html( $tags, $context ) { global $allowedposttags; if( $context === 'acf' ) { return $allowedposttags; } return $tags; } add_filter( 'wp_kses_allowed_html', '_acf_kses_allowed_html', 0, 2 ); } else { /** * acf_esc_html * * Encodes