Completed
Branch FET-10816-display-form-wide-er... (f3ba21)
by
unknown
85:23 queued 74:18
created
core/libraries/messages/EE_message_type.lib.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -825,7 +825,7 @@
 block discarded – undo
825 825
      * Takes care of setting up the addressee object(s) for the primary attendee.
826 826
      *
827 827
      * @access protected
828
-     * @return array of EE_Addressee objects
828
+     * @return EE_Messages_Addressee[] of EE_Addressee objects
829 829
      */
830 830
     protected function _primary_attendee_addressees()
831 831
     {
Please login to merge, or discard this patch.
Indentation   +895 added lines, -895 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -18,906 +18,906 @@  discard block
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * message type child classes will set what contexts are associated with the message type via this array.
23
-     * format:
24
-     * array(
25
-     * 'context' => array(
26
-     *        'label' => __('Context Label', 'event_espresso'),
27
-     *        'description' => __('Context description (for help popups)', 'event_espresso')
28
-     *    ));
29
-     *
30
-     * @var array
31
-     */
32
-    protected $_contexts = array();
33
-
34
-
35
-    /**
36
-     * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.)
37
-     * Format:
38
-     * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' );
39
-     *
40
-     * @var array
41
-     */
42
-    protected $_context_label;
43
-
44
-
45
-    /** MESSAGE ASSEMBLING PROPERTIES **/
46
-    /**
47
-     * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger.
48
-     *
49
-     * @var array of message objects.
50
-     */
51
-    public $messages = array();
52
-
53
-    /**
54
-     * The following holds the templates that will be used to assemble the message object for the messenger.
55
-     *
56
-     * @var array
57
-     */
58
-    protected $_templates;
59
-
60
-
61
-    /**
62
-     * If a specific template is being parsed, this will hold the message template group GRP_ID for that template.
63
-     *
64
-     * @var int.
65
-     */
66
-    protected $_GRP_ID;
67
-
68
-
69
-    /** OTHER INFO PROPERTIES **/
70
-    /**
71
-     * This will hold the count of the message objects in the messages array. This could be used for determining if
72
-     * batching/queueing is needed.
73
-     *
74
-     * @var int
75
-     */
76
-    public $count = 0;
77
-
78
-
79
-    /**
80
-     * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of
81
-     * this message type at time of sending.
82
-     *
83
-     * @var EE_messenger
84
-     */
85
-    protected $_active_messenger;
86
-
87
-
88
-    /**
89
-     * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates
90
-     *
91
-     * @var object
92
-     */
93
-    protected $_shortcode_replace;
94
-
95
-
96
-    /**
97
-     * The purpose for this property is to simply allow message types to indicate if the message generated is intended
98
-     * for only single context.  Child message types should redefine this variable (if necessary) in the
99
-     * _set_data_Handler() method.
100
-     *
101
-     * @var boolean
102
-     */
103
-    protected $_single_message = false;
104
-
105
-
106
-    /**
107
-     * This will hold an array of specific reg_ids that are receiving messages.
108
-     *
109
-     * @since 4.7.x
110
-     * @var array
111
-     */
112
-    protected $_regs_for_sending = array();
113
-
114
-
115
-    /**
116
-     * This holds the data passed to this class from the controller and also the final processed data.
117
-     *
118
-     * @var object
119
-     */
120
-    protected $_data;
121
-
122
-
123
-    /**
124
-     * this is just a flag indicating whether we're in preview mode or not.
125
-     *
126
-     * @var bool
127
-     */
128
-    protected $_preview = false;
129
-
130
-
131
-    /**
132
-     * This just holds defaults for addressee data that children merge with their data array setup
133
-     *
134
-     * @var array
135
-     */
136
-    protected $_default_addressee_data;
137
-
138
-
139
-    /**
140
-     * Child classes declare through this property what handler they want to use for the incoming data and this string
141
-     * is used to instantiate the EE_Messages_incoming_data child class for that handler.
142
-     *
143
-     * @var string
144
-     */
145
-    protected $_data_handler;
146
-
147
-
148
-    /**
149
-     * This holds any specific fields for holding any settings related to a message type (if any needed)
150
-     *
151
-     * @var array
152
-     */
153
-    protected $_admin_settings_fields = array();
154
-
155
-    /**
156
-     * this property will hold any existing setting that may have been set in the admin.
157
-     *
158
-     * @var array
159
-     */
160
-    protected $_existing_admin_settings = array();
161
-
162
-
163
-    /**
164
-     * This is used to designate the generating and alternative sending messengers for a message type.  It is set via
165
-     * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message
166
-     * type.  However ONLY the generating messengers are used for creating templates for this message type. Should be
167
-     * in this format:
168
-     * {
169
-     *
170
-     * @type string $generating_messenger the name of the generating messenger.  Generating
171
-     *                                          messengers are used for generating templates,
172
-     *                                          doing validation and defining valid shortcodes.
173
-     *      {
174
-     * @type string $sending_messenger    values are the name(s) for the sending
175
-     *                                              messengers.  sending messengers are
176
-     *                                              just valid delivery vehicles that will utilize
177
-     *                                              the templates (and generated EE_message
178
-     *                                              objects from the generating messengers).
179
-     *      }
180
-     * }
181
-     * @since                             4.5.0
182
-     * @var array
183
-     */
184
-    protected $_with_messengers = array();
185
-
186
-
187
-    /**
188
-     * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects.
189
-     *
190
-     * @access protected
191
-     * @var array
192
-     */
193
-    protected $_addressees = array();
194
-
195
-
196
-    /**
197
-     * This allows each message type to set what alternate messenger&message type combination can be used for fallback
198
-     * default templates if there are no specific ones defined for this messenger and message type.  Should be in the
199
-     * format:
200
-     * array(
201
-     *      'messenger' => 'message_type',
202
-     *      'another_messenger' => another_message_type
203
-     * );
204
-     * This is set in the message type constructor.
205
-     *
206
-     * @var array
207
-     */
208
-    protected $_master_templates = array();
209
-
210
-
211
-    /**
212
-     * This holds whatever the set template pack is for a message template group when generating messages.
213
-     *
214
-     * @since 4.5.0
215
-     * @var EE_Messages_Template_Pack
216
-     */
217
-    protected $_template_pack;
218
-
219
-
220
-    /**
221
-     * This holds whatever the set variation is for a message template group when generating messages.
222
-     *
223
-     * @since 4.5.0
224
-     * @var string
225
-     */
226
-    protected $_variation;
227
-
228
-
229
-    /**
230
-     * EE_message_type constructor.
231
-     */
232
-    public function __construct()
233
-    {
234
-        $this->_messages_item_type = 'message_type';
235
-        $this->_set_contexts();
236
-        $this->_set_with_messengers();
237
-        parent::__construct();
238
-    }
239
-
240
-
241
-    /**
242
-     * This sets the data handler for the message type.  It must be used to define the _data_handler property.  It is
243
-     * called when messages are setup.
244
-     *
245
-     * @abstract
246
-     * @access protected
247
-     * @return void
248
-     */
249
-    abstract protected function _set_data_handler();
250
-
251
-
252
-    /**
253
-     * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and
254
-     * ID (which should be the primary key id for the base class).  Client code doesn't have to know what a message
255
-     * type's data handler is.
256
-     *
257
-     * @since 4.5.0
258
-     * @param string          $context      This should be a string matching a valid context for the message type.
259
-     * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
260
-     *                                      guessing a url).
261
-     * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
262
-     *                                      EE_Base_Class_Object
263
-     * @return mixed ( EE_Base_Class||EE_Base_Class[] )
264
-     */
265
-    abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
266
-
267
-
268
-    /**
269
-     * _set_contexts
270
-     * This sets up the contexts associated with the message_type
271
-     *
272
-     * @abstract
273
-     * @access  protected
274
-     * @return  void
275
-     */
276
-    abstract protected function _set_contexts();
277
-
278
-
279
-    /**
280
-     * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger().
281
-     * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific
282
-     * EE_Base_Class that is required in generating a message for a message type recipient then the message
283
-     * type should override this method and use the given params to generate the correct ID.
284
-     *
285
-     * @param string          $context      The message type context.
286
-     * @param EE_Registration $registration Registration object
287
-     * @deprecated 4.9.0
288
-     * @return int
289
-     */
290
-    protected function _get_id_for_msg_url($context, EE_Registration $registration)
291
-    {
292
-        return 0;
293
-    }
294
-
295
-
296
-    /**
297
-     * This sets up any action/filter hooks this message type puts in place for a specific messenger.  Note that by
298
-     * default this does nothing.  Child classes will need to override if they want to add specific hooks for a
299
-     * messenger.
300
-     *
301
-     * @since 1.0.0
302
-     * @return void
303
-     */
304
-    protected function _do_messenger_hooks()
305
-    {
306
-        return;
307
-    }
308
-
309
-
310
-    /**
311
-     * This is a public wrapper for the protected _do_messenger_hooks() method.
312
-     * For backward compat reasons, this was done rather than making the protected method public.
313
-     *
314
-     * @param   EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able
315
-     *                                  to know what messenger is being used to send the message at the time of
316
-     *                                  sending.
317
-     * @since 4.9.0
318
-     */
319
-    public function do_messenger_hooks($messenger = null)
320
-    {
321
-        $this->_active_messenger = $messenger;
322
-        $this->_do_messenger_hooks();
323
-    }
324
-
325
-
326
-    /**
327
-     * This method returns whether this message type should always generate a new copy
328
-     * when requested, or if links can be to the already generated copy.
329
-     * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table.
330
-     * Child classes should override this if different from the default of false.
331
-     *
332
-     * @return bool     false means can link to generated EE_Message.  true must regenerate.
333
-     */
334
-    public function always_generate()
335
-    {
336
-        return false;
337
-    }
338
-
339
-
340
-    /**
341
-     * Returns the priority for the message type.
342
-     * Priorities are defined as constants on EEM_Message.  Currently there are three priorities:
343
-     * - EEM_Message::priority_high
344
-     * - EEM_Message::priority_medium
345
-     * - EEM_Message::priority_low
346
-     * Priority is used to determine the weight the message type is given when queuing for generation and/or sending.
347
-     *
348
-     * @see    EEM_Message for more phpdocs on priority.
349
-     *         The default priority for all message_types is EEM_Message::priority_low.  Message Types wanting to give
350
-     *         a higher priority must override this method. Also note, messengers are able to override priorities
351
-     *         queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger
352
-     *         which displays things in the browser.
353
-     * @since  4.9.0
354
-     * @return int
355
-     */
356
-    public function get_priority()
357
-    {
358
-        return EEM_Message::priority_low;
359
-    }
360
-
361
-
362
-    /**
363
-     * This runs the _set_data_handler() method for message types and then returns what got set.
364
-     *
365
-     * @param mixed $data This sets the data property for the message type with the incoming data used for generating.
366
-     * @return string (the reference for the data handler) (will be an empty string if could not be determined).
367
-     */
368
-    public function get_data_handler($data)
369
-    {
370
-        $this->_data = $data;
371
-        $this->_set_data_handler();
372
-        return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this);
373
-    }
374
-
375
-
376
-    /**
377
-     * This is called externally to reset the value of the $_data property for the message type.
378
-     * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
379
-     * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called
380
-     * (and for back compat reasons). This particular method is used in
381
-     * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is
382
-     * cleaned before subsequent EE_Message generation in the same request.
383
-     *
384
-     * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
385
-     *            ensure that there is no manipulation of the _data property during run time so there's a clear
386
-     *            expectation of what it is.  Likely we need to ensure that _data is not persisted IN the message type
387
-     *            at all.
388
-     * @internal  Plugin authors, do not implement this method, it is subject to change.
389
-     * @since     4.9
390
-     */
391
-    public function reset_data()
392
-    {
393
-        $this->_data = null;
394
-    }
395
-
396
-
397
-    /**
398
-     * This does some validation of incoming params gets the url trigger from the defined method in the specific child
399
-     * class and then filters the results.
400
-     *
401
-     * @param string          $context           The message type context
402
-     * @param string          $sending_messenger The sending messenger
403
-     * @param EE_Registration $registration      Registration object
404
-     * @throws EE_Error
405
-     * @deprecated  4.9.0  Likely 4.9.10 or 4.10.0 will remove this method completely
406
-     * @return string          generated url
407
-     */
408
-    public function get_url_trigger($context, $sending_messenger, EE_Registration $registration)
409
-    {
410
-        //validate context
411
-        //valid context?
412
-        if (! isset($this->_contexts[$context])) {
413
-            throw new EE_Error(
414
-                sprintf(
415
-                    __('The context %s is not a valid context for %s.', 'event_espresso'),
416
-                    $context,
417
-                    get_class($this)
418
-                )
419
-            );
420
-        }
421
-        //valid sending_messenger?
422
-        $not_valid_msgr = false;
423
-        foreach ($this->_with_messengers as $generating => $sendings) {
424
-            if (empty($sendings) || array_search($sending_messenger, $sendings) === false) {
425
-                $not_valid_msgr = true;
426
-            }
427
-        }
428
-        if ($not_valid_msgr) {
429
-            throw new EE_Error(
430
-                sprintf(
431
-                    __(
432
-                        'The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.',
433
-                        'event_espresso'
434
-                    ),
435
-                    $sending_messenger,
436
-                    get_class($this)
437
-                )
438
-            );
439
-        }
440
-        return EEH_MSG_Template::generate_url_trigger(
441
-            $sending_messenger,
442
-            $this->_active_messenger->name,
443
-            $context,
444
-            $this->name,
445
-            $registration,
446
-            $this->_GRP_ID,
447
-            $this->_get_id_for_msg_url($context, $registration)
448
-        );
449
-    }
450
-
451
-
452
-    /**
453
-     * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows
454
-     * for filtering. This is (currently) called by the EED_Messages module.
455
-     *
456
-     * @since 4.5.0
457
-     * @throws EE_Error
458
-     * @param string          $context      This should be a string matching a valid context for the message type.
459
-     * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
460
-     *                                      guessing a url).
461
-     * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
462
-     *                                      EE_Base_Class_Object
463
-     * @return mixed (EE_Base_Class||EE_Base_Class[])
464
-     */
465
-    public function get_data_for_context($context, EE_Registration $registration, $id = 0)
466
-    {
467
-        //valid context?
468
-        if (! isset($this->_contexts[$context])) {
469
-            throw new EE_Error(
470
-                sprintf(
471
-                    __('The context %s is not a valid context for %s.', 'event_espresso'),
472
-                    $context,
473
-                    get_class($this)
474
-                )
475
-            );
476
-        }
477
-        //get data and apply global and class specific filters on it.
478
-        $data = apply_filters(
479
-            'FHEE__EE_message_type__get_data_for_context__data',
480
-            $this->_get_data_for_context($context, $registration, $id),
481
-            $this
482
-        );
483
-        $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
484
-        //if empty then something went wrong!
485
-        if (empty($data)) {
486
-            throw new EE_Error(
487
-                sprintf(
488
-                    __(
489
-                        'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.',
490
-                        'event_espresso'
491
-                    ),
492
-                    $id,
493
-                    $this->name
494
-                )
495
-            );
496
-        }
497
-        return $data;
498
-    }
499
-
500
-
501
-    /**
502
-     * This returns the contents of the _data property.
503
-     * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
504
-     * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called.
505
-     *
506
-     * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
507
-     *            ensure that there is no manipulation of the _data property during run time so there's a clear
508
-     *            expectation of what it is.
509
-     * @internal  Plugin authors, do not implement this method, it is subject to change.
510
-     * @return mixed
511
-     */
512
-    public function get_data()
513
-    {
514
-        return $this->_data;
515
-    }
516
-
517
-
518
-    /**
519
-     * used to set the $_with_messengers property. (this is a default, child classes SHOULD override)
520
-     *
521
-     * @see   property definition for description of setup.
522
-     * @since 4.5.0
523
-     * @abstract
524
-     * @return void
525
-     */
526
-    protected function _set_with_messengers()
527
-    {
528
-        $this->_with_messengers = array(
529
-            'email' => array('html'),
530
-        );
531
-    }
532
-
533
-
534
-    /**
535
-     * Return the value of the _with_messengers property
536
-     *
537
-     * @since 4.5.0
538
-     * @return array
539
-     */
540
-    public function with_messengers()
541
-    {
542
-        return apply_filters(
543
-            'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
544
-            $this->_with_messengers
545
-        );
546
-    }
547
-
548
-
549
-    /**
550
-     * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class
551
-     * callback function if that page is registered via the `_admin_registered_page` property set by the child class.
552
-     * *
553
-     *
554
-     * @param string $page       the slug of the EE admin page
555
-     * @param array  $messengers an array of active messenger objects
556
-     * @param string $action     the page action (to allow for more specific handling - i.e. edit vs. add pages)
557
-     * @param array  $extra      This is just an extra argument that can be used to pass additional data for setting up
558
-     *                           page content.
559
-     * @access public
560
-     * @return string
561
-     */
562
-    public function get_message_type_admin_page_content(
563
-        $page,
564
-        $action = null,
565
-        $extra = array(),
566
-        $messengers = array()
567
-    ) {
568
-        //we can also further refine the context by action (if present).
569
-        return $this->_get_admin_page_content($page, $action, $extra, $messengers);
570
-    }
571
-
572
-
573
-    /**
574
-     * @return array
575
-     */
576
-    public function get_contexts()
577
-    {
578
-        return $this->_contexts;
579
-    }
580
-
581
-
582
-    /**
583
-     * This just returns the context label for a given context (as set in $_context_label property)
584
-     *
585
-     * @access public
586
-     * @return array
587
-     */
588
-    public function get_context_label()
589
-    {
590
-        return $this->_context_label;
591
-    }
592
-
593
-
594
-    /**
595
-     * This just returns the (filtered) _master_templates property.
596
-     *
597
-     * @see property definition for documentation.
598
-     * @return array
599
-     */
600
-    public function get_master_templates()
601
-    {
602
-        //first class specific filter then filter that by the global filter.
603
-        $master_templates = apply_filters(
604
-            'FHEE__' . get_class($this) . '__get_master_templates',
605
-            $this->_master_templates
606
-        );
607
-        return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
608
-    }
609
-
610
-
611
-    /**
612
-     * Accepts an incoming data handler which contains data for processing, and returns an array of
613
-     * EE_Messages_Addressee objects.
614
-     *
615
-     * @param EE_Messages_incoming_data $data
616
-     * @param string                    $context Limit addressees to specific context.
617
-     * @return array   An array indexed by context where each context is an array of EE_Messages_Addressee objects for
618
-     *                                           that context
619
-     */
620
-    public function get_addressees(EE_Messages_incoming_data $data, $context = '')
621
-    {
622
-        //override _data
623
-        $this->_data       = $data;
624
-        $addressees        = array();
625
-        $original_contexts = $this->_contexts;
626
-        //if incoming context then limit to that context
627
-        if (! empty($context)) {
628
-            $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
629
-            if (! empty($cntxt)) {
630
-                $this->_contexts           = array();
631
-                $this->_contexts[$context] = $cntxt;
632
-            }
633
-        }
634
-        $this->_set_default_addressee_data();
635
-        if ($this->_process_data()) {
636
-            $addressees = $this->_addressees;
637
-        }
638
-
639
-        //reset contexts and addressees
640
-        $this->_contexts   = $original_contexts;
641
-        $this->_addressees = array();
642
-        return $addressees;
643
-    }
644
-
645
-
646
-    /**
647
-     * processes the data object so we get
648
-     *
649
-     * @throws EE_Error
650
-     * @return bool  true means data was processed successfully, false means not.
651
-     */
652
-    protected function _process_data()
653
-    {
654
-        //at a minimum, we NEED EE_Attendee objects.
655
-        if (empty($this->_data->attendees)) {
656
-            return false;  //there's no data to process!
657
-        }
658
-        // process addressees for each context.  Child classes will have to have methods for
659
-        // each context defined to handle the processing of the data object within them
660
-        foreach ($this->_contexts as $context => $details) {
661
-            $xpctd_method = '_' . $context . '_addressees';
662
-            if (! method_exists($this, $xpctd_method)) {
663
-                throw new EE_Error(
664
-                    sprintf(
665
-                        __(
666
-                            'The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present',
667
-                            'event_espresso'
668
-                        ),
669
-                        $this->label['singular'],
670
-                        $xpctd_method
671
-                    )
672
-                );
673
-            }
674
-            $this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
675
-        }
676
-        return true; //data was processed successfully.
677
-    }
678
-
679
-
680
-    /**
681
-     * sets the default_addressee_data property,
682
-     *
683
-     * @access private
684
-     * @return void
685
-     */
686
-    private function _set_default_addressee_data()
687
-    {
688
-        $this->_default_addressee_data = array(
689
-            'billing'                  => $this->_data->billing,
690
-            'taxes'                    => $this->_data->taxes,
691
-            'tax_line_items'           => $this->_data->tax_line_items,
692
-            'additional_line_items'    => $this->_data->additional_line_items,
693
-            'grand_total_line_item'    => $this->_data->grand_total_line_item,
694
-            'txn'                      => $this->_data->txn,
695
-            'payments'                 => $this->_data->payments,
696
-            'payment'                  => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment
697
-                ? $this->_data->payment
698
-                : null,
699
-            'reg_objs'                 => $this->_data->reg_objs,
700
-            'registrations'            => $this->_data->registrations,
701
-            'datetimes'                => $this->_data->datetimes,
702
-            'tickets'                  => $this->_data->tickets,
703
-            'line_items_with_children' => $this->_data->line_items_with_children,
704
-            'questions'                => $this->_data->questions,
705
-            'answers'                  => $this->_data->answers,
706
-            'txn_status'               => $this->_data->txn_status,
707
-            'total_ticket_count'       => $this->_data->total_ticket_count,
708
-        );
709
-        if (is_array($this->_data->primary_attendee_data)) {
710
-            $this->_default_addressee_data                    = array_merge(
711
-                $this->_default_addressee_data,
712
-                $this->_data->primary_attendee_data
713
-            );
714
-            $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
715
-            $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
716
-        }
717
-    }
718
-
719
-
720
-
721
-    /********************
21
+	/**
22
+	 * message type child classes will set what contexts are associated with the message type via this array.
23
+	 * format:
24
+	 * array(
25
+	 * 'context' => array(
26
+	 *        'label' => __('Context Label', 'event_espresso'),
27
+	 *        'description' => __('Context description (for help popups)', 'event_espresso')
28
+	 *    ));
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $_contexts = array();
33
+
34
+
35
+	/**
36
+	 * This property is used to define what the display label will be for contexts (eg. "Recipients", "Themes" etc.)
37
+	 * Format:
38
+	 * array( 'label' => 'something', 'plural' => 'somethings', 'description' => 'something' );
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected $_context_label;
43
+
44
+
45
+	/** MESSAGE ASSEMBLING PROPERTIES **/
46
+	/**
47
+	 * This parameter simply holds all the message objects for retrieval by the controller and sending to the messenger.
48
+	 *
49
+	 * @var array of message objects.
50
+	 */
51
+	public $messages = array();
52
+
53
+	/**
54
+	 * The following holds the templates that will be used to assemble the message object for the messenger.
55
+	 *
56
+	 * @var array
57
+	 */
58
+	protected $_templates;
59
+
60
+
61
+	/**
62
+	 * If a specific template is being parsed, this will hold the message template group GRP_ID for that template.
63
+	 *
64
+	 * @var int.
65
+	 */
66
+	protected $_GRP_ID;
67
+
68
+
69
+	/** OTHER INFO PROPERTIES **/
70
+	/**
71
+	 * This will hold the count of the message objects in the messages array. This could be used for determining if
72
+	 * batching/queueing is needed.
73
+	 *
74
+	 * @var int
75
+	 */
76
+	public $count = 0;
77
+
78
+
79
+	/**
80
+	 * This is set via the `do_messenger_hooks` method and contains the messenger being used to send the message of
81
+	 * this message type at time of sending.
82
+	 *
83
+	 * @var EE_messenger
84
+	 */
85
+	protected $_active_messenger;
86
+
87
+
88
+	/**
89
+	 * This will hold the shortcode_replace instance for handling replacement of shortcodes in the various templates
90
+	 *
91
+	 * @var object
92
+	 */
93
+	protected $_shortcode_replace;
94
+
95
+
96
+	/**
97
+	 * The purpose for this property is to simply allow message types to indicate if the message generated is intended
98
+	 * for only single context.  Child message types should redefine this variable (if necessary) in the
99
+	 * _set_data_Handler() method.
100
+	 *
101
+	 * @var boolean
102
+	 */
103
+	protected $_single_message = false;
104
+
105
+
106
+	/**
107
+	 * This will hold an array of specific reg_ids that are receiving messages.
108
+	 *
109
+	 * @since 4.7.x
110
+	 * @var array
111
+	 */
112
+	protected $_regs_for_sending = array();
113
+
114
+
115
+	/**
116
+	 * This holds the data passed to this class from the controller and also the final processed data.
117
+	 *
118
+	 * @var object
119
+	 */
120
+	protected $_data;
121
+
122
+
123
+	/**
124
+	 * this is just a flag indicating whether we're in preview mode or not.
125
+	 *
126
+	 * @var bool
127
+	 */
128
+	protected $_preview = false;
129
+
130
+
131
+	/**
132
+	 * This just holds defaults for addressee data that children merge with their data array setup
133
+	 *
134
+	 * @var array
135
+	 */
136
+	protected $_default_addressee_data;
137
+
138
+
139
+	/**
140
+	 * Child classes declare through this property what handler they want to use for the incoming data and this string
141
+	 * is used to instantiate the EE_Messages_incoming_data child class for that handler.
142
+	 *
143
+	 * @var string
144
+	 */
145
+	protected $_data_handler;
146
+
147
+
148
+	/**
149
+	 * This holds any specific fields for holding any settings related to a message type (if any needed)
150
+	 *
151
+	 * @var array
152
+	 */
153
+	protected $_admin_settings_fields = array();
154
+
155
+	/**
156
+	 * this property will hold any existing setting that may have been set in the admin.
157
+	 *
158
+	 * @var array
159
+	 */
160
+	protected $_existing_admin_settings = array();
161
+
162
+
163
+	/**
164
+	 * This is used to designate the generating and alternative sending messengers for a message type.  It is set via
165
+	 * set_with_messengers() on construct. Note, generating messenger also acts as a sending messenger for this message
166
+	 * type.  However ONLY the generating messengers are used for creating templates for this message type. Should be
167
+	 * in this format:
168
+	 * {
169
+	 *
170
+	 * @type string $generating_messenger the name of the generating messenger.  Generating
171
+	 *                                          messengers are used for generating templates,
172
+	 *                                          doing validation and defining valid shortcodes.
173
+	 *      {
174
+	 * @type string $sending_messenger    values are the name(s) for the sending
175
+	 *                                              messengers.  sending messengers are
176
+	 *                                              just valid delivery vehicles that will utilize
177
+	 *                                              the templates (and generated EE_message
178
+	 *                                              objects from the generating messengers).
179
+	 *      }
180
+	 * }
181
+	 * @since                             4.5.0
182
+	 * @var array
183
+	 */
184
+	protected $_with_messengers = array();
185
+
186
+
187
+	/**
188
+	 * This holds the addressees in an array indexed by context for later retrieval when assembling the message objects.
189
+	 *
190
+	 * @access protected
191
+	 * @var array
192
+	 */
193
+	protected $_addressees = array();
194
+
195
+
196
+	/**
197
+	 * This allows each message type to set what alternate messenger&message type combination can be used for fallback
198
+	 * default templates if there are no specific ones defined for this messenger and message type.  Should be in the
199
+	 * format:
200
+	 * array(
201
+	 *      'messenger' => 'message_type',
202
+	 *      'another_messenger' => another_message_type
203
+	 * );
204
+	 * This is set in the message type constructor.
205
+	 *
206
+	 * @var array
207
+	 */
208
+	protected $_master_templates = array();
209
+
210
+
211
+	/**
212
+	 * This holds whatever the set template pack is for a message template group when generating messages.
213
+	 *
214
+	 * @since 4.5.0
215
+	 * @var EE_Messages_Template_Pack
216
+	 */
217
+	protected $_template_pack;
218
+
219
+
220
+	/**
221
+	 * This holds whatever the set variation is for a message template group when generating messages.
222
+	 *
223
+	 * @since 4.5.0
224
+	 * @var string
225
+	 */
226
+	protected $_variation;
227
+
228
+
229
+	/**
230
+	 * EE_message_type constructor.
231
+	 */
232
+	public function __construct()
233
+	{
234
+		$this->_messages_item_type = 'message_type';
235
+		$this->_set_contexts();
236
+		$this->_set_with_messengers();
237
+		parent::__construct();
238
+	}
239
+
240
+
241
+	/**
242
+	 * This sets the data handler for the message type.  It must be used to define the _data_handler property.  It is
243
+	 * called when messages are setup.
244
+	 *
245
+	 * @abstract
246
+	 * @access protected
247
+	 * @return void
248
+	 */
249
+	abstract protected function _set_data_handler();
250
+
251
+
252
+	/**
253
+	 * This method should return a EE_Base_Class object (or array of EE_Base_Class objects) for the given context and
254
+	 * ID (which should be the primary key id for the base class).  Client code doesn't have to know what a message
255
+	 * type's data handler is.
256
+	 *
257
+	 * @since 4.5.0
258
+	 * @param string          $context      This should be a string matching a valid context for the message type.
259
+	 * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
260
+	 *                                      guessing a url).
261
+	 * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
262
+	 *                                      EE_Base_Class_Object
263
+	 * @return mixed ( EE_Base_Class||EE_Base_Class[] )
264
+	 */
265
+	abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
266
+
267
+
268
+	/**
269
+	 * _set_contexts
270
+	 * This sets up the contexts associated with the message_type
271
+	 *
272
+	 * @abstract
273
+	 * @access  protected
274
+	 * @return  void
275
+	 */
276
+	abstract protected function _set_contexts();
277
+
278
+
279
+	/**
280
+	 * This is used to get the "id" value fo the msg_trigger_url generated by get_url_trigger().
281
+	 * In most cases, child classes don't need anything, (hence the default of 0), however if there is a specific
282
+	 * EE_Base_Class that is required in generating a message for a message type recipient then the message
283
+	 * type should override this method and use the given params to generate the correct ID.
284
+	 *
285
+	 * @param string          $context      The message type context.
286
+	 * @param EE_Registration $registration Registration object
287
+	 * @deprecated 4.9.0
288
+	 * @return int
289
+	 */
290
+	protected function _get_id_for_msg_url($context, EE_Registration $registration)
291
+	{
292
+		return 0;
293
+	}
294
+
295
+
296
+	/**
297
+	 * This sets up any action/filter hooks this message type puts in place for a specific messenger.  Note that by
298
+	 * default this does nothing.  Child classes will need to override if they want to add specific hooks for a
299
+	 * messenger.
300
+	 *
301
+	 * @since 1.0.0
302
+	 * @return void
303
+	 */
304
+	protected function _do_messenger_hooks()
305
+	{
306
+		return;
307
+	}
308
+
309
+
310
+	/**
311
+	 * This is a public wrapper for the protected _do_messenger_hooks() method.
312
+	 * For backward compat reasons, this was done rather than making the protected method public.
313
+	 *
314
+	 * @param   EE_messenger $messenger This is used to set the $_active_messenger property, so message types are able
315
+	 *                                  to know what messenger is being used to send the message at the time of
316
+	 *                                  sending.
317
+	 * @since 4.9.0
318
+	 */
319
+	public function do_messenger_hooks($messenger = null)
320
+	{
321
+		$this->_active_messenger = $messenger;
322
+		$this->_do_messenger_hooks();
323
+	}
324
+
325
+
326
+	/**
327
+	 * This method returns whether this message type should always generate a new copy
328
+	 * when requested, or if links can be to the already generated copy.
329
+	 * Note: this does NOT affect viewing/resending already generated messages in the EE_Message list table.
330
+	 * Child classes should override this if different from the default of false.
331
+	 *
332
+	 * @return bool     false means can link to generated EE_Message.  true must regenerate.
333
+	 */
334
+	public function always_generate()
335
+	{
336
+		return false;
337
+	}
338
+
339
+
340
+	/**
341
+	 * Returns the priority for the message type.
342
+	 * Priorities are defined as constants on EEM_Message.  Currently there are three priorities:
343
+	 * - EEM_Message::priority_high
344
+	 * - EEM_Message::priority_medium
345
+	 * - EEM_Message::priority_low
346
+	 * Priority is used to determine the weight the message type is given when queuing for generation and/or sending.
347
+	 *
348
+	 * @see    EEM_Message for more phpdocs on priority.
349
+	 *         The default priority for all message_types is EEM_Message::priority_low.  Message Types wanting to give
350
+	 *         a higher priority must override this method. Also note, messengers are able to override priorities
351
+	 *         queuing instructions if their "send_now" flag is set to true. An example of this is the HTML messenger
352
+	 *         which displays things in the browser.
353
+	 * @since  4.9.0
354
+	 * @return int
355
+	 */
356
+	public function get_priority()
357
+	{
358
+		return EEM_Message::priority_low;
359
+	}
360
+
361
+
362
+	/**
363
+	 * This runs the _set_data_handler() method for message types and then returns what got set.
364
+	 *
365
+	 * @param mixed $data This sets the data property for the message type with the incoming data used for generating.
366
+	 * @return string (the reference for the data handler) (will be an empty string if could not be determined).
367
+	 */
368
+	public function get_data_handler($data)
369
+	{
370
+		$this->_data = $data;
371
+		$this->_set_data_handler();
372
+		return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this);
373
+	}
374
+
375
+
376
+	/**
377
+	 * This is called externally to reset the value of the $_data property for the message type.
378
+	 * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
379
+	 * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called
380
+	 * (and for back compat reasons). This particular method is used in
381
+	 * EE_Messages_Generator::_reset_current_properties to ensure that the internal _data on the message type is
382
+	 * cleaned before subsequent EE_Message generation in the same request.
383
+	 *
384
+	 * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
385
+	 *            ensure that there is no manipulation of the _data property during run time so there's a clear
386
+	 *            expectation of what it is.  Likely we need to ensure that _data is not persisted IN the message type
387
+	 *            at all.
388
+	 * @internal  Plugin authors, do not implement this method, it is subject to change.
389
+	 * @since     4.9
390
+	 */
391
+	public function reset_data()
392
+	{
393
+		$this->_data = null;
394
+	}
395
+
396
+
397
+	/**
398
+	 * This does some validation of incoming params gets the url trigger from the defined method in the specific child
399
+	 * class and then filters the results.
400
+	 *
401
+	 * @param string          $context           The message type context
402
+	 * @param string          $sending_messenger The sending messenger
403
+	 * @param EE_Registration $registration      Registration object
404
+	 * @throws EE_Error
405
+	 * @deprecated  4.9.0  Likely 4.9.10 or 4.10.0 will remove this method completely
406
+	 * @return string          generated url
407
+	 */
408
+	public function get_url_trigger($context, $sending_messenger, EE_Registration $registration)
409
+	{
410
+		//validate context
411
+		//valid context?
412
+		if (! isset($this->_contexts[$context])) {
413
+			throw new EE_Error(
414
+				sprintf(
415
+					__('The context %s is not a valid context for %s.', 'event_espresso'),
416
+					$context,
417
+					get_class($this)
418
+				)
419
+			);
420
+		}
421
+		//valid sending_messenger?
422
+		$not_valid_msgr = false;
423
+		foreach ($this->_with_messengers as $generating => $sendings) {
424
+			if (empty($sendings) || array_search($sending_messenger, $sendings) === false) {
425
+				$not_valid_msgr = true;
426
+			}
427
+		}
428
+		if ($not_valid_msgr) {
429
+			throw new EE_Error(
430
+				sprintf(
431
+					__(
432
+						'The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.',
433
+						'event_espresso'
434
+					),
435
+					$sending_messenger,
436
+					get_class($this)
437
+				)
438
+			);
439
+		}
440
+		return EEH_MSG_Template::generate_url_trigger(
441
+			$sending_messenger,
442
+			$this->_active_messenger->name,
443
+			$context,
444
+			$this->name,
445
+			$registration,
446
+			$this->_GRP_ID,
447
+			$this->_get_id_for_msg_url($context, $registration)
448
+		);
449
+	}
450
+
451
+
452
+	/**
453
+	 * Wrapper for _get_data_for_context() that handles some validation before calling the main class and also allows
454
+	 * for filtering. This is (currently) called by the EED_Messages module.
455
+	 *
456
+	 * @since 4.5.0
457
+	 * @throws EE_Error
458
+	 * @param string          $context      This should be a string matching a valid context for the message type.
459
+	 * @param EE_Registration $registration Need a registration to ensure that the data is valid (prevents people
460
+	 *                                      guessing a url).
461
+	 * @param int             $id           Optional. Integer corresponding to the value for the primary key of a
462
+	 *                                      EE_Base_Class_Object
463
+	 * @return mixed (EE_Base_Class||EE_Base_Class[])
464
+	 */
465
+	public function get_data_for_context($context, EE_Registration $registration, $id = 0)
466
+	{
467
+		//valid context?
468
+		if (! isset($this->_contexts[$context])) {
469
+			throw new EE_Error(
470
+				sprintf(
471
+					__('The context %s is not a valid context for %s.', 'event_espresso'),
472
+					$context,
473
+					get_class($this)
474
+				)
475
+			);
476
+		}
477
+		//get data and apply global and class specific filters on it.
478
+		$data = apply_filters(
479
+			'FHEE__EE_message_type__get_data_for_context__data',
480
+			$this->_get_data_for_context($context, $registration, $id),
481
+			$this
482
+		);
483
+		$data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
484
+		//if empty then something went wrong!
485
+		if (empty($data)) {
486
+			throw new EE_Error(
487
+				sprintf(
488
+					__(
489
+						'There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.',
490
+						'event_espresso'
491
+					),
492
+					$id,
493
+					$this->name
494
+				)
495
+			);
496
+		}
497
+		return $data;
498
+	}
499
+
500
+
501
+	/**
502
+	 * This returns the contents of the _data property.
503
+	 * Please note the value of the _data is highly volatile.  It was added as an interim measure ensuring
504
+	 * EE_Message_To_Generate objects have any changes to the _data property when `_set_data_handler` method is called.
505
+	 *
506
+	 * @todo      This needs refactored along with the whole _set_data_handler() method in EE_message_types. Need to
507
+	 *            ensure that there is no manipulation of the _data property during run time so there's a clear
508
+	 *            expectation of what it is.
509
+	 * @internal  Plugin authors, do not implement this method, it is subject to change.
510
+	 * @return mixed
511
+	 */
512
+	public function get_data()
513
+	{
514
+		return $this->_data;
515
+	}
516
+
517
+
518
+	/**
519
+	 * used to set the $_with_messengers property. (this is a default, child classes SHOULD override)
520
+	 *
521
+	 * @see   property definition for description of setup.
522
+	 * @since 4.5.0
523
+	 * @abstract
524
+	 * @return void
525
+	 */
526
+	protected function _set_with_messengers()
527
+	{
528
+		$this->_with_messengers = array(
529
+			'email' => array('html'),
530
+		);
531
+	}
532
+
533
+
534
+	/**
535
+	 * Return the value of the _with_messengers property
536
+	 *
537
+	 * @since 4.5.0
538
+	 * @return array
539
+	 */
540
+	public function with_messengers()
541
+	{
542
+		return apply_filters(
543
+			'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
544
+			$this->_with_messengers
545
+		);
546
+	}
547
+
548
+
549
+	/**
550
+	 * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class
551
+	 * callback function if that page is registered via the `_admin_registered_page` property set by the child class.
552
+	 * *
553
+	 *
554
+	 * @param string $page       the slug of the EE admin page
555
+	 * @param array  $messengers an array of active messenger objects
556
+	 * @param string $action     the page action (to allow for more specific handling - i.e. edit vs. add pages)
557
+	 * @param array  $extra      This is just an extra argument that can be used to pass additional data for setting up
558
+	 *                           page content.
559
+	 * @access public
560
+	 * @return string
561
+	 */
562
+	public function get_message_type_admin_page_content(
563
+		$page,
564
+		$action = null,
565
+		$extra = array(),
566
+		$messengers = array()
567
+	) {
568
+		//we can also further refine the context by action (if present).
569
+		return $this->_get_admin_page_content($page, $action, $extra, $messengers);
570
+	}
571
+
572
+
573
+	/**
574
+	 * @return array
575
+	 */
576
+	public function get_contexts()
577
+	{
578
+		return $this->_contexts;
579
+	}
580
+
581
+
582
+	/**
583
+	 * This just returns the context label for a given context (as set in $_context_label property)
584
+	 *
585
+	 * @access public
586
+	 * @return array
587
+	 */
588
+	public function get_context_label()
589
+	{
590
+		return $this->_context_label;
591
+	}
592
+
593
+
594
+	/**
595
+	 * This just returns the (filtered) _master_templates property.
596
+	 *
597
+	 * @see property definition for documentation.
598
+	 * @return array
599
+	 */
600
+	public function get_master_templates()
601
+	{
602
+		//first class specific filter then filter that by the global filter.
603
+		$master_templates = apply_filters(
604
+			'FHEE__' . get_class($this) . '__get_master_templates',
605
+			$this->_master_templates
606
+		);
607
+		return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
608
+	}
609
+
610
+
611
+	/**
612
+	 * Accepts an incoming data handler which contains data for processing, and returns an array of
613
+	 * EE_Messages_Addressee objects.
614
+	 *
615
+	 * @param EE_Messages_incoming_data $data
616
+	 * @param string                    $context Limit addressees to specific context.
617
+	 * @return array   An array indexed by context where each context is an array of EE_Messages_Addressee objects for
618
+	 *                                           that context
619
+	 */
620
+	public function get_addressees(EE_Messages_incoming_data $data, $context = '')
621
+	{
622
+		//override _data
623
+		$this->_data       = $data;
624
+		$addressees        = array();
625
+		$original_contexts = $this->_contexts;
626
+		//if incoming context then limit to that context
627
+		if (! empty($context)) {
628
+			$cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
629
+			if (! empty($cntxt)) {
630
+				$this->_contexts           = array();
631
+				$this->_contexts[$context] = $cntxt;
632
+			}
633
+		}
634
+		$this->_set_default_addressee_data();
635
+		if ($this->_process_data()) {
636
+			$addressees = $this->_addressees;
637
+		}
638
+
639
+		//reset contexts and addressees
640
+		$this->_contexts   = $original_contexts;
641
+		$this->_addressees = array();
642
+		return $addressees;
643
+	}
644
+
645
+
646
+	/**
647
+	 * processes the data object so we get
648
+	 *
649
+	 * @throws EE_Error
650
+	 * @return bool  true means data was processed successfully, false means not.
651
+	 */
652
+	protected function _process_data()
653
+	{
654
+		//at a minimum, we NEED EE_Attendee objects.
655
+		if (empty($this->_data->attendees)) {
656
+			return false;  //there's no data to process!
657
+		}
658
+		// process addressees for each context.  Child classes will have to have methods for
659
+		// each context defined to handle the processing of the data object within them
660
+		foreach ($this->_contexts as $context => $details) {
661
+			$xpctd_method = '_' . $context . '_addressees';
662
+			if (! method_exists($this, $xpctd_method)) {
663
+				throw new EE_Error(
664
+					sprintf(
665
+						__(
666
+							'The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present',
667
+							'event_espresso'
668
+						),
669
+						$this->label['singular'],
670
+						$xpctd_method
671
+					)
672
+				);
673
+			}
674
+			$this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
675
+		}
676
+		return true; //data was processed successfully.
677
+	}
678
+
679
+
680
+	/**
681
+	 * sets the default_addressee_data property,
682
+	 *
683
+	 * @access private
684
+	 * @return void
685
+	 */
686
+	private function _set_default_addressee_data()
687
+	{
688
+		$this->_default_addressee_data = array(
689
+			'billing'                  => $this->_data->billing,
690
+			'taxes'                    => $this->_data->taxes,
691
+			'tax_line_items'           => $this->_data->tax_line_items,
692
+			'additional_line_items'    => $this->_data->additional_line_items,
693
+			'grand_total_line_item'    => $this->_data->grand_total_line_item,
694
+			'txn'                      => $this->_data->txn,
695
+			'payments'                 => $this->_data->payments,
696
+			'payment'                  => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment
697
+				? $this->_data->payment
698
+				: null,
699
+			'reg_objs'                 => $this->_data->reg_objs,
700
+			'registrations'            => $this->_data->registrations,
701
+			'datetimes'                => $this->_data->datetimes,
702
+			'tickets'                  => $this->_data->tickets,
703
+			'line_items_with_children' => $this->_data->line_items_with_children,
704
+			'questions'                => $this->_data->questions,
705
+			'answers'                  => $this->_data->answers,
706
+			'txn_status'               => $this->_data->txn_status,
707
+			'total_ticket_count'       => $this->_data->total_ticket_count,
708
+		);
709
+		if (is_array($this->_data->primary_attendee_data)) {
710
+			$this->_default_addressee_data                    = array_merge(
711
+				$this->_default_addressee_data,
712
+				$this->_data->primary_attendee_data
713
+			);
714
+			$this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
715
+			$this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
716
+		}
717
+	}
718
+
719
+
720
+
721
+	/********************
722 722
      * setup default shared addressee object/contexts
723 723
      * These can be utilized simply by defining the context in the child message type.
724 724
      * They can also be overridden if a specific message type needs to do something different for that context.
725 725
      ****************/
