/** * Convert the event recurrence meta into a human readable string * @param array $postId The recurring event * @return The human readable string */ public static function recurrenceToText($postId = null) { $text = ""; $custom_text = ""; $occurrence_text = ""; if ($postId == null) { global $post; $postId = $post->ID; } extract(TribeEventsRecurrenceMeta::getRecurrenceMeta($postId)); if ($recType == "Every Day") { $text = __("Every day", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d day", " for %d days", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); $custom_text = ""; } else { if ($recType == "Every Week") { $text = __("Every week", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d week", " for %d weeks", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recType == "Every Month") { $text = __("Every month", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d month", " for %d months", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recType == "Every Year") { $text = __("Every year", 'tribe-events-calendar-pro'); $occurrence_text = sprintf(_n(" for %d year", " for %d years", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recType == "Custom") { if ($recCustomType == "Daily") { $text = $recCustomInterval == 1 ? __("Every day", 'tribe-events-calendar-pro') : sprintf(__("Every %d days", 'tribe-events-calendar-pro'), $recCustomInterval); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recCustomType == "Weekly") { $text = $recCustomInterval == 1 ? __("Every week", 'tribe-events-calendar-pro') : sprintf(__("Every %d weeks", 'tribe-events-calendar-pro'), $recCustomInterval); $custom_text = sprintf(__(" on %s", 'tribe-events-calendar-pro'), self::daysToText($recCustomWeekDay)); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recCustomType == "Monthly") { $text = $recCustomInterval == 1 ? __("Every month", 'tribe-events-calendar-pro') : sprintf(__("Every %d months", 'tribe-events-calendar-pro'), $recCustomInterval); $number_display = is_numeric($recCustomMonthNumber) ? TribeDateUtils::numberToOrdinal($recCustomMonthNumber) : strtolower($recCustomMonthNumber); $custom_text = sprintf(__(" on the %s %s", 'tribe-events-calendar-pro'), $number_display, is_numeric($recCustomMonthNumber) ? __("day", 'tribe-events-calendar-pro') : self::daysToText($recCustomMonthDay)); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } else { if ($recCustomType == "Yearly") { $text = $recCustomInterval == 1 ? __("Every year", 'tribe-events-calendar-pro') : sprintf(__("Every %d years", 'tribe-events-calendar-pro'), $recCustomInterval); $customYearNumber = $recCustomYearMonthNumber != -1 ? TribeDateUtils::numberToOrdinal($recCustomYearMonthNumber) : __("last", 'tribe-events-calendar-pro'); $day = $recCustomYearFilter ? $customYearNumber : TribeDateUtils::numberToOrdinal(date('j', strtotime(TribeEvents::getRealStartDate($postId)))); $of_week = $recCustomYearFilter ? self::daysToText($recCustomYearMonthDay) : ""; $months = self::monthsToText($recCustomYearMonth); $custom_text = sprintf(__(" on the %s %s of %s", 'tribe-events-calendar-pro'), $day, $of_week, $months); $occurrence_text = sprintf(_n(", recurring %d time", ", recurring %d times", $recEndCount, 'tribe-events-calendar-pro'), $recEndCount); } } } } } } } } } // end text if ($recEndType == "On") { $endText = ' ' . sprintf(__(" until %s", 'tribe-events-calendar-pro'), date_i18n(get_option('date_format'), strtotime($recEnd))); } else { $endText = $occurrence_text; } return sprintf(__('%s%s%s', 'tribe-events-calendar-pro'), $text, $custom_text, $endText); }