Skip to content
Custom fields for WordPress that are quick to build and quick to load. Get Pro
Docs

Functions

ugly_html_attributes()

1 minute to read Updated 1 week ago

PHP
ugly_html_attributes( array $attributes ): string

Builds the attributes of a tag, each one escaped: name="value" other="value". A true prints the bare attribute (required), a false leaves it out.

PHP
echo '<input' . ugly_html_attributes( array(
	'type'     => 'text',
	'name'     => 'title',
	'required' => true,
	'disabled' => false,
) ) . '>';
// <input type="text" name="title" required>

It is made for your own field types, so the output is safe and it is clear that it is.

Did this article answer your question?