date );
$date = mktime(12, 0, 0, $month, 1, $year); // 1st day of month as unix stamp
$daysInMonth = date("t", $date);
$monthView = events_by_month( $eventPosts, $spEvents->date );
$rawOffset = date("w", $date) - $startOfWeek;
$offset = ( $rawOffset < 0 ) ? $rawOffset + 7 : $rawOffset; // month begins on day x
$rows = 1;
$monthView = events_by_month( $eventPosts, $spEvents->date );
?>
daysOfWeek) + $startOfWeek; $n++ ) {
$dayOfWeek = ( $n >= 7 ) ? $n - 7 : $n;
echo '| ' . $spEvents->daysOfWeekShort[$dayOfWeek] . ' | ';
}
?>
";
}
// output this month
for( $day = 1; $day <= date("t", $date); $day++ ) {
if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
echo "
\n\t";
$rows++;
}
// Var'ng up days, months and years
$current_day = date_i18n( 'd' );
$current_month = date_i18n( 'm' );
$current_year = date_i18n( 'Y' );
if ( $current_month == $month && $current_year == $year) {
// Past, Present, Future class
if ($current_day == $day ) {
$ppf = ' tec-present';
} elseif ($current_day > $day) {
$ppf = ' tec-past';
} elseif ($current_day < $day) {
$ppf = ' tec-future';
}
} elseif ( $current_month > $month && $current_year == $year || $current_year > $year ) {
$ppf = ' tec-past';
} elseif ( $current_month < $month && $current_year == $year || $current_year < $year ) {
$ppf = ' tec-future';
} else { $ppf = false; }
echo "| " . display_day_title( $day, $monthView ) . "\n";
echo display_day( $day, $monthView );
echo " | ";
}
// skip next month
while( ($day + $offset) <= $rows * 7)
{
echo " | ";
$day++;
}
?>
";
if( !count( $monthView[$day] ) || count( $monthView[$day] ) < get_option( 'posts_per_page' ) ) {
$return .= $day;
} else {
global $post;
$return .= "$day";
$return .= "";
for( $i = 0; $i < count( $monthView[$day] ); $i++ ) {
$post = $monthView[$day][$i];
setup_postdata( $post );
$return .= '
' . get_the_title() . '
';
}
$return .= '';
$return .= '';
}
$return .= "";
return $return;
}
/**
* Each day in the calendar grid view will only display posts_per_page events.
* Each event will have a tooltip for more information on that event.
*/
function display_day( $day, $monthView ) {
global $post;
$output = '';
$posts_per_page = get_option( 'posts_per_page' );
for( $i = 0; $i < count( $monthView[$day] ) && $i < $posts_per_page; $i++ ) {
$post = $monthView[$day][$i];
setup_postdata( $post );
$eventId = $post->ID.'-'.$day;
$start = the_event_start_date( $post->ID );
$end = the_event_end_date( $post->ID );
$cost = the_event_cost( $post->ID );
$address = the_event_address( $post->ID );
$city = the_event_city( $post->ID );
$state = the_event_state( $post->ID );
$province = the_event_province( $post->ID );
$country = the_event_country( $post->ID );
?>
";
}
}
}