wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_sanitize_script_attributes › WordPress Function

Since5.7.0
Deprecatedn/a
wp_sanitize_script_attributes ( $attributes )
Parameters:
  • (array<string,string|bool>) $attributes Key-value pairs representing `<script>` tag attributes.
    Required: Yes
Returns:
  • (string) String made of sanitized `<script>` tag attributes.
Defined at:
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}.


Source

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;
}