Completed
Branch fix/escaping-2 (5dcb9a)
by
unknown
13:02 queued 10:26
created
messages/defaults/default/html_receipt_ticket_line_item_pms.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 <tr class="item">
9 9
     <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td>
10 10
     <td colspan="2">[LINE_ITEM_DESCRIPTION]
11
-        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . esc_html__('any', 'event_espresso') . ']'); ?></p>
11
+        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.esc_html__('any', 'event_espresso').']'); ?></p>
12 12
     </td>
13 13
     <td class="item_c">[LINE_ITEM_QUANTITY]</td>
14 14
     <td class="item_c">[LINE_ITEM_AMOUNT]</td>
Please login to merge, or discard this patch.
core/libraries/messages/defaults/EE_Messages_Template_Pack.core.php 2 patches
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -14,511 +14,511 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * This defines the base_path where the templates are located.
19
-     *
20
-     * @since            4.5.0
21
-     *
22
-     * @var string
23
-     */
24
-    protected $_base_path;
17
+	/**
18
+	 * This defines the base_path where the templates are located.
19
+	 *
20
+	 * @since            4.5.0
21
+	 *
22
+	 * @var string
23
+	 */
24
+	protected $_base_path;
25 25
 
26 26
 
27 27
 
28 28
 
29
-    /**
30
-     * This defines the base_url where things are found for this template pack (possibly variations).
31
-     *
32
-     * @since 4.5.0
33
-     *
34
-     * @var string
35
-     */
36
-    protected $_base_url;
29
+	/**
30
+	 * This defines the base_url where things are found for this template pack (possibly variations).
31
+	 *
32
+	 * @since 4.5.0
33
+	 *
34
+	 * @var string
35
+	 */
36
+	protected $_base_url;
37 37
 
38 38
 
39 39
 
40
-    /**
41
-     * localized label for this template pack
42
-     *
43
-     * @since            4.5.0
44
-     *
45
-     * @var string
46
-     */
47
-    public $label;
40
+	/**
41
+	 * localized label for this template pack
42
+	 *
43
+	 * @since            4.5.0
44
+	 *
45
+	 * @var string
46
+	 */
47
+	public $label;
48 48
 
49 49
 
50 50
 
51 51
 
52
-    /**
53
-     * used to contain a description for the template pack.
54
-     *
55
-     * @since 4.5.0
56
-     *
57
-     * @var string
58
-     */
59
-    public $description;
52
+	/**
53
+	 * used to contain a description for the template pack.
54
+	 *
55
+	 * @since 4.5.0
56
+	 *
57
+	 * @var string
58
+	 */
59
+	public $description;
60 60
 
61 61
 
62 62
 
63 63
 
64
-    /**
65
-     * How this template is referenced in the db
66
-     *
67
-     * @since 4.5.0
68
-     *
69
-     * @var string
70
-     */
71
-    public $dbref;
64
+	/**
65
+	 * How this template is referenced in the db
66
+	 *
67
+	 * @since 4.5.0
68
+	 *
69
+	 * @var string
70
+	 */
71
+	public $dbref;
72 72
 
73 73
 
74 74
 
75 75
 
76
-    /**
77
-     * This is an array indexed by messenger and with an array of message types as values that indicate what messenger and message type this template pack supports by default.  It is possible for this to be modified by plugins via filters, but out of the box, this is what the template pack supports.
78
-     *
79
-     * @since 4.5.0
80
-     *
81
-     * @var array.
82
-     */
83
-    protected $_supports = array();
76
+	/**
77
+	 * This is an array indexed by messenger and with an array of message types as values that indicate what messenger and message type this template pack supports by default.  It is possible for this to be modified by plugins via filters, but out of the box, this is what the template pack supports.
78
+	 *
79
+	 * @since 4.5.0
80
+	 *
81
+	 * @var array.
82
+	 */
83
+	protected $_supports = array();
84 84
 
85 85
 
86 86
 
87 87
 
88 88
 
89
-    /**
90
-     * Holds the retrieved default templates for this template pack in a multidimensional array indexed by context and field, for a given messenger and message type.  Example format:
91
-     *
92
-     * $templates = array(
93
-     *  'email' => array(
94
-     *      'registration' => array(
95
-     *          'admin' => array(
96
-     *              'to' => 'contents',
97
-     *              'from' => 'contents',
98
-     *              'subject' => 'contents',
99
-     *              'content' => 'contents',
100
-     *              'event_list' => 'contents',
101
-     *              'attendee_list' => 'contents'
102
-     *          ),
103
-     *          'attendee' => array(
104
-     *              'to' => 'contents',
105
-     *              'from' => 'contents',
106
-     *              'subject' => 'contents',
107
-     *              'content' => 'contents',
108
-     *              'event_list' => 'contents',
109
-     *              'attendee_list' => 'contents',
110
-     *          ),
111
-     *      )
112
-     *  )
113
-     * )
114
-     *
115
-     * @since 4.5.0
116
-     *
117
-     * @var array
118
-     */
119
-    protected $_templates = array();
89
+	/**
90
+	 * Holds the retrieved default templates for this template pack in a multidimensional array indexed by context and field, for a given messenger and message type.  Example format:
91
+	 *
92
+	 * $templates = array(
93
+	 *  'email' => array(
94
+	 *      'registration' => array(
95
+	 *          'admin' => array(
96
+	 *              'to' => 'contents',
97
+	 *              'from' => 'contents',
98
+	 *              'subject' => 'contents',
99
+	 *              'content' => 'contents',
100
+	 *              'event_list' => 'contents',
101
+	 *              'attendee_list' => 'contents'
102
+	 *          ),
103
+	 *          'attendee' => array(
104
+	 *              'to' => 'contents',
105
+	 *              'from' => 'contents',
106
+	 *              'subject' => 'contents',
107
+	 *              'content' => 'contents',
108
+	 *              'event_list' => 'contents',
109
+	 *              'attendee_list' => 'contents',
110
+	 *          ),
111
+	 *      )
112
+	 *  )
113
+	 * )
114
+	 *
115
+	 * @since 4.5.0
116
+	 *
117
+	 * @var array
118
+	 */
119
+	protected $_templates = array();
120 120
 
121 121
 
122 122
 
123 123
 
124 124
 
125 125
 
126
-    /**
127
-     * Template Packs must ALWAYS have a default variation defined.  This property allow one to override the default variation labels per messenger.
128
-     * example:
129
-     * $this->_default_variation_labels = array( 'email' =>  esc_html__('Default', 'event_espresso' ) );
130
-     *
131
-     * @var array
132
-     */
133
-    protected $_default_variation_labels = array();
126
+	/**
127
+	 * Template Packs must ALWAYS have a default variation defined.  This property allow one to override the default variation labels per messenger.
128
+	 * example:
129
+	 * $this->_default_variation_labels = array( 'email' =>  esc_html__('Default', 'event_espresso' ) );
130
+	 *
131
+	 * @var array
132
+	 */
133
+	protected $_default_variation_labels = array();
134 134
 
135 135
 
136 136
 
137 137
 
