Field::get_attr( array $arr )

Description #

Convert and sanitize attributes of array to string.

Parameters #

  • $arr
    array (Required) Custom attributes to apply.

Source #

File: lib/form/class-field.php

	protected function get_attr( $arr ) {
		$html = '';
		if ( ! empty( $arr ) && is_array( $arr ) ) {
			foreach ( $arr as $attr_key => $attr_value ) {
				$html .= ' ' . sanitize_html_class( $attr_key ) . '="' . esc_attr( $attr_value ) . '"';
			}
		}

		return $html;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment