File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 44 /**
55 * Generate a string of HTML attributes
66 *
7- * @param array $attr Associative array of attribute names and values.
7+ * @param array|object $attr Associative array or object of attribute names and values.
88 * @param callable|null $callback Callback function to escape values for HTML attributes.
99 * Defaults to `htmlspecialchars()`.
10- * @return string Returns a string of HTML attributes.
10+ * @return string Returns a string of HTML attributes
11+ * or a empty string if $attr is invalid or empty.
1112 */
12- function html_build_attributes (array $ attr , callable $ callback = null )
13+ function html_build_attributes ($ attr , callable $ callback = null )
1314 {
14- if (!count ($ attr )) {
15+ if (is_object ($ attr ) && !($ attr instanceof \Traversable)) {
16+ $ attr = get_object_vars ($ attr );
17+ }
18+
19+ if (!is_array ($ attr ) || !count ($ attr )) {
1520 return '' ;
1621 }
1722
You can’t perform that action at this time.
0 commit comments