138
-    /**
139
-     * This is an array of extra css variations for message templates indexed by messenger with the values as an array or message types the variations apply to as the key  and then values are an array with variation slugs as the key and label as the value. Note the default variation is not included in this array.  So the structure is:
140
-     * array(
141
-     *  'email' => array(
142
-     *  )
143
-     * )
144
-     *
145
-     * Keep in mind that this property is used both for indicating valid variations for a given message type and messenger but the variation files themselves are ONLY unique to the messenger.  So if you have a variation for the html messenger referenced by the slug "sunset_red" Then the variation file for the main type will be html_main_sunset_red.css.  All the array in this property allows you to do, is indicate that with certain message types the sunset_red variation is available but for other message types its not.  But you could NOT have a sunset_red variation file for one messenger/message_type and a different one for another messenger/message_type.  If you want different css looks then you can define a different structural layout for the template , messenger, message type combination and in the same sunset_red.css variation file just add css specific to that layout.
146
-     *
147
-     * @since 4.5.0
148
-     *
149
-     * @var array
150
-     */
151
-    public $_variations = array();
152
-
153
-
154
-
155
-
156
-    /**
157
-     * Template pack constructor
158
-     *
159
-     * @since 4.5.0
160
-     */
161
-    public function __construct()
162
-    {
163
-        $this->_set_props();
164
-        // make sure classname is correct
165
-        $classname = get_class($this);
166
-        // make sure required props have been set
167
-
168
-        // if label is empty then throw an error because we should have it defined by now.
169
-        if (! isset($this->label)) {
170
-            throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
171
-        }
172
-
173
-
174
-        // the reference for this template pack
175
-        if (! isset($this->dbref)) {
176
-            throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
177
-        }
178
-
179
-        // make sure dbref is safe
180
-        $this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
181
-
182
-        $should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
183
-
184
-        if ($should_be !== $classname) {
185
-            throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
186
-        }
187
-
188
-        // if _base_path is not set then throw an error because a base path string is needed.
189
-        if (empty($this->_base_path)) {
190
-            throw new EE_Error(sprintf(esc_html__('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
191
-        }
192
-
193
-
194
-        // if _base_url is not set then throw an error because a  string is needed for variations.
195
-        if (empty($this->_base_url)) {
196
-            throw new EE_Error(sprintf(esc_html__('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
197
-        }
198
-
199
-
200
-        // if $supports is not set then throw an error because that effectively means this template_pack does not have any templates!
201
-        if (empty($this->_supports)) {
202
-            throw new EE_Error(sprintf(esc_html__('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
203
-        }
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     * This method should be used to define the following properties:
210
-     * - label
211
-     * - dbref
212
-     * - description
213
-     * - _base_path
214
-     * - _base_url
215
-     * - supports
216
-     * - variations
217
-     *
218
-     * @since 4.5.0
219
-     * @return void.
220
-     * @abstract
221
-     */
222
-    abstract protected function _set_props();
223
-
224
-
225
-
226
-
227
-    /**
228
-     * Wrapper for get_templates() ( @see get_templates() for documentation)
229
-     *
230
-     * @since 4.5.0
231
-     *
232
-     * @param EE_messenger    $messenger
233
-     * @param EE_message_type $message_type
234
-     *
235
-     * @return array
236
-     */
237
-    public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
238
-    {
239
-        return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
240
-    }
241
-
242
-
243
-
244
-
245
-    /**
246
-     * This takes the incoming messenger and message type objects, uses them to get the set fields and contexts, then attempts to retrieve the templates matching those for this given template pack.
247
-     *
248
-     * @since 4.5.0
249
-     *
250
-     * @param EE_messenger    $messenger
251
-     * @param EE_message_type $message_type
252
-     *
253
-     * @return array          Returns an multi-level associative array indexed by template context and field in the format:
254
-     *                                array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) );
255
-     */
256
-    protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type)
257
-    {
258
-        $templates = array();
259
-
260
-        /**
261
-         * Retrieving the default pack for later usage of default templates for template packs that
262
-         * are NOT the default pack ( or an extension of the default pack ).
263
-         * We ONLY set this variable to be the default pack IF the loaded class is NOT the default
264
-         * pack.  This prevents recursion in _get_specific_template().  The intention is that for
265
-         * template packs that are NOT default packs, we use the default template pack to provide
266
-         * the final fallback templates if there aren't any defined for the called template pack.
267
-         *
268
-         * @type EE_Messages_Template_Pack_Default | null $default_pack
269
-         */
270
-        $default_pack = ! $this instanceof EE_Messages_Template_Pack_Default ? new EE_Messages_Template_Pack_Default() : null;
271
-
272
-        $fields = $messenger->get_template_fields();
273
-        $contexts = $message_type->get_contexts();
274
-
275
-
276
-        foreach ($contexts as $context => $details) {
277
-            foreach ($fields as $field => $field_details) {
278
-                if (empty($field_details)) {
279
-                    continue;
280
-                }
281
-                /**
282
-                 * is this a field array (linked to a main field)?
283
-                 */
284
-                if ($field == 'extra') {
285
-                    foreach ($field_details as $main_field => $sub_fields) {
286
-                        foreach ($sub_fields as $sub_field => $sub_field_details) {
287
-                            // make sure that the template_field_ref matches what the main template field is for this template group.
288
-                            $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
289
-                            $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
290
-                        }
291
-                    }
292
-                } else {
293
-                    $templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
294
-                }
295
-            }
296
-        }
297
-
298
-        $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
299
-
300
-        $this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
301
-         return $templates;
302
-    }
303
-
304
-
305
-    /**
306
-     * Utility method for retrieving a specific template matching the given parameters
307
-     *
308
-     * @param null | EE_Messages_Template_Pack_Default $default_pack
309
-     * @param EE_messenger                             $messenger
310
-     * @param EE_message_type                          $message_type
311
-     * @param string                                   $field          The field reference for the specific template being looked up.
312
-     * @param string                                   $context      The context reference for the specific template being looked up
313
-     *
314
-     * @return string          The template contents.
315
-     */
316
-    protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context)
317
-    {
318
-
319
-        // default templates
320
-        $default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array();
321
-
322
-        // first we allow for the $_base_path to be filtered.  However, we assign this to a new variable so that we have the original base_path as a fallback.
323
-        $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
324
-
325
-        $master_templates = $message_type->get_master_templates();
326
-        $master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
327
-        $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
328
-        $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
329
-        $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
-        $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
-        $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
332
-        $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
333
-
334
-        /**
335
-         * Template checks are done hierarchically in the following order:
336
-         *
337
-         * - a match for the full messenger name, message type, context and field in the full path for the given template pack.
338
-         * - a match for the full messenger name, message type, field in the full path for the given template pack.
339
-         * - a match for the full messenger name, message type, field, context in the path grabbed for the related message type defined in the _master_templates property for the message type (i.e. all registration message types share the same template as the main registration message type).
340
-         * - match for the full messenger name, message type, field for the related message type defined in the _master templates property for the message type
341
-         * - a match for a default template matching the messenger, name, context, field (as set by the default template packs).
342
-         * - empty string.
343
-         */
344
-
345
-
346
-        if (is_readable($full_path)) {
347
-            $actual_path = $full_path;
348
-        } elseif (is_readable($fallback_path)) {
349
-            $actual_path = $fallback_path;
350
-        } elseif (is_readable($mt_defined_full_path)) {
351
-            $actual_path = $mt_defined_full_path;
352
-        } elseif (is_readable($mt_defined_fallback_path)) {
353
-            $actual_path = $mt_defined_fallback_path;
354
-        } elseif (is_readable($base_defined_full_path)) {
355
-            $actual_path = $base_defined_full_path;
356
-        } elseif (is_readable($base_defined_fallback_path)) {
357
-            $actual_path = $base_defined_fallback_path;
358
-        } else {
359
-            $actual_path = '';
360
-        }
361
-        if (empty($actual_path)) {
362
-            $contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
363
-        } else {
364
-            $contents = EEH_Template::display_template($actual_path, array(), true);
365
-        }
366
-
367
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this);
368
-    }
369
-
370
-
371
-
372
-
373
-
374
-    /**
375
-     * Return filtered _supports property.
376
-     *
377
-     * @since 4.5.0
378
-     *
379
-     * @return array
380
-     */
381
-    public function get_supports()
382
-    {
383
-        $supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
384
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
385
-    }
386
-
387
-
388
-
389
-
390
-    /**
391
-     * This simply returns the $_default_variation_labels property value.
392
-     *
393
-     * @since 4.5.0
394
-     *
395
-     * @param string $messenger if the messenger slug is returned then the default label for the specific messenger is retrieved.  If it doesn't exist then the esc_html__('Default', 'event_espresso') is returned.  If NO value is provided then whatever is set on the _default_variation_labels property is returned.
396
-     *
397
-     * @return array|string
398
-     */
399
-    public function get_default_variation_labels($messenger = '')
400
-    {
401
-        $label = empty($messenger) ? $this->_default_variation_labels : array();
402
-        $label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
403
-
404
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
405
-    }
406
-
407
-
408
-
409
-
410
-
411
-    /**
412
-     * This simply returns the _variations property.
413
-     *
414
-     * @since 4.5.0
415
-     *
416
-     * @param string $messenger if included then css variations matching the messenger are returned.  Otherwise, just the default variation is included.  If both message type AND messenger are empty then all variations are returned.
417
-     * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set).  Otherwise the array of variations per message type are returned.  If message_type is provided but NOT the messenger, then just all variations for all messengers are returned.
418
-     * @return array
419
-     */
420
-    public function get_variations($messenger = '', $message_type = '')
421
-    {
422
-        $messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
423
-
424
-        // message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
425
-        $variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
426
-
427
-        // now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
428
-        $variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
429
-
430
-        // filter per template pack and globally.
431
-        $variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
432
-        $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
433
-
434
-        // prepend the _default_variation, but ONLY if we're returning the fully validated array.
435
-        if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
436
-            $variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
437
-        }
438
-
439
-        return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
440
-    }
441
-
442
-
443
-
444
-
445
-    /**
446
-     * This is typically called by EE_messenger objects to get the specific css variation defined for the messenger, message_type and type (i.e. inline, wpeditor, preview etc.)
447
-     *
448
-     * @since 4.5.0
449
-     *
450
-     * @param string $messenger messenger slug
451
-     * @param string $message_type message_type slug
452
-     * @param string $type           variation type (i.e. inline, base, wpeditor, preview etc. //this varies per messenger).
453
-     * @param string $variation    this should match one of the defined variations in the _variations property on this class.
454
-     * @param string $file_extension  What type of file the variation file is (defaults to css)
455
-     * @param bool   $url          if true then return the url otherwise path.
456
-     * @param bool   $skip_filters This should not be set directly, its used internally to skip filters when the default template pack is called internally as the fallback.
457
-     *
458
-     * @return string The variation path or url (typically css reference)
459
-     */
460
-    public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = false)
461
-    {
138
+	/**
139
+	 * This is an array of extra css variations for message templates indexed by messenger with the values as an array or message types the variations apply to as the key  and then values are an array with variation slugs as the key and label as the value. Note the default variation is not included in this array.  So the structure is:
140
+	 * array(
141
+	 *  'email' => array(
142
+	 *  )
143
+	 * )
144
+	 *
145
+	 * Keep in mind that this property is used both for indicating valid variations for a given message type and messenger but the variation files themselves are ONLY unique to the messenger.  So if you have a variation for the html messenger referenced by the slug "sunset_red" Then the variation file for the main type will be html_main_sunset_red.css.  All the array in this property allows you to do, is indicate that with certain message types the sunset_red variation is available but for other message types its not.  But you could NOT have a sunset_red variation file for one messenger/message_type and a different one for another messenger/message_type.  If you want different css looks then you can define a different structural layout for the template , messenger, message type combination and in the same sunset_red.css variation file just add css specific to that layout.
146
+	 *
147
+	 * @since 4.5.0
148
+	 *
149
+	 * @var array
150
+	 */
151
+	public $_variations = array();
152
+
153
+
154
+
155
+
156
+	/**
157
+	 * Template pack constructor
158
+	 *
159
+	 * @since 4.5.0
160
+	 */
161
+	public function __construct()
162
+	{
163
+		$this->_set_props();
164
+		// make sure classname is correct
165
+		$classname = get_class($this);
166
+		// make sure required props have been set
167
+
168
+		// if label is empty then throw an error because we should have it defined by now.
169
+		if (! isset($this->label)) {
170
+			throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
171
+		}
172
+
173
+
174
+		// the reference for this template pack
175
+		if (! isset($this->dbref)) {
176
+			throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
177
+		}
178
+
179
+		// make sure dbref is safe
180
+		$this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
181
+
182
+		$should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
183
+
184
+		if ($should_be !== $classname) {
185
+			throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
186
+		}
187
+
188
+		// if _base_path is not set then throw an error because a base path string is needed.
189
+		if (empty($this->_base_path)) {
190
+			throw new EE_Error(sprintf(esc_html__('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
191
+		}
192
+
193
+
194
+		// if _base_url is not set then throw an error because a  string is needed for variations.
195
+		if (empty($this->_base_url)) {
196
+			throw new EE_Error(sprintf(esc_html__('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
197
+		}
198
+
199
+
200
+		// if $supports is not set then throw an error because that effectively means this template_pack does not have any templates!
201
+		if (empty($this->_supports)) {
202
+			throw new EE_Error(sprintf(esc_html__('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
203
+		}
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 * This method should be used to define the following properties:
210
+	 * - label
211
+	 * - dbref
212
+	 * - description
213
+	 * - _base_path
214
+	 * - _base_url
215
+	 * - supports
216
+	 * - variations
217
+	 *
218
+	 * @since 4.5.0
219
+	 * @return void.
220
+	 * @abstract
221
+	 */
222
+	abstract protected function _set_props();
223
+
224
+
225
+
226
+
227
+	/**
228
+	 * Wrapper for get_templates() ( @see get_templates() for documentation)
229
+	 *
230
+	 * @since 4.5.0
231
+	 *
232
+	 * @param EE_messenger    $messenger
233
+	 * @param EE_message_type $message_type
234
+	 *
235
+	 * @return array
236
+	 */
237
+	public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
238
+	{
239
+		return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
240
+	}
241
+
242
+
243
+
244
+
245
+	/**
246
+	 * This takes the incoming messenger and message type objects, uses them to get the set fields and contexts, then attempts to retrieve the templates matching those for this given template pack.
247
+	 *
248
+	 * @since 4.5.0
249
+	 *
250
+	 * @param EE_messenger    $messenger
251
+	 * @param EE_message_type $message_type
252
+	 *
253
+	 * @return array          Returns an multi-level associative array indexed by template context and field in the format:
254
+	 *                                array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) );
255
+	 */
256
+	protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type)
257
+	{
258
+		$templates = array();
259
+
260
+		/**
261
+		 * Retrieving the default pack for later usage of default templates for template packs that
262
+		 * are NOT the default pack ( or an extension of the default pack ).
263
+		 * We ONLY set this variable to be the default pack IF the loaded class is NOT the default
264
+		 * pack.  This prevents recursion in _get_specific_template().  The intention is that for
265
+		 * template packs that are NOT default packs, we use the default template pack to provide
266
+		 * the final fallback templates if there aren't any defined for the called template pack.
267
+		 *
268
+		 * @type EE_Messages_Template_Pack_Default | null $default_pack
269
+		 */
270
+		$default_pack = ! $this instanceof EE_Messages_Template_Pack_Default ? new EE_Messages_Template_Pack_Default() : null;
271
+
272
+		$fields = $messenger->get_template_fields();
273
+		$contexts = $message_type->get_contexts();
274
+
275
+
276
+		foreach ($contexts as $context => $details) {
277
+			foreach ($fields as $field => $field_details) {
278
+				if (empty($field_details)) {
279
+					continue;
280
+				}
281
+				/**
282
+				 * is this a field array (linked to a main field)?
283
+				 */
284
+				if ($field == 'extra') {
285
+					foreach ($field_details as $main_field => $sub_fields) {
286
+						foreach ($sub_fields as $sub_field => $sub_field_details) {
287
+							// make sure that the template_field_ref matches what the main template field is for this template group.
288
+							$template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
289
+							$templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
290
+						}
291
+					}
292
+				} else {
293
+					$templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
294
+				}
295
+			}
296
+		}
297
+
298
+		$templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
299
+
300
+		$this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
301
+		 return $templates;
302
+	}
303
+
304
+
305
+	/**
306
+	 * Utility method for retrieving a specific template matching the given parameters
307
+	 *
308
+	 * @param null | EE_Messages_Template_Pack_Default $default_pack
309
+	 * @param EE_messenger                             $messenger
310
+	 * @param EE_message_type                          $message_type
311
+	 * @param string                                   $field          The field reference for the specific template being looked up.
312
+	 * @param string                                   $context      The context reference for the specific template being looked up
313
+	 *
314
+	 * @return string          The template contents.
315
+	 */
316
+	protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context)
317
+	{
318
+
319
+		// default templates
320
+		$default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array();
321
+
322
+		// first we allow for the $_base_path to be filtered.  However, we assign this to a new variable so that we have the original base_path as a fallback.
323
+		$filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
324
+
325
+		$master_templates = $message_type->get_master_templates();
326
+		$master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
327
+		$full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
328
+		$fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
329
+		$mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
+		$mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
+		$base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
332
+		$base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
333
+
334
+		/**
335
+		 * Template checks are done hierarchically in the following order:
336
+		 *
337
+		 * - a match for the full messenger name, message type, context and field in the full path for the given template pack.
338
+		 * - a match for the full messenger name, message type, field in the full path for the given template pack.
339
+		 * - a match for the full messenger name, message type, field, context in the path grabbed for the related message type defined in the _master_templates property for the message type (i.e. all registration message types share the same template as the main registration message type).
340
+		 * - match for the full messenger name, message type, field for the related message type defined in the _master templates property for the message type
341
+		 * - a match for a default template matching the messenger, name, context, field (as set by the default template packs).
342
+		 * - empty string.
343
+		 */
344
+
345
+
346
+		if (is_readable($full_path)) {
347
+			$actual_path = $full_path;
348
+		} elseif (is_readable($fallback_path)) {
349
+			$actual_path = $fallback_path;
350
+		} elseif (is_readable($mt_defined_full_path)) {
351
+			$actual_path = $mt_defined_full_path;
352
+		} elseif (is_readable($mt_defined_fallback_path)) {
353
+			$actual_path = $mt_defined_fallback_path;
354
+		} elseif (is_readable($base_defined_full_path)) {
355
+			$actual_path = $base_defined_full_path;
356
+		} elseif (is_readable($base_defined_fallback_path)) {
357
+			$actual_path = $base_defined_fallback_path;
358
+		} else {
359
+			$actual_path = '';
360
+		}
361
+		if (empty($actual_path)) {
362
+			$contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
363
+		} else {
364
+			$contents = EEH_Template::display_template($actual_path, array(), true);
365
+		}
366
+
367
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this);
368
+	}
369
+
370
+
371
+
372
+
373
+
374
+	/**
375
+	 * Return filtered _supports property.
376
+	 *
377
+	 * @since 4.5.0
378
+	 *
379
+	 * @return array
380
+	 */
381
+	public function get_supports()
382
+	{
383
+		$supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
384
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
385
+	}
386
+
387
+
388
+
389
+
390
+	/**
391
+	 * This simply returns the $_default_variation_labels property value.
392
+	 *
393
+	 * @since 4.5.0
394
+	 *
395
+	 * @param string $messenger if the messenger slug is returned then the default label for the specific messenger is retrieved.  If it doesn't exist then the esc_html__('Default', 'event_espresso') is returned.  If NO value is provided then whatever is set on the _default_variation_labels property is returned.
396
+	 *
397
+	 * @return array|string
398
+	 */
399
+	public function get_default_variation_labels($messenger = '')
400
+	{
401
+		$label = empty($messenger) ? $this->_default_variation_labels : array();
402
+		$label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
403
+
404
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
405
+	}
406
+
407
+
408
+
409
+
410
+
411
+	/**
412
+	 * This simply returns the _variations property.
413
+	 *
414
+	 * @since 4.5.0
415
+	 *
416
+	 * @param string $messenger if included then css variations matching the messenger are returned.  Otherwise, just the default variation is included.  If both message type AND messenger are empty then all variations are returned.
417
+	 * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set).  Otherwise the array of variations per message type are returned.  If message_type is provided but NOT the messenger, then just all variations for all messengers are returned.
418
+	 * @return array
419
+	 */
420
+	public function get_variations($messenger = '', $message_type = '')
421
+	{
422
+		$messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
423
+
424
+		// message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
425
+		$variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
426
+
427
+		// now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
428
+		$variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
429
+
430
+		// filter per template pack and globally.
431
+		$variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
432
+		$variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
433
+
434
+		// prepend the _default_variation, but ONLY if we're returning the fully validated array.
435
+		if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
436
+			$variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
437
+		}
438
+
439
+		return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
440
+	}
441
+
442
+
443
+
444
+
445
+	/**
446
+	 * This is typically called by EE_messenger objects to get the specific css variation defined for the messenger, message_type and type (i.e. inline, wpeditor, preview etc.)
447
+	 *
448
+	 * @since 4.5.0
449
+	 *
450
+	 * @param string $messenger messenger slug
451
+	 * @param string $message_type message_type slug
452
+	 * @param string $type           variation type (i.e. inline, base, wpeditor, preview etc. //this varies per messenger).
453
+	 * @param string $variation    this should match one of the defined variations in the _variations property on this class.
454
+	 * @param string $file_extension  What type of file the variation file is (defaults to css)
455
+	 * @param bool   $url          if true then return the url otherwise path.
456
+	 * @param bool   $skip_filters This should not be set directly, its used internally to skip filters when the default template pack is called internally as the fallback.
457
+	 *
458
+	 * @return string The variation path or url (typically css reference)
459
+	 */
460
+	public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = false)
461
+	{
462 462
 
463
-        $base = $url ? $this->_base_url : $this->_base_path;
464
-        $base_path = $this->_base_path;
463
+		$base = $url ? $this->_base_url : $this->_base_path;
464
+		$base_path = $this->_base_path;
465 465
 
466
-        if (! $skip_filters) {
467
-            $base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
468
-            $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
469
-        }
466
+		if (! $skip_filters) {
467
+			$base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
468
+			$base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
469
+		}
470 470
 
471
-        $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
472
-
473
-        // possible variation paths considering whether message type is present or not in the file name.
474
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
475
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
476
-
477
-        // first see if fully validated file exists.
478
-        if (is_readable($base_path . $path_string)) {
479
-            $variation_path = $base . $path_string;
480
-        // otherwise see if default exists.
481
-        } elseif (is_readable($base_path . $default_path_string)) {
482
-            $variation_path = $base . $default_path_string;
483
-        } else {
484
-            $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
485
-        }
471
+		$default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
472
+
473
+		// possible variation paths considering whether message type is present or not in the file name.
474
+		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
475
+		$default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
476
+
477
+		// first see if fully validated file exists.
478
+		if (is_readable($base_path . $path_string)) {
479
+			$variation_path = $base . $path_string;
480
+		// otherwise see if default exists.
481
+		} elseif (is_readable($base_path . $default_path_string)) {
482
+			$variation_path = $base . $default_path_string;
483
+		} else {
484
+			$variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
485
+		}
486 486
 
487
-        if ($skip_filters) {
488
-            return $variation_path;
489
-        }
490
-
491
-        // filter result
492
-        $variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
493
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
494
-    }
495
-
496
-
497
-
498
-
499
-
500
-    /**
501
-     * This method is used to return the wrapper template for the given template pack.  If the given template pack does not include any wrapper templates then the default is used.
502
-     *
503
-     * @param string $messenger What messenger the wrapper is for.
504
-     * @param string $type           What type of wrapper is being returned ( for messengers that may have more than one wrapper )
505
-     *
506
-     * @return string returns the path for the requested wrapper template.
507
-     */
508
-    public function get_wrapper($messenger, $type = 'main')
509
-    {
510
-        $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
511
-
512
-        $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
513
-
514
-        if (is_readable($path_string)) {
515
-            $template = $path_string;
516
-        } else {
517
-            $template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : '';
518
-        }
519
-
520
-        // filter
521
-        $template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
522
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
523
-    }
487
+		if ($skip_filters) {
488
+			return $variation_path;
489
+		}
490
+
491
+		// filter result
492
+		$variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
493
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
494
+	}
495
+
496
+
497
+
498
+
499
+
500
+	/**
501
+	 * This method is used to return the wrapper template for the given template pack.  If the given template pack does not include any wrapper templates then the default is used.
502
+	 *
503
+	 * @param string $messenger What messenger the wrapper is for.
504
+	 * @param string $type           What type of wrapper is being returned ( for messengers that may have more than one wrapper )
505
+	 *
506
+	 * @return string returns the path for the requested wrapper template.
507
+	 */
508
+	public function get_wrapper($messenger, $type = 'main')
509
+	{
510
+		$default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
511
+
512
+		$path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
513
+
514
+		if (is_readable($path_string)) {
515
+			$template = $path_string;
516
+		} else {
517
+			$template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : '';
518
+		}
519
+
520
+		// filter
521
+		$template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
522
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
523
+	}
524 524
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -166,20 +166,20 @@  discard block
 block discarded – undo
166 166
         // make sure required props have been set
167 167
 
168 168
         // if label is empty then throw an error because we should have it defined by now.
169
-        if (! isset($this->label)) {
169
+        if ( ! isset($this->label)) {
170 170
             throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
171 171
         }
172 172
 
173 173
 
174 174
         // the reference for this template pack
175
-        if (! isset($this->dbref)) {
175
+        if ( ! isset($this->dbref)) {
176 176
             throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
177 177
         }
178 178
 
179 179
         // make sure dbref is safe
180 180
         $this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
181 181
 
182
-        $should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
182
+        $should_be = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
183 183
 
184 184
         if ($should_be !== $classname) {
185 185
             throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
238 238
     {
239
-        return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
239
+        return isset($this->_templates[$messenger->name][$message_type->name]) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates($messenger, $message_type);
240 240
     }
241 241
 
242 242
 
@@ -286,18 +286,18 @@  discard block
 block discarded – undo
286 286
                         foreach ($sub_fields as $sub_field => $sub_field_details) {
287 287
                             // make sure that the template_field_ref matches what the main template field is for this template group.
288 288
                             $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
289
-                            $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
289
+                            $templates[$context][$main_field][$sub_field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
290 290
                         }
291 291
                     }
292 292
                 } else {
293
-                    $templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
293
+                    $templates[$context][$field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
294 294
                 }
295 295
             }
296 296
         }
297 297
 
298 298
         $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
299 299
 
300
-        $this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
300
+        $this->_templates[$messenger->name][$message_type->name] = $templates;
301 301
          return $templates;
302 302
     }
303 303
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
         $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
324 324
 
325 325
         $master_templates = $message_type->get_master_templates();
326
-        $master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
327
-        $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
328
-        $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
329
-        $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
-        $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
-        $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
332
-        $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
326
+        $master_templates_mt = isset($master_templates[$messenger->name]) ? $master_templates[$messenger->name] : $message_type->name;
327
+        $full_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'_'.$context.'.template.php';
328
+        $fallback_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'.template.php';
329
+        $mt_defined_full_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
330
+        $mt_defined_fallback_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
331
+        $base_defined_full_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
332
+        $base_defined_fallback_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
333 333
 
334 334
         /**
335 335
          * Template checks are done hierarchically in the following order:
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             $actual_path = '';
360 360
         }
361 361
         if (empty($actual_path)) {
362
-            $contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
362
+            $contents = isset($default_templates[$context][$field]) ? $default_templates[$context][$field] : '';
363 363
         } else {
364 364
             $contents = EEH_Template::display_template($actual_path, array(), true);
365 365
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      */
381 381
     public function get_supports()
382 382
     {
383
-        $supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
383
+        $supports = apply_filters('FHEE__'.get_class($this).'__get_supports', $this->_supports);
384 384
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
385 385
     }
386 386
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
     public function get_default_variation_labels($messenger = '')
400 400
     {
401 401
         $label = empty($messenger) ? $this->_default_variation_labels : array();
402
-        $label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
402
+        $label = empty($label) && ! empty($this->_default_variation_labels[$messenger]) ? $this->_default_variation_labels[$messenger] : esc_html__('Default', 'event_espresso');
403 403
 
404 404
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
405 405
     }
@@ -419,24 +419,24 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function get_variations($messenger = '', $message_type = '')
421 421
     {
422
-        $messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
422
+        $messenger_variations = ! empty($messenger) && isset($this->_variations[$messenger]) ? $this->_variations[$messenger] : array();
423 423
 
424 424
         // message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
425
-        $variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
425
+        $variations = ! empty($messenger) && ! empty($message_type) && isset($messenger_variations[$message_type]) ? $messenger_variations[$message_type] : array();
426 426
 
427 427
         // now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
428
-        $variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
428
+        $variations = empty($variations) && ! empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
429 429
 
430 430
         // filter per template pack and globally.
431
-        $variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
431
+        $variations = apply_filters('FHEE__'.get_class($this).'__get_variations', $variations, $messenger, $message_type);
432 432
         $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
433 433
 
434 434
         // prepend the _default_variation, but ONLY if we're returning the fully validated array.
435
-        if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
436
-            $variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
435
+        if ( ! empty($messenger) && ! empty($message_type) && ! empty($variations)) {
436
+            $variations = array('default' => $this->get_default_variation_labels($messenger)) + $variations;
437 437
         }
438 438
 
439
-        return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
439
+        return empty($variations) ? array('default' => $this->get_default_variation_labels('dft')) : $variations;
440 440
     }
441 441
 
442 442
 
@@ -463,23 +463,23 @@  discard block
 block discarded – undo
463 463
         $base = $url ? $this->_base_url : $this->_base_path;
464 464
         $base_path = $this->_base_path;
465 465
 
466
-        if (! $skip_filters) {
467
-            $base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
466
+        if ( ! $skip_filters) {
467
+            $base = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
468 468
             $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
469 469
         }
470 470
 
471 471
         $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
472 472
 
473 473
         // possible variation paths considering whether message type is present or not in the file name.
474
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
475
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
474
+        $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_'.$variation.$file_extension;
475
+        $default_path_string = 'variations/'.$messenger.'_'.$type.'_'.$variation.$file_extension;
476 476
 
477 477
         // first see if fully validated file exists.
478
-        if (is_readable($base_path . $path_string)) {
479
-            $variation_path = $base . $path_string;
478
+        if (is_readable($base_path.$path_string)) {
479
+            $variation_path = $base.$path_string;
480 480
         // otherwise see if default exists.
481
-        } elseif (is_readable($base_path . $default_path_string)) {
482
-            $variation_path = $base . $default_path_string;
481
+        } elseif (is_readable($base_path.$default_path_string)) {
482
+            $variation_path = $base.$default_path_string;
483 483
         } else {
484 484
             $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
485 485
         }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         }
490 490
 
491 491
         // filter result
492
-        $variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
492
+        $variation_path = apply_filters('FHEE__'.get_class($this).'__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
493 493
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
494 494
     }
495 495
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     {
510 510
         $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
511 511
 
512
-        $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
512
+        $path_string = $this->_base_path.$messenger.'_'.$type.'_wrapper.template.php';
513 513
 
514 514
         if (is_readable($path_string)) {
515 515
             $template = $path_string;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
         }
519 519
 
520 520
         // filter
521
-        $template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
521
+        $template = apply_filters('FHEE__'.get_class($this).'__get_wrapper', $template, $messenger, $type);
522 522
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
523 523
     }
524 524
 }
Please login to merge, or discard this patch.
libraries/messages/defaults/EE_Messages_Template_Pack_Default.class.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -11,71 +11,71 @@
 block discarded – undo
11 11
 class EE_Messages_Template_Pack_Default extends EE_Messages_Template_Pack
12 12
 {
13 13
 
14
-    public function _set_props()
15
-    {
16
-        $this->label = esc_html__('Default', 'event_espresso');
17
-        $this->dbref = 'default';
18
-        $this->description = esc_html__('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
19
-        $this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
20
-        $this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
21
-        $this->_supports = array(
22
-            'email' => array(
23
-                'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
24
-                    'registration_summary',
25
-                'payment_declined', 'payment', 'payment_refund', 'payment_reminder'
26
-                ),
27
-            'html' => array(
28
-                'receipt', 'invoice'
29
-                )
30
-            );
31
-        $this->_default_variation_labels = array(
32
-            'email' => esc_html__('Default', 'event_espresso'),
33
-            'html' =>  esc_html__('Simple', 'event_espresso')
34
-             );
35
-        $this->_variations = array(
36
-            'html' => array(
37
-                'receipt' =>
38
-                    array(
39
-                    'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
40
-                    'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
41
-                    'horizon' => esc_html__('Horizon', 'event_espresso'),
42
-                    'lola' => esc_html__('Lola', 'event_espresso'),
43
-                    'tranquility' => esc_html__('Tranquility', 'event_espresso'),
44
-                    'union' => esc_html__('Union', 'event_espresso'),
45
-                    ),
46
-                'invoice' =>
47
-                    array(
48
-                    'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
49
-                    'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
50
-                    'horizon' => esc_html__('Horizon', 'event_espresso'),
51
-                    'lola' => esc_html__('Lola', 'event_espresso'),
52
-                    'tranquility' => esc_html__('Tranquility', 'event_espresso'),
53
-                    'union' => esc_html__('Union', 'event_espresso'),
54
-                    )
55
-                )
56
-            );
57
-    }
14
+	public function _set_props()
15
+	{
16
+		$this->label = esc_html__('Default', 'event_espresso');
17
+		$this->dbref = 'default';
18
+		$this->description = esc_html__('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
19
+		$this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
20
+		$this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
21
+		$this->_supports = array(
22
+			'email' => array(
23
+				'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
24
+					'registration_summary',
25
+				'payment_declined', 'payment', 'payment_refund', 'payment_reminder'
26
+				),
27
+			'html' => array(
28
+				'receipt', 'invoice'
29
+				)
30
+			);
31
+		$this->_default_variation_labels = array(
32
+			'email' => esc_html__('Default', 'event_espresso'),
33
+			'html' =>  esc_html__('Simple', 'event_espresso')
34
+			 );
35
+		$this->_variations = array(
36
+			'html' => array(
37
+				'receipt' =>
38
+					array(
39
+					'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
40
+					'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
41
+					'horizon' => esc_html__('Horizon', 'event_espresso'),
42
+					'lola' => esc_html__('Lola', 'event_espresso'),
43
+					'tranquility' => esc_html__('Tranquility', 'event_espresso'),
44
+					'union' => esc_html__('Union', 'event_espresso'),
45
+					),
46
+				'invoice' =>
47
+					array(
48
+					'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
49
+					'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
50
+					'horizon' => esc_html__('Horizon', 'event_espresso'),
51
+					'lola' => esc_html__('Lola', 'event_espresso'),
52
+					'tranquility' => esc_html__('Tranquility', 'event_espresso'),
53
+					'union' => esc_html__('Union', 'event_espresso'),
54
+					)
55
+				)
56
+			);
57
+	}
58 58
 
59 59
 
60 60
 
61
-    public function get_default_variation($messenger, $message_type, $type, $url, $file_extension)
62
-    {
63
-        $base = $url ? $this->_base_url : $this->_base_path;
64
-        $base_path = $this->_base_path;
65
-        // possible variation paths considering whether message type is present or not in the file name.
66
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
67
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
68
-        // first see if fully validated file exists.
69
-        if (is_readable($base_path . $path_string)) {
70
-            $variation_path = $base . $path_string;
71
-        // otherwise see if default exists.
72
-        } elseif (is_readable($base_path . $default_path_string)) {
73
-            $variation_path = $base . $default_path_string;
74
-        } else {
75
-            // no matches found so nothing is present.
76
-            $variation_path = '';
77
-        }
61
+	public function get_default_variation($messenger, $message_type, $type, $url, $file_extension)
62
+	{
63
+		$base = $url ? $this->_base_url : $this->_base_path;
64
+		$base_path = $this->_base_path;
65
+		// possible variation paths considering whether message type is present or not in the file name.
66
+		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
67
+		$default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
68
+		// first see if fully validated file exists.
69
+		if (is_readable($base_path . $path_string)) {
70
+			$variation_path = $base . $path_string;
71
+		// otherwise see if default exists.
72
+		} elseif (is_readable($base_path . $default_path_string)) {
73
+			$variation_path = $base . $default_path_string;
74
+		} else {
75
+			// no matches found so nothing is present.
76
+			$variation_path = '';
77
+		}
78 78
 
79
-        return $variation_path;
80
-    }
79
+		return $variation_path;
80
+	}
81 81
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
         $this->label = esc_html__('Default', 'event_espresso');
17 17
         $this->dbref = 'default';
18 18
         $this->description = esc_html__('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
19
-        $this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
20
-        $this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
19
+        $this->_base_url = EE_PLUGIN_DIR_URL.'core/libraries/messages/defaults/default/';
20
+        $this->_base_path = EE_LIBRARIES.'messages/defaults/default/';
21 21
         $this->_supports = array(
22 22
             'email' => array(
23 23
                 'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
         $base = $url ? $this->_base_url : $this->_base_path;
64 64
         $base_path = $this->_base_path;
65 65
         // possible variation paths considering whether message type is present or not in the file name.
66
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
67
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
66
+        $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_default'.$file_extension;
67
+        $default_path_string = 'variations/'.$messenger.'_'.$type.'_default'.$file_extension;
68 68
         // first see if fully validated file exists.
69
-        if (is_readable($base_path . $path_string)) {
70
-            $variation_path = $base . $path_string;
69
+        if (is_readable($base_path.$path_string)) {
70
+            $variation_path = $base.$path_string;
71 71
         // otherwise see if default exists.
72
-        } elseif (is_readable($base_path . $default_path_string)) {
73
-            $variation_path = $base . $default_path_string;
72
+        } elseif (is_readable($base_path.$default_path_string)) {
73
+            $variation_path = $base.$default_path_string;
74 74
         } else {
75 75
             // no matches found so nothing is present.
76 76
             $variation_path = '';
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Html_messenger.class.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                     ),
314 314
                     'ticket_line_item_no_pms' => array(
315 315
                         'input' => 'textarea',
316
-                        'label' => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
316
+                        'label' => '[TICKET_LINE_ITEM_LIST] <br>'.esc_html__(
317 317
                             'Ticket Line Item List with no Price Modifiers',
318 318
                             'event_espresso'
319 319
                         ),
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
                     ),
328 328
                     'ticket_line_item_pms' => array(
329 329
                         'input' => 'textarea',
330
-                        'label' => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
330
+                        'label' => '[TICKET_LINE_ITEM_LIST] <br>'.esc_html__(
331 331
                             'Ticket Line Item List with Price Modifiers',
332 332
                             'event_espresso'
333 333
                         ),
Please login to merge, or discard this patch.
Indentation   +545 added lines, -545 removed lines patch added patch discarded remove patch
@@ -12,549 +12,549 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * The following are the properties that this messenger requires for displaying the html
17
-     */
18
-    /**
19
-     * This is the html body generated by the template via the message type.
20
-     *
21
-     * @var string
22
-     */
23
-    protected $_content;
24
-
25
-
26
-    /**
27
-     * This is for the page title that gets displayed.  (Why use "subject"?  Because the "title" tag in html is
28
-     * equivalent to the "subject" of the page.
29
-     *
30
-     * @var string
31
-     */
32
-    protected $_subject;
33
-
34
-
35
-    /**
36
-     * EE_Html_messenger constructor.
37
-     */
38
-    public function __construct()
39
-    {
40
-        // set properties
41
-        $this->name = 'html';
42
-        $this->description = esc_html__('This messenger outputs a message to a browser for display.', 'event_espresso');
43
-        $this->label = array(
44
-            'singular' => esc_html__('html', 'event_espresso'),
45
-            'plural' => esc_html__('html', 'event_espresso'),
46
-        );
47
-        $this->activate_on_install = true;
48
-        // add the "powered by EE" credit link to the HTML receipt and invoice
49
-        add_filter(
50
-            'FHEE__EE_Html_messenger___send_message__main_body',
51
-            array($this, 'add_powered_by_credit_link_to_receipt_and_invoice'),
52
-            10,
53
-            3
54
-        );
55
-        parent::__construct();
56
-    }
57
-
58
-
59
-    /**
60
-     * HTML Messenger desires execution immediately.
61
-     *
62
-     * @see    parent::send_now() for documentation.
63
-     * @since  4.9.0
64
-     * @return bool
65
-     */
66
-    public function send_now()
67
-    {
68
-        return true;
69
-    }
70
-
71
-
72
-    /**
73
-     * HTML Messenger allows an empty to field.
74
-     *
75
-     * @see    parent::allow_empty_to_field() for documentation
76
-     * @since  4.9.0
77
-     * @return bool
78
-     */
79
-    public function allow_empty_to_field()
80
-    {
81
-        return true;
82
-    }
83
-
84
-
85
-    /**
86
-     * @see abstract declaration in EE_messenger for details.
87
-     */
88
-    protected function _set_admin_pages()
89
-    {
90
-        $this->admin_registered_pages = array('events_edit' => true);
91
-    }
92
-
93
-
94
-    /**
95
-     * @see abstract declaration in EE_messenger for details.
96
-     */
97
-    protected function _set_valid_shortcodes()
98
-    {
99
-        $this->_valid_shortcodes = array();
100
-    }
101
-
102
-
103
-    /**
104
-     * @see abstract declaration in EE_messenger for details.
105
-     */
106
-    protected function _set_validator_config()
107
-    {
108
-        $this->_validator_config = array(
109
-            'subject' => array(
110
-                'shortcodes' => array('organization', 'primary_registration_details', 'email', 'transaction'),
111
-            ),
112
-            'content' => array(
113
-                'shortcodes' => array(
114
-                    'organization',
115
-                    'primary_registration_list',
116
-                    'primary_registration_details',
117
-                    'email',
118
-                    'transaction',
119
-                    'event_list',
120
-                    'payment_list',
121
-                    'venue',
122
-                    'line_item_list',
123
-                    'messenger',
124
-                    'ticket_list',
125
-                ),
126
-            ),
127
-            'event_list' => array(
128
-                'shortcodes' => array(
129
-                    'event',
130
-                    'ticket_list',
131
-                    'venue',
132
-                    'primary_registration_details',
133
-                    'primary_registration_list',
134
-                    'event_author',
135
-                ),
136
-                'required' => array('[EVENT_LIST]'),
137
-            ),
138
-            'ticket_list' => array(
139
-                'shortcodes' => array(
140
-                    'attendee_list',
141
-                    'ticket',
142
-                    'datetime_list',
143
-                    'primary_registration_details',
144
-                    'line_item_list',
145
-                    'venue',
146
-                ),
147
-                'required' => array('[TICKET_LIST]'),
148
-            ),
149
-            'ticket_line_item_no_pms' => array(
150
-                'shortcodes' => array('line_item', 'ticket'),
151
-                'required' => array('[TICKET_LINE_ITEM_LIST]'),
152
-            ),
153
-            'ticket_line_item_pms' => array(
154
-                'shortcodes' => array('line_item', 'ticket', 'line_item_list'),
155
-                'required' => array('[TICKET_LINE_ITEM_LIST]'),
156
-            ),
157
-            'price_modifier_line_item_list' => array(
158
-                'shortcodes' => array('line_item'),
159
-                'required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'),
160
-            ),
161
-            'datetime_list' => array(
162
-                'shortcodes' => array('datetime'),
163
-                'required' => array('[DATETIME_LIST]'),
164
-            ),
165
-            'attendee_list' => array(
166
-                'shortcodes' => array('attendee'),
167
-                'required' => array('[ATTENDEE_LIST]'),
168
-            ),
169
-            'tax_line_item_list' => array(
170
-                'shortcodes' => array('line_item'),
171
-                'required' => array('[TAX_LINE_ITEM_LIST]'),
172
-            ),
173
-            'additional_line_item_list' => array(
174
-                'shortcodes' => array('line_item'),
175
-                'required' => array('[ADDITIONAL_LINE_ITEM_LIST]'),
176
-            ),
177
-            'payment_list' => array(
178
-                'shortcodes' => array('payment'),
179
-                'required' => array('[PAYMENT_LIST_*]'),
180
-            ),
181
-        );
182
-    }
183
-
184
-
185
-    /**
186
-     * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger
187
-     * is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary
188
-     * (i.e. swap out css files or something else).
189
-     *
190
-     * @since 4.5.0
191
-     * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
192
-     * @return void
193
-     */
194
-    public function do_secondary_messenger_hooks($sending_messenger_name)
195
-    {
196
-        if ($sending_messenger_name === 'pdf') {
197
-            add_filter('EE_messenger__get_variation__variation', array($this, 'add_html_css'), 10, 8);
198
-        }
199
-    }
200
-
201
-
202
-    /**
203
-     * @param                            $variation_path
204
-     * @param \EE_Messages_Template_Pack $template_pack
205
-     * @param                            $messenger_name
206
-     * @param                            $message_type_name
207
-     * @param                            $url
208
-     * @param                            $type
209
-     * @param                            $variation
210
-     * @param                            $skip_filters
211
-     * @return string
212
-     */
213
-    public function add_html_css(
214
-        $variation_path,
215
-        EE_Messages_Template_Pack $template_pack,
216
-        $messenger_name,
217
-        $message_type_name,
218
-        $url,
219
-        $type,
220
-        $variation,
221
-        $skip_filters
222
-    ) {
223
-        $variation = $template_pack->get_variation(
224
-            $this->name,
225
-            $message_type_name,
226
-            $type,
227
-            $variation,
228
-            $url,
229
-            '.css',
230
-            $skip_filters
231
-        );
232
-        return $variation;
233
-    }
234
-
235
-
236
-    /**
237
-     * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this
238
-     * messenger can add their own js.
239
-     *
240
-     * @return void.
241
-     */
242
-    public function enqueue_scripts_styles()
243
-    {
244
-        parent::enqueue_scripts_styles();
245
-        do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles');
246
-    }
247
-
248
-
249
-    /**
250
-     * _set_template_fields
251
-     * This sets up the fields that a messenger requires for the message to go out.
252
-     *
253
-     * @access  protected
254
-     * @return void
255
-     */
256
-    protected function _set_template_fields()
257
-    {
258
-        // any extra template fields that are NOT used by the messenger
259
-        // but will get used by a messenger field for shortcode replacement
260
-        // get added to the 'extra' key in an associated array
261
-        // indexed by the messenger field they relate to.
262
-        // This is important for the Messages_admin to know what fields to display to the user.
263
-        // Also, notice that the "values" are equal to the field type
264
-        // that messages admin will use to know what kind of field to display.
265
-        // The values ALSO have one index labeled "shortcode".
266
-        // The values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE])
267
-        // is required in order for this extra field to be displayed.
268
-        //  If the required shortcode isn't part of the shortcodes array
269
-        // then the field is not needed and will not be displayed/parsed.
270
-        $this->_template_fields = array(
271
-            'subject' => array(
272
-                'input' => 'text',
273
-                'label' => esc_html__('Page Title', 'event_espresso'),
274
-                'type' => 'string',
275
-                'required' => true,
276
-                'validation' => true,
277
-                'css_class' => 'large-text',
278
-                'format' => '%s',
279
-            ),
280
-            'content' => '',
281
-            // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
282
-            'extra' => array(
283
-                'content' => array(
284
-                    'main' => array(
285
-                        'input' => 'wp_editor',
286
-                        'label' => esc_html__('Main Content', 'event_espresso'),
287
-                        'type' => 'string',
288
-                        'required' => true,
289
-                        'validation' => true,
290
-                        'format' => '%s',
291
-                        'rows' => '15',
292
-                    ),
293
-                    'event_list' => array(
294
-                        'input' => 'wp_editor',
295
-                        'label' => '[EVENT_LIST]',
296
-                        'type' => 'string',
297
-                        'required' => true,
298
-                        'validation' => true,
299
-                        'format' => '%s',
300
-                        'rows' => '15',
301
-                        'shortcodes_required' => array('[EVENT_LIST]'),
302
-                    ),
303
-                    'ticket_list' => array(
304
-                        'input' => 'textarea',
305
-                        'label' => '[TICKET_LIST]',
306
-                        'type' => 'string',
307
-                        'required' => true,
308
-                        'validation' => true,
309
-                        'format' => '%s',
310
-                        'css_class' => 'large-text',
311
-                        'rows' => '10',
312
-                        'shortcodes_required' => array('[TICKET_LIST]'),
313
-                    ),
314
-                    'ticket_line_item_no_pms' => array(
315
-                        'input' => 'textarea',
316
-                        'label' => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
317
-                            'Ticket Line Item List with no Price Modifiers',
318
-                            'event_espresso'
319
-                        ),
320
-                        'type' => 'string',
321
-                        'required' => false,
322
-                        'validation' => true,
323
-                        'format' => '%s',
324
-                        'css_class' => 'large-text',
325
-                        'rows' => '5',
326
-                        'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'),
327
-                    ),
328
-                    'ticket_line_item_pms' => array(
329
-                        'input' => 'textarea',
330
-                        'label' => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
331
-                            'Ticket Line Item List with Price Modifiers',
332
-                            'event_espresso'
333
-                        ),
334
-                        'type' => 'string',
335
-                        'required' => false,
336
-                        'validation' => true,
337
-                        'format' => '%s',
338
-                        'css_class' => 'large-text',
339
-                        'rows' => '5',
340
-                        'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'),
341
-                    ),
342
-                    'price_modifier_line_item_list' => array(
343
-                        'input' => 'textarea',
344
-                        'label' => '[PRICE_MODIFIER_LINE_ITEM_LIST]',
345
-                        'type' => 'string',
346
-                        'required' => false,
347
-                        'validation' => true,
348
-                        'format' => '%s',
349
-                        'css_class' => 'large-text',
350
-                        'rows' => '5',
351
-                        'shortcodes_required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'),
352
-                    ),
353
-                    'datetime_list' => array(
354
-                        'input' => 'textarea',
355
-                        'label' => '[DATETIME_LIST]',
356
-                        'type' => 'string',
357
-                        'required' => true,
358
-                        'validation' => true,
359
-                        'format' => '%s',
360
-                        'css_class' => 'large-text',
361
-                        'rows' => '5',
362
-                        'shortcodes_required' => array('[DATETIME_LIST]'),
363
-                    ),
364
-                    'attendee_list' => array(
365
-                        'input' => 'textarea',
366
-                        'label' => '[ATTENDEE_LIST]',
367
-                        'type' => 'string',
368
-                        'required' => true,
369
-                        'validation' => true,
370
-                        'format' => '%s',
371
-                        'css_class' => 'large-text',
372
-                        'rows' => '5',
373
-                        'shortcodes_required' => array('[ATTENDEE_LIST]'),
374
-                    ),
375
-                    'tax_line_item_list' => array(
376
-                        'input' => 'textarea',
377
-                        'label' => '[TAX_LINE_ITEM_LIST]',
378
-                        'type' => 'string',
379
-                        'required' => false,
380
-                        'validation' => true,
381
-                        'format' => '%s',
382
-                        'css_class' => 'large-text',
383
-                        'rows' => '5',
384
-                        'shortcodes_required' => array('[TAX_LINE_ITEM_LIST]'),
385
-                    ),
386
-                    'additional_line_item_list' => array(
387
-                        'input' => 'textarea',
388
-                        'label' => '[ADDITIONAL_LINE_ITEM_LIST]',
389
-                        'type' => 'string',
390
-                        'required' => false,
391
-                        'validation' => true,
392
-                        'format' => '%s',
393
-                        'css_class' => 'large-text',
394
-                        'rows' => '5',
395
-                        'shortcodes_required' => array('[ADDITIONAL_LINE_ITEM_LIST]'),
396
-                    ),
397
-                    'payment_list' => array(
398
-                        'input' => 'textarea',
399
-                        'label' => '[PAYMENT_LIST]',
400
-                        'type' => 'string',
401
-                        'required' => true,
402
-                        'validation' => true,
403
-                        'format' => '%s',
404
-                        'css_class' => 'large-text',
405
-                        'rows' => '5',
406
-                        'shortcodes_required' => array('[PAYMENT_LIST_*]'),
407
-                    ),
408
-                ),
409
-            ),
410
-        );
411
-    }
412
-
413
-
414
-    /**
415
-     * @see   definition of this method in parent
416
-     * @since 4.5.0
417
-     */
418
-    protected function _set_default_message_types()
419
-    {
420
-        $this->_default_message_types = array('receipt', 'invoice');
421
-    }
422
-
423
-
424
-    /**
425
-     * @see   definition of this method in parent
426
-     * @since 4.5.0
427
-     */
428
-    protected function _set_valid_message_types()
429
-    {
430
-        $this->_valid_message_types = array('receipt', 'invoice');
431
-    }
432
-
433
-
434
-    /**
435
-     * Displays the message in the browser.
436
-     *
437
-     * @since 4.5.0
438
-     * @return string.
439
-     */
440
-    protected function _send_message()
441
-    {
442
-        $this->_template_args = array(
443
-            'page_title' => $this->_subject,
444
-            'base_css' => $this->get_variation(
445
-                $this->_tmp_pack,
446
-                $this->_incoming_message_type->name,
447
-                true,
448
-                'base',
449
-                $this->_variation
450
-            ),
451
-            'print_css' => $this->get_variation(
452
-                $this->_tmp_pack,
453
-                $this->_incoming_message_type->name,
454
-                true,
455
-                'print',
456
-                $this->_variation
457
-            ),
458
-            'main_css' => $this->get_variation(
459
-                $this->_tmp_pack,
460
-                $this->_incoming_message_type->name,
461
-                true,
462
-                'main',
463
-                $this->_variation
464
-            ),
465
-            'main_body' => wpautop(
466
-                apply_filters(
467
-                    'FHEE__EE_Html_messenger___send_message__main_body',
468
-                    $this->_content,
469
-                    $this->_content,
470
-                    $this->_incoming_message_type
471
-                )
472
-            )
473
-        );
474
-        $this->_deregister_wp_hooks();
475
-        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
476
-        echo $this->_get_main_template(); // already escaped
477
-        exit();
478
-    }
479
-
480
-
481
-    /**
482
-     * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't
483
-     * interfere with our templates.  If users want to add any custom styles or scripts they must use the
484
-     * AHEE__EE_Html_messenger__enqueue_scripts_styles hook.
485
-     *
486
-     * @since 4.5.0
487
-     * @return void
488
-     */
489
-    protected function _deregister_wp_hooks()
490
-    {
491
-        remove_all_actions('wp_head');
492
-        remove_all_actions('wp_footer');
493
-        remove_all_actions('wp_print_footer_scripts');
494
-        remove_all_actions('wp_enqueue_scripts');
495
-        global $wp_scripts, $wp_styles;
496
-        $wp_scripts = $wp_styles = array();
497
-        // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
498
-        add_action('wp_footer', 'wp_print_footer_scripts');
499
-        add_action('wp_print_footer_scripts', '_wp_footer_scripts');
500
-        add_action('wp_head', 'wp_enqueue_scripts');
501
-    }
502
-
503
-
504
-    /**
505
-     * Overwrite parent _get_main_template for display_html purposes.
506
-     *
507
-     * @since  4.5.0
508
-     * @param bool $preview
509
-     * @return string
510
-     */
511
-    protected function _get_main_template($preview = false)
512
-    {
513
-        $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main');
514
-        // include message type as a template arg
515
-        $this->_template_args['message_type'] = $this->_incoming_message_type;
516
-        return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
517
-    }
518
-
519
-
520
-    /**
521
-     * @return string
522
-     */
523
-    protected function _preview()
524
-    {
525
-        return $this->_send_message();
526
-    }
527
-
528
-
529
-    protected function _set_admin_settings_fields()
530
-    {
531
-    }
532
-
533
-
534
-    /**
535
-     * add the "powered by EE" credit link to the HTML receipt and invoice
536
-     *
537
-     * @param string $content
538
-     * @param string $content_again
539
-     * @param \EE_message_type $incoming_message_type
540
-     * @return string
541
-     */
542
-    public function add_powered_by_credit_link_to_receipt_and_invoice(
543
-        $content = '',
544
-        $content_again = '',
545
-        EE_message_type $incoming_message_type
546
-    ) {
547
-        if (
548
-            ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt')
549
-            && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true)
550
-        ) {
551
-            $content .= \EEH_Template::powered_by_event_espresso(
552
-                'aln-cntr',
553
-                '',
554
-                array('utm_content' => 'messages_system')
555
-            )
556
-                . EEH_HTML::div(EEH_HTML::p('&nbsp;'));
557
-        }
558
-        return $content;
559
-    }
15
+	/**
16
+	 * The following are the properties that this messenger requires for displaying the html
17
+	 */
18
+	/**
19
+	 * This is the html body generated by the template via the message type.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $_content;
24
+
25
+
26
+	/**
27
+	 * This is for the page title that gets displayed.  (Why use "subject"?  Because the "title" tag in html is
28
+	 * equivalent to the "subject" of the page.
29
+	 *
30
+	 * @var string
31
+	 */
32
+	protected $_subject;
33
+
34
+
35
+	/**
36
+	 * EE_Html_messenger constructor.
37
+	 */
38
+	public function __construct()
39
+	{
40
+		// set properties
41
+		$this->name = 'html';
42
+		$this->description = esc_html__('This messenger outputs a message to a browser for display.', 'event_espresso');
43
+		$this->label = array(
44
+			'singular' => esc_html__('html', 'event_espresso'),
45
+			'plural' => esc_html__('html', 'event_espresso'),
46
+		);
47
+		$this->activate_on_install = true;
48
+		// add the "powered by EE" credit link to the HTML receipt and invoice
49
+		add_filter(
50
+			'FHEE__EE_Html_messenger___send_message__main_body',
51
+			array($this, 'add_powered_by_credit_link_to_receipt_and_invoice'),
52
+			10,
53
+			3
54
+		);
55
+		parent::__construct();
56
+	}
57
+
58
+
59
+	/**
60
+	 * HTML Messenger desires execution immediately.
61
+	 *
62
+	 * @see    parent::send_now() for documentation.
63
+	 * @since  4.9.0
64
+	 * @return bool
65
+	 */
66
+	public function send_now()
67
+	{
68
+		return true;
69
+	}
70
+
71
+
72
+	/**
73
+	 * HTML Messenger allows an empty to field.
74
+	 *
75
+	 * @see    parent::allow_empty_to_field() for documentation
76
+	 * @since  4.9.0
77
+	 * @return bool
78
+	 */
79
+	public function allow_empty_to_field()
80
+	{
81
+		return true;
82
+	}
83
+
84
+
85
+	/**
86
+	 * @see abstract declaration in EE_messenger for details.
87
+	 */
88
+	protected function _set_admin_pages()
89
+	{
90
+		$this->admin_registered_pages = array('events_edit' => true);
91
+	}
92
+
93
+
94
+	/**
95
+	 * @see abstract declaration in EE_messenger for details.
96
+	 */
97
+	protected function _set_valid_shortcodes()
98
+	{
99
+		$this->_valid_shortcodes = array();
100
+	}
101
+
102
+
103
+	/**
104
+	 * @see abstract declaration in EE_messenger for details.
105
+	 */
106
+	protected function _set_validator_config()
107
+	{
108
+		$this->_validator_config = array(
109
+			'subject' => array(
110
+				'shortcodes' => array('organization', 'primary_registration_details', 'email', 'transaction'),
111
+			),
112
+			'content' => array(
113
+				'shortcodes' => array(
114
+					'organization',
115
+					'primary_registration_list',
116
+					'primary_registration_details',
117
+					'email',
118
+					'transaction',
119
+					'event_list',
120
+					'payment_list',
121
+					'venue',
122
+					'line_item_list',
123
+					'messenger',
124
+					'ticket_list',
125
+				),
126
+			),
127
+			'event_list' => array(
128
+				'shortcodes' => array(
129
+					'event',
130
+					'ticket_list',
131
+					'venue',
132
+					'primary_registration_details',
133
+					'primary_registration_list',
134
+					'event_author',
135
+				),
136
+				'required' => array('[EVENT_LIST]'),
137
+			),
138
+			'ticket_list' => array(
139
+				'shortcodes' => array(
140
+					'attendee_list',
141
+					'ticket',
142
+					'datetime_list',
143
+					'primary_registration_details',
144
+					'line_item_list',
145
+					'venue',
146
+				),
147
+				'required' => array('[TICKET_LIST]'),
148
+			),
149
+			'ticket_line_item_no_pms' => array(
150
+				'shortcodes' => array('line_item', 'ticket'),
151
+				'required' => array('[TICKET_LINE_ITEM_LIST]'),
152
+			),
153
+			'ticket_line_item_pms' => array(
154
+				'shortcodes' => array('line_item', 'ticket', 'line_item_list'),
155
+				'required' => array('[TICKET_LINE_ITEM_LIST]'),
156
+			),
157
+			'price_modifier_line_item_list' => array(
158
+				'shortcodes' => array('line_item'),
159
+				'required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'),
160
+			),
161
+			'datetime_list' => array(
162
+				'shortcodes' => array('datetime'),
163
+				'required' => array('[DATETIME_LIST]'),
164
+			),
165
+			'attendee_list' => array(
166
+				'shortcodes' => array('attendee'),
167
+				'required' => array('[ATTENDEE_LIST]'),
168
+			),
169
+			'tax_line_item_list' => array(
170
+				'shortcodes' => array('line_item'),
171
+				'required' => array('[TAX_LINE_ITEM_LIST]'),
172
+			),
173
+			'additional_line_item_list' => array(
174
+				'shortcodes' => array('line_item'),
175
+				'required' => array('[ADDITIONAL_LINE_ITEM_LIST]'),
176
+			),
177
+			'payment_list' => array(
178
+				'shortcodes' => array('payment'),
179
+				'required' => array('[PAYMENT_LIST_*]'),
180
+			),
181
+		);
182
+	}
183
+
184
+
185
+	/**
186
+	 * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger
187
+	 * is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary
188
+	 * (i.e. swap out css files or something else).
189
+	 *
190
+	 * @since 4.5.0
191
+	 * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
192
+	 * @return void
193
+	 */
194
+	public function do_secondary_messenger_hooks($sending_messenger_name)
195
+	{
196
+		if ($sending_messenger_name === 'pdf') {
197
+			add_filter('EE_messenger__get_variation__variation', array($this, 'add_html_css'), 10, 8);
198
+		}
199
+	}
200
+
201
+
202
+	/**
203
+	 * @param                            $variation_path
204
+	 * @param \EE_Messages_Template_Pack $template_pack
205
+	 * @param                            $messenger_name
206
+	 * @param                            $message_type_name
207
+	 * @param                            $url
208
+	 * @param                            $type
209
+	 * @param                            $variation
210
+	 * @param                            $skip_filters
211
+	 * @return string
212
+	 */
213
+	public function add_html_css(
214
+		$variation_path,
215
+		EE_Messages_Template_Pack $template_pack,
216
+		$messenger_name,
217
+		$message_type_name,
218
+		$url,
219
+		$type,
220
+		$variation,
221
+		$skip_filters
222
+	) {
223
+		$variation = $template_pack->get_variation(
224
+			$this->name,
225
+			$message_type_name,
226
+			$type,
227
+			$variation,
228
+			$url,
229
+			'.css',
230
+			$skip_filters
231
+		);
232
+		return $variation;
233
+	}
234
+
235
+
236
+	/**
237
+	 * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this
238
+	 * messenger can add their own js.
239
+	 *
240
+	 * @return void.
241
+	 */
242
+	public function enqueue_scripts_styles()
243
+	{
244
+		parent::enqueue_scripts_styles();
245
+		do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles');
246
+	}
247
+
248
+
249
+	/**
250
+	 * _set_template_fields
251
+	 * This sets up the fields that a messenger requires for the message to go out.
252
+	 *
253
+	 * @access  protected
254
+	 * @return void
255
+	 */
256
+	protected function _set_template_fields()
257
+	{
258
+		// any extra template fields that are NOT used by the messenger
259
+		// but will get used by a messenger field for shortcode replacement
260
+		// get added to the 'extra' key in an associated array
261
+		// indexed by the messenger field they relate to.
262
+		// This is important for the Messages_admin to know what fields to display to the user.
263
+		// Also, notice that the "values" are equal to the field type
264
+		// that messages admin will use to know what kind of field to display.
265
+		// The values ALSO have one index labeled "shortcode".
266
+		// The values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE])
267
+		// is required in order for this extra field to be displayed.
268
+		//  If the required shortcode isn't part of the shortcodes array
269
+		// then the field is not needed and will not be displayed/parsed.
270
+		$this->_template_fields = array(
271
+			'subject' => array(
272
+				'input' => 'text',
273
+				'label' => esc_html__('Page Title', 'event_espresso'),
274
+				'type' => 'string',
275
+				'required' => true,
276
+				'validation' => true,
277
+				'css_class' => 'large-text',
278
+				'format' => '%s',
279
+			),
280
+			'content' => '',
281
+			// left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
282
+			'extra' => array(
283
+				'content' => array(
284
+					'main' => array(
285
+						'input' => 'wp_editor',
286
+						'label' => esc_html__('Main Content', 'event_espresso'),
287
+						'type' => 'string',
288
+						'required' => true,
289
+						'validation' => true,
290
+						'format' => '%s',
291
+						'rows' => '15',
292
+					),
293
+					'event_list' => array(
294
+						'input' => 'wp_editor',
295
+						'label' => '[EVENT_LIST]',
296
+						'type' => 'string',
297
+						'required' => true,
298
+						'validation' => true,
299
+						'format' => '%s',
300
+						'rows' => '15',
301
+						'shortcodes_required' => array('[EVENT_LIST]'),
302
+					),
303
+					'ticket_list' => array(
304
+						'input' => 'textarea',
305
+						'label' => '[TICKET_LIST]',
306
+						'type' => 'string',
307
+						'required' => true,
308
+						'validation' => true,
309
+						'format' => '%s',
310
+						'css_class' => 'large-text',
311
+						'rows' => '10',
312
+						'shortcodes_required' => array('[TICKET_LIST]'),
313
+					),
314
+					'ticket_line_item_no_pms' => array(
315
+						'input' => 'textarea',
316
+						'label' => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
317
+							'Ticket Line Item List with no Price Modifiers',
318
+							'event_espresso'
319
+						),
320
+						'type' => 'string',
321
+						'required' => false,
322
+						'validation' => true,
323
+						'format' => '%s',
324
+						'css_class' => 'large-text',
325
+						'rows' => '5',
326
+						'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'),
327
+					),
328
+					'ticket_line_item_pms' => array(
329
+						'input' => 'textarea',
330
+						'label' => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
331
+							'Ticket Line Item List with Price Modifiers',
332
+							'event_espresso'
333
+						),
334
+						'type' => 'string',
335
+						'required' => false,
336
+						'validation' => true,
337
+						'format' => '%s',
338
+						'css_class' => 'large-text',
339
+						'rows' => '5',
340
+						'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'),
341
+					),
342
+					'price_modifier_line_item_list' => array(
343
+						'input' => 'textarea',
344
+						'label' => '[PRICE_MODIFIER_LINE_ITEM_LIST]',
345
+						'type' => 'string',
346
+						'required' => false,
347
+						'validation' => true,
348
+						'format' => '%s',
349
+						'css_class' => 'large-text',
350
+						'rows' => '5',
351
+						'shortcodes_required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'),
352
+					),
353
+					'datetime_list' => array(
354
+						'input' => 'textarea',
355
+						'label' => '[DATETIME_LIST]',
356
+						'type' => 'string',
357
+						'required' => true,
358
+						'validation' => true,
359
+						'format' => '%s',
360
+						'css_class' => 'large-text',
361
+						'rows' => '5',
362
+						'shortcodes_required' => array('[DATETIME_LIST]'),
363
+					),
364
+					'attendee_list' => array(
365
+						'input' => 'textarea',
366
+						'label' => '[ATTENDEE_LIST]',
367
+						'type' => 'string',
368
+						'required' => true,
369
+						'validation' => true,
370
+						'format' => '%s',
371
+						'css_class' => 'large-text',
372
+						'rows' => '5',
373
+						'shortcodes_required' => array('[ATTENDEE_LIST]'),
374
+					),
375
+					'tax_line_item_list' => array(
376
+						'input' => 'textarea',
377
+						'label' => '[TAX_LINE_ITEM_LIST]',
378
+						'type' => 'string',
379
+						'required' => false,
380
+						'validation' => true,
381
+						'format' => '%s',
382
+						'css_class' => 'large-text',
383
+						'rows' => '5',
384
+						'shortcodes_required' => array('[TAX_LINE_ITEM_LIST]'),
385
+					),
386
+					'additional_line_item_list' => array(
387
+						'input' => 'textarea',
388
+						'label' => '[ADDITIONAL_LINE_ITEM_LIST]',
389
+						'type' => 'string',
390
+						'required' => false,
391
+						'validation' => true,
392
+						'format' => '%s',
393
+						'css_class' => 'large-text',
394
+						'rows' => '5',
395
+						'shortcodes_required' => array('[ADDITIONAL_LINE_ITEM_LIST]'),
396
+					),
397
+					'payment_list' => array(
398
+						'input' => 'textarea',
399
+						'label' => '[PAYMENT_LIST]',
400
+						'type' => 'string',
401
+						'required' => true,
402
+						'validation' => true,
403
+						'format' => '%s',
404
+						'css_class' => 'large-text',
405
+						'rows' => '5',
406
+						'shortcodes_required' => array('[PAYMENT_LIST_*]'),
407
+					),
408
+				),
409
+			),
410
+		);
411
+	}
412
+
413
+
414
+	/**
415
+	 * @see   definition of this method in parent
416
+	 * @since 4.5.0
417
+	 */
418
+	protected function _set_default_message_types()
419
+	{
420
+		$this->_default_message_types = array('receipt', 'invoice');
421
+	}
422
+
423
+
424
+	/**
425
+	 * @see   definition of this method in parent
426
+	 * @since 4.5.0
427
+	 */
428
+	protected function _set_valid_message_types()
429
+	{
430
+		$this->_valid_message_types = array('receipt', 'invoice');
431
+	}
432
+
433
+
434
+	/**
435
+	 * Displays the message in the browser.
436
+	 *
437
+	 * @since 4.5.0
438
+	 * @return string.
439
+	 */
440
+	protected function _send_message()
441
+	{
442
+		$this->_template_args = array(
443
+			'page_title' => $this->_subject,
444
+			'base_css' => $this->get_variation(
445
+				$this->_tmp_pack,
446
+				$this->_incoming_message_type->name,
447
+				true,
448
+				'base',
449
+				$this->_variation
450
+			),
451
+			'print_css' => $this->get_variation(
452
+				$this->_tmp_pack,
453
+				$this->_incoming_message_type->name,
454
+				true,
455
+				'print',
456
+				$this->_variation
457
+			),
458
+			'main_css' => $this->get_variation(
459
+				$this->_tmp_pack,
460
+				$this->_incoming_message_type->name,
461
+				true,
462
+				'main',
463
+				$this->_variation
464
+			),
465
+			'main_body' => wpautop(
466
+				apply_filters(
467
+					'FHEE__EE_Html_messenger___send_message__main_body',
468
+					$this->_content,
469
+					$this->_content,
470
+					$this->_incoming_message_type
471
+				)
472
+			)
473
+		);
474
+		$this->_deregister_wp_hooks();
475
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
476
+		echo $this->_get_main_template(); // already escaped
477
+		exit();
478
+	}
479
+
480
+
481
+	/**
482
+	 * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't
483
+	 * interfere with our templates.  If users want to add any custom styles or scripts they must use the
484
+	 * AHEE__EE_Html_messenger__enqueue_scripts_styles hook.
485
+	 *
486
+	 * @since 4.5.0
487
+	 * @return void
488
+	 */
489
+	protected function _deregister_wp_hooks()
490
+	{
491
+		remove_all_actions('wp_head');
492
+		remove_all_actions('wp_footer');
493
+		remove_all_actions('wp_print_footer_scripts');
494
+		remove_all_actions('wp_enqueue_scripts');
495
+		global $wp_scripts, $wp_styles;
496
+		$wp_scripts = $wp_styles = array();
497
+		// just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
498
+		add_action('wp_footer', 'wp_print_footer_scripts');
499
+		add_action('wp_print_footer_scripts', '_wp_footer_scripts');
500
+		add_action('wp_head', 'wp_enqueue_scripts');
501
+	}
502
+
503
+
504
+	/**
505
+	 * Overwrite parent _get_main_template for display_html purposes.
506
+	 *
507
+	 * @since  4.5.0
508
+	 * @param bool $preview
509
+	 * @return string
510
+	 */
511
+	protected function _get_main_template($preview = false)
512
+	{
513
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main');
514
+		// include message type as a template arg
515
+		$this->_template_args['message_type'] = $this->_incoming_message_type;
516
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
517
+	}
518
+
519
+
520
+	/**
521
+	 * @return string
522
+	 */
523
+	protected function _preview()
524
+	{
525
+		return $this->_send_message();
526
+	}
527
+
528
+
529
+	protected function _set_admin_settings_fields()
530
+	{
531
+	}
532
+
533
+
534
+	/**
535
+	 * add the "powered by EE" credit link to the HTML receipt and invoice
536
+	 *
537
+	 * @param string $content
538
+	 * @param string $content_again
539
+	 * @param \EE_message_type $incoming_message_type
540
+	 * @return string
541
+	 */
542
+	public function add_powered_by_credit_link_to_receipt_and_invoice(
543
+		$content = '',
544
+		$content_again = '',
545
+		EE_message_type $incoming_message_type
546
+	) {
547
+		if (
548
+			($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt')
549
+			&& apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true)
550
+		) {
551
+			$content .= \EEH_Template::powered_by_event_espresso(
552
+				'aln-cntr',
553
+				'',
554
+				array('utm_content' => 'messages_system')
555
+			)
556
+				. EEH_HTML::div(EEH_HTML::p('&nbsp;'));
557
+		}
558
+		return $content;
559
+	}
560 560
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_messenger.lib.php 2 patches
Indentation   +735 added lines, -735 removed lines patch added patch discarded remove patch
@@ -19,182 +19,182 @@  discard block
 block discarded – undo
19 19
 
20 20
 
21 21
 
22
-    /**
23
-     * This property holds the default message types associated with this messenger when it is activated. The values of the array must match a valid message type.
24
-     * This property gets set by the _set_default_message_types() method.
25
-     *
26
-     * @var array
27
-     */
28
-    protected $_default_message_types = array();
22
+	/**
23
+	 * This property holds the default message types associated with this messenger when it is activated. The values of the array must match a valid message type.
24
+	 * This property gets set by the _set_default_message_types() method.
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected $_default_message_types = array();
29 29
 
30 30
 
31 31
 
32 32
 
33
-    /**
34
-     * This property holds the message types that are valid for use with this messenger.
35
-     * It gets set by the _set_valid_message_types() method.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $_valid_message_types = array();
33
+	/**
34
+	 * This property holds the message types that are valid for use with this messenger.
35
+	 * It gets set by the _set_valid_message_types() method.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $_valid_message_types = array();
40 40
 
41 41
 
42 42
 
43
-    /**
44
-     * Holds the configuration for the EE_Messages_Validator class to know how to validated the different fields. Note that the Validator will match each field here with the allowed shortcodes set in the "valid_shortcodes" array for the matched message type context.  So message types don't need to set a $_validator_config property.
45
-     *
46
-     * Remember, ALL fields must be declared in this array.  However, an empty value for the field means that the field will accept all valid shortcodes set for the given context in the message type (by default).
47
-     *
48
-     * Array should be in this format:
49
-     *
50
-     * array(
51
-     *  'field_name(i.e.to)' => array(
52
-     *      'shortcodes' => array('email'), //an array of shortcode groups (correspond to EE_Shortcodes library class) that are allowed in the field. Typically you can just include $this->_valid_shortcodes['field_name'] as the value here (because they will match).
53
-     *      'specific_shortcodes' => array( array('[EVENT_AUTHOR_EMAIL]' => esc_html__('Admin Email', 'event_espresso')), //if this index is present you can further restrict the field to ONLY specific shortcodes if an entire group isn't sufficient. Specific shortcodes need to be listed as an array with the index the shortcode and the value = the label.
54
-     *      'type' => 'email' //this is the field type and should match one of the validator types (see EE_Messages_Validator::validator() for all the possible types).  If not required you can just leave empty.,
55
-     *      'required' => array'[SHORTCODE]') //this is used to indicate the shortcodes that MUST be in the assembled array of shortcodes by the validator in order for this field to be included in validation.  Otherwise the validator will always assign shortcodes for this field (regardless of whether the field settings for the given messenger/message_type/context use the field or not.).. please note, this does NOT mean that the shortcodes listed here MUST be in the given field.
56
-     *  )
57
-     * )
58
-     *
59
-     * @var array
60
-     */
61
-    protected $_validator_config = array();
43
+	/**
44
+	 * Holds the configuration for the EE_Messages_Validator class to know how to validated the different fields. Note that the Validator will match each field here with the allowed shortcodes set in the "valid_shortcodes" array for the matched message type context.  So message types don't need to set a $_validator_config property.
45
+	 *
46
+	 * Remember, ALL fields must be declared in this array.  However, an empty value for the field means that the field will accept all valid shortcodes set for the given context in the message type (by default).
47
+	 *
48
+	 * Array should be in this format:
49
+	 *
50
+	 * array(
51
+	 *  'field_name(i.e.to)' => array(
52
+	 *      'shortcodes' => array('email'), //an array of shortcode groups (correspond to EE_Shortcodes library class) that are allowed in the field. Typically you can just include $this->_valid_shortcodes['field_name'] as the value here (because they will match).
53
+	 *      'specific_shortcodes' => array( array('[EVENT_AUTHOR_EMAIL]' => esc_html__('Admin Email', 'event_espresso')), //if this index is present you can further restrict the field to ONLY specific shortcodes if an entire group isn't sufficient. Specific shortcodes need to be listed as an array with the index the shortcode and the value = the label.
54
+	 *      'type' => 'email' //this is the field type and should match one of the validator types (see EE_Messages_Validator::validator() for all the possible types).  If not required you can just leave empty.,
55
+	 *      'required' => array'[SHORTCODE]') //this is used to indicate the shortcodes that MUST be in the assembled array of shortcodes by the validator in order for this field to be included in validation.  Otherwise the validator will always assign shortcodes for this field (regardless of whether the field settings for the given messenger/message_type/context use the field or not.).. please note, this does NOT mean that the shortcodes listed here MUST be in the given field.
56
+	 *  )
57
+	 * )
58
+	 *
59
+	 * @var array
60
+	 */
61
+	protected $_validator_config = array();
62 62
 
63 63
 
64 64
 
65
-    /**
66
-     * This will hold the EEM_message_templates model for interacting with the database and retrieving active templates for the messenger
67
-     * @var object
68
-     */
69
-    protected $_EEM_data;
65
+	/**
66
+	 * This will hold the EEM_message_templates model for interacting with the database and retrieving active templates for the messenger
67
+	 * @var object
68
+	 */
69
+	protected $_EEM_data;
70 70
 
71 71
 
72 72
 
73
-    /**
74
-     * this property just holds an array of the various template refs.
75
-     * @var array
76
-     */
77
-    protected $_template_fields = array();
73
+	/**
74
+	 * this property just holds an array of the various template refs.
75
+	 * @var array
76
+	 */
77
+	protected $_template_fields = array();
78 78
 
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * This holds an array of the arguments used in parsing a template for the sender.
84
-     * @var array
85
-     */
86
-    protected $_template_args = array();
82
+	/**
83
+	 * This holds an array of the arguments used in parsing a template for the sender.
84
+	 * @var array
85
+	 */
86
+	protected $_template_args = array();
87 87
 
88 88
 
89 89
 
90 90
 
91 91
 
92 92
 
93
-    /**
94
-     * This property will hold the configuration for any test settings fields that are required for the "test" button that is used to trigger an actual test of this messenger
95
-     *
96
-     * @protected
97
-     * @var array
98
-     */
99
-    protected $_test_settings_fields = array();
93
+	/**
94
+	 * This property will hold the configuration for any test settings fields that are required for the "test" button that is used to trigger an actual test of this messenger
95
+	 *
96
+	 * @protected
97
+	 * @var array
98
+	 */
99
+	protected $_test_settings_fields = array();
100 100
 
101 101
 
102 102
 
103 103
 
104 104
 
105 105
 
106
-    /**
107
-     * This will hold the EE_Messages_Template_Pack object when set on the messenger.  This is set via the validate and setup method which grabs the template pack from the incoming messages object.
108
-     *
109
-     * @since 4.5.0
110
-     *
111
-     * @var EE_Messages_Template_Pack
112
-     */
113
-    protected $_tmp_pack;
106
+	/**
107
+	 * This will hold the EE_Messages_Template_Pack object when set on the messenger.  This is set via the validate and setup method which grabs the template pack from the incoming messages object.
108
+	 *
109
+	 * @since 4.5.0
110
+	 *
111
+	 * @var EE_Messages_Template_Pack
112
+	 */
113
+	protected $_tmp_pack;
114 114
 
115 115
 
116 116
 
117 117
 
118
-    /**
119
-     * This will hold the variation to use when performing a send.  It is set via the validate and setup method which grabs the variation from the incoming messages object on the send method.
120
-     *
121
-     * @since 4.5.0
122
-     *
123
-     * @var string
124
-     */
125
-    protected $_variation;
118
+	/**
119
+	 * This will hold the variation to use when performing a send.  It is set via the validate and setup method which grabs the variation from the incoming messages object on the send method.
120
+	 *
121
+	 * @since 4.5.0
122
+	 *
123
+	 * @var string
124
+	 */
125
+	protected $_variation;
126 126
 
127 127
 
128 128
 
129 129
 
130 130
 
131
-    /**
132
-     * This property is a stdClass that holds labels for all the various supporting properties for this messenger.  These labels are set via the _set_supports_labels() method in children classes. Initially this will include the label for:
133
-     *
134
-     *  - template pack
135
-     *  - template variation
136
-     *
137
-     * @since 4.5.0
138
-     *
139
-     * @var stdClass
140
-     */
141
-    protected $_supports_labels;
131
+	/**
132
+	 * This property is a stdClass that holds labels for all the various supporting properties for this messenger.  These labels are set via the _set_supports_labels() method in children classes. Initially this will include the label for:
133
+	 *
134
+	 *  - template pack
135
+	 *  - template variation
136
+	 *
137
+	 * @since 4.5.0
138
+	 *
139
+	 * @var stdClass
140
+	 */
141
+	protected $_supports_labels;
142 142
 
143 143
 
144 144
 
145 145
 
146 146
 
147
-    /**
148
-     * This property is set when the send_message() method is called and holds the Message Type used to generate templates with this messenger for the messages.
149
-     *
150
-     * @var EE_message_type
151
-     */
152
-    protected $_incoming_message_type;
147
+	/**
148
+	 * This property is set when the send_message() method is called and holds the Message Type used to generate templates with this messenger for the messages.
149
+	 *
150
+	 * @var EE_message_type
151
+	 */
152
+	protected $_incoming_message_type;
153 153
 
154 154
 
155 155
 
156
-    /**
157
-     * This flag sets whether a messenger is activated by default  on installation (or reactivation) of EE core or not.
158
-     *
159
-     * @var bool
160
-     */
161
-    public $activate_on_install = false;
156
+	/**
157
+	 * This flag sets whether a messenger is activated by default  on installation (or reactivation) of EE core or not.
158
+	 *
159
+	 * @var bool
160
+	 */
161
+	public $activate_on_install = false;
162 162
 
163 163
 
164 164
 
165 165
 
166 166
 
167
-    public function __construct()
168
-    {
169
-        $this->_EEM_data = EEM_Message_Template_Group::instance();
170
-        $this->_messages_item_type = 'messenger';
167
+	public function __construct()
168
+	{
169
+		$this->_EEM_data = EEM_Message_Template_Group::instance();
170
+		$this->_messages_item_type = 'messenger';
171 171
 
172
-        parent::__construct();
172
+		parent::__construct();
173 173
 
174
-        $this->_set_test_settings_fields();
175
-        $this->_set_template_fields();
176
-        $this->_set_default_message_types();
177
-        $this->_set_valid_message_types();
178
-        $this->_set_validator_config();
174
+		$this->_set_test_settings_fields();
175
+		$this->_set_template_fields();
176
+		$this->_set_default_message_types();
177
+		$this->_set_valid_message_types();
178
+		$this->_set_validator_config();
179 179
 
180 180
 
181
-        $this->_supports_labels = new stdClass();
182
-        $this->_set_supports_labels();
183
-    }
181
+		$this->_supports_labels = new stdClass();
182
+		$this->_set_supports_labels();
183
+	}
184 184
 
185 185
 
186 186
 
187 187
 
188 188
 
189
-    /**
190
-     * _set_template_fields
191
-     * This sets up the fields that a messenger requires for the message to go out.
192
-     *
193
-     * @abstract
194
-     * @access  protected
195
-     * @return void
196
-     */
197
-    abstract protected function _set_template_fields();
189
+	/**
190
+	 * _set_template_fields
191
+	 * This sets up the fields that a messenger requires for the message to go out.
192
+	 *
193
+	 * @abstract
194
+	 * @access  protected
195
+	 * @return void
196
+	 */
197
+	abstract protected function _set_template_fields();
198 198
 
199 199
 
200 200
 
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 
205 205
 
206 206
 
207
-    /**
208
-     * This method sets the _default_message_type property (see definition in docs attached to property)
209
-     *
210
-     * @abstract
211
-     * @access protected
212
-     * @return void
213
-     */
214
-    abstract protected function _set_default_message_types();
207
+	/**
208
+	 * This method sets the _default_message_type property (see definition in docs attached to property)
209
+	 *
210
+	 * @abstract
211
+	 * @access protected
212
+	 * @return void
213
+	 */
214
+	abstract protected function _set_default_message_types();
215 215
 
216 216
 
217 217
 
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 
220 220
 
221 221
 
222
-    /**
223
-     * Sets the _valid_message_types property (see definition in cods attached to property)
224
-     *
225
-     * @since 4.5.0
226
-     *
227
-     * @abstract
228
-     * @return void
229
-     */
230
-    abstract protected function _set_valid_message_types();
222
+	/**
223
+	 * Sets the _valid_message_types property (see definition in cods attached to property)
224
+	 *
225
+	 * @since 4.5.0
226
+	 *
227
+	 * @abstract
228
+	 * @return void
229
+	 */
230
+	abstract protected function _set_valid_message_types();
231 231
 
232 232
 
233 233
 
@@ -235,171 +235,171 @@  discard block
 block discarded – undo
235 235
 
236 236
 
237 237
 
238
-    /**
239
-     * Child classes must declare the $_validator_config property using this method.
240
-     * See comments for $_validator_config for details on what it is used for.
241
-     *
242
-     * NOTE:  messengers should set an array of valid shortcodes for ALL scenarios.  The corresponding validator class (validators/{messenger}) can be used to restrict only certain shortcodes per template so users cannot add certain shortcodes.
243
-     *
244
-     * @access protected
245
-     * @return void
246
-     */
247
-    abstract protected function _set_validator_config();
238
+	/**
239
+	 * Child classes must declare the $_validator_config property using this method.
240
+	 * See comments for $_validator_config for details on what it is used for.
241
+	 *
242
+	 * NOTE:  messengers should set an array of valid shortcodes for ALL scenarios.  The corresponding validator class (validators/{messenger}) can be used to restrict only certain shortcodes per template so users cannot add certain shortcodes.
243
+	 *
244
+	 * @access protected
245
+	 * @return void
246
+	 */
247
+	abstract protected function _set_validator_config();
248 248
 
249 249
 
250 250
 
251 251
 
252 252
 
253 253
 
254
-    /**
255
-     * We just deliver the messages don't kill us!!  This method will need to be modified by child classes for whatever action is taken to actually send a message.
256
-     *
257
-     * @return bool|WP_Error
258
-     * @throw \Exception
259
-     */
260
-    abstract protected function _send_message();
254
+	/**
255
+	 * We just deliver the messages don't kill us!!  This method will need to be modified by child classes for whatever action is taken to actually send a message.
256
+	 *
257
+	 * @return bool|WP_Error
258
+	 * @throw \Exception
259
+	 */
260
+	abstract protected function _send_message();
261 261
 
262 262
 
263 263
 
264 264
 
265
-    /**
266
-     * We give you pretty previews of the messages!
267
-     * @return string html body for message content.
268
-     */
269
-    abstract protected function _preview();
265
+	/**
266
+	 * We give you pretty previews of the messages!
267
+	 * @return string html body for message content.
268
+	 */
269
+	abstract protected function _preview();
270 270
 
271 271
 
272 272
 
273 273
 
274
-    /**
275
-     * Used by messengers (or preview) for enqueueing any scripts or styles need in message generation.
276
-     *
277
-     * @since 4.5.0
278
-     *
279
-     * @return void
280
-     */
281
-    public function enqueue_scripts_styles()
282
-    {
283
-        do_action('AHEE__EE_messenger__enqueue_scripts_styles');
284
-    }
274
+	/**
275
+	 * Used by messengers (or preview) for enqueueing any scripts or styles need in message generation.
276
+	 *
277
+	 * @since 4.5.0
278
+	 *
279
+	 * @return void
280
+	 */
281
+	public function enqueue_scripts_styles()
282
+	{
283
+		do_action('AHEE__EE_messenger__enqueue_scripts_styles');
284
+	}
285 285
 
286 286
 
287 287
 
288 288
 
289 289
 
290
-    /**
291
-     * This is used to indicate whether a messenger must be sent immediately or not.
292
-     * eg. The HTML messenger will override this to return true because it should be displayed in user's browser right
293
-     * away.  The PDF messenger is similar.
294
-     *
295
-     * This flag thus overrides any priorities that may be set on the message type used to generate the message.
296
-     *
297
-     * Default for this is false.  So children classes must override this if they want a message to be executed immediately.
298
-     *
299
-     * @since  4.9.0
300
-     * @return bool
301
-     */
302
-    public function send_now()
303
-    {
304
-        return false;
305
-    }
290
+	/**
291
+	 * This is used to indicate whether a messenger must be sent immediately or not.
292
+	 * eg. The HTML messenger will override this to return true because it should be displayed in user's browser right
293
+	 * away.  The PDF messenger is similar.
294
+	 *
295
+	 * This flag thus overrides any priorities that may be set on the message type used to generate the message.
296
+	 *
297
+	 * Default for this is false.  So children classes must override this if they want a message to be executed immediately.
298
+	 *
299
+	 * @since  4.9.0
300
+	 * @return bool
301
+	 */
302
+	public function send_now()
303
+	{
304
+		return false;
305
+	}
306 306
 
307 307
 
308 308
 
309 309
 
310 310
 
311
-    /**
312
-     * This is a way for a messenger to indicate whether it allows an empty to field or not.
313
-     * Note: If the generated message is a for a preview, this value is ignored.
314
-     * @since 4.9.0
315
-     * @return bool
316
-     */
317
-    public function allow_empty_to_field()
318
-    {
319
-        return false;
320
-    }
311
+	/**
312
+	 * This is a way for a messenger to indicate whether it allows an empty to field or not.
313
+	 * Note: If the generated message is a for a preview, this value is ignored.
314
+	 * @since 4.9.0
315
+	 * @return bool
316
+	 */
317
+	public function allow_empty_to_field()
318
+	{
319
+		return false;
320
+	}
321 321
 
322 322
 
323 323
 
324 324
 
325 325
 
326
-    /**
327
-     * Sets the defaults for the _supports_labels property.  Can be overridden by child classes.
328
-     * @see property definition for info on how its formatted.
329
-     *
330
-     * @since 4.5.0;
331
-     * @return void
332
-     */
333
-    protected function _set_supports_labels()
334
-    {
335
-        $this->_set_supports_labels_defaults();
336
-    }
326
+	/**
327
+	 * Sets the defaults for the _supports_labels property.  Can be overridden by child classes.
328
+	 * @see property definition for info on how its formatted.
329
+	 *
330
+	 * @since 4.5.0;
331
+	 * @return void
332
+	 */
333
+	protected function _set_supports_labels()
334
+	{
335
+		$this->_set_supports_labels_defaults();
336
+	}
337 337
 
338 338
 
339 339
 
340 340
 
341 341
 
342
-    /**
343
-     * Sets the defaults for the _supports_labels property.
344
-     *
345
-     * @since 4.5.0
346
-     *
347
-     * @return void
348
-     */
349
-    private function _set_supports_labels_defaults()
350
-    {
351
-        $this->_supports_labels->template_pack = esc_html__('Template Structure', 'event_espresso');
352
-        $this->_supports_labels->template_variation = esc_html__('Template Style', 'event_espresso');
353
-        $this->_supports_labels->template_pack_description = esc_html__('Template Structure options are bundled structural changes for templates.', 'event_espresso');
342
+	/**
343
+	 * Sets the defaults for the _supports_labels property.
344
+	 *
345
+	 * @since 4.5.0
346
+	 *
347
+	 * @return void
348
+	 */
349
+	private function _set_supports_labels_defaults()
350
+	{
351
+		$this->_supports_labels->template_pack = esc_html__('Template Structure', 'event_espresso');
352
+		$this->_supports_labels->template_variation = esc_html__('Template Style', 'event_espresso');
353
+		$this->_supports_labels->template_pack_description = esc_html__('Template Structure options are bundled structural changes for templates.', 'event_espresso');
354 354
 
355
-        $this->_supports_labels->template_variation_description = esc_html__('These are different styles to choose from for the selected template structure.  Usually these affect things like font style, color, borders etc.  In some cases the styles will also make minor layout changes.', 'event_espresso');
355
+		$this->_supports_labels->template_variation_description = esc_html__('These are different styles to choose from for the selected template structure.  Usually these affect things like font style, color, borders etc.  In some cases the styles will also make minor layout changes.', 'event_espresso');
356 356
 
357
-        $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
358
-    }
357
+		$this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
358
+	}
359 359
 
360 360
 
361 361
 
362 362
 
363 363
 
364
-    /**
365
-     * This returns the _supports_labels property.
366
-     *
367
-     * @since 4.5.0
368
-     *
369
-     * @return stdClass
370
-     */
371
-    public function get_supports_labels()
372
-    {
373
-        if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
374
-            $this->_set_supports_labels_defaults();
375
-        }
376
-        return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
377
-    }
364
+	/**
365
+	 * This returns the _supports_labels property.
366
+	 *
367
+	 * @since 4.5.0
368
+	 *
369
+	 * @return stdClass
370
+	 */
371
+	public function get_supports_labels()
372
+	{
373
+		if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
374
+			$this->_set_supports_labels_defaults();
375
+		}
376
+		return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
377
+	}
378 378
 
379 379
 
380 380
 
381 381
 
382
-    /**
383
-     * Used to retrieve a variation (typically the path/url to a css file)
384
-     *
385
-     * @since 4.5.0
386
-     *
387
-     * @param EE_Messages_Template_Pack $pack   The template pack used for retrieving the variation.
388
-     * @param string                    $message_type_name The name property of the message type that we need the variation for.
389
-     * @param bool                      $url   Whether to return url (true) or path (false). Default is false.
390
-     * @param string                    $type What variation type to return. Default is 'main'.
391
-     * @param string               $variation What variation for the template pack
392
-     * @param bool             $skip_filters This allows messengers to add a filter for another messengers get_variation but call skip filters on the callback so there is no recursion on apply_filters.
393
-     *
394
-     * @return string                    path or url for the requested variation.
395
-     */
396
-    public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = false, $type = 'main', $variation = 'default', $skip_filters = false)
397
-    {
398
-        $this->_tmp_pack = $pack;
399
-        $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
400
-        $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
401
-        return $variation_path;
402
-    }
382
+	/**
383
+	 * Used to retrieve a variation (typically the path/url to a css file)
384
+	 *
385
+	 * @since 4.5.0
386
+	 *
387
+	 * @param EE_Messages_Template_Pack $pack   The template pack used for retrieving the variation.
388
+	 * @param string                    $message_type_name The name property of the message type that we need the variation for.
389
+	 * @param bool                      $url   Whether to return url (true) or path (false). Default is false.
390
+	 * @param string                    $type What variation type to return. Default is 'main'.
391
+	 * @param string               $variation What variation for the template pack
392
+	 * @param bool             $skip_filters This allows messengers to add a filter for another messengers get_variation but call skip filters on the callback so there is no recursion on apply_filters.
393
+	 *
394
+	 * @return string                    path or url for the requested variation.
395
+	 */
396
+	public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = false, $type = 'main', $variation = 'default', $skip_filters = false)
397
+	{
398
+		$this->_tmp_pack = $pack;
399
+		$variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
400
+		$variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
401
+		return $variation_path;
402
+	}
403 403
 
404 404
 
405 405
 
@@ -407,492 +407,492 @@  discard block
 block discarded – undo
407 407
 
408 408
 
409 409
 
410
-    /**
411
-     * This just returns the default message types associated with this messenger when it is first activated.
412
-     *
413
-     * @access public
414
-     * @return array
415
-     */
416
-    public function get_default_message_types()
417
-    {
418
-        $class = get_class($this);
410
+	/**
411
+	 * This just returns the default message types associated with this messenger when it is first activated.
412
+	 *
413
+	 * @access public
414
+	 * @return array
415
+	 */
416
+	public function get_default_message_types()
417
+	{
418
+		$class = get_class($this);
419 419
 
420
-        // messenger specific filter
421
-        $default_types = apply_filters('FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this);
420
+		// messenger specific filter
421
+		$default_types = apply_filters('FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this);
422 422
 
423
-        // all messengers filter
424
-        $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
425
-        return $default_types;
426
-    }
423
+		// all messengers filter
424
+		$default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
425
+		return $default_types;
426
+	}
427 427
 
428 428
 
429 429
 
430 430
 
431
-    /**
432
-     * Returns the valid message types associated with this messenger.
433
-     *
434
-     * @since 4.5.0
435
-     *
436
-     * @return array
437
-     */
438
-    public function get_valid_message_types()
439
-    {
440
-        $class = get_class($this);
441
-
442
-        // messenger specific filter
443
-        // messenger specific filter
444
-        $valid_types = apply_filters('FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
445
-
446
-        // all messengers filter
447
-        $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
448
-        return $valid_types;
449
-    }
450
-
451
-
452
-
453
-
454
-
455
-    /**
456
-     * this is just used by the custom validators (EE_Messages_Validator classes) to modify the _validator_config for certain message_type/messenger combos where a context may only use certain shortcodes etc.
457
-     *
458
-     * @access public
459
-     * @param array $new_config Whatever is put in here will reset the _validator_config property
460
-     */
461
-    public function set_validator_config($new_config)
462
-    {
463
-        $this->_validator_config = $new_config;
464
-    }
465
-
466
-
467
-
468
-
469
-    /**
470
-     * This returns the _validator_config property
471
-     *
472
-     * @access public
473
-     * @return array
474
-     */
475
-    public function get_validator_config()
476
-    {
477
-        $class = get_class($this);
478
-
479
-        $config = apply_filters('FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this);
480
-        $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
481
-        return $config;
482
-    }
483
-
484
-
485
-
486
-
487
-    /**
488
-     * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class callback function if that page is registered via the `_admin_registered_page` property set by the child class.
489
-     *
490
-     * @param string $page the slug of the EE admin page
491
-     * @param array $message_types an array of active message type objects
492
-     * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages)
493
-     * @param array $extra  This is just an extra argument that can be used to pass additional data for setting up page content.
494
-     * @access public
495
-     * @return string content for page
496
-     */
497
-    public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array())
498
-    {
499
-        return $this->_get_admin_page_content($page, $action, $extra, $message_types);
500
-    }
501
-
502
-
503
-
504
-    /**
505
-     * @param $message_types
506
-     * @param array $extra
507
-     * @return mixed|string
508
-     */
509
-    protected function _get_admin_content_events_edit($message_types, $extra)
510
-    {
511
-        // defaults
512
-        $template_args = array();
513
-        $selector_rows = '';
514
-
515
-        // we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
516
-        $event_id = isset($extra['event']) ? $extra['event'] : null;
517
-
518
-        $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
519
-        $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
520
-
521
-        // array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
522
-        $global_templates = EEM_Message_Template_Group::instance()->get_all(
523
-            array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
524
-        );
525
-        $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
526
-            $event_id,
527
-            array(
528
-                'MTP_messenger' => $this->name,
529
-                'MTP_is_active' => true
530
-            )
531
-        );
532
-        $templates_for_event = !empty($templates_for_event) ? $templates_for_event : array();
533
-
534
-        // so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
535
-        foreach ($global_templates as $mtpgID => $mtpg) {
536
-            if ($mtpg instanceof EE_Message_Template_Group) {
537
-                // verify this message type is supposed to show on this page
538
-                $mtp_obj = $mtpg->message_type_obj();
539
-                if (! $mtp_obj instanceof EE_message_type) {
540
-                    continue;
541
-                }
542
-                $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
543
-                if (! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
544
-                    continue;
545
-                }
546
-                $select_values = array();
547
-                $select_values[ $mtpgID ] = esc_html__('Global', 'event_espresso');
548
-                $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
549
-                // if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
550
-                if (! $mtpg->get('MTP_is_override')) {
551
-                    // any custom templates for this message type?
552
-                    $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
553
-                    foreach ($custom_templates as $cmtpgID => $cmtpg) {
554
-                        $select_values[ $cmtpgID ] = $cmtpg->name();
555
-                        $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
556
-                    }
557
-                }
558
-                // if there is no $default_value then we set it as the global
559
-                $default_value = empty($default_value) ? $mtpgID : $default_value;
560
-                $edit_url_query_args = [
561
-                    'page' => 'espresso_messages',
562
-                    'action' => 'edit_message_template',
563
-                    'id' => $default_value,
564
-                    'evt_id' => $event_id
565
-                ];
566
-                $edit_url = EEH_URL::add_query_args_and_nonce($edit_url_query_args, admin_url('admin.php'));
567
-                $create_url_query_args = [
568
-                    'page' => 'espresso_messages',
569
-                    'action' => 'add_new_message_template',
570
-                    'GRP_ID' => $default_value
571
-                ];
572
-                $create_url = EEH_URL::add_query_args_and_nonce($create_url_query_args, admin_url('admin.php'));
573
-                $st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
574
-                $st_args['mt_slug'] = $mtpg->message_type();
575
-                $st_args['messenger_slug'] = $this->name;
576
-                $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector');
577
-                // note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
578
-                $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . esc_html__('Create New Custom', 'event_espresso') . '</a>';
579
-                $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : '';
580
-                $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . esc_html__('Edit', 'event_espresso') . '</a>' : '';
581
-                $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
582
-            }
583
-        }
584
-
585
-        // if no selectors present then get out.
586
-        if (empty($selector_rows)) {
587
-            return '';
588
-        }
589
-
590
-        $template_args['selector_rows'] = $selector_rows;
591
-        return EEH_Template::display_template($template_wrapper_path, $template_args, true);
592
-    }
593
-
594
-
595
-
596
-
597
-
598
-
599
-    /**
600
-     * get_template_fields
601
-     *
602
-     * @access public
603
-     * @return array $this->_template_fields
604
-     */
605
-    public function get_template_fields()
606
-    {
607
-        $template_fields = apply_filters('FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this);
608
-        $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
609
-        return $template_fields;
610
-    }
611
-
612
-
613
-
614
-
615
-    /** SETUP METHODS **/
616
-    /**
617
-     * The following method doesn't NEED to be used by child classes but might be modified by the specific messenger
618
-     * @param string $item
619
-     * @param mixed $value
620
-     */
621
-    protected function _set_template_value($item, $value)
622
-    {
623
-        if (array_key_exists($item, $this->_template_fields)) {
624
-            $prop = '_' . $item;
625
-            $this->{$prop} = $value;
626
-        }
627
-    }
628
-
629
-    /**
630
-     * Sets up the message for sending.
631
-     *
632
-     * @param  EE_message $message the message object that contains details about the message.
633
-     * @param EE_message_type $message_type The message type object used in combination with this messenger to generate the provided message.
634
-     *
635
-     * @return bool Very important that all messengers return bool for successful send or not.  Error messages can be
636
-     *              added to EE_Error.
637
-     *              true = message sent successfully
638
-     *              false = message not sent but can be retried (i.e. the failure might be just due to communication issues at the time of send).
639
-     *              Throwing a SendMessageException means the message failed sending and cannot be retried.
640
-     *
641
-     * @throws SendMessageException
642
-     */
643
-    final public function send_message($message, EE_message_type $message_type)
644
-    {
645
-        try {
646
-            $this->_validate_and_setup($message);
647
-            $this->_incoming_message_type = $message_type;
648
-            $response = $this->_send_message();
649
-            if ($response instanceof WP_Error) {
650
-                EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
651
-                $response = false;
652
-            }
653
-        } catch (\Exception $e) {
654
-            // convert to an instance of SendMessageException
655
-            throw new SendMessageException($e->getMessage());
656
-        }
657
-        return $response;
658
-    }
659
-
660
-
661
-
662
-    /**
663
-     * Sets up and returns message preview
664
-     * @param  EE_Message $message incoming message object
665
-     * @param EE_message_type $message_type This is whatever message type was used in combination with this messenger to generate the message.
666
-     * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
667
-     * @return string          return the message html content
668
-     */
669
-    public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false)
670
-    {
671
-        $this->_validate_and_setup($message);
672
-
673
-        $this->_incoming_message_type = $message_type;
674
-
675
-        if ($send) {
676
-            // are we overriding any existing template fields?
677
-            $settings = apply_filters(
678
-                'FHEE__EE_messenger__get_preview__messenger_test_settings',
679
-                $this->get_existing_test_settings(),
680
-                $this,
681
-                $send,
682
-                $message,
683
-                $message_type
684
-            );
685
-            if (! empty($settings)) {
686
-                foreach ($settings as $field => $value) {
687
-                    $this->_set_template_value($field, $value);
688
-                }
689
-            }
690
-        }
691
-
692
-        // enqueue preview js so that any links/buttons on the page are disabled.
693
-        if (! $send) {
694
-            // the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
695
-            // it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
696
-            add_action('admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
697
-            add_action('wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
698
-            add_action('AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10);
699
-        }
700
-
701
-        return $send ? $this->_send_message() : $this->_preview();
702
-    }
703
-
704
-
705
-
706
-
707
-    /**
708
-     * Callback for enqueue_scripts so that we setup the preview script for all previews.
709
-     *
710
-     * @since 4.5.0
711
-     *
712
-     * @return void
713
-     */
714
-    public function add_preview_script()
715
-    {
716
-        // error message
717
-        EE_Registry::$i18n_js_strings['links_disabled'] = wp_strip_all_tags(
718
-            __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso')
719
-        );
720
-        wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true);
721
-        wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
722
-        wp_enqueue_script('ee-messages-preview-js');
723
-    }
724
-
725
-
726
-
727
-
728
-    /**
729
-     * simply validates the incoming message object and then sets up the properties for the messenger
730
-     * @param  EE_Message $message
731
-     * @throws EE_Error
732
-     */
733
-    protected function _validate_and_setup(EE_Message $message)
734
-    {
735
-        $template_pack = $message->get_template_pack();
736
-        $variation = $message->get_template_pack_variation();
737
-
738
-        // verify we have the required template pack value on the $message object.
739
-        if (! $template_pack instanceof EE_Messages_Template_Pack) {
740
-            throw new EE_Error(esc_html__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
741
-        }
742
-
743
-        $this->_tmp_pack = $template_pack;
744
-
745
-        $this->_variation = $variation ? $variation : 'default';
746
-
747
-        $template_fields = $this->get_template_fields();
748
-
749
-        foreach ($template_fields as $template => $value) {
750
-            if ($template !== 'extra') {
751
-                $column_value = $message->get_field_or_extra_meta('MSG_' . $template);
752
-                $message_template_value = $column_value ? $column_value : null;
753
-                $this->_set_template_value($template, $message_template_value);
754
-            }
755
-        }
756
-    }
757
-
758
-
759
-
760
-    /**
761
-     * Utility method for child classes to get the contents of a template file and return
762
-     *
763
-     * We're assuming the child messenger class has already setup template args!
764
-     * @param  bool $preview if true we use the preview wrapper otherwise we use main wrapper.
765
-     * @return string
766
-     * @throws \EE_Error
767
-     */
768
-    protected function _get_main_template($preview = false)
769
-    {
770
-        $type = $preview ? 'preview' : 'main';
771
-
772
-        $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
773
-
774
-        // check file exists and is readable
775
-        if (!is_readable($wrapper_template)) {
776
-            throw new EE_Error(sprintf(esc_html__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
777
-        }
778
-
779
-        // add message type to template args
780
-        $this->_template_args['message_type'] = $this->_incoming_message_type;
781
-
782
-        return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
783
-    }
784
-
785
-
786
-
787
-    /**
788
-     * set the _test_settings_fields property
789
-     *
790
-     * @access protected
791
-     * @return void
792
-     */
793
-    protected function _set_test_settings_fields()
794
-    {
795
-        $this->_test_settings_fields = array();
796
-    }
797
-
798
-
799
-
800
-    /**
801
-     * return the _test_settings_fields property
802
-     * @return array
803
-     */
804
-    public function get_test_settings_fields()
805
-    {
806
-        return $this->_test_settings_fields;
807
-    }
808
-
809
-
810
-
811
-
812
-    /**
813
-     * This just returns any existing test settings that might be saved in the database
814
-     *
815
-     * @access public
816
-     * @return array
817
-     */
818
-    public function get_existing_test_settings()
819
-    {
820
-        /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
821
-        $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
822
-        $settings = $Message_Resource_Manager->get_active_messengers_option();
823
-        return isset($settings[ $this->name ]['test_settings']) ? $settings[ $this->name ]['test_settings'] : array();
824
-    }
825
-
826
-
827
-
828
-    /**
829
-     * All this does is set the existing test settings (in the db) for the messenger
830
-     *
831
-     * @access public
832
-     * @param $settings
833
-     * @return bool success/fail
834
-     */
835
-    public function set_existing_test_settings($settings)
836
-    {
837
-        /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
838
-        $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
839
-        $existing = $Message_Resource_Manager->get_active_messengers_option();
840
-        $existing[ $this->name ]['test_settings'] = $settings;
841
-        return $Message_Resource_Manager->update_active_messengers_option($existing);
842
-    }
843
-
844
-
845
-
846
-    /**
847
-     * This just returns the field label for a given field setup in the _template_fields property.
848
-     *
849
-     * @since   4.3.0
850
-     *
851
-     * @param string $field The field to retrieve the label for
852
-     * @return string             The label
853
-     */
854
-    public function get_field_label($field)
855
-    {
856
-        // first let's see if the field requests is in the top level array.
857
-        if (isset($this->_template_fields[ $field ]) && !empty($this->_template_fields[ $field ]['label'])) {
858
-            return $this->_template[ $field ]['label'];
859
-        }
860
-
861
-        // nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
862
-        if (isset($this->_template_fields['extra']) && !empty($this->_template_fields['extra'][ $field ]) && !empty($this->_template_fields['extra'][ $field ]['main']['label'])) {
863
-            return $this->_template_fields['extra'][ $field ]['main']['label'];
864
-        }
865
-
866
-        // now it's possible this field may just be existing in any of the extra array items.
867
-        if (!empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
868
-            foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
869
-                if (!is_array($subfields)) {
870
-                    continue;
871
-                }
872
-                if (isset($subfields[ $field ]) && !empty($subfields[ $field ]['label'])) {
873
-                    return $subfields[ $field ]['label'];
874
-                }
875
-            }
876
-        }
877
-
878
-        // if we made it here then there's no label set so let's just return the $field.
879
-        return $field;
880
-    }
881
-
882
-
883
-
884
-
885
-    /**
886
-     * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary (i.e. swap out css files or something else).
887
-     *
888
-     * @since 4.5.0
889
-     *
890
-     * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
891
-     *
892
-     * @return void
893
-     */
894
-    public function do_secondary_messenger_hooks($sending_messenger_name)
895
-    {
896
-        return;
897
-    }
431
+	/**
432
+	 * Returns the valid message types associated with this messenger.
433
+	 *
434
+	 * @since 4.5.0
435
+	 *
436
+	 * @return array
437
+	 */
438
+	public function get_valid_message_types()
439
+	{
440
+		$class = get_class($this);
441
+
442
+		// messenger specific filter
443
+		// messenger specific filter
444
+		$valid_types = apply_filters('FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
445
+
446
+		// all messengers filter
447
+		$valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
448
+		return $valid_types;
449
+	}
450
+
451
+
452
+
453
+
454
+
455
+	/**
456
+	 * this is just used by the custom validators (EE_Messages_Validator classes) to modify the _validator_config for certain message_type/messenger combos where a context may only use certain shortcodes etc.
457
+	 *
458
+	 * @access public
459
+	 * @param array $new_config Whatever is put in here will reset the _validator_config property
460
+	 */
461
+	public function set_validator_config($new_config)
462
+	{
463
+		$this->_validator_config = $new_config;
464
+	}
465
+
466
+
467
+
468
+
469
+	/**
470
+	 * This returns the _validator_config property
471
+	 *
472
+	 * @access public
473
+	 * @return array
474
+	 */
475
+	public function get_validator_config()
476
+	{
477
+		$class = get_class($this);
478
+
479
+		$config = apply_filters('FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this);
480
+		$config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
481
+		return $config;
482
+	}
483
+
484
+
485
+
486
+
487
+	/**
488
+	 * this public method accepts a page slug (for an EE_admin page) and will return the response from the child class callback function if that page is registered via the `_admin_registered_page` property set by the child class.
489
+	 *
490
+	 * @param string $page the slug of the EE admin page
491
+	 * @param array $message_types an array of active message type objects
492
+	 * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages)
493
+	 * @param array $extra  This is just an extra argument that can be used to pass additional data for setting up page content.
494
+	 * @access public
495
+	 * @return string content for page
496
+	 */
497
+	public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array())
498
+	{
499
+		return $this->_get_admin_page_content($page, $action, $extra, $message_types);
500
+	}
501
+
502
+
503
+
504
+	/**
505
+	 * @param $message_types
506
+	 * @param array $extra
507
+	 * @return mixed|string
508
+	 */
509
+	protected function _get_admin_content_events_edit($message_types, $extra)
510
+	{
511
+		// defaults
512
+		$template_args = array();
513
+		$selector_rows = '';
514
+
515
+		// we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
516
+		$event_id = isset($extra['event']) ? $extra['event'] : null;
517
+
518
+		$template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
519
+		$template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
520
+
521
+		// array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
522
+		$global_templates = EEM_Message_Template_Group::instance()->get_all(
523
+			array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
524
+		);
525
+		$templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
526
+			$event_id,
527
+			array(
528
+				'MTP_messenger' => $this->name,
529
+				'MTP_is_active' => true
530
+			)
531
+		);
532
+		$templates_for_event = !empty($templates_for_event) ? $templates_for_event : array();
533
+
534
+		// so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
535
+		foreach ($global_templates as $mtpgID => $mtpg) {
536
+			if ($mtpg instanceof EE_Message_Template_Group) {
537
+				// verify this message type is supposed to show on this page
538
+				$mtp_obj = $mtpg->message_type_obj();
539
+				if (! $mtp_obj instanceof EE_message_type) {
540
+					continue;
541
+				}
542
+				$mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
543
+				if (! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
544
+					continue;
545
+				}
546
+				$select_values = array();
547
+				$select_values[ $mtpgID ] = esc_html__('Global', 'event_espresso');
548
+				$default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
549
+				// if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
550
+				if (! $mtpg->get('MTP_is_override')) {
551
+					// any custom templates for this message type?
552
+					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
553
+					foreach ($custom_templates as $cmtpgID => $cmtpg) {
554
+						$select_values[ $cmtpgID ] = $cmtpg->name();
555
+						$default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
556
+					}
557
+				}
558
+				// if there is no $default_value then we set it as the global
559
+				$default_value = empty($default_value) ? $mtpgID : $default_value;
560
+				$edit_url_query_args = [
561
+					'page' => 'espresso_messages',
562
+					'action' => 'edit_message_template',
563
+					'id' => $default_value,
564
+					'evt_id' => $event_id
565
+				];
566
+				$edit_url = EEH_URL::add_query_args_and_nonce($edit_url_query_args, admin_url('admin.php'));
567
+				$create_url_query_args = [
568
+					'page' => 'espresso_messages',
569
+					'action' => 'add_new_message_template',
570
+					'GRP_ID' => $default_value
571
+				];
572
+				$create_url = EEH_URL::add_query_args_and_nonce($create_url_query_args, admin_url('admin.php'));
573
+				$st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
574
+				$st_args['mt_slug'] = $mtpg->message_type();
575
+				$st_args['messenger_slug'] = $this->name;
576
+				$st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector');
577
+				// note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
578
+				$st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . esc_html__('Create New Custom', 'event_espresso') . '</a>';
579
+				$st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : '';
580
+				$st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . esc_html__('Edit', 'event_espresso') . '</a>' : '';
581
+				$selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
582
+			}
583
+		}
584
+
585
+		// if no selectors present then get out.
586
+		if (empty($selector_rows)) {
587
+			return '';
588
+		}
589
+
590
+		$template_args['selector_rows'] = $selector_rows;
591
+		return EEH_Template::display_template($template_wrapper_path, $template_args, true);
592
+	}
593
+
594
+
595
+
596
+
597
+
598
+
599
+	/**
600
+	 * get_template_fields
601
+	 *
602
+	 * @access public
603
+	 * @return array $this->_template_fields
604
+	 */
605
+	public function get_template_fields()
606
+	{
607
+		$template_fields = apply_filters('FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this);
608
+		$template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
609
+		return $template_fields;
610
+	}
611
+
612
+
613
+
614
+
615
+	/** SETUP METHODS **/
616
+	/**
617
+	 * The following method doesn't NEED to be used by child classes but might be modified by the specific messenger
618
+	 * @param string $item
619
+	 * @param mixed $value
620
+	 */
621
+	protected function _set_template_value($item, $value)
622
+	{
623
+		if (array_key_exists($item, $this->_template_fields)) {
624
+			$prop = '_' . $item;
625
+			$this->{$prop} = $value;
626
+		}
627
+	}
628
+
629
+	/**
630
+	 * Sets up the message for sending.
631
+	 *
632
+	 * @param  EE_message $message the message object that contains details about the message.
633
+	 * @param EE_message_type $message_type The message type object used in combination with this messenger to generate the provided message.
634
+	 *
635
+	 * @return bool Very important that all messengers return bool for successful send or not.  Error messages can be
636
+	 *              added to EE_Error.
637
+	 *              true = message sent successfully
638
+	 *              false = message not sent but can be retried (i.e. the failure might be just due to communication issues at the time of send).
639
+	 *              Throwing a SendMessageException means the message failed sending and cannot be retried.
640
+	 *
641
+	 * @throws SendMessageException
642
+	 */
643
+	final public function send_message($message, EE_message_type $message_type)
644
+	{
645
+		try {
646
+			$this->_validate_and_setup($message);
647
+			$this->_incoming_message_type = $message_type;
648
+			$response = $this->_send_message();
649
+			if ($response instanceof WP_Error) {
650
+				EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
651
+				$response = false;
652
+			}
653
+		} catch (\Exception $e) {
654
+			// convert to an instance of SendMessageException
655
+			throw new SendMessageException($e->getMessage());
656
+		}
657
+		return $response;
658
+	}
659
+
660
+
661
+
662
+	/**
663
+	 * Sets up and returns message preview
664
+	 * @param  EE_Message $message incoming message object
665
+	 * @param EE_message_type $message_type This is whatever message type was used in combination with this messenger to generate the message.
666
+	 * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
667
+	 * @return string          return the message html content
668
+	 */
669
+	public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false)
670
+	{
671
+		$this->_validate_and_setup($message);
672
+
673
+		$this->_incoming_message_type = $message_type;
674
+
675
+		if ($send) {
676
+			// are we overriding any existing template fields?
677
+			$settings = apply_filters(
678
+				'FHEE__EE_messenger__get_preview__messenger_test_settings',
679
+				$this->get_existing_test_settings(),
680
+				$this,
681
+				$send,
682
+				$message,
683
+				$message_type
684
+			);
685
+			if (! empty($settings)) {
686
+				foreach ($settings as $field => $value) {
687
+					$this->_set_template_value($field, $value);
688
+				}
689
+			}
690
+		}
691
+
692
+		// enqueue preview js so that any links/buttons on the page are disabled.
693
+		if (! $send) {
694
+			// the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
695
+			// it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
696
+			add_action('admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
697
+			add_action('wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
698
+			add_action('AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10);
699
+		}
700
+
701
+		return $send ? $this->_send_message() : $this->_preview();
702
+	}
703
+
704
+
705
+
706
+
707
+	/**
708
+	 * Callback for enqueue_scripts so that we setup the preview script for all previews.
709
+	 *
710
+	 * @since 4.5.0
711
+	 *
712
+	 * @return void
713
+	 */
714
+	public function add_preview_script()
715
+	{
716
+		// error message
717
+		EE_Registry::$i18n_js_strings['links_disabled'] = wp_strip_all_tags(
718
+			__('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso')
719
+		);
720
+		wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true);
721
+		wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
722
+		wp_enqueue_script('ee-messages-preview-js');
723
+	}
724
+
725
+
726
+
727
+
728
+	/**
729
+	 * simply validates the incoming message object and then sets up the properties for the messenger
730
+	 * @param  EE_Message $message
731
+	 * @throws EE_Error
732
+	 */
733
+	protected function _validate_and_setup(EE_Message $message)
734
+	{
735
+		$template_pack = $message->get_template_pack();
736
+		$variation = $message->get_template_pack_variation();
737
+
738
+		// verify we have the required template pack value on the $message object.
739
+		if (! $template_pack instanceof EE_Messages_Template_Pack) {
740
+			throw new EE_Error(esc_html__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
741
+		}
742
+
743
+		$this->_tmp_pack = $template_pack;
744
+
745
+		$this->_variation = $variation ? $variation : 'default';
746
+
747
+		$template_fields = $this->get_template_fields();
748
+
749
+		foreach ($template_fields as $template => $value) {
750
+			if ($template !== 'extra') {
751
+				$column_value = $message->get_field_or_extra_meta('MSG_' . $template);
752
+				$message_template_value = $column_value ? $column_value : null;
753
+				$this->_set_template_value($template, $message_template_value);
754
+			}
755
+		}
756
+	}
757
+
758
+
759
+
760
+	/**
761
+	 * Utility method for child classes to get the contents of a template file and return
762
+	 *
763
+	 * We're assuming the child messenger class has already setup template args!
764
+	 * @param  bool $preview if true we use the preview wrapper otherwise we use main wrapper.
765
+	 * @return string
766
+	 * @throws \EE_Error
767
+	 */
768
+	protected function _get_main_template($preview = false)
769
+	{
770
+		$type = $preview ? 'preview' : 'main';
771
+
772
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
773
+
774
+		// check file exists and is readable
775
+		if (!is_readable($wrapper_template)) {
776
+			throw new EE_Error(sprintf(esc_html__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
777
+		}
778
+
779
+		// add message type to template args
780
+		$this->_template_args['message_type'] = $this->_incoming_message_type;
781
+
782
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
783
+	}
784
+
785
+
786
+
787
+	/**
788
+	 * set the _test_settings_fields property
789
+	 *
790
+	 * @access protected
791
+	 * @return void
792
+	 */
793
+	protected function _set_test_settings_fields()
794
+	{
795
+		$this->_test_settings_fields = array();
796
+	}
797
+
798
+
799
+
800
+	/**
801
+	 * return the _test_settings_fields property
802
+	 * @return array
803
+	 */
804
+	public function get_test_settings_fields()
805
+	{
806
+		return $this->_test_settings_fields;
807
+	}
808
+
809
+
810
+
811
+
812
+	/**
813
+	 * This just returns any existing test settings that might be saved in the database
814
+	 *
815
+	 * @access public
816
+	 * @return array
817
+	 */
818
+	public function get_existing_test_settings()
819
+	{
820
+		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
821
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
822
+		$settings = $Message_Resource_Manager->get_active_messengers_option();
823
+		return isset($settings[ $this->name ]['test_settings']) ? $settings[ $this->name ]['test_settings'] : array();
824
+	}
825
+
826
+
827
+
828
+	/**
829
+	 * All this does is set the existing test settings (in the db) for the messenger
830
+	 *
831
+	 * @access public
832
+	 * @param $settings
833
+	 * @return bool success/fail
834
+	 */
835
+	public function set_existing_test_settings($settings)
836
+	{
837
+		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
838
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
839
+		$existing = $Message_Resource_Manager->get_active_messengers_option();
840
+		$existing[ $this->name ]['test_settings'] = $settings;
841
+		return $Message_Resource_Manager->update_active_messengers_option($existing);
842
+	}
843
+
844
+
845
+
846
+	/**
847
+	 * This just returns the field label for a given field setup in the _template_fields property.
848
+	 *
849
+	 * @since   4.3.0
850
+	 *
851
+	 * @param string $field The field to retrieve the label for
852
+	 * @return string             The label
853
+	 */
854
+	public function get_field_label($field)
855
+	{
856
+		// first let's see if the field requests is in the top level array.
857
+		if (isset($this->_template_fields[ $field ]) && !empty($this->_template_fields[ $field ]['label'])) {
858
+			return $this->_template[ $field ]['label'];
859
+		}
860
+
861
+		// nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
862
+		if (isset($this->_template_fields['extra']) && !empty($this->_template_fields['extra'][ $field ]) && !empty($this->_template_fields['extra'][ $field ]['main']['label'])) {
863
+			return $this->_template_fields['extra'][ $field ]['main']['label'];
864
+		}
865
+
866
+		// now it's possible this field may just be existing in any of the extra array items.
867
+		if (!empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
868
+			foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
869
+				if (!is_array($subfields)) {
870
+					continue;
871
+				}
872
+				if (isset($subfields[ $field ]) && !empty($subfields[ $field ]['label'])) {
873
+					return $subfields[ $field ]['label'];
874
+				}
875
+			}
876
+		}
877
+
878
+		// if we made it here then there's no label set so let's just return the $field.
879
+		return $field;
880
+	}
881
+
882
+
883
+
884
+
885
+	/**
886
+	 * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary (i.e. swap out css files or something else).
887
+	 *
888
+	 * @since 4.5.0
889
+	 *
890
+	 * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
891
+	 *
892
+	 * @return void
893
+	 */
894
+	public function do_secondary_messenger_hooks($sending_messenger_name)
895
+	{
896
+		return;
897
+	}
898 898
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
         $class = get_class($this);
419 419
 
420 420
         // messenger specific filter
421
-        $default_types = apply_filters('FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this);
421
+        $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this);
422 422
 
423 423
         // all messengers filter
424 424
         $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 
442 442
         // messenger specific filter
443 443
         // messenger specific filter
444
-        $valid_types = apply_filters('FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
444
+        $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
445 445
 
446 446
         // all messengers filter
447 447
         $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     {
477 477
         $class = get_class($this);
478 478
 
479
-        $config = apply_filters('FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this);
479
+        $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this);
480 480
         $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
481 481
         return $config;
482 482
     }
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
         // we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
516 516
         $event_id = isset($extra['event']) ? $extra['event'] : null;
517 517
 
518
-        $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
519
-        $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
518
+        $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
519
+        $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php';
520 520
 
521 521
         // array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
522 522
         $global_templates = EEM_Message_Template_Group::instance()->get_all(
523
-            array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
523
+            array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true))
524 524
         );
525 525
         $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
526 526
             $event_id,
@@ -529,29 +529,29 @@  discard block
 block discarded – undo
529 529
                 'MTP_is_active' => true
530 530
             )
531 531
         );
532
-        $templates_for_event = !empty($templates_for_event) ? $templates_for_event : array();
532
+        $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array();
533 533
 
534 534
         // so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
535 535
         foreach ($global_templates as $mtpgID => $mtpg) {
536 536
             if ($mtpg instanceof EE_Message_Template_Group) {
537 537
                 // verify this message type is supposed to show on this page
538 538
                 $mtp_obj = $mtpg->message_type_obj();
539
-                if (! $mtp_obj instanceof EE_message_type) {
539
+                if ( ! $mtp_obj instanceof EE_message_type) {
540 540
                     continue;
541 541
                 }
542 542
                 $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
543
-                if (! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
543
+                if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
544 544
                     continue;
545 545
                 }
546 546
                 $select_values = array();
547
-                $select_values[ $mtpgID ] = esc_html__('Global', 'event_espresso');
547
+                $select_values[$mtpgID] = esc_html__('Global', 'event_espresso');
548 548
                 $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
549 549
                 // if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
550
-                if (! $mtpg->get('MTP_is_override')) {
550
+                if ( ! $mtpg->get('MTP_is_override')) {
551 551
                     // any custom templates for this message type?
552 552
                     $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
553 553
                     foreach ($custom_templates as $cmtpgID => $cmtpg) {
554
-                        $select_values[ $cmtpgID ] = $cmtpg->name();
554
+                        $select_values[$cmtpgID] = $cmtpg->name();
555 555
                         $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
556 556
                     }
557 557
                 }
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
                 $st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
574 574
                 $st_args['mt_slug'] = $mtpg->message_type();
575 575
                 $st_args['messenger_slug'] = $this->name;
576
-                $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector');
576
+                $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector');
577 577
                 // note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
578
-                $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . esc_html__('Create New Custom', 'event_espresso') . '</a>';
578
+                $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.esc_html__('Create New Custom', 'event_espresso').'</a>';
579 579
                 $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : '';
580
-                $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . esc_html__('Edit', 'event_espresso') . '</a>' : '';
580
+                $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.esc_html__('Edit', 'event_espresso').'</a>' : '';
581 581
                 $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
582 582
             }
583 583
         }
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
      */
605 605
     public function get_template_fields()
606 606
     {
607
-        $template_fields = apply_filters('FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this);
607
+        $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this);
608 608
         $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
609 609
         return $template_fields;
610 610
     }
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
     protected function _set_template_value($item, $value)
622 622
     {
623 623
         if (array_key_exists($item, $this->_template_fields)) {
624
-            $prop = '_' . $item;
624
+            $prop = '_'.$item;
625 625
             $this->{$prop} = $value;
626 626
         }
627 627
     }
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                 $message,
683 683
                 $message_type
684 684
             );
685
-            if (! empty($settings)) {
685
+            if ( ! empty($settings)) {
686 686
                 foreach ($settings as $field => $value) {
687 687
                     $this->_set_template_value($field, $value);
688 688
                 }
@@ -690,12 +690,12 @@  discard block
 block discarded – undo
690 690
         }
691 691
 
692 692
         // enqueue preview js so that any links/buttons on the page are disabled.
693
-        if (! $send) {
693
+        if ( ! $send) {
694 694
             // the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
695 695
             // it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
696
-            add_action('admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
697
-            add_action('wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10);
698
-            add_action('AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10);
696
+            add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10);
697
+            add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10);
698
+            add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10);
699 699
         }
700 700
 
701 701
         return $send ? $this->_send_message() : $this->_preview();
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         EE_Registry::$i18n_js_strings['links_disabled'] = wp_strip_all_tags(
718 718
             __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso')
719 719
         );
720
-        wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true);
720
+        wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
721 721
         wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
722 722
         wp_enqueue_script('ee-messages-preview-js');
723 723
     }
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
         $variation = $message->get_template_pack_variation();
737 737
 
738 738
         // verify we have the required template pack value on the $message object.
739
-        if (! $template_pack instanceof EE_Messages_Template_Pack) {
739
+        if ( ! $template_pack instanceof EE_Messages_Template_Pack) {
740 740
             throw new EE_Error(esc_html__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
741 741
         }
742 742
 
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 
749 749
         foreach ($template_fields as $template => $value) {
750 750
             if ($template !== 'extra') {
751
-                $column_value = $message->get_field_or_extra_meta('MSG_' . $template);
751
+                $column_value = $message->get_field_or_extra_meta('MSG_'.$template);
752 752
                 $message_template_value = $column_value ? $column_value : null;
753 753
                 $this->_set_template_value($template, $message_template_value);
754 754
             }
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
         $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
773 773
 
774 774
         // check file exists and is readable
775
-        if (!is_readable($wrapper_template)) {
775
+        if ( ! is_readable($wrapper_template)) {
776 776
             throw new EE_Error(sprintf(esc_html__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
777 777
         }
778 778
 
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
         /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
821 821
         $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
822 822
         $settings = $Message_Resource_Manager->get_active_messengers_option();
823
-        return isset($settings[ $this->name ]['test_settings']) ? $settings[ $this->name ]['test_settings'] : array();
823
+        return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array();
824 824
     }
825 825
 
826 826
 
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
         /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
838 838
         $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
839 839
         $existing = $Message_Resource_Manager->get_active_messengers_option();
840
-        $existing[ $this->name ]['test_settings'] = $settings;
840
+        $existing[$this->name]['test_settings'] = $settings;
841 841
         return $Message_Resource_Manager->update_active_messengers_option($existing);
842 842
     }
843 843
 
@@ -854,23 +854,23 @@  discard block
 block discarded – undo
854 854
     public function get_field_label($field)
855 855
     {
856 856
         // first let's see if the field requests is in the top level array.
857
-        if (isset($this->_template_fields[ $field ]) && !empty($this->_template_fields[ $field ]['label'])) {
858
-            return $this->_template[ $field ]['label'];
857
+        if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) {
858
+            return $this->_template[$field]['label'];
859 859
         }
860 860
 
861 861
         // nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
862
-        if (isset($this->_template_fields['extra']) && !empty($this->_template_fields['extra'][ $field ]) && !empty($this->_template_fields['extra'][ $field ]['main']['label'])) {
863
-            return $this->_template_fields['extra'][ $field ]['main']['label'];
862
+        if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) {
863
+            return $this->_template_fields['extra'][$field]['main']['label'];
864 864
         }
865 865
 
866 866
         // now it's possible this field may just be existing in any of the extra array items.
867
-        if (!empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
867
+        if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
868 868
             foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
869
-                if (!is_array($subfields)) {
869
+                if ( ! is_array($subfields)) {
870 870
                     continue;
871 871
                 }
872
-                if (isset($subfields[ $field ]) && !empty($subfields[ $field ]['label'])) {
873
-                    return $subfields[ $field ]['label'];
872
+                if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) {
873
+                    return $subfields[$field]['label'];
874 874
                 }
875 875
             }
876 876
         }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Payment_Base_message_type.lib.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -15,67 +15,67 @@
 block discarded – undo
15 15
 
16 16
 
17 17
 
18
-    /**
19
-     * @see parent::get_priority() for documentation.
20
-     * @return int
21
-     */
22
-    public function get_priority()
23
-    {
24
-        return EEM_Message::priority_high;
25
-    }
18
+	/**
19
+	 * @see parent::get_priority() for documentation.
20
+	 * @return int
21
+	 */
22
+	public function get_priority()
23
+	{
24
+		return EEM_Message::priority_high;
25
+	}
26 26
 
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * see abstract declaration in parent class for details.
32
-     */
33
-    protected function _set_admin_pages()
34
-    {
35
-        $this->admin_registered_pages = array(
36
-            'events_edit' => true
37
-            );
38
-    }
30
+	/**
31
+	 * see abstract declaration in parent class for details.
32
+	 */
33
+	protected function _set_admin_pages()
34
+	{
35
+		$this->admin_registered_pages = array(
36
+			'events_edit' => true
37
+			);
38
+	}
39 39
 
40 40
 
41 41
 
42
-    protected function _set_data_handler()
43
-    {
44
-        $this->_data_handler = 'Gateways';
45
-    }
42
+	protected function _set_data_handler()
43
+	{
44
+		$this->_data_handler = 'Gateways';
45
+	}
46 46
 
47 47
 
48 48
 
49 49
 
50
-    protected function _get_data_for_context($context, EE_Registration $registration, $id)
51
-    {
50
+	protected function _get_data_for_context($context, EE_Registration $registration, $id)
51
+	{
52 52
 
53
-        // use the registration to get the transaction.
54
-        $transaction = $registration->transaction();
53
+		// use the registration to get the transaction.
54
+		$transaction = $registration->transaction();
55 55
 
56
-        // bail early if no transaction
57
-        if (! $transaction instanceof EE_Transaction) {
58
-            throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
59
-        }
56
+		// bail early if no transaction
57
+		if (! $transaction instanceof EE_Transaction) {
58
+			throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
59
+		}
60 60
 
61
-        $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
61
+		$payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
62 62
 
63
-        return array( $transaction, $payment );
64
-    }
63
+		return array( $transaction, $payment );
64
+	}
65 65
 
66 66
 
67 67
 
68
-    protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
69
-    {
70
-        // this is just a test
71
-        return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
72
-    }
68
+	protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
69
+	{
70
+		// this is just a test
71
+		return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
72
+	}
73 73
 
74
-    /**
75
-     * This message type doesn't need any settings so we are just setting to empty array.
76
-     */
77
-    protected function _set_admin_settings_fields()
78
-    {
79
-        $this->_admin_settings_fields = array();
80
-    }
74
+	/**
75
+	 * This message type doesn't need any settings so we are just setting to empty array.
76
+	 */
77
+	protected function _set_admin_settings_fields()
78
+	{
79
+		$this->_admin_settings_fields = array();
80
+	}
81 81
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         $transaction = $registration->transaction();
55 55
 
56 56
         // bail early if no transaction
57
-        if (! $transaction instanceof EE_Transaction) {
57
+        if ( ! $transaction instanceof EE_Transaction) {
58 58
             throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
59 59
         }
60 60
 
61
-        $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
61
+        $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0;
62 62
 
63
-        return array( $transaction, $payment );
63
+        return array($transaction, $payment);
64 64
     }
65 65
 
66 66
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
69 69
     {
70 70
         // this is just a test
71
-        return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
71
+        return $this->name.' Message Type for '.$messenger->name.' Messenger ';
72 72
     }
73 73
 
74 74
     /**
Please login to merge, or discard this patch.
libraries/messages/message_type/EE_Payment_Refund_message_type.class.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
 class EE_Payment_Refund_message_type extends EE_Payment_Base_message_type
16 16
 {
17 17
 
18
-    public function __construct()
19
-    {
18
+	public function __construct()
19
+	{
20 20
 
21
-        // setup type details for reference
22
-        $this->name = 'payment_refund';
23
-        $this->description = esc_html__('This message type is used for all payment notification messages that go out for refunds.', 'event_espresso');
24
-        $this->label = array(
25
-            'singular' => esc_html__('refund issued', 'event_espresso'),
26
-            'plural' => esc_html__('refunds issued', 'event_espresso')
27
-            );
21
+		// setup type details for reference
22
+		$this->name = 'payment_refund';
23
+		$this->description = esc_html__('This message type is used for all payment notification messages that go out for refunds.', 'event_espresso');
24
+		$this->label = array(
25
+			'singular' => esc_html__('refund issued', 'event_espresso'),
26
+			'plural' => esc_html__('refunds issued', 'event_espresso')
27
+			);
28 28
 
29
-        $this->_master_templates = array(
30
-            'email' => 'payment'
31
-            );
29
+		$this->_master_templates = array(
30
+			'email' => 'payment'
31
+			);
32 32
 
33
-        parent::__construct();
34
-    }
33
+		parent::__construct();
34
+	}
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * _set_contexts
40
-     * This sets up the contexts associated with the message_type
41
-     *
42
-     * @access  protected
43
-     * @return  void
44
-     */
45
-    protected function _set_contexts()
46
-    {
47
-        $this->_context_label = array(
48
-            'label' => esc_html__('recipient', 'event_espresso'),
49
-            'plural' => esc_html__('recipients', 'event_espresso'),
50
-            'description' => esc_html__('Recipient\'s are who will receive the template.  You may want different payment details sent out depending on who the recipient is', 'event_espresso')
51
-            );
38
+	/**
39
+	 * _set_contexts
40
+	 * This sets up the contexts associated with the message_type
41
+	 *
42
+	 * @access  protected
43
+	 * @return  void
44
+	 */
45
+	protected function _set_contexts()
46
+	{
47
+		$this->_context_label = array(
48
+			'label' => esc_html__('recipient', 'event_espresso'),
49
+			'plural' => esc_html__('recipients', 'event_espresso'),
50
+			'description' => esc_html__('Recipient\'s are who will receive the template.  You may want different payment details sent out depending on who the recipient is', 'event_espresso')
51
+			);
52 52
 
53
-        $this->_contexts = array(
54
-            'admin' => array(
55
-                'label' => esc_html__('Event Admin', 'event_espresso'),
56
-                'description' => esc_html__('This template is what event administrators will receive on a successful refund.', 'event_espresso')
57
-                ),
58
-            'primary_attendee' => array(
59
-                'label' => esc_html__('Primary Registrant', 'event_espresso'),
60
-                'description' => esc_html__('This template is what the primary registrant (the person who made the main registration) will receive on successful refund.', 'event_espresso')
61
-                )
62
-            );
63
-    }
53
+		$this->_contexts = array(
54
+			'admin' => array(
55
+				'label' => esc_html__('Event Admin', 'event_espresso'),
56
+				'description' => esc_html__('This template is what event administrators will receive on a successful refund.', 'event_espresso')
57
+				),
58
+			'primary_attendee' => array(
59
+				'label' => esc_html__('Primary Registrant', 'event_espresso'),
60
+				'description' => esc_html__('This template is what the primary registrant (the person who made the main registration) will receive on successful refund.', 'event_espresso')
61
+				)
62
+			);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
core/libraries/messages/message_type/EE_Registration_message_type.class.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -14,48 +14,48 @@
 block discarded – undo
14 14
 class EE_Registration_message_type extends EE_Registration_Base_message_type
15 15
 {
16 16
 
17
-    public function __construct()
18
-    {
19
-        $this->name = 'registration';
20
-        $this->description = esc_html__('This message type is for messages sent to attendees when their registration is approved.', 'event_espresso');
21
-        $this->label = array(
22
-            'singular' => esc_html__('registration approved', 'event_espresso'),
23
-            'plural' => esc_html__('registrations approved', 'event_espresso')
24
-            );
17
+	public function __construct()
18
+	{
19
+		$this->name = 'registration';
20
+		$this->description = esc_html__('This message type is for messages sent to attendees when their registration is approved.', 'event_espresso');
21
+		$this->label = array(
22
+			'singular' => esc_html__('registration approved', 'event_espresso'),
23
+			'plural' => esc_html__('registrations approved', 'event_espresso')
24
+			);
25 25
 
26
-        parent::__construct();
27
-    }
26
+		parent::__construct();
27
+	}
28 28
 
29 29
 
30 30
 
31
-    /**
32
-     * _set_contexts
33
-     * This sets up the contexts associated with the message_type
34
-     *
35
-     * @access  protected
36
-     * @return  void
37
-     */
38
-    protected function _set_contexts()
39
-    {
40
-        $this->_context_label = array(
41
-            'label' => esc_html__('recipient', 'event_espresso'),
42
-            'plural' => esc_html__('recipients', 'event_espresso'),
43
-            'description' => esc_html__('Recipient\'s are who will receive the template.  You may want different registration details sent out depending on who the recipient is', 'event_espresso')
44
-            );
31
+	/**
32
+	 * _set_contexts
33
+	 * This sets up the contexts associated with the message_type
34
+	 *
35
+	 * @access  protected
36
+	 * @return  void
37
+	 */
38
+	protected function _set_contexts()
39
+	{
40
+		$this->_context_label = array(
41
+			'label' => esc_html__('recipient', 'event_espresso'),
42
+			'plural' => esc_html__('recipients', 'event_espresso'),
43
+			'description' => esc_html__('Recipient\'s are who will receive the template.  You may want different registration details sent out depending on who the recipient is', 'event_espresso')
44
+			);
45 45
 
46
-        $this->_contexts = array(
47
-            'admin' => array(
48
-                'label' => esc_html__('Event Admin', 'event_espresso'),
49
-                'description' => esc_html__('This template is what event administrators will receive with an approved registration', 'event_espresso')
50
-                ),
51
-            'primary_attendee' => array(
52
-                'label' => esc_html__('Primary Registrant', 'event_espresso'),
53
-                'description' => esc_html__('This template is what the primary registrant (the person who completed the initial transaction) will receive with approved registration', 'event_espresso')
54
-                ),
55
-            'attendee' => array(
56
-                'label' => esc_html__('Registrant', 'event_espresso'),
57
-                'description' => esc_html__('This template is what each registrant for the event will receive when their registration is approved.', 'event_espresso')
58
-                )
59
-            );
60
-    }
46
+		$this->_contexts = array(
47
+			'admin' => array(
48
+				'label' => esc_html__('Event Admin', 'event_espresso'),
49
+				'description' => esc_html__('This template is what event administrators will receive with an approved registration', 'event_espresso')
50
+				),
51
+			'primary_attendee' => array(
52
+				'label' => esc_html__('Primary Registrant', 'event_espresso'),
53
+				'description' => esc_html__('This template is what the primary registrant (the person who completed the initial transaction) will receive with approved registration', 'event_espresso')
54
+				),
55
+			'attendee' => array(
56
+				'label' => esc_html__('Registrant', 'event_espresso'),
57
+				'description' => esc_html__('This template is what each registrant for the event will receive when their registration is approved.', 'event_espresso')
58
+				)
59
+			);
60
+	}
61 61
 }
Please login to merge, or discard this patch.
libraries/messages/message_type/EE_Pending_Approval_message_type.class.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -14,59 +14,59 @@
 block discarded – undo
14 14
 class EE_Pending_Approval_message_type extends EE_Registration_Base_message_type
15 15
 {
16 16
 
17
-    public function __construct()
18
-    {
19
-        $this->name = 'pending_approval';
20
-        $this->description = esc_html__('This message type is used for recipients who have Pending Payment registration status.', 'event_espresso');
21
-        $this->label = array(
22
-            'singular' => esc_html__('registration pending payment', 'event_espresso'),
23
-            'plural' => esc_html__('registrations pending payment', 'event_espresso')
24
-            );
17
+	public function __construct()
18
+	{
19
+		$this->name = 'pending_approval';
20
+		$this->description = esc_html__('This message type is used for recipients who have Pending Payment registration status.', 'event_espresso');
21
+		$this->label = array(
22
+			'singular' => esc_html__('registration pending payment', 'event_espresso'),
23
+			'plural' => esc_html__('registrations pending payment', 'event_espresso')
24
+			);
25 25
 
26
-        $this->_master_templates = array(
27
-            'email' => 'registration'
28
-            );
26
+		$this->_master_templates = array(
27
+			'email' => 'registration'
28
+			);
29 29
 
30
-        parent::__construct();
31
-    }
30
+		parent::__construct();
31
+	}
32 32
 
33 33
 
34 34
 
35
-    /**
36
-     * _set_contexts
37
-     * This sets up the contexts associated with the message_type
38
-     *
39
-     * @access  protected
40
-     * @return  void
41
-     */
42
-    protected function _set_contexts()
43
-    {
44
-        $this->_context_label = array(
45
-            'label' => esc_html__('recipient', 'event_espresso'),
46
-            'plural' => esc_html__('recipients', 'event_espresso'),
47
-            'description' => esc_html__('Recipient\'s are who will receive the template.  You may want different pending approval details sent out depending on who the recipient is.  To "turn off" a recipient from receiving message, simply remove any content from the "to" field in the template.', 'event_espresso')
48
-            );
35
+	/**
36
+	 * _set_contexts
37
+	 * This sets up the contexts associated with the message_type
38
+	 *
39
+	 * @access  protected
40
+	 * @return  void
41
+	 */
42
+	protected function _set_contexts()
43
+	{
44
+		$this->_context_label = array(
45
+			'label' => esc_html__('recipient', 'event_espresso'),
46
+			'plural' => esc_html__('recipients', 'event_espresso'),
47
+			'description' => esc_html__('Recipient\'s are who will receive the template.  You may want different pending approval details sent out depending on who the recipient is.  To "turn off" a recipient from receiving message, simply remove any content from the "to" field in the template.', 'event_espresso')
48
+			);
49 49
 
50
-        $this->_contexts = array(
51
-            'admin' => array(
52
-                'label' => esc_html__('Event Admin', 'event_espresso'),
53
-                'description' => esc_html__('This template is what event administrators will receive when a message is sent to registrants with the pending payment registration status.', 'event_espresso')
54
-                ),
55
-            'primary_attendee' => array(
56
-                'label' => esc_html__('Primary Registrant', 'event_espresso'),
57
-                'description' => esc_html__('This template is what the primary registrant (the person who completed the initial transaction) will receive on when their registration status is pending payment.', 'event_espresso')
58
-                )
59
-            );
60
-    }
50
+		$this->_contexts = array(
51
+			'admin' => array(
52
+				'label' => esc_html__('Event Admin', 'event_espresso'),
53
+				'description' => esc_html__('This template is what event administrators will receive when a message is sent to registrants with the pending payment registration status.', 'event_espresso')
54
+				),
55
+			'primary_attendee' => array(
56
+				'label' => esc_html__('Primary Registrant', 'event_espresso'),
57
+				'description' => esc_html__('This template is what the primary registrant (the person who completed the initial transaction) will receive on when their registration status is pending payment.', 'event_espresso')
58
+				)
59
+			);
60
+	}
61 61
 
62 62
 
63 63
 
64
-    protected function _primary_attendee_addressees()
65
-    {
66
-        $cached = $this->_single_message;
67
-        $this->_single_message = false;
68
-        $addressees = parent::_primary_attendee_addressees();
69
-        $this->_single_message = $cached;
70
-        return $addressees;
71
-    }
64
+	protected function _primary_attendee_addressees()
65
+	{
66
+		$cached = $this->_single_message;
67
+		$this->_single_message = false;
68
+		$addressees = parent::_primary_attendee_addressees();
69
+		$this->_single_message = $cached;
70
+		return $addressees;
71
+	}
72 72
 }
Please login to merge, or discard this patch.