/** * Builds a set of options for displaying a day chooser * @param int number of days in the month * @param string the current date (optional) * @return string a set of HTML options with all days (current day selected) */ public static function getDayOptions($date = "", $totalDays = 31) { $days = TribeEventsViewHelpers::days($totalDays); $options = ''; if (empty($date)) { $day = date_i18n('j'); if ($day == date_i18n('t')) { $day = '01'; } elseif ($day < 9) { $day = '0' . ($day + 1); } else { $day++; } } else { $day = date('d', strtotime($date)); } foreach ($days as $dayText) { if ($dayText < 10) { $dayText = "0" . $dayText; // need a leading zero in the day } if ($day == $dayText) { $selected = 'selected="selected"'; } else { $selected = ''; } $options .= "<option value='{$dayText}' {$selected}>{$dayText}</option>\n"; } return $options; }