Events Manager - Version 5.11

Version Description

  • fixed booking-related php errors deriving from accessing $EM_Booking->people directly since 5.10
  • added 'week', 'this-week' and 'this-month' scopes
Download this release

Release Info

Developer netweblogic
Plugin Icon 128x128 Events Manager
Version 5.11
Comparing to
See all releases

Code changes from version 5.10 to 5.11

admin/em-docs.php CHANGED
@@ -24,7 +24,7 @@ function em_docs_init($force_init = false){
24
  'recurrences' => array( 'desc'=> 'Show only recurrences if set to 1 or non-recurrences if set to 0, shows all events if not used.'),
25
  'recurrence' => array( 'desc'=> 'If set to the event id of the recurring event, this will show only events this event recurrences.', 'default'=>0),
26
  'recurring' => array( 'desc'=> 'If set to 1, will only show recurring event templates. Only useful if you know what you\'re doing, use recurrence or recurrences if you want to filter event recurrences.', 'default'=>0),
27
- 'scope' => array( 'desc'=> 'Choose the time frame of events to show. Additionally you can supply dates (in format of YYYY-MM-DD), either single for events on a specific date or two dates separated by a comma (e.g. 2010-12-25,2010-12-31) for events ocurring between these dates.', 'default'=>'future', 'args'=>array("future", "past", "today", "tomorrow", "month", "next-month", "1-months", "2-months", "3-months", "6-months", "12-months","all")),
28
  'search' => array( 'desc'=> 'Do a search for this string within event name, details and location address.' ),
29
  'status' => array( 'desc' => sprintf('Limit search to %s with a spefic status (1 is active, 0 is pending approval)','events'), 'default'=>1),
30
  'tag' => array( 'desc'=> str_replace('%s', 'tags', 'Supply a single id, slug or comma-separated ids or slugs (e.g. "1,%s-slug,3") to limit the search to events in any of these %s. You can also use negative numbers and slugs to exclude specific %s (e.g. -1,-exclude-%s,-3). If you mix inclusions and exclusions, all events with included %s AND without excluded %s will be shown. You can also use & to separate ids and slugs, in which case events must contain (or not contain) both %s to be shown.'), 'default'=>0),
24
  'recurrences' => array( 'desc'=> 'Show only recurrences if set to 1 or non-recurrences if set to 0, shows all events if not used.'),
25
  'recurrence' => array( 'desc'=> 'If set to the event id of the recurring event, this will show only events this event recurrences.', 'default'=>0),
26
  'recurring' => array( 'desc'=> 'If set to 1, will only show recurring event templates. Only useful if you know what you\'re doing, use recurrence or recurrences if you want to filter event recurrences.', 'default'=>0),
27
+ 'scope' => array( 'desc'=> 'Choose the time frame of events to show. Additionally you can supply dates (in format of YYYY-MM-DD), either single for events on a specific date or two dates separated by a comma (e.g. 2010-12-25,2010-12-31) for events ocurring between these dates.', 'default'=>'future', 'args'=>array("future", "past", "today", "tomorrow", 'week', 'this-week', "month", 'this-month', "next-month", "1-months", "2-months", "3-months", "6-months", "12-months","all")),
28
  'search' => array( 'desc'=> 'Do a search for this string within event name, details and location address.' ),
29
  'status' => array( 'desc' => sprintf('Limit search to %s with a spefic status (1 is active, 0 is pending approval)','events'), 'default'=>1),
30
  'tag' => array( 'desc'=> str_replace('%s', 'tags', 'Supply a single id, slug or comma-separated ids or slugs (e.g. "1,%s-slug,3") to limit the search to events in any of these %s. You can also use negative numbers and slugs to exclude specific %s (e.g. -1,-exclude-%s,-3). If you mix inclusions and exclusions, all events with included %s AND without excluded %s will be shown. You can also use & to separate ids and slugs, in which case events must contain (or not contain) both %s to be shown.'), 'default'=>0),
classes/em-booking.php CHANGED
@@ -29,6 +29,7 @@ function em_get_booking($id = false) {
29
  * Contains all information and relevant functions surrounding a single booking made with Events Manager
30
  * @property int|false $booking_status
31
  * @property string $language
 
32
  */
33
  class EM_Booking extends EM_Object{
34
  //DB Fields
@@ -78,7 +79,7 @@ class EM_Booking extends EM_Object{
78
  /**
79
  * @var EM_Person
80
  */
81
- var $person;
82
  var $required_fields = array('booking_id', 'event_id', 'person_id', 'booking_spaces');
83
  var $feedback_message = "";
84
  var $errors = array();
@@ -176,6 +177,8 @@ class EM_Booking extends EM_Object{
176
  }
177
  }elseif( $var == 'booking_status' ){
178
  return ($this->booking_status == 0 && !get_option('dbem_bookings_approval') ) ? 1:$this->booking_status;
 
 
179
  }
180
  return null;
181
  }
29
  * Contains all information and relevant functions surrounding a single booking made with Events Manager
30
  * @property int|false $booking_status
31
  * @property string $language
32
+ * @property EM_Person $person
33
  */
34
  class EM_Booking extends EM_Object{
35
  //DB Fields
79
  /**
80
  * @var EM_Person
81
  */
82
+ protected $person;
83
  var $required_fields = array('booking_id', 'event_id', 'person_id', 'booking_spaces');
84
  var $feedback_message = "";
85
  var $errors = array();
177
  }
178
  }elseif( $var == 'booking_status' ){
179
  return ($this->booking_status == 0 && !get_option('dbem_bookings_approval') ) ? 1:$this->booking_status;
180
+ }elseif( $var == 'person' ){
181
+ return $this->get_person();
182
  }
183
  return null;
184
  }