726
-    /**
727
-     * see abstract declaration in parent class for details, children message types can
728
-     * override these valid shortcodes if desired (we include all for all contexts by default).
729
-     */
730
-    protected function _set_valid_shortcodes()
731
-    {
732
-        $all_shortcodes = array(
733
-            'attendee_list',
734
-            'attendee',
735
-            'datetime_list',
736
-            'datetime',
737
-            'event_list',
738
-            'event_meta',
739
-            'event',
740
-            'organization',
741
-            'recipient_details',
742
-            'recipient_list',
743
-            'ticket_list',
744
-            'ticket',
745
-            'transaction',
746
-            'venue',
747
-            'primary_registration_details',
748
-            'primary_registration_list',
749
-            'event_author',
750
-            'email',
751
-            'messenger',
752
-        );
753
-        $contexts       = $this->get_contexts();
754
-        foreach ($contexts as $context => $details) {
755
-            $this->_valid_shortcodes[$context] = $all_shortcodes;
756
-            //make sure non admin context does not include the event_author shortcodes
757
-            if ($context != 'admin') {
758
-                if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
759
-                    unset($this->_valid_shortcodes[$context][$key]);
760
-                }
761
-            }
762
-        }
763
-        // make sure admin context does not include the recipient_details shortcodes
764
-        // IF we have admin context hooked in message types might not have that context.
765
-        if (! empty($this->_valid_shortcodes['admin'])) {
766
-            if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
767
-                unset($this->_valid_shortcodes['admin'][$key]);
768
-            }
769
-            //make sure admin context does not include the recipient_details shortcodes
770
-            if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
771
-                unset($this->_valid_shortcodes['admin'][$key]);
772
-            }
773
-        }
774
-    }
775
-
776
-
777
-    /**
778
-     * Used by Validators to modify the valid shortcodes.
779
-     *
780
-     * @param  array $new_config array of valid shortcodes (by context)
781
-     * @return void               sets valid_shortcodes property
782
-     */
783
-    public function reset_valid_shortcodes_config($new_config)
784
-    {
785
-        foreach ($new_config as $context => $shortcodes) {
786
-            $this->_valid_shortcodes[$context] = $shortcodes;
787
-        }
788
-    }
789
-
790
-
791
-    /**
792
-     * returns an array of addressee objects for event_admins
793
-     *
794
-     * @access protected
795
-     * @return array array of EE_Messages_Addressee objects
796
-     */
797
-    protected function _admin_addressees()
798
-    {
799
-        $admin_events = array();
800
-        $addressees   = array();
801
-        // first we need to get the event admin user id for all the events
802
-        // and setup an addressee object for each unique admin user.
803
-        foreach ($this->_data->events as $line_ref => $event) {
804
-            $admin_id = $this->_get_event_admin_id($event['ID']);
805
-            //make sure we are just including the events that belong to this admin!
806
-            $admin_events[$admin_id][$line_ref] = $event;
807
-        }
808
-        //k now we can loop through the event_admins and setup the addressee data.
809
-        foreach ($admin_events as $admin_id => $event_details) {
810
-            $aee          = array(
811
-                'user_id'        => $admin_id,
812
-                'events'         => $event_details,
813
-                'attendees'      => $this->_data->attendees,
814
-                'recipient_id'   => $admin_id,
815
-                'recipient_type' => 'WP_User',
816
-            );
817
-            $aee          = array_merge($this->_default_addressee_data, $aee);
818
-            $addressees[] = new EE_Messages_Addressee($aee);
819
-        }
820
-        return $addressees;
821
-    }
822
-
823
-
824
-    /**
825
-     * Takes care of setting up the addressee object(s) for the primary attendee.
826
-     *
827
-     * @access protected
828
-     * @return array of EE_Addressee objects
829
-     */
830
-    protected function _primary_attendee_addressees()
831
-    {
832
-        $aee                   = $this->_default_addressee_data;
833
-        $aee['events']         = $this->_data->events;
834
-        $aee['attendees']      = $this->_data->attendees;
835
-        $aee['recipient_id']   = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0;
836
-        $aee['recipient_type'] = 'Attendee';
837
-        //great now we can instantiate the $addressee object and return (as an array);
838
-        $add[] = new EE_Messages_Addressee($aee);
839
-        return $add;
840
-    }
841
-
842
-
843
-    /**
844
-     * Takes care of setting up the addressee object(s) for the registered attendees
845
-     *
846
-     * @access protected
847
-     * @return array of EE_Addressee objects
848
-     */
849
-    protected function _attendee_addressees()
850
-    {
851
-        $add = array();
852
-        //we just have to loop through the attendees.  We'll also set the attached events for each attendee.
853
-        //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
854
-        $already_processed = array();
855
-        foreach ($this->_data->attendees as $att_id => $details) {
856
-            //set the attendee array to blank on each loop;
857
-            $aee = array();
858
-            if (isset($this->_data->reg_obj)
859
-                && ($this->_data->reg_obj->attendee_ID() != $att_id)
860
-                && $this->_single_message
861
-            ) {
862
-                continue;
863
-            }
864
-            // is $this->_regs_for_sending present?
865
-            // If so, let's make sure we ONLY generate addressee for registrations in that array.
866
-            if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
867
-                $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
868
-                if (empty($regs_allowed)) {
869
-                    continue;
870
-                }
871
-            }
872
-            if (
873
-                in_array($details['attendee_email'], $already_processed)
874
-                && apply_filters(
875
-                    'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends',
876
-                    true,
877
-                    $this->_data,
878
-                    $this
879
-                )
880
-            ) {
881
-                continue;
882
-            }
883
-            $already_processed[] = $details['attendee_email'];
884
-            foreach ($details as $item => $value) {
885
-                $aee[$item] = $value;
886
-                if ($item == 'line_ref') {
887
-                    foreach ($value as $event_id) {
888
-                        $aee['events'][$event_id] = $this->_data->events[$event_id];
889
-                    }
890
-                }
891
-                if ($item == 'attendee_email') {
892
-                    $aee['attendee_email'] = $value;
893
-                }
894
-                /*if ( $item == 'registration_id' ) {
726
+	/**
727
+	 * see abstract declaration in parent class for details, children message types can
728
+	 * override these valid shortcodes if desired (we include all for all contexts by default).
729
+	 */
730
+	protected function _set_valid_shortcodes()
731
+	{
732
+		$all_shortcodes = array(
733
+			'attendee_list',
734
+			'attendee',
735
+			'datetime_list',
736
+			'datetime',
737
+			'event_list',
738
+			'event_meta',
739
+			'event',
740
+			'organization',
741
+			'recipient_details',
742
+			'recipient_list',
743
+			'ticket_list',
744
+			'ticket',
745
+			'transaction',
746
+			'venue',
747
+			'primary_registration_details',
748
+			'primary_registration_list',
749
+			'event_author',
750
+			'email',
751
+			'messenger',
752
+		);
753
+		$contexts       = $this->get_contexts();
754
+		foreach ($contexts as $context => $details) {
755
+			$this->_valid_shortcodes[$context] = $all_shortcodes;
756
+			//make sure non admin context does not include the event_author shortcodes
757
+			if ($context != 'admin') {
758
+				if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
759
+					unset($this->_valid_shortcodes[$context][$key]);
760
+				}
761
+			}
762
+		}
763
+		// make sure admin context does not include the recipient_details shortcodes
764
+		// IF we have admin context hooked in message types might not have that context.
765
+		if (! empty($this->_valid_shortcodes['admin'])) {
766
+			if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
767
+				unset($this->_valid_shortcodes['admin'][$key]);
768
+			}
769
+			//make sure admin context does not include the recipient_details shortcodes
770
+			if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
771
+				unset($this->_valid_shortcodes['admin'][$key]);
772
+			}
773
+		}
774
+	}
775
+
776
+
777
+	/**
778
+	 * Used by Validators to modify the valid shortcodes.
779
+	 *
780
+	 * @param  array $new_config array of valid shortcodes (by context)
781
+	 * @return void               sets valid_shortcodes property
782
+	 */
783
+	public function reset_valid_shortcodes_config($new_config)
784
+	{
785
+		foreach ($new_config as $context => $shortcodes) {
786
+			$this->_valid_shortcodes[$context] = $shortcodes;
787
+		}
788
+	}
789
+
790
+
791
+	/**
792
+	 * returns an array of addressee objects for event_admins
793
+	 *
794
+	 * @access protected
795
+	 * @return array array of EE_Messages_Addressee objects
796
+	 */
797
+	protected function _admin_addressees()
798
+	{
799
+		$admin_events = array();
800
+		$addressees   = array();
801
+		// first we need to get the event admin user id for all the events
802
+		// and setup an addressee object for each unique admin user.
803
+		foreach ($this->_data->events as $line_ref => $event) {
804
+			$admin_id = $this->_get_event_admin_id($event['ID']);
805
+			//make sure we are just including the events that belong to this admin!
806
+			$admin_events[$admin_id][$line_ref] = $event;
807
+		}
808
+		//k now we can loop through the event_admins and setup the addressee data.
809
+		foreach ($admin_events as $admin_id => $event_details) {
810
+			$aee          = array(
811
+				'user_id'        => $admin_id,
812
+				'events'         => $event_details,
813
+				'attendees'      => $this->_data->attendees,
814
+				'recipient_id'   => $admin_id,
815
+				'recipient_type' => 'WP_User',
816
+			);
817
+			$aee          = array_merge($this->_default_addressee_data, $aee);
818
+			$addressees[] = new EE_Messages_Addressee($aee);
819
+		}
820
+		return $addressees;
821
+	}
822
+
823
+
824
+	/**
825
+	 * Takes care of setting up the addressee object(s) for the primary attendee.
826
+	 *
827
+	 * @access protected
828
+	 * @return array of EE_Addressee objects
829
+	 */
830
+	protected function _primary_attendee_addressees()
831
+	{
832
+		$aee                   = $this->_default_addressee_data;
833
+		$aee['events']         = $this->_data->events;
834
+		$aee['attendees']      = $this->_data->attendees;
835
+		$aee['recipient_id']   = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0;
836
+		$aee['recipient_type'] = 'Attendee';
837
+		//great now we can instantiate the $addressee object and return (as an array);
838
+		$add[] = new EE_Messages_Addressee($aee);
839
+		return $add;
840
+	}
841
+
842
+
843
+	/**
844
+	 * Takes care of setting up the addressee object(s) for the registered attendees
845
+	 *
846
+	 * @access protected
847
+	 * @return array of EE_Addressee objects
848
+	 */
849
+	protected function _attendee_addressees()
850
+	{
851
+		$add = array();
852
+		//we just have to loop through the attendees.  We'll also set the attached events for each attendee.
853
+		//use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
854
+		$already_processed = array();
855
+		foreach ($this->_data->attendees as $att_id => $details) {
856
+			//set the attendee array to blank on each loop;
857
+			$aee = array();
858
+			if (isset($this->_data->reg_obj)
859
+				&& ($this->_data->reg_obj->attendee_ID() != $att_id)
860
+				&& $this->_single_message
861
+			) {
862
+				continue;
863
+			}
864
+			// is $this->_regs_for_sending present?
865
+			// If so, let's make sure we ONLY generate addressee for registrations in that array.
866
+			if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
867
+				$regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
868
+				if (empty($regs_allowed)) {
869
+					continue;
870
+				}
871
+			}
872
+			if (
873
+				in_array($details['attendee_email'], $already_processed)
874
+				&& apply_filters(
875
+					'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends',
876
+					true,
877
+					$this->_data,
878
+					$this
879
+				)
880
+			) {
881
+				continue;
882
+			}
883
+			$already_processed[] = $details['attendee_email'];
884
+			foreach ($details as $item => $value) {
885
+				$aee[$item] = $value;
886
+				if ($item == 'line_ref') {
887
+					foreach ($value as $event_id) {
888
+						$aee['events'][$event_id] = $this->_data->events[$event_id];
889
+					}
890
+				}
891
+				if ($item == 'attendee_email') {
892
+					$aee['attendee_email'] = $value;
893
+				}
894
+				/*if ( $item == 'registration_id' ) {
895 895
                     $aee['attendee_registration_id'] = $value;
896 896
                 }/**/
897
-            }
898
-            // note the FIRST reg object in this array is the one
899
-            // we'll use for this attendee as the primary registration for this attendee.
900
-            $aee['reg_obj']        = reset($this->_data->attendees[$att_id]['reg_objs']);
901
-            $aee['attendees']      = $this->_data->attendees;
902
-            $aee['recipient_id']   = $att_id;
903
-            $aee['recipient_type'] = 'Attendee';
904
-            //merge in the primary attendee data
905
-            $aee   = array_merge($this->_default_addressee_data, $aee);
906
-            $add[] = new EE_Messages_Addressee($aee);
907
-        }
908
-        return $add;
909
-    }
910
-
911
-
912
-    /**
913
-     * @param $event_id
914
-     * @return int
915
-     */
916
-    protected function _get_event_admin_id($event_id)
917
-    {
918
-        $event = EEM_Event::instance()->get_one_by_ID($event_id);
919
-        return $event instanceof EE_Event ? $event->wp_user() : 0;
920
-    }
897
+			}
898
+			// note the FIRST reg object in this array is the one
899
+			// we'll use for this attendee as the primary registration for this attendee.
900
+			$aee['reg_obj']        = reset($this->_data->attendees[$att_id]['reg_objs']);
901
+			$aee['attendees']      = $this->_data->attendees;
902
+			$aee['recipient_id']   = $att_id;
903
+			$aee['recipient_type'] = 'Attendee';
904
+			//merge in the primary attendee data
905
+			$aee   = array_merge($this->_default_addressee_data, $aee);
906
+			$add[] = new EE_Messages_Addressee($aee);
907
+		}
908
+		return $add;
909
+	}
910
+
911
+
912
+	/**
913
+	 * @param $event_id
914
+	 * @return int
915
+	 */
916
+	protected function _get_event_admin_id($event_id)
917
+	{
918
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
919
+		return $event instanceof EE_Event ? $event->wp_user() : 0;
920
+	}
921 921
 
