ensure variable is of type string

This commit is contained in:
IanDelMar 2022-07-24 08:12:17 +02:00
parent e0b0004178
commit 0b13b87a43
1 changed files with 5 additions and 0 deletions

View File

@ -153,14 +153,19 @@ if ( ! function_exists( 'understrap_body_attributes' ) ) {
if ( ! is_array( $atts ) || empty( $atts ) ) {
return;
}
$attributes = '';
foreach ( $atts as $name => $value ) {
if ( $value ) {
if ( ! is_string( $value ) ) {
continue;
}
$attributes .= sanitize_key( $name ) . '="' . esc_attr( $value ) . '" ';
} else {
$attributes .= sanitize_key( $name ) . ' ';
}
}
echo trim( $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput
}
}