Completed
Branch master (c35040)
by
unknown
07:33
created
core/db_classes/EE_Venue.class.php 1 patch
Indentation   +668 added lines, -668 removed lines patch added patch discarded remove patch
@@ -13,672 +13,672 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Venue extends EE_CPT_Base implements AddressInterface
15 15
 {
16
-    /**
17
-     * @param array  $props_n_values          incoming values
18
-     * @param string|null $timezone           incoming timezone (if not set the timezone set for the website
19
-     *                                        will be
20
-     *                                        used.)
21
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
22
-     *                                        date_format and the second value is the time format
23
-     * @return EE_Venue
24
-     * @throws EE_Error
25
-     * @throws ReflectionException
26
-     */
27
-    public static function new_instance(
28
-        array $props_n_values = [],
29
-        ?string $timezone = '',
30
-        array $date_formats = []
31
-    ): EE_Venue {
32
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
33
-        return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
34
-    }
35
-
36
-
37
-    /**
38
-     * @param array  $props_n_values  incoming values from the database
39
-     * @param string|null $timezone   incoming timezone as set by the model.
40
-     *                                If not set the timezone for the website will be used.
41
-     * @return EE_Venue
42
-     * @throws EE_Error
43
-     * @throws ReflectionException
44
-     */
45
-    public static function new_instance_from_db(array $props_n_values = [], ?string $timezone = ''): EE_Venue
46
-    {
47
-        return new self($props_n_values, true, $timezone);
48
-    }
49
-
50
-
51
-    /**
52
-     * Gets name
53
-     *
54
-     * @return string
55
-     * @throws EE_Error
56
-     * @throws ReflectionException
57
-     */
58
-    public function name(): string
59
-    {
60
-        return (string) $this->get('VNU_name');
61
-    }
62
-
63
-
64
-    /**
65
-     * Gets phone
66
-     *
67
-     * @return string
68
-     * @throws EE_Error
69
-     * @throws ReflectionException
70
-     */
71
-    public function phone(): string
72
-    {
73
-        return (string) $this->get('VNU_phone');
74
-    }
75
-
76
-
77
-    /**
78
-     * venue_url
79
-     *
80
-     * @return string
81
-     * @throws EE_Error
82
-     * @throws ReflectionException
83
-     */
84
-    public function venue_url(): string
85
-    {
86
-        return (string) $this->get('VNU_url');
87
-    }
88
-
89
-
90
-    /**
91
-     * Gets desc
92
-     *
93
-     * @return string
94
-     * @throws EE_Error
95
-     * @throws ReflectionException
96
-     */
97
-    public function description(): string
98
-    {
99
-        return (string) $this->get('VNU_desc');
100
-    }
101
-
102
-
103
-    /**
104
-     * Gets short description (AKA: the excerpt)
105
-     *
106
-     * @return string
107
-     * @throws EE_Error
108
-     * @throws ReflectionException
109
-     */
110
-    public function excerpt(): string
111
-    {
112
-        return (string) $this->get('VNU_short_desc');
113
-    }
114
-
115
-
116
-    /**
117
-     * Gets identifier
118
-     *
119
-     * @return string
120
-     * @throws EE_Error
121
-     * @throws ReflectionException
122
-     */
123
-    public function identifier(): string
124
-    {
125
-        return (string) $this->get('VNU_identifier');
126
-    }
127
-
128
-
129
-    /**
130
-     * Gets address
131
-     *
132
-     * @return string
133
-     * @throws EE_Error
134
-     * @throws ReflectionException
135
-     */
136
-    public function address(): string
137
-    {
138
-        return (string) $this->get('VNU_address');
139
-    }
140
-
141
-
142
-    /**
143
-     * Gets address2
144
-     *
145
-     * @return string
146
-     * @throws EE_Error
147
-     * @throws ReflectionException
148
-     */
149
-    public function address2(): string
150
-    {
151
-        return (string) $this->get('VNU_address2');
152
-    }
153
-
154
-
155
-    /**
156
-     * Gets city
157
-     *
158
-     * @return string
159
-     * @throws EE_Error
160
-     * @throws ReflectionException
161
-     */
162
-    public function city(): string
163
-    {
164
-        return (string) $this->get('VNU_city');
165
-    }
166
-
167
-
168
-    /**
169
-     * Gets state
170
-     *
171
-     * @return int
172
-     * @throws EE_Error
173
-     * @throws ReflectionException
174
-     */
175
-    public function state_ID(): int
176
-    {
177
-        return (int) $this->get('STA_ID');
178
-    }
179
-
180
-
181
-    /**
182
-     * @return string
183
-     * @throws EE_Error
184
-     * @throws ReflectionException
185
-     */
186
-    public function state_abbrev(): string
187
-    {
188
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
189
-    }
190
-
191
-
192
-    /**
193
-     * @return string
194
-     * @throws EE_Error
195
-     * @throws ReflectionException
196
-     */
197
-    public function state_name(): string
198
-    {
199
-        return (string) $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : '';
200
-    }
201
-
202
-
203
-    /**
204
-     * Gets the state for this venue
205
-     *
206
-     * @return EE_State|null
207
-     * @throws EE_Error
208
-     * @throws ReflectionException
209
-     */
210
-    public function state_obj(): ?EE_State
211
-    {
212
-        return $this->get_first_related('State');
213
-    }
214
-
215
-
216
-    /**
217
-     * either displays the state abbreviation or the state name, as determined
218
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
219
-     * defaults to abbreviation
220
-     *
221
-     * @return string
222
-     * @throws EE_Error
223
-     * @throws ReflectionException
224
-     */
225
-    public function state(): string
226
-    {
227
-        return apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())
228
-            ? $this->state_abbrev()
229
-            : $this->state_name();
230
-    }
231
-
232
-
233
-    /**
234
-     * country_ID
235
-     *
236
-     * @return string
237
-     * @throws EE_Error
238
-     * @throws ReflectionException
239
-     */
240
-    public function country_ID(): string
241
-    {
242
-        return (string) $this->get('CNT_ISO');
243
-    }
244
-
245
-
246
-    /**
247
-     * @return string
248
-     * @throws EE_Error
249
-     * @throws ReflectionException
250
-     */
251
-    public function country_name(): string
252
-    {
253
-        return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : '';
254
-    }
255
-
256
-
257
-    /**
258
-     * Gets the country of this venue
259
-     *
260
-     * @return EE_Country|null
261
-     * @throws EE_Error
262
-     * @throws ReflectionException
263
-     */
264
-    public function country_obj(): ?EE_Country
265
-    {
266
-        return $this->get_first_related('Country');
267
-    }
268
-
269
-
270
-    /**
271
-     * either displays the country ISO2 code or the country name, as determined
272
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
273
-     * defaults to abbreviation
274
-     *
275
-     * @return string
276
-     * @throws EE_Error
277
-     * @throws ReflectionException
278
-     */
279
-    public function country(): string
280
-    {
281
-        return apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())
282
-            ? $this->country_ID()
283
-            : $this->country_name();
284
-    }
285
-
286
-
287
-    /**
288
-     * Gets zip
289
-     *
290
-     * @return string
291
-     * @throws EE_Error
292
-     * @throws ReflectionException
293
-     */
294
-    public function zip(): string
295
-    {
296
-        return $this->get('VNU_zip');
297
-    }
298
-
299
-
300
-    /**
301
-     * Gets capacity
302
-     *
303
-     * @return int|string
304
-     * @throws EE_Error
305
-     * @throws ReflectionException
306
-     */
307
-    public function capacity()
308
-    {
309
-        return $this->get_pretty('VNU_capacity', 'symbol');
310
-    }
311
-
312
-
313
-    /**
314
-     * Gets created
315
-     *
316
-     * @return string
317
-     * @throws EE_Error
318
-     * @throws ReflectionException
319
-     */
320
-    public function created(): string
321
-    {
322
-        return (string) $this->get('VNU_created');
323
-    }
324
-
325
-
326
-    /**
327
-     * Gets modified
328
-     *
329
-     * @return string
330
-     * @throws EE_Error
331
-     * @throws ReflectionException
332
-     */
333
-    public function modified(): string
334
-    {
335
-        return (string) $this->get('VNU_modified');
336
-    }
337
-
338
-
339
-    /**
340
-     * Gets order
341
-     *
342
-     * @return int
343
-     * @throws EE_Error
344
-     * @throws ReflectionException
345
-     */
346
-    public function order(): int
347
-    {
348
-        return (int) $this->get('VNU_order');
349
-    }
350
-
351
-
352
-    /**
353
-     * Gets wp_user
354
-     *
355
-     * @return int
356
-     * @throws EE_Error
357
-     * @throws ReflectionException
358
-     */
359
-    public function wp_user(): int
360
-    {
361
-        return (int) $this->get('VNU_wp_user');
362
-    }
363
-
364
-
365
-    /**
366
-     * @return string
367
-     * @throws EE_Error
368
-     * @throws ReflectionException
369
-     */
370
-    public function virtual_phone(): string
371
-    {
372
-        return (string) $this->get('VNU_virtual_phone');
373
-    }
374
-
375
-
376
-    /**
377
-     * @return string
378
-     * @throws EE_Error
379
-     * @throws ReflectionException
380
-     */
381
-    public function virtual_url(): string
382
-    {
383
-        return (string) $this->get('VNU_virtual_url');
384
-    }
385
-
386
-
387
-    /**
388
-     * @return bool
389
-     * @throws EE_Error
390
-     * @throws ReflectionException
391
-     */
392
-    public function enable_for_gmap(): bool
393
-    {
394
-        return (bool) $this->get('VNU_enable_for_gmap');
395
-    }
396
-
397
-
398
-    /**
399
-     * @return string
400
-     * @throws EE_Error
401
-     * @throws ReflectionException
402
-     */
403
-    public function google_map_link(): string
404
-    {
405
-        return (string) $this->get('VNU_google_map_link');
406
-    }
407
-
408
-
409
-    /**
410
-     * Gets all events happening at this venue. Query parameters can be added to
411
-     * fetch a subset of those events.
412
-     *
413
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
414
-     * @param bool  $upcoming
415
-     * @return EE_Event[]
416
-     * @throws EE_Error
417
-     * @throws ReflectionException
418
-     */
419
-    public function events(array $query_params = array(), bool $upcoming = false): array
420
-    {
421
-        if ($upcoming) {
422
-            $query_params = array(
423
-                array(
424
-                    'status'                 => 'publish',
425
-                    'Datetime.DTT_EVT_start' => array(
426
-                        '>',
427
-                        EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
428
-                    ),
429
-                ),
430
-            );
431
-        }
432
-        return $this->get_many_related('Event', $query_params);
433
-    }
434
-
435
-
436
-    /**
437
-     * Sets address
438
-     *
439
-     * @param string $address
440
-     * @throws EE_Error
441
-     * @throws ReflectionException
442
-     */
443
-    public function set_address(string $address = '')
444
-    {
445
-        $this->set('VNU_address', $address);
446
-    }
447
-
448
-
449
-    /**
450
-     * @param string $address2
451
-     * @throws EE_Error
452
-     * @throws ReflectionException
453
-     */
454
-    public function set_address2(string $address2 = '')
455
-    {
456
-        $this->set('VNU_address2', $address2);
457
-    }
458
-
459
-
460
-    /**
461
-     * @param string $city
462
-     * @throws EE_Error
463
-     * @throws ReflectionException
464
-     */
465
-    public function set_city(string $city = '')
466
-    {
467
-        $this->set('VNU_city', $city);
468
-    }
469
-
470
-
471
-    /**
472
-     * @param int $state
473
-     * @throws EE_Error
474
-     * @throws ReflectionException
475
-     */
476
-    public function set_state_ID(int $state = 0)
477
-    {
478
-        $this->set('STA_ID', $state);
479
-    }
480
-
481
-
482
-    /**
483
-     * Sets the state, given either a state id or state object
484
-     *
485
-     * @param EE_State|int $state_id_or_obj
486
-     * @return EE_State
487
-     * @throws EE_Error
488
-     * @throws ReflectionException
489
-     */
490
-    public function set_state_obj($state_id_or_obj): EE_State
491
-    {
492
-        return $this->_add_relation_to($state_id_or_obj, 'State');
493
-    }
494
-
495
-
496
-    /**
497
-     * @param string $country_ID
498
-     * @throws EE_Error
499
-     * @throws ReflectionException
500
-     */
501
-    public function set_country_ID(string $country_ID = '')
502
-    {
503
-        $this->set('CNT_ISO', $country_ID);
504
-    }
505
-
506
-
507
-    /**
508
-     * Sets the country on the venue
509
-     *
510
-     * @param EE_Country|string $country_id_or_obj
511
-     * @return EE_Country
512
-     * @throws EE_Error
513
-     * @throws ReflectionException
514
-     */
515
-    public function set_country_obj($country_id_or_obj): EE_Country
516
-    {
517
-        return $this->_add_relation_to($country_id_or_obj, 'Country');
518
-    }
519
-
520
-
521
-    /**
522
-     * @param string $zip
523
-     * @throws EE_Error
524
-     * @throws ReflectionException
525
-     */
526
-    public function set_zip(string $zip = '')
527
-    {
528
-        $this->set('VNU_zip', $zip);
529
-    }
530
-
531
-
532
-    /**
533
-     * @param int $capacity
534
-     * @throws EE_Error
535
-     * @throws ReflectionException
536
-     */
537
-    public function set_capacity(int $capacity = 0)
538
-    {
539
-        $this->set('VNU_capacity', $capacity);
540
-    }
541
-
542
-
543
-    /**
544
-     * @param string $created
545
-     * @throws EE_Error
546
-     * @throws ReflectionException
547
-     */
548
-    public function set_created(string $created = '')
549
-    {
550
-        $this->set('VNU_created', $created);
551
-    }
552
-
553
-
554
-    /**
555
-     * @param string $desc
556
-     * @throws EE_Error
557
-     * @throws ReflectionException
558
-     */
559
-    public function set_description(string $desc = '')
560
-    {
561
-        $this->set('VNU_desc', $desc);
562
-    }
563
-
564
-
565
-    /**
566
-     * @param string $identifier
567
-     * @throws EE_Error
568
-     * @throws ReflectionException
569
-     */
570
-    public function set_identifier(string $identifier = '')
571
-    {
572
-        $this->set('VNU_identifier', $identifier);
573
-    }
574
-
575
-
576
-    /**
577
-     * @param string $modified
578
-     * @throws EE_Error
579
-     * @throws ReflectionException
580
-     */
581
-    public function set_modified(string $modified = '')
582
-    {
583
-        $this->set('VNU_modified', $modified);
584
-    }
585
-
586
-
587
-    /**
588
-     * @param string $name
589
-     * @throws EE_Error
590
-     * @throws ReflectionException
591
-     */
592
-    public function set_name(string $name = '')
593
-    {
594
-        $this->set('VNU_name', $name);
595
-    }
596
-
597
-
598
-    /**
599
-     * @param int $order
600
-     * @throws EE_Error
601
-     * @throws ReflectionException
602
-     */
603
-    public function set_order(int $order = 0)
604
-    {
605
-        $this->set('VNU_order', $order);
606
-    }
607
-
608
-
609
-    /**
610
-     * @param string $phone
611
-     * @throws EE_Error
612
-     * @throws ReflectionException
613
-     */
614
-    public function set_phone(string $phone = '')
615
-    {
616
-        $this->set('VNU_phone', $phone);
617
-    }
618
-
619
-
620
-    /**
621
-     * @param int $wp_user
622
-     * @throws EE_Error
623
-     * @throws ReflectionException
624
-     */
625
-    public function set_wp_user(int $wp_user = 1)
626
-    {
627
-        $this->set('VNU_wp_user', $wp_user);
628
-    }
629
-
630
-
631
-    /**
632
-     * @param string $url
633
-     * @throws EE_Error
634
-     * @throws ReflectionException
635
-     */
636
-    public function set_venue_url(string $url = '')
637
-    {
638
-        $this->set('VNU_url', $url);
639
-    }
640
-
641
-
642
-    /**
643
-     * @param string $phone
644
-     * @throws EE_Error
645
-     * @throws ReflectionException
646
-     */
647
-    public function set_virtual_phone(string $phone = '')
648
-    {
649
-        $this->set('VNU_virtual_phone', $phone);
650
-    }
651
-
652
-
653
-    /**
654
-     * @param string $url
655
-     * @throws EE_Error
656
-     * @throws ReflectionException
657
-     */
658
-    public function set_virtual_url(string $url = '')
659
-    {
660
-        $this->set('VNU_virtual_url', $url);
661
-    }
662
-
663
-
664
-    /**
665
-     * @param bool|int|string $enable
666
-     * @throws EE_Error
667
-     * @throws ReflectionException
668
-     */
669
-    public function set_enable_for_gmap($enable = false)
670
-    {
671
-        $this->set('VNU_enable_for_gmap', $enable);
672
-    }
673
-
674
-
675
-    /**
676
-     * @param string $google_map_link
677
-     * @throws EE_Error
678
-     * @throws ReflectionException
679
-     */
680
-    public function set_google_map_link(string $google_map_link = '')
681
-    {
682
-        $this->set('VNU_google_map_link', $google_map_link);
683
-    }
16
+	/**
17
+	 * @param array  $props_n_values          incoming values
18
+	 * @param string|null $timezone           incoming timezone (if not set the timezone set for the website
19
+	 *                                        will be
20
+	 *                                        used.)
21
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
22
+	 *                                        date_format and the second value is the time format
23
+	 * @return EE_Venue
24
+	 * @throws EE_Error
25
+	 * @throws ReflectionException
26
+	 */
27
+	public static function new_instance(
28
+		array $props_n_values = [],
29
+		?string $timezone = '',
30
+		array $date_formats = []
31
+	): EE_Venue {
32
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
33
+		return $has_object ?: new self($props_n_values, false, $timezone, $date_formats);
34
+	}
35
+
36
+
37
+	/**
38
+	 * @param array  $props_n_values  incoming values from the database
39
+	 * @param string|null $timezone   incoming timezone as set by the model.
40
+	 *                                If not set the timezone for the website will be used.
41
+	 * @return EE_Venue
42
+	 * @throws EE_Error
43
+	 * @throws ReflectionException
44
+	 */
45
+	public static function new_instance_from_db(array $props_n_values = [], ?string $timezone = ''): EE_Venue
46
+	{
47
+		return new self($props_n_values, true, $timezone);
48
+	}
49
+
50
+
51
+	/**
52
+	 * Gets name
53
+	 *
54
+	 * @return string
55
+	 * @throws EE_Error
56
+	 * @throws ReflectionException
57
+	 */
58
+	public function name(): string
59
+	{
60
+		return (string) $this->get('VNU_name');
61
+	}
62
+
63
+
64
+	/**
65
+	 * Gets phone
66
+	 *
67
+	 * @return string
68
+	 * @throws EE_Error
69
+	 * @throws ReflectionException
70
+	 */
71
+	public function phone(): string
72
+	{
73
+		return (string) $this->get('VNU_phone');
74
+	}
75
+
76
+
77
+	/**
78
+	 * venue_url
79
+	 *
80
+	 * @return string
81
+	 * @throws EE_Error
82
+	 * @throws ReflectionException
83
+	 */
84
+	public function venue_url(): string
85
+	{
86
+		return (string) $this->get('VNU_url');
87
+	}
88
+
89
+
90
+	/**
91
+	 * Gets desc
92
+	 *
93
+	 * @return string
94
+	 * @throws EE_Error
95
+	 * @throws ReflectionException
96
+	 */
97
+	public function description(): string
98
+	{
99
+		return (string) $this->get('VNU_desc');
100
+	}
101
+
102
+
103
+	/**
104
+	 * Gets short description (AKA: the excerpt)
105
+	 *
106
+	 * @return string
107
+	 * @throws EE_Error
108
+	 * @throws ReflectionException
109
+	 */
110
+	public function excerpt(): string
111
+	{
112
+		return (string) $this->get('VNU_short_desc');
113
+	}
114
+
115
+
116
+	/**
117
+	 * Gets identifier
118
+	 *
119
+	 * @return string
120
+	 * @throws EE_Error
121
+	 * @throws ReflectionException
122
+	 */
123
+	public function identifier(): string
124
+	{
125
+		return (string) $this->get('VNU_identifier');
126
+	}
127
+
128
+
129
+	/**
130
+	 * Gets address
131
+	 *
132
+	 * @return string
133
+	 * @throws EE_Error
134
+	 * @throws ReflectionException
135
+	 */
136
+	public function address(): string
137
+	{
138
+		return (string) $this->get('VNU_address');
139
+	}
140
+
141
+
142
+	/**
143
+	 * Gets address2
144
+	 *
145
+	 * @return string
146
+	 * @throws EE_Error
147
+	 * @throws ReflectionException
148
+	 */
149
+	public function address2(): string
150
+	{
151
+		return (string) $this->get('VNU_address2');
152
+	}
153
+
154
+
155
+	/**
156
+	 * Gets city
157
+	 *
158
+	 * @return string
159
+	 * @throws EE_Error
160
+	 * @throws ReflectionException
161
+	 */
162
+	public function city(): string
163
+	{
164
+		return (string) $this->get('VNU_city');
165
+	}
166
+
167
+
168
+	/**
169
+	 * Gets state
170
+	 *
171
+	 * @return int
172
+	 * @throws EE_Error
173
+	 * @throws ReflectionException
174
+	 */
175
+	public function state_ID(): int
176
+	{
177
+		return (int) $this->get('STA_ID');
178
+	}
179
+
180
+
181
+	/**
182
+	 * @return string
183
+	 * @throws EE_Error
184
+	 * @throws ReflectionException
185
+	 */
186
+	public function state_abbrev(): string
187
+	{
188
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
189
+	}
190
+
191
+
192
+	/**
193
+	 * @return string
194
+	 * @throws EE_Error
195
+	 * @throws ReflectionException
196
+	 */
197
+	public function state_name(): string
198
+	{
199
+		return (string) $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : '';
200
+	}
201
+
202
+
203
+	/**
204
+	 * Gets the state for this venue
205
+	 *
206
+	 * @return EE_State|null
207
+	 * @throws EE_Error
208
+	 * @throws ReflectionException
209
+	 */
210
+	public function state_obj(): ?EE_State
211
+	{
212
+		return $this->get_first_related('State');
213
+	}
214
+
215
+
216
+	/**
217
+	 * either displays the state abbreviation or the state name, as determined
218
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
219
+	 * defaults to abbreviation
220
+	 *
221
+	 * @return string
222
+	 * @throws EE_Error
223
+	 * @throws ReflectionException
224
+	 */
225
+	public function state(): string
226
+	{
227
+		return apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())
228
+			? $this->state_abbrev()
229
+			: $this->state_name();
230
+	}
231
+
232
+
233
+	/**
234
+	 * country_ID
235
+	 *
236
+	 * @return string
237
+	 * @throws EE_Error
238
+	 * @throws ReflectionException
239
+	 */
240
+	public function country_ID(): string
241
+	{
242
+		return (string) $this->get('CNT_ISO');
243
+	}
244
+
245
+
246
+	/**
247
+	 * @return string
248
+	 * @throws EE_Error
249
+	 * @throws ReflectionException
250
+	 */
251
+	public function country_name(): string
252
+	{
253
+		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : '';
254
+	}
255
+
256
+
257
+	/**
258
+	 * Gets the country of this venue
259
+	 *
260
+	 * @return EE_Country|null
261
+	 * @throws EE_Error
262
+	 * @throws ReflectionException
263
+	 */
264
+	public function country_obj(): ?EE_Country
265
+	{
266
+		return $this->get_first_related('Country');
267
+	}
268
+
269
+
270
+	/**
271
+	 * either displays the country ISO2 code or the country name, as determined
272
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
273
+	 * defaults to abbreviation
274
+	 *
275
+	 * @return string
276
+	 * @throws EE_Error
277
+	 * @throws ReflectionException
278
+	 */
279
+	public function country(): string
280
+	{
281
+		return apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())
282
+			? $this->country_ID()
283
+			: $this->country_name();
284
+	}
285
+
286
+
287
+	/**
288
+	 * Gets zip
289
+	 *
290
+	 * @return string
291
+	 * @throws EE_Error
292
+	 * @throws ReflectionException
293
+	 */
294
+	public function zip(): string
295
+	{
296
+		return $this->get('VNU_zip');
297
+	}
298
+
299
+
300
+	/**
301
+	 * Gets capacity
302
+	 *
303
+	 * @return int|string
304
+	 * @throws EE_Error
305
+	 * @throws ReflectionException
306
+	 */
307
+	public function capacity()
308
+	{
309
+		return $this->get_pretty('VNU_capacity', 'symbol');
310
+	}
311
+
312
+
313
+	/**
314
+	 * Gets created
315
+	 *
316
+	 * @return string
317
+	 * @throws EE_Error
318
+	 * @throws ReflectionException
319
+	 */
320
+	public function created(): string
321
+	{
322
+		return (string) $this->get('VNU_created');
323
+	}
324
+
325
+
326
+	/**
327
+	 * Gets modified
328
+	 *
329
+	 * @return string
330
+	 * @throws EE_Error
331
+	 * @throws ReflectionException
332
+	 */
333
+	public function modified(): string
334
+	{
335
+		return (string) $this->get('VNU_modified');
336
+	}
337
+
338
+
339
+	/**
340
+	 * Gets order
341
+	 *
342
+	 * @return int
343
+	 * @throws EE_Error
344
+	 * @throws ReflectionException
345
+	 */
346
+	public function order(): int
347
+	{
348
+		return (int) $this->get('VNU_order');
349
+	}
350
+
351
+
352
+	/**
353
+	 * Gets wp_user
354
+	 *
355
+	 * @return int
356
+	 * @throws EE_Error
357
+	 * @throws ReflectionException
358
+	 */
359
+	public function wp_user(): int
360
+	{
361
+		return (int) $this->get('VNU_wp_user');
362
+	}
363
+
364
+
365
+	/**
366
+	 * @return string
367
+	 * @throws EE_Error
368
+	 * @throws ReflectionException
369
+	 */
370
+	public function virtual_phone(): string
371
+	{
372
+		return (string) $this->get('VNU_virtual_phone');
373
+	}
374
+
375
+
376
+	/**
377
+	 * @return string
378
+	 * @throws EE_Error
379
+	 * @throws ReflectionException
380
+	 */
381
+	public function virtual_url(): string
382
+	{
383
+		return (string) $this->get('VNU_virtual_url');
384
+	}
385
+
386
+
387
+	/**
388
+	 * @return bool
389
+	 * @throws EE_Error
390
+	 * @throws ReflectionException
391
+	 */
392
+	public function enable_for_gmap(): bool
393
+	{
394
+		return (bool) $this->get('VNU_enable_for_gmap');
395
+	}
396
+
397
+
398
+	/**
399
+	 * @return string
400
+	 * @throws EE_Error
401
+	 * @throws ReflectionException
402
+	 */
403
+	public function google_map_link(): string
404
+	{
405
+		return (string) $this->get('VNU_google_map_link');
406
+	}
407
+
408
+
409
+	/**
410
+	 * Gets all events happening at this venue. Query parameters can be added to
411
+	 * fetch a subset of those events.
412
+	 *
413
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
414
+	 * @param bool  $upcoming
415
+	 * @return EE_Event[]
416
+	 * @throws EE_Error
417
+	 * @throws ReflectionException
418
+	 */
419
+	public function events(array $query_params = array(), bool $upcoming = false): array
420
+	{
421
+		if ($upcoming) {
422
+			$query_params = array(
423
+				array(
424
+					'status'                 => 'publish',
425
+					'Datetime.DTT_EVT_start' => array(
426
+						'>',
427
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
428
+					),
429
+				),
430
+			);
431
+		}
432
+		return $this->get_many_related('Event', $query_params);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Sets address
438
+	 *
439
+	 * @param string $address
440
+	 * @throws EE_Error
441
+	 * @throws ReflectionException
442
+	 */
443
+	public function set_address(string $address = '')
444
+	{
445
+		$this->set('VNU_address', $address);
446
+	}
447
+
448
+
449
+	/**
450
+	 * @param string $address2
451
+	 * @throws EE_Error
452
+	 * @throws ReflectionException
453
+	 */
454
+	public function set_address2(string $address2 = '')
455
+	{
456
+		$this->set('VNU_address2', $address2);
457
+	}
458
+
459
+
460
+	/**
461
+	 * @param string $city
462
+	 * @throws EE_Error
463
+	 * @throws ReflectionException
464
+	 */
465
+	public function set_city(string $city = '')
466
+	{
467
+		$this->set('VNU_city', $city);
468
+	}
469
+
470
+
471
+	/**
472
+	 * @param int $state
473
+	 * @throws EE_Error
474
+	 * @throws ReflectionException
475
+	 */
476
+	public function set_state_ID(int $state = 0)
477
+	{
478
+		$this->set('STA_ID', $state);
479
+	}
480
+
481
+
482
+	/**
483
+	 * Sets the state, given either a state id or state object
484
+	 *
485
+	 * @param EE_State|int $state_id_or_obj
486
+	 * @return EE_State
487
+	 * @throws EE_Error
488
+	 * @throws ReflectionException
489
+	 */
490
+	public function set_state_obj($state_id_or_obj): EE_State
491
+	{
492
+		return $this->_add_relation_to($state_id_or_obj, 'State');
493
+	}
494
+
495
+
496
+	/**
497
+	 * @param string $country_ID
498
+	 * @throws EE_Error
499
+	 * @throws ReflectionException
500
+	 */
501
+	public function set_country_ID(string $country_ID = '')
502
+	{
503
+		$this->set('CNT_ISO', $country_ID);
504
+	}
505
+
506
+
507
+	/**
508
+	 * Sets the country on the venue
509
+	 *
510
+	 * @param EE_Country|string $country_id_or_obj
511
+	 * @return EE_Country
512
+	 * @throws EE_Error
513
+	 * @throws ReflectionException
514
+	 */
515
+	public function set_country_obj($country_id_or_obj): EE_Country
516
+	{
517
+		return $this->_add_relation_to($country_id_or_obj, 'Country');
518
+	}
519
+
520
+
521
+	/**
522
+	 * @param string $zip
523
+	 * @throws EE_Error
524
+	 * @throws ReflectionException
525
+	 */
526
+	public function set_zip(string $zip = '')
527
+	{
528
+		$this->set('VNU_zip', $zip);
529
+	}
530
+
531
+
532
+	/**
533
+	 * @param int $capacity
534
+	 * @throws EE_Error
535
+	 * @throws ReflectionException
536
+	 */
537
+	public function set_capacity(int $capacity = 0)
538
+	{
539
+		$this->set('VNU_capacity', $capacity);
540
+	}
541
+
542
+
543
+	/**
544
+	 * @param string $created
545
+	 * @throws EE_Error
546
+	 * @throws ReflectionException
547
+	 */
548
+	public function set_created(string $created = '')
549
+	{
550
+		$this->set('VNU_created', $created);
551
+	}
552
+
553
+
554
+	/**
555
+	 * @param string $desc
556
+	 * @throws EE_Error
557
+	 * @throws ReflectionException
558
+	 */
559
+	public function set_description(string $desc = '')
560
+	{
561
+		$this->set('VNU_desc', $desc);
562
+	}
563
+
564
+
565
+	/**
566
+	 * @param string $identifier
567
+	 * @throws EE_Error
568
+	 * @throws ReflectionException
569
+	 */
570
+	public function set_identifier(string $identifier = '')
571
+	{
572
+		$this->set('VNU_identifier', $identifier);
573
+	}
574
+
575
+
576
+	/**
577
+	 * @param string $modified
578
+	 * @throws EE_Error
579
+	 * @throws ReflectionException
580
+	 */
581
+	public function set_modified(string $modified = '')
582
+	{
583
+		$this->set('VNU_modified', $modified);
584
+	}
585
+
586
+
587
+	/**
588
+	 * @param string $name
589
+	 * @throws EE_Error
590
+	 * @throws ReflectionException
591
+	 */
592
+	public function set_name(string $name = '')
593
+	{
594
+		$this->set('VNU_name', $name);
595
+	}
596
+
597
+
598
+	/**
599
+	 * @param int $order
600
+	 * @throws EE_Error
601
+	 * @throws ReflectionException
602
+	 */
603
+	public function set_order(int $order = 0)
604
+	{
605
+		$this->set('VNU_order', $order);
606
+	}
607
+
608
+
609
+	/**
610
+	 * @param string $phone
611
+	 * @throws EE_Error
612
+	 * @throws ReflectionException
613
+	 */
614
+	public function set_phone(string $phone = '')
615
+	{
616
+		$this->set('VNU_phone', $phone);
617
+	}
618
+
619
+
620
+	/**
621
+	 * @param int $wp_user
622
+	 * @throws EE_Error
623
+	 * @throws ReflectionException
624
+	 */
625
+	public function set_wp_user(int $wp_user = 1)
626
+	{
627
+		$this->set('VNU_wp_user', $wp_user);
628
+	}
629
+
630
+
631
+	/**
632
+	 * @param string $url
633
+	 * @throws EE_Error
634
+	 * @throws ReflectionException
635
+	 */
636
+	public function set_venue_url(string $url = '')
637
+	{
638
+		$this->set('VNU_url', $url);
639
+	}
640
+
641
+
642
+	/**
643
+	 * @param string $phone
644
+	 * @throws EE_Error
645
+	 * @throws ReflectionException
646
+	 */
647
+	public function set_virtual_phone(string $phone = '')
648
+	{
649
+		$this->set('VNU_virtual_phone', $phone);
650
+	}
651
+
652
+
653
+	/**
654
+	 * @param string $url
655
+	 * @throws EE_Error
656
+	 * @throws ReflectionException
657
+	 */
658
+	public function set_virtual_url(string $url = '')
659
+	{
660
+		$this->set('VNU_virtual_url', $url);
661
+	}
662
+
663
+
664
+	/**
665
+	 * @param bool|int|string $enable
666
+	 * @throws EE_Error
667
+	 * @throws ReflectionException
668
+	 */
669
+	public function set_enable_for_gmap($enable = false)
670
+	{
671
+		$this->set('VNU_enable_for_gmap', $enable);
672
+	}
673
+
674
+
675
+	/**
676
+	 * @param string $google_map_link
677
+	 * @throws EE_Error
678
+	 * @throws ReflectionException
679
+	 */
680
+	public function set_google_map_link(string $google_map_link = '')
681
+	{
682
+		$this->set('VNU_google_map_link', $google_map_link);
683
+	}
684 684
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '7.2.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '7.2.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.44.rc.001');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.44.rc.001');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.