function hocwp_get_term_drop_down($args = array()) { $defaults = array('hide_empty' => false, 'hide_if_empty' => true, 'hierarchical' => true, 'orderby' => 'NAME', 'show_count' => true, 'echo' => false, 'taxonomy' => 'category'); $args = wp_parse_args($args, $defaults); $select = wp_dropdown_categories($args); if (!empty($select)) { $required = hocwp_get_value_by_key($args, 'required', false); $autocomplete = (bool) hocwp_get_value_by_key($args, 'autocomplete', false); if ($required) { $select = hocwp_add_html_attribute('select', $select, 'required aria-required="true"'); } if (!$autocomplete) { $select = hocwp_add_html_attribute('select', $select, 'autocomplete="off"'); } } return $select; }
function hocwp_add_class_to_string($tag = '', $html, $class) { $search = 'class="'; if (empty($tag)) { $parts = explode(' ', $html); $tag = array_shift($parts); $tag = str_replace('<', '', $tag); } if (!hocwp_string_contain($html, $search)) { $class = 'class="' . $class . '"'; $html = hocwp_add_html_attribute($tag, $html, $class); } else { $class = 'class="' . $class . ' '; $html = str_replace($search, $class, $html); } return $html; }