922 922
 
923 923
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     {
410 410
         //validate context
411 411
         //valid context?
412
-        if (! isset($this->_contexts[$context])) {
412
+        if ( ! isset($this->_contexts[$context])) {
413 413
             throw new EE_Error(
414 414
                 sprintf(
415 415
                     __('The context %s is not a valid context for %s.', 'event_espresso'),
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     public function get_data_for_context($context, EE_Registration $registration, $id = 0)
466 466
     {
467 467
         //valid context?
468
-        if (! isset($this->_contexts[$context])) {
468
+        if ( ! isset($this->_contexts[$context])) {
469 469
             throw new EE_Error(
470 470
                 sprintf(
471 471
                     __('The context %s is not a valid context for %s.', 'event_espresso'),
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
             $this->_get_data_for_context($context, $registration, $id),
481 481
             $this
482 482
         );
483
-        $data = apply_filters('FHEE__' . get_class($this) . '__get_data_for_context__data', $data, $this);
483
+        $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this);
484 484
         //if empty then something went wrong!
485 485
         if (empty($data)) {
486 486
             throw new EE_Error(
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     public function with_messengers()
541 541
     {
542 542
         return apply_filters(
543
-            'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class($this),
543
+            'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this),
544 544
             $this->_with_messengers
545 545
         );
546 546
     }
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
     {
602 602
         //first class specific filter then filter that by the global filter.
603 603
         $master_templates = apply_filters(
604
-            'FHEE__' . get_class($this) . '__get_master_templates',
604
+            'FHEE__'.get_class($this).'__get_master_templates',
605 605
             $this->_master_templates
606 606
         );
607 607
         return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
@@ -624,9 +624,9 @@  discard block
 block discarded – undo
624 624
         $addressees        = array();
625 625
         $original_contexts = $this->_contexts;
626 626
         //if incoming context then limit to that context
627
-        if (! empty($context)) {
627
+        if ( ! empty($context)) {
628 628
             $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
629
-            if (! empty($cntxt)) {
629
+            if ( ! empty($cntxt)) {
630 630
                 $this->_contexts           = array();
631 631
                 $this->_contexts[$context] = $cntxt;
632 632
             }
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
     {
654 654
         //at a minimum, we NEED EE_Attendee objects.
655 655
         if (empty($this->_data->attendees)) {
656
-            return false;  //there's no data to process!
656
+            return false; //there's no data to process!
657 657
         }
658 658
         // process addressees for each context.  Child classes will have to have methods for
659 659
         // each context defined to handle the processing of the data object within them
660 660
         foreach ($this->_contexts as $context => $details) {
661
-            $xpctd_method = '_' . $context . '_addressees';
662
-            if (! method_exists($this, $xpctd_method)) {
661
+            $xpctd_method = '_'.$context.'_addressees';
662
+            if ( ! method_exists($this, $xpctd_method)) {
663 663
                 throw new EE_Error(
664 664
                     sprintf(
665 665
                         __(
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
             'total_ticket_count'       => $this->_data->total_ticket_count,
708 708
         );
709 709
         if (is_array($this->_data->primary_attendee_data)) {
710
-            $this->_default_addressee_data                    = array_merge(
710
+            $this->_default_addressee_data = array_merge(
711 711
                 $this->_default_addressee_data,
712 712
                 $this->_data->primary_attendee_data
713 713
             );
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
             'email',
751 751
             'messenger',
752 752
         );
753
-        $contexts       = $this->get_contexts();
753
+        $contexts = $this->get_contexts();
754 754
         foreach ($contexts as $context => $details) {
755 755
             $this->_valid_shortcodes[$context] = $all_shortcodes;
756 756
             //make sure non admin context does not include the event_author shortcodes
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         }
763 763
         // make sure admin context does not include the recipient_details shortcodes
764 764
         // IF we have admin context hooked in message types might not have that context.
765
-        if (! empty($this->_valid_shortcodes['admin'])) {
765
+        if ( ! empty($this->_valid_shortcodes['admin'])) {
766 766
             if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
767 767
                 unset($this->_valid_shortcodes['admin'][$key]);
768 768
             }
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
         }
808 808
         //k now we can loop through the event_admins and setup the addressee data.
809 809
         foreach ($admin_events as $admin_id => $event_details) {
810
-            $aee          = array(
810
+            $aee = array(
811 811
                 'user_id'        => $admin_id,
812 812
                 'events'         => $event_details,
813 813
                 'attendees'      => $this->_data->attendees,
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
             }
864 864
             // is $this->_regs_for_sending present?
865 865
             // If so, let's make sure we ONLY generate addressee for registrations in that array.
866
-            if (! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
866
+            if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
867 867
                 $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
868 868
                 if (empty($regs_allowed)) {
869 869
                     continue;
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php 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
-                ); ?>
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
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
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', '5.3.9');
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
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.027');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.027');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.