%3$s', sanitize_key( $tag_name ), $attr_string, $content ); } public static function build_attributes_string( $attributes ) { $string = array(); foreach ( $attributes as $name => $value ) { if ( '' === $value ) { $string[] = sprintf( '%s', sanitize_key( $name ) ); } else { $string[] = sprintf( '%s="%s"', sanitize_key( $name ), esc_attr( $value ) ); } } return implode( ' ', $string ); } }