wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_sanitize_script_attributes › WordPress Function
Seit5.7.0
Veraltetn/v
› wp_sanitize_script_attributes ( $attributes )
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag.
Automatically injects type attribute if needed. Used by {@see} and {@see}.Ähnliche Funktionen: wp_kses_uri_attributes, serialize_block_attributes, wp_pre_kses_block_attributes, sanitize_title, wp_initialize_site
Quellcode
function wp_sanitize_script_attributes( $attributes ) {
$attributes_string = '';
/*
* If HTML5 script tag is supported, only the attribute name is added
* to $attributes_string for entries with a boolean value, and that are true.
*/
foreach ( $attributes as $attribute_name => $attribute_value ) {
if ( is_bool( $attribute_value ) ) {
if ( $attribute_value ) {
$attributes_string .= ' ' . esc_attr( $attribute_name );
}
} else {
$attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) );
}
}
return $attributes_string;
}