Event Calendar WD – Responsive Event Calendar plugin - Version 1.0.52

Version Description

Added: Mark all days of multi-day event option

Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 Event Calendar WD – Responsive Event Calendar plugin
Version 1.0.52
Comparing to
See all releases

Code changes from version 1.0.51 to 1.0.52

css/images/featured/arrow3.png DELETED
Binary file
css/images/featured/minus.png DELETED
Binary file
css/images/featured/plus.png DELETED
Binary file
ecwd.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Event Calendar WD
4
  * Plugin URI: https://web-dorado.com/products/wordpress-event-calendar-wd.html
5
  * Description: Event Calendar WD is an easy event management and planning tool with advanced features.
6
- * Version: 1.0.51
7
  * Author: WebDorado
8
  * Author URI: http://web-dorado.com
9
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
3
  * Plugin Name: Event Calendar WD
4
  * Plugin URI: https://web-dorado.com/products/wordpress-event-calendar-wd.html
5
  * Description: Event Calendar WD is an easy event management and planning tool with advanced features.
6
+ * Version: 1.0.52
7
  * Author: WebDorado
8
  * Author URI: http://web-dorado.com
9
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
ecwd_admin_class.php CHANGED
@@ -6,7 +6,7 @@
6
  class ECWD_Admin {
7
 
8
  protected static $instance = null;
9
- protected $version = '1.0.51';
10
  protected $ecwd_page = null;
11
  protected $notices = null;
12
 
6
  class ECWD_Admin {
7
 
8
  protected static $instance = null;
9
+ protected $version = '1.0.52';
10
  protected $ecwd_page = null;
11
  protected $notices = null;
12
 
ecwd_class.php CHANGED
@@ -6,7 +6,7 @@
6
  */
7
  class ECWD {
8
 
9
- protected $version = '1.0.51';
10
  protected $plugin_name = 'event-calendar-wd';
11
  protected $prefix = 'ecwd';
12
  protected static $instance = null;
6
  */
7
  class ECWD {
8
 
9
+ protected $version = '1.0.52';
10
  protected $plugin_name = 'event-calendar-wd';
11
  protected $prefix = 'ecwd';
12
  protected static $instance = null;
includes/calendar-class.php CHANGED
@@ -223,11 +223,13 @@ class Calendar {
223
  }
224
 
225
  public function addEvent($arr) {
226
-
227
-
228
  $this->events[] = $arr;
229
  }
230
 
 
 
 
 
231
  // next month link
232
 
233
  public function dateDiff($beginDate, $endDate) {
@@ -251,7 +253,11 @@ class Calendar {
251
 
252
  public function showcal() {
253
  global $cal_ID;
 
254
  $html = '';
 
 
 
255
  $html .= $this->calendar_head(); // set table head
256
  $this->seted_days = array();
257
  if (!in_array($this->displaytype, array(
@@ -261,8 +267,7 @@ class Calendar {
261
  'day',
262
  ))
263
  ) { // mini and full cal
264
- $html .= '
265
- <tr>';
266
 
267
  // render week number on left
268
  if ($this->weeknumbers == 'left' && $this->monthstartday != $this->weekstartday) {
@@ -368,7 +373,12 @@ class Calendar {
368
  $html .= '</ul>';
369
  } else { // event list and map
370
  if (count($this->events) > 0) {
371
- //$this->events = $this->arraySort($this->events, 'from');
 
 
 
 
 
372
  }
373
  if ($this->displaytype == 'map') {
374
 
@@ -376,127 +386,143 @@ class Calendar {
376
  $pages = 0;
377
  $page = $this->page;
378
  $html .= '<ul class="ecwd_list">';
379
- if ($this->listlimit !== false && $this->listlimit != 0) {
380
- $offset = ( $page - 1 ) * $this->listlimit;
381
- $pages = ceil(count($this->events) / $this->listlimit);
382
- $this->events = array_slice($this->events, $offset, $this->listlimit);
 
 
 
 
383
  }
384
- foreach ($this->events as $event) {
385
- if (strtotime($event['from']) >= strtotime($this->year . '-' . $this->month . '-1') &&
386
- strtotime($event['from']) <= strtotime(date('Y-m-t', strtotime($this->date)))) {
387
- if ($this->displaytype == 'list') { // full event list
388
- $image_class = '';
389
- $image = $this->getAndReplaceFirstImage($event['details']);
390
- if (!has_post_thumbnail($event['id']) && $event['image'] == "") {
391
- $image_class = "ecwd-no-image";
392
- }
393
- $html .= '<li class="' . $image_class . '" itemscope itemtype="http://schema.org/Event">';
394
- if (!$this->widget) {
395
 
396
-
397
- $html .= '<div class="ecwd-list-date resp" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', strtotime($event['starttime'])) . '">' . __(date('d', strtotime($event['from'])), 'ecwd') . '</div>';
398
- $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, strtotime($event['from'])) : (date('d', strtotime($event['from'])) . '.' . __(date('F', strtotime($event['from'])), 'ecwd') . '.' . __(date('l', strtotime($event['from'])), 'ecwd')));
399
- if ($this->list_date_format !== 'd.F.l') {
400
- $month_name = date('F', strtotime($event['from']));
401
- $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
402
- }
403
-
404
-
405
- $html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container"><div class="ecwd-list-date web">' . $event_date . '</div>';
406
-
407
- $html .= '<div class="ecwd-img">';
408
- if (get_the_post_thumbnail($event['id']) || $event['image']) {
409
- if (get_the_post_thumbnail($event['id'])) {
410
- $html .= get_the_post_thumbnail($event['id']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  } else {
412
- $html .= '<img src="' . $event['image'] . '" />';
413
  }
414
- } elseif ($image['image'] != null) {
415
- $html .= '<img src="' . $image['image'] . '" />';
416
- $event['details'] = $image['content'];
417
- }
418
- $html .= '</div></div></div>';
419
- } else {
420
- $html .= '<div class="ecwd-list-date" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', strtotime($event['starttime'])) . '">' . __(date('d', strtotime($event['from'])), 'ecwd') . '</div>';
421
- }
422
- $html .= '<div class="event-main-content">';
423
- if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
424
- $html .= '<h3 class="event-title" itemprop="name"><span class="ecwd_open_event_popup event' . $event['id'] . '" style="color:' . $event['color'] . ';">' . $event['title'] . '</span></h3>';
425
- } else if ($event['permalink'] != '') {
426
- $html .= '<h3 class="event-title" itemprop="name"><a href="' . $event['permalink'] . '" ' . $this->eventlinktarget . ' itemprop="url" style="color:' . $event['color'] . ';">' . $event['title'] . '</a></h3>';
427
- } else {
428
- $html .= '<h3 class="event-title" style="color:' . $event['color'] . ';" itemprop="name">' . $event['title'] . '</h3>';
429
- }
430
- $html .= '<div class="ecwd-list-date-cont">';
431
 
432
- if (isset($event['all_day_event']) && $event['all_day_event'] == 1) {
433
- $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . __('All day', 'ecwd');
434
- $eventtime .= '</span>';
435
- $eventtime .= '</div>';
436
- } else {
437
- if ($event['starttime'] != '') { // event details - hidden until clicked (full)
438
- $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . date($this->timeformat, strtotime($event['starttime']));
439
- if ($event['endtime'] != '' && strtotime($event['endtime']) != strtotime($event['starttime'])) {
440
- $eventtime .= "-" . date($this->timeformat, strtotime($event['endtime']));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  }
442
- $eventtime .= '</span>';
443
- $eventtime .= '</div>';
444
- }
445
- }
446
- $html .= $eventtime;
447
- if ($event['from'] != '') { // event details - hidden until clicked (full)
448
- $eventdate = '<div class="ecwd-date"><span class="metainfo"> ' . date($this->dateformat, strtotime($event['from']));
449
- if ($event['to'] != '' && strtotime($event['to']) !== strtotime($event['from'])) {
450
- $eventdate .= "-" . date($this->dateformat, strtotime($event['to']));
451
- }
452
- $eventdate .= '</span>';
453
- $eventdate .= '</div>';
454
- $html .= $eventdate;
455
- }
456
- $html .= '</div>';
457
- if (isset($event['organizers']) && count($event['organizers']) > 0) {
458
- $html .= '<div class="event-organizers"><div class="ecwd-org-cont">';
459
- foreach ($event['organizers'] as $organizer) {
460
- $html .= '<div class="event-organizer" itemprop="organizer"> <a href="' . $organizer['permalink'] . '">' . $organizer['name'] . '</a></div>';
461
- }
462
- $html .= '</div></div>';
463
- }
464
 
465
- if ($event['location'] !== '') {
466
- $html .= '<div class="event-venue" itemprop="location" itemscope itemtype="http://schema.org/Place"><div class="ecwd-org-cont">
467
  <span itemprop="name">';
468
- if (isset($event['venue']['name'])) {
469
- $html .= '<a href="' . $event['venue']['permalink'] . '">' . $event['venue']['name'] . '</a>';
470
- }
471
- $html .= '</span>
472
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
473
  ' . ( $event['location'] ? $event['location'] : "" ) . '
474
  </div>
475
  </div>
476
  </div>';
477
- }
478
- $html .= '<div class="event-content" itemprop="description">' . ( $event['details'] ? $event['details'] : $this->eventemptytext ) . '</div></div>';
479
- } else { // mini event list
480
- $html .= '<li style="background:' . $event['color'] . ';"';
481
- if ($this->minilinkbase !== false) { // enable link (good for linking to full calendar)
482
- $html .= ' class="event-link"';
483
- if ($this->linktarget == '_blank') {
484
- $html .= ' onClick="window.open(\'' . $this->minilinkbase . '\', \'_blank\')"';
485
- } else {
486
- $html .= ' onClick="' . $this->linktarget . '.location=\'' . $this->minilinkbase . '\'"';
487
- }
488
- } else if ($event['link'] != '') { // enable link (links to event url)
489
- $html .= ' class="event-link"';
490
- if ($this->linktarget == '_blank') {
491
- $html .= 'onClick="window.open(\'' . $event['link'] . '\', \'_blank\')"';
492
- } else {
493
- $html .= ' onClick="' . $this->linktarget . '.location=\'' . $event['link'] . '\'"';
 
 
494
  }
 
495
  }
 
496
  }
497
- $html .= '</li>';
498
  }
499
  }
 
 
 
 
 
 
500
  if (count($this->events) <= 0) { // if events array is empty
501
  $html .= '<li >';
502
  $html .= '<div class="event-content">' . __('No Events', 'ecwd') . '</div>';
@@ -504,7 +530,6 @@ class Calendar {
504
  }
505
 
506
  $html .= '</ul>';
507
-
508
  ///PAGINATION////
509
  if ($pages > 1) {
510
  $html .= '<div class="ecwd-pagination">';
@@ -802,6 +827,7 @@ class Calendar {
802
  $html .= '<div class="type">' . '<a href="?date=' . $this->displaysName[$display]['date'] . '&t=' . $display . '" rel="noindex, nofollow">' . $this->displaysName[$display]['name'] . '</a>' . '</div>';
803
  }
804
  }
 
805
  $html .= '</div></div>';
806
  } else {
807
  $html = ' <div class="ecwd_calendar_view_tabs cal_tabs_' . $this->color . '" >';
@@ -845,7 +871,7 @@ class Calendar {
845
  // returns month from passed date (string), $type: 0=number,1=full(January,February,etc),2=abbreviation(Jan,Feb,etc)
846
 
847
  public function calendar_cell($day, $class, $date = '', $style = '') {
848
- global $cal_ID;
849
 
850
  $addclass = '';
851
 
@@ -854,13 +880,24 @@ class Calendar {
854
  } else {
855
  $tag = 'td';
856
  }
857
-
858
  if ($day != '') {
859
  $bgColor = '';
860
  $cellevents = array();
861
-
862
- if (is_array($this->events)) { // events array populated from addEvent()
863
- foreach ($this->events as $event) {
 
 
 
 
 
 
 
 
 
 
 
 
864
  $color = $event['color'];
865
  $title = $event['title'];
866
  $link = $event['link'];
@@ -877,10 +914,9 @@ class Calendar {
877
  $all_day_event = $event['all_day_event'];
878
  $permalink = $event['permalink'];
879
  $image = $event['image'];
880
-
881
  $id = $event['id'];
882
 
883
-
884
  if ($date == date('Y-n-j', strtotime($eventdate))) {
885
  $cellevents[] = array(
886
  'color' => $color,
@@ -895,6 +931,7 @@ class Calendar {
895
  'details' => $details,
896
  'location' => $location,
897
  'all_day_event' => $all_day_event,
 
898
  'terms' => $terms,
899
  'venue' => $venue,
900
  'organizers' => $organizers,
@@ -905,6 +942,8 @@ class Calendar {
905
  }
906
  }
907
 
 
 
908
  // sort by starttime for the cell
909
  if (count($cellevents) > 0) {
910
  $cellevents = $this->arraySort($cellevents, 'starttime');
@@ -950,11 +989,10 @@ class Calendar {
950
  if ($this->displaytype == 'mini') {
951
  $content = $day;
952
  } elseif ($this->widget && $this->displaytype != 'mini') {
953
- $content = '<div class="ecwd-week-date">' . __(date('d', strtotime($date)), 'ecwd') . '</div>';
954
  } elseif (( $this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day' ) && !$this->widget) {
955
-
956
  //here
957
- $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, strtotime($date)) : (date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd')));
958
  if ($this->list_date_format !== 'd.F.l') {
959
  $month_name = date('F', strtotime($date));
960
  $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
@@ -975,7 +1013,7 @@ class Calendar {
975
  if ($i > 2 && $this->displaytype !== 'mini') {
976
  $li_class = 'inmore';
977
  }
978
-
979
  $eventcontent .= '<li itemscope itemtype="http://schema.org/Event" style="';
980
  if (is_array($cellevent['terms'])) {
981
  if (isset($cellevent['color']) && $cellevent['color'] !== '') {
@@ -996,7 +1034,8 @@ class Calendar {
996
  } */
997
  }
998
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
999
- $eventcontent .= '<span class="ecwd_open_event_popup event' . $cellevent['id'] . '" itemprop="name">' . $cellevent['title'] . '</span>';
 
1000
  } elseif ($cellevent['permalink']) {
1001
  $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . '><span itemprop="name">' . $cellevent['title'] . '</span></a>';
1002
  } else {
@@ -1014,7 +1053,7 @@ class Calendar {
1014
  $eventcontent .= ' <span class="event-metalabel" style="background:' . $cellevent['color'] . '"></span>
1015
  <h5 style="color:' . $cellevent['color'] . '" itemprop="name">';
1016
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1017
- $eventcontent .= '<span class="ecwd_open_event_popup event' . $cellevent['id'] . '" style="color: ' . $cellevent['color'] . '">' . $cellevent['title'] . '</span>';
1018
  } else if (isset($cellevent['permalink']) && $cellevent['permalink'] !== '') {
1019
  $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . ' style="color: ' . $cellevent['color'] . '">' . $cellevent['title'] . '</a>';
1020
  } else {
@@ -1026,7 +1065,7 @@ class Calendar {
1026
  $eventcontent .= ' <span class="event-metalabel"></span>
1027
  <h5 itemprop="name">';
1028
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1029
- $eventcontent .= '<span class="ecwd_open_event_popup event' . $cellevent['id'] . '">' . $cellevent['title'] . '</span>';
1030
  } else if (isset($cellevent['permalink']) && $cellevent['permalink'] !== '') {
1031
  $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . '>' . $cellevent['title'] . '</a>';
1032
  } else {
@@ -1099,13 +1138,11 @@ class Calendar {
1099
  $eventcontent .= '<img src="' . $image['image'] . '" />';
1100
  $cellevent['details'] = $image['content'];
1101
  }
 
1102
  $eventcontent .= $cellevent['details'] . '</div>';
1103
  }
1104
 
1105
-
1106
  $eventcontent .= '</div><div class="ecwd-event-arrow-right"></div>';
1107
-
1108
-
1109
  $eventcontent .= '</li> ';
1110
 
1111
 
@@ -1132,11 +1169,8 @@ class Calendar {
1132
 
1133
 
1134
  if ($this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day') {
1135
-
1136
  if (count($cellevents) > 0) {
1137
-
1138
  $html = '';
1139
-
1140
  if (!$this->widget) {
1141
  $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, strtotime($date)) : (date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd')));
1142
  if ($this->list_date_format !== 'd.F.l') {
@@ -1145,7 +1179,6 @@ class Calendar {
1145
  }
1146
 
1147
 
1148
-
1149
  $html = '<div class="ecwd-week-date resp" style="background:#' . $this->eventlistbg . '" itemprop="startDate" content="' . date('Y-m-d', strtotime($date)) . 'T' . date('H:i', strtotime($date)) . '">' . date('d', strtotime($date)) . '</div><div class="ecwd-week-date web"">' . $event_date . '</div>';
1150
  } else {
1151
  $html = '<div class="ecwd-week-date">' . date('d', strtotime($date)) . '</div>';
@@ -1177,7 +1210,7 @@ class Calendar {
1177
  $html .= '</div></div></div>';
1178
  }
1179
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1180
- $html .= '<h3 class="event-title" itemprop="name"><span class="ecwd_open_event_popup event' . $cellevent['id'] . '"';
1181
  if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1182
  $html .= ' style="color:' . $cellevent['color'] . ';"';
1183
  }
@@ -1236,7 +1269,7 @@ class Calendar {
1236
  <span itemprop="name">';
1237
  if (isset($cellevent['venue']['name'])) {
1238
  $html .= '<a href="' . $cellevent['venue']['permalink'] . '">' . $cellevent['venue']['name'] . '</a>';
1239
- }
1240
  $html .= '</span>
1241
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
1242
  <span itemprop="streetAddress">' . $cellevent['location'] . '</span>
@@ -1262,6 +1295,7 @@ class Calendar {
1262
  }
1263
 
1264
  public function arraySort($a, $subkey) {
 
1265
  foreach ($a as $k => $v) {
1266
  $b[$k] = strtolower($v[$subkey]);
1267
  }
@@ -1269,7 +1303,6 @@ class Calendar {
1269
  foreach ($b as $key => $val) {
1270
  $c[] = $a[$key];
1271
  }
1272
-
1273
  return $c;
1274
  }
1275
 
@@ -1403,6 +1436,13 @@ class Calendar {
1403
  return $content;
1404
  }
1405
 
 
 
 
 
 
 
 
1406
  }
1407
 
1408
  // end class
223
  }
224
 
225
  public function addEvent($arr) {
 
 
226
  $this->events[] = $arr;
227
  }
228
 
229
+ public function addEvents($arr) {
230
+ $this->events = $arr;
231
+ }
232
+
233
  // next month link
234
 
235
  public function dateDiff($beginDate, $endDate) {
253
 
254
  public function showcal() {
255
  global $cal_ID;
256
+ global $ecwd_options;
257
  $html = '';
258
+ $start_date = strtotime($this->year . '-' . $this->month . '-1');
259
+ $end_date = date('Y-m-t', strtotime($this->date));
260
+
261
  $html .= $this->calendar_head(); // set table head
262
  $this->seted_days = array();
263
  if (!in_array($this->displaytype, array(
267
  'day',
268
  ))
269
  ) { // mini and full cal
270
+ $html .= '<tr>';
 
271
 
272
  // render week number on left
273
  if ($this->weeknumbers == 'left' && $this->monthstartday != $this->weekstartday) {
373
  $html .= '</ul>';
374
  } else { // event list and map
375
  if (count($this->events) > 0) {
376
+ // $events = array();
377
+ // foreach ($this->events as $date_events){
378
+ // $events[] = $date_events;
379
+ // }
380
+ //
381
+ // $this->events= $events;// = $this->arraySort($this->events, 'from');
382
  }
383
  if ($this->displaytype == 'map') {
384
 
386
  $pages = 0;
387
  $page = $this->page;
388
  $html .= '<ul class="ecwd_list">';
389
+ $page_index = 0;
390
+ $ev_counts = 0;
391
+
392
+ $events_for_list = $this->events;
393
+ if (!isset($ecwd_options['long_events']) || (isset($ecwd_options['long_events']) && $ecwd_options['long_events'] == '0')) {
394
+ $events_for_list = array(
395
+ $start_date => $events_for_list,
396
+ );
397
  }
 
 
 
 
 
 
 
 
 
 
 
398
 
399
+ foreach ($events_for_list as $date_key => $events) {
400
+ foreach ($events as $event) {
401
+ if ($date_key >= $start_date && $date_key <= strtotime($end_date)) {
402
+ if ($page_index >= $page * $this->listlimit) {
403
+ break 1;
404
+ }
405
+ if ($page_index >= (($page - 1) * $this->listlimit)) {
406
+ if ($this->displaytype == 'list') { // full event list
407
+ $image_class = '';
408
+ $image = $this->getAndReplaceFirstImage($event['details']);
409
+ if (!has_post_thumbnail($event['id']) && $event['image'] == "") {
410
+ $image_class = "ecwd-no-image";
411
+ }
412
+ $html .= '<li class="' . $image_class . '" itemscope itemtype="http://schema.org/Event">';
413
+ if (!$this->widget) {
414
+ $html .= '<div class="ecwd-list-date resp" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', $date_key) . '">' . __(date('d', $date_key), 'ecwd') . '</div>';
415
+ //$html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container"><div class="ecwd-list-date web">' . date('d', strtotime($event['from'])) . '.' . __(date('F', strtotime($event['from'])), 'ecwd') . '.' . __(date('l', strtotime($event['from'])), 'ecwd') . '</div>';
416
+ $event_date = ( ( $this->list_date_format !== 'd.F.l' ) ? date($this->list_date_format, $date_key) : ( date('d', $date_key) . '.' . __(date('F', $date_key), 'ecwd') . '.' . __(date('l', $date_key), 'ecwd') ) );
417
+ if ($this->list_date_format !== 'd.F.l') {
418
+ $month_name = date('F', strtotime($event['from']));
419
+ $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
420
+ }
421
+
422
+
423
+ $html .= '<div class="ecwd-list-img"><div class="ecwd-list-img-container"><div class="ecwd-list-date web">' . $event_date . '</div>';
424
+ $html .= '<div class="ecwd-img">';
425
+ if (get_the_post_thumbnail($event['id']) || $event['image']) {
426
+ if (get_the_post_thumbnail($event['id'])) {
427
+ $html .= get_the_post_thumbnail($event['id']);
428
+ } else {
429
+ $html .= '<img src="' . $event['image'] . '" />';
430
+ }
431
+ } elseif ($image['image'] != null) {
432
+ $html .= '<img src="' . $image['image'] . '" />';
433
+ $event['details'] = $image['content'];
434
+ }
435
+ $html .= '</div></div></div>';
436
  } else {
437
+ $html .= '<div class="ecwd-list-date" itemprop="startDate" content="' . date('Y-m-d', strtotime($event['from'])) . 'T' . date('H:i', strtotime($event['starttime'])) . '">' . __(date('d', strtotime($event['from'])), 'ecwd') . '</div>';
438
  }
439
+ $html .= '<div class="event-main-content">';
440
+ if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
441
+ $html .= '<h3 class="event-title" itemprop="name"><span start-date-data="' . $event['from'] . '" class="ecwd_open_event_popup event' . $event['id'] . '" style="color:' . $event['color'] . ';">' . $event['title'] . '</span></h3>';
442
+ } else if ($event['permalink'] != '') {
443
+ $html .= '<h3 class="event-title" itemprop="name"><a href="' . $event['permalink'] . '" ' . $this->eventlinktarget . ' itemprop="url" style="color:' . $event['color'] . ';">' . $event['title'] . '</a></h3>';
444
+ } else {
445
+ $html .= '<h3 class="event-title" style="color:' . $event['color'] . ';" itemprop="name">' . $event['title'] . '</h3>';
446
+ }
447
+ $html .= '<div class="ecwd-list-date-cont">';
 
 
 
 
 
 
 
 
448
 
449
+ if (isset($event['all_day_event']) && $event['all_day_event'] == 1) {
450
+ $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . __('All day', 'ecwd');
451
+ $eventtime .= '</span>';
452
+ $eventtime .= '</div>';
453
+ } else {
454
+ if ($event['starttime'] != '') { // event details - hidden until clicked (full)
455
+ $eventtime = '<div class="ecwd-time"><span class="metainfo"> ' . date($this->timeformat, strtotime($event['starttime']));
456
+ if ($event['endtime'] != '' && strtotime($event['endtime']) != strtotime($event['starttime'])) {
457
+ $eventtime .= "-" . date($this->timeformat, strtotime($event['endtime']));
458
+ }
459
+ $eventtime .= '</span>';
460
+ $eventtime .= '</div>';
461
+ }
462
+ }
463
+ $html .= $eventtime;
464
+ if ($event['from'] != '') { // event details - hidden until clicked (full)
465
+ $eventdate = '<div class="ecwd-date"><span class="metainfo"> ' . date($this->dateformat, strtotime($event['from']));
466
+ if ($event['to'] != '' && strtotime($event['to']) !== strtotime($event['from'])) {
467
+ $eventdate .= "-" . date($this->dateformat, strtotime($event['to']));
468
+ }
469
+ $eventdate .= '</span>';
470
+ $eventdate .= '</div>';
471
+ $html .= $eventdate;
472
+ }
473
+ $html .= '</div>';
474
+ if (isset($event['organizers']) && count($event['organizers']) > 0) {
475
+ $html .= '<div class="event-organizers"><div class="ecwd-org-cont">';
476
+ foreach ($event['organizers'] as $organizer) {
477
+ $html .= '<div class="event-organizer" itemprop="organizer"> <a href="' . $organizer['permalink'] . '">' . $organizer['name'] . '</a></div>';
478
+ }
479
+ $html .= '</div></div>';
480
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
 
482
+ if ($event['location'] !== '') {
483
+ $html .= '<div class="event-venue" itemprop="location" itemscope itemtype="http://schema.org/Place"><div class="ecwd-org-cont">
484
  <span itemprop="name">';
485
+ if (isset($event['venue']['name'])) {
486
+ $html .= '<a href="' . $event['venue']['permalink'] . '">' . $event['venue']['name'] . '</a>';
487
+ }
488
+ $html .= '</span>
489
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
490
  ' . ( $event['location'] ? $event['location'] : "" ) . '
491
  </div>
492
  </div>
493
  </div>';
494
+ }
495
+ $html .= '<div class="event-content" itemprop="description">' . ( $event['details'] ? $event['details'] : $this->eventemptytext ) . '</div></div>';
496
+ } else { // mini event list
497
+ $html .= '<li style="background:' . $event['color'] . ';"';
498
+ if ($this->minilinkbase !== false) { // enable link (good for linking to full calendar)
499
+ $html .= ' class="event-link"';
500
+ if ($this->linktarget == '_blank') {
501
+ $html .= ' onClick="window.open(\'' . $this->minilinkbase . '\', \'_blank\')"';
502
+ } else {
503
+ $html .= ' onClick="' . $this->linktarget . '.location=\'' . $this->minilinkbase . '\'"';
504
+ }
505
+ } else if ($event['link'] != '') { // enable link (links to event url)
506
+ $html .= ' class="event-link"';
507
+ if ($this->linktarget == '_blank') {
508
+ $html .= 'onClick="window.open(\'' . $event['link'] . '\', \'_blank\')"';
509
+ } else {
510
+ $html .= ' onClick="' . $this->linktarget . '.location=\'' . $event['link'] . '\'"';
511
+ }
512
+ }
513
  }
514
+ $html .= '</li>';
515
  }
516
+ $page_index++;
517
  }
 
518
  }
519
  }
520
+
521
+ if ($this->listlimit !== false && $this->listlimit != 0) {
522
+ $offset = ( $page - 1 ) * $this->listlimit;
523
+ $pages = ceil($ev_counts / $this->listlimit);
524
+ }
525
+
526
  if (count($this->events) <= 0) { // if events array is empty
527
  $html .= '<li >';
528
  $html .= '<div class="event-content">' . __('No Events', 'ecwd') . '</div>';
530
  }
531
 
532
  $html .= '</ul>';
 
533
  ///PAGINATION////
534
  if ($pages > 1) {
535
  $html .= '<div class="ecwd-pagination">';
827
  $html .= '<div class="type">' . '<a href="?date=' . $this->displaysName[$display]['date'] . '&t=' . $display . '" rel="noindex, nofollow">' . $this->displaysName[$display]['name'] . '</a>' . '</div>';
828
  }
829
  }
830
+
831
  $html .= '</div></div>';
832
  } else {
833
  $html = ' <div class="ecwd_calendar_view_tabs cal_tabs_' . $this->color . '" >';
871
  // returns month from passed date (string), $type: 0=number,1=full(January,February,etc),2=abbreviation(Jan,Feb,etc)
872
 
873
  public function calendar_cell($day, $class, $date = '', $style = '') {
874
+ global $cal_ID, $ecwd_options;
875
 
876
  $addclass = '';
877
 
880
  } else {
881
  $tag = 'td';
882
  }
 
883
  if ($day != '') {
884
  $bgColor = '';
885
  $cellevents = array();
886
+ if (!$date && is_int($day)) {
887
+ $date = $this->year . '-' . $this->month . '-' . $day;
888
+ }
889
+ if (isset($ecwd_options["long_events"]) && $ecwd_options["long_events"]) {
890
+ if (isset($this->events[strtotime($date)])) {
891
+ $all_events = array_reverse($this->events[strtotime($date)]);
892
+ } else {
893
+ $all_events = array();
894
+ }
895
+ } else {
896
+ $all_events = $this->events;
897
+ }
898
+ if (is_array($all_events) && $date) { // events array populated from addEvent()
899
+ foreach ($all_events as $event) {
900
+ //echo $event['from'].'------'.$event['title'].'<br />';
901
  $color = $event['color'];
902
  $title = $event['title'];
903
  $link = $event['link'];
914
  $all_day_event = $event['all_day_event'];
915
  $permalink = $event['permalink'];
916
  $image = $event['image'];
917
+ $latlong = $event['latlong'];
918
  $id = $event['id'];
919
 
 
920
  if ($date == date('Y-n-j', strtotime($eventdate))) {
921
  $cellevents[] = array(
922
  'color' => $color,
931
  'details' => $details,
932
  'location' => $location,
933
  'all_day_event' => $all_day_event,
934
+ 'latlong' => $latlong,
935
  'terms' => $terms,
936
  'venue' => $venue,
937
  'organizers' => $organizers,
942
  }
943
  }
944
 
945
+
946
+
947
  // sort by starttime for the cell
948
  if (count($cellevents) > 0) {
949
  $cellevents = $this->arraySort($cellevents, 'starttime');
989
  if ($this->displaytype == 'mini') {
990
  $content = $day;
991
  } elseif ($this->widget && $this->displaytype != 'mini') {
992
+ $content = '<div class="ecwd-week-date">' . date('d', strtotime($date)) . '</div>';
993
  } elseif (( $this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day' ) && !$this->widget) {
 
994
  //here
995
+ $event_date = ( ( $this->list_date_format !== 'd.F.l' ) ? date($this->list_date_format, strtotime($date)) : ( date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd') ) );
996
  if ($this->list_date_format !== 'd.F.l') {
997
  $month_name = date('F', strtotime($date));
998
  $event_date = str_replace($month_name, __($month_name, 'ecwd'), $event_date);
1013
  if ($i > 2 && $this->displaytype !== 'mini') {
1014
  $li_class = 'inmore';
1015
  }
1016
+ //var_dump($cellevent);
1017
  $eventcontent .= '<li itemscope itemtype="http://schema.org/Event" style="';
1018
  if (is_array($cellevent['terms'])) {
1019
  if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1034
  } */
1035
  }
1036
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1037
+
1038
+ $eventcontent .= '<span start-date-data="' . $event['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '" itemprop="name">' . $cellevent['title'] . '</span>';
1039
  } elseif ($cellevent['permalink']) {
1040
  $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . '><span itemprop="name">' . $cellevent['title'] . '</span></a>';
1041
  } else {
1053
  $eventcontent .= ' <span class="event-metalabel" style="background:' . $cellevent['color'] . '"></span>
1054
  <h5 style="color:' . $cellevent['color'] . '" itemprop="name">';
1055
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1056
+ $eventcontent .= '<span start-date-data="' . $cellevent['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '">' . $cellevent['title'] . '</span>';
1057
  } else if (isset($cellevent['permalink']) && $cellevent['permalink'] !== '') {
1058
  $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . ' style="color: ' . $cellevent['color'] . '">' . $cellevent['title'] . '</a>';
1059
  } else {
1065
  $eventcontent .= ' <span class="event-metalabel"></span>
1066
  <h5 itemprop="name">';
1067
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1068
+ $eventcontent .= '<span start-date-data="' . $cellevent['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '">' . $cellevent['title'] . '</span>';
1069
  } else if (isset($cellevent['permalink']) && $cellevent['permalink'] !== '') {
1070
  $eventcontent .= '<a href="' . $cellevent['permalink'] . '" ' . $this->eventlinktarget . '>' . $cellevent['title'] . '</a>';
1071
  } else {
1138
  $eventcontent .= '<img src="' . $image['image'] . '" />';
1139
  $cellevent['details'] = $image['content'];
1140
  }
1141
+
1142
  $eventcontent .= $cellevent['details'] . '</div>';
1143
  }
1144
 
 
1145
  $eventcontent .= '</div><div class="ecwd-event-arrow-right"></div>';
 
 
1146
  $eventcontent .= '</li> ';
1147
 
1148
 
1169
 
1170
 
1171
  if ($this->displaytype == 'week' || $this->displaytype == 'day' || $this->displaytype == '4day') {
 
1172
  if (count($cellevents) > 0) {
 
1173
  $html = '';
 
1174
  if (!$this->widget) {
1175
  $event_date = (($this->list_date_format !== 'd.F.l') ? date($this->list_date_format, strtotime($date)) : (date('d', strtotime($date)) . '.' . __(date('F', strtotime($date)), 'ecwd') . '.' . __(date('l', strtotime($date)), 'ecwd')));
1176
  if ($this->list_date_format !== 'd.F.l') {
1179
  }
1180
 
1181
 
 
1182
  $html = '<div class="ecwd-week-date resp" style="background:#' . $this->eventlistbg . '" itemprop="startDate" content="' . date('Y-m-d', strtotime($date)) . 'T' . date('H:i', strtotime($date)) . '">' . date('d', strtotime($date)) . '</div><div class="ecwd-week-date web"">' . $event_date . '</div>';
1183
  } else {
1184
  $html = '<div class="ecwd-week-date">' . date('d', strtotime($date)) . '</div>';
1210
  $html .= '</div></div></div>';
1211
  }
1212
  if ($this->event_popup == "yes" && get_post_meta($event['id'], '', true)) {
1213
+ $html .= '<h3 class="event-title" itemprop="name"><span start-date-data="' . $cellevent['date'] . '" class="ecwd_open_event_popup event' . $cellevent['id'] . '"';
1214
  if (isset($cellevent['color']) && $cellevent['color'] !== '') {
1215
  $html .= ' style="color:' . $cellevent['color'] . ';"';
1216
  }
1269
  <span itemprop="name">';
1270
  if (isset($cellevent['venue']['name'])) {
1271
  $html .= '<a href="' . $cellevent['venue']['permalink'] . '">' . $cellevent['venue']['name'] . '</a>';
1272
+ }
1273
  $html .= '</span>
1274
  <div class="address" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
1275
  <span itemprop="streetAddress">' . $cellevent['location'] . '</span>
1295
  }
1296
 
1297
  public function arraySort($a, $subkey) {
1298
+
1299
  foreach ($a as $k => $v) {
1300
  $b[$k] = strtolower($v[$subkey]);
1301
  }
1303
  foreach ($b as $key => $val) {
1304
  $c[] = $a[$key];
1305
  }
 
1306
  return $c;
1307
  }
1308
 
1436
  return $content;
1437
  }
1438
 
1439
+ public function cal_days_in_month() {
1440
+ $date_str = $this->year . '-' . $this->month . '-01';
1441
+ $date = date('t', strtotime($date_str));
1442
+
1443
+ return intval($date);
1444
+ }
1445
+
1446
  }
1447
 
1448
  // end class
includes/ecwd-display-class.php CHANGED
@@ -5,1037 +5,1283 @@
5
  */
6
  class ECWD_Display {
7
 
8
- private $merged_events, $goole_events, $date, $month, $year, $day;
9
  public $events;
10
 
11
- public function __construct( $ids, $title_text = null, $sort_order = 'asc', $date = '', $page = 1, $search_params = array(), $displays = null, $filters = null, $page_items = 5, $event_search = 'yes', $display = '',$ecwd_views = array() ) {
12
- $this->id = $ids;
13
- $this->title = $title_text;
14
- $this->sort = $sort_order;
15
- $this->merged_events = array();
16
- $this->search = $search_params;
17
- $this->displays = ! is_array( $displays ) ? explode( ',', $displays ) : $displays;
18
- $this->filters = ! is_array( $filters ) ? explode( ',', $filters ) : $filters;
19
- $this->page_items = $page_items;
20
- $this->event_search = $event_search;
21
- //$this->date = $date;
22
- $this->page = $page;
23
- if ( $display ) {
24
- $this->display = $display;
25
- } else {
26
- $this->display = 'full';
27
- }
28
-
29
- if ( isset( $_REQUEST['date'] ) ) {
30
- $date = $_REQUEST['date'];
31
- $date = date( 'Y-n-j', strtotime( $date ) );
32
-
33
- }
34
- if ( $date == '' && ! isset( $_REQUEST['date'] ) ) {
35
- $date = date( 'Y-n-j' );
36
- }
37
- $start_date = date( 'Y-n-d', strtotime( $date ) );
38
- $date = date( 'Y-n-t', strtotime( $date ) ); // format the date for parsing
39
- $date_part = explode( '-', $date ); // separate year/month/day
40
- $year = $date_part[0];
41
- $month = $date_part[1];
42
- $day = $date_part[2];
43
- if ( isset( $_REQUEST['y'] ) && $_REQUEST['y'] != '' ) {
44
- $year = $_REQUEST['y'];
45
- } // if year is set in querystring it takes precedence
46
- if ( isset( $_REQUEST['m'] ) && $_REQUEST['m'] != '' ) {
47
- $month = $_REQUEST['m'];
48
- } // if month is set in querystring it takes precedence
49
- if ( isset( $_REQUEST['d'] ) && $_REQUEST['d'] != '' ) {
50
- $day = $_REQUEST['d'];
51
- } // if day is set in querystring it takes precedence
52
-
53
- if ( $year == '' ) {
54
- $year = date( 'Y' );
55
- }
56
- if ( $month == '' ) {
57
- $month = date( 'n' ); // set to january if year is known
58
- }
59
- if ( $day == '' ) {
60
- $day = date( 'j' ); // set to the 1st is year and month is known
61
- }
62
- $this->date = $date;
63
- $this->month = (int) $month;
64
- $this->year = (int) $year;
65
- $this->day = (int) $day;
66
- $this->start_date = $this->year . '-' . $this->month . '-1';
67
- $this->end_date = date( 'Y-m-t', strtotime( $this->date ) );
68
- if ( ( isset( $_REQUEST['t'] ) && $_REQUEST['t'] == 'week' ) || $this->display == 'week' ) {
69
- $this->start_date = $start_date;
70
- $this->end_date = date( "Y-m-d", strtotime( '+7 days', strtotime( $start_date ) ) );
71
- $this->date = date( 'Y-n-t', strtotime( $this->end_date ) );
72
- } elseif ( ( isset( $_REQUEST['t'] ) && $_REQUEST['t'] == '4day' ) || $this->display == '4day' ) {
73
- $this->start_date = $start_date;
74
- $this->end_date = date( "Y-m-d", strtotime( '+4 days', strtotime( $start_date ) ) );
75
- $this->date = date( 'Y-n-t', strtotime( $this->end_date ) );
76
- }
77
-
78
-
79
- if ( $this->id ) {
80
- $this->get_events();
81
- }
82
-
83
- }
84
-
85
- public function get_events() {
86
-
87
- //get events by calendars
88
- if ( ! $this->date ) {
89
- $this->date = $date = date( 'Y-m-t' );
90
- }
91
- $date = $this->date;
92
-
93
-
94
- $query = ( isset( $this->search['query'] ) ? $this->search['query'] : '' );
95
-
96
- foreach ( $this->id as $id ) {
97
- $ecwd_events_title = array();
98
- if ( ! is_array( $this->search ) || count( $this->search ) == 0 ) {
99
- $args = array(
100
- 'numberposts' => - 1,
101
- 'post_type' => ECWD_PLUGIN_PREFIX . '_event',
102
- 'meta_query' => array(
103
- array(
104
- 'key' => ECWD_PLUGIN_PREFIX . '_event_calendars',
105
- 'value' => serialize( strval( $id ) ),
106
- 'compare' => 'LIKE'
107
- ),
108
- array(
109
- 'key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
110
- 'value' => $date,
111
- 'compare' => '<=',
112
- 'type' => 'DATE'
113
- ),
114
-
115
- ),
116
- 'meta_key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
117
- 'orderby' => 'meta_value',
118
- 'order' => 'ASC'
119
-
120
- );
121
- } else {
122
- $ecwd_events_title_query = 'post_type=ecwd_event';
123
- $organizers_query = array();
124
- if ( $query != '' ) {
125
- $ecwd_events_title_query .= '&s=' . $query;
126
-
127
- $metaquery = new WP_Query( 's=' . $query . '&post_type=ecwd_organizer' );
128
- $organizers = $metaquery->get_posts();
129
-
130
- $organizers_query['relation'] = 'OR';
131
-
132
- foreach ( $organizers as $organizer ) {
133
- $organizers_query[] = array(
134
- 'key' => ECWD_PLUGIN_PREFIX . '_event_organizers',
135
- 'value' => serialize( strval( $organizer->ID ) ),
136
- 'compare' => 'LIKE'
137
- );
138
-
139
- }
140
- $organizers_query[] = array(
141
- 'key' => ECWD_PLUGIN_PREFIX . '_event_location',
142
- 'value' => $query,
143
- 'compare' => 'LIKE'
144
- );
145
- }
146
-
147
- $tax_query = array();
148
- $organizers_ids = array();
149
- $venue_query = array();;
150
- if ( isset( $this->search['categories'] ) && $this->search['categories'] !== 0 ) {
151
- $tax_query[] =
152
- array(
153
- 'taxonomy' => ECWD_PLUGIN_PREFIX . '_event_category',
154
- 'terms' => $this->search['categories'],
155
-
156
- );
157
- }
158
- if ( isset( $this->search['tags'] ) && $this->search['tags'] > 0 ) {
159
- $tax_query[] =
160
- array(
161
- 'taxonomy' => 'ecwd_event_tag',
162
- 'terms' => $this->search['tags'],
163
-
164
- );
165
- }
166
- if ( isset( $this->search['venues'] ) && $this->search['venues'] > 0 ) {
167
- $venue_query['relation'] = 'OR';
168
- foreach ( $this->search['venues'] as $venue ) {
169
- $venue_query[] = array(
170
- 'key' => ECWD_PLUGIN_PREFIX . '_event_venue',
171
- 'value' => $venue
172
- );
173
-
174
- }
175
-
176
- }
177
- if ( isset( $this->search['organizers'] ) && $this->search['organizers'] !== 0 ) {
178
- $organizers_ids['relation'] = 'OR';
179
- foreach ( $this->search['organizers'] as $organizer ) {
180
- $organizers_ids[] = array(
181
- 'key' => ECWD_PLUGIN_PREFIX . '_event_organizers',
182
- 'value' => serialize( strval( $organizer ) ),
183
- 'compare' => 'LIKE'
184
- );
185
-
186
- }
187
-
188
- }
189
-
190
-
191
- $meta_query = array(
192
- 'relation' => 'AND',
193
- $organizers_query,
194
- array(
195
- 'key' => ECWD_PLUGIN_PREFIX . '_event_calendars',
196
- 'value' => serialize( strval( $id ) ),
197
- 'compare' => 'LIKE'
198
- ),
199
- array(
200
- 'key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
201
- 'value' => $this->end_date,
202
- 'compare' => '<=',
203
- 'type' => 'DATE'
204
- ),
205
- $venue_query,
206
- $organizers_ids
207
-
208
- );
209
- $args = array(
210
- 'numberposts' => - 1,
211
- 'post_type' => ECWD_PLUGIN_PREFIX . '_event',
212
- 'relation' => 'AND',
213
- 'meta_query' => $meta_query,
214
- 'tax_query' => $tax_query,
215
- 'meta_key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
216
- 'orderby' => 'meta_value',
217
- 'order' => 'ASC'
218
-
219
- );
220
-
221
- if ( $query && $query !== '' ) {
222
- try {
223
- $ecwd_events_title = new WP_Query( $ecwd_events_title_query );
224
- $ecwd_events_title = $ecwd_events_title->get_posts();
225
- } catch ( Exception $e ) {
226
- $ecwd_events_title = array();
227
- }
228
-
229
- }
230
- wp_reset_query();
231
- }
232
- try {
233
- $ecwd_events = get_posts( $args );
234
- } catch ( Exception $e ) {
235
- $ecwd_events = array();
236
- }
237
-
238
- $ecwd_events += $ecwd_events_title;
239
- wp_reset_query();
240
- $google_events = array();
241
- $events = array();
242
- $ical_events = array();
243
- $facebook_events = array();
244
- //fetch google calendar events
245
-
246
-
247
-
248
- foreach ( $ecwd_events as $ecwd_event ) {
249
-
250
- $term_metas = '';
251
- $categories = get_the_terms( $ecwd_event->ID, ECWD_PLUGIN_PREFIX . '_event_category' );
252
- if ( is_array( $categories ) ) {
253
- $ci = 0;
254
- foreach ( $categories as $i => $category ) {
255
- $term_metas[ $ci ] = get_option( "ecwd_event_category_$category->term_id" );
256
- $term_metas[ $ci ]['id'] = $category->term_id;
257
- $term_metas[ $ci ]['name'] = $category->name;
258
- $term_metas[ $ci ]['slug'] = $category->slug;
259
- $ci ++;
260
- }
261
- }
262
- $ecwd_event_metas = get_post_meta( $ecwd_event->ID, '', true );
263
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_url' ] = array( 0 => '' );
264
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_location' ] ) ) {
265
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_location' ] = array( 0 => '' );
266
- }
267
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_lat_long' ] ) ) {
268
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_lat_long' ] = array( 0 => '' );
269
- }
270
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_to' ] ) ) {
271
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_to' ] = array( 0 => '' );
272
- }
273
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_from' ] ) ) {
274
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_from' ] = array( 0 => '' );
275
- }
276
-
277
- $permalink = get_permalink( $ecwd_event->ID );
278
- if ( isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_calendars' ][0] ) ) {
279
- if ( is_serialized( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_calendars' ][0] ) ) {
280
- $event_calendar_ids = unserialize( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_calendars' ][0] );
281
- } else {
282
- $event_calendar_ids = $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_calendars' ][0];
283
- }
284
- //var_dump($term_metas);
285
- if ( in_array( $this->id[0], $event_calendar_ids ) ) {
286
- $events[ $ecwd_event->ID ] = new ECWD_Event( $ecwd_event->ID, $id, $ecwd_event->post_title, $ecwd_event->post_content, $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_location' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_from' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_to' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_url' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_lat_long' ][0], $permalink, $ecwd_event, $term_metas, $ecwd_event_metas );
287
- }
288
- }
289
- }
290
- $this->merged_events += $google_events + $facebook_events + $ical_events + $events;
291
-
292
- //$this->merged_events += $events;
293
- $this->get_event_days();
294
- }
295
-
296
- }
297
-
298
- /**
299
- * Comparison function for use when sorting merged event data (with usort)
300
- */
301
- function compare( $event1, $event2 ) {
302
  // //Sort ascending or descending
303
  // if ('asc' == $this->sort)
304
  // return $event1->start_time - $event2->start_time;
305
  //
306
  // return $event2->start_time - $event1->start_time;
307
- }
308
-
309
- /**
310
- * Returns array of days with events, with sub-arrays of events for that day
311
- */
312
- public function get_event_days( $events = '', $current_month = 1, $start_date = '', $end_date = '' ) {
313
- if ( ! $events ) {
314
- $events = $this->merged_events;
315
-
316
- }
317
- if ( $start_date && $end_date ) {
318
- $this->start_date = $start_date;
319
- $this->end_date = $end_date;
320
- }
321
-
322
- foreach ( $events as $id => $arr ) {
323
-
324
- if ( is_int( $arr->start_time ) ) {
325
- $start_date = date( 'Y-m-d', $arr->start_time );
326
- $end_date = date( 'Y-m-d', $arr->end_time );
327
- $start_time = date( 'H:i', $arr->start_time );
328
- $end_time = date( 'H:i', $arr->end_time );
329
- } else {
330
- $start_date = date( 'Y-m-d', strtotime( $arr->start_time ) );
331
- $end_date = date( 'Y-m-d', strtotime( $arr->end_time ) );
332
- $start_time = date( 'H:i', strtotime( $arr->start_time ) );
333
- $end_time = date( 'H:i', strtotime( $arr->end_time ) );
334
- }
335
- $arr = (array) $arr;
336
- $from = $start_date;
337
- $to = $end_date;
338
- $starttime = $start_time;
339
- $endtime = $end_time;
340
- $venue = '';
341
- $color = array_key_exists( 'color', $arr ) ? $arr['color'] : '';
342
- $title = array_key_exists( 'title', $arr ) ? $arr['title'] : '';
343
- $details = array_key_exists( 'description', $arr ) ? $arr['description'] : '';
344
- $location = array_key_exists( 'location', $arr ) ? $arr['location'] : '';
345
- $link = array_key_exists( 'link', $arr ) ? $arr['link'] : '';
346
- $permalink = array_key_exists( 'permalink', $arr ) ? $arr['permalink'] : '';
347
- $latlong = array_key_exists( 'permalink', $arr ) ? $arr['latlong'] : '';
348
- $id = $id;
349
- $terms = array_key_exists( 'terms', $arr ) ? $arr['terms'] : '';
350
- $post = array_key_exists( 'post', $arr ) ? $arr['post'] : '';
351
- $metas = array_key_exists( 'metas', $arr ) ? $arr['metas'] : '';
352
- $image = array_key_exists( 'image', $arr ) ? $arr['image'] : '';
353
- if ( $metas && isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_venue' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_event_venue' ][0] ) {
354
- $venue_post = get_post( $metas[ ECWD_PLUGIN_PREFIX . '_event_venue' ][0] );
355
- if ( $venue_post ) {
356
- $venue['name'] = $venue_post->post_title;
357
- $venue['id'] = $venue_post->ID;
358
- $venue['permalink'] = get_permalink( $venue_post->ID );
359
- }
360
- }
361
- //echo $title.'---'.$starttime.'---'.$arr['metas']['ecwd_all_day_event'][0].'<br />'; die;
362
- $organizers = array();
363
- $organizersIDs = array();
364
- if ( $metas && isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_organizers' ][0] ) ) {
365
- if ( is_serialized( $metas[ ECWD_PLUGIN_PREFIX . '_event_organizers' ][0] ) ) {
366
- $organizers_ids = unserialize( $metas[ ECWD_PLUGIN_PREFIX . '_event_organizers' ][0] );
367
- } elseif ( is_array( $metas[ ECWD_PLUGIN_PREFIX . '_event_organizers' ][0] ) ) {
368
- $organizers_ids = $metas[ ECWD_PLUGIN_PREFIX . '_event_organizers' ][0];
369
- } else {
370
- $organizers_ids = array();
371
- }
372
- if ( $organizers_ids ) {
373
- foreach ( $organizers_ids as $organizer_id ) {
374
- if ( $organizer_id ) {
375
- $opost = get_post( $organizer_id );
376
- if ( $opost ) {
377
- $organizers[] = array(
378
- 'id' => $opost->ID,
379
- 'name' => $opost->post_title,
380
- 'permalink' => get_permalink( $opost->ID )
381
- );
382
- $organizersIDs[] = $opost->ID;
383
- }
384
- }
385
- }
386
- }
387
- }
388
- if ( $terms ) {
389
- if ( isset( $terms['0']['color'] ) ) {
390
- $color = $terms['0']['color'];
391
- } else {
392
- $color = '';
393
- }
394
- $catIds = array();
395
- foreach ( $terms as $term ) {
396
- if ( isset( $term['id'] ) ) {
397
- $catIds[] = $term['id'];
398
- }
399
- }
400
- }
401
- if ( isset( $this->search['categories'] ) && $this->search['categories'] > 0 ) {
402
- if ( ! array_intersect( $this->search['categories'], $catIds ) ) {
403
- continue;
404
- };
405
-
406
- }
407
- //echo '<br />';
408
-
409
- if ( isset( $this->search['venues'] ) && $this->search['venues'] > 0 ) {
410
- if ( ! isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_venue' ][0] ) || ! count( $venue ) ) {
411
- continue;
412
- } else {
413
- if ( ! in_array( $venue['id'], $this->search['venues'] ) ) {
414
- continue;
415
- }
416
- }
417
- }
418
- if ( isset( $this->search['organizers'] ) && $this->search['organizers'] > 0 ) {
419
- if ( ! array_intersect( $this->search['organizers'], $organizersIDs ) ) {
420
- continue;
421
- };
422
- }
423
- $weekdays = array( 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday' );
424
- if ( isset( $this->search['weekdays'] ) && $this->search['weekdays'] > 0 ) {
425
- $weekdays = $this->search['weekdays'];
426
- }
427
-
428
-
429
- if ( $metas && isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] !== 'no_repeat' && $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] != '' ) {
430
- $event_week_last_day = '';
431
- if ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'weekly' ) {
432
- $days = array();
433
- if ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] != '' && $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] != 1 ) {
434
-
435
- if ( is_serialized( $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] ) ) {
436
- $days = unserialize( $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] );
437
- } elseif ( is_array( $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] ) ) {
438
- $days = $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0];
439
- }
440
- } else {
441
- $days = array( strtolower( date( 'l', strtotime( $from ) ) ) );
442
- }
443
-
444
- $until = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] : $to );
445
- if(strtotime($until)>strtotime($this->end_date)){
446
- $until = $this->end_date;
447
- }
448
- $how = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] : 1 );
449
- if ( count( $days ) ) {
450
- $event_week_last_day = $days[ count( $days ) - 1 ];
451
- }
452
- $eventdays = $this->dateDiff( $from, $until );
453
- $eventdayslong = $this->dateDiff( $from, $to );
454
- if ( $eventdays < 0 ) {
455
- continue;
456
- }
457
- $from_date = $from;
458
-
459
- for ( $i = 0; $i <= $eventdays; $i ++ ) {
460
- $eventdate = strtotime( date( "Y-m-d", strtotime( $from_date ) ) . " +" . $i . " day" );
461
- $week_day = strtolower( date( 'l', $eventdate ) );
462
- $eventdate = date( "Y-n-j", $eventdate );
463
-
464
- if ( is_array( $days ) && in_array( $week_day, $days ) ) {
465
- if ( $how > 1 && $week_day == $event_week_last_day ) {
466
- $from_date = strtotime( ( date( "Y-m-d", ( strtotime( $from_date ) ) ) . " +" . ( ( $how * 7 ) - 7 ) . " days" ) );
467
- $from_date = date( 'Y-m-d', $from_date );
468
- $next_week = date( "Y-m-d", strtotime( 'next monday', strtotime( $from_date ) ) );
469
- }
470
- $from = $eventdate;
471
-
472
- if ( strtotime( $until ) >= strtotime( date( 'Y-m-d', strtotime( $from ) ) ) ) {
473
-
474
-
475
- $to = date( 'Y-m-d', strtotime( $from . ' + ' . $eventdayslong . ' days' ) );
476
- //var_dump();
477
-
478
-
479
- if ( ! $current_month || ( strtotime( $from ) <= strtotime( $this->end_date ) && strtotime( $from ) >= strtotime( $this->start_date ) && in_array( strtolower( date( 'l', strtotime( $from ) ) ), $weekdays ) ) ) {
480
- if($permalink){
481
- $permalink = ECWD_Event::getLink($post, $from);
482
- }
483
- $this->events[] = array(
484
- 'color' => $color,
485
- 'title' => $title,
486
- 'link' => $link,
487
- 'date' => $eventdate,
488
- 'from' => $from,
489
- 'to' => $to,
490
- 'id' => $id,
491
- 'starttime' => $starttime,
492
- 'endtime' => $endtime,
493
- 'details' => $details,
494
- 'location' => $location,
495
- 'permalink' => $permalink,
496
- 'latlong' => $latlong,
497
- 'terms' => $terms,
498
- 'metas' => $metas,
499
- 'all_day_event' => ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] == 1 ) ? 1 : 0,
500
- 'venue' => $venue,
501
- 'organizers' => $organizers,
502
- 'post' => $post,
503
- 'image' => $image
504
- );
505
- }
506
-
507
- }
508
- }
509
- }
510
- } elseif ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'daily' ) {
511
- $until = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] : $to );
512
-
513
- if(strtotime($until)>strtotime($this->end_date)){
514
- $until = $this->end_date;
515
- }
516
- $how = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] : 1 );
517
- $eventdays = $this->dateDiff( $from, $until );
518
- $eventdayslong = $this->dateDiff( $from, $to );
519
- if ( $eventdays < 0 ) {
520
- continue;
521
- }
522
- $from_date = $from;
523
- for ( $i = 0; $i <= $eventdays; $i ++ ) {
524
- $date = strtotime( date( "Y-m-d", strtotime( $from_date ) ) . " +" . $i . " day" );
525
- $date = date( "Y-n-j", $date );
526
-
527
- if ( strtotime( $until ) >= strtotime( date( 'Y-m-d', strtotime( $date ) ) ) ) {
528
-
529
- $from_date = strtotime( ( date( "Y-m-d", ( strtotime( $from_date ) ) ) . " +" . ( ( $how - 1 ) ) . " days" ) );
530
- $from_date = date( 'Y-m-d', $from_date );
531
- $from = $date;
532
- $to = date( 'Y-m-d', strtotime( $from . ' + ' . $eventdayslong . ' days' ) );
533
-
534
- if ( ! $current_month || ( strtotime( $from ) <= strtotime( $this->end_date ) && strtotime( $from ) >= strtotime( $this->start_date ) && in_array( strtolower( date( 'l', strtotime( $from ) ) ), $weekdays ) ) ) {
535
- if($permalink){
536
- $permalink = ECWD_Event::getLink($post, $from);
537
- }
538
- $this->events[] = array(
539
- 'color' => $color,
540
- 'title' => $title,
541
- 'link' => $link,
542
- 'date' => $date,
543
- 'from' => $from,
544
- 'to' => $to,
545
- 'id' => $id,
546
- 'starttime' => $starttime,
547
- 'endtime' => $endtime,
548
- 'details' => $details,
549
- 'location' => $location,
550
- 'permalink' => $permalink,
551
- 'latlong' => $latlong,
552
- 'terms' => $terms,
553
- 'metas' => $metas,
554
- 'all_day_event' => ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] == 1 ) ? 1 : 0,
555
- 'venue' => $venue,
556
- 'organizers' => $organizers,
557
- 'post' => $post,
558
- 'image' => $image
559
- );
560
- }
561
- }
562
-
563
-
564
- }
565
- } else if ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'monthly' ) {
566
- $until = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] : $to );
567
- $how = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] : 1 );
568
- $eventdays = $this->dateDiff( $from, $until );
569
- $eventdayslong = $this->dateDiff( $from, $to );
570
- $event_from = $from;
571
- $from_date = $from;
572
- $repeat_days = isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days' ][0] : 1;
573
- $repeat_when = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_monthly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_monthly' ][0] : false;
574
- $repeat_day = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_monthly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_monthly' ][0] : false;
575
-
576
- $min_date = strtotime( $event_from );
577
- $max_date = strtotime( "+1 MONTH", strtotime( $until ) );
578
- if ( $max_date >= $min_date ) {
579
- $i = 0;
580
- while ( ( $min_date = strtotime( "+1 MONTH", $min_date ) ) <= $max_date ) {
581
- //echo date('Y-m-d', $min_date).'----'.date('Y-m-d', $max_date).'<br />';
582
- $date = strtotime( date( "Y-m-d", strtotime( $event_from ) ) . " +" . $i * $how . " MONTH" );
583
- if ( $i > 0 ) {
584
- if ( $repeat_days == 2 && $repeat_day && $repeat_when && date( 'Y-m', strtotime( $event_from ) ) !== date( 'Y-m', $date ) ) {
585
- $monthyear = date( "F Y", $date );
586
- $repeat_date = date( 'Y-m-d', strtotime( $repeat_when . ' ' . ucfirst( $repeat_day ) . ' of ' . $monthyear ) );
587
- if($repeat_date == '1970-01-01' || $repeat_date=='1969-12-31') {
588
- $repeat_date = date( 'Y-m-d', strtotime( $monthyear . ' ' . $repeat_when . ' ' . $repeat_day ) );
589
- }
590
-
591
- $date = strtotime( $repeat_date );
592
- }
593
- }
594
- $date = date( "Y-n-j", $date );
595
- $i ++;
596
- if ( strtotime( $until ) >= strtotime( date( 'Y-m-d', strtotime( $date ) ) ) ) {
597
- $min_date = $from_date = strtotime( ( date( "Y-m-1", ( strtotime( $date ) ) ) . " +" . ( ( $how ) ) . " month" ) );
598
-
599
- $eventdays -= 30;
600
- $from_date = strtotime( ( date( "Y-m-d", $from_date ) . " - 1 day" ) );
601
-
602
- $from_date = date( 'Y-m-d', $from_date );
603
- $from = $date;
604
- $to = strtotime( ( date( "Y-m-d", ( strtotime( $from ) ) ) . " +" . ( $eventdayslong ) . " days" ) );
605
- $to = date( 'Y-m-d', $to );
606
- if ( ! $current_month || ( strtotime( $from ) <= strtotime( $this->end_date ) && strtotime( $from ) >= strtotime( $this->start_date ) && in_array( strtolower( date( 'l', strtotime( $from ) ) ), $weekdays ) ) ) {
607
- if($permalink){
608
- $permalink = ECWD_Event::getLink($post, $from);
609
- }
610
- $this->events[] = array(
611
- 'color' => $color,
612
- 'title' => $title,
613
- 'link' => $link,
614
- 'date' => $date,
615
- 'from' => $from,
616
- 'to' => $to,
617
- 'id' => $id,
618
- 'starttime' => $starttime,
619
- 'endtime' => $endtime,
620
- 'details' => $details,
621
- 'location' => $location,
622
- 'permalink' => $permalink,
623
- 'latlong' => $latlong,
624
- 'terms' => $terms,
625
- 'metas' => $metas,
626
- 'all_day_event' => ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] == 1 ) ? 1 : 0,
627
- 'venue' => $venue,
628
- 'organizers' => $organizers,
629
- 'post' => $post,
630
- 'image' => $image
631
- );
632
- }
633
- }
634
-
635
- }
636
- }
637
-
638
- } else if ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'yearly' ) {
639
- $until = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] : $to );
640
- $how = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] : 1 );
641
- $eventdays = $this->dateDiff( $from, $until );
642
- $eventdayslong = $this->dateDiff( $from, $to );
643
- $event_from = $from;
644
- $from_date = $from;
645
- $repeat_days = isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days' ][0] : 1;
646
- $repeat_when = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_yearly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_yearly' ][0] : false;
647
- $repeat_day = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_yearly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_yearly' ][0] : false;
648
- if ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_year_month' ][0] ) && $repeat_days == 2 ) {
649
- $month = $metas[ ECWD_PLUGIN_PREFIX . '_event_year_month' ][0];
650
- $monthName = date( 'F', strtotime( '2015-' . $month . '-1' ) );
651
- } else {
652
- $monthName = date( 'F', strtotime( $from_date ) );
653
- }
654
- $min_date = strtotime( $event_from );
655
- $max_date = strtotime( $until );
656
- $i = 0;
657
- while ( ( $min_date = strtotime( "+1 YEAR", $min_date ) ) <= $max_date ) {
658
- $date = strtotime( date( "Y-m-d", strtotime( $event_from ) ) . " +" . $i * $how . " YEAR" );
659
- if ( $i > 0 ) {
660
- if ( $repeat_days == 1 ) {
661
- $monthyear = $monthName . ' ' . date( "d Y", $date );
662
- $repeat_date = strtotime( date( 'Y-m-d', strtotime( $monthyear ) ) );
663
- $date = $repeat_date;
664
-
665
- }
666
- if ( $repeat_days == 2 && $repeat_day && $repeat_when ) {
667
- $monthyear = $monthName . ' ' . date( "Y", $date );
668
- //echo $repeat_when.' '.ucfirst( $repeat_day ).' of '.$monthyear.'<br />';
669
- $repeat_date = date( 'Y-m-d', strtotime( $repeat_when . ' ' . ucfirst( $repeat_day ) . ' of ' . $monthyear ) );
670
- if($repeat_date == '1970-01-01' || $repeat_date=='1969-12-31') {
671
- $repeat_date = date( 'Y-m-d', strtotime( $monthyear . ' ' . $repeat_when . ' ' . $repeat_day ) );
672
- }
673
- //$repeat_date = date( 'Y-m-d', strtotime($repeat_when.' '.ucfirst( $repeat_day ).' of '.$monthyear) );
674
- //don't know why, but "last sunday,last monday... returns last s,m of previous month"
675
- if ( $repeat_when == 'last' ) {
676
- $repeat_date = date( 'Y-m-d',strtotime( $repeat_when . ' ' . ucfirst( $repeat_day ) . ' of ' . $monthyear, strtotime( "+1 MONTH", $repeat_date )) );
677
- }
678
- $date = strtotime($repeat_date);
679
-
680
- }
681
- }
682
- $date = date( "Y-n-j", $date );
683
-
684
- $i ++;
685
- if ( strtotime( $until ) >= strtotime( date( 'Y-m-t', strtotime( $this->date ) ) ) && strtotime( $date ) <= strtotime( $until ) ) {
686
- $from_date = strtotime( ( date( "Y-m-d", ( strtotime( $from_date ) ) ) . " +" . ( ( $how ) ) . " year" ) );
687
- $from_date = strtotime( ( date( "Y-m-d", $from_date ) . " - 1 day" ) );
688
- $from_date = date( 'Y-m-d', $from_date );
689
- $from = $date;
690
- $to = strtotime( ( date( "Y-m-d", ( strtotime( $from_date ) ) ) . " +" . ( $eventdayslong ) . " days" ) );
691
- $to = date( 'Y-m-d', $to );
692
- if ( ! $current_month || ( strtotime( $from ) <= strtotime( $this->end_date ) && strtotime( $from ) >= strtotime( $this->start_date ) && in_array( strtolower( date( 'l', strtotime( $from ) ) ), $weekdays ) ) ) {
693
- if($permalink){
694
- $permalink = ECWD_Event::getLink($post, $from);
695
- }
696
- $this->events[] = array(
697
- 'color' => $color,
698
- 'title' => $title,
699
- 'link' => $link,
700
- 'date' => $date,
701
- 'from' => $from,
702
- 'to' => $to,
703
- 'id' => $id,
704
- 'starttime' => $starttime,
705
- 'endtime' => $endtime,
706
- 'details' => $details,
707
- 'location' => $location,
708
- 'permalink' => $permalink,
709
- 'latlong' => $latlong,
710
- 'terms' => $terms,
711
- 'metas' => $metas,
712
- 'all_day_event' => ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] == 1 ) ? 1 : 0,
713
- 'venue' => $venue,
714
- 'organizers' => $organizers,
715
- 'post' => $post,
716
- 'image' => $image
717
- );
718
- }
719
- }
720
-
721
-
722
- }
723
-
724
- }
725
-
726
- } else {
727
-
728
- $eventdays = $this->dateDiff( $from, $to ); // get the difference in days between the two dates
729
-
730
- $date = strtotime( date( "Y-m-d", strtotime( $from ) ) );
731
- $date = date( "Y-n-j", $date );
732
- if ( ! $current_month || ( strtotime( $from ) <= strtotime( $this->end_date ) && strtotime( $from ) >= strtotime( $this->start_date ) && in_array( strtolower( date( 'l', strtotime( $from ) ) ), $weekdays ) ) ) {
733
- if($permalink){
734
- $permalink = ECWD_Event::getLink($post, $from);
735
- }
736
- $this->events[] = array(
737
- 'color' => $color,
738
- 'title' => $title,
739
- 'link' => $link,
740
- 'date' => $date,
741
- 'from' => $date,
742
- 'to' => $to,
743
- 'id' => $id,
744
- 'starttime' => $starttime,
745
- 'endtime' => $endtime,
746
- 'details' => $details,
747
- 'location' => $location,
748
- 'permalink' => $permalink,
749
- 'latlong' => $latlong,
750
- 'terms' => $terms,
751
- 'metas' => $metas,
752
- 'all_day_event' => ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_all_day_event' ][0] == 1 ) ? 1 : 0,
753
- 'venue' => $venue,
754
- 'organizers' => $organizers,
755
- 'post' => $post,
756
- 'image' => $image
757
- );
758
- // }
759
- }
760
- }
761
-
762
- }
763
-
764
-
765
- if ( $this->events ) {
766
- $this->events = $this->arraySort( $this->events, 'from' );
767
- }
768
-
769
- if ( $events ) {
770
- return $this->events;
771
-
772
- }
773
- }
774
-
775
-
776
- function literalDate( $timestamp, $weekday ) {
777
- $timestamp = is_numeric( $timestamp ) ? $timestamp : strtotime( $timestamp );
778
- $month = date( 'M', $timestamp );
779
- $ord = 0;
780
-
781
- while ( date( 'M', ( $timestamp = strtotime( '-1 week', $timestamp ) ) ) == $month ) {
782
- $ord ++;
783
- }
784
-
785
- $lit = array( 'first', 'second', 'third', 'fourth', 'fifth' );
786
-
787
- return strtolower( $lit[ $ord ] . ' ' . $weekday );
788
- }
789
-
790
- /**
791
- * Return the calendar
792
- */
793
- public function get_view( $date = '', $type = '', $widget = 0,$ecwd_views,$preview) {
794
- require_once 'calendar-class.php';
795
- $categories = get_categories( array( 'taxonomy' => ECWD_PLUGIN_PREFIX . '_event_category' ) );
796
- $tags = get_terms( 'ecwd_event_tag', array( 'hide_empty' => false ) );
797
-
798
- //Get events data
799
- //Generate the calendar markup and return it
800
- $cal = new Calendar( $type, $date, '', $widget, $this->page_items, $this->page, $this->displays, $this->filters, $this->event_search,array(),$preview);
801
- $search_params = $this->search;
802
- if ( is_array( $search_params ) && ( ( isset( $search_params['query'] ) && $search_params['query'] !== '' ) || ( isset( $search_params['category'] ) && $search_params['category'] > 0 ) || ( isset( $search_params['tag'] ) && $search_params['tag'] > 0 ) ) || ( isset( $search_params['venue'] ) && $search_params['venue'] > 0 ) || ( isset( $search_params['organizer'] ) && $search_params['organizer'] > 0 ) ) {
803
- $cal->search_params = $this->search;
804
- }
805
- if ( $categories ) {
806
- $cal->add_terms( 'categories', $categories );
807
- }
808
- if ( $tags ) {
809
- $cal->add_terms( 'tags', $tags );
810
- }
811
-
812
- $args = array(
813
- 'post_type' => ECWD_PLUGIN_PREFIX . '_venue',
814
- 'post_status' => 'publish',
815
- 'posts_per_page' => - 1,
816
- 'ignore_sticky_posts' => 1
817
- );
818
- $venues = get_posts( $args );
819
- if ( $venues ) {
820
- $cal->add_terms( 'venues', $venues );
821
- }
822
- $args = array(
823
- 'post_type' => ECWD_PLUGIN_PREFIX . '_organizer',
824
- 'post_status' => 'publish',
825
- 'posts_per_page' => - 1,
826
- 'ignore_sticky_posts' => 1
827
- );
828
- $organizers = get_posts( $args );
829
- if ( $organizers ) {
830
- $cal->add_terms( 'organizers', $organizers );
831
- }
832
-
833
- if ( $this->events ) {
834
-
835
- foreach ( $this->events as $id => $event ) {
836
- $cal->addEvent( $event );
837
- }
838
- }
839
-
840
- return $cal->showcal();
841
- }
842
-
843
-
844
- public function get_countdown( $event_id, $date = '', $display = '', $widget = '' ) {
845
- $next_event = null;
846
- $count_down_events = array();
847
- if ( $this->events ) {
848
- foreach ( $this->events as $id => $event ) {
849
- $start = strtotime( $event['from'] . 'T' . $event['starttime'] );
850
- if ( $start >= strtotime( gmdate( 'Y-m-dTH:i' ) ) ) {
851
- $count_down_events[ $id ] = $event;
852
- $next_event = $count_down_events[ $id ];
853
- break;
854
- }
855
- }
856
- } else {
857
-
858
- $ecwd_event = get_post( $event_id );
859
- $term_metas = '';
860
- if ( $ecwd_event ) {
861
- $categories = get_the_terms( $ecwd_event->ID, ECWD_PLUGIN_PREFIX . '_event_category' );
862
- if ( is_array( $categories ) ) {
863
- foreach ( $categories as $category ) {
864
- $term_metas = get_option( "ecwd_event_category_$category->term_id" );
865
- $term_metas['id'] = $category->term_id;
866
- $term_metas['name'] = $category->name;
867
- $term_metas['slug'] = $category->slug;
868
- }
869
- }
870
- $ecwd_event_metas = get_post_meta( $ecwd_event->ID, '', true );
871
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_url' ] = array( 0 => '' );
872
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_location' ] ) ) {
873
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_location' ] = array( 0 => '' );
874
- }
875
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_lat_long' ] ) ) {
876
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_lat_long' ] = array( 0 => '' );
877
- }
878
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_to' ] ) ) {
879
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_to' ] = array( 0 => '' );
880
- }
881
- if ( ! isset( $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_from' ] ) ) {
882
- $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_from' ] = array( 0 => '' );
883
- }
884
-
885
-
886
- $permalink = get_permalink( $ecwd_event->ID );
887
-
888
- $events[ $ecwd_event->ID ] = new ECWD_Event( $ecwd_event->ID, '', $ecwd_event->post_title, $ecwd_event->post_content, $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_location' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_from' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_date_to' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_event_url' ][0], $ecwd_event_metas[ ECWD_PLUGIN_PREFIX . '_lat_long' ][0], $permalink, $ecwd_event, $term_metas, $ecwd_event_metas );
889
-
890
- $this->merged_events = $events;
891
- //$this->merged_events += $events;
892
- $this->get_event_days( '', 0 );
893
-
894
- if ( $this->events ) {
895
- foreach ( $this->events as $id => $event ) {
896
- $start = strtotime( $event['from'] . 'T' . $event['starttime'] );
897
- if ( $start >= strtotime( gmdate( 'Y-m-dTH:i' ) ) ) {
898
- $count_down_events[ $id ] = $event;
899
- $next_event = $count_down_events[ $id ];
900
- break;
901
- }
902
- }
903
- }
904
- }
905
- }
906
-
907
- return $next_event;
908
-
909
- }
910
-
911
- public function get_repeat_rate( $event_id, $metas = '', $datefomat = 'Y-m-d' ) {
912
- $repeat_text = '';
913
- if ( ! $metas ) {
914
- $metas = get_post_meta( $event_id, '', true );
915
- }
916
- $from = $metas[ ECWD_PLUGIN_PREFIX . '_event_date_from' ][0];
917
- $days = array();
918
- if ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] != '' ) {
919
- if ( is_serialized( $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] ) ) {
920
- $days = unserialize( $metas[ ECWD_PLUGIN_PREFIX . '_event_day' ][0] );
921
- }
922
- } else {
923
- $days = array( strtolower( date( 'l', strtotime( $from ) ) ) );
924
- }
925
- if ( $metas && isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] ) && $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] !== 'no_repeat' && $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] != '' ) {
926
- $how = ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_how' ][0] : 1 );
927
-
928
- if ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'daily' ) {
929
- if ( $how > 1 ) {
930
- $repeat_text .= 'Repeat every ' . $how . ' days';
931
- } else {
932
- $repeat_text .= 'Repeat every day';
933
- }
934
- } elseif ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'weekly' ) {
935
- if ( $how > 1 ) {
936
- $repeat_text .= 'Repeat every ' . $how . ' weeks';
937
- } else {
938
- $repeat_text .= 'Repeat every week';
939
- }
940
-
941
-
942
- if ( count( $days ) > 0 ) {
943
- $repeat_text .= ' on ';
944
- foreach ( $days as $i => $day ) {
945
- $repeat_text .= ucfirst( $day ) . 's';
946
- if ( $i !== ( count( $days ) - 1 ) ) {
947
- $repeat_text .= ',';
948
- }
949
- $repeat_text .= ' ';
950
- }
951
- }
952
- } elseif ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'monthly' ) {
953
- if ( $how > 1 ) {
954
- $repeat_text .= 'Repeat every ' . $how . ' months';
955
- } else {
956
- $repeat_text .= 'Repeat every month';
957
- }
958
- $repeat_days = isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days' ][0] : 1;
959
-
960
- if ( $repeat_days == 1 ) {
961
- $repeat_text .= ' on the same day';
962
- } else {
963
- $repeat_when = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_monthly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_monthly' ][0] : false;
964
- $repeat_day = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_monthly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_monthly' ][0] : false;
965
- if ( $repeat_when && $repeat_day ) {
966
- $repeat_text .= ' on the ' . ucfirst( $repeat_when ) . ' ' . ucfirst( $repeat_day );
967
- }
968
- }
969
- } elseif ( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_event' ][0] == 'yearly' ) {
970
- if ( $how > 1 ) {
971
- $repeat_text .= 'Repeat every ' . $how . ' years';
972
- } else {
973
- $repeat_text .= 'Repeat every year';
974
- }
975
-
976
- $repeat_days = isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days' ][0] : 1;
977
- if ( isset( $metas[ ECWD_PLUGIN_PREFIX . '_event_year_month' ][0] ) ) {
978
- $month = $metas[ ECWD_PLUGIN_PREFIX . '_event_year_month' ][0];
979
- $monthName = date( 'F', strtotime( '2015-' . $month . '-1' ) );
980
- } else {
981
- $monthName = date( 'F', strtotime( $from ) );
982
- }
983
- $repeat_text .= ' in ' . $monthName;
984
- if ( $repeat_days == 1 ) {
985
- $repeat_text .= ' on the same day';
986
- } else {
987
- $repeat_when = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_yearly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_list_yearly' ][0] : false;
988
- $repeat_day = isset( $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_yearly' ][0] ) ? $metas[ ECWD_PLUGIN_PREFIX . '_monthly_week_yearly' ][0] : false;
989
- if ( $repeat_when && $repeat_day ) {
990
- $repeat_text .= ' on the ' . ucfirst( $repeat_when ) . ' ' . ucfirst( $repeat_day );
991
- }
992
- }
993
- }
994
- $repeat_text .= ' until ' . date( $datefomat, strtotime( $metas[ ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until' ][0] ) );
995
-
996
- }
997
-
998
- return $repeat_text;
999
- }
1000
-
1001
- function events_unique( $array ) {
1002
- $events_ids = array();
1003
- foreach ( $array as $key => $event ) {
1004
- if ( ! in_array( $event['id'], $events_ids ) ) {
1005
- $events_ids[] = $event['id'];
1006
- } else {
1007
- unset( $array[ $key ] );
1008
- }
1009
- }
1010
-
1011
- return $array;
1012
- }
1013
-
1014
- public function arraySort( $a, $subkey ) {
1015
- foreach ( $a as $k => $v ) {
1016
- $b[ $k ] = strtotime( $v[ $subkey ] . 'T' . $v['starttime'] );
1017
- }
1018
- asort( $b );
1019
- foreach ( $b as $key => $val ) {
1020
- $c[] = $a[ $key ];
1021
- }
1022
-
1023
- return $c;
1024
- }
1025
-
1026
- public function dateDiff( $beginDate, $endDate ) {
1027
- if ( $endDate == '' ) {
1028
- return 0;
1029
- }
1030
- $fromDate = date( 'Y-n-j', strtotime( $beginDate ) );
1031
- $toDate = date( 'Y-n-j', strtotime( $endDate ) );
1032
- $date_parts1 = explode( '-', $fromDate );
1033
- $date_parts2 = explode( '-', $toDate );
1034
-
1035
- $start_date = gregoriantojd( $date_parts1[1], $date_parts1[2], $date_parts1[0] );
1036
- $end_date = gregoriantojd( $date_parts2[1], $date_parts2[2], $date_parts2[0] );
1037
-
1038
- return $end_date - $start_date;
1039
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1040
 
1041
  }
5
  */
6
  class ECWD_Display {
7
 
8
+ private $merged_events, $goole_events, $date, $month, $year, $day, $event_options;
9
  public $events;
10
 
11
+ public function __construct($ids, $title_text = null, $sort_order = 'asc', $date = '', $page = 1, $search_params = array(), $displays = null, $filters = null, $page_items = 5, $event_search = 'yes', $display = '', $ecwd_views = array()) {
12
+ $this->id = $ids;
13
+ $this->title = $title_text;
14
+ $this->sort = $sort_order;
15
+ $this->merged_events = array();
16
+ $this->search = $search_params;
17
+ $this->displays = !is_array($displays) ? explode(',', $displays) : $displays;
18
+ $this->filters = !is_array($filters) ? explode(',', $filters) : $filters;
19
+ $this->page_items = $page_items;
20
+ $this->event_search = $event_search;
21
+ //$this->date = $date;
22
+ $this->page = $page;
23
+ if ($display) {
24
+ $this->display = $display;
25
+ } else {
26
+ $this->display = 'full';
27
+ }
28
+
29
+ if (isset($_REQUEST['date'])) {
30
+ $date = $_REQUEST['date'];
31
+ $date = date('Y-n-j', strtotime($date));
32
+ }
33
+ if ($date == '' && !isset($_REQUEST['date'])) {
34
+ $date = date('Y-n-j');
35
+ }
36
+ $start_date = date('Y-n-d', strtotime($date));
37
+ $date = date('Y-n-t', strtotime($date)); // format the date for parsing
38
+ $date_part = explode('-', $date); // separate year/month/day
39
+ $year = $date_part[0];
40
+ $month = $date_part[1];
41
+ $day = $date_part[2];
42
+ if (isset($_REQUEST['y']) && $_REQUEST['y'] != '') {
43
+ $year = $_REQUEST['y'];
44
+ } // if year is set in querystring it takes precedence
45
+ if (isset($_REQUEST['m']) && $_REQUEST['m'] != '') {
46
+ $month = $_REQUEST['m'];
47
+ } // if month is set in querystring it takes precedence
48
+ if (isset($_REQUEST['d']) && $_REQUEST['d'] != '') {
49
+ $day = $_REQUEST['d'];
50
+ } // if day is set in querystring it takes precedence
51
+
52
+ if ($year == '') {
53
+ $year = date('Y');
54
+ }
55
+ if ($month == '') {
56
+ $month = date('n'); // set to january if year is known
57
+ }
58
+ if ($day == '') {
59
+ $day = date('j'); // set to the 1st is year and month is known
60
+ }
61
+ $this->date = $date;
62
+ $this->month = (int) $month;
63
+ $this->year = (int) $year;
64
+ $this->day = (int) $day;
65
+ $this->start_date = $this->year . '-' . $this->month . '-1';
66
+ $this->end_date = date('Y-m-t', strtotime($this->date));
67
+ if (( isset($_REQUEST['t']) && $_REQUEST['t'] == 'week' ) || $this->display == 'week') {
68
+ $this->start_date = $start_date;
69
+ $this->end_date = date("Y-m-d", strtotime('+7 days', strtotime($start_date)));
70
+ $this->date = date('Y-n-t', strtotime($this->end_date));
71
+ } elseif (( isset($_REQUEST['t']) && $_REQUEST['t'] == '4day' ) || $this->display == '4day') {
72
+ $this->start_date = $start_date;
73
+ $this->end_date = date("Y-m-d", strtotime('+4 days', strtotime($start_date)));
74
+ $this->date = date('Y-n-t', strtotime($this->end_date));
75
+ }
76
+
77
+
78
+ if ($this->id) {
79
+ $this->get_events();
80
+ }
81
+ }
82
+
83
+ public function get_events() {
84
+
85
+ //get events by calendars
86
+ if (!$this->date) {
87
+ $this->date = $date = date('Y-m-t');
88
+ }
89
+ $date = $this->date;
90
+
91
+
92
+ $query = ( isset($this->search['query']) ? $this->search['query'] : '' );
93
+
94
+ foreach ($this->id as $id) {
95
+ $ecwd_events_title = array();
96
+ if (!is_array($this->search) || count($this->search) == 0) {
97
+ $args = array(
98
+ 'numberposts' => - 1,
99
+ 'post_type' => ECWD_PLUGIN_PREFIX . '_event',
100
+ 'meta_query' => array(
101
+ array(
102
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_calendars',
103
+ 'value' => serialize(strval($id)),
104
+ 'compare' => 'LIKE'
105
+ ),
106
+ array(
107
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
108
+ 'value' => $date,
109
+ 'compare' => '<=',
110
+ 'type' => 'DATE'
111
+ ),
112
+ ),
113
+ 'meta_key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
114
+ 'orderby' => 'meta_value',
115
+ 'order' => 'ASC'
116
+ );
117
+ } else {
118
+ $ecwd_events_title_query = 'post_type=ecwd_event';
119
+ $organizers_query = array();
120
+ if ($query != '') {
121
+ $ecwd_events_title_query .= '&s=' . $query;
122
+
123
+ $metaquery = new WP_Query('s=' . $query . '&post_type=ecwd_organizer');
124
+ $organizers = $metaquery->get_posts();
125
+
126
+ $organizers_query['relation'] = 'OR';
127
+
128
+ foreach ($organizers as $organizer) {
129
+ $organizers_query[] = array(
130
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_organizers',
131
+ 'value' => serialize(strval($organizer->ID)),
132
+ 'compare' => 'LIKE'
133
+ );
134
+ }
135
+ $organizers_query[] = array(
136
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_location',
137
+ 'value' => $query,
138
+ 'compare' => 'LIKE'
139
+ );
140
+ }
141
+
142
+ $tax_query = array();
143
+ $organizers_ids = array();
144
+ $venue_query = array();
145
+ ;
146
+ if (isset($this->search['categories']) && $this->search['categories'] !== 0) {
147
+ $tax_query[] = array(
148
+ 'taxonomy' => ECWD_PLUGIN_PREFIX . '_event_category',
149
+ 'terms' => $this->search['categories'],
150
+ );
151
+ }
152
+ if (isset($this->search['tags']) && $this->search['tags'] > 0) {
153
+ $tax_query[] = array(
154
+ 'taxonomy' => 'ecwd_event_tag',
155
+ 'terms' => $this->search['tags'],
156
+ );
157
+ }
158
+ if (isset($this->search['venues']) && $this->search['venues'] > 0) {
159
+ $venue_query['relation'] = 'OR';
160
+ foreach ($this->search['venues'] as $venue) {
161
+ $venue_query[] = array(
162
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_venue',
163
+ 'value' => $venue
164
+ );
165
+ }
166
+ }
167
+ if (isset($this->search['organizers']) && $this->search['organizers'] !== 0) {
168
+ $organizers_ids['relation'] = 'OR';
169
+ foreach ($this->search['organizers'] as $organizer) {
170
+ $organizers_ids[] = array(
171
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_organizers',
172
+ 'value' => serialize(strval($organizer)),
173
+ 'compare' => 'LIKE'
174
+ );
175
+ }
176
+ }
177
+
178
+
179
+ $meta_query = array(
180
+ 'relation' => 'AND',
181
+ $organizers_query,
182
+ array(
183
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_calendars',
184
+ 'value' => serialize(strval($id)),
185
+ 'compare' => 'LIKE'
186
+ ),
187
+ array(
188
+ 'key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
189
+ 'value' => $this->end_date,
190
+ 'compare' => '<=',
191
+ 'type' => 'DATE'
192
+ ),
193
+ $venue_query,
194
+ $organizers_ids
195
+ );
196
+ $args = array(
197
+ 'numberposts' => - 1,
198
+ 'post_type' => ECWD_PLUGIN_PREFIX . '_event',
199
+ 'relation' => 'AND',
200
+ 'meta_query' => $meta_query,
201
+ 'tax_query' => $tax_query,
202
+ 'meta_key' => ECWD_PLUGIN_PREFIX . '_event_date_from',
203
+ 'orderby' => 'meta_value',
204
+ 'order' => 'ASC'
205
+ );
206
+
207
+ if ($query && $query !== '') {
208
+ try {
209
+ $ecwd_events_title = new WP_Query($ecwd_events_title_query);
210
+ $ecwd_events_title = $ecwd_events_title->get_posts();
211
+ } catch (Exception $e) {
212
+ $ecwd_events_title = array();
213
+ }
214
+ }
215
+ wp_reset_query();
216
+ }
217
+ try {
218
+ $ecwd_events = get_posts($args);
219
+ } catch (Exception $e) {
220
+ $ecwd_events = array();
221
+ }
222
+
223
+ $ecwd_events += $ecwd_events_title;
224
+ wp_reset_query();
225
+ $google_events = array();
226
+ $events = array();
227
+ $ical_events = array();
228
+ $facebook_events = array();
229
+ //fetch google calendar events
230
+
231
+
232
+
233
+ foreach ($ecwd_events as $ecwd_event) {
234
+
235
+ $term_metas = '';
236
+ $categories = get_the_terms($ecwd_event->ID, ECWD_PLUGIN_PREFIX . '_event_category');
237
+ if (is_array($categories)) {
238
+ $ci = 0;
239
+ foreach ($categories as $i => $category) {
240
+ $term_metas[$ci] = get_option("ecwd_event_category_$category->term_id");
241
+ $term_metas[$ci]['id'] = $category->term_id;
242
+ $term_metas[$ci]['name'] = $category->name;
243
+ $term_metas[$ci]['slug'] = $category->slug;
244
+ $ci ++;
245
+ }
246
+ }
247
+ $ecwd_event_metas = get_post_meta($ecwd_event->ID, '', true);
248
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_url'] = array(0 => '');
249
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'])) {
250
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'] = array(0 => '');
251
+ }
252
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'])) {
253
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'] = array(0 => '');
254
+ }
255
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'])) {
256
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'] = array(0 => '');
257
+ }
258
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'])) {
259
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'] = array(0 => '');
260
+ }
261
+
262
+ $permalink = get_permalink($ecwd_event->ID);
263
+ if (isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_calendars'][0])) {
264
+ if (is_serialized($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_calendars'][0])) {
265
+ $event_calendar_ids = unserialize($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_calendars'][0]);
266
+ } else {
267
+ $event_calendar_ids = $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_calendars'][0];
268
+ }
269
+ //var_dump($term_metas);
270
+ if (in_array($this->id[0], $event_calendar_ids)) {
271
+ $events[$ecwd_event->ID] = new ECWD_Event($ecwd_event->ID, $id, $ecwd_event->post_title, $ecwd_event->post_content, $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_url'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'][0], $permalink, $ecwd_event, $term_metas, $ecwd_event_metas);
272
+ }
273
+ }
274
+ }
275
+ $this->merged_events += $google_events + $facebook_events + $ical_events + $events;
276
+
277
+ //$this->merged_events += $events;
278
+
279
+ global $ecwd_options;
280
+
281
+ $this->get_events_for_long_days();
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Comparison function for use when sorting merged event data (with usort)
287
+ */
288
+ function compare($event1, $event2) {
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  // //Sort ascending or descending
290
  // if ('asc' == $this->sort)
291
  // return $event1->start_time - $event2->start_time;
292
  //
293
  // return $event2->start_time - $event1->start_time;
294
+ }
295
+
296
+ /**
297
+ * Returns array of days with events, with sub-arrays of events for that day
298
+ */
299
+ public function get_event_days($events = '', $current_month = 1, $start_date = '', $end_date = '') {
300
+ if (!$events) {
301
+ $events = $this->merged_events;
302
+ }
303
+ if ($start_date && $end_date) {
304
+ $this->start_date = $start_date;
305
+ $this->end_date = $end_date;
306
+ }
307
+
308
+ foreach ($events as $id => $arr) {
309
+
310
+ if (is_int($arr->start_time)) {
311
+ $start_date = date('Y-m-d', $arr->start_time);
312
+ $end_date = date('Y-m-d', $arr->end_time);
313
+ $start_time = date('H:i', $arr->start_time);
314
+ $end_time = date('H:i', $arr->end_time);
315
+ } else {
316
+ $start_date = date('Y-m-d', strtotime($arr->start_time));
317
+ $end_date = date('Y-m-d', strtotime($arr->end_time));
318
+ $start_time = date('H:i', strtotime($arr->start_time));
319
+ $end_time = date('H:i', strtotime($arr->end_time));
320
+ }
321
+ $arr = (array) $arr;
322
+ $from = $start_date;
323
+ $to = $end_date;
324
+ $starttime = $start_time;
325
+ $endtime = $end_time;
326
+
327
+ $post = array_key_exists('post', $arr) ? $arr['post'] : '';
328
+ $color = array_key_exists('color', $arr) ? $arr['color'] : '';
329
+ $permalink = array_key_exists('permalink', $arr) ? $arr['permalink'] : '';
330
+ if ($permalink) {
331
+ $permalink = ECWD_Event::getLink($post, $from);
332
+ }
333
+
334
+ $metas = array_key_exists('metas', $arr) ? $arr['metas'] : '';
335
+ $terms = array_key_exists('terms', $arr) ? $arr['terms'] : '';
336
+ $venue = array();
337
+ if ($metas && isset($metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]) {
338
+ $venue_post = get_post($metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]);
339
+ if ($venue_post) {
340
+ $venue['name'] = $venue_post->post_title;
341
+ $venue['id'] = $venue_post->ID;
342
+ $venue['permalink'] = get_permalink($venue_post->ID);
343
+ }
344
+ }
345
+ $organizers = array();
346
+ $organizersIDs = array();
347
+ if ($metas && isset($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0])) {
348
+ if (is_serialized($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0])) {
349
+ $organizers_ids = unserialize($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0]);
350
+ } elseif (is_array($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0])) {
351
+ $organizers_ids = $metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0];
352
+ } else {
353
+ $organizers_ids = array();
354
+ }
355
+ if ($organizers_ids) {
356
+ foreach ($organizers_ids as $organizer_id) {
357
+ if ($organizer_id) {
358
+ $opost = get_post($organizer_id);
359
+ if ($opost) {
360
+ $organizers[] = array(
361
+ 'id' => $opost->ID,
362
+ 'name' => $opost->post_title,
363
+ 'permalink' => get_permalink($opost->ID)
364
+ );
365
+ $organizersIDs[] = $opost->ID;
366
+ }
367
+ }
368
+ }
369
+ }
370
+ }
371
+ if ($terms) {
372
+ if (isset($terms['0']['color'])) {
373
+ $color = $terms['0']['color'];
374
+ } else {
375
+ $color = '';
376
+ }
377
+ $catIds = array();
378
+ foreach ($terms as $term) {
379
+ if (isset($term['id'])) {
380
+ $catIds[] = $term['id'];
381
+ }
382
+ }
383
+ }
384
+
385
+ $this->event_options['id'] = $id;
386
+ $this->event_options['from'] = $from;
387
+ $this->event_options['to'] = $to;
388
+ $this->event_options['starttime'] = $start_time;
389
+ $this->event_options['endtime'] = $end_time;
390
+ $this->event_options['title'] = array_key_exists('title', $arr) ? $arr['title'] : '';
391
+ $this->event_options['details'] = array_key_exists('description', $arr) ? $arr['description'] : '';
392
+ $this->event_options['color'] = $color;
393
+ $this->event_options['link'] = array_key_exists('link', $arr) ? $arr['link'] : '';
394
+ $this->event_options['location'] = array_key_exists('location', $arr) ? $arr['location'] : '';
395
+ $this->event_options['permalink'] = array_key_exists('permalink', $arr) ? $arr['permalink'] : '';
396
+ $this->event_options['latlong'] = array_key_exists('latlong', $arr) ? $arr['latlong'] : '';
397
+ $this->event_options['terms'] = $terms;
398
+ $this->event_options['metas'] = $metas;
399
+ $this->event_options['all_day_event'] = ( isset($metas['ecwd_all_day_event'][0]) && $metas['ecwd_all_day_event'][0] == 1 ) ? 1 : 0;
400
+ $this->event_options['post'] = $post;
401
+ $this->event_options['image'] = array_key_exists('image', $arr) ? $arr['image'] : '';
402
+ $this->event_options['organizers'] = $organizers;
403
+ $this->event_options['venue'] = $venue;
404
+
405
+
406
+ if (isset($this->search['categories']) && $this->search['categories'] > 0) {
407
+ if (!array_intersect($this->search['categories'], $catIds)) {
408
+ continue;
409
+ };
410
+ }
411
+ //echo '<br />';
412
+
413
+ if (isset($this->search['venues']) && $this->search['venues'] > 0) {
414
+ if (!isset($metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]) || !count($venue)) {
415
+ continue;
416
+ } else {
417
+ if (!in_array($venue['id'], $this->search['venues'])) {
418
+ continue;
419
+ }
420
+ }
421
+ }
422
+ if (isset($this->search['organizers']) && $this->search['organizers'] > 0) {
423
+ if (!array_intersect($this->search['organizers'], $organizersIDs)) {
424
+ continue;
425
+ };
426
+ }
427
+ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
428
+ if (isset($this->search['weekdays']) && $this->search['weekdays'] > 0) {
429
+ $weekdays = $this->search['weekdays'];
430
+ }
431
+
432
+
433
+ if ($metas && isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] !== 'no_repeat' && $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] != '') {
434
+ $event_week_last_day = '';
435
+ if ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'weekly') {
436
+ $days = array();
437
+ if (isset($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_day'][0] != '' && $metas[ECWD_PLUGIN_PREFIX . '_event_day'][0] != 1) {
438
+
439
+ if (is_serialized($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0])) {
440
+ $days = unserialize($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0]);
441
+ } elseif (is_array($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0])) {
442
+ $days = $metas[ECWD_PLUGIN_PREFIX . '_event_day'][0];
443
+ }
444
+ } else {
445
+ $days = array(strtolower(date('l', strtotime($from))));
446
+ }
447
+
448
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
449
+ if (strtotime($until) > strtotime($this->end_date)) {
450
+ $until = $this->end_date;
451
+ }
452
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
453
+ if (count($days)) {
454
+ $event_week_last_day = $days[count($days) - 1];
455
+ }
456
+ $eventdays = $this->dateDiff($from, $until);
457
+ $eventdayslong = $this->dateDiff($from, $to);
458
+ if ($eventdays < 0) {
459
+ continue;
460
+ }
461
+ $from_date = $from;
462
+
463
+ for ($i = 0; $i <= $eventdays; $i ++) {
464
+ $eventdate = strtotime(date("Y-m-d", strtotime($from_date)) . " +" . $i . " day");
465
+ $week_day = strtolower(date('l', $eventdate));
466
+ $eventdate = date("Y-n-j", $eventdate);
467
+
468
+ if (is_array($days) && in_array($week_day, $days)) {
469
+ if ($how > 1 && $week_day == $event_week_last_day) {
470
+ $from_date = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( ( $how * 7 ) - 7 ) . " days"));
471
+ $from_date = date('Y-m-d', $from_date);
472
+ $next_week = date("Y-m-d", strtotime('next monday', strtotime($from_date)));
473
+ }
474
+ $from = $eventdate;
475
+
476
+ if (strtotime($until) >= strtotime(date('Y-m-d', strtotime($from)))) {
477
+
478
+
479
+ $to = date('Y-m-d', strtotime($from . ' + ' . $eventdayslong . ' days'));
480
+
481
+
482
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
483
+ $this->set_event($eventdate, $from, $to);
484
+ }
485
+ }
486
+ }
487
+ }
488
+ } elseif ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'daily') {
489
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
490
+
491
+ if (strtotime($until) > strtotime($this->end_date)) {
492
+ $until = $this->end_date;
493
+ }
494
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
495
+ $eventdays = $this->dateDiff($from, $until);
496
+ $eventdayslong = $this->dateDiff($from, $to);
497
+ if ($eventdays < 0) {
498
+ continue;
499
+ }
500
+ $from_date = $from;
501
+ for ($i = 0; $i <= $eventdays; $i ++) {
502
+ $date = strtotime(date("Y-m-d", strtotime($from_date)) . " +" . $i . " day");
503
+ $date = date("Y-n-j", $date);
504
+ if (strtotime($until) >= strtotime(date('Y-m-d', strtotime($date)))) {
505
+
506
+ $from_date = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( ( $how - 1 ) ) . " days"));
507
+ $from_date = date('Y-m-d', $from_date);
508
+ $from = $date;
509
+ $to = date('Y-m-d', strtotime($from . ' + ' . $eventdayslong . ' days'));
510
+
511
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
512
+ $this->set_event($date, $from, $to);
513
+ }
514
+ }
515
+ }
516
+ } else if ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'monthly') {
517
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
518
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
519
+ $eventdays = $this->dateDiff($from, $until);
520
+ $eventdayslong = $this->dateDiff($from, $to);
521
+ $event_from = $from;
522
+ $from_date = $from;
523
+ $repeat_days = isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days'][0] : 1;
524
+ $repeat_when = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_list_monthly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_list_monthly'][0] : false;
525
+ $repeat_day = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_week_monthly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_week_monthly'][0] : false;
526
+
527
+ $min_date = strtotime($event_from);
528
+ $max_date = strtotime("+1 MONTH", strtotime($until));
529
+ if ($max_date >= $min_date) {
530
+ $i = 0;
531
+ while (( $min_date = strtotime("+1 MONTH", $min_date) ) <= $max_date) {
532
+ //echo date('Y-m-d', $min_date).'----'.date('Y-m-d', $max_date).'<br />';
533
+ $date = strtotime(date("Y-m-d", strtotime($event_from)) . " +" . $i * $how . " MONTH");
534
+ if ($i > 0) {
535
+ if ($repeat_days == 2 && $repeat_day && $repeat_when && date('Y-m', strtotime($event_from)) !== date('Y-m', $date)) {
536
+ $monthyear = date("F Y", $date);
537
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $monthyear));
538
+ if ($repeat_date == '1970-01-01' || $repeat_date == '1969-12-31') {
539
+ $repeat_date = date('Y-m-d', strtotime($monthyear . ' ' . $repeat_when . ' ' . $repeat_day));
540
+ }
541
+
542
+ $date = strtotime($repeat_date);
543
+ }
544
+ }
545
+ $date = date("Y-n-j", $date);
546
+ $i ++;
547
+ if (strtotime($until) >= strtotime(date('Y-m-d', strtotime($date)))) {
548
+ $min_date = $from_date = strtotime(( date("Y-m-1", ( strtotime($date))) . " +" . ( ( $how ) ) . " month"));
549
+ $eventdays -= 30;
550
+ $from_date = strtotime(( date("Y-m-d", $from_date) . " - 1 day"));
551
+
552
+ $from_date = date('Y-m-d', $from_date);
553
+ $from = $date;
554
+ $to = strtotime(( date("Y-m-d", ( strtotime($from))) . " +" . ( $eventdayslong ) . " days"));
555
+ $to = date('Y-m-d', $to);
556
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
557
+ $this->set_event($date, $from, $to);
558
+ }
559
+ }
560
+ }
561
+ }
562
+ } else if ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'yearly') {
563
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
564
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
565
+ $eventdays = $this->dateDiff($from, $until);
566
+ $eventdayslong = $this->dateDiff($from, $to);
567
+ $event_from = $from;
568
+ $from_date = $from;
569
+ $repeat_days = isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days'][0] : 1;
570
+ $repeat_when = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_list_yearly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_list_yearly'][0] : false;
571
+ $repeat_day = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_week_yearly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_week_yearly'][0] : false;
572
+ if (isset($metas[ECWD_PLUGIN_PREFIX . '_event_year_month'][0]) && $repeat_days == 2) {
573
+ $month = $metas[ECWD_PLUGIN_PREFIX . '_event_year_month'][0];
574
+ $monthName = date('F', strtotime('2015-' . $month . '-1'));
575
+ } else {
576
+ $monthName = date('F', strtotime($from_date));
577
+ }
578
+ $min_date = strtotime($event_from);
579
+ $max_date = strtotime($until);
580
+ $i = 0;
581
+ while (( $min_date = strtotime("+1 YEAR", $min_date) ) <= $max_date) {
582
+ $date = strtotime(date("Y-m-d", strtotime($event_from)) . " +" . $i * $how . " YEAR");
583
+ if ($i > 0) {
584
+ if ($repeat_days == 1) {
585
+ $monthyear = $monthName . ' ' . date("d Y", $date);
586
+ $repeat_date = strtotime(date('Y-m-d', strtotime($monthyear)));
587
+ $date = $repeat_date;
588
+ }
589
+ if ($repeat_days == 2 && $repeat_day && $repeat_when) {
590
+ $monthyear = $monthName . ' ' . date("Y", $date);
591
+ //echo $repeat_when.' '.ucfirst( $repeat_day ).' of '.$monthyear.'<br />';
592
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $monthyear));
593
+ if ($repeat_date == '1970-01-01' || $repeat_date == '1969-12-31') {
594
+ $repeat_date = date('Y-m-d', strtotime($monthyear . ' ' . $repeat_when . ' ' . $repeat_day));
595
+ }
596
+ //$repeat_date = date( 'Y-m-d', strtotime($repeat_when.' '.ucfirst( $repeat_day ).' of '.$monthyear) );
597
+ //don't know why, but "last sunday,last monday... returns last s,m of previous month"
598
+ if ($repeat_when == 'last') {
599
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $monthyear, strtotime("+1 MONTH", $repeat_date)));
600
+ }
601
+ $date = strtotime($repeat_date);
602
+ }
603
+ }
604
+ $date = date("Y-n-j", $date);
605
+
606
+ $i ++;
607
+ if (strtotime($until) >= strtotime(date('Y-m-t', strtotime($this->date))) && strtotime($date) <= strtotime($until)) {
608
+ $from_date = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( ( $how ) ) . " year"));
609
+ $from_date = strtotime(( date("Y-m-d", $from_date) . " - 1 day"));
610
+ $from_date = date('Y-m-d', $from_date);
611
+ $from = $date;
612
+ $to = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( $eventdayslong ) . " days"));
613
+ $to = date('Y-m-d', $to);
614
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
615
+ $this->set_event($date, $from, $to);
616
+ }
617
+ }
618
+ }
619
+ }
620
+ } else {
621
+ $eventdays = $this->dateDiff($from, $to); // get the difference in days between the two dates
622
+ $date = strtotime(date("Y-m-d", strtotime($from)));
623
+ $date = date("Y-n-j", $date);
624
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
625
+ $this->set_event($date, $from, $to);
626
+ }
627
+ }
628
+ }
629
+
630
+ if ($this->events) {
631
+ $this->events = $this->arraySort($this->events, 'from');
632
+ }
633
+ if ($events) {
634
+ return $this->events;
635
+ }
636
+ }
637
+
638
+ /**
639
+ * Returns array of days with events, with sub-arrays of events for that day
640
+ */
641
+ public function get_events_for_long_days($events = '', $current_month = 1, $start_date = '', $end_date = '') {
642
+ global $ecwd_options;
643
+ if (!$events) {
644
+ $events = $this->merged_events;
645
+ }
646
+
647
+ if ($start_date && $end_date) {
648
+ $this->start_date = $start_date;
649
+ $this->end_date = $end_date;
650
+ }
651
+ foreach ($events as $id => $arr) {
652
+
653
+ if (is_int($arr->start_time)) {
654
+ $start_date = date('Y-m-d', $arr->start_time);
655
+ $end_date = date('Y-m-d', $arr->end_time);
656
+ $start_time = date('H:i', $arr->start_time);
657
+ $end_time = date('H:i', $arr->end_time);
658
+ } else {
659
+ $start_date = date('Y-m-d', strtotime($arr->start_time));
660
+ $end_date = date('Y-m-d', strtotime($arr->end_time));
661
+ $start_time = date('H:i', strtotime($arr->start_time));
662
+ $end_time = date('H:i', strtotime($arr->end_time));
663
+ }
664
+ $arr = (array) $arr;
665
+ $from = $start_date;
666
+ $to = $end_date;
667
+ $starttime = $start_time;
668
+ $endtime = $end_time;
669
+
670
+ $post = array_key_exists('post', $arr) ? $arr['post'] : '';
671
+ $color = array_key_exists('color', $arr) ? $arr['color'] : '';
672
+ $permalink = array_key_exists('permalink', $arr) ? $arr['permalink'] : '';
673
+ if ($permalink) {
674
+ $permalink = ECWD_Event::getLink($post, $from);
675
+ }
676
+
677
+ $metas = array_key_exists('metas', $arr) ? $arr['metas'] : '';
678
+ $terms = array_key_exists('terms', $arr) ? $arr['terms'] : '';
679
+ $venue = array();
680
+ if ($metas && isset($metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]) {
681
+ $venue_post = get_post($metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]);
682
+ if ($venue_post) {
683
+ $venue['name'] = $venue_post->post_title;
684
+ $venue['id'] = $venue_post->ID;
685
+ $venue['permalink'] = get_permalink($venue_post->ID);
686
+ }
687
+ }
688
+
689
+ $organizers = array();
690
+ $organizersIDs = array();
691
+ if ($metas && isset($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0])) {
692
+ if (is_serialized($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0])) {
693
+ $organizers_ids = unserialize($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0]);
694
+ } elseif (is_array($metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0])) {
695
+ $organizers_ids = $metas[ECWD_PLUGIN_PREFIX . '_event_organizers'][0];
696
+ } else {
697
+ $organizers_ids = array();
698
+ }
699
+ if ($organizers_ids) {
700
+ foreach ($organizers_ids as $organizer_id) {
701
+ if ($organizer_id) {
702
+ $opost = get_post($organizer_id);
703
+ if ($opost) {
704
+ $organizers[] = array(
705
+ 'id' => $opost->ID,
706
+ 'name' => $opost->post_title,
707
+ 'permalink' => get_permalink($opost->ID)
708
+ );
709
+ $organizersIDs[] = $opost->ID;
710
+ }
711
+ }
712
+ }
713
+ }
714
+ }
715
+ if ($terms) {
716
+ if (isset($terms['0']['color'])) {
717
+ $color = $terms['0']['color'];
718
+ } else {
719
+ $color = '';
720
+ }
721
+ $catIds = array();
722
+ foreach ($terms as $term) {
723
+ if (isset($term['id'])) {
724
+ $catIds[] = $term['id'];
725
+ }
726
+ }
727
+ }
728
+
729
+
730
+ $this->event_options['id'] = $id;
731
+ $this->event_options['from'] = $from;
732
+ $this->event_options['to'] = $to;
733
+ $this->event_options['starttime'] = $start_time;
734
+ $this->event_options['endtime'] = $end_time;
735
+ $this->event_options['title'] = array_key_exists('title', $arr) ? $arr['title'] : '';
736
+ $this->event_options['details'] = array_key_exists('description', $arr) ? $arr['description'] : '';
737
+ $this->event_options['color'] = $color;
738
+ $this->event_options['link'] = array_key_exists('link', $arr) ? $arr['link'] : '';
739
+ $this->event_options['location'] = array_key_exists('location', $arr) ? $arr['location'] : '';
740
+ $this->event_options['permalink'] = array_key_exists('permalink', $arr) ? $arr['permalink'] : '';
741
+ $this->event_options['latlong'] = array_key_exists('latlong', $arr) ? $arr['latlong'] : '';
742
+ $this->event_options['terms'] = $terms;
743
+ $this->event_options['metas'] = $metas;
744
+ $this->event_options['all_day_event'] = ( isset($metas['ecwd_all_day_event'][0]) && $metas['ecwd_all_day_event'][0] == 1 ) ? 1 : 0;
745
+ $this->event_options['post'] = $post;
746
+ $this->event_options['image'] = array_key_exists('image', $arr) ? $arr['image'] : '';
747
+ $this->event_options['organizers'] = $organizers;
748
+ $this->event_options['venue'] = $venue;
749
+
750
+
751
+
752
+ if (isset($this->search['categories']) && $this->search['categories'] > 0) {
753
+ if (!array_intersect($this->search['categories'], $catIds)) {
754
+ continue;
755
+ };
756
+ }
757
+ //echo '<br />';
758
+
759
+ if (isset($this->search['venues']) && $this->search['venues'] > 0) {
760
+ if (!isset($metas[ECWD_PLUGIN_PREFIX . '_event_venue'][0]) || !count($venue)) {
761
+ continue;
762
+ } else {
763
+ if (!in_array($venue['id'], $this->search['venues'])) {
764
+ continue;
765
+ }
766
+ }
767
+ }
768
+ if (isset($this->search['organizers']) && $this->search['organizers'] > 0) {
769
+ if (!array_intersect($this->search['organizers'], $organizersIDs)) {
770
+ continue;
771
+ };
772
+ }
773
+ $weekdays = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
774
+ if (isset($this->search['weekdays']) && $this->search['weekdays'] > 0) {
775
+ $weekdays = $this->search['weekdays'];
776
+ }
777
+
778
+ if ($metas && isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] !== 'no_repeat' && $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] != '') {
779
+ $event_week_last_day = '';
780
+
781
+ if ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'weekly') {
782
+ $days = array();
783
+ if (isset($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_day'][0] != '' && $metas[ECWD_PLUGIN_PREFIX . '_event_day'][0] != 1) {
784
+
785
+ if (is_serialized($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0])) {
786
+ $days = unserialize($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0]);
787
+ } elseif (is_array($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0])) {
788
+ $days = $metas[ECWD_PLUGIN_PREFIX . '_event_day'][0];
789
+ }
790
+ } else {
791
+ $days = array(strtolower(date('l', strtotime($from))));
792
+ }
793
+
794
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
795
+ if (strtotime($until) > strtotime($this->end_date)) {
796
+ $until = $this->end_date;
797
+ }
798
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
799
+ if (count($days)) {
800
+ $event_week_last_day = $days[count($days) - 1];
801
+ }
802
+ $eventdays = $this->dateDiff($from, $until);
803
+ $eventdayslong = $this->dateDiff($from, $to);
804
+ if ($eventdays < 0) {
805
+ continue;
806
+ }
807
+ $from_date = $from;
808
+
809
+ for ($i = 0; $i <= $eventdays; $i ++) {
810
+ $eventdate = strtotime(date("Y-m-d", strtotime($from_date)) . " +" . $i . " day");
811
+ $week_day = strtolower(date('l', $eventdate));
812
+ $eventdate = date("Y-n-j", $eventdate);
813
+
814
+ if (is_array($days) && in_array($week_day, $days)) {
815
+ if ($how > 1 && $week_day == $event_week_last_day) {
816
+ $from_date = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( ( $how * 7 ) - 7 ) . " days"));
817
+ $from_date = date('Y-m-d', $from_date);
818
+ $next_week = date("Y-m-d", strtotime('next monday', strtotime($from_date)));
819
+ }
820
+ $from = $eventdate;
821
+
822
+ if (strtotime($until) >= strtotime(date('Y-m-d', strtotime($from)))) {
823
+ $to = date('Y-m-d', strtotime($from . ' + ' . $eventdayslong . ' days'));
824
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
825
+ $this->set_long_event($eventdate, $from, $to);
826
+ }
827
+ }
828
+ }
829
+ }
830
+ } elseif ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'daily') {
831
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
832
+
833
+ if (strtotime($until) > strtotime($this->end_date)) {
834
+ $until = $this->end_date;
835
+ }
836
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
837
+ $eventdays = $this->dateDiff($from, $until);
838
+ $eventdayslong = $this->dateDiff($from, $to);
839
+ if ($eventdays < 0) {
840
+ continue;
841
+ }
842
+ $from_date = $from;
843
+ for ($i = 0; $i <= $eventdays; $i ++) {
844
+ $date = strtotime(date("Y-m-d", strtotime($from_date)) . " +" . $i . " day");
845
+ $date = date("Y-n-j", $date);
846
+ if (strtotime($until) >= strtotime(date('Y-m-d', strtotime($date)))) {
847
+
848
+ $from_date = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( ( $how - 1 ) ) . " days"));
849
+ $from_date = date('Y-m-d', $from_date);
850
+ $from = $date;
851
+ $to = date('Y-m-d', strtotime($from . ' + ' . $eventdayslong . ' days'));
852
+
853
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
854
+ $this->set_long_event($date, $from, $to);
855
+ }
856
+ }
857
+ }
858
+ } else if ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'monthly') {
859
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
860
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
861
+ $eventdays = $this->dateDiff($from, $until);
862
+ $eventdayslong = $this->dateDiff($from, $to);
863
+ $event_from = $from;
864
+ $from_date = $from;
865
+ $repeat_days = isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days'][0] : 1;
866
+ $repeat_when = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_list_monthly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_list_monthly'][0] : false;
867
+ $repeat_day = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_week_monthly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_week_monthly'][0] : false;
868
+
869
+ $min_date = strtotime($event_from);
870
+ $max_date = strtotime("+1 MONTH", strtotime($until));
871
+ if ($max_date >= $min_date) {
872
+ $i = 0;
873
+ while (( $min_date = strtotime("+1 MONTH", $min_date) ) <= $max_date) {
874
+ //echo date('Y-m-d', $min_date).'----'.date('Y-m-d', $max_date).'<br />';
875
+ $date = strtotime(date("Y-m-d", strtotime($event_from)) . " +" . $i * $how . " MONTH");
876
+ if ($i > 0) {
877
+ if ($repeat_days == 2 && $repeat_day && $repeat_when && date('Y-m', strtotime($event_from)) !== date('Y-m', $date)) {
878
+ $monthyear = date("F Y", $date);
879
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $monthyear));
880
+ if ($repeat_date == '1970-01-01' || $repeat_date == '1969-12-31') {
881
+ $repeat_date = date('Y-m-d', strtotime($monthyear . ' ' . $repeat_when . ' ' . $repeat_day));
882
+ }
883
+
884
+ $date = strtotime($repeat_date);
885
+ }
886
+ }
887
+ $date = date("Y-n-j", $date);
888
+ $i ++;
889
+ if (strtotime($until) >= strtotime(date('Y-m-d', strtotime($date)))) {
890
+ $min_date = $from_date = strtotime(( date("Y-m-1", ( strtotime($date))) . " +" . ( ( $how ) ) . " month"));
891
+ $eventdays -= 30;
892
+ $from_date = strtotime(( date("Y-m-d", $from_date) . " - 1 day"));
893
+
894
+ $from_date = date('Y-m-d', $from_date);
895
+ $from = $date;
896
+ $to = strtotime(( date("Y-m-d", ( strtotime($from))) . " +" . ( $eventdayslong ) . " days"));
897
+ $to = date('Y-m-d', $to);
898
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
899
+ $this->set_long_event($date, $from, $to);
900
+ }
901
+ }
902
+ }
903
+ }
904
+ } else if ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'yearly') {
905
+ $until = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0] : $to );
906
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
907
+ $eventdays = $this->dateDiff($from, $until);
908
+ $eventdayslong = $this->dateDiff($from, $to);
909
+ $event_from = $from;
910
+ $from_date = $from;
911
+ $repeat_days = isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days'][0] : 1;
912
+ $repeat_when = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_list_yearly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_list_yearly'][0] : false;
913
+ $repeat_day = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_week_yearly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_week_yearly'][0] : false;
914
+ if (isset($metas[ECWD_PLUGIN_PREFIX . '_event_year_month'][0]) && $repeat_days == 2) {
915
+ $month = $metas[ECWD_PLUGIN_PREFIX . '_event_year_month'][0];
916
+ $monthName = date('F', strtotime('2015-' . $month . '-1'));
917
+ } else {
918
+ $monthName = date('F', strtotime($from_date));
919
+ }
920
+ $min_date = strtotime($event_from);
921
+ $max_date = strtotime($until);
922
+ $i = 0;
923
+ while (( $min_date = strtotime("+1 YEAR", $min_date) ) <= $max_date) {
924
+ $date = strtotime(date("Y-m-d", strtotime($event_from)) . " +" . $i * $how . " YEAR");
925
+ if ($i > 0) {
926
+ if ($repeat_days == 1) {
927
+ $monthyear = $monthName . ' ' . date("d Y", $date);
928
+ $repeat_date = strtotime(date('Y-m-d', strtotime($monthyear)));
929
+ $date = $repeat_date;
930
+ }
931
+ if ($repeat_days == 2 && $repeat_day && $repeat_when) {
932
+ $monthyear = $monthName . ' ' . date("Y", $date);
933
+ //echo $repeat_when.' '.ucfirst( $repeat_day ).' of '.$monthyear.'<br />';
934
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $monthyear));
935
+ if ($repeat_date == '1970-01-01' || $repeat_date == '1969-12-31') {
936
+ $repeat_date = date('Y-m-d', strtotime($monthyear . ' ' . $repeat_when . ' ' . $repeat_day));
937
+ }
938
+ //$repeat_date = date( 'Y-m-d', strtotime($repeat_when.' '.ucfirst( $repeat_day ).' of '.$monthyear) );
939
+ //don't know why, but "last sunday,last monday... returns last s,m of previous month"
940
+ if ($repeat_when == 'last') {
941
+ $repeat_date = date('Y-m-d', strtotime($repeat_when . ' ' . ucfirst($repeat_day) . ' of ' . $monthyear, strtotime("+1 MONTH", $repeat_date)));
942
+ }
943
+ $date = strtotime($repeat_date);
944
+ }
945
+ }
946
+ $date = date("Y-n-j", $date);
947
+
948
+ $i ++;
949
+ if (strtotime($until) >= strtotime(date('Y-m-t', strtotime($this->date))) && strtotime($date) <= strtotime($until)) {
950
+ $from_date = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( ( $how ) ) . " year"));
951
+ $from_date = strtotime(( date("Y-m-d", $from_date) . " - 1 day"));
952
+ $from_date = date('Y-m-d', $from_date);
953
+ $from = $date;
954
+ $to = strtotime(( date("Y-m-d", ( strtotime($from_date))) . " +" . ( $eventdayslong ) . " days"));
955
+ $to = date('Y-m-d', $to);
956
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
957
+ $this->set_long_event($date, $from, $to);
958
+ }
959
+ }
960
+ }
961
+ }
962
+ } else {
963
+ $eventdays = $this->dateDiff($from, $to); // get the difference in days between the two dates
964
+ $date = strtotime(date("Y-m-d", strtotime($from)));
965
+ $date = date("Y-n-j", $date);
966
+ if (!$current_month || ( strtotime($from) <= strtotime($this->end_date) && strtotime($from) >= strtotime($this->start_date) && in_array(strtolower(date('l', strtotime($from))), $weekdays) )) {
967
+ $this->set_long_event($date, $from, $to);
968
+ }
969
+ }
970
+ }
971
+
972
+
973
+ if ($events) {
974
+ return $this->events;
975
+ }
976
+ }
977
+
978
+ private function set_long_event($date, $from, $to) {
979
+ global $ecwd_options;
980
+ $event_data = $this->event_options;
981
+ $event_data['date'] = $date;
982
+ $event_data['from'] = $from;
983
+ $event_data['to'] = $to;
984
+ if ($event_data['permalink']) {
985
+ $event_data['permalink'] = ECWD_Event::getLink($event_data['post'], $from);
986
+ }
987
+
988
+ if (isset($ecwd_options["long_events"]) && $ecwd_options["long_events"] == '1' &&
989
+ !($this->display == 'posterboard' || $this->display == 'map')) {
990
+ $long_to = $to;
991
+
992
+ if (strtotime($long_to) > strtotime($this->end_date)) {
993
+ $long_to = $this->end_date;
994
+ }
995
+
996
+ $date_for_diff = $date;
997
+ if (strtotime($date_for_diff) < strtotime($this->start_date)) {
998
+ $date_for_diff = $this->start_date;
999
+ }
1000
+ $long_days = $this->dateDiff($date_for_diff, $long_to);
1001
+
1002
+ for ($j = 0; $j <= $long_days; $j ++) {
1003
+
1004
+ $long_from = strtotime(date("Y-m-d", strtotime($date)) . " + " . $j . " day");
1005
+ if (!isset($this->events[$long_from])) {
1006
+ $this->events[$long_from] = array();
1007
+ }
1008
+ $event_data['date'] = date("Y-n-j", $long_from);
1009
+ $this->events[$long_from][] = $event_data;
1010
+ }
1011
+ } else {
1012
+ $this->events[] = $event_data;
1013
+ }
1014
+ }
1015
+
1016
+ private function set_event($date, $from, $to) {
1017
+ global $ecwd_options;
1018
+ $event_data = $this->event_options;
1019
+ $event_data['date'] = $date;
1020
+ $event_data['from'] = $from;
1021
+ $event_data['to'] = $to;
1022
+ if ($event_data['permalink']) {
1023
+ $event_data['permalink'] = ECWD_Event::getLink($event_data['post'], $from);
1024
+ }
1025
+ $this->events[] = $event_data;
1026
+ }
1027
+
1028
+ function literalDate($timestamp, $weekday) {
1029
+ $timestamp = is_numeric($timestamp) ? $timestamp : strtotime($timestamp);
1030
+ $month = date('M', $timestamp);
1031
+ $ord = 0;
1032
+
1033
+ while (date('M', ( $timestamp = strtotime('-1 week', $timestamp))) == $month) {
1034
+ $ord ++;
1035
+ }
1036
+
1037
+ $lit = array('first', 'second', 'third', 'fourth', 'fifth');
1038
+
1039
+ return strtolower($lit[$ord] . ' ' . $weekday);
1040
+ }
1041
+
1042
+ /**
1043
+ * Return the calendar
1044
+ */
1045
+ public function get_view($date = '', $type = '', $widget = 0, $ecwd_views, $preview) {
1046
+ require_once 'calendar-class.php';
1047
+ $categories = get_categories(array('taxonomy' => ECWD_PLUGIN_PREFIX . '_event_category'));
1048
+ $tags = get_terms('ecwd_event_tag', array('hide_empty' => false));
1049
+
1050
+ //Get events data
1051
+ //Generate the calendar markup and return it
1052
+ $cal = new Calendar($type, $date, '', $widget, $this->page_items, $this->page, $this->displays, $this->filters, $this->event_search, array(), $preview);
1053
+ $search_params = $this->search;
1054
+ if (is_array($search_params) && ( ( isset($search_params['query']) && $search_params['query'] !== '' ) || ( isset($search_params['category']) && $search_params['category'] > 0 ) || ( isset($search_params['tag']) && $search_params['tag'] > 0 ) ) || ( isset($search_params['venue']) && $search_params['venue'] > 0 ) || ( isset($search_params['organizer']) && $search_params['organizer'] > 0 )) {
1055
+ $cal->search_params = $this->search;
1056
+ }
1057
+ if ($categories) {
1058
+ $cal->add_terms('categories', $categories);
1059
+ }
1060
+ if ($tags) {
1061
+ $cal->add_terms('tags', $tags);
1062
+ }
1063
+
1064
+ $args = array(
1065
+ 'post_type' => ECWD_PLUGIN_PREFIX . '_venue',
1066
+ 'post_status' => 'publish',
1067
+ 'posts_per_page' => - 1,
1068
+ 'ignore_sticky_posts' => 1
1069
+ );
1070
+ $venues = get_posts($args);
1071
+ if ($venues) {
1072
+ $cal->add_terms('venues', $venues);
1073
+ }
1074
+ $args = array(
1075
+ 'post_type' => ECWD_PLUGIN_PREFIX . '_organizer',
1076
+ 'post_status' => 'publish',
1077
+ 'posts_per_page' => - 1,
1078
+ 'ignore_sticky_posts' => 1
1079
+ );
1080
+ $organizers = get_posts($args);
1081
+ if ($organizers) {
1082
+ $cal->add_terms('organizers', $organizers);
1083
+ }
1084
+
1085
+ if ($this->events) {
1086
+ $cal->addEvents($this->events);
1087
+ }
1088
+
1089
+ return $cal->showcal();
1090
+ }
1091
+
1092
+ public function get_countdown($event_id, $date = '', $display = '', $widget = '') {
1093
+ $next_event = null;
1094
+ $count_down_events = array();
1095
+ if ($this->events) {
1096
+ foreach ($this->events as $id => $event) {
1097
+ $start = strtotime($event['from'] . 'T' . $event['starttime']);
1098
+ if ($start >= strtotime(gmdate('Y-m-dTH:i'))) {
1099
+ $count_down_events[$id] = $event;
1100
+ $next_event = $count_down_events[$id];
1101
+ break;
1102
+ }
1103
+ }
1104
+ } else {
1105
+
1106
+ $ecwd_event = get_post($event_id);
1107
+ $term_metas = '';
1108
+ if ($ecwd_event) {
1109
+ $categories = get_the_terms($ecwd_event->ID, ECWD_PLUGIN_PREFIX . '_event_category');
1110
+ if (is_array($categories)) {
1111
+ foreach ($categories as $category) {
1112
+ $term_metas = get_option("ecwd_event_category_$category->term_id");
1113
+ $term_metas['id'] = $category->term_id;
1114
+ $term_metas['name'] = $category->name;
1115
+ $term_metas['slug'] = $category->slug;
1116
+ }
1117
+ }
1118
+ $ecwd_event_metas = get_post_meta($ecwd_event->ID, '', true);
1119
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_url'] = array(0 => '');
1120
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'])) {
1121
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'] = array(0 => '');
1122
+ }
1123
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'])) {
1124
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'] = array(0 => '');
1125
+ }
1126
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'])) {
1127
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'] = array(0 => '');
1128
+ }
1129
+ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'])) {
1130
+ $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'] = array(0 => '');
1131
+ }
1132
+
1133
+
1134
+ $permalink = get_permalink($ecwd_event->ID);
1135
+
1136
+ $events[$ecwd_event->ID] = new ECWD_Event($ecwd_event->ID, '', $ecwd_event->post_title, $ecwd_event->post_content, $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_url'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'][0], $permalink, $ecwd_event, $term_metas, $ecwd_event_metas);
1137
+
1138
+ $this->merged_events = $events;
1139
+ //$this->merged_events += $events;
1140
+ $this->get_event_days('', 0);
1141
+
1142
+ if ($this->events) {
1143
+ foreach ($this->events as $id => $event) {
1144
+ $start = strtotime($event['from'] . 'T' . $event['starttime']);
1145
+ if ($start >= strtotime(gmdate('Y-m-dTH:i'))) {
1146
+ $count_down_events[$id] = $event;
1147
+ $next_event = $count_down_events[$id];
1148
+ break;
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+ }
1154
+
1155
+ return $next_event;
1156
+ }
1157
+
1158
+ public function get_repeat_rate($event_id, $metas = '', $datefomat = 'Y-m-d') {
1159
+ $repeat_text = '';
1160
+ if (!$metas) {
1161
+ $metas = get_post_meta($event_id, '', true);
1162
+ }
1163
+ $from = $metas[ECWD_PLUGIN_PREFIX . '_event_date_from'][0];
1164
+ $days = array();
1165
+ if (isset($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_day'][0] != '') {
1166
+ if (is_serialized($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0])) {
1167
+ $days = unserialize($metas[ECWD_PLUGIN_PREFIX . '_event_day'][0]);
1168
+ }
1169
+ } else {
1170
+ $days = array(strtolower(date('l', strtotime($from))));
1171
+ }
1172
+ if ($metas && isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0]) && $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] !== 'no_repeat' && $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] != '') {
1173
+ $how = ( isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_how'][0] : 1 );
1174
+
1175
+ if ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'daily') {
1176
+ if ($how > 1) {
1177
+ $repeat_text .= 'Repeat every ' . $how . ' days';
1178
+ } else {
1179
+ $repeat_text .= 'Repeat every day';
1180
+ }
1181
+ } elseif ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'weekly') {
1182
+ if ($how > 1) {
1183
+ $repeat_text .= 'Repeat every ' . $how . ' weeks';
1184
+ } else {
1185
+ $repeat_text .= 'Repeat every week';
1186
+ }
1187
+
1188
+
1189
+ if (count($days) > 0) {
1190
+ $repeat_text .= ' on ';
1191
+ foreach ($days as $i => $day) {
1192
+ $repeat_text .= ucfirst($day) . 's';
1193
+ if ($i !== ( count($days) - 1 )) {
1194
+ $repeat_text .= ',';
1195
+ }
1196
+ $repeat_text .= ' ';
1197
+ }
1198
+ }
1199
+ } elseif ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'monthly') {
1200
+ if ($how > 1) {
1201
+ $repeat_text .= 'Repeat every ' . $how . ' months';
1202
+ } else {
1203
+ $repeat_text .= 'Repeat every month';
1204
+ }
1205
+ $repeat_days = isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_month_on_days'][0] : 1;
1206
+
1207
+ if ($repeat_days == 1) {
1208
+ $repeat_text .= ' on the same day';
1209
+ } else {
1210
+ $repeat_when = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_list_monthly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_list_monthly'][0] : false;
1211
+ $repeat_day = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_week_monthly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_week_monthly'][0] : false;
1212
+ if ($repeat_when && $repeat_day) {
1213
+ $repeat_text .= ' on the ' . ucfirst($repeat_when) . ' ' . ucfirst($repeat_day);
1214
+ }
1215
+ }
1216
+ } elseif ($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_event'][0] == 'yearly') {
1217
+ if ($how > 1) {
1218
+ $repeat_text .= 'Repeat every ' . $how . ' years';
1219
+ } else {
1220
+ $repeat_text .= 'Repeat every year';
1221
+ }
1222
+
1223
+ $repeat_days = isset($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_event_repeat_year_on_days'][0] : 1;
1224
+ if (isset($metas[ECWD_PLUGIN_PREFIX . '_event_year_month'][0])) {
1225
+ $month = $metas[ECWD_PLUGIN_PREFIX . '_event_year_month'][0];
1226
+ $monthName = date('F', strtotime('2015-' . $month . '-1'));
1227
+ } else {
1228
+ $monthName = date('F', strtotime($from));
1229
+ }
1230
+ $repeat_text .= ' in ' . $monthName;
1231
+ if ($repeat_days == 1) {
1232
+ $repeat_text .= ' on the same day';
1233
+ } else {
1234
+ $repeat_when = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_list_yearly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_list_yearly'][0] : false;
1235
+ $repeat_day = isset($metas[ECWD_PLUGIN_PREFIX . '_monthly_week_yearly'][0]) ? $metas[ECWD_PLUGIN_PREFIX . '_monthly_week_yearly'][0] : false;
1236
+ if ($repeat_when && $repeat_day) {
1237
+ $repeat_text .= ' on the ' . ucfirst($repeat_when) . ' ' . ucfirst($repeat_day);
1238
+ }
1239
+ }
1240
+ }
1241
+ $repeat_text .= ' until ' . date($datefomat, strtotime($metas[ECWD_PLUGIN_PREFIX . '_event_repeat_repeat_until'][0]));
1242
+ }
1243
+
1244
+ return $repeat_text;
1245
+ }
1246
+
1247
+ function events_unique($array) {
1248
+ $events_ids = array();
1249
+ foreach ($array as $key => $event) {
1250
+ if (!in_array($event['id'], $events_ids)) {
1251
+ $events_ids[] = $event['id'];
1252
+ } else {
1253
+ unset($array[$key]);
1254
+ }
1255
+ }
1256
+
1257
+ return $array;
1258
+ }
1259
+
1260
+ public function arraySort($a, $subkey) {
1261
+ foreach ($a as $k => $v) {
1262
+ $b[$k] = strtotime($v[$subkey] . 'T' . $v['starttime']);
1263
+ }
1264
+ asort($b);
1265
+ foreach ($b as $key => $val) {
1266
+ $c[] = $a[$key];
1267
+ }
1268
+
1269
+ return $c;
1270
+ }
1271
+
1272
+ public function dateDiff($beginDate, $endDate) {
1273
+ if ($endDate == '') {
1274
+ return 0;
1275
+ }
1276
+ $fromDate = date('Y-n-j', strtotime($beginDate));
1277
+ $toDate = date('Y-n-j', strtotime($endDate));
1278
+ $date_parts1 = explode('-', $fromDate);
1279
+ $date_parts2 = explode('-', $toDate);
1280
+
1281
+ $start_date = gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
1282
+ $end_date = gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
1283
+
1284
+ return $end_date - $start_date;
1285
+ }
1286
 
1287
  }
includes/ecwd-functions.php CHANGED
@@ -271,7 +271,7 @@ function replaceFirstImages( $content ) {
271
  }
272
 
273
  function ecwd_event_popup_ajax() {
274
-
275
  if (isset($_POST['id'])) {
276
  $post_id = $_POST['id'];
277
  include_once(ECWD_DIR . '/views/ecwd-event-popup.php');
271
  }
272
 
273
  function ecwd_event_popup_ajax() {
274
+ $ajax_date = isset($_POST['date']) ? $_POST['date'] : null;
275
  if (isset($_POST['id'])) {
276
  $post_id = $_POST['id'];
277
  include_once(ECWD_DIR . '/views/ecwd-event-popup.php');
includes/register-settings.php CHANGED
@@ -222,12 +222,13 @@ function ecwd_register_settings() {
222
  'type' => 'radio',
223
  'default' => 0
224
  ),
225
- // 'featured_image_for_themes' => array(
226
- // 'id' => 'featured_image_for_themes',
227
- // 'name' => __('', 'ecwd'),
228
- // 'desc' => 'Tick the checkbox to enable featured image for posts and pages if it does not function by default',
229
- // 'type' => 'checkbox'
230
- // ),
 
231
  ),
232
  'category_archive' => array(
233
  'category_archive_slug' => array(
@@ -284,7 +285,7 @@ function ecwd_register_settings() {
284
  $calendar = get_posts(array(
285
  'post_type' => 'ecwd_calendar'
286
  ));
287
- $settings_init_on_activate = ((strpos($_SERVER['REQUEST_URI'], 'plugins.php')) && ((empty($calendar) && (get_option("activation_page_option") === false)) || isset($_POST['ecwd_settings_general']['week_starts'])));
288
  if ($settings_init_on_activate) {
289
  update_option("activation_page_option", "submit");
290
  include_once "activation_settings_page.php";
222
  'type' => 'radio',
223
  'default' => 0
224
  ),
225
+ 'long_events' => array(
226
+ 'id' => 'long_events',
227
+ 'name' => __('Mark all days of multi-day event', 'ecwd'),
228
+ 'desc' => '',
229
+ 'type' => 'radio',
230
+ 'default' => 0
231
+ ),
232
  ),
233
  'category_archive' => array(
234
  'category_archive_slug' => array(
285
  $calendar = get_posts(array(
286
  'post_type' => 'ecwd_calendar'
287
  ));
288
+ $settings_init_on_activate = ((strpos($_SERVER['REQUEST_URI'], 'plugins.php')) && ((empty($calendar) && (get_option("activation_page_option") === false)) || isset($_POST['ecwd_settings_general']['week_starts'])));
289
  if ($settings_init_on_activate) {
290
  update_option("activation_page_option", "submit");
291
  include_once "activation_settings_page.php";
js/scripts.js CHANGED
@@ -70,9 +70,11 @@ if (typeof ecwd_js_init != "function")
70
  body_class: "ecwd-excluded-events ecwd_popup_body_scroll",
71
  title: "Event Details",
72
  get_ajax_data: function (el) {
 
73
  var data = {
74
  action: 'ecwd_event_popup_ajax',
75
- id: el.attr('class').split('event')[2]
 
76
  };
77
  return data;
78
  }
70
  body_class: "ecwd-excluded-events ecwd_popup_body_scroll",
71
  title: "Event Details",
72
  get_ajax_data: function (el) {
73
+ var date = el.closest('.has-events').data('date');
74
  var data = {
75
  action: 'ecwd_event_popup_ajax',
76
+ id: el.attr('class').split('event')[2],
77
+ date: date
78
  };
79
  return data;
80
  }
languages/ecwd-ca.mo ADDED
Binary file
languages/ecwd-ca.po ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: event_calendar_wd\n"
4
+ "POT-Creation-Date: 2015-07-23 13:04+0400\n"
5
+ "PO-Revision-Date: 2015-11-11 17:33+0100\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.7.5\n"
12
+ "X-Poedit-Basepath: ../\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "X-Poedit-KeywordsList: _e;__\n"
15
+ "Language: ca_ES\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+ "X-Poedit-SearchPathExcluded-0: views/admin\n"
18
+ "X-Poedit-SearchPathExcluded-1: js\n"
19
+ "X-Poedit-SearchPathExcluded-2: includes/ecwd-cpt-class.php\n"
20
+ "X-Poedit-SearchPathExcluded-3: includes/register-settings.php\n"
21
+ "X-Poedit-SearchPathExcluded-4: includes/ecwd-ical-events-class.php\n"
22
+ "X-Poedit-SearchPathExcluded-5: includes/ecwd-google-events-class.php\n"
23
+ "X-Poedit-SearchPathExcluded-6: includes/ecwd-facebook-events-class.php\n"
24
+ "X-Poedit-SearchPathExcluded-7: ecwd_admin_class.php\n"
25
+
26
+ #: includes/calendar-class.php:175 includes/calendar-class.php:176
27
+ #: views/widgets.php:168
28
+ msgid "Month"
29
+ msgstr "Mes"
30
+
31
+ #: includes/calendar-class.php:177 views/widgets.php:169
32
+ msgid "List"
33
+ msgstr "Llista"
34
+
35
+ #: includes/calendar-class.php:179
36
+ msgid "Week"
37
+ msgstr "Setmana"
38
+
39
+ #: includes/calendar-class.php:183
40
+ msgid "Day"
41
+ msgstr "Dia"
42
+
43
+ #: includes/calendar-class.php:186
44
+ msgid "Map"
45
+ msgstr "Mapa"
46
+
47
+ #: includes/calendar-class.php:188
48
+ msgid "4 Days"
49
+ msgstr "4 dies"
50
+
51
+ #: includes/calendar-class.php:191
52
+ msgid "Posterboard"
53
+ msgstr "Poster"
54
+
55
+ #: includes/calendar-class.php:383 includes/calendar-class.php:417
56
+ #: includes/calendar-class.php:572 includes/calendar-class.php:1181
57
+ #: includes/calendar-class.php:1330 includes/ecwd-functions.php:360
58
+ #: views/ecwd-event-content.php:76 views/ecwd-event-content.php:158
59
+ #: views/ecwd-organizer-content.php:145 views/ecwd-venue-content.php:178
60
+ #: views/single-event.php:151 views/single-event.php:247
61
+ #: views/single-event.php:487
62
+ msgid "All day"
63
+ msgstr "Tot el dia"
64
+
65
+ #: includes/calendar-class.php:440 includes/calendar-class.php:520
66
+ #: includes/calendar-class.php:1386
67
+ msgid "No events"
68
+ msgstr "Sense esdeveniments"
69
+
70
+ #: includes/calendar-class.php:644
71
+ msgid "No Events"
72
+ msgstr "Sense esdeveniments"
73
+
74
+ #: includes/calendar-class.php:1256
75
+ msgid "More events"
76
+ msgstr "Més esdeveniments"
77
+
78
+ #: includes/ecwd-cpt-filter.php:67
79
+ msgid "From"
80
+ msgstr "Des de"
81
+
82
+ #: includes/ecwd-cpt-filter.php:74
83
+ msgid "To"
84
+ msgstr "Fins"
85
+
86
+ #: includes/ecwd-display-class.php:876 includes/ecwd-display-class.php:882
87
+ #: includes/ecwd-display-class.php:900 includes/ecwd-display-class.php:917
88
+ #: includes/texts.php:60
89
+ msgid "Repeat every"
90
+ msgstr "Repetir cada"
91
+
92
+ #: includes/ecwd-display-class.php:876 includes/texts.php:66
93
+ msgid "days"
94
+ msgstr "dies"
95
+
96
+ #: includes/ecwd-display-class.php:878 includes/texts.php:61
97
+ msgid "Repeat every day"
98
+ msgstr "Repetir cada dia"
99
+
100
+ #: includes/ecwd-display-class.php:882 includes/texts.php:67
101
+ msgid "weeks"
102
+ msgstr "setmanes"
103
+
104
+ #: includes/ecwd-display-class.php:884 includes/texts.php:62
105
+ msgid "Repeat every week"
106
+ msgstr "Repetir cada setmana"
107
+
108
+ #: includes/ecwd-display-class.php:889
109
+ msgid "on"
110
+ msgstr "de"
111
+
112
+ #: includes/ecwd-display-class.php:900 includes/texts.php:68
113
+ msgid "months"
114
+ msgstr "mesos"
115
+
116
+ #: includes/ecwd-display-class.php:902 includes/texts.php:63
117
+ msgid "Repeat every month"
118
+ msgstr "Repetir cada mes"
119
+
120
+ #: includes/ecwd-display-class.php:907 includes/ecwd-display-class.php:931
121
+ msgid "on the same day"
122
+ msgstr "el mateix dia"
123
+
124
+ #: includes/ecwd-display-class.php:912 includes/ecwd-display-class.php:936
125
+ msgid "on the"
126
+ msgstr "el"
127
+
128
+ #: includes/ecwd-display-class.php:917 includes/texts.php:69
129
+ msgid "years"
130
+ msgstr "anys"
131
+
132
+ #: includes/ecwd-display-class.php:919 includes/texts.php:64
133
+ msgid "Repeat every year"
134
+ msgstr "Repetir cada any"
135
+
136
+ #: includes/ecwd-display-class.php:940 includes/texts.php:70
137
+ msgid "until"
138
+ msgstr "fins"
139
+
140
+ #: includes/ecwd-functions.php:8
141
+ msgid "Loading..."
142
+ msgstr "Carregant..."
143
+
144
+ #: includes/ecwd-functions.php:439 includes/texts.php:53
145
+ msgid "DAYS"
146
+ msgstr "DIES"
147
+
148
+ #: includes/ecwd-functions.php:440 includes/texts.php:54
149
+ msgid "HOURS"
150
+ msgstr "HORES"
151
+
152
+ #: includes/ecwd-functions.php:441 includes/texts.php:55
153
+ msgid "MINUTES"
154
+ msgstr "MINUTS"
155
+
156
+ #: includes/ecwd-functions.php:442 includes/texts.php:56
157
+ msgid "SECONDS"
158
+ msgstr "SEGONS"
159
+
160
+ #: includes/texts.php:2
161
+ msgid "January"
162
+ msgstr "Gener"
163
+
164
+ #: includes/texts.php:3
165
+ msgid "February"
166
+ msgstr "Febrer"
167
+
168
+ #: includes/texts.php:4
169
+ msgid "March"
170
+ msgstr "Març"
171
+
172
+ #: includes/texts.php:5
173
+ msgid "April"
174
+ msgstr "Abril"
175
+
176
+ #: includes/texts.php:6
177
+ msgid "May"
178
+ msgstr "Maig"
179
+
180
+ #: includes/texts.php:7
181
+ msgid "June"
182
+ msgstr "Juny"
183
+
184
+ #: includes/texts.php:8
185
+ msgid "July"
186
+ msgstr "Juliol"
187
+
188
+ #: includes/texts.php:9
189
+ msgid "August"
190
+ msgstr "Agost"
191
+
192
+ #: includes/texts.php:10
193
+ msgid "September"
194
+ msgstr "Setembre"
195
+
196
+ #: includes/texts.php:11
197
+ msgid "October"
198
+ msgstr "Octubre"
199
+
200
+ #: includes/texts.php:12
201
+ msgid "November"
202
+ msgstr "Novembre"
203
+
204
+ #: includes/texts.php:13
205
+ msgid "December"
206
+ msgstr "Desembre"
207
+
208
+ #: includes/texts.php:15
209
+ msgid "Sunday"
210
+ msgstr "Diumenge"
211
+
212
+ #: includes/texts.php:16
213
+ msgid "Monday"
214
+ msgstr "Dilluns"
215
+
216
+ #: includes/texts.php:17
217
+ msgid "Tuesday"
218
+ msgstr "Dimarts"
219
+
220
+ #: includes/texts.php:18
221
+ msgid "Wednesday"
222
+ msgstr "Dimecres"
223
+
224
+ #: includes/texts.php:19
225
+ msgid "Thursday"
226
+ msgstr "Dijous"
227
+
228
+ #: includes/texts.php:20
229
+ msgid "Friday"
230
+ msgstr "Divendres"
231
+
232
+ #: includes/texts.php:21
233
+ msgid "Saturday"
234
+ msgstr "Dissabte"
235
+
236
+ #: includes/texts.php:25
237
+ msgid "Sun"
238
+ msgstr "Dg"
239
+
240
+ #: includes/texts.php:26
241
+ msgid "Mon"
242
+ msgstr "Dl"
243
+
244
+ #: includes/texts.php:27
245
+ msgid "Tue"
246
+ msgstr "Dm"
247
+
248
+ #: includes/texts.php:28
249
+ msgid "Wed"
250
+ msgstr "Dc"
251
+
252
+ #: includes/texts.php:29
253
+ msgid "Thu"
254
+ msgstr "Dj"
255
+
256
+ #: includes/texts.php:30
257
+ msgid "Fri"
258
+ msgstr "Dv"
259
+
260
+ #: includes/texts.php:31
261
+ msgid "Sat"
262
+ msgstr "Ds"
263
+
264
+ #: includes/texts.php:34
265
+ msgid "Su"
266
+ msgstr "Dg"
267
+
268
+ #: includes/texts.php:35
269
+ msgid "Mo"
270
+ msgstr "Dl"
271
+
272
+ #: includes/texts.php:36
273
+ msgid "Tu"
274
+ msgstr "Dm"
275
+
276
+ #: includes/texts.php:37
277
+ msgid "We"
278
+ msgstr "Dc"
279
+
280
+ #: includes/texts.php:38
281
+ msgid "Th"
282
+ msgstr "Dj"
283
+
284
+ #: includes/texts.php:39
285
+ msgid "Fr"
286
+ msgstr "Dv"
287
+
288
+ #: includes/texts.php:40
289
+ msgid "Sa"
290
+ msgstr "Ds"
291
+
292
+ #: includes/texts.php:44
293
+ msgid "Show Filters"
294
+ msgstr "Mostrar filtres"
295
+
296
+ #: includes/texts.php:45
297
+ msgid "Collapse Filters"
298
+ msgstr "Amagar filtres"
299
+
300
+ #: includes/texts.php:46
301
+ msgid "Reset Filters"
302
+ msgstr "Resetejar filtres"
303
+
304
+ #: includes/texts.php:48
305
+ msgid "Days"
306
+ msgstr "Dies"
307
+
308
+ #: includes/texts.php:49
309
+ msgid "Categories"
310
+ msgstr "Categories"
311
+
312
+ #: includes/texts.php:50
313
+ msgid "Venues"
314
+ msgstr "Llocs"
315
+
316
+ #: includes/texts.php:57
317
+ msgid "The event has just started"
318
+ msgstr "L'esdeveniment ha començat"
319
+
320
+ #: includes/texts.php:72
321
+ msgid "Sundays"
322
+ msgstr "Diumenges"
323
+
324
+ #: includes/texts.php:73
325
+ msgid "Mondays"
326
+ msgstr "Dilluns"
327
+
328
+ #: includes/texts.php:74
329
+ msgid "Tuesdays"
330
+ msgstr "Dimarts"
331
+
332
+ #: includes/texts.php:75
333
+ msgid "Wednesdays"
334
+ msgstr "Dimecres"
335
+
336
+ #: includes/texts.php:76
337
+ msgid "Thursdays"
338
+ msgstr "Dijous"
339
+
340
+ #: includes/texts.php:77
341
+ msgid "Fridays"
342
+ msgstr "Divendres"
343
+
344
+ #: includes/texts.php:78
345
+ msgid "Saturdays"
346
+ msgstr "Dissabtes"
347
+
348
+ #: views/ecwd-event-content.php:67 views/ecwd-event-content.php:153
349
+ #: views/single-event.php:142 views/single-event.php:242
350
+ msgid "Date"
351
+ msgstr "Dada"
352
+
353
+ #: views/ecwd-event-content.php:91 views/single-event.php:170
354
+ msgid "Url"
355
+ msgstr "Url"
356
+
357
+ #: views/ecwd-event-content.php:97 views/single-event.php:177
358
+ msgid "Organizers"
359
+ msgstr "Organitzadors"
360
+
361
+ #: views/ecwd-organizer-content.php:109
362
+ msgid "upcoming events"
363
+ msgstr "propers esdeveniments"
364
+
365
+ #: views/ecwd-venue-content.php:141
366
+ msgid "events"
367
+ msgstr "esdeveniments"
368
+
369
+ #: views/single-event.php:190
370
+ msgid "Venue"
371
+ msgstr "Lloc"
372
+
373
+ #: views/single-event.php:200
374
+ msgid "Location"
375
+ msgstr "Localització"
376
+
377
+ #: views/single-event.php:449
378
+ msgid "Related events"
379
+ msgstr "Esdeveniments relacionats"
languages/ecwd-ca_ES.mo CHANGED
Binary file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://web-dorado.com/products/wordpress-event-calendar-wd.html
4
  Tags: calendar, calendars, event, event calendar, event manager, events calendar, calendar widget, event registration, event management,events, agenda, holiday calendar , scheduling, free calendar, Calender, upcoming events , event widget , event list, calendar localization, Organizer, editorial calendar, Interactive Calendar, news calendar, meeting , appointment, event tracking, event organizer, upcoming events widget, event page, event bookings, recurring, recurring events, conference, date, dates, schedule, times, venue, AJAX, responsive, shortcode, seminar, summit, facebook integration, widget
5
  Requires at least: 3.9
6
  Tested up to: 4.4
7
- Stable tag: 1.0.51
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -152,6 +152,9 @@ After downloading the ZIP file of the Event Calendar WD plugin,
152
 
153
  == Changelog ==
154
 
 
 
 
155
  = 1.0.51 =
156
  Added: Config page
157
  Changed: Spanish Translation
4
  Tags: calendar, calendars, event, event calendar, event manager, events calendar, calendar widget, event registration, event management,events, agenda, holiday calendar , scheduling, free calendar, Calender, upcoming events , event widget , event list, calendar localization, Organizer, editorial calendar, Interactive Calendar, news calendar, meeting , appointment, event tracking, event organizer, upcoming events widget, event page, event bookings, recurring, recurring events, conference, date, dates, schedule, times, venue, AJAX, responsive, shortcode, seminar, summit, facebook integration, widget
5
  Requires at least: 3.9
6
  Tested up to: 4.4
7
+ Stable tag: 1.0.52
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
152
 
153
  == Changelog ==
154
 
155
+ = 1.0.52 =
156
+ Added: Mark all days of multi-day event option
157
+
158
  = 1.0.51 =
159
  Added: Config page
160
  Changed: Spanish Translation
views/ecwd-event-popup.php CHANGED
@@ -54,17 +54,21 @@ if (!isset($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'])) {
54
 
55
  $permalink = get_the_permalink($ecwd_event->ID);
56
  $this_event = $events[$ecwd_event->ID] = new ECWD_Event($ecwd_event->ID, '', $ecwd_event->post_title, $ecwd_event->post_content, $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_url'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'][0], $permalink, $ecwd_event, '', $ecwd_event_metas);
 
 
57
  $d = new ECWD_Display('');
58
- if (isset($_GET['eventDate']) || isset($wp_query->query_vars['eventDate'])) {
59
- $fromDate = isset($_GET['eventDate']) ? $_GET['eventDate'] : $wp_query->query_vars['eventDate'];
 
 
 
 
 
60
 
61
- $eventdayslong = $d->dateDiff($ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'][0]);
62
- $toDate = date('Y-m-d', strtotime(( date("Y-m-d", ( strtotime($fromDate))) . " +" . ( $eventdayslong + 2 ) . " days")));
63
- $this_event_dates = $d->get_event_days(array($ecwd_event->ID => $this_event), 1, $fromDate, $toDate);
64
- if (isset($this_event_dates[0]['from']) && strtotime($fromDate) == strtotime($this_event_dates[0]['from'])) {
65
- $ecwd_event_date_from = $this_event_dates[0]['from'] . ' ' . $this_event_dates[0]['starttime'];
66
- $ecwd_event_date_to = $this_event_dates[0]['to'] . ' ' . $this_event_dates[0]['endtime'];
67
- }
68
  }
69
 
70
 
@@ -303,7 +307,7 @@ $event_categories = wp_get_post_terms($post->ID, 'ecwd_event_category', $args);
303
  </div>
304
  <!-- End Content -->
305
  <!-- Categories and tags -->
306
- <?php if ($category_and_tags == 1) { ?>
307
  <div class="event_cageory_and_tags">
308
 
309
  <?php if (!empty($event_categories)) { ?>
54
 
55
  $permalink = get_the_permalink($ecwd_event->ID);
56
  $this_event = $events[$ecwd_event->ID] = new ECWD_Event($ecwd_event->ID, '', $ecwd_event->post_title, $ecwd_event->post_content, $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_location'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_url'][0], $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_lat_long'][0], $permalink, $ecwd_event, '', $ecwd_event_metas);
57
+ $ecwd_event_date_from = $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_from'][0];
58
+ $ecwd_event_date_to = $ecwd_event_metas[ECWD_PLUGIN_PREFIX . '_event_date_to'][0];
59
  $d = new ECWD_Display('');
60
+ if ($ajax_date != null) {
61
+ $start_time = date('H:i', strtotime($ecwd_event_date_from));
62
+ $end_time = date('H:i', strtotime($ecwd_event_date_to));
63
+
64
+ $eventdayslong = $d->dateDiff($ecwd_event_date_from, $ecwd_event_date_to);
65
+ $ecwd_event_date_from = $ajax_date;
66
+ $ecwd_event_date_to = date('Y-m-d', strtotime(( date("Y-m-d", ( strtotime($ecwd_event_date_from))) . " +" . ( $eventdayslong ) . " days")));
67
 
68
+
69
+
70
+ $ecwd_event_date_from = $ecwd_event_date_from . ' ' . $start_time;
71
+ $ecwd_event_date_to = $ecwd_event_date_to . ' ' . $end_time;
 
 
 
72
  }
73
 
74
 
307
  </div>
308
  <!-- End Content -->
309
  <!-- Categories and tags -->
310
+ <?php if ($category_and_tags == 1) { ?>
311
  <div class="event_cageory_and_tags">
312
 
313
  <?php if (!empty($event_categories)) { ?>