acf_filter_attrs()
acf_filter_attrs
Filters out empty attrs from the provided array.
No Hooks.
Returns
Array.
Usage
acf_filter_attrs( $attrs );
- $attrs(array) (required)
- The array of attrs.
Changelog
| Since 5.8.1 | Introduced. |
acf_filter_attrs() acf filter attrs code ACF 6.0.4
function acf_filter_attrs( $attrs ) {
// Filter out empty attrs but allow "0" values.
$filtered = array_filter( $attrs, 'acf_not_empty' );
// Correct specific attributes (required="required").
foreach ( array( 'required', 'readonly', 'disabled', 'multiple' ) as $key ) {
unset( $filtered[ $key ] );
if ( ! empty( $attrs[ $key ] ) ) {
$filtered[ $key ] = $key;
}
}
return $filtered;
}