Event Tickets - Version 4.0.2

Version Description

Download this release

Release Info

Developer borkweb
Plugin Icon 128x128 Event Tickets
Version 4.0.2
Comparing to
See all releases

Code changes from version 4.0.1 to 4.0.2

common/src/Tribe/Admin/Notice/Archive_Slug_Conflict.php CHANGED
@@ -51,20 +51,18 @@ class Tribe__Admin__Notice__Archive_Slug_Conflict {
51
  * Echoes the admin notice to the page
52
  */
53
  public function notice() {
54
-
55
  // What's happening?
56
  $page_title = apply_filters( 'the_title', $this->page->post_title );
57
  $line_1 = __( sprintf( 'The page "%1$s" uses the "/%2$s" slug: the Events Calendar plugin will show its calendar in place of the page.', $page_title, $this->archive_slug ), 'tribe-common' );
58
 
59
  // What the user can do
60
  $page_edit_link = get_edit_post_link( $this->page->ID );
61
- // $can_edit_page_link = sprintf( __( '<a href="%s">Edit the page slug</a>', 'tribe-common' ), $page_edit_link );
62
  $can_edit_page_link = sprintf( __( '<a href="%s">Edit the page slug</a>', 'tribe-common' ), $page_edit_link );
63
  $page_edit_link_string = current_user_can( 'edit_pages' ) ? $can_edit_page_link : __( 'Ask the site administrator to edit the page slug', 'tribe-common' );
64
 
65
  $settings_cap = apply_filters( 'tribe_settings_req_cap', 'manage_options' );
66
  $admin_slug = apply_filters( 'tribe_settings_admin_slug', 'tribe-common' );
67
- $setting_page_link = apply_filters( 'tribe_settings_url', admin_url( 'edit.php?page=' . $admin_slug . '#tribe-field-singleEventSlug' ) );
68
  $can_edit_settings_link = sprintf( __( '<a href="%s">edit Events settings</a>.', 'tribe-common' ), $setting_page_link );
69
  $events_settings_link_string = current_user_can( $settings_cap ) ? $can_edit_settings_link : __( ' ask the site administrator set a different Events URL slug.', 'tribe-common' );
70
 
51
  * Echoes the admin notice to the page
52
  */
53
  public function notice() {
 
54
  // What's happening?
55
  $page_title = apply_filters( 'the_title', $this->page->post_title );
56
  $line_1 = __( sprintf( 'The page "%1$s" uses the "/%2$s" slug: the Events Calendar plugin will show its calendar in place of the page.', $page_title, $this->archive_slug ), 'tribe-common' );
57
 
58
  // What the user can do
59
  $page_edit_link = get_edit_post_link( $this->page->ID );
 
60
  $can_edit_page_link = sprintf( __( '<a href="%s">Edit the page slug</a>', 'tribe-common' ), $page_edit_link );
61
  $page_edit_link_string = current_user_can( 'edit_pages' ) ? $can_edit_page_link : __( 'Ask the site administrator to edit the page slug', 'tribe-common' );
62
 
63
  $settings_cap = apply_filters( 'tribe_settings_req_cap', 'manage_options' );
64
  $admin_slug = apply_filters( 'tribe_settings_admin_slug', 'tribe-common' );
65
+ $setting_page_link = apply_filters( 'tribe_settings_url', admin_url( 'edit.php?page=' . $admin_slug . '#tribe-field-eventsSlug' ) );
66
  $can_edit_settings_link = sprintf( __( '<a href="%s">edit Events settings</a>.', 'tribe-common' ), $setting_page_link );
67
  $events_settings_link_string = current_user_can( $settings_cap ) ? $can_edit_settings_link : __( ' ask the site administrator set a different Events URL slug.', 'tribe-common' );
68
 
common/src/Tribe/Main.php CHANGED
@@ -17,7 +17,7 @@ class Tribe__Main {
17
  const OPTIONNAME = 'tribe_events_calendar_options';
18
  const OPTIONNAMENETWORK = 'tribe_events_calendar_network_options';
19
 
20
- const VERSION = '4.0.1';
21
  const FEED_URL = 'https://theeventscalendar.com/feed/';
22
 
23
  protected $plugin_context;
17
  const OPTIONNAME = 'tribe_events_calendar_options';
18
  const OPTIONNAMENETWORK = 'tribe_events_calendar_network_options';
19
 
20
+ const VERSION = '4.0.2';
21
  const FEED_URL = 'https://theeventscalendar.com/feed/';
22
 
23
  protected $plugin_context;
common/tests/wpunit/Tribe/Events/common/Date_UtilsTest.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Tribe\Events\Common;
3
+
4
+ use \Tribe__Date_Utils as Date_Utils;
5
+
6
+ class Date_UtilsTest extends \Codeception\TestCase\WPTestCase {
7
+
8
+ /**
9
+ * @var string
10
+ */
11
+ protected static $tz_backup;
12
+
13
+ protected $backupGlobals = false;
14
+
15
+ public static function setUpBeforeClass() {
16
+ self::$tz_backup = date_default_timezone_get();
17
+
18
+ return parent::setUpBeforeClass();
19
+ }
20
+
21
+ public static function tearDownAfterClass() {
22
+ date_default_timezone_set( self::$tz_backup );
23
+
24
+ return parent::tearDownAfterClass();
25
+ }
26
+
27
+ public function setUp() {
28
+ // before
29
+ parent::setUp();
30
+
31
+ // your set up methods here
32
+ }
33
+
34
+ public function tearDown() {
35
+ // your tear down methods here
36
+
37
+ // then
38
+ parent::tearDown();
39
+ }
40
+
41
+ public function bad_argument_formats() {
42
+ return array_map( function ( $arr ) {
43
+ return [ $arr ];
44
+ }, [
45
+ [ 'day', 2, 3, 2012, 1 ], [ 2, 'week', 3, 2012, 1 ], [ 2, 2, 'month', 2012, 1 ], [ 2, 2, 3, 'year', 1 ],
46
+ [ 2, 2, 3, 2012, 'direction' ], [ 2, 2, 3, 2012, 23 ], [ 2, 2, 3, 2012, - 2 ],
47
+ ] );
48
+ }
49
+
50
+ /**
51
+ * get_weekday_timestamp returns false for wrong argument format
52
+ *
53
+ * @dataProvider bad_argument_formats
54
+ */
55
+ public function test_get_weekday_timestamp_returns_false_if_day_of_week_is_not_int( $args ) {
56
+ $this->assertFalse( call_user_func_array( [ 'Tribe__Date_Utils', 'get_weekday_timestamp' ], $args ) );
57
+ }
58
+
59
+ public function etc_natural_direction_expected_timestamps() {
60
+ return [
61
+ [ 1420416000, [ 1, 1, 1, 2015, 1 ] ], // Mon, first week of Jan 2015
62
+ [ 1423094400, [ 4, 1, 2, 2015, 1 ] ], // Thursday, first week of Feb 2015
63
+ [ 1425081600, [ 6, 4, 2, 2015, 1 ] ], // Saturday, 4th week of Feb 2015
64
+ ];
65
+ }
66
+
67
+ /**
68
+ * get_weekday_timestamp returns right timestamp etc in natural direction
69
+ *
70
+ * @dataProvider etc_natural_direction_expected_timestamps
71
+ */
72
+ public function test_get_weekday_timestamp_returns_right_timestamp_in_etc_natural_direction( $expected, $args ) {
73
+ date_default_timezone_set( 'Etc/GMT+0' );
74
+ $this->assertEquals( $expected, call_user_func_array( [
75
+ 'Tribe__Date_Utils', 'get_weekday_timestamp'
76
+ ], $args ) );
77
+ }
78
+
79
+ /**
80
+ * get_weekday_timestamp returns right timestamp etc -9 in natural direction
81
+ *
82
+ * @dataProvider etc_natural_direction_expected_timestamps
83
+ */
84
+ public function test_get_weekday_timestamp_returns_right_timestamp_etc_minus_9_in_natural_direction( $expected, $args ) {
85
+ date_default_timezone_set( 'Etc/GMT-9' );
86
+ $nine_hours = 60 * 60 * 9;
87
+ $this->assertEquals( $expected - $nine_hours, call_user_func_array( [
88
+ 'Tribe__Date_Utils', 'get_weekday_timestamp'
89
+ ], $args ) );
90
+ }
91
+
92
+ /**
93
+ * get_weekday_timestamp returns right timestamp etc +9 in natural direction
94
+ *
95
+ * @dataProvider etc_natural_direction_expected_timestamps
96
+ */
97
+ public function test_get_weekday_timestamp_returns_right_timestamp_etc_plus_9_in_natural_direction( $expected, $args ) {
98
+ date_default_timezone_set( 'Etc/GMT+9' );
99
+ $nine_hours = 60 * 60 * 9;
100
+ $this->assertEquals( $expected + $nine_hours, call_user_func_array( [
101
+ 'Tribe__Date_Utils', 'get_weekday_timestamp'
102
+ ], $args ) );
103
+ }
104
+
105
+ public function etc_reverse_direction_expected_timestamps() {
106
+ return [
107
+ [ 1422230400, [ 1, 1, 1, 2015, - 1 ] ], // Mon, last week of Jan 2015
108
+ [ 1424908800, [ 4, 1, 2, 2015, - 1 ] ], // Thursday, last week of Feb 2015
109
+ [ 1424476800, [ 6, 2, 2, 2015, - 1 ] ], // Saturday, penultimate week of Feb 2015
110
+ [ 1423872000, [ 6, 3, 2, 2015, - 1 ] ], // Saturday, antepenultimate week of Feb 2015
111
+ ];
112
+ }
113
+
114
+ /**
115
+ * get_weekday_timestamp returns right timestamp etc in reverse direction
116
+ *
117
+ * @dataProvider etc_reverse_direction_expected_timestamps
118
+ */
119
+ public function test_get_weekday_timestamp_returns_right_timestamp_in_etc_reverse_direction( $expected, $args ) {
120
+ date_default_timezone_set( 'Etc/GMT+0' );
121
+ $this->assertEquals( $expected, call_user_func_array( [
122
+ 'Tribe__Date_Utils', 'get_weekday_timestamp'
123
+ ], $args ) );
124
+ }
125
+
126
+ /**
127
+ * get_weekday_timestamp returns right timestamp etc -9 in reverse direction
128
+ *
129
+ * @dataProvider etc_reverse_direction_expected_timestamps
130
+ */
131
+ public function test_get_weekday_timestamp_returns_right_timestamp_etc_minus_9_in_reverse_direction( $expected, $args ) {
132
+ date_default_timezone_set( 'Etc/GMT-9' );
133
+ $nine_hours = 60 * 60 * 9;
134
+ $this->assertEquals( $expected - $nine_hours, call_user_func_array( [
135
+ 'Tribe__Date_Utils', 'get_weekday_timestamp'
136
+ ], $args ) );
137
+ }
138
+
139
+ /**
140
+ * get_weekday_timestamp returns right timestamp etc +9 in reverse direction
141
+ *
142
+ * @dataProvider etc_reverse_direction_expected_timestamps
143
+ */
144
+ public function test_get_weekday_timestamp_returns_right_timestamp_etc_plus_9_in_reverse_direction( $expected, $args ) {
145
+ date_default_timezone_set( 'Etc/GMT+9' );
146
+ $nine_hours = 60 * 60 * 9;
147
+ $this->assertEquals( $expected + $nine_hours, call_user_func_array( [
148
+ 'Tribe__Date_Utils', 'get_weekday_timestamp'
149
+ ], $args ) );
150
+ }
151
+ }
common/tribe-common.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Description: An event settings framework for managing shared options
4
- Version: 3.12.3
5
  Author: Modern Tribe, Inc.
6
  Author URI: http://m.tri.be/1x
7
  Text Domain: tribe-common
1
  <?php
2
  /*
3
  Description: An event settings framework for managing shared options
4
+ Version: 4.0.2
5
  Author: Modern Tribe, Inc.
6
  Author URI: http://m.tri.be/1x
7
  Text Domain: tribe-common
event-tickets.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Event Tickets
4
  Description: Event Tickets allows you to sell tickets to events
5
- Version: 4.0.1
6
  Author: Modern Tribe, Inc.
7
  Author URI: http://m.tri.be/28
8
  License: GPLv2 or later
2
  /*
3
  Plugin Name: Event Tickets
4
  Description: Event Tickets allows you to sell tickets to events
5
+ Version: 4.0.2
6
  Author: Modern Tribe, Inc.
7
  Author URI: http://m.tri.be/28
8
  License: GPLv2 or later
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: ModernTribe, borkweb, zbtirrell, barry.hughes, bordoni, brianjesse
4
  Tags: events, add-on, ticket sales, tickets, calendar, community, registration, api, dates, date, posts, workshop, conference, meeting, seminar, concert, summit, The Events Calendar, Events Calendar PRO, ticket integration, event ticketing, RSVP, Event Tickets, Event Tickets Plus
5
  Requires at least: 3.9
6
  Tested up to: 4.4
7
- Stable tag: 4.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -60,7 +60,7 @@ Looking for something else?
60
 
61
  = SUBMITTING PATCHES =
62
 
63
- If you’ve identified a bug and want to submit a patch, we’d welcome it at our <a href="https://github.com/moderntribe/events-tickets" target="_blank">GitHub page for Event Tickets.</a> Simply cue up your proposed patch as a pull request, and we’ll review as part of our release cycle and merge into the codebase if appropriate from there. (If a pull request is rejected, we’ll do our best to tell you why). Users whose pull requests are accepted will receive credit in the plugin’s changelog. For more information, check out the readme at our GitHub page. Happy coding!
64
 
65
  == Installation ==
66
 
@@ -179,6 +179,11 @@ Our Premium Plugins:
179
 
180
  == Changelog ==
181
 
 
 
 
 
 
182
  = [4.0.1] 2015-12-10 =
183
 
184
  * Tweak - Removed The Events Calendar-specific fields from the Attendees Report as defaults. The Events Calendar will now hook into the report and inject event-specific fields
4
  Tags: events, add-on, ticket sales, tickets, calendar, community, registration, api, dates, date, posts, workshop, conference, meeting, seminar, concert, summit, The Events Calendar, Events Calendar PRO, ticket integration, event ticketing, RSVP, Event Tickets, Event Tickets Plus
5
  Requires at least: 3.9
6
  Tested up to: 4.4
7
+ Stable tag: 4.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
60
 
61
  = SUBMITTING PATCHES =
62
 
63
+ If you’ve identified a bug and want to submit a patch, we’d welcome it at our <a href="https://github.com/moderntribe/event-tickets" target="_blank">GitHub page for Event Tickets.</a> Simply cue up your proposed patch as a pull request, and we’ll review as part of our release cycle and merge into the codebase if appropriate from there. (If a pull request is rejected, we’ll do our best to tell you why). Users whose pull requests are accepted will receive credit in the plugin’s changelog. For more information, check out the readme at our GitHub page. Happy coding!
64
 
65
  == Installation ==
66
 
179
 
180
  == Changelog ==
181
 
182
+ = [4.0.2] 2015-12-16 =
183
+
184
+ * Tweak - Removing dates from ticket emails when those tickets are attached to non The Events Calendar event posts
185
+ * Fix - Fixed a settings page URL (Thanks for the tip Kristy!)
186
+
187
  = [4.0.1] 2015-12-10 =
188
 
189
  * Tweak - Removed The Events Calendar-specific fields from the Attendees Report as defaults. The Events Calendar will now hook into the report and inject event-specific fields
src/Tribe/Main.php CHANGED
@@ -9,7 +9,7 @@ class Tribe__Tickets__Main {
9
  /**
10
  * Current version of this plugin
11
  */
12
- const VERSION = '4.0.1';
13
 
14
  /**
15
  * Min required The Events Calendar version
9
  /**
10
  * Current version of this plugin
11
  */
12
+ const VERSION = '4.0.2';
13
 
14
  /**
15
  * Min required The Events Calendar version
src/Tribe/Ticket_Object.php CHANGED
@@ -95,6 +95,14 @@ if ( ! class_exists( 'Tribe__Tickets__Ticket_Object' ) ) {
95
  */
96
  protected $qty_pending = 0;
97
 
 
 
 
 
 
 
 
 
98
  /**
99
  * Holds whether or not stock is being managed
100
  *
@@ -320,6 +328,9 @@ if ( ! class_exists( 'Tribe__Tickets__Ticket_Object' ) ) {
320
  case 'qty_sold':
321
  return $this->qty_sold();
322
  break;
 
 
 
323
  }
324
 
325
  return null;
@@ -342,9 +353,33 @@ if ( ! class_exists( 'Tribe__Tickets__Ticket_Object' ) ) {
342
  case 'qty_sold':
343
  return $this->qty_sold( $value );
344
  break;
 
 
 
345
  }
346
 
347
  return null;
348
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  }
 
350
  }
95
  */
96
  protected $qty_pending = 0;
97
 
98
+ /**
99
+ * Number of tickets for which an order has been cancelled.
100
+ * Use $this->qty_cancelled( value ) to set manage and get the value
101
+ *
102
+ * @var int
103
+ */
104
+ protected $qty_cancelled = 0;
105
+
106
  /**
107
  * Holds whether or not stock is being managed
108
  *
328
  case 'qty_sold':
329
  return $this->qty_sold();
330
  break;
331
+ case 'qty_cancelled':
332
+ return $this->qty_cancelled();
333
+ break;
334
  }
335
 
336
  return null;
353
  case 'qty_sold':
354
  return $this->qty_sold( $value );
355
  break;
356
+ case 'qty_cancelled':
357
+ return $this->qty_cancelled( $value );
358
+ break;
359
  }
360
 
361
  return null;
362
  }
363
+
364
+ /**
365
+ * Method to manage the protected `qty_cancelled` propriety of the Object
366
+ * Prevents setting `qty_cancelled` lower then zero
367
+ *
368
+ * @param int|null $value This will overwrite the old value
369
+ * @return int
370
+ */
371
+ public function qty_cancelled( $value = null ) {
372
+ // If the Value was passed as numeric value overwrite
373
+ if ( is_numeric( $value ) ) {
374
+ $this->qty_cancelled = $value;
375
+ }
376
+
377
+ // Prevents qty_cancelled from going negative
378
+ $this->qty_cancelled = max( (int) $this->qty_cancelled, 0 );
379
+
380
+ // return the new Qty Cancelled
381
+ return $this->qty_cancelled;
382
+ }
383
  }
384
+
385
  }
src/admin-views/list.php CHANGED
@@ -93,11 +93,23 @@
93
  <?php
94
  $stock = $ticket->stock();
95
  $sold = $ticket->qty_sold();
 
96
 
97
  if ( empty( $stock ) && $stock !== 0 ) : ?>
98
  <?php echo sprintf( esc_html__( 'Sold %d', 'event-tickets' ), esc_html( $sold ) ); ?>
99
  <?php else : ?>
100
- <?php echo sprintf( esc_html__( 'Sold %1$d of %2$d', 'event-tickets' ), esc_html( $sold ), esc_html( $sold + $stock ) ); ?>
 
 
 
 
 
 
 
 
 
 
 
101
  <?php endif; ?>
102
  </td>
103
  <td width="40%" valign="top">
93
  <?php
94
  $stock = $ticket->stock();
95
  $sold = $ticket->qty_sold();
96
+ $cancelled = $ticket->qty_cancelled();
97
 
98
  if ( empty( $stock ) && $stock !== 0 ) : ?>
99
  <?php echo sprintf( esc_html__( 'Sold %d', 'event-tickets' ), esc_html( $sold ) ); ?>
100
  <?php else : ?>
101
+ <?php
102
+ $cancelled_entry = empty( $cancelled ) ? '' : esc_html(sprintf(
103
+ __( ' (%1$d %2$s)' ), $cancelled,
104
+ _n( 'unit cancelled', 'units cancelled', $cancelled, 'event-tickets' )
105
+ ));
106
+ $line = sprintf(
107
+ esc_html__( 'Sold %1$d of %2$d%3$s', 'event-tickets' ), esc_html( $sold ),
108
+ esc_html( $sold + $stock ), $cancelled_entry
109
+ );
110
+
111
+ echo $line;
112
+ ?>
113
  <?php endif; ?>
114
  </td>
115
  <td width="40%" valign="top">
src/template-tags/tickets.php CHANGED
@@ -205,7 +205,7 @@ if ( ! function_exists( 'tribe_tickets_get_ticket_stock_message' ) ) {
205
 
206
  $pending_message = '';
207
  if ( $pending > 0 ) {
208
- $pending_message = sprintf( _n( '(%d awaiting review)', '(%d awaiting review)', 'event-tickets', $pending ), (int) $pending );
209
  }
210
 
211
  if ( ! $stock ) {
205
 
206
  $pending_message = '';
207
  if ( $pending > 0 ) {
208
+ $pending_message = sprintf( _n( '(%d awaiting review)', '(%d awaiting review)', $pending, 'event-tickets' ), (int) $pending );
209
  }
210
 
211
  if ( ! $stock ) {
src/views/tickets/email.php CHANGED
@@ -243,6 +243,7 @@
243
  }
244
 
245
  $venue_label = '';
 
246
 
247
  if ( function_exists( 'tribe_get_venue_id' ) ) {
248
  $venue_id = tribe_get_venue_id( $event->ID );
@@ -262,7 +263,17 @@
262
  }
263
  }
264
 
265
- if ( function_exists( 'tribe_get_start_date' ) ) {
 
 
 
 
 
 
 
 
 
 
266
  $start_date = tribe_get_start_date( $event, true );
267
  }
268
 
243
  }
244
 
245
  $venue_label = '';
246
+ $venue_name = null;
247
 
248
  if ( function_exists( 'tribe_get_venue_id' ) ) {
249
  $venue_id = tribe_get_venue_id( $event->ID );
263
  }
264
  }
265
 
266
+ $start_date = null;
267
+
268
+ /**
269
+ * Filters whether or not the event start date should be included in the ticket email
270
+ *
271
+ * @var boolean Include start date? Defaults to false
272
+ * @var int Event ID
273
+ */
274
+ $include_start_date = apply_filters( 'event_tickets_email_include_start_date', false, $event->ID );
275
+
276
+ if ( $include_start_date && function_exists( 'tribe_get_start_date' ) ) {
277
  $start_date = tribe_get_start_date( $event, true );
278
  }
279