/** * Commodity to extends selected() WordPress function with array check * * @param string|array $haystack Single value or array * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * * @return string html attribute or empty string * @deprecated Since 1.2.0 Use WPDKHTMLTagSelect::selected() instead */ function wpdk_selected($haystack, $current, $echo = true) { _deprecated_function(__FUNCTION__, '1.2.0', 'WPDKHTMLTagSelect::selected()'); return WPDKHTMLTagSelect::selected($haystack, $current); }
/** * Recursive method to build the options and option group for select tag. * Display the HTML markup for the option and optgroup tag. * * @brief Build the options * * @param array $options A key value pairs array. If the value is an array then an optio group is created. */ private function _options($options) { if (!empty($this->_first_item)) { ?> <option value="" disabled="disabled" selected="selected" style="display:none"><?php echo $this->_first_item; ?> </option> <?php } foreach ($options as $key => $option) { ?> <?php if (is_array($option)) { ?> <optgroup class="wpdk-form-optiongroup" label="<?php echo $key; ?> "> <?php $this->_options($option); ?> </optgroup> <?php } else { ?> <option class="wpdk-form-option" <?php if (!empty($this->value)) { echo WPDKHTMLTagSelect::selected($this->value, $key); } ?> value="<?php echo $key; ?> "><?php echo $option; ?> </option> <?php } ?> <?php } }