$event_data = [];
// this section is for a sidebar events widget, typically on a front page
- if(isset($_REQUEST['date_string'])){
- $date = date_parse($_REQUEST['date_string']);
- $month = $date['month'];
- $year = $date['year'];
+ if( isset( $_REQUEST['date_string'] ) || isset($_REQUEST['all_events'] ) ){
$image_url = GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/';
- $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
- $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE YEAR(start_time) = $year AND MONTH(start_time) = $month AND active = 1 ORDER BY start_time ) LIMIT 3; ";
- $events = $wpdb->get_results($sql);
-
+ if(isset($_REQUEST['date_string'])){
+ $date = date_parse($_REQUEST['date_string']);
+ $month = $date['month'];
+ $year = $date['year'];
+
+
+ $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
+ $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE YEAR(start_time) = $year AND MONTH(start_time) = $month AND active = 1 ORDER BY start_time ) LIMIT 3; ";
+ $events = $wpdb->get_results($sql);
+
+
+ } else if(isset($_REQUEST['all_events'])){
+ $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX ."events WHERE status = 10 AND id IN (SELECT event FROM ";
+ $sql .= GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ORDER BY start_time ) LIMIT 3; ";
+ $events = $wpdb->get_results($sql);
+
+ }
foreach($events as $event){
$sql = "SELECT start_time, end_time FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE event = " . $event->id;
-
+
if($event->image !== ''){
$image = $image_url . $event->image;
} else {
$image = "none";
}
-
+
$date = $wpdb->get_results($sql);
$dates[] = $date[0];
$start_date = date('M d', strtotime($date[0]->start_time));
$end_date = date('M d', strtotime($date[0]->end_time));
$start_timestamp = strtotime($start_date);
$end_timestamp = strtotime($end_date);
-
+
$sidebar_events[$event->id] =
array(
"start_date" => $start_date,
// $events_date[$start_date] = array();
$arrayDates[date('F d D', strtotime($start_date))] = array();
}
-
+
function sortFunction( $event1, $event2 ) {
return strtotime($event1['start_date']) - strtotime($event2["start_date"]);
}
usort($sidebar_events, "sortFunction");
-
+
foreach($arrayDates as $key=>$date){
foreach($sidebar_events as $event){
if($event['timestamp'] === strtotime($key)){