classes/em-datetime.php CHANGED
@@ -336,4 +336,36 @@ class EM_DateTime extends DateTime {
336
  if( $DateTime === false ) return false;
337
  return new EM_DateTime($DateTime->format('Y-m-d H:i:s'), $timezone);
338
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  }
336
  if( $DateTime === false ) return false;
337
  return new EM_DateTime($DateTime->format('Y-m-d H:i:s'), $timezone);
338
  }
339
+
340
+ /**
341
+ * Gets a set of start/end dates for the relative week of this $EM_DateTime, until the day before the starting weekday as per WP Settings.
342
+ *
343
+ * Accepts two scopes for $scope, both which calculate relative dates until the day before next start day of week.:
344
+ * 'this-week' - events for the rest of the week starting 'today'
345
+ * 'week' - events from start of relative week since previous start day of week
346
+ *
347
+ * @param string $scope
348
+ * @return string[]
349
+ */
350
+ public function get_week_dates( $scope = 'week' ) {
351
+ $start_of_week = get_option('start_of_week');
352
+ $days_of_week = array( 0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday');
353
+ $EM_DateTime = $this->copy(); // so we don't modify this $EM_DateTime
354
+ $today_day_of_week = $EM_DateTime->format('w');
355
+ $end_of_week = $start_of_week > 0 ? $start_of_week-1 : 6;
356
+ $end_of_week_name = $days_of_week[$end_of_week];
357
+ // get stat date, either today if it's start of week or 'this-week' scope, or the previous start day of week
358
+ if( $scope == 'this-week' || $today_day_of_week == $start_of_week ){
359
+ $start_date = $EM_DateTime->getDate();
360
+ }else{
361
+ $start_of_week_name = $days_of_week[$start_of_week];
362
+ $start_date = $EM_DateTime->modify('last '. $start_of_week_name)->getDate();
363
+ }
364
+ $end_date = $start_date; // set as today in event it's the last day of week
365
+ if( $scope == 'week' || $today_day_of_week != $end_of_week ){
366
+ // if we're looking for whole week, $EM_DateTime is set to start of week, so get relative end of week even if it's today
367
+ $end_date = $EM_DateTime->modify('next '. $end_of_week_name)->getDate();
368
+ }
369
+ return array($start_date, $end_date);
370
+ }
371
  }
classes/em-event-post.php CHANGED
@@ -289,10 +289,10 @@ class EM_Event_Post {
289
  }else{
290
  $query[] = array( 'key' => '_event_end', 'value' => $EM_DateTime->getDateTime(), 'compare' => $compare, 'type' => 'DATETIME' );
291
  }
292
- }elseif ($scope == "month" || $scope == "next-month" ){
293
  $EM_DateTime = new EM_DateTime(); //create default time in blog timezone
294
  if( $scope == 'next-month' ) $EM_DateTime->add('P1M');
295
- $start_month = $EM_DateTime->modify('first day of this month')->getDate();
296
  $end_month = $EM_DateTime->modify('last day of this month')->getDate();
297
  if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
298
  $query[] = array( 'key' => '_event_start_date', 'value' => array($start_month,$end_month), 'type' => 'DATE', 'compare' => 'BETWEEN');
@@ -300,6 +300,15 @@ class EM_Event_Post {
300
  $query[] = array( 'key' => '_event_start_date', 'value' => $end_month, 'compare' => '<=', 'type' => 'DATE' );
301
  $query[] = array( 'key' => '_event_end_date', 'value' => $start_month, 'compare' => '>=', 'type' => 'DATE' );
302
  }
 
 
 
 
 
 
 
 
 
303
  }elseif( preg_match('/(\d\d?)\-months/',$scope,$matches) ){ // next x months means this month (what's left of it), plus the following x months until the end of that month.
304
  $EM_DateTime = new EM_DateTime(); //create default time in blog timezone
305
  $months_to_add = $matches[1];
289
  }else{
290
  $query[] = array( 'key' => '_event_end', 'value' => $EM_DateTime->getDateTime(), 'compare' => $compare, 'type' => 'DATETIME' );
291
  }
292
+ }elseif ($scope == "month" || $scope == "next-month" || $scope == 'this-month'){
293
  $EM_DateTime = new EM_DateTime(); //create default time in blog timezone
294
  if( $scope == 'next-month' ) $EM_DateTime->add('P1M');
295
+ $start_month = $scope == 'this-month' ? $EM_DateTime->getDate() : $EM_DateTime->modify('first day of this month')->getDate();
296
  $end_month = $EM_DateTime->modify('last day of this month')->getDate();
297
  if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
298
  $query[] = array( 'key' => '_event_start_date', 'value' => array($start_month,$end_month), 'type' => 'DATE', 'compare' => 'BETWEEN');
300
  $query[] = array( 'key' => '_event_start_date', 'value' => $end_month, 'compare' => '<=', 'type' => 'DATE' );
301
  $query[] = array( 'key' => '_event_end_date', 'value' => $start_month, 'compare' => '>=', 'type' => 'DATE' );
302
  }
303
+ }elseif ($scope == "week" || $scope == 'this-week'){
304
+ $EM_DateTime = new EM_DateTime(); //create default time in blog timezone
305
+ list($start_date, $end_date) = $EM_DateTime->get_week_dates( $scope );
306
+ if( get_option('dbem_events_current_are_past') && $wp_query->query_vars['post_type'] != 'event-recurring' ){
307
+ $query[] = array( 'key' => '_event_start_date', 'value' => array($start_date,$end_date), 'type' => 'DATE', 'compare' => 'BETWEEN');
308
+ }else{
309
+ $query[] = array( 'key' => '_event_start_date', 'value' => $end_date, 'compare' => '<=', 'type' => 'DATE' );
310
+ $query[] = array( 'key' => '_event_end_date', 'value' => $start_date, 'compare' => '>=', 'type' => 'DATE' );
311
+ }
312
  }elseif( preg_match('/(\d\d?)\-months/',$scope,$matches) ){ // next x months means this month (what's left of it), plus the following x months until the end of that month.
313
  $EM_DateTime = new EM_DateTime(); //create default time in blog timezone
314
  $months_to_add = $matches[1];
classes/em-object.php CHANGED
@@ -378,9 +378,15 @@ class EM_Object {
378
  if( !get_option('dbem_events_current_are_past') ){
379
  $conditions['scope'] .= " OR (event_start_date <= CAST('".$EM_DateTime->getDate()."' AS DATE) AND event_end_date >= CAST('".$EM_DateTime->getDate()."' AS DATE))";
380
  }
381
- }elseif ($scope == "month" || $scope == "next-month"){
 
 
 
 
 
 
382
  if( $scope == 'next-month' ) $EM_DateTime->add('P1M');
383
- $start_month = $EM_DateTime->modify('first day of this month')->getDate();
384
  $end_month = $EM_DateTime->modify('last day of this month')->getDate();
385
  $conditions['scope'] = " (event_start_date BETWEEN CAST('$start_month' AS DATE) AND CAST('$end_month' AS DATE))";
386
  if( !get_option('dbem_events_current_are_past') ){
378
  if( !get_option('dbem_events_current_are_past') ){
379
  $conditions['scope'] .= " OR (event_start_date <= CAST('".$EM_DateTime->getDate()."' AS DATE) AND event_end_date >= CAST('".$EM_DateTime->getDate()."' AS DATE))";
380
  }
381
+ }elseif ($scope == "week" || $scope == 'this-week'){
382
+ list($start_date, $end_date) = $EM_DateTime->get_week_dates( $scope );
383
+ $conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE))";
384
+ if( !get_option('dbem_events_current_are_past') ){
385
+ $conditions['scope'] .= " OR (event_start_date < CAST('$start_date' AS DATE) AND event_end_date >= CAST('$start_date' AS DATE))";
386
+ }
387
+ }elseif ($scope == "month" || $scope == "next-month" || $scope == 'this-month'){
388
  if( $scope == 'next-month' ) $EM_DateTime->add('P1M');
389
+ $start_month = $scope == 'this-month' ? $EM_DateTime->getDate() : $EM_DateTime->modify('first day of this month')->getDate();
390
  $end_month = $EM_DateTime->modify('last day of this month')->getDate();
391
  $conditions['scope'] = " (event_start_date BETWEEN CAST('$start_month' AS DATE) AND CAST('$end_month' AS DATE))";
392
  if( !get_option('dbem_events_current_are_past') ){
em-actions.php CHANGED
@@ -614,25 +614,10 @@ function em_init_actions() {
614
  if( is_user_logged_in() ){
615
  //Admin operations
616
  //Specific Oject Ajax
617
- if( !empty($_REQUEST['em_obj']) ){
618
- switch( $_REQUEST['em_obj'] ){
619
- case 'em_bookings_events_table':
620
- include_once('admin/bookings/em-events.php');
621
- em_bookings_events_table();
622
- exit();
623
- break;
624
- case 'em_bookings_pending_table':
625
- include_once('admin/bookings/em-pending.php');
626
- em_bookings_pending_table();
627
- exit();
628
- break;
629
- case 'em_bookings_confirmed_table':
630
- //add some admin files just in case
631
- include_once('admin/bookings/em-confirmed.php');
632
- em_bookings_confirmed_table();
633
- exit();
634
- break;
635
- }
636
  }
637
  }
638
  //Export CSV - WIP
614
  if( is_user_logged_in() ){
615
  //Admin operations
616
  //Specific Oject Ajax
617
+ if( !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table' ){
618
+ include_once('admin/bookings/em-events.php');
619
+ em_bookings_events_table();
620
+ exit();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  }
622
  }
623
  //Export CSV - WIP
em-functions.php CHANGED
@@ -201,13 +201,20 @@ function em_get_countries($add_blank = false, $sort = true){
201
  * Returns an array of scopes available to events manager. Hooking into this function's em_get_scopes filter will allow you to add scope options to the event pages.
202
  */
203
  function em_get_scopes(){
 
 
 
 
204
  $scopes = array(
205
  'all' => __('All events','events-manager'),
206
  'future' => __('Future events','events-manager'),
207
  'past' => __('Past events','events-manager'),
208
  'today' => __('Today\'s events','events-manager'),
209
  'tomorrow' => __('Tomorrow\'s events','events-manager'),
 
 
210
  'month' => __('Events this month','events-manager'),
 
211
  'next-month' => __('Events next month','events-manager'),
212
  '1-months' => __('Events current and next month','events-manager'),
213
  '2-months' => __('Events within 2 months','events-manager'),
201
  * Returns an array of scopes available to events manager. Hooking into this function's em_get_scopes filter will allow you to add scope options to the event pages.
202
  */
203
  function em_get_scopes(){
204
+ global $wp_locale;
205
+ $start_of_week = get_option('start_of_week');
206
+ $end_of_week_name = $start_of_week > 0 ? $wp_locale->get_weekday($start_of_week-1) : $wp_locale->get_weekday(6);
207
+ $start_of_week_name = $wp_locale->get_weekday($start_of_week);
208
  $scopes = array(
209
  'all' => __('All events','events-manager'),
210
  'future' => __('Future events','events-manager'),
211
  'past' => __('Past events','events-manager'),
212
  'today' => __('Today\'s events','events-manager'),
213
  'tomorrow' => __('Tomorrow\'s events','events-manager'),
214
+ 'week' => sprintf(__('Events this whole week (%s to %s)','events-manager'), $wp_locale->get_weekday_abbrev($start_of_week_name), $wp_locale->get_weekday_abbrev($end_of_week_name)),
215
+ 'this-week' => sprintf(__('Events this week (today to %s)','events-manager'), $wp_locale->get_weekday_abbrev($end_of_week_name)),
216
  'month' => __('Events this month','events-manager'),
217
+ 'this-month' => __('Events this month (today onwards)', 'events-manager'),
218
  'next-month' => __('Events next month','events-manager'),
219
  '1-months' => __('Events current and next month','events-manager'),
220
  '2-months' => __('Events within 2 months','events-manager'),
events-manager.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
- Version: 5.10
5
  Plugin URI: http://wp-events-plugin.com
6
  Description: Event registration and booking management for WordPress. Recurring events, locations, webinars, google maps, rss, ical, booking registration and more!
7
  Author: Marcus Sykes
@@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
 
30
  // Setting constants
31
- define('EM_VERSION', 5.99910); //self expanatory, although version currently may not correspond directly with published version number. until 6.0 we're stuck updating 5.999.x
32
  define('EM_PRO_MIN_VERSION', 2.6712); //self expanatory
33
  define('EM_PRO_MIN_VERSION_CRITICAL', 2.377); //self expanatory
34
  define('EM_DIR', dirname( __FILE__ )); //an absolute path to this directory
1
  <?php
2
  /*
3
  Plugin Name: Events Manager
4
+ Version: 5.11
5
  Plugin URI: http://wp-events-plugin.com
6
  Description: Event registration and booking management for WordPress. Recurring events, locations, webinars, google maps, rss, ical, booking registration and more!
7
  Author: Marcus Sykes
28
  */
29
 
30
  // Setting constants
31
+ define('EM_VERSION', 5.99911); //self expanatory, although version currently may not correspond directly with published version number. until 6.0 we're stuck updating 5.999.x
32
  define('EM_PRO_MIN_VERSION', 2.6712); //self expanatory
33
  define('EM_PRO_MIN_VERSION_CRITICAL', 2.377); //self expanatory
34
  define('EM_DIR', dirname( __FILE__ )); //an absolute path to this directory
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: bookings, calendar, tickets, events, buddypress, event management, google
5
  Text Domain: events-manager
6
  Requires at least: 5.2
7
  Tested up to: 5.8
8
- Stable tag: 5.10
9
  Requires PHP: 5.3
10
 
11
  Fully featured event registration management including recurring events, locations management, calendar, Google map integration, booking management
@@ -119,6 +119,10 @@ See our [FAQ](http://wp-events-plugin.com/documentation/faq/) page, which is upd
119
  6. Manage attendees with various booking reports
120
 
121
  == Changelog ==
 
 
 
 
122
  = 5.10 =
123
  * fixed a minor PHPMailer PHP warning tiggered when mailing errors occur
124
  * fixed date validation errors restting available from/until times to 12AM for tickets
5
  Text Domain: events-manager
6
  Requires at least: 5.2
7
  Tested up to: 5.8
8
+ Stable tag: 5.11
9
  Requires PHP: 5.3
10
 
11
  Fully featured event registration management including recurring events, locations management, calendar, Google map integration, booking management
119
  6. Manage attendees with various booking reports
120
 
121
  == Changelog ==
122
+ = 5.11 =
123
+ * fixed booking-related php errors deriving from accessing $EM_Booking->people directly since 5.10
124
+ * added 'week', 'this-week' and 'this-month' scopes
125
+
126
  = 5.10 =
127
  * fixed a minor PHPMailer PHP warning tiggered when mailing errors occur
128
  * fixed date validation errors restting available from/until times to 12AM for tickets