WPDKHTMLTagSelect::selected PHP Method

selected() public static method

Commodity to extends selected() WordPress function with array check.
Since: 1.2.0
public static selected ( string | array $haystack, mixed $current ) : string
$haystack string | array Single value or array
$current mixed (true) The other value to compare if not just true
return string HTML attribute or empty string
    public static function selected($haystack, $current)
    {
        if (is_array($haystack)) {
            if (in_array($current, $haystack)) {
                $current = $haystack = 1;
                return selected($haystack, $current, false);
            }
            return false;
        }
        return selected($haystack, $current, false);
    }

Usage Example

Example #1
0
 /**
  * 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);
 }
All Usage Examples Of WPDKHTMLTagSelect::selected