/** * Builds a set of options for displaying a year chooser * @param string the current date (optional) * @return string a set of HTML options with adjacent years (current year selected) */ public static function getYearOptions($date = "") { $years = TribeEventsViewHelpers::years(); $options = ''; if (empty($date)) { $year = date_i18n('Y'); if (date_i18n('n') == 12 && date_i18n('j') == 31) { $year++; } } else { $year = date('Y', strtotime($date)); } foreach ($years as $yearText) { if ($year == $yearText) { $selected = 'selected="selected"'; } else { $selected = ''; } $options .= "<option value='{$yearText}' {$selected}>{$yearText}</option>\n"; } return $options; }