Completed
Branch new-admin-design (ca26a3)
by
unknown
12:01 queued 06:54
created
core/domain/entities/routing/data_nodes/core/CurrentUser.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,54 +16,54 @@
 block discarded – undo
16 16
  */
17 17
 class CurrentUser extends JsonDataNode
18 18
 {
19
-    const NODE_NAME = 'currentUser';
19
+	const NODE_NAME = 'currentUser';
20 20
 
21
-    /**
22
-     * @var Capabilities $capabilities
23
-     */
24
-    private $capabilities;
21
+	/**
22
+	 * @var Capabilities $capabilities
23
+	 */
24
+	private $capabilities;
25 25
 
26
-    /**
27
-     * @param Capabilities $capabilities
28
-     * @param JsonDataNodeValidator $validator
29
-     */
30
-    public function __construct(Capabilities $capabilities, JsonDataNodeValidator $validator)
31
-    {
32
-        if (! class_exists('WPGraphQL')) {
33
-            require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
34
-        }
35
-        parent::__construct($validator);
36
-        $this->capabilities = $capabilities;
37
-        $this->setNodeName(CurrentUser::NODE_NAME);
38
-    }
26
+	/**
27
+	 * @param Capabilities $capabilities
28
+	 * @param JsonDataNodeValidator $validator
29
+	 */
30
+	public function __construct(Capabilities $capabilities, JsonDataNodeValidator $validator)
31
+	{
32
+		if (! class_exists('WPGraphQL')) {
33
+			require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php';
34
+		}
35
+		parent::__construct($validator);
36
+		$this->capabilities = $capabilities;
37
+		$this->setNodeName(CurrentUser::NODE_NAME);
38
+	}
39 39
 
40
-    /**
41
-     * @inheritDoc
42
-     */
43
-    public function initialize()
44
-    {
45
-        $current_user = wp_get_current_user();
46
-        if (! $current_user instanceof WP_User) {
47
-            $current_user = new WP_User();
48
-        }
40
+	/**
41
+	 * @inheritDoc
42
+	 */
43
+	public function initialize()
44
+	{
45
+		$current_user = wp_get_current_user();
46
+		if (! $current_user instanceof WP_User) {
47
+			$current_user = new WP_User();
48
+		}
49 49
 
50
-        if (class_exists(Relay::class)) {
51
-            $this->addData('id', Relay::toGlobalId('user', $current_user->ID));
52
-        }
53
-        $this->addData('databaseId', $current_user->ID);
54
-        $this->addData('description', $current_user->description);
55
-        $this->addData('email', $current_user->user_email);
56
-        $this->addData('firstName', $current_user->first_name);
57
-        $this->addData('isa', is_super_admin($current_user->ID));
58
-        $this->addData('lastName', $current_user->last_name);
59
-        $this->addData('locale', get_user_locale($current_user->ID));
60
-        $this->addData('name', $current_user->display_name);
61
-        $this->addData('nicename', $current_user->user_nicename);
62
-        $this->addData('nickname', $current_user->nickname);
63
-        $this->addData('username', $current_user->user_login);
64
-        $this->addData('roles', $current_user->roles);
65
-        $this->addData('__typename', 'User');
66
-        $this->addDataNode($this->capabilities);
67
-        $this->setInitialized(true);
68
-    }
50
+		if (class_exists(Relay::class)) {
51
+			$this->addData('id', Relay::toGlobalId('user', $current_user->ID));
52
+		}
53
+		$this->addData('databaseId', $current_user->ID);
54
+		$this->addData('description', $current_user->description);
55
+		$this->addData('email', $current_user->user_email);
56
+		$this->addData('firstName', $current_user->first_name);
57
+		$this->addData('isa', is_super_admin($current_user->ID));
58
+		$this->addData('lastName', $current_user->last_name);
59
+		$this->addData('locale', get_user_locale($current_user->ID));
60
+		$this->addData('name', $current_user->display_name);
61
+		$this->addData('nicename', $current_user->user_nicename);
62
+		$this->addData('nickname', $current_user->nickname);
63
+		$this->addData('username', $current_user->user_login);
64
+		$this->addData('roles', $current_user->roles);
65
+		$this->addData('__typename', 'User');
66
+		$this->addDataNode($this->capabilities);
67
+		$this->setInitialized(true);
68
+	}
69 69
 }
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 1 patch
Indentation   +4643 added lines, -4643 removed lines patch added patch discarded remove patch
@@ -16,2684 +16,2684 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class Messages_Admin_Page extends EE_Admin_Page
18 18
 {
19
-    /**
20
-     * @var EEM_Message
21
-     */
22
-    private $MSG_MODEL;
23
-
24
-    /**
25
-     * @var EEM_Message_Template
26
-     */
27
-    private $MTP_MODEL;
28
-
29
-    /**
30
-     * @var EEM_Message_Template_Group
31
-     */
32
-    private $MTG_MODEL;
33
-
34
-    /**
35
-     * @var EE_Message_Resource_Manager $_message_resource_manager
36
-     */
37
-    protected $_message_resource_manager;
38
-
39
-    /**
40
-     * @var string
41
-     */
42
-    protected $_active_message_type_name = '';
43
-
44
-    /**
45
-     * @var string
46
-     */
47
-    protected $_active_messenger_name = '';
48
-
49
-    /**
50
-     * @var EE_messenger $_active_messenger
51
-     */
52
-    protected $_active_messenger;
53
-
54
-    protected $_activate_meta_box_type;
55
-
56
-    protected $_current_message_meta_box;
57
-
58
-    protected $_current_message_meta_box_object;
59
-
60
-    protected $_context_switcher;
61
-
62
-    protected $_shortcodes           = [];
63
-
64
-    protected $_active_messengers    = [];
65
-
66
-    protected $_active_message_types = [];
67
-
68
-    /**
69
-     * @var EE_Message_Template_Group $_message_template_group
70
-     */
71
-    protected $_message_template_group;
72
-
73
-    protected $_m_mt_settings = [];
74
-
75
-
76
-    /**
77
-     * This is set via the _set_message_template_group method and holds whatever the template pack for the group is.
78
-     * IF there is no group then it gets automatically set to the Default template pack.
79
-     *
80
-     * @since 4.5.0
81
-     *
82
-     * @var EE_Messages_Template_Pack
83
-     */
84
-    protected $_template_pack;
85
-
86
-
87
-    /**
88
-     * This is set via the _set_message_template_group method and holds whatever the template pack variation for the
89
-     * group is.  If there is no group then it automatically gets set to default.
90
-     *
91
-     * @since 4.5.0
92
-     *
93
-     * @var string
94
-     */
95
-    protected $_variation;
96
-
97
-
98
-    /**
99
-     * @param bool $routing
100
-     * @throws EE_Error
101
-     * @throws ReflectionException
102
-     */
103
-    public function __construct($routing = true)
104
-    {
105
-        // make sure messages autoloader is running
106
-        EED_Messages::set_autoloaders();
107
-        parent::__construct($routing);
108
-    }
109
-
110
-
111
-    /**
112
-     * @return EEM_Message
113
-     * @throws EE_Error
114
-     */
115
-    public function getMsgModel()
116
-    {
117
-        if (! $this->MSG_MODEL instanceof EEM_Message) {
118
-            $this->MSG_MODEL = EEM_Message::instance();
119
-        }
120
-        return $this->MSG_MODEL;
121
-    }
122
-
123
-
124
-    /**
125
-     * @return EEM_Message_Template
126
-     * @throws EE_Error
127
-     */
128
-    public function getMtpModel()
129
-    {
130
-        if (! $this->MTP_MODEL instanceof EEM_Message_Template) {
131
-            $this->MTP_MODEL = EEM_Message_Template::instance();
132
-        }
133
-        return $this->MTP_MODEL;
134
-    }
135
-
136
-
137
-    /**
138
-     * @return EEM_Message_Template_Group
139
-     * @throws EE_Error
140
-     */
141
-    public function getMtgModel()
142
-    {
143
-        if (! $this->MTG_MODEL instanceof EEM_Message_Template_Group) {
144
-            $this->MTG_MODEL = EEM_Message_Template_Group::instance();
145
-        }
146
-        return $this->MTG_MODEL;
147
-    }
148
-
149
-
150
-    /**
151
-     * @throws EE_Error
152
-     * @throws ReflectionException
153
-     */
154
-    protected function _init_page_props()
155
-    {
156
-        $this->page_slug        = EE_MSG_PG_SLUG;
157
-        $this->page_label       = esc_html__('Messages Settings', 'event_espresso');
158
-        $this->_admin_base_url  = EE_MSG_ADMIN_URL;
159
-        $this->_admin_base_path = EE_MSG_ADMIN;
160
-
161
-        $messenger    = $this->request->getRequestParam('messenger', '');
162
-        $message_type = $this->request->getRequestParam('message_type', '');
163
-        $this->_active_messenger_name    = $this->request->getRequestParam('MTP_messenger', $messenger);
164
-        $this->_active_message_type_name = $this->request->getRequestParam('MTP_message_type', $message_type);
165
-
166
-        $this->_load_message_resource_manager();
167
-    }
168
-
169
-
170
-    /**
171
-     * loads messenger objects into the $_active_messengers property (so we can access the needed methods)
172
-     *
173
-     * @throws EE_Error
174
-     * @throws InvalidDataTypeException
175
-     * @throws InvalidInterfaceException
176
-     * @throws InvalidArgumentException
177
-     * @throws ReflectionException
178
-     */
179
-    protected function _load_message_resource_manager()
180
-    {
181
-        $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
182
-    }
183
-
184
-
185
-    /**
186
-     * @return array
187
-     * @throws EE_Error
188
-     * @throws InvalidArgumentException
189
-     * @throws InvalidDataTypeException
190
-     * @throws InvalidInterfaceException
191
-     * @deprecated 4.9.9.rc.014
192
-     */
193
-    public function get_messengers_for_list_table()
194
-    {
195
-        EE_Error::doing_it_wrong(
196
-            __METHOD__,
197
-            sprintf(
198
-                esc_html__(
199
-                    'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a messenger filter dropdown which is now generated differently via %s',
200
-                    'event_espresso'
201
-                ),
202
-                'Messages_Admin_Page::get_messengers_select_input()'
203
-            ),
204
-            '4.9.9.rc.014'
205
-        );
206
-
207
-        $m_values          = [];
208
-        $active_messengers = $this->getMsgModel()->get_all(['group_by' => 'MSG_messenger']);
209
-        // setup messengers for selects
210
-        $i = 1;
211
-        foreach ($active_messengers as $active_messenger) {
212
-            if ($active_messenger instanceof EE_Message) {
213
-                $m_values[ $i ]['id']   = $active_messenger->messenger();
214
-                $m_values[ $i ]['text'] = ucwords($active_messenger->messenger_label());
215
-                $i++;
216
-            }
217
-        }
218
-
219
-        return $m_values;
220
-    }
221
-
222
-
223
-    /**
224
-     * @return array
225
-     * @throws EE_Error
226
-     * @throws InvalidArgumentException
227
-     * @throws InvalidDataTypeException
228
-     * @throws InvalidInterfaceException
229
-     * @deprecated 4.9.9.rc.014
230
-     */
231
-    public function get_message_types_for_list_table()
232
-    {
233
-        EE_Error::doing_it_wrong(
234
-            __METHOD__,
235
-            sprintf(
236
-                esc_html__(
237
-                    'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type filter dropdown which is now generated differently via %s',
238
-                    'event_espresso'
239
-                ),
240
-                'Messages_Admin_Page::get_message_types_select_input()'
241
-            ),
242
-            '4.9.9.rc.014'
243
-        );
244
-
245
-        $mt_values       = [];
246
-        $active_messages = $this->getMsgModel()->get_all(['group_by' => 'MSG_message_type']);
247
-        $i               = 1;
248
-        foreach ($active_messages as $active_message) {
249
-            if ($active_message instanceof EE_Message) {
250
-                $mt_values[ $i ]['id']   = $active_message->message_type();
251
-                $mt_values[ $i ]['text'] = ucwords($active_message->message_type_label());
252
-                $i++;
253
-            }
254
-        }
255
-
256
-        return $mt_values;
257
-    }
258
-
259
-
260
-    /**
261
-     * @return array
262
-     * @throws EE_Error
263
-     * @throws InvalidArgumentException
264
-     * @throws InvalidDataTypeException
265
-     * @throws InvalidInterfaceException
266
-     * @deprecated 4.9.9.rc.014
267
-     */
268
-    public function get_contexts_for_message_types_for_list_table()
269
-    {
270
-        EE_Error::doing_it_wrong(
271
-            __METHOD__,
272
-            sprintf(
273
-                esc_html__(
274
-                    'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type context filter dropdown which is now generated differently via %s',
275
-                    'event_espresso'
276
-                ),
277
-                'Messages_Admin_Page::get_contexts_for_message_types_select_input()'
278
-            ),
279
-            '4.9.9.rc.014'
280
-        );
281
-
282
-        $contexts                = [];
283
-        $active_message_contexts = $this->getMsgModel()->get_all(['group_by' => 'MSG_context']);
284
-        foreach ($active_message_contexts as $active_message) {
285
-            if ($active_message instanceof EE_Message) {
286
-                $message_type = $active_message->message_type_object();
287
-                if ($message_type instanceof EE_message_type) {
288
-                    $message_type_contexts = $message_type->get_contexts();
289
-                    foreach ($message_type_contexts as $context => $context_details) {
290
-                        $contexts[ $context ] = $context_details['label'];
291
-                    }
292
-                }
293
-            }
294
-        }
295
-
296
-        return $contexts;
297
-    }
298
-
299
-
300
-    /**
301
-     * Generate select input with provided messenger options array.
302
-     *
303
-     * @param array $messenger_options Array of messengers indexed by messenger slug and values are the messenger
304
-     *                                 labels.
305
-     * @return string
306
-     * @throws EE_Error
307
-     */
308
-    public function get_messengers_select_input($messenger_options)
309
-    {
310
-        // if empty or just one value then just return an empty string
311
-        if (
312
-            empty($messenger_options)
313
-            || ! is_array($messenger_options)
314
-            || count($messenger_options) === 1
315
-        ) {
316
-            return '';
317
-        }
318
-        // merge in default
319
-        $messenger_options = array_merge(
320
-            ['none_selected' => esc_html__('Show All Messengers', 'event_espresso')],
321
-            $messenger_options
322
-        );
323
-        $input             = new EE_Select_Input(
324
-            $messenger_options,
325
-            [
326
-                'html_name'  => 'ee_messenger_filter_by',
327
-                'html_id'    => 'ee_messenger_filter_by',
328
-                'html_class' => 'wide',
329
-                'default'    => $this->request->getRequestParam('ee_messenger_filter_by', 'none_selected', 'title'),
330
-            ]
331
-        );
332
-
333
-        return $input->get_html_for_input();
334
-    }
335
-
336
-
337
-    /**
338
-     * Generate select input with provided message type options array.
339
-     *
340
-     * @param array $message_type_options Array of message types indexed by message type slug, and values are the
341
-     *                                    message type labels
342
-     * @return string
343
-     * @throws EE_Error
344
-     */
345
-    public function get_message_types_select_input($message_type_options)
346
-    {
347
-        // if empty or count of options is 1 then just return an empty string
348
-        if (
349
-            empty($message_type_options)
350
-            || ! is_array($message_type_options)
351
-            || count($message_type_options) === 1
352
-        ) {
353
-            return '';
354
-        }
355
-        // merge in default
356
-        $message_type_options = array_merge(
357
-            ['none_selected' => esc_html__('Show All Message Types', 'event_espresso')],
358
-            $message_type_options
359
-        );
360
-        $input                = new EE_Select_Input(
361
-            $message_type_options,
362
-            [
363
-                'html_name'  => 'ee_message_type_filter_by',
364
-                'html_id'    => 'ee_message_type_filter_by',
365
-                'html_class' => 'wide',
366
-                'default'    => $this->request->getRequestParam('ee_message_type_filter_by', 'none_selected', 'title'),
367
-            ]
368
-        );
369
-
370
-        return $input->get_html_for_input();
371
-    }
372
-
373
-
374
-    /**
375
-     * Generate select input with provide message type contexts array.
376
-     *
377
-     * @param array $context_options Array of message type contexts indexed by context slug, and values are the
378
-     *                               context label.
379
-     * @return string
380
-     * @throws EE_Error
381
-     */
382
-    public function get_contexts_for_message_types_select_input($context_options)
383
-    {
384
-        // if empty or count of options is one then just return empty string
385
-        if (
386
-            empty($context_options)
387
-            || ! is_array($context_options)
388
-            || count($context_options) === 1
389
-        ) {
390
-            return '';
391
-        }
392
-        // merge in default
393
-        $context_options = array_merge(
394
-            ['none_selected' => esc_html__('Show all Contexts', 'event_espresso')],
395
-            $context_options
396
-        );
397
-        $input           = new EE_Select_Input(
398
-            $context_options,
399
-            [
400
-                'html_name'  => 'ee_context_filter_by',
401
-                'html_id'    => 'ee_context_filter_by',
402
-                'html_class' => 'wide',
403
-                'default'    => $this->request->getRequestParam('ee_context_filter_by', 'none_selected', 'title'),
404
-            ]
405
-        );
406
-
407
-        return $input->get_html_for_input();
408
-    }
409
-
410
-
411
-    protected function _ajax_hooks()
412
-    {
413
-        add_action('wp_ajax_activate_messenger', [$this, 'activate_messenger_toggle']);
414
-        add_action('wp_ajax_activate_mt', [$this, 'activate_mt_toggle']);
415
-        add_action('wp_ajax_ee_msgs_save_settings', [$this, 'save_settings']);
416
-        add_action('wp_ajax_ee_msgs_update_mt_form', [$this, 'update_mt_form']);
417
-        add_action('wp_ajax_switch_template_pack', [$this, 'switch_template_pack']);
418
-        add_action('wp_ajax_toggle_context_template', [$this, 'toggle_context_template']);
419
-    }
420
-
421
-
422
-    protected function _define_page_props()
423
-    {
424
-        $this->_admin_page_title = $this->page_label;
425
-        $this->_labels           = [
426
-            'buttons'    => [
427
-                'add'    => esc_html__('Add New Message Template', 'event_espresso'),
428
-                'edit'   => esc_html__('Edit Message Template', 'event_espresso'),
429
-                'delete' => esc_html__('Delete Message Template', 'event_espresso'),
430
-            ],
431
-            'publishbox' => esc_html__('Update Actions', 'event_espresso'),
432
-        ];
433
-    }
434
-
435
-
436
-    /**
437
-     *        an array for storing key => value pairs of request actions and their corresponding methods
438
-     *
439
-     * @access protected
440
-     * @return void
441
-     */
442
-    protected function _set_page_routes()
443
-    {
444
-        $GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
445
-        $GRP_ID = $this->request->getRequestParam('id', $GRP_ID, 'int');
446
-        $MSG_ID = $this->request->getRequestParam('MSG_ID', 0, 'int');
447
-
448
-        $this->_page_routes = [
449
-            'default'                          => [
450
-                'func'       => '_message_queue_list_table',
451
-                'capability' => 'ee_read_global_messages',
452
-            ],
453
-            'global_mtps'                      => [
454
-                'func'       => '_ee_default_messages_overview_list_table',
455
-                'capability' => 'ee_read_global_messages',
456
-            ],
457
-            'custom_mtps'                      => [
458
-                'func'       => '_custom_mtps_preview',
459
-                'capability' => 'ee_read_messages',
460
-            ],
461
-            'add_new_message_template'         => [
462
-                'func'       => 'add_message_template',
463
-                'capability' => 'ee_edit_messages',
464
-                'noheader'   => true,
465
-            ],
466
-            'edit_message_template'            => [
467
-                'func'       => '_edit_message_template',
468
-                'capability' => 'ee_edit_message',
469
-                'obj_id'     => $GRP_ID,
470
-            ],
471
-            'preview_message'                  => [
472
-                'func'               => '_preview_message',
473
-                'capability'         => 'ee_read_message',
474
-                'obj_id'             => $GRP_ID,
475
-                'noheader'           => true,
476
-                'headers_sent_route' => 'display_preview_message',
477
-            ],
478
-            'display_preview_message'          => [
479
-                'func'       => '_display_preview_message',
480
-                'capability' => 'ee_read_message',
481
-                'obj_id'     => $GRP_ID,
482
-            ],
483
-            'insert_message_template'          => [
484
-                'func'       => '_insert_or_update_message_template',
485
-                'capability' => 'ee_edit_messages',
486
-                'args'       => ['new' => true],
487
-                'noheader'   => true,
488
-            ],
489
-            'update_message_template'          => [
490
-                'func'       => '_insert_or_update_message_template',
491
-                'capability' => 'ee_edit_message',
492
-                'obj_id'     => $GRP_ID,
493
-                'args'       => ['new' => false],
494
-                'noheader'   => true,
495
-            ],
496
-            'trash_message_template'           => [
497
-                'func'       => '_trash_or_restore_message_template',
498
-                'capability' => 'ee_delete_message',
499
-                'obj_id'     => $GRP_ID,
500
-                'args'       => ['trash' => true, 'all' => true],
501
-                'noheader'   => true,
502
-            ],
503
-            'trash_message_template_context'   => [
504
-                'func'       => '_trash_or_restore_message_template',
505
-                'capability' => 'ee_delete_message',
506
-                'obj_id'     => $GRP_ID,
507
-                'args'       => ['trash' => true],
508
-                'noheader'   => true,
509
-            ],
510
-            'restore_message_template'         => [
511
-                'func'       => '_trash_or_restore_message_template',
512
-                'capability' => 'ee_delete_message',
513
-                'obj_id'     => $GRP_ID,
514
-                'args'       => ['trash' => false, 'all' => true],
515
-                'noheader'   => true,
516
-            ],
517
-            'restore_message_template_context' => [
518
-                'func'       => '_trash_or_restore_message_template',
519
-                'capability' => 'ee_delete_message',
520
-                'obj_id'     => $GRP_ID,
521
-                'args'       => ['trash' => false],
522
-                'noheader'   => true,
523
-            ],
524
-            'delete_message_template'          => [
525
-                'func'       => '_delete_message_template',
526
-                'capability' => 'ee_delete_message',
527
-                'obj_id'     => $GRP_ID,
528
-                'noheader'   => true,
529
-            ],
530
-            'reset_to_default'                 => [
531
-                'func'       => '_reset_to_default_template',
532
-                'capability' => 'ee_edit_message',
533
-                'obj_id'     => $GRP_ID,
534
-                'noheader'   => true,
535
-            ],
536
-            'settings'                         => [
537
-                'func'       => '_settings',
538
-                'capability' => 'manage_options',
539
-            ],
540
-            'update_global_settings'           => [
541
-                'func'       => '_update_global_settings',
542
-                'capability' => 'manage_options',
543
-                'noheader'   => true,
544
-            ],
545
-            'generate_now'                     => [
546
-                'func'       => '_generate_now',
547
-                'capability' => 'ee_send_message',
548
-                'noheader'   => true,
549
-            ],
550
-            'generate_and_send_now'            => [
551
-                'func'       => '_generate_and_send_now',
552
-                'capability' => 'ee_send_message',
553
-                'noheader'   => true,
554
-            ],
555
-            'queue_for_resending'              => [
556
-                'func'       => '_queue_for_resending',
557
-                'capability' => 'ee_send_message',
558
-                'noheader'   => true,
559
-            ],
560
-            'send_now'                         => [
561
-                'func'       => '_send_now',
562
-                'capability' => 'ee_send_message',
563
-                'noheader'   => true,
564
-            ],
565
-            'delete_ee_message'                => [
566
-                'func'       => '_delete_ee_messages',
567
-                'capability' => 'ee_delete_messages',
568
-                'noheader'   => true,
569
-            ],
570
-            'delete_ee_messages'               => [
571
-                'func'       => '_delete_ee_messages',
572
-                'capability' => 'ee_delete_messages',
573
-                'noheader'   => true,
574
-                'obj_id'     => $MSG_ID,
575
-            ],
576
-        ];
577
-    }
578
-
579
-
580
-    protected function _set_page_config()
581
-    {
582
-        $this->_page_config = [
583
-            'default'                  => [
584
-                'nav'           => [
585
-                    'label' => esc_html__('Message Activity', 'event_espresso'),
586
-                    'order' => 10,
587
-                ],
588
-                'list_table'    => 'EE_Message_List_Table',
589
-                // 'qtips' => array( 'EE_Message_List_Table_Tips' ),
590
-                'require_nonce' => false,
591
-            ],
592
-            'global_mtps'              => [
593
-                'nav'           => [
594
-                    'label' => esc_html__('Default Message Templates', 'event_espresso'),
595
-                    'order' => 20,
596
-                ],
597
-                'list_table'    => 'Messages_Template_List_Table',
598
-                'help_tabs'     => [
599
-                    'messages_overview_help_tab'                                => [
600
-                        'title'    => esc_html__('Messages Overview', 'event_espresso'),
601
-                        'filename' => 'messages_overview',
602
-                    ],
603
-                    'messages_overview_messages_table_column_headings_help_tab' => [
604
-                        'title'    => esc_html__('Messages Table Column Headings', 'event_espresso'),
605
-                        'filename' => 'messages_overview_table_column_headings',
606
-                    ],
607
-                    'messages_overview_messages_filters_help_tab'               => [
608
-                        'title'    => esc_html__('Message Filters', 'event_espresso'),
609
-                        'filename' => 'messages_overview_filters',
610
-                    ],
611
-                    'messages_overview_messages_views_help_tab'                 => [
612
-                        'title'    => esc_html__('Message Views', 'event_espresso'),
613
-                        'filename' => 'messages_overview_views',
614
-                    ],
615
-                    'message_overview_message_types_help_tab'                   => [
616
-                        'title'    => esc_html__('Message Types', 'event_espresso'),
617
-                        'filename' => 'messages_overview_types',
618
-                    ],
619
-                    'messages_overview_messengers_help_tab'                     => [
620
-                        'title'    => esc_html__('Messengers', 'event_espresso'),
621
-                        'filename' => 'messages_overview_messengers',
622
-                    ],
623
-                ],
624
-                'require_nonce' => false,
625
-            ],
626
-            'custom_mtps'              => [
627
-                'nav'           => [
628
-                    'label' => esc_html__('Custom Message Templates', 'event_espresso'),
629
-                    'order' => 30,
630
-                ],
631
-                'help_tabs'     => [],
632
-                'require_nonce' => false,
633
-            ],
634
-            'add_new_message_template' => [
635
-                'nav'           => [
636
-                    'label'      => esc_html__('Add New Message Templates', 'event_espresso'),
637
-                    'order'      => 5,
638
-                    'persistent' => false,
639
-                ],
640
-                'require_nonce' => false,
641
-            ],
642
-            'edit_message_template'    => [
643
-                'labels'        => [
644
-                    'buttons'    => [
645
-                        'reset' => esc_html__('Reset Templates', 'event_espresso'),
646
-                    ],
647
-                    'publishbox' => esc_html__('Update Actions', 'event_espresso'),
648
-                ],
649
-                'nav'           => [
650
-                    'label'      => esc_html__('Edit Message Templates', 'event_espresso'),
651
-                    'order'      => 5,
652
-                    'persistent' => false,
653
-                    'url'        => '',
654
-                ],
655
-                'metaboxes'     => ['_publish_post_box', '_register_edit_meta_boxes'],
656
-                'has_metaboxes' => true,
657
-                'help_tabs'     => [
658
-                    'edit_message_template'            => [
659
-                        'title'    => esc_html__('Message Template Editor', 'event_espresso'),
660
-                        'callback' => 'edit_message_template_help_tab',
661
-                    ],
662
-                    'message_templates_help_tab'       => [
663
-                        'title'    => esc_html__('Message Templates', 'event_espresso'),
664
-                        'filename' => 'messages_templates',
665
-                    ],
666
-                    'message_template_shortcodes'      => [
667
-                        'title'    => esc_html__('Message Shortcodes', 'event_espresso'),
668
-                        'callback' => 'message_template_shortcodes_help_tab',
669
-                    ],
670
-                    'message_preview_help_tab'         => [
671
-                        'title'    => esc_html__('Message Preview', 'event_espresso'),
672
-                        'filename' => 'messages_preview',
673
-                    ],
674
-                    'messages_overview_other_help_tab' => [
675
-                        'title'    => esc_html__('Messages Other', 'event_espresso'),
676
-                        'filename' => 'messages_overview_other',
677
-                    ],
678
-                ],
679
-                'require_nonce' => false,
680
-            ],
681
-            'display_preview_message'  => [
682
-                'nav'           => [
683
-                    'label'      => esc_html__('Message Preview', 'event_espresso'),
684
-                    'order'      => 5,
685
-                    'url'        => '',
686
-                    'persistent' => false,
687
-                ],
688
-                'help_tabs'     => [
689
-                    'preview_message' => [
690
-                        'title'    => esc_html__('About Previews', 'event_espresso'),
691
-                        'callback' => 'preview_message_help_tab',
692
-                    ],
693
-                ],
694
-                'require_nonce' => false,
695
-            ],
696
-            'settings'                 => [
697
-                'nav'           => [
698
-                    'label' => esc_html__('Settings', 'event_espresso'),
699
-                    'order' => 40,
700
-                ],
701
-                'metaboxes'     => ['_messages_settings_metaboxes'],
702
-                'help_tabs'     => [
703
-                    'messages_settings_help_tab'               => [
704
-                        'title'    => esc_html__('Messages Settings', 'event_espresso'),
705
-                        'filename' => 'messages_settings',
706
-                    ],
707
-                    'messages_settings_message_types_help_tab' => [
708
-                        'title'    => esc_html__('Activating / Deactivating Message Types', 'event_espresso'),
709
-                        'filename' => 'messages_settings_message_types',
710
-                    ],
711
-                    'messages_settings_messengers_help_tab'    => [
712
-                        'title'    => esc_html__('Activating / Deactivating Messengers', 'event_espresso'),
713
-                        'filename' => 'messages_settings_messengers',
714
-                    ],
715
-                ],
716
-                'require_nonce' => false,
717
-            ],
718
-        ];
719
-    }
720
-
721
-
722
-    protected function _add_screen_options()
723
-    {
724
-        // todo
725
-    }
726
-
727
-
728
-    protected function _add_screen_options_global_mtps()
729
-    {
730
-        /**
731
-         * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options
732
-         * uses the $_admin_page_title property and we want different outputs in the different spots.
733
-         */
734
-        $page_title              = $this->_admin_page_title;
735
-        $this->_admin_page_title = esc_html__('Global Message Templates', 'event_espresso');
736
-        $this->_per_page_screen_option();
737
-        $this->_admin_page_title = $page_title;
738
-    }
739
-
740
-
741
-    protected function _add_screen_options_default()
742
-    {
743
-        $this->_admin_page_title = esc_html__('Message Activity', 'event_espresso');
744
-        $this->_per_page_screen_option();
745
-    }
746
-
747
-
748
-    // none of the below group are currently used for Messages
749
-    protected function _add_feature_pointers()
750
-    {
751
-    }
752
-
753
-
754
-    public function admin_init()
755
-    {
756
-    }
757
-
758
-
759
-    public function admin_notices()
760
-    {
761
-    }
762
-
763
-
764
-    public function admin_footer_scripts()
765
-    {
766
-    }
767
-
768
-
769
-    public function messages_help_tab()
770
-    {
771
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php');
772
-    }
773
-
774
-
775
-    public function messengers_help_tab()
776
-    {
777
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php');
778
-    }
779
-
780
-
781
-    public function message_types_help_tab()
782
-    {
783
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php');
784
-    }
785
-
786
-
787
-    public function messages_overview_help_tab()
788
-    {
789
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php');
790
-    }
791
-
792
-
793
-    public function message_templates_help_tab()
794
-    {
795
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php');
796
-    }
797
-
798
-
799
-    public function edit_message_template_help_tab()
800
-    {
801
-        $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="'
802
-                        . esc_attr__('Editor Title', 'event_espresso')
803
-                        . '" />';
804
-        $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="'
805
-                        . esc_attr__('Context Switcher and Preview', 'event_espresso')
806
-                        . '" />';
807
-        $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="'
808
-                        . esc_attr__('Message Template Form Fields', 'event_espresso')
809
-                        . '" />';
810
-        $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="'
811
-                        . esc_attr__('Shortcodes Metabox', 'event_espresso')
812
-                        . '" />';
813
-        $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="'
814
-                        . esc_attr__('Publish Metabox', 'event_espresso')
815
-                        . '" />';
816
-        EEH_Template::display_template(
817
-            EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php',
818
-            $args
819
-        );
820
-    }
821
-
822
-
823
-    /**
824
-     * @throws ReflectionException
825
-     * @throws EE_Error
826
-     */
827
-    public function message_template_shortcodes_help_tab()
828
-    {
829
-        $this->_set_shortcodes();
830
-        $args['shortcodes'] = $this->_shortcodes;
831
-        EEH_Template::display_template(
832
-            EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php',
833
-            $args
834
-        );
835
-    }
836
-
837
-
838
-    public function preview_message_help_tab()
839
-    {
840
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php');
841
-    }
842
-
843
-
844
-    public function settings_help_tab()
845
-    {
846
-        $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png'
847
-                        . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
848
-        $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
849
-                        . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
850
-        $args['img3'] = '<div class="switch">'
851
-                        . '<input class="ee-on-off-toggle ee-toggle-round-flat"'
852
-                        . ' type="checkbox" checked="checked">'
853
-                        . '<label for="ee-on-off-toggle-on"></label>'
854
-                        . '</div>';
855
-        $args['img4'] = '<div class="switch">'
856
-                        . '<input class="ee-on-off-toggle ee-toggle-round-flat"'
857
-                        . ' type="checkbox">'
858
-                        . '<label for="ee-on-off-toggle-on"></label>'
859
-                        . '</div>';
860
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
861
-    }
862
-
863
-
864
-    public function load_scripts_styles()
865
-    {
866
-        wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
867
-        wp_enqueue_style('espresso_ee_msg');
868
-
869
-        wp_register_script(
870
-            'ee-messages-settings',
871
-            EE_MSG_ASSETS_URL . 'ee-messages-settings.js',
872
-            ['jquery-ui-droppable', 'ee-serialize-full-array'],
873
-            EVENT_ESPRESSO_VERSION,
874
-            true
875
-        );
876
-        wp_register_script(
877
-            'ee-msg-list-table-js',
878
-            EE_MSG_ASSETS_URL . 'ee_message_admin_list_table.js',
879
-            ['ee-dialog'],
880
-            EVENT_ESPRESSO_VERSION
881
-        );
882
-    }
883
-
884
-
885
-    public function load_scripts_styles_default()
886
-    {
887
-        wp_enqueue_script('ee-msg-list-table-js');
888
-    }
889
-
890
-
891
-    public function wp_editor_css($mce_css)
892
-    {
893
-        // if we're on the edit_message_template route
894
-        if ($this->_req_action === 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
895
-            $message_type_name = $this->_active_message_type_name;
896
-
897
-            // we're going to REPLACE the existing mce css
898
-            // we need to get the css file location from the active messenger
899
-            $mce_css = $this->_active_messenger->get_variation(
900
-                $this->_template_pack,
901
-                $message_type_name,
902
-                true,
903
-                'wpeditor',
904
-                $this->_variation
905
-            );
906
-        }
907
-
908
-        return $mce_css;
909
-    }
910
-
911
-
912
-    /**
913
-     * @throws EE_Error
914
-     * @throws ReflectionException
915
-     */
916
-    public function load_scripts_styles_edit_message_template()
917
-    {
918
-
919
-        $this->_set_shortcodes();
920
-
921
-        EE_Registry::$i18n_js_strings['confirm_default_reset']        = sprintf(
922
-            esc_html__(
923
-                'Are you sure you want to reset the %s %s message templates?  Remember continuing will reset the templates for all contexts in this messenger and message type group.',
924
-                'event_espresso'
925
-            ),
926
-            $this->_message_template_group->messenger_obj()->label['singular'],
927
-            $this->_message_template_group->message_type_obj()->label['singular']
928
-        );
929
-        EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = esc_html__(
930
-            'Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?',
931
-            'event_espresso'
932
-        );
933
-        EE_Registry::$i18n_js_strings['server_error']                 = esc_html__(
934
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
935
-            'event_espresso'
936
-        );
937
-
938
-        wp_register_script(
939
-            'ee_msgs_edit_js',
940
-            EE_MSG_ASSETS_URL . 'ee_message_editor.js',
941
-            ['jquery'],
942
-            EVENT_ESPRESSO_VERSION
943
-        );
944
-
945
-        wp_enqueue_script('ee_admin_js');
946
-        wp_enqueue_script('ee_msgs_edit_js');
947
-
948
-        // add in special css for tiny_mce
949
-        add_filter('mce_css', [$this, 'wp_editor_css']);
950
-    }
951
-
952
-
953
-    /**
954
-     * @throws EE_Error
955
-     * @throws ReflectionException
956
-     */
957
-    public function load_scripts_styles_display_preview_message()
958
-    {
959
-        $this->_set_message_template_group();
960
-        if ($this->_active_messenger_name) {
961
-            $this->_active_messenger = $this->_message_resource_manager->get_active_messenger(
962
-                $this->_active_messenger_name
963
-            );
964
-        }
965
-
966
-        wp_enqueue_style(
967
-            'espresso_preview_css',
968
-            $this->_active_messenger->get_variation(
969
-                $this->_template_pack,
970
-                $this->_active_message_type_name,
971
-                true,
972
-                'preview',
973
-                $this->_variation
974
-            )
975
-        );
976
-    }
977
-
978
-
979
-    public function load_scripts_styles_settings()
980
-    {
981
-        wp_register_style(
982
-            'ee-message-settings',
983
-            EE_MSG_ASSETS_URL . 'ee_message_settings.css',
984
-            [],
985
-            EVENT_ESPRESSO_VERSION
986
-        );
987
-        wp_enqueue_style('ee-text-links');
988
-        wp_enqueue_style('ee-message-settings');
989
-        wp_enqueue_script('ee-messages-settings');
990
-    }
991
-
992
-
993
-    /**
994
-     * set views array for List Table
995
-     */
996
-    public function _set_list_table_views_global_mtps()
997
-    {
998
-        $this->_views = [
999
-            'in_use' => [
1000
-                'slug'  => 'in_use',
1001
-                'label' => esc_html__('In Use', 'event_espresso'),
1002
-                'count' => 0,
1003
-            ],
1004
-        ];
1005
-    }
1006
-
1007
-
1008
-    /**
1009
-     * Set views array for the Custom Template List Table
1010
-     */
1011
-    public function _set_list_table_views_custom_mtps()
1012
-    {
1013
-        $this->_set_list_table_views_global_mtps();
1014
-        $this->_views['in_use']['bulk_action'] = [
1015
-            'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'),
1016
-        ];
1017
-    }
1018
-
1019
-
1020
-    /**
1021
-     * set views array for message queue list table
1022
-     *
1023
-     * @throws InvalidDataTypeException
1024
-     * @throws InvalidInterfaceException
1025
-     * @throws InvalidArgumentException
1026
-     * @throws EE_Error
1027
-     * @throws ReflectionException
1028
-     */
1029
-    public function _set_list_table_views_default()
1030
-    {
1031
-        EE_Registry::instance()->load_helper('Template');
1032
-
1033
-        $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can(
1034
-            'ee_send_message',
1035
-            'message_list_table_bulk_actions'
1036
-        )
1037
-            ? [
1038
-                'generate_now'          => esc_html__('Generate Now', 'event_espresso'),
1039
-                'generate_and_send_now' => esc_html__('Generate and Send Now', 'event_espresso'),
1040
-                'queue_for_resending'   => esc_html__('Queue for Resending', 'event_espresso'),
1041
-                'send_now'              => esc_html__('Send Now', 'event_espresso'),
1042
-            ]
1043
-            : [];
1044
-
1045
-        $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can(
1046
-            'ee_delete_messages',
1047
-            'message_list_table_bulk_actions'
1048
-        )
1049
-            ? ['delete_ee_messages' => esc_html__('Delete Messages', 'event_espresso')]
1050
-            : [];
1051
-
1052
-
1053
-        $this->_views = [
1054
-            'all' => [
1055
-                'slug'        => 'all',
1056
-                'label'       => esc_html__('All', 'event_espresso'),
1057
-                'count'       => 0,
1058
-                'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action),
1059
-            ],
1060
-        ];
1061
-
1062
-
1063
-        foreach ($this->getMsgModel()->all_statuses() as $status) {
1064
-            if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) {
1065
-                continue;
1066
-            }
1067
-            $status_bulk_actions = $common_bulk_actions;
1068
-            // unset bulk actions not applying to status
1069
-            if (! empty($status_bulk_actions)) {
1070
-                switch ($status) {
1071
-                    case EEM_Message::status_idle:
1072
-                    case EEM_Message::status_resend:
1073
-                        $status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
1074
-                        break;
1075
-
1076
-                    case EEM_Message::status_failed:
1077
-                    case EEM_Message::status_debug_only:
1078
-                    case EEM_Message::status_messenger_executing:
1079
-                        $status_bulk_actions = [];
1080
-                        break;
1081
-
1082
-                    case EEM_Message::status_incomplete:
1083
-                        unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
1084
-                        break;
1085
-
1086
-                    case EEM_Message::status_retry:
1087
-                    case EEM_Message::status_sent:
1088
-                        unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
1089
-                        break;
1090
-                }
1091
-            }
1092
-
1093
-            // skip adding messenger executing status to views because it will be included with the Failed view.
1094
-            if ($status === EEM_Message::status_messenger_executing) {
1095
-                continue;
1096
-            }
1097
-
1098
-            $this->_views[ strtolower($status) ] = [
1099
-                'slug'        => strtolower($status),
1100
-                'label'       => EEH_Template::pretty_status($status, false, 'sentence'),
1101
-                'count'       => 0,
1102
-                'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action),
1103
-            ];
1104
-        }
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     * @throws EE_Error
1110
-     */
1111
-    protected function _ee_default_messages_overview_list_table()
1112
-    {
1113
-        $this->_admin_page_title = esc_html__('Default Message Templates', 'event_espresso');
1114
-        $this->display_admin_list_table_page_with_no_sidebar();
1115
-    }
1116
-
1117
-
1118
-    /**
1119
-     * @throws EE_Error
1120
-     * @throws ReflectionException
1121
-     */
1122
-    protected function _message_queue_list_table()
1123
-    {
1124
-        $this->_search_btn_label                   = esc_html__('Message Activity', 'event_espresso');
1125
-        $this->_template_args['per_column']        = 6;
1126
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_message_legend_items());
1127
-        $message_results = trim(EEM_Message::instance()->get_pretty_label_for_results());
1128
-        $this->_template_args['before_list_table'] = ! empty($message_results) ? "<h3>{$message_results}</h3>" : '';
1129
-        $this->display_admin_list_table_page_with_no_sidebar();
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * @throws EE_Error
1135
-     */
1136
-    protected function _message_legend_items()
1137
-    {
1138
-
1139
-        $action_css_classes = EEH_MSG_Template::get_message_action_icons();
1140
-        $action_items       = [];
1141
-
1142
-        foreach ($action_css_classes as $action_item => $action_details) {
1143
-            if ($action_item === 'see_notifications_for') {
1144
-                continue;
1145
-            }
1146
-            $action_items[ $action_item ] = [
1147
-                'class' => $action_details['css_class'],
1148
-                'desc'  => $action_details['label'],
1149
-            ];
1150
-        }
1151
-
1152
-        /** @var array $status_items status legend setup */
1153
-        $status_items = [
1154
-            'sent_status'                => [
1155
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_sent,
1156
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence'),
1157
-            ],
1158
-            'idle_status'                => [
1159
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_idle,
1160
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence'),
1161
-            ],
1162
-            'failed_status'              => [
1163
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_failed,
1164
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence'),
1165
-            ],
1166
-            'messenger_executing_status' => [
1167
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_messenger_executing,
1168
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_messenger_executing, false, 'sentence'),
1169
-            ],
1170
-            'resend_status'              => [
1171
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_resend,
1172
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence'),
1173
-            ],
1174
-            'incomplete_status'          => [
1175
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_incomplete,
1176
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence'),
1177
-            ],
1178
-            'retry_status'               => [
1179
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_retry,
1180
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence'),
1181
-            ],
1182
-        ];
1183
-        if (EEM_Message::debug()) {
1184
-            $status_items['debug_only_status'] = [
1185
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_debug_only,
1186
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence'),
1187
-            ];
1188
-        }
1189
-
1190
-        return array_merge($action_items, $status_items);
1191
-    }
1192
-
1193
-
1194
-    /**
1195
-     * @throws EE_Error
1196
-     */
1197
-    protected function _custom_mtps_preview()
1198
-    {
1199
-        $this->_admin_page_title              = esc_html__('Custom Message Templates (Preview)', 'event_espresso');
1200
-        $this->_template_args['preview_img']  = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png"'
1201
-                                                . ' alt="' . esc_attr__(
1202
-                                                    'Preview Custom Message Templates screenshot',
1203
-                                                    'event_espresso'
1204
-                                                ) . '" />';
1205
-        $this->_template_args['preview_text'] = '<strong>'
1206
-                                                . esc_html__(
1207
-                                                    'Custom Message Templates is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Custom Message Templates feature, you are able to create custom message templates and assign them on a per-event basis.',
1208
-                                                    'event_espresso'
1209
-                                                )
1210
-                                                . '</strong>';
1211
-
1212
-        $this->display_admin_caf_preview_page('custom_message_types', false);
1213
-    }
1214
-
1215
-
1216
-    /**
1217
-     * get_message_templates
1218
-     * This gets all the message templates for listing on the overview list.
1219
-     *
1220
-     * @access public
1221
-     * @param int    $per_page the amount of templates groups to show per page
1222
-     * @param string $type     the current _view we're getting templates for
1223
-     * @param bool   $count    return count?
1224
-     * @param bool   $all      disregard any paging info (get all data);
1225
-     * @param bool   $global   whether to return just global (true) or custom templates (false)
1226
-     * @return array
1227
-     * @throws EE_Error
1228
-     * @throws InvalidArgumentException
1229
-     * @throws InvalidDataTypeException
1230
-     * @throws InvalidInterfaceException
1231
-     */
1232
-    public function get_message_templates(
1233
-        $per_page = 10,
1234
-        $type = 'in_use',
1235
-        $count = false,
1236
-        $all = false,
1237
-        $global = true
1238
-    ) {
1239
-        $orderby = $this->request->getRequestParam('orderby', 'GRP_ID');
1240
-        $this->request->setRequestParam('orderby', $orderby);
1241
-
1242
-        $order        = $this->request->getRequestParam('order', 'ASC');
1243
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1244
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1245
-
1246
-        $offset = ($current_page - 1) * $per_page;
1247
-        $limit  = $all ? null : [$offset, $per_page];
1248
-
1249
-        // options will match what is in the _views array property
1250
-        return $type === 'in_use'
1251
-            ? $this->getMtgModel()->get_all_active_message_templates(
1252
-                $orderby,
1253
-                $order,
1254
-                $limit,
1255
-                $count,
1256
-                $global,
1257
-                true
1258
-            )
1259
-            : $this->getMtgModel()->get_all_trashed_grouped_message_templates(
1260
-                $orderby,
1261
-                $order,
1262
-                $limit,
1263
-                $count,
1264
-                $global
1265
-            );
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     * filters etc might need a list of installed message_types
1271
-     *
1272
-     * @return array an array of message type objects
1273
-     */
1274
-    public function get_installed_message_types()
1275
-    {
1276
-        $installed_message_types = $this->_message_resource_manager->installed_message_types();
1277
-        $installed               = [];
1278
-
1279
-        foreach ($installed_message_types as $message_type) {
1280
-            $installed[ $message_type->name ] = $message_type;
1281
-        }
1282
-
1283
-        return $installed;
1284
-    }
1285
-
1286
-
1287
-    /**
1288
-     * This is used when creating a custom template. All Custom Templates start based off another template.
1289
-     *
1290
-     * @param string $message_type
1291
-     * @param string $messenger
1292
-     * @param string $GRP_ID
1293
-     *
1294
-     * @throws EE_error
1295
-     * @throws ReflectionException
1296
-     */
1297
-    public function add_message_template($message_type = '', $messenger = '', $GRP_ID = '')
1298
-    {
1299
-        // set values override any request data
1300
-        $message_type = ! empty($message_type) ? $message_type : $this->_active_message_type_name;
1301
-        $messenger    = ! empty($messenger) ? $messenger : $this->_active_messenger_name;
1302
-        $GRP_ID       = ! empty($GRP_ID) ? $GRP_ID : $this->request->getRequestParam('GRP_ID', 0, 'int');
1303
-
1304
-        // we need messenger and message type.  They should be coming from the event editor. If not here then return error
1305
-        if (empty($message_type) || empty($messenger)) {
1306
-            throw new EE_Error(
1307
-                esc_html__(
1308
-                    'Sorry, but we can\'t create new templates because we\'re missing the messenger or message type',
1309
-                    'event_espresso'
1310
-                )
1311
-            );
1312
-        }
1313
-
1314
-        // we need the GRP_ID for the template being used as the base for the new template
1315
-        if (empty($GRP_ID)) {
1316
-            throw new EE_Error(
1317
-                esc_html__(
1318
-                    'In order to create a custom message template the GRP_ID of the template being used as a base is needed',
1319
-                    'event_espresso'
1320
-                )
1321
-            );
1322
-        }
1323
-
1324
-        // let's just make sure the template gets generated!
1325
-
1326
-        // we need to reassign some variables for what the insert is expecting
1327
-        $this->request->setRequestParam('MTP_messenger', $messenger);
1328
-        $this->request->setRequestParam('MTP_message_type', $message_type);
1329
-        $this->request->setRequestParam('GRP_ID', $GRP_ID);
1330
-
1331
-        $this->_insert_or_update_message_template(true);
1332
-    }
1333
-
1334
-
1335
-    /**
1336
-     * @param string $message_type     message type slug
1337
-     * @param string $messenger        messenger slug
1338
-     * @param int    $GRP_ID           GRP_ID for the related message template group this new template will be based
1339
-     *                                 off of.
1340
-     * @throws EE_error
1341
-     * @throws ReflectionException
1342
-     * @deprecated 4.10.29.p
1343
-     */
1344
-    protected function _add_message_template($message_type, $messenger, $GRP_ID)
1345
-    {
1346
-        $this->add_message_template($message_type, $messenger, $GRP_ID);
1347
-    }
1348
-
1349
-
1350
-    /**
1351
-     * _edit_message_template
1352
-     *
1353
-     * @access protected
1354
-     * @return void
1355
-     * @throws InvalidIdentifierException
1356
-     * @throws DomainException
1357
-     * @throws EE_Error
1358
-     * @throws InvalidArgumentException
1359
-     * @throws ReflectionException
1360
-     * @throws InvalidDataTypeException
1361
-     * @throws InvalidInterfaceException
1362
-     */
1363
-    protected function _edit_message_template()
1364
-    {
1365
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1366
-        $template_fields = '';
1367
-        $sidebar_fields  = '';
1368
-        // we filter the tinyMCE settings to remove the validation since message templates by their nature will not have
1369
-        // valid html in the templates.
1370
-        add_filter('tiny_mce_before_init', [$this, 'filter_tinymce_init'], 10, 2);
1371
-
1372
-        $GRP_ID = $this->request->getRequestParam('id', 0, 'int');
1373
-        $EVT_ID = $this->request->getRequestParam('evt_id', 0, 'int');
1374
-
1375
-        $this->_set_shortcodes(); // this also sets the _message_template property.
1376
-        $message_template_group = $this->_message_template_group;
1377
-        $c_label                = $message_template_group->context_label();
1378
-        $c_config               = $message_template_group->contexts_config();
1379
-
1380
-        reset($c_config);
1381
-        $context = $this->request->getRequestParam('context', key($c_config));
1382
-        $context = strtolower($context);
1383
-
1384
-        $action = empty($GRP_ID) ? 'insert_message_template' : 'update_message_template';
1385
-
1386
-        $edit_message_template_form_url = add_query_arg(
1387
-            ['action' => $action, 'noheader' => true],
1388
-            EE_MSG_ADMIN_URL
1389
-        );
1390
-
1391
-        // set active messenger for this view
1392
-        $this->_active_messenger         = $this->_message_resource_manager->get_active_messenger(
1393
-            $message_template_group->messenger()
1394
-        );
1395
-        $this->_active_message_type_name = $message_template_group->message_type();
1396
-
1397
-
1398
-        // Do we have any validation errors?
1399
-        $validators = $this->_get_transient();
1400
-        $v_fields   = ! empty($validators) ? array_keys($validators) : [];
1401
-
1402
-
1403
-        // we need to assemble the title from Various details
1404
-        $context_label = sprintf(
1405
-            esc_html__('(%s %s)', 'event_espresso'),
1406
-            $c_config[ $context ]['label'],
1407
-            ucwords($c_label['label'])
1408
-        );
1409
-
1410
-        $title = sprintf(
1411
-            esc_html__(' %s %s Template %s', 'event_espresso'),
1412
-            ucwords($message_template_group->messenger_obj()->label['singular']),
1413
-            ucwords($message_template_group->message_type_obj()->label['singular']),
1414
-            $context_label
1415
-        );
1416
-
1417
-        $this->_template_args['GRP_ID']           = $GRP_ID;
1418
-        $this->_template_args['message_template'] = $message_template_group;
1419
-        $this->_template_args['is_extra_fields']  = false;
1420
-
1421
-
1422
-        // let's get EEH_MSG_Template so we can get template form fields
1423
-        $template_field_structure = EEH_MSG_Template::get_fields(
1424
-            $message_template_group->messenger(),
1425
-            $message_template_group->message_type()
1426
-        );
1427
-
1428
-        if (! $template_field_structure) {
1429
-            $template_field_structure = false;
1430
-            $template_fields          = esc_html__(
1431
-                'There was an error in assembling the fields for this display (you should see an error message)',
1432
-                'event_espresso'
1433
-            );
1434
-        }
1435
-
1436
-
1437
-        $message_templates = $message_template_group->context_templates();
1438
-
1439
-
1440
-        // if we have the extra key.. then we need to remove the content index from the template_field_structure as it
1441
-        // will get handled in the "extra" array.
1442
-        if (is_array($template_field_structure[ $context ]) && isset($template_field_structure[ $context ]['extra'])) {
1443
-            foreach ($template_field_structure[ $context ]['extra'] as $reference_field => $new_fields) {
1444
-                unset($template_field_structure[ $context ][ $reference_field ]);
1445
-            }
1446
-        }
1447
-
1448
-        // let's loop through the template_field_structure and actually assemble the input fields!
1449
-        if (! empty($template_field_structure)) {
1450
-            foreach ($template_field_structure[ $context ] as $template_field => $field_setup_array) {
1451
-                // if this is an 'extra' template field then we need to remove any existing fields that are keyed up in
1452
-                // the extra array and reset them.
1453
-                if ($template_field === 'extra') {
1454
-                    $this->_template_args['is_extra_fields'] = true;
1455
-                    foreach ($field_setup_array as $reference_field => $new_fields_array) {
1456
-                        $message_template = $message_templates[ $context ][ $reference_field ];
1457
-                        $content          = $message_template instanceof EE_Message_Template
1458
-                            ? $message_template->get('MTP_content')
1459
-                            : '';
1460
-                        foreach ($new_fields_array as $extra_field => $extra_array) {
1461
-                            // let's verify if we need this extra field via the shortcodes parameter.
1462
-                            $continue = false;
1463
-                            if (isset($extra_array['shortcodes_required'])) {
1464
-                                foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
1465
-                                    if (! array_key_exists($shortcode, $this->_shortcodes)) {
1466
-                                        $continue = true;
1467
-                                    }
1468
-                                }
1469
-                                if ($continue) {
1470
-                                    continue;
1471
-                                }
1472
-                            }
1473
-
1474
-                            $field_id = $reference_field . '-' . $extra_field . '-content';
1475
-
1476
-                            $template_form_fields[ $field_id ]         = $extra_array;
1477
-                            $template_form_fields[ $field_id ]['name'] = 'MTP_template_fields['
1478
-                                                                         . $reference_field
1479
-                                                                         . '][content]['
1480
-                                                                         . $extra_field . ']';
1481
-                            $css_class                                 = isset($extra_array['css_class'])
1482
-                                ? $extra_array['css_class']
1483
-                                : '';
1484
-
1485
-                            $template_form_fields[ $field_id ]['css_class'] = ! empty($v_fields)
1486
-                                                                              && in_array($extra_field, $v_fields, true)
1487
-                                                                              && (
1488
-                                                                                  is_array($validators[ $extra_field ])
1489
-                                                                                  && isset($validators[ $extra_field ]['msg'])
1490
-                                                                              )
1491
-                                ? 'validate-error ' . $css_class
1492
-                                : $css_class;
1493
-
1494
-                            $template_form_fields[ $field_id ]['value'] = ! empty($message_templates)
1495
-                                                                          && isset($content[ $extra_field ])
1496
-                                ? $content[ $extra_field ]
1497
-                                : '';
1498
-
1499
-                            // do we have a validation error?  if we do then let's use that value instead
1500
-                            $template_form_fields[ $field_id ]['value'] = isset($validators[ $extra_field ])
1501
-                                ? $validators[ $extra_field ]['value']
1502
-                                : $template_form_fields[ $field_id ]['value'];
1503
-
1504
-
1505
-                            $template_form_fields[ $field_id ]['db-col'] = 'MTP_content';
1506
-
1507
-                            // shortcode selector
1508
-                            $field_name_to_use                                   = $extra_field === 'main'
1509
-                                ? 'content'
1510
-                                : $extra_field;
1511
-                            $template_form_fields[ $field_id ]['append_content'] = $this->_get_shortcode_selector(
1512
-                                $field_name_to_use,
1513
-                                $field_id
1514
-                            );
1515
-                        }
1516
-                        $template_field_MTP_id           = $reference_field . '-MTP_ID';
1517
-                        $template_field_template_name_id = $reference_field . '-name';
1518
-
1519
-                        $template_form_fields[ $template_field_MTP_id ] = [
1520
-                            'name'       => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1521
-                            'label'      => null,
1522
-                            'input'      => 'hidden',
1523
-                            'type'       => 'int',
1524
-                            'required'   => false,
1525
-                            'validation' => false,
1526
-                            'value'      => ! empty($message_templates) ? $message_template->ID() : '',
1527
-                            'css_class'  => '',
1528
-                            'format'     => '%d',
1529
-                            'db-col'     => 'MTP_ID',
1530
-                        ];
1531
-
1532
-                        $template_form_fields[ $template_field_template_name_id ] = [
1533
-                            'name'       => 'MTP_template_fields[' . $reference_field . '][name]',
1534
-                            'label'      => null,
1535
-                            'input'      => 'hidden',
1536
-                            'type'       => 'string',
1537
-                            'required'   => false,
1538
-                            'validation' => true,
1539
-                            'value'      => $reference_field,
1540
-                            'css_class'  => '',
1541
-                            'format'     => '%s',
1542
-                            'db-col'     => 'MTP_template_field',
1543
-                        ];
1544
-                    }
1545
-                    continue; // skip the next stuff, we got the necessary fields here for this dataset.
1546
-                } else {
1547
-                    $field_id                                   = $template_field . '-content';
1548
-                    $template_form_fields[ $field_id ]          = $field_setup_array;
1549
-                    $template_form_fields[ $field_id ]['name']  =
1550
-                        'MTP_template_fields[' . $template_field . '][content]';
1551
-                    $message_template                           =
1552
-                        isset($message_templates[ $context ][ $template_field ])
1553
-                            ? $message_templates[ $context ][ $template_field ]
1554
-                            : null;
1555
-                    $template_form_fields[ $field_id ]['value'] = ! empty($message_templates)
1556
-                                                                  && is_array($message_templates[ $context ])
1557
-                                                                  && $message_template instanceof EE_Message_Template
1558
-                        ? $message_template->get('MTP_content')
1559
-                        : '';
1560
-
1561
-                    // do we have a validator error for this field?  if we do then we'll use that value instead
1562
-                    $template_form_fields[ $field_id ]['value'] = isset($validators[ $template_field ])
1563
-                        ? $validators[ $template_field ]['value']
1564
-                        : $template_form_fields[ $field_id ]['value'];
1565
-
1566
-
1567
-                    $template_form_fields[ $field_id ]['db-col']    = 'MTP_content';
1568
-                    $css_class                                      = isset($field_setup_array['css_class'])
1569
-                        ? $field_setup_array['css_class']
1570
-                        : '';
1571
-                    $template_form_fields[ $field_id ]['css_class'] = ! empty($v_fields)
1572
-                                                                      && in_array($template_field, $v_fields, true)
1573
-                                                                      && isset($validators[ $template_field ]['msg'])
1574
-                        ? 'validate-error ' . $css_class
1575
-                        : $css_class;
1576
-
1577
-                    // shortcode selector
1578
-                    $template_form_fields[ $field_id ]['append_content'] = $this->_get_shortcode_selector(
1579
-                        $template_field,
1580
-                        $field_id
1581
-                    );
1582
-                }
1583
-
1584
-                // k took care of content field(s) now let's take care of others.
1585
-
1586
-                $template_field_MTP_id                 = $template_field . '-MTP_ID';
1587
-                $template_field_field_template_name_id = $template_field . '-name';
1588
-
1589
-                // foreach template field there are actually two form fields created
1590
-                $template_form_fields[ $template_field_MTP_id ] = [
1591
-                    'name'       => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1592
-                    'label'      => null,
1593
-                    'input'      => 'hidden',
1594
-                    'type'       => 'int',
1595
-                    'required'   => false,
1596
-                    'validation' => true,
1597
-                    'value'      => $message_template instanceof EE_Message_Template ? $message_template->ID() : '',
1598
-                    'css_class'  => '',
1599
-                    'format'     => '%d',
1600
-                    'db-col'     => 'MTP_ID',
1601
-                ];
1602
-
1603
-                $template_form_fields[ $template_field_field_template_name_id ] = [
1604
-                    'name'       => 'MTP_template_fields[' . $template_field . '][name]',
1605
-                    'label'      => null,
1606
-                    'input'      => 'hidden',
1607
-                    'type'       => 'string',
1608
-                    'required'   => false,
1609
-                    'validation' => true,
1610
-                    'value'      => $template_field,
1611
-                    'css_class'  => '',
1612
-                    'format'     => '%s',
1613
-                    'db-col'     => 'MTP_template_field',
1614
-                ];
1615
-            }
1616
-
1617
-            // add other fields
1618
-            $template_form_fields['ee-msg-current-context'] = [
1619
-                'name'       => 'MTP_context',
1620
-                'label'      => null,
1621
-                'input'      => 'hidden',
1622
-                'type'       => 'string',
1623
-                'required'   => false,
1624
-                'validation' => true,
1625
-                'value'      => $context,
1626
-                'css_class'  => '',
1627
-                'format'     => '%s',
1628
-                'db-col'     => 'MTP_context',
1629
-            ];
1630
-
1631
-            $template_form_fields['ee-msg-grp-id'] = [
1632
-                'name'       => 'GRP_ID',
1633
-                'label'      => null,
1634
-                'input'      => 'hidden',
1635
-                'type'       => 'int',
1636
-                'required'   => false,
1637
-                'validation' => true,
1638
-                'value'      => $GRP_ID,
1639
-                'css_class'  => '',
1640
-                'format'     => '%d',
1641
-                'db-col'     => 'GRP_ID',
1642
-            ];
1643
-
1644
-            $template_form_fields['ee-msg-messenger'] = [
1645
-                'name'       => 'MTP_messenger',
1646
-                'label'      => null,
1647
-                'input'      => 'hidden',
1648
-                'type'       => 'string',
1649
-                'required'   => false,
1650
-                'validation' => true,
1651
-                'value'      => $message_template_group->messenger(),
1652
-                'css_class'  => '',
1653
-                'format'     => '%s',
1654
-                'db-col'     => 'MTP_messenger',
1655
-            ];
1656
-
1657
-            $template_form_fields['ee-msg-message-type'] = [
1658
-                'name'       => 'MTP_message_type',
1659
-                'label'      => null,
1660
-                'input'      => 'hidden',
1661
-                'type'       => 'string',
1662
-                'required'   => false,
1663
-                'validation' => true,
1664
-                'value'      => $message_template_group->message_type(),
1665
-                'css_class'  => '',
1666
-                'format'     => '%s',
1667
-                'db-col'     => 'MTP_message_type',
1668
-            ];
1669
-
1670
-            $sidebar_form_fields['ee-msg-is-global'] = [
1671
-                'name'       => 'MTP_is_global',
1672
-                'label'      => esc_html__('Global Template', 'event_espresso'),
1673
-                'input'      => 'hidden',
1674
-                'type'       => 'int',
1675
-                'required'   => false,
1676
-                'validation' => true,
1677
-                'value'      => $message_template_group->get('MTP_is_global'),
1678
-                'css_class'  => '',
1679
-                'format'     => '%d',
1680
-                'db-col'     => 'MTP_is_global',
1681
-            ];
1682
-
1683
-            $sidebar_form_fields['ee-msg-is-override'] = [
1684
-                'name'       => 'MTP_is_override',
1685
-                'label'      => esc_html__('Override all custom', 'event_espresso'),
1686
-                'input'      => $message_template_group->is_global() ? 'checkbox' : 'hidden',
1687
-                'type'       => 'int',
1688
-                'required'   => false,
1689
-                'validation' => true,
1690
-                'value'      => $message_template_group->get('MTP_is_override'),
1691
-                'css_class'  => '',
1692
-                'format'     => '%d',
1693
-                'db-col'     => 'MTP_is_override',
1694
-            ];
1695
-
1696
-            $sidebar_form_fields['ee-msg-is-active'] = [
1697
-                'name'       => 'MTP_is_active',
1698
-                'label'      => esc_html__('Active Template', 'event_espresso'),
1699
-                'input'      => 'hidden',
1700
-                'type'       => 'int',
1701
-                'required'   => false,
1702
-                'validation' => true,
1703
-                'value'      => $message_template_group->is_active(),
1704
-                'css_class'  => '',
1705
-                'format'     => '%d',
1706
-                'db-col'     => 'MTP_is_active',
1707
-            ];
1708
-
1709
-            $sidebar_form_fields['ee-msg-deleted'] = [
1710
-                'name'       => 'MTP_deleted',
1711
-                'label'      => null,
1712
-                'input'      => 'hidden',
1713
-                'type'       => 'int',
1714
-                'required'   => false,
1715
-                'validation' => true,
1716
-                'value'      => $message_template_group->get('MTP_deleted'),
1717
-                'css_class'  => '',
1718
-                'format'     => '%d',
1719
-                'db-col'     => 'MTP_deleted',
1720
-            ];
1721
-            $sidebar_form_fields['ee-msg-author']  = [
1722
-                'name'       => 'MTP_user_id',
1723
-                'label'      => esc_html__('Author', 'event_espresso'),
1724
-                'input'      => 'hidden',
1725
-                'type'       => 'int',
1726
-                'required'   => false,
1727
-                'validation' => false,
1728
-                'value'      => $message_template_group->user(),
1729
-                'format'     => '%d',
1730
-                'db-col'     => 'MTP_user_id',
1731
-            ];
1732
-
1733
-            $sidebar_form_fields['ee-msg-route'] = [
1734
-                'name'  => 'action',
1735
-                'input' => 'hidden',
1736
-                'type'  => 'string',
1737
-                'value' => $action,
1738
-            ];
1739
-
1740
-            $sidebar_form_fields['ee-msg-id']        = [
1741
-                'name'  => 'id',
1742
-                'input' => 'hidden',
1743
-                'type'  => 'int',
1744
-                'value' => $GRP_ID,
1745
-            ];
1746
-            $sidebar_form_fields['ee-msg-evt-nonce'] = [
1747
-                'name'  => $action . '_nonce',
1748
-                'input' => 'hidden',
1749
-                'type'  => 'string',
1750
-                'value' => wp_create_nonce($action . '_nonce'),
1751
-            ];
1752
-
1753
-            $template_switch = $this->request->getRequestParam('template_switch');
1754
-            if ($template_switch) {
1755
-                $sidebar_form_fields['ee-msg-template-switch'] = [
1756
-                    'name'  => 'template_switch',
1757
-                    'input' => 'hidden',
1758
-                    'type'  => 'int',
1759
-                    'value' => 1,
1760
-                ];
1761
-            }
1762
-
1763
-
1764
-            $template_fields = $this->_generate_admin_form_fields($template_form_fields);
1765
-            $sidebar_fields  = $this->_generate_admin_form_fields($sidebar_form_fields);
1766
-        } //end if ( !empty($template_field_structure) )
1767
-
1768
-        // set extra content for publish box
1769
-        $this->_template_args['publish_box_extra_content'] = $sidebar_fields;
1770
-        $this->_set_publish_post_box_vars(
1771
-            'id',
1772
-            $GRP_ID,
1773
-            false,
1774
-            add_query_arg(
1775
-                ['action' => 'global_mtps'],
1776
-                $this->_admin_base_url
1777
-            )
1778
-        );
1779
-
1780
-        // add preview button
1781
-        $preview_url    = parent::add_query_args_and_nonce(
1782
-            [
1783
-                'message_type' => $message_template_group->message_type(),
1784
-                'messenger'    => $message_template_group->messenger(),
1785
-                'context'      => $context,
1786
-                'GRP_ID'       => $GRP_ID,
1787
-                'evt_id'       => $EVT_ID ?: false,
1788
-                'action'       => 'preview_message',
1789
-            ],
1790
-            $this->_admin_base_url
1791
-        );
1792
-        $preview_button = '<a href="' . $preview_url . '" class="button--secondary messages-preview-button">'
1793
-                          . esc_html__('Preview', 'event_espresso')
1794
-                          . '</a>';
1795
-
1796
-
1797
-        // setup context switcher
1798
-        $this->_set_context_switcher(
1799
-            $message_template_group,
1800
-            [
1801
-                'page'    => 'espresso_messages',
1802
-                'action'  => 'edit_message_template',
1803
-                'id'      => $GRP_ID,
1804
-                'evt_id'  => $EVT_ID,
1805
-                'context' => $context,
1806
-                'extra'   => $preview_button,
1807
-            ]
1808
-        );
1809
-
1810
-
1811
-        // main box
1812
-        $this->_template_args['template_fields']                         = $template_fields;
1813
-        $this->_template_args['sidebar_box_id']                          = 'details';
1814
-        $this->_template_args['action']                                  = $action;
1815
-        $this->_template_args['context']                                 = $context;
1816
-        $this->_template_args['edit_message_template_form_url']          = $edit_message_template_form_url;
1817
-        $this->_template_args['learn_more_about_message_templates_link'] =
1818
-            $this->_learn_more_about_message_templates_link();
1819
-
1820
-
1821
-        $this->_template_args['before_admin_page_content'] = '<div class="ee-msg-admin-header">';
1822
-        $this->_template_args['before_admin_page_content'] .= $this->add_active_context_element(
1823
-            $message_template_group,
1824
-            $context,
1825
-            $context_label
1826
-        );
1827
-        $this->_template_args['before_admin_page_content'] .= $this->add_context_switcher();
1828
-        $this->_template_args['before_admin_page_content'] .= '</div>';
1829
-        $this->_template_args['before_admin_page_content'] .= $this->_add_form_element_before();
1830
-        $this->_template_args['after_admin_page_content']  = $this->_add_form_element_after();
1831
-
1832
-        $this->_template_path = $this->_template_args['GRP_ID']
1833
-            ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1834
-            : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1835
-
1836
-        // send along EE_Message_Template_Group object for further template use.
1837
-        $this->_template_args['MTP'] = $message_template_group;
1838
-
1839
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1840
-            $this->_template_path,
1841
-            $this->_template_args,
1842
-            true
1843
-        );
1844
-
1845
-
1846
-        // finally, let's set the admin_page title
1847
-        $this->_admin_page_title = sprintf(esc_html__('Editing %s', 'event_espresso'), $title);
1848
-
1849
-
1850
-        // we need to take care of setting the shortcodes property for use elsewhere.
1851
-        $this->_set_shortcodes();
1852
-
1853
-
1854
-        // final template wrapper
1855
-        $this->display_admin_page_with_sidebar();
1856
-    }
1857
-
1858
-
1859
-    public function filter_tinymce_init($mceInit, $editor_id)
1860
-    {
1861
-        return $mceInit;
1862
-    }
1863
-
1864
-
1865
-    public function add_context_switcher()
1866
-    {
1867
-        return $this->_context_switcher;
1868
-    }
1869
-
1870
-
1871
-    /**
1872
-     * Adds the activation/deactivation toggle for the message template context.
1873
-     *
1874
-     * @param EE_Message_Template_Group $message_template_group
1875
-     * @param string                    $context
1876
-     * @param string                    $context_label
1877
-     * @return string
1878
-     * @throws DomainException
1879
-     * @throws EE_Error
1880
-     * @throws InvalidIdentifierException
1881
-     * @throws ReflectionException
1882
-     */
1883
-    protected function add_active_context_element(
1884
-        EE_Message_Template_Group $message_template_group,
1885
-        $context,
1886
-        $context_label
1887
-    ) {
1888
-        $template_args = [
1889
-            'context'                   => $context,
1890
-            'nonce'                     => wp_create_nonce('activate_' . $context . '_toggle_nonce'),
1891
-            'is_active'                 => $message_template_group->is_context_active($context),
1892
-            'on_off_action'             => $message_template_group->is_context_active($context)
1893
-                ? 'context-off'
1894
-                : 'context-on',
1895
-            'context_label'             => str_replace(['(', ')'], '', $context_label),
1896
-            'message_template_group_id' => $message_template_group->ID(),
1897
-        ];
1898
-        return EEH_Template::display_template(
1899
-            EE_MSG_TEMPLATE_PATH . 'ee_msg_editor_active_context_element.template.php',
1900
-            $template_args,
1901
-            true
1902
-        );
1903
-    }
1904
-
1905
-
1906
-    /**
1907
-     * Ajax callback for `toggle_context_template` ajax action.
1908
-     * Handles toggling the message context on or off.
1909
-     *
1910
-     * @throws EE_Error
1911
-     * @throws InvalidArgumentException
1912
-     * @throws InvalidDataTypeException
1913
-     * @throws InvalidIdentifierException
1914
-     * @throws InvalidInterfaceException
1915
-     */
1916
-    public function toggle_context_template()
1917
-    {
1918
-        $success = true;
1919
-        // check for required data
1920
-        if (
1921
-            ! (
1922
-                $this->request->requestParamIsSet('message_template_group_id')
1923
-                && $this->request->requestParamIsSet('context')
1924
-                && $this->request->requestParamIsSet('status')
1925
-            )
1926
-        ) {
1927
-            EE_Error::add_error(
1928
-                esc_html__('Required data for doing this action is not available.', 'event_espresso'),
1929
-                __FILE__,
1930
-                __FUNCTION__,
1931
-                __LINE__
1932
-            );
1933
-            $success = false;
1934
-        }
1935
-
1936
-        $nonce   = $this->request->getRequestParam('toggle_context_nonce', '');
1937
-        $context = $this->request->getRequestParam('context', '');
1938
-        $status  = $this->request->getRequestParam('status', '');
1939
-
1940
-        $this->_verify_nonce($nonce, "activate_{$context}_toggle_nonce");
1941
-
1942
-        if ($status !== 'off' && $status !== 'on') {
1943
-            EE_Error::add_error(
1944
-                sprintf(
1945
-                    esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
1946
-                    $status
1947
-                ),
1948
-                __FILE__,
1949
-                __FUNCTION__,
1950
-                __LINE__
1951
-            );
1952
-            $success = false;
1953
-        }
1954
-        $message_template_group_id = $this->request->getRequestParam('message_template_group_id', 0, 'int');
1955
-        $message_template_group    = $this->getMtgModel()->get_one_by_ID($message_template_group_id);
1956
-        if (! $message_template_group instanceof EE_Message_Template_Group) {
1957
-            EE_Error::add_error(
1958
-                sprintf(
1959
-                    esc_html__(
1960
-                        'Unable to change the active state because the given id "%1$d" does not match a valid "%2$s"',
1961
-                        'event_espresso'
1962
-                    ),
1963
-                    $message_template_group_id,
1964
-                    'EE_Message_Template_Group'
1965
-                ),
1966
-                __FILE__,
1967
-                __FUNCTION__,
1968
-                __LINE__
1969
-            );
1970
-            $success = false;
1971
-        }
1972
-        if ($success) {
1973
-            $success = $status === 'off'
1974
-                ? $message_template_group->deactivate_context($context)
1975
-                : $message_template_group->activate_context($context);
1976
-        }
1977
-        $this->_template_args['success'] = $success;
1978
-        $this->_return_json();
1979
-    }
1980
-
1981
-
1982
-    public function _add_form_element_before()
1983
-    {
1984
-        return '<form method="post" action="'
1985
-               . $this->_template_args['edit_message_template_form_url']
1986
-               . '" id="ee-msg-edit-frm">';
1987
-    }
1988
-
1989
-
1990
-    public function _add_form_element_after()
1991
-    {
1992
-        return '</form>';
1993
-    }
1994
-
1995
-
1996
-    /**
1997
-     * This executes switching the template pack for a message template.
1998
-     *
1999
-     * @throws EE_Error
2000
-     * @throws InvalidDataTypeException
2001
-     * @throws InvalidInterfaceException
2002
-     * @throws InvalidArgumentException
2003
-     * @throws ReflectionException
2004
-     * @since 4.5.0
2005
-     */
2006
-    public function switch_template_pack()
2007
-    {
2008
-
2009
-        $GRP_ID        = $this->request->getRequestParam('GRP_ID', 0, 'int');
2010
-        $template_pack = $this->request->getRequestParam('template_pack', '');
2011
-
2012
-        // verify we have needed values.
2013
-        if (empty($GRP_ID) || empty($template_pack)) {
2014
-            $this->_template_args['error'] = true;
2015
-            EE_Error::add_error(
2016
-                esc_html__('The required date for switching templates is not available.', 'event_espresso'),
2017
-                __FILE__,
2018
-                __FUNCTION__,
2019
-                __LINE__
2020
-            );
2021
-        } else {
2022
-            // get template, set the new template_pack and then reset to default
2023
-            /** @var EE_Message_Template_Group $message_template_group */
2024
-            $message_template_group = $this->getMtgModel()->get_one_by_ID($GRP_ID);
2025
-
2026
-            $message_template_group->set_template_pack_name($template_pack);
2027
-            $this->request->setRequestParam('msgr', $message_template_group->messenger());
2028
-            $this->request->setRequestParam('mt', $message_template_group->message_type());
2029
-
2030
-            $query_args = $this->_reset_to_default_template();
2031
-
2032
-            if (empty($query_args['id'])) {
2033
-                EE_Error::add_error(
2034
-                    esc_html__(
2035
-                        'Something went wrong with switching the template pack. Please try again or contact EE support',
2036
-                        'event_espresso'
2037
-                    ),
2038
-                    __FILE__,
2039
-                    __FUNCTION__,
2040
-                    __LINE__
2041
-                );
2042
-                $this->_template_args['error'] = true;
2043
-            } else {
2044
-                $template_label       = $message_template_group->get_template_pack()->label;
2045
-                $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels();
2046
-                EE_Error::add_success(
2047
-                    sprintf(
2048
-                        esc_html__(
2049
-                            'This message template has been successfully switched to use the %1$s %2$s.  Please wait while the page reloads with your new template.',
2050
-                            'event_espresso'
2051
-                        ),
2052
-                        $template_label,
2053
-                        $template_pack_labels->template_pack
2054
-                    )
2055
-                );
2056
-                // generate the redirect url for js.
2057
-                $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2058
-
2059
-                $this->_template_args['data']['redirect_url'] = $url;
2060
-                $this->_template_args['success']              = true;
2061
-            }
2062
-
2063
-            $this->_return_json();
2064
-        }
2065
-    }
2066
-
2067
-
2068
-    /**
2069
-     * This handles resetting the template for the given messenger/message_type so that users can start from scratch if
2070
-     * they want.
2071
-     *
2072
-     * @access protected
2073
-     * @return array|void
2074
-     * @throws EE_Error
2075
-     * @throws InvalidArgumentException
2076
-     * @throws InvalidDataTypeException
2077
-     * @throws InvalidInterfaceException
2078
-     * @throws ReflectionException
2079
-     */
2080
-    protected function _reset_to_default_template()
2081
-    {
2082
-        $templates    = [];
2083
-        $GRP_ID       = $this->request->getRequestParam('GRP_ID', 0, 'int');
2084
-        $messenger    = $this->request->getRequestParam('msgr');
2085
-        $message_type = $this->request->getRequestParam('mt');
2086
-        // we need to make sure we've got the info we need.
2087
-        if (! ($GRP_ID && $messenger && $message_type)) {
2088
-            EE_Error::add_error(
2089
-                esc_html__(
2090
-                    'In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.',
2091
-                    'event_espresso'
2092
-                ),
2093
-                __FILE__,
2094
-                __FUNCTION__,
2095
-                __LINE__
2096
-            );
2097
-        }
2098
-
2099
-        // all templates will be reset to whatever the defaults are
2100
-        // for the global template matching the messenger and message type.
2101
-        $success = ! empty($GRP_ID);
2102
-
2103
-        if ($success) {
2104
-            // let's first determine if the incoming template is a global template,
2105
-            // if it isn't then we need to get the global template matching messenger and message type.
2106
-            // $MTPG = $this->getMtgModel()->get_one_by_ID( $GRP_ID );
2107
-
2108
-
2109
-            // note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
2110
-            $success = $this->_delete_mtp_permanently($GRP_ID, false);
2111
-
2112
-            if ($success) {
2113
-                // if successfully deleted, lets generate the new ones.
2114
-                // Note. We set GLOBAL to true, because resets on ANY template
2115
-                // will use the related global template defaults for regeneration.
2116
-                // This means that if a custom template is reset it resets to whatever the related global template is.
2117
-                // HOWEVER, we DO keep the template pack and template variation set
2118
-                // for the current custom template when resetting.
2119
-                $templates = $this->_generate_new_templates($messenger, $message_type, $GRP_ID, true);
2120
-            }
2121
-        }
2122
-
2123
-        // any error messages?
2124
-        if (! $success) {
2125
-            EE_Error::add_error(
2126
-                esc_html__(
2127
-                    'Something went wrong with deleting existing templates. Unable to reset to default',
2128
-                    'event_espresso'
2129
-                ),
2130
-                __FILE__,
2131
-                __FUNCTION__,
2132
-                __LINE__
2133
-            );
2134
-        }
2135
-
2136
-        // all good, let's add a success message!
2137
-        if ($success && ! empty($templates)) {
2138
-            // the info for the template we generated is the first element in the returned array
2139
-            EE_Error::overwrite_success();
2140
-            EE_Error::add_success(esc_html__('Templates have been reset to defaults.', 'event_espresso'));
2141
-        }
2142
-
2143
-
2144
-        $query_args = [
2145
-            'id'      => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
2146
-            'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
2147
-            'action'  => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps',
2148
-        ];
2149
-
2150
-        // if called via ajax then we return query args otherwise redirect
2151
-        if ($this->request->isAjax()) {
2152
-            return $query_args;
2153
-        }
2154
-        $this->_redirect_after_action(false, '', '', $query_args, true);
2155
-    }
2156
-
2157
-
2158
-    /**
2159
-     * Retrieve and set the message preview for display.
2160
-     *
2161
-     * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
2162
-     * @return string
2163
-     * @throws ReflectionException
2164
-     * @throws EE_Error
2165
-     * @throws InvalidArgumentException
2166
-     * @throws InvalidDataTypeException
2167
-     * @throws InvalidInterfaceException
2168
-     */
2169
-    public function _preview_message($send = false)
2170
-    {
2171
-        // first make sure we've got the necessary parameters
2172
-        $GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
2173
-        if (! ($GRP_ID && $this->_active_messenger_name && $this->_active_message_type_name)) {
2174
-            EE_Error::add_error(
2175
-                esc_html__('Missing necessary parameters for displaying preview', 'event_espresso'),
2176
-                __FILE__,
2177
-                __FUNCTION__,
2178
-                __LINE__
2179
-            );
2180
-        }
2181
-
2182
-        $context = $this->request->getRequestParam('context');
2183
-        // get the preview!
2184
-        $preview = EED_Messages::preview_message(
2185
-            $this->_active_message_type_name,
2186
-            $context,
2187
-            $this->_active_messenger_name,
2188
-            $send
2189
-        );
2190
-
2191
-        if ($send) {
2192
-            return $preview;
2193
-        }
2194
-
2195
-        // if we have an evt_id set on the request, use it.
2196
-        $EVT_ID = $this->request->getRequestParam('evt_id', 0, 'int');
2197
-
2198
-        // let's add a button to go back to the edit view
2199
-        $query_args             = [
2200
-            'id'      => $GRP_ID,
2201
-            'evt_id'  => $EVT_ID,
2202
-            'context' => $context,
2203
-            'action'  => 'edit_message_template',
2204
-        ];
2205
-        $go_back_url            = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2206
-        $preview_button         = '<a href="'
2207
-                                  . $go_back_url
2208
-                                  . '" class="button--secondary messages-preview-go-back-button">'
2209
-                                  . esc_html__('Go Back to Edit', 'event_espresso')
2210
-                                  . '</a>';
2211
-        $message_types          = $this->get_installed_message_types();
2212
-        $active_messenger       = $this->_message_resource_manager->get_active_messenger($this->_active_messenger_name);
2213
-        $active_messenger_label = $active_messenger instanceof EE_messenger
2214
-            ? ucwords($active_messenger->label['singular'])
2215
-            : esc_html__('Unknown Messenger', 'event_espresso');
2216
-        // let's provide a helpful title for context
2217
-        $preview_title = sprintf(
2218
-            esc_html__('Viewing Preview for %s %s Message Template', 'event_espresso'),
2219
-            $active_messenger_label,
2220
-            ucwords($message_types[ $this->_active_message_type_name ]->label['singular'])
2221
-        );
2222
-        if (empty($preview)) {
2223
-            $this->noEventsErrorMessage();
2224
-        }
2225
-        // setup display of preview.
2226
-        $this->_admin_page_title                    = $preview_title;
2227
-        $this->_template_args['admin_page_title']   = $preview_title;
2228
-        $this->_template_args['admin_page_content'] = $preview_button . '<br />' . $preview;
2229
-        $this->_template_args['data']['force_json'] = true;
2230
-
2231
-        return '';
2232
-    }
2233
-
2234
-
2235
-    /**
2236
-     * Used to set an error if there are no events available for generating a preview/test send.
2237
-     *
2238
-     * @param bool $test_send Whether the error should be generated for the context of a test send.
2239
-     */
2240
-    protected function noEventsErrorMessage($test_send = false)
2241
-    {
2242
-        $events_url = parent::add_query_args_and_nonce(
2243
-            [
2244
-                'action' => 'default',
2245
-                'page'   => 'espresso_events',
2246
-            ],
2247
-            admin_url('admin.php')
2248
-        );
2249
-        $message    = $test_send
2250
-            ? esc_html__(
2251
-                'A test message could not be sent for this message template because there are no events created yet. The preview system uses actual events for generating the test message. %1$sGo see your events%2$s!',
2252
-                'event_espresso'
2253
-            )
2254
-            : esc_html__(
2255
-                'There is no preview for this message template available because there are no events created yet. The preview system uses actual events for generating the preview. %1$sGo see your events%2$s!',
2256
-                'event_espresso'
2257
-            );
2258
-
2259
-        EE_Error::add_attention(
2260
-            sprintf(
2261
-                $message,
2262
-                "<a href='{$events_url}'>",
2263
-                '</a>'
2264
-            )
2265
-        );
2266
-    }
2267
-
2268
-
2269
-    /**
2270
-     * The initial _preview_message is on a no headers route.  It will optionally call this if necessary otherwise it
2271
-     * gets called automatically.
2272
-     *
2273
-     * @return void
2274
-     * @throws EE_Error
2275
-     * @since 4.5.0
2276
-     *
2277
-     */
2278
-    protected function _display_preview_message()
2279
-    {
2280
-        $this->display_admin_page_with_no_sidebar();
2281
-    }
2282
-
2283
-
2284
-    /**
2285
-     * registers metaboxes that should show up on the "edit_message_template" page
2286
-     *
2287
-     * @access protected
2288
-     * @return void
2289
-     */
2290
-    protected function _register_edit_meta_boxes()
2291
-    {
2292
-        $this->addMetaBox(
2293
-            'mtp_valid_shortcodes',
2294
-            esc_html__('Valid Shortcodes', 'event_espresso'),
2295
-            [$this, 'shortcode_meta_box'],
2296
-            $this->_current_screen->id,
2297
-            'side'
2298
-        );
2299
-        $this->addMetaBox(
2300
-            'mtp_extra_actions',
2301
-            esc_html__('Extra Actions', 'event_espresso'),
2302
-            [$this, 'extra_actions_meta_box'],
2303
-            $this->_current_screen->id,
2304
-            'side',
2305
-            'high'
2306
-        );
2307
-        $this->addMetaBox(
2308
-            'mtp_templates',
2309
-            esc_html__('Template Styles', 'event_espresso'),
2310
-            [$this, 'template_pack_meta_box'],
2311
-            $this->_current_screen->id,
2312
-            'side',
2313
-            'high'
2314
-        );
2315
-    }
2316
-
2317
-
2318
-    /**
2319
-     * metabox content for all template pack and variation selection.
2320
-     *
2321
-     * @return void
2322
-     * @throws DomainException
2323
-     * @throws EE_Error
2324
-     * @throws InvalidArgumentException
2325
-     * @throws ReflectionException
2326
-     * @throws InvalidDataTypeException
2327
-     * @throws InvalidInterfaceException
2328
-     * @since 4.5.0
2329
-     */
2330
-    public function template_pack_meta_box()
2331
-    {
2332
-        $this->_set_message_template_group();
2333
-
2334
-        $tp_collection = EEH_MSG_Template::get_template_pack_collection();
2335
-
2336
-        $tp_select_values = [];
2337
-
2338
-        foreach ($tp_collection as $tp) {
2339
-            // only include template packs that support this messenger and message type!
2340
-            $supports = $tp->get_supports();
2341
-            if (
2342
-                ! isset($supports[ $this->_message_template_group->messenger() ])
2343
-                || ! in_array(
2344
-                    $this->_message_template_group->message_type(),
2345
-                    $supports[ $this->_message_template_group->messenger() ],
2346
-                    true
2347
-                )
2348
-            ) {
2349
-                // not supported
2350
-                continue;
2351
-            }
2352
-
2353
-            $tp_select_values[] = [
2354
-                'text' => $tp->label,
2355
-                'id'   => $tp->dbref,
2356
-            ];
2357
-        }
2358
-
2359
-        // if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by
2360
-        // the default template pack.  This still allows for the odd template pack to override.
2361
-        if (empty($tp_select_values)) {
2362
-            $tp_select_values[] = [
2363
-                'text' => esc_html__('Default', 'event_espresso'),
2364
-                'id'   => 'default',
2365
-            ];
2366
-        }
2367
-
2368
-        // setup variation select values for the currently selected template.
2369
-        $variations               = $this->_message_template_group->get_template_pack()->get_variations(
2370
-            $this->_message_template_group->messenger(),
2371
-            $this->_message_template_group->message_type()
2372
-        );
2373
-        $variations_select_values = [];
2374
-        foreach ($variations as $variation => $label) {
2375
-            $variations_select_values[] = [
2376
-                'text' => $label,
2377
-                'id'   => $variation,
2378
-            ];
2379
-        }
2380
-
2381
-        $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
2382
-
2383
-        $template_args['template_packs_selector']        = EEH_Form_Fields::select_input(
2384
-            'MTP_template_pack',
2385
-            $tp_select_values,
2386
-            $this->_message_template_group->get_template_pack_name()
2387
-        );
2388
-        $template_args['variations_selector']            = EEH_Form_Fields::select_input(
2389
-            'MTP_template_variation',
2390
-            $variations_select_values,
2391
-            $this->_message_template_group->get_template_pack_variation()
2392
-        );
2393
-        $template_args['template_pack_label']            = $template_pack_labels->template_pack;
2394
-        $template_args['template_variation_label']       = $template_pack_labels->template_variation;
2395
-        $template_args['template_pack_description']      = $template_pack_labels->template_pack_description;
2396
-        $template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
2397
-
2398
-        $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
2399
-
2400
-        EEH_Template::display_template($template, $template_args);
2401
-    }
2402
-
2403
-
2404
-    /**
2405
-     * This meta box holds any extra actions related to Message Templates
2406
-     * For now, this includes Resetting templates to defaults and sending a test email.
2407
-     *
2408
-     * @access  public
2409
-     * @return void
2410
-     * @throws EE_Error
2411
-     */
2412
-    public function extra_actions_meta_box()
2413
-    {
2414
-        $template_form_fields = [];
2415
-
2416
-        $extra_args = [
2417
-            'msgr'   => $this->_message_template_group->messenger(),
2418
-            'mt'     => $this->_message_template_group->message_type(),
2419
-            'GRP_ID' => $this->_message_template_group->GRP_ID(),
2420
-        ];
2421
-        // first we need to see if there are any fields
2422
-        $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
2423
-
2424
-        if (! empty($fields)) {
2425
-            // yup there be fields
2426
-            foreach ($fields as $field => $config) {
2427
-                $field_id = $this->_message_template_group->messenger() . '_' . $field;
2428
-                $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
2429
-                $default  = isset($config['default']) ? $config['default'] : '';
2430
-                $default  = isset($config['value']) ? $config['value'] : $default;
2431
-
2432
-                // if type is hidden and the value is empty
2433
-                // something may have gone wrong so let's correct with the defaults
2434
-                $fix                = $config['input'] === 'hidden'
2435
-                                      && isset($existing[ $field ])
2436
-                                      && empty($existing[ $field ])
2437
-                    ? $default
2438
-                    : '';
2439
-                $existing[ $field ] = isset($existing[ $field ]) && empty($fix)
2440
-                    ? $existing[ $field ]
2441
-                    : $fix;
2442
-
2443
-                $template_form_fields[ $field_id ] = [
2444
-                    'name'       => 'test_settings_fld[' . $field . ']',
2445
-                    'label'      => $config['label'],
2446
-                    'input'      => $config['input'],
2447
-                    'type'       => $config['type'],
2448
-                    'required'   => $config['required'],
2449
-                    'validation' => $config['validation'],
2450
-                    'value'      => isset($existing[ $field ]) ? $existing[ $field ] : $default,
2451
-                    'css_class'  => $config['css_class'],
2452
-                    'options'    => isset($config['options']) ? $config['options'] : [],
2453
-                    'default'    => $default,
2454
-                    'format'     => $config['format'],
2455
-                ];
2456
-            }
2457
-        }
2458
-
2459
-        $test_settings_html = ! empty($template_form_fields)
2460
-            ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds')
2461
-            : '';
2462
-
2463
-        // print out $test_settings_fields
2464
-        if (! empty($test_settings_html)) {
2465
-            $test_settings_html .= '<input type="submit" class="button--primary mtp-test-button alignright" ';
2466
-            $test_settings_html .= 'name="test_button" value="';
2467
-            $test_settings_html .= esc_html__('Test Send', 'event_espresso');
2468
-            $test_settings_html .= '" /><div style="clear:both"></div>';
2469
-        }
2470
-
2471
-        // and button
2472
-        $test_settings_html .= '<div class="publishing-action alignright resetbutton">';
2473
-        $test_settings_html .= '<p>';
2474
-        $test_settings_html .= esc_html__('Need to reset this message type and start over?', 'event_espresso');
2475
-        $test_settings_html .= '</p>';
2476
-        $test_settings_html .= $this->get_action_link_or_button(
2477
-            'reset_to_default',
2478
-            'reset',
2479
-            $extra_args,
2480
-            'button--primary reset-default-button'
2481
-        );
2482
-        $test_settings_html .= '</div><div style="clear:both"></div>';
2483
-        echo $test_settings_html; // already escaped
2484
-    }
2485
-
2486
-
2487
-    /**
2488
-     * This returns the shortcode selector skeleton for a given context and field.
2489
-     *
2490
-     * @param string $field           The name of the field retrieving shortcodes for.
2491
-     * @param string $linked_input_id The css id of the input that the shortcodes get added to.
2492
-     * @return string
2493
-     * @throws DomainException
2494
-     * @throws EE_Error
2495
-     * @throws InvalidArgumentException
2496
-     * @throws ReflectionException
2497
-     * @throws InvalidDataTypeException
2498
-     * @throws InvalidInterfaceException
2499
-     * @since 4.9.rc.000
2500
-     */
2501
-    protected function _get_shortcode_selector($field, $linked_input_id)
2502
-    {
2503
-        $template_args = [
2504
-            'shortcodes'      => $this->_get_shortcodes([$field]),
2505
-            'fieldname'       => $field,
2506
-            'linked_input_id' => $linked_input_id,
2507
-        ];
2508
-
2509
-        return EEH_Template::display_template(
2510
-            EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php',
2511
-            $template_args,
2512
-            true
2513
-        );
2514
-    }
2515
-
2516
-
2517
-    /**
2518
-     * This just takes care of returning the meta box content for shortcodes (only used on the edit message template
2519
-     * page)
2520
-     *
2521
-     * @access public
2522
-     * @return void
2523
-     * @throws EE_Error
2524
-     * @throws InvalidArgumentException
2525
-     * @throws ReflectionException
2526
-     * @throws InvalidDataTypeException
2527
-     * @throws InvalidInterfaceException
2528
-     */
2529
-    public function shortcode_meta_box()
2530
-    {
2531
-        $shortcodes = $this->_get_shortcodes([], false);
2532
-        // just make sure the shortcodes property is set
2533
-        // $messenger = $this->_message_template_group->messenger_obj();
2534
-        // now let's set the content depending on the status of the shortcodes array
2535
-        if (empty($shortcodes)) {
2536
-            echo '<p>' . esc_html__('There are no valid shortcodes available', 'event_espresso') . '</p>';
2537
-            return;
2538
-        }
2539
-        ?>
19
+	/**
20
+	 * @var EEM_Message
21
+	 */
22
+	private $MSG_MODEL;
23
+
24
+	/**
25
+	 * @var EEM_Message_Template
26
+	 */
27
+	private $MTP_MODEL;
28
+
29
+	/**
30
+	 * @var EEM_Message_Template_Group
31
+	 */
32
+	private $MTG_MODEL;
33
+
34
+	/**
35
+	 * @var EE_Message_Resource_Manager $_message_resource_manager
36
+	 */
37
+	protected $_message_resource_manager;
38
+
39
+	/**
40
+	 * @var string
41
+	 */
42
+	protected $_active_message_type_name = '';
43
+
44
+	/**
45
+	 * @var string
46
+	 */
47
+	protected $_active_messenger_name = '';
48
+
49
+	/**
50
+	 * @var EE_messenger $_active_messenger
51
+	 */
52
+	protected $_active_messenger;
53
+
54
+	protected $_activate_meta_box_type;
55
+
56
+	protected $_current_message_meta_box;
57
+
58
+	protected $_current_message_meta_box_object;
59
+
60
+	protected $_context_switcher;
61
+
62
+	protected $_shortcodes           = [];
63
+
64
+	protected $_active_messengers    = [];
65
+
66
+	protected $_active_message_types = [];
67
+
68
+	/**
69
+	 * @var EE_Message_Template_Group $_message_template_group
70
+	 */
71
+	protected $_message_template_group;
72
+
73
+	protected $_m_mt_settings = [];
74
+
75
+
76
+	/**
77
+	 * This is set via the _set_message_template_group method and holds whatever the template pack for the group is.
78
+	 * IF there is no group then it gets automatically set to the Default template pack.
79
+	 *
80
+	 * @since 4.5.0
81
+	 *
82
+	 * @var EE_Messages_Template_Pack
83
+	 */
84
+	protected $_template_pack;
85
+
86
+
87
+	/**
88
+	 * This is set via the _set_message_template_group method and holds whatever the template pack variation for the
89
+	 * group is.  If there is no group then it automatically gets set to default.
90
+	 *
91
+	 * @since 4.5.0
92
+	 *
93
+	 * @var string
94
+	 */
95
+	protected $_variation;
96
+
97
+
98
+	/**
99
+	 * @param bool $routing
100
+	 * @throws EE_Error
101
+	 * @throws ReflectionException
102
+	 */
103
+	public function __construct($routing = true)
104
+	{
105
+		// make sure messages autoloader is running
106
+		EED_Messages::set_autoloaders();
107
+		parent::__construct($routing);
108
+	}
109
+
110
+
111
+	/**
112
+	 * @return EEM_Message
113
+	 * @throws EE_Error
114
+	 */
115
+	public function getMsgModel()
116
+	{
117
+		if (! $this->MSG_MODEL instanceof EEM_Message) {
118
+			$this->MSG_MODEL = EEM_Message::instance();
119
+		}
120
+		return $this->MSG_MODEL;
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return EEM_Message_Template
126
+	 * @throws EE_Error
127
+	 */
128
+	public function getMtpModel()
129
+	{
130
+		if (! $this->MTP_MODEL instanceof EEM_Message_Template) {
131
+			$this->MTP_MODEL = EEM_Message_Template::instance();
132
+		}
133
+		return $this->MTP_MODEL;
134
+	}
135
+
136
+
137
+	/**
138
+	 * @return EEM_Message_Template_Group
139
+	 * @throws EE_Error
140
+	 */
141
+	public function getMtgModel()
142
+	{
143
+		if (! $this->MTG_MODEL instanceof EEM_Message_Template_Group) {
144
+			$this->MTG_MODEL = EEM_Message_Template_Group::instance();
145
+		}
146
+		return $this->MTG_MODEL;
147
+	}
148
+
149
+
150
+	/**
151
+	 * @throws EE_Error
152
+	 * @throws ReflectionException
153
+	 */
154
+	protected function _init_page_props()
155
+	{
156
+		$this->page_slug        = EE_MSG_PG_SLUG;
157
+		$this->page_label       = esc_html__('Messages Settings', 'event_espresso');
158
+		$this->_admin_base_url  = EE_MSG_ADMIN_URL;
159
+		$this->_admin_base_path = EE_MSG_ADMIN;
160
+
161
+		$messenger    = $this->request->getRequestParam('messenger', '');
162
+		$message_type = $this->request->getRequestParam('message_type', '');
163
+		$this->_active_messenger_name    = $this->request->getRequestParam('MTP_messenger', $messenger);
164
+		$this->_active_message_type_name = $this->request->getRequestParam('MTP_message_type', $message_type);
165
+
166
+		$this->_load_message_resource_manager();
167
+	}
168
+
169
+
170
+	/**
171
+	 * loads messenger objects into the $_active_messengers property (so we can access the needed methods)
172
+	 *
173
+	 * @throws EE_Error
174
+	 * @throws InvalidDataTypeException
175
+	 * @throws InvalidInterfaceException
176
+	 * @throws InvalidArgumentException
177
+	 * @throws ReflectionException
178
+	 */
179
+	protected function _load_message_resource_manager()
180
+	{
181
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
182
+	}
183
+
184
+
185
+	/**
186
+	 * @return array
187
+	 * @throws EE_Error
188
+	 * @throws InvalidArgumentException
189
+	 * @throws InvalidDataTypeException
190
+	 * @throws InvalidInterfaceException
191
+	 * @deprecated 4.9.9.rc.014
192
+	 */
193
+	public function get_messengers_for_list_table()
194
+	{
195
+		EE_Error::doing_it_wrong(
196
+			__METHOD__,
197
+			sprintf(
198
+				esc_html__(
199
+					'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a messenger filter dropdown which is now generated differently via %s',
200
+					'event_espresso'
201
+				),
202
+				'Messages_Admin_Page::get_messengers_select_input()'
203
+			),
204
+			'4.9.9.rc.014'
205
+		);
206
+
207
+		$m_values          = [];
208
+		$active_messengers = $this->getMsgModel()->get_all(['group_by' => 'MSG_messenger']);
209
+		// setup messengers for selects
210
+		$i = 1;
211
+		foreach ($active_messengers as $active_messenger) {
212
+			if ($active_messenger instanceof EE_Message) {
213
+				$m_values[ $i ]['id']   = $active_messenger->messenger();
214
+				$m_values[ $i ]['text'] = ucwords($active_messenger->messenger_label());
215
+				$i++;
216
+			}
217
+		}
218
+
219
+		return $m_values;
220
+	}
221
+
222
+
223
+	/**
224
+	 * @return array
225
+	 * @throws EE_Error
226
+	 * @throws InvalidArgumentException
227
+	 * @throws InvalidDataTypeException
228
+	 * @throws InvalidInterfaceException
229
+	 * @deprecated 4.9.9.rc.014
230
+	 */
231
+	public function get_message_types_for_list_table()
232
+	{
233
+		EE_Error::doing_it_wrong(
234
+			__METHOD__,
235
+			sprintf(
236
+				esc_html__(
237
+					'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type filter dropdown which is now generated differently via %s',
238
+					'event_espresso'
239
+				),
240
+				'Messages_Admin_Page::get_message_types_select_input()'
241
+			),
242
+			'4.9.9.rc.014'
243
+		);
244
+
245
+		$mt_values       = [];
246
+		$active_messages = $this->getMsgModel()->get_all(['group_by' => 'MSG_message_type']);
247
+		$i               = 1;
248
+		foreach ($active_messages as $active_message) {
249
+			if ($active_message instanceof EE_Message) {
250
+				$mt_values[ $i ]['id']   = $active_message->message_type();
251
+				$mt_values[ $i ]['text'] = ucwords($active_message->message_type_label());
252
+				$i++;
253
+			}
254
+		}
255
+
256
+		return $mt_values;
257
+	}
258
+
259
+
260
+	/**
261
+	 * @return array
262
+	 * @throws EE_Error
263
+	 * @throws InvalidArgumentException
264
+	 * @throws InvalidDataTypeException
265
+	 * @throws InvalidInterfaceException
266
+	 * @deprecated 4.9.9.rc.014
267
+	 */
268
+	public function get_contexts_for_message_types_for_list_table()
269
+	{
270
+		EE_Error::doing_it_wrong(
271
+			__METHOD__,
272
+			sprintf(
273
+				esc_html__(
274
+					'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type context filter dropdown which is now generated differently via %s',
275
+					'event_espresso'
276
+				),
277
+				'Messages_Admin_Page::get_contexts_for_message_types_select_input()'
278
+			),
279
+			'4.9.9.rc.014'
280
+		);
281
+
282
+		$contexts                = [];
283
+		$active_message_contexts = $this->getMsgModel()->get_all(['group_by' => 'MSG_context']);
284
+		foreach ($active_message_contexts as $active_message) {
285
+			if ($active_message instanceof EE_Message) {
286
+				$message_type = $active_message->message_type_object();
287
+				if ($message_type instanceof EE_message_type) {
288
+					$message_type_contexts = $message_type->get_contexts();
289
+					foreach ($message_type_contexts as $context => $context_details) {
290
+						$contexts[ $context ] = $context_details['label'];
291
+					}
292
+				}
293
+			}
294
+		}
295
+
296
+		return $contexts;
297
+	}
298
+
299
+
300
+	/**
301
+	 * Generate select input with provided messenger options array.
302
+	 *
303
+	 * @param array $messenger_options Array of messengers indexed by messenger slug and values are the messenger
304
+	 *                                 labels.
305
+	 * @return string
306
+	 * @throws EE_Error
307
+	 */
308
+	public function get_messengers_select_input($messenger_options)
309
+	{
310
+		// if empty or just one value then just return an empty string
311
+		if (
312
+			empty($messenger_options)
313
+			|| ! is_array($messenger_options)
314
+			|| count($messenger_options) === 1
315
+		) {
316
+			return '';
317
+		}
318
+		// merge in default
319
+		$messenger_options = array_merge(
320
+			['none_selected' => esc_html__('Show All Messengers', 'event_espresso')],
321
+			$messenger_options
322
+		);
323
+		$input             = new EE_Select_Input(
324
+			$messenger_options,
325
+			[
326
+				'html_name'  => 'ee_messenger_filter_by',
327
+				'html_id'    => 'ee_messenger_filter_by',
328
+				'html_class' => 'wide',
329
+				'default'    => $this->request->getRequestParam('ee_messenger_filter_by', 'none_selected', 'title'),
330
+			]
331
+		);
332
+
333
+		return $input->get_html_for_input();
334
+	}
335
+
336
+
337
+	/**
338
+	 * Generate select input with provided message type options array.
339
+	 *
340
+	 * @param array $message_type_options Array of message types indexed by message type slug, and values are the
341
+	 *                                    message type labels
342
+	 * @return string
343
+	 * @throws EE_Error
344
+	 */
345
+	public function get_message_types_select_input($message_type_options)
346
+	{
347
+		// if empty or count of options is 1 then just return an empty string
348
+		if (
349
+			empty($message_type_options)
350
+			|| ! is_array($message_type_options)
351
+			|| count($message_type_options) === 1
352
+		) {
353
+			return '';
354
+		}
355
+		// merge in default
356
+		$message_type_options = array_merge(
357
+			['none_selected' => esc_html__('Show All Message Types', 'event_espresso')],
358
+			$message_type_options
359
+		);
360
+		$input                = new EE_Select_Input(
361
+			$message_type_options,
362
+			[
363
+				'html_name'  => 'ee_message_type_filter_by',
364
+				'html_id'    => 'ee_message_type_filter_by',
365
+				'html_class' => 'wide',
366
+				'default'    => $this->request->getRequestParam('ee_message_type_filter_by', 'none_selected', 'title'),
367
+			]
368
+		);
369
+
370
+		return $input->get_html_for_input();
371
+	}
372
+
373
+
374
+	/**
375
+	 * Generate select input with provide message type contexts array.
376
+	 *
377
+	 * @param array $context_options Array of message type contexts indexed by context slug, and values are the
378
+	 *                               context label.
379
+	 * @return string
380
+	 * @throws EE_Error
381
+	 */
382
+	public function get_contexts_for_message_types_select_input($context_options)
383
+	{
384
+		// if empty or count of options is one then just return empty string
385
+		if (
386
+			empty($context_options)
387
+			|| ! is_array($context_options)
388
+			|| count($context_options) === 1
389
+		) {
390
+			return '';
391
+		}
392
+		// merge in default
393
+		$context_options = array_merge(
394
+			['none_selected' => esc_html__('Show all Contexts', 'event_espresso')],
395
+			$context_options
396
+		);
397
+		$input           = new EE_Select_Input(
398
+			$context_options,
399
+			[
400
+				'html_name'  => 'ee_context_filter_by',
401
+				'html_id'    => 'ee_context_filter_by',
402
+				'html_class' => 'wide',
403
+				'default'    => $this->request->getRequestParam('ee_context_filter_by', 'none_selected', 'title'),
404
+			]
405
+		);
406
+
407
+		return $input->get_html_for_input();
408
+	}
409
+
410
+
411
+	protected function _ajax_hooks()
412
+	{
413
+		add_action('wp_ajax_activate_messenger', [$this, 'activate_messenger_toggle']);
414
+		add_action('wp_ajax_activate_mt', [$this, 'activate_mt_toggle']);
415
+		add_action('wp_ajax_ee_msgs_save_settings', [$this, 'save_settings']);
416
+		add_action('wp_ajax_ee_msgs_update_mt_form', [$this, 'update_mt_form']);
417
+		add_action('wp_ajax_switch_template_pack', [$this, 'switch_template_pack']);
418
+		add_action('wp_ajax_toggle_context_template', [$this, 'toggle_context_template']);
419
+	}
420
+
421
+
422
+	protected function _define_page_props()
423
+	{
424
+		$this->_admin_page_title = $this->page_label;
425
+		$this->_labels           = [
426
+			'buttons'    => [
427
+				'add'    => esc_html__('Add New Message Template', 'event_espresso'),
428
+				'edit'   => esc_html__('Edit Message Template', 'event_espresso'),
429
+				'delete' => esc_html__('Delete Message Template', 'event_espresso'),
430
+			],
431
+			'publishbox' => esc_html__('Update Actions', 'event_espresso'),
432
+		];
433
+	}
434
+
435
+
436
+	/**
437
+	 *        an array for storing key => value pairs of request actions and their corresponding methods
438
+	 *
439
+	 * @access protected
440
+	 * @return void
441
+	 */
442
+	protected function _set_page_routes()
443
+	{
444
+		$GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
445
+		$GRP_ID = $this->request->getRequestParam('id', $GRP_ID, 'int');
446
+		$MSG_ID = $this->request->getRequestParam('MSG_ID', 0, 'int');
447
+
448
+		$this->_page_routes = [
449
+			'default'                          => [
450
+				'func'       => '_message_queue_list_table',
451
+				'capability' => 'ee_read_global_messages',
452
+			],
453
+			'global_mtps'                      => [
454
+				'func'       => '_ee_default_messages_overview_list_table',
455
+				'capability' => 'ee_read_global_messages',
456
+			],
457
+			'custom_mtps'                      => [
458
+				'func'       => '_custom_mtps_preview',
459
+				'capability' => 'ee_read_messages',
460
+			],
461
+			'add_new_message_template'         => [
462
+				'func'       => 'add_message_template',
463
+				'capability' => 'ee_edit_messages',
464
+				'noheader'   => true,
465
+			],
466
+			'edit_message_template'            => [
467
+				'func'       => '_edit_message_template',
468
+				'capability' => 'ee_edit_message',
469
+				'obj_id'     => $GRP_ID,
470
+			],
471
+			'preview_message'                  => [
472
+				'func'               => '_preview_message',
473
+				'capability'         => 'ee_read_message',
474
+				'obj_id'             => $GRP_ID,
475
+				'noheader'           => true,
476
+				'headers_sent_route' => 'display_preview_message',
477
+			],
478
+			'display_preview_message'          => [
479
+				'func'       => '_display_preview_message',
480
+				'capability' => 'ee_read_message',
481
+				'obj_id'     => $GRP_ID,
482
+			],
483
+			'insert_message_template'          => [
484
+				'func'       => '_insert_or_update_message_template',
485
+				'capability' => 'ee_edit_messages',
486
+				'args'       => ['new' => true],
487
+				'noheader'   => true,
488
+			],
489
+			'update_message_template'          => [
490
+				'func'       => '_insert_or_update_message_template',
491
+				'capability' => 'ee_edit_message',
492
+				'obj_id'     => $GRP_ID,
493
+				'args'       => ['new' => false],
494
+				'noheader'   => true,
495
+			],
496
+			'trash_message_template'           => [
497
+				'func'       => '_trash_or_restore_message_template',
498
+				'capability' => 'ee_delete_message',
499
+				'obj_id'     => $GRP_ID,
500
+				'args'       => ['trash' => true, 'all' => true],
501
+				'noheader'   => true,
502
+			],
503
+			'trash_message_template_context'   => [
504
+				'func'       => '_trash_or_restore_message_template',
505
+				'capability' => 'ee_delete_message',
506
+				'obj_id'     => $GRP_ID,
507
+				'args'       => ['trash' => true],
508
+				'noheader'   => true,
509
+			],
510
+			'restore_message_template'         => [
511
+				'func'       => '_trash_or_restore_message_template',
512
+				'capability' => 'ee_delete_message',
513
+				'obj_id'     => $GRP_ID,
514
+				'args'       => ['trash' => false, 'all' => true],
515
+				'noheader'   => true,
516
+			],
517
+			'restore_message_template_context' => [
518
+				'func'       => '_trash_or_restore_message_template',
519
+				'capability' => 'ee_delete_message',
520
+				'obj_id'     => $GRP_ID,
521
+				'args'       => ['trash' => false],
522
+				'noheader'   => true,
523
+			],
524
+			'delete_message_template'          => [
525
+				'func'       => '_delete_message_template',
526
+				'capability' => 'ee_delete_message',
527
+				'obj_id'     => $GRP_ID,
528
+				'noheader'   => true,
529
+			],
530
+			'reset_to_default'                 => [
531
+				'func'       => '_reset_to_default_template',
532
+				'capability' => 'ee_edit_message',
533
+				'obj_id'     => $GRP_ID,
534
+				'noheader'   => true,
535
+			],
536
+			'settings'                         => [
537
+				'func'       => '_settings',
538
+				'capability' => 'manage_options',
539
+			],
540
+			'update_global_settings'           => [
541
+				'func'       => '_update_global_settings',
542
+				'capability' => 'manage_options',
543
+				'noheader'   => true,
544
+			],
545
+			'generate_now'                     => [
546
+				'func'       => '_generate_now',
547
+				'capability' => 'ee_send_message',
548
+				'noheader'   => true,
549
+			],
550
+			'generate_and_send_now'            => [
551
+				'func'       => '_generate_and_send_now',
552
+				'capability' => 'ee_send_message',
553
+				'noheader'   => true,
554
+			],
555
+			'queue_for_resending'              => [
556
+				'func'       => '_queue_for_resending',
557
+				'capability' => 'ee_send_message',
558
+				'noheader'   => true,
559
+			],
560
+			'send_now'                         => [
561
+				'func'       => '_send_now',
562
+				'capability' => 'ee_send_message',
563
+				'noheader'   => true,
564
+			],
565
+			'delete_ee_message'                => [
566
+				'func'       => '_delete_ee_messages',
567
+				'capability' => 'ee_delete_messages',
568
+				'noheader'   => true,
569
+			],
570
+			'delete_ee_messages'               => [
571
+				'func'       => '_delete_ee_messages',
572
+				'capability' => 'ee_delete_messages',
573
+				'noheader'   => true,
574
+				'obj_id'     => $MSG_ID,
575
+			],
576
+		];
577
+	}
578
+
579
+
580
+	protected function _set_page_config()
581
+	{
582
+		$this->_page_config = [
583
+			'default'                  => [
584
+				'nav'           => [
585
+					'label' => esc_html__('Message Activity', 'event_espresso'),
586
+					'order' => 10,
587
+				],
588
+				'list_table'    => 'EE_Message_List_Table',
589
+				// 'qtips' => array( 'EE_Message_List_Table_Tips' ),
590
+				'require_nonce' => false,
591
+			],
592
+			'global_mtps'              => [
593
+				'nav'           => [
594
+					'label' => esc_html__('Default Message Templates', 'event_espresso'),
595
+					'order' => 20,
596
+				],
597
+				'list_table'    => 'Messages_Template_List_Table',
598
+				'help_tabs'     => [
599
+					'messages_overview_help_tab'                                => [
600
+						'title'    => esc_html__('Messages Overview', 'event_espresso'),
601
+						'filename' => 'messages_overview',
602
+					],
603
+					'messages_overview_messages_table_column_headings_help_tab' => [
604
+						'title'    => esc_html__('Messages Table Column Headings', 'event_espresso'),
605
+						'filename' => 'messages_overview_table_column_headings',
606
+					],
607
+					'messages_overview_messages_filters_help_tab'               => [
608
+						'title'    => esc_html__('Message Filters', 'event_espresso'),
609
+						'filename' => 'messages_overview_filters',
610
+					],
611
+					'messages_overview_messages_views_help_tab'                 => [
612
+						'title'    => esc_html__('Message Views', 'event_espresso'),
613
+						'filename' => 'messages_overview_views',
614
+					],
615
+					'message_overview_message_types_help_tab'                   => [
616
+						'title'    => esc_html__('Message Types', 'event_espresso'),
617
+						'filename' => 'messages_overview_types',
618
+					],
619
+					'messages_overview_messengers_help_tab'                     => [
620
+						'title'    => esc_html__('Messengers', 'event_espresso'),
621
+						'filename' => 'messages_overview_messengers',
622
+					],
623
+				],
624
+				'require_nonce' => false,
625
+			],
626
+			'custom_mtps'              => [
627
+				'nav'           => [
628
+					'label' => esc_html__('Custom Message Templates', 'event_espresso'),
629
+					'order' => 30,
630
+				],
631
+				'help_tabs'     => [],
632
+				'require_nonce' => false,
633
+			],
634
+			'add_new_message_template' => [
635
+				'nav'           => [
636
+					'label'      => esc_html__('Add New Message Templates', 'event_espresso'),
637
+					'order'      => 5,
638
+					'persistent' => false,
639
+				],
640
+				'require_nonce' => false,
641
+			],
642
+			'edit_message_template'    => [
643
+				'labels'        => [
644
+					'buttons'    => [
645
+						'reset' => esc_html__('Reset Templates', 'event_espresso'),
646
+					],
647
+					'publishbox' => esc_html__('Update Actions', 'event_espresso'),
648
+				],
649
+				'nav'           => [
650
+					'label'      => esc_html__('Edit Message Templates', 'event_espresso'),
651
+					'order'      => 5,
652
+					'persistent' => false,
653
+					'url'        => '',
654
+				],
655
+				'metaboxes'     => ['_publish_post_box', '_register_edit_meta_boxes'],
656
+				'has_metaboxes' => true,
657
+				'help_tabs'     => [
658
+					'edit_message_template'            => [
659
+						'title'    => esc_html__('Message Template Editor', 'event_espresso'),
660
+						'callback' => 'edit_message_template_help_tab',
661
+					],
662
+					'message_templates_help_tab'       => [
663
+						'title'    => esc_html__('Message Templates', 'event_espresso'),
664
+						'filename' => 'messages_templates',
665
+					],
666
+					'message_template_shortcodes'      => [
667
+						'title'    => esc_html__('Message Shortcodes', 'event_espresso'),
668
+						'callback' => 'message_template_shortcodes_help_tab',
669
+					],
670
+					'message_preview_help_tab'         => [
671
+						'title'    => esc_html__('Message Preview', 'event_espresso'),
672
+						'filename' => 'messages_preview',
673
+					],
674
+					'messages_overview_other_help_tab' => [
675
+						'title'    => esc_html__('Messages Other', 'event_espresso'),
676
+						'filename' => 'messages_overview_other',
677
+					],
678
+				],
679
+				'require_nonce' => false,
680
+			],
681
+			'display_preview_message'  => [
682
+				'nav'           => [
683
+					'label'      => esc_html__('Message Preview', 'event_espresso'),
684
+					'order'      => 5,
685
+					'url'        => '',
686
+					'persistent' => false,
687
+				],
688
+				'help_tabs'     => [
689
+					'preview_message' => [
690
+						'title'    => esc_html__('About Previews', 'event_espresso'),
691
+						'callback' => 'preview_message_help_tab',
692
+					],
693
+				],
694
+				'require_nonce' => false,
695
+			],
696
+			'settings'                 => [
697
+				'nav'           => [
698
+					'label' => esc_html__('Settings', 'event_espresso'),
699
+					'order' => 40,
700
+				],
701
+				'metaboxes'     => ['_messages_settings_metaboxes'],
702
+				'help_tabs'     => [
703
+					'messages_settings_help_tab'               => [
704
+						'title'    => esc_html__('Messages Settings', 'event_espresso'),
705
+						'filename' => 'messages_settings',
706
+					],
707
+					'messages_settings_message_types_help_tab' => [
708
+						'title'    => esc_html__('Activating / Deactivating Message Types', 'event_espresso'),
709
+						'filename' => 'messages_settings_message_types',
710
+					],
711
+					'messages_settings_messengers_help_tab'    => [
712
+						'title'    => esc_html__('Activating / Deactivating Messengers', 'event_espresso'),
713
+						'filename' => 'messages_settings_messengers',
714
+					],
715
+				],
716
+				'require_nonce' => false,
717
+			],
718
+		];
719
+	}
720
+
721
+
722
+	protected function _add_screen_options()
723
+	{
724
+		// todo
725
+	}
726
+
727
+
728
+	protected function _add_screen_options_global_mtps()
729
+	{
730
+		/**
731
+		 * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options
732
+		 * uses the $_admin_page_title property and we want different outputs in the different spots.
733
+		 */
734
+		$page_title              = $this->_admin_page_title;
735
+		$this->_admin_page_title = esc_html__('Global Message Templates', 'event_espresso');
736
+		$this->_per_page_screen_option();
737
+		$this->_admin_page_title = $page_title;
738
+	}
739
+
740
+
741
+	protected function _add_screen_options_default()
742
+	{
743
+		$this->_admin_page_title = esc_html__('Message Activity', 'event_espresso');
744
+		$this->_per_page_screen_option();
745
+	}
746
+
747
+
748
+	// none of the below group are currently used for Messages
749
+	protected function _add_feature_pointers()
750
+	{
751
+	}
752
+
753
+
754
+	public function admin_init()
755
+	{
756
+	}
757
+
758
+
759
+	public function admin_notices()
760
+	{
761
+	}
762
+
763
+
764
+	public function admin_footer_scripts()
765
+	{
766
+	}
767
+
768
+
769
+	public function messages_help_tab()
770
+	{
771
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php');
772
+	}
773
+
774
+
775
+	public function messengers_help_tab()
776
+	{
777
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php');
778
+	}
779
+
780
+
781
+	public function message_types_help_tab()
782
+	{
783
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php');
784
+	}
785
+
786
+
787
+	public function messages_overview_help_tab()
788
+	{
789
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php');
790
+	}
791
+
792
+
793
+	public function message_templates_help_tab()
794
+	{
795
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php');
796
+	}
797
+
798
+
799
+	public function edit_message_template_help_tab()
800
+	{
801
+		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="'
802
+						. esc_attr__('Editor Title', 'event_espresso')
803
+						. '" />';
804
+		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="'
805
+						. esc_attr__('Context Switcher and Preview', 'event_espresso')
806
+						. '" />';
807
+		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="'
808
+						. esc_attr__('Message Template Form Fields', 'event_espresso')
809
+						. '" />';
810
+		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="'
811
+						. esc_attr__('Shortcodes Metabox', 'event_espresso')
812
+						. '" />';
813
+		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="'
814
+						. esc_attr__('Publish Metabox', 'event_espresso')
815
+						. '" />';
816
+		EEH_Template::display_template(
817
+			EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php',
818
+			$args
819
+		);
820
+	}
821
+
822
+
823
+	/**
824
+	 * @throws ReflectionException
825
+	 * @throws EE_Error
826
+	 */
827
+	public function message_template_shortcodes_help_tab()
828
+	{
829
+		$this->_set_shortcodes();
830
+		$args['shortcodes'] = $this->_shortcodes;
831
+		EEH_Template::display_template(
832
+			EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php',
833
+			$args
834
+		);
835
+	}
836
+
837
+
838
+	public function preview_message_help_tab()
839
+	{
840
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php');
841
+	}
842
+
843
+
844
+	public function settings_help_tab()
845
+	{
846
+		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png'
847
+						. '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
848
+		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
849
+						. '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
850
+		$args['img3'] = '<div class="switch">'
851
+						. '<input class="ee-on-off-toggle ee-toggle-round-flat"'
852
+						. ' type="checkbox" checked="checked">'
853
+						. '<label for="ee-on-off-toggle-on"></label>'
854
+						. '</div>';
855
+		$args['img4'] = '<div class="switch">'
856
+						. '<input class="ee-on-off-toggle ee-toggle-round-flat"'
857
+						. ' type="checkbox">'
858
+						. '<label for="ee-on-off-toggle-on"></label>'
859
+						. '</div>';
860
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
861
+	}
862
+
863
+
864
+	public function load_scripts_styles()
865
+	{
866
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
867
+		wp_enqueue_style('espresso_ee_msg');
868
+
869
+		wp_register_script(
870
+			'ee-messages-settings',
871
+			EE_MSG_ASSETS_URL . 'ee-messages-settings.js',
872
+			['jquery-ui-droppable', 'ee-serialize-full-array'],
873
+			EVENT_ESPRESSO_VERSION,
874
+			true
875
+		);
876
+		wp_register_script(
877
+			'ee-msg-list-table-js',
878
+			EE_MSG_ASSETS_URL . 'ee_message_admin_list_table.js',
879
+			['ee-dialog'],
880
+			EVENT_ESPRESSO_VERSION
881
+		);
882
+	}
883
+
884
+
885
+	public function load_scripts_styles_default()
886
+	{
887
+		wp_enqueue_script('ee-msg-list-table-js');
888
+	}
889
+
890
+
891
+	public function wp_editor_css($mce_css)
892
+	{
893
+		// if we're on the edit_message_template route
894
+		if ($this->_req_action === 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
895
+			$message_type_name = $this->_active_message_type_name;
896
+
897
+			// we're going to REPLACE the existing mce css
898
+			// we need to get the css file location from the active messenger
899
+			$mce_css = $this->_active_messenger->get_variation(
900
+				$this->_template_pack,
901
+				$message_type_name,
902
+				true,
903
+				'wpeditor',
904
+				$this->_variation
905
+			);
906
+		}
907
+
908
+		return $mce_css;
909
+	}
910
+
911
+
912
+	/**
913
+	 * @throws EE_Error
914
+	 * @throws ReflectionException
915
+	 */
916
+	public function load_scripts_styles_edit_message_template()
917
+	{
918
+
919
+		$this->_set_shortcodes();
920
+
921
+		EE_Registry::$i18n_js_strings['confirm_default_reset']        = sprintf(
922
+			esc_html__(
923
+				'Are you sure you want to reset the %s %s message templates?  Remember continuing will reset the templates for all contexts in this messenger and message type group.',
924
+				'event_espresso'
925
+			),
926
+			$this->_message_template_group->messenger_obj()->label['singular'],
927
+			$this->_message_template_group->message_type_obj()->label['singular']
928
+		);
929
+		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = esc_html__(
930
+			'Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?',
931
+			'event_espresso'
932
+		);
933
+		EE_Registry::$i18n_js_strings['server_error']                 = esc_html__(
934
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
935
+			'event_espresso'
936
+		);
937
+
938
+		wp_register_script(
939
+			'ee_msgs_edit_js',
940
+			EE_MSG_ASSETS_URL . 'ee_message_editor.js',
941
+			['jquery'],
942
+			EVENT_ESPRESSO_VERSION
943
+		);
944
+
945
+		wp_enqueue_script('ee_admin_js');
946
+		wp_enqueue_script('ee_msgs_edit_js');
947
+
948
+		// add in special css for tiny_mce
949
+		add_filter('mce_css', [$this, 'wp_editor_css']);
950
+	}
951
+
952
+
953
+	/**
954
+	 * @throws EE_Error
955
+	 * @throws ReflectionException
956
+	 */
957
+	public function load_scripts_styles_display_preview_message()
958
+	{
959
+		$this->_set_message_template_group();
960
+		if ($this->_active_messenger_name) {
961
+			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger(
962
+				$this->_active_messenger_name
963
+			);
964
+		}
965
+
966
+		wp_enqueue_style(
967
+			'espresso_preview_css',
968
+			$this->_active_messenger->get_variation(
969
+				$this->_template_pack,
970
+				$this->_active_message_type_name,
971
+				true,
972
+				'preview',
973
+				$this->_variation
974
+			)
975
+		);
976
+	}
977
+
978
+
979
+	public function load_scripts_styles_settings()
980
+	{
981
+		wp_register_style(
982
+			'ee-message-settings',
983
+			EE_MSG_ASSETS_URL . 'ee_message_settings.css',
984
+			[],
985
+			EVENT_ESPRESSO_VERSION
986
+		);
987
+		wp_enqueue_style('ee-text-links');
988
+		wp_enqueue_style('ee-message-settings');
989
+		wp_enqueue_script('ee-messages-settings');
990
+	}
991
+
992
+
993
+	/**
994
+	 * set views array for List Table
995
+	 */
996
+	public function _set_list_table_views_global_mtps()
997
+	{
998
+		$this->_views = [
999
+			'in_use' => [
1000
+				'slug'  => 'in_use',
1001
+				'label' => esc_html__('In Use', 'event_espresso'),
1002
+				'count' => 0,
1003
+			],
1004
+		];
1005
+	}
1006
+
1007
+
1008
+	/**
1009
+	 * Set views array for the Custom Template List Table
1010
+	 */
1011
+	public function _set_list_table_views_custom_mtps()
1012
+	{
1013
+		$this->_set_list_table_views_global_mtps();
1014
+		$this->_views['in_use']['bulk_action'] = [
1015
+			'trash_message_template' => esc_html__('Move to Trash', 'event_espresso'),
1016
+		];
1017
+	}
1018
+
1019
+
1020
+	/**
1021
+	 * set views array for message queue list table
1022
+	 *
1023
+	 * @throws InvalidDataTypeException
1024
+	 * @throws InvalidInterfaceException
1025
+	 * @throws InvalidArgumentException
1026
+	 * @throws EE_Error
1027
+	 * @throws ReflectionException
1028
+	 */
1029
+	public function _set_list_table_views_default()
1030
+	{
1031
+		EE_Registry::instance()->load_helper('Template');
1032
+
1033
+		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can(
1034
+			'ee_send_message',
1035
+			'message_list_table_bulk_actions'
1036
+		)
1037
+			? [
1038
+				'generate_now'          => esc_html__('Generate Now', 'event_espresso'),
1039
+				'generate_and_send_now' => esc_html__('Generate and Send Now', 'event_espresso'),
1040
+				'queue_for_resending'   => esc_html__('Queue for Resending', 'event_espresso'),
1041
+				'send_now'              => esc_html__('Send Now', 'event_espresso'),
1042
+			]
1043
+			: [];
1044
+
1045
+		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can(
1046
+			'ee_delete_messages',
1047
+			'message_list_table_bulk_actions'
1048
+		)
1049
+			? ['delete_ee_messages' => esc_html__('Delete Messages', 'event_espresso')]
1050
+			: [];
1051
+
1052
+
1053
+		$this->_views = [
1054
+			'all' => [
1055
+				'slug'        => 'all',
1056
+				'label'       => esc_html__('All', 'event_espresso'),
1057
+				'count'       => 0,
1058
+				'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action),
1059
+			],
1060
+		];
1061
+
1062
+
1063
+		foreach ($this->getMsgModel()->all_statuses() as $status) {
1064
+			if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) {
1065
+				continue;
1066
+			}
1067
+			$status_bulk_actions = $common_bulk_actions;
1068
+			// unset bulk actions not applying to status
1069
+			if (! empty($status_bulk_actions)) {
1070
+				switch ($status) {
1071
+					case EEM_Message::status_idle:
1072
+					case EEM_Message::status_resend:
1073
+						$status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
1074
+						break;
1075
+
1076
+					case EEM_Message::status_failed:
1077
+					case EEM_Message::status_debug_only:
1078
+					case EEM_Message::status_messenger_executing:
1079
+						$status_bulk_actions = [];
1080
+						break;
1081
+
1082
+					case EEM_Message::status_incomplete:
1083
+						unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
1084
+						break;
1085
+
1086
+					case EEM_Message::status_retry:
1087
+					case EEM_Message::status_sent:
1088
+						unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
1089
+						break;
1090
+				}
1091
+			}
1092
+
1093
+			// skip adding messenger executing status to views because it will be included with the Failed view.
1094
+			if ($status === EEM_Message::status_messenger_executing) {
1095
+				continue;
1096
+			}
1097
+
1098
+			$this->_views[ strtolower($status) ] = [
1099
+				'slug'        => strtolower($status),
1100
+				'label'       => EEH_Template::pretty_status($status, false, 'sentence'),
1101
+				'count'       => 0,
1102
+				'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action),
1103
+			];
1104
+		}
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 * @throws EE_Error
1110
+	 */
1111
+	protected function _ee_default_messages_overview_list_table()
1112
+	{
1113
+		$this->_admin_page_title = esc_html__('Default Message Templates', 'event_espresso');
1114
+		$this->display_admin_list_table_page_with_no_sidebar();
1115
+	}
1116
+
1117
+
1118
+	/**
1119
+	 * @throws EE_Error
1120
+	 * @throws ReflectionException
1121
+	 */
1122
+	protected function _message_queue_list_table()
1123
+	{
1124
+		$this->_search_btn_label                   = esc_html__('Message Activity', 'event_espresso');
1125
+		$this->_template_args['per_column']        = 6;
1126
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_message_legend_items());
1127
+		$message_results = trim(EEM_Message::instance()->get_pretty_label_for_results());
1128
+		$this->_template_args['before_list_table'] = ! empty($message_results) ? "<h3>{$message_results}</h3>" : '';
1129
+		$this->display_admin_list_table_page_with_no_sidebar();
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * @throws EE_Error
1135
+	 */
1136
+	protected function _message_legend_items()
1137
+	{
1138
+
1139
+		$action_css_classes = EEH_MSG_Template::get_message_action_icons();
1140
+		$action_items       = [];
1141
+
1142
+		foreach ($action_css_classes as $action_item => $action_details) {
1143
+			if ($action_item === 'see_notifications_for') {
1144
+				continue;
1145
+			}
1146
+			$action_items[ $action_item ] = [
1147
+				'class' => $action_details['css_class'],
1148
+				'desc'  => $action_details['label'],
1149
+			];
1150
+		}
1151
+
1152
+		/** @var array $status_items status legend setup */
1153
+		$status_items = [
1154
+			'sent_status'                => [
1155
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_sent,
1156
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence'),
1157
+			],
1158
+			'idle_status'                => [
1159
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_idle,
1160
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence'),
1161
+			],
1162
+			'failed_status'              => [
1163
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_failed,
1164
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence'),
1165
+			],
1166
+			'messenger_executing_status' => [
1167
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_messenger_executing,
1168
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_messenger_executing, false, 'sentence'),
1169
+			],
1170
+			'resend_status'              => [
1171
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_resend,
1172
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence'),
1173
+			],
1174
+			'incomplete_status'          => [
1175
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_incomplete,
1176
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence'),
1177
+			],
1178
+			'retry_status'               => [
1179
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_retry,
1180
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence'),
1181
+			],
1182
+		];
1183
+		if (EEM_Message::debug()) {
1184
+			$status_items['debug_only_status'] = [
1185
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Message::status_debug_only,
1186
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence'),
1187
+			];
1188
+		}
1189
+
1190
+		return array_merge($action_items, $status_items);
1191
+	}
1192
+
1193
+
1194
+	/**
1195
+	 * @throws EE_Error
1196
+	 */
1197
+	protected function _custom_mtps_preview()
1198
+	{
1199
+		$this->_admin_page_title              = esc_html__('Custom Message Templates (Preview)', 'event_espresso');
1200
+		$this->_template_args['preview_img']  = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png"'
1201
+												. ' alt="' . esc_attr__(
1202
+													'Preview Custom Message Templates screenshot',
1203
+													'event_espresso'
1204
+												) . '" />';
1205
+		$this->_template_args['preview_text'] = '<strong>'
1206
+												. esc_html__(
1207
+													'Custom Message Templates is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Custom Message Templates feature, you are able to create custom message templates and assign them on a per-event basis.',
1208
+													'event_espresso'
1209
+												)
1210
+												. '</strong>';
1211
+
1212
+		$this->display_admin_caf_preview_page('custom_message_types', false);
1213
+	}
1214
+
1215
+
1216
+	/**
1217
+	 * get_message_templates
1218
+	 * This gets all the message templates for listing on the overview list.
1219
+	 *
1220
+	 * @access public
1221
+	 * @param int    $per_page the amount of templates groups to show per page
1222
+	 * @param string $type     the current _view we're getting templates for
1223
+	 * @param bool   $count    return count?
1224
+	 * @param bool   $all      disregard any paging info (get all data);
1225
+	 * @param bool   $global   whether to return just global (true) or custom templates (false)
1226
+	 * @return array
1227
+	 * @throws EE_Error
1228
+	 * @throws InvalidArgumentException
1229
+	 * @throws InvalidDataTypeException
1230
+	 * @throws InvalidInterfaceException
1231
+	 */
1232
+	public function get_message_templates(
1233
+		$per_page = 10,
1234
+		$type = 'in_use',
1235
+		$count = false,
1236
+		$all = false,
1237
+		$global = true
1238
+	) {
1239
+		$orderby = $this->request->getRequestParam('orderby', 'GRP_ID');
1240
+		$this->request->setRequestParam('orderby', $orderby);
1241
+
1242
+		$order        = $this->request->getRequestParam('order', 'ASC');
1243
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1244
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1245
+
1246
+		$offset = ($current_page - 1) * $per_page;
1247
+		$limit  = $all ? null : [$offset, $per_page];
1248
+
1249
+		// options will match what is in the _views array property
1250
+		return $type === 'in_use'
1251
+			? $this->getMtgModel()->get_all_active_message_templates(
1252
+				$orderby,
1253
+				$order,
1254
+				$limit,
1255
+				$count,
1256
+				$global,
1257
+				true
1258
+			)
1259
+			: $this->getMtgModel()->get_all_trashed_grouped_message_templates(
1260
+				$orderby,
1261
+				$order,
1262
+				$limit,
1263
+				$count,
1264
+				$global
1265
+			);
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 * filters etc might need a list of installed message_types
1271
+	 *
1272
+	 * @return array an array of message type objects
1273
+	 */
1274
+	public function get_installed_message_types()
1275
+	{
1276
+		$installed_message_types = $this->_message_resource_manager->installed_message_types();
1277
+		$installed               = [];
1278
+
1279
+		foreach ($installed_message_types as $message_type) {
1280
+			$installed[ $message_type->name ] = $message_type;
1281
+		}
1282
+
1283
+		return $installed;
1284
+	}
1285
+
1286
+
1287
+	/**
1288
+	 * This is used when creating a custom template. All Custom Templates start based off another template.
1289
+	 *
1290
+	 * @param string $message_type
1291
+	 * @param string $messenger
1292
+	 * @param string $GRP_ID
1293
+	 *
1294
+	 * @throws EE_error
1295
+	 * @throws ReflectionException
1296
+	 */
1297
+	public function add_message_template($message_type = '', $messenger = '', $GRP_ID = '')
1298
+	{
1299
+		// set values override any request data
1300
+		$message_type = ! empty($message_type) ? $message_type : $this->_active_message_type_name;
1301
+		$messenger    = ! empty($messenger) ? $messenger : $this->_active_messenger_name;
1302
+		$GRP_ID       = ! empty($GRP_ID) ? $GRP_ID : $this->request->getRequestParam('GRP_ID', 0, 'int');
1303
+
1304
+		// we need messenger and message type.  They should be coming from the event editor. If not here then return error
1305
+		if (empty($message_type) || empty($messenger)) {
1306
+			throw new EE_Error(
1307
+				esc_html__(
1308
+					'Sorry, but we can\'t create new templates because we\'re missing the messenger or message type',
1309
+					'event_espresso'
1310
+				)
1311
+			);
1312
+		}
1313
+
1314
+		// we need the GRP_ID for the template being used as the base for the new template
1315
+		if (empty($GRP_ID)) {
1316
+			throw new EE_Error(
1317
+				esc_html__(
1318
+					'In order to create a custom message template the GRP_ID of the template being used as a base is needed',
1319
+					'event_espresso'
1320
+				)
1321
+			);
1322
+		}
1323
+
1324
+		// let's just make sure the template gets generated!
1325
+
1326
+		// we need to reassign some variables for what the insert is expecting
1327
+		$this->request->setRequestParam('MTP_messenger', $messenger);
1328
+		$this->request->setRequestParam('MTP_message_type', $message_type);
1329
+		$this->request->setRequestParam('GRP_ID', $GRP_ID);
1330
+
1331
+		$this->_insert_or_update_message_template(true);
1332
+	}
1333
+
1334
+
1335
+	/**
1336
+	 * @param string $message_type     message type slug
1337
+	 * @param string $messenger        messenger slug
1338
+	 * @param int    $GRP_ID           GRP_ID for the related message template group this new template will be based
1339
+	 *                                 off of.
1340
+	 * @throws EE_error
1341
+	 * @throws ReflectionException
1342
+	 * @deprecated 4.10.29.p
1343
+	 */
1344
+	protected function _add_message_template($message_type, $messenger, $GRP_ID)
1345
+	{
1346
+		$this->add_message_template($message_type, $messenger, $GRP_ID);
1347
+	}
1348
+
1349
+
1350
+	/**
1351
+	 * _edit_message_template
1352
+	 *
1353
+	 * @access protected
1354
+	 * @return void
1355
+	 * @throws InvalidIdentifierException
1356
+	 * @throws DomainException
1357
+	 * @throws EE_Error
1358
+	 * @throws InvalidArgumentException
1359
+	 * @throws ReflectionException
1360
+	 * @throws InvalidDataTypeException
1361
+	 * @throws InvalidInterfaceException
1362
+	 */
1363
+	protected function _edit_message_template()
1364
+	{
1365
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1366
+		$template_fields = '';
1367
+		$sidebar_fields  = '';
1368
+		// we filter the tinyMCE settings to remove the validation since message templates by their nature will not have
1369
+		// valid html in the templates.
1370
+		add_filter('tiny_mce_before_init', [$this, 'filter_tinymce_init'], 10, 2);
1371
+
1372
+		$GRP_ID = $this->request->getRequestParam('id', 0, 'int');
1373
+		$EVT_ID = $this->request->getRequestParam('evt_id', 0, 'int');
1374
+
1375
+		$this->_set_shortcodes(); // this also sets the _message_template property.
1376
+		$message_template_group = $this->_message_template_group;
1377
+		$c_label                = $message_template_group->context_label();
1378
+		$c_config               = $message_template_group->contexts_config();
1379
+
1380
+		reset($c_config);
1381
+		$context = $this->request->getRequestParam('context', key($c_config));
1382
+		$context = strtolower($context);
1383
+
1384
+		$action = empty($GRP_ID) ? 'insert_message_template' : 'update_message_template';
1385
+
1386
+		$edit_message_template_form_url = add_query_arg(
1387
+			['action' => $action, 'noheader' => true],
1388
+			EE_MSG_ADMIN_URL
1389
+		);
1390
+
1391
+		// set active messenger for this view
1392
+		$this->_active_messenger         = $this->_message_resource_manager->get_active_messenger(
1393
+			$message_template_group->messenger()
1394
+		);
1395
+		$this->_active_message_type_name = $message_template_group->message_type();
1396
+
1397
+
1398
+		// Do we have any validation errors?
1399
+		$validators = $this->_get_transient();
1400
+		$v_fields   = ! empty($validators) ? array_keys($validators) : [];
1401
+
1402
+
1403
+		// we need to assemble the title from Various details
1404
+		$context_label = sprintf(
1405
+			esc_html__('(%s %s)', 'event_espresso'),
1406
+			$c_config[ $context ]['label'],
1407
+			ucwords($c_label['label'])
1408
+		);
1409
+
1410
+		$title = sprintf(
1411
+			esc_html__(' %s %s Template %s', 'event_espresso'),
1412
+			ucwords($message_template_group->messenger_obj()->label['singular']),
1413
+			ucwords($message_template_group->message_type_obj()->label['singular']),
1414
+			$context_label
1415
+		);
1416
+
1417
+		$this->_template_args['GRP_ID']           = $GRP_ID;
1418
+		$this->_template_args['message_template'] = $message_template_group;
1419
+		$this->_template_args['is_extra_fields']  = false;
1420
+
1421
+
1422
+		// let's get EEH_MSG_Template so we can get template form fields
1423
+		$template_field_structure = EEH_MSG_Template::get_fields(
1424
+			$message_template_group->messenger(),
1425
+			$message_template_group->message_type()
1426
+		);
1427
+
1428
+		if (! $template_field_structure) {
1429
+			$template_field_structure = false;
1430
+			$template_fields          = esc_html__(
1431
+				'There was an error in assembling the fields for this display (you should see an error message)',
1432
+				'event_espresso'
1433
+			);
1434
+		}
1435
+
1436
+
1437
+		$message_templates = $message_template_group->context_templates();
1438
+
1439
+
1440
+		// if we have the extra key.. then we need to remove the content index from the template_field_structure as it
1441
+		// will get handled in the "extra" array.
1442
+		if (is_array($template_field_structure[ $context ]) && isset($template_field_structure[ $context ]['extra'])) {
1443
+			foreach ($template_field_structure[ $context ]['extra'] as $reference_field => $new_fields) {
1444
+				unset($template_field_structure[ $context ][ $reference_field ]);
1445
+			}
1446
+		}
1447
+
1448
+		// let's loop through the template_field_structure and actually assemble the input fields!
1449
+		if (! empty($template_field_structure)) {
1450
+			foreach ($template_field_structure[ $context ] as $template_field => $field_setup_array) {
1451
+				// if this is an 'extra' template field then we need to remove any existing fields that are keyed up in
1452
+				// the extra array and reset them.
1453
+				if ($template_field === 'extra') {
1454
+					$this->_template_args['is_extra_fields'] = true;
1455
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
1456
+						$message_template = $message_templates[ $context ][ $reference_field ];
1457
+						$content          = $message_template instanceof EE_Message_Template
1458
+							? $message_template->get('MTP_content')
1459
+							: '';
1460
+						foreach ($new_fields_array as $extra_field => $extra_array) {
1461
+							// let's verify if we need this extra field via the shortcodes parameter.
1462
+							$continue = false;
1463
+							if (isset($extra_array['shortcodes_required'])) {
1464
+								foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
1465
+									if (! array_key_exists($shortcode, $this->_shortcodes)) {
1466
+										$continue = true;
1467
+									}
1468
+								}
1469
+								if ($continue) {
1470
+									continue;
1471
+								}
1472
+							}
1473
+
1474
+							$field_id = $reference_field . '-' . $extra_field . '-content';
1475
+
1476
+							$template_form_fields[ $field_id ]         = $extra_array;
1477
+							$template_form_fields[ $field_id ]['name'] = 'MTP_template_fields['
1478
+																		 . $reference_field
1479
+																		 . '][content]['
1480
+																		 . $extra_field . ']';
1481
+							$css_class                                 = isset($extra_array['css_class'])
1482
+								? $extra_array['css_class']
1483
+								: '';
1484
+
1485
+							$template_form_fields[ $field_id ]['css_class'] = ! empty($v_fields)
1486
+																			  && in_array($extra_field, $v_fields, true)
1487
+																			  && (
1488
+																				  is_array($validators[ $extra_field ])
1489
+																				  && isset($validators[ $extra_field ]['msg'])
1490
+																			  )
1491
+								? 'validate-error ' . $css_class
1492
+								: $css_class;
1493
+
1494
+							$template_form_fields[ $field_id ]['value'] = ! empty($message_templates)
1495
+																		  && isset($content[ $extra_field ])
1496
+								? $content[ $extra_field ]
1497
+								: '';
1498
+
1499
+							// do we have a validation error?  if we do then let's use that value instead
1500
+							$template_form_fields[ $field_id ]['value'] = isset($validators[ $extra_field ])
1501
+								? $validators[ $extra_field ]['value']
1502
+								: $template_form_fields[ $field_id ]['value'];
1503
+
1504
+
1505
+							$template_form_fields[ $field_id ]['db-col'] = 'MTP_content';
1506
+
1507
+							// shortcode selector
1508
+							$field_name_to_use                                   = $extra_field === 'main'
1509
+								? 'content'
1510
+								: $extra_field;
1511
+							$template_form_fields[ $field_id ]['append_content'] = $this->_get_shortcode_selector(
1512
+								$field_name_to_use,
1513
+								$field_id
1514
+							);
1515
+						}
1516
+						$template_field_MTP_id           = $reference_field . '-MTP_ID';
1517
+						$template_field_template_name_id = $reference_field . '-name';
1518
+
1519
+						$template_form_fields[ $template_field_MTP_id ] = [
1520
+							'name'       => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1521
+							'label'      => null,
1522
+							'input'      => 'hidden',
1523
+							'type'       => 'int',
1524
+							'required'   => false,
1525
+							'validation' => false,
1526
+							'value'      => ! empty($message_templates) ? $message_template->ID() : '',
1527
+							'css_class'  => '',
1528
+							'format'     => '%d',
1529
+							'db-col'     => 'MTP_ID',
1530
+						];
1531
+
1532
+						$template_form_fields[ $template_field_template_name_id ] = [
1533
+							'name'       => 'MTP_template_fields[' . $reference_field . '][name]',
1534
+							'label'      => null,
1535
+							'input'      => 'hidden',
1536
+							'type'       => 'string',
1537
+							'required'   => false,
1538
+							'validation' => true,
1539
+							'value'      => $reference_field,
1540
+							'css_class'  => '',
1541
+							'format'     => '%s',
1542
+							'db-col'     => 'MTP_template_field',
1543
+						];
1544
+					}
1545
+					continue; // skip the next stuff, we got the necessary fields here for this dataset.
1546
+				} else {
1547
+					$field_id                                   = $template_field . '-content';
1548
+					$template_form_fields[ $field_id ]          = $field_setup_array;
1549
+					$template_form_fields[ $field_id ]['name']  =
1550
+						'MTP_template_fields[' . $template_field . '][content]';
1551
+					$message_template                           =
1552
+						isset($message_templates[ $context ][ $template_field ])
1553
+							? $message_templates[ $context ][ $template_field ]
1554
+							: null;
1555
+					$template_form_fields[ $field_id ]['value'] = ! empty($message_templates)
1556
+																  && is_array($message_templates[ $context ])
1557
+																  && $message_template instanceof EE_Message_Template
1558
+						? $message_template->get('MTP_content')
1559
+						: '';
1560
+
1561
+					// do we have a validator error for this field?  if we do then we'll use that value instead
1562
+					$template_form_fields[ $field_id ]['value'] = isset($validators[ $template_field ])
1563
+						? $validators[ $template_field ]['value']
1564
+						: $template_form_fields[ $field_id ]['value'];
1565
+
1566
+
1567
+					$template_form_fields[ $field_id ]['db-col']    = 'MTP_content';
1568
+					$css_class                                      = isset($field_setup_array['css_class'])
1569
+						? $field_setup_array['css_class']
1570
+						: '';
1571
+					$template_form_fields[ $field_id ]['css_class'] = ! empty($v_fields)
1572
+																	  && in_array($template_field, $v_fields, true)
1573
+																	  && isset($validators[ $template_field ]['msg'])
1574
+						? 'validate-error ' . $css_class
1575
+						: $css_class;
1576
+
1577
+					// shortcode selector
1578
+					$template_form_fields[ $field_id ]['append_content'] = $this->_get_shortcode_selector(
1579
+						$template_field,
1580
+						$field_id
1581
+					);
1582
+				}
1583
+
1584
+				// k took care of content field(s) now let's take care of others.
1585
+
1586
+				$template_field_MTP_id                 = $template_field . '-MTP_ID';
1587
+				$template_field_field_template_name_id = $template_field . '-name';
1588
+
1589
+				// foreach template field there are actually two form fields created
1590
+				$template_form_fields[ $template_field_MTP_id ] = [
1591
+					'name'       => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1592
+					'label'      => null,
1593
+					'input'      => 'hidden',
1594
+					'type'       => 'int',
1595
+					'required'   => false,
1596
+					'validation' => true,
1597
+					'value'      => $message_template instanceof EE_Message_Template ? $message_template->ID() : '',
1598
+					'css_class'  => '',
1599
+					'format'     => '%d',
1600
+					'db-col'     => 'MTP_ID',
1601
+				];
1602
+
1603
+				$template_form_fields[ $template_field_field_template_name_id ] = [
1604
+					'name'       => 'MTP_template_fields[' . $template_field . '][name]',
1605
+					'label'      => null,
1606
+					'input'      => 'hidden',
1607
+					'type'       => 'string',
1608
+					'required'   => false,
1609
+					'validation' => true,
1610
+					'value'      => $template_field,
1611
+					'css_class'  => '',
1612
+					'format'     => '%s',
1613
+					'db-col'     => 'MTP_template_field',
1614
+				];
1615
+			}
1616
+
1617
+			// add other fields
1618
+			$template_form_fields['ee-msg-current-context'] = [
1619
+				'name'       => 'MTP_context',
1620
+				'label'      => null,
1621
+				'input'      => 'hidden',
1622
+				'type'       => 'string',
1623
+				'required'   => false,
1624
+				'validation' => true,
1625
+				'value'      => $context,
1626
+				'css_class'  => '',
1627
+				'format'     => '%s',
1628
+				'db-col'     => 'MTP_context',
1629
+			];
1630
+
1631
+			$template_form_fields['ee-msg-grp-id'] = [
1632
+				'name'       => 'GRP_ID',
1633
+				'label'      => null,
1634
+				'input'      => 'hidden',
1635
+				'type'       => 'int',
1636
+				'required'   => false,
1637
+				'validation' => true,
1638
+				'value'      => $GRP_ID,
1639
+				'css_class'  => '',
1640
+				'format'     => '%d',
1641
+				'db-col'     => 'GRP_ID',
1642
+			];
1643
+
1644
+			$template_form_fields['ee-msg-messenger'] = [
1645
+				'name'       => 'MTP_messenger',
1646
+				'label'      => null,
1647
+				'input'      => 'hidden',
1648
+				'type'       => 'string',
1649
+				'required'   => false,
1650
+				'validation' => true,
1651
+				'value'      => $message_template_group->messenger(),
1652
+				'css_class'  => '',
1653
+				'format'     => '%s',
1654
+				'db-col'     => 'MTP_messenger',
1655
+			];
1656
+
1657
+			$template_form_fields['ee-msg-message-type'] = [
1658
+				'name'       => 'MTP_message_type',
1659
+				'label'      => null,
1660
+				'input'      => 'hidden',
1661
+				'type'       => 'string',
1662
+				'required'   => false,
1663
+				'validation' => true,
1664
+				'value'      => $message_template_group->message_type(),
1665
+				'css_class'  => '',
1666
+				'format'     => '%s',
1667
+				'db-col'     => 'MTP_message_type',
1668
+			];
1669
+
1670
+			$sidebar_form_fields['ee-msg-is-global'] = [
1671
+				'name'       => 'MTP_is_global',
1672
+				'label'      => esc_html__('Global Template', 'event_espresso'),
1673
+				'input'      => 'hidden',
1674
+				'type'       => 'int',
1675
+				'required'   => false,
1676
+				'validation' => true,
1677
+				'value'      => $message_template_group->get('MTP_is_global'),
1678
+				'css_class'  => '',
1679
+				'format'     => '%d',
1680
+				'db-col'     => 'MTP_is_global',
1681
+			];
1682
+
1683
+			$sidebar_form_fields['ee-msg-is-override'] = [
1684
+				'name'       => 'MTP_is_override',
1685
+				'label'      => esc_html__('Override all custom', 'event_espresso'),
1686
+				'input'      => $message_template_group->is_global() ? 'checkbox' : 'hidden',
1687
+				'type'       => 'int',
1688
+				'required'   => false,
1689
+				'validation' => true,
1690
+				'value'      => $message_template_group->get('MTP_is_override'),
1691
+				'css_class'  => '',
1692
+				'format'     => '%d',
1693
+				'db-col'     => 'MTP_is_override',
1694
+			];
1695
+
1696
+			$sidebar_form_fields['ee-msg-is-active'] = [
1697
+				'name'       => 'MTP_is_active',
1698
+				'label'      => esc_html__('Active Template', 'event_espresso'),
1699
+				'input'      => 'hidden',
1700
+				'type'       => 'int',
1701
+				'required'   => false,
1702
+				'validation' => true,
1703
+				'value'      => $message_template_group->is_active(),
1704
+				'css_class'  => '',
1705
+				'format'     => '%d',
1706
+				'db-col'     => 'MTP_is_active',
1707
+			];
1708
+
1709
+			$sidebar_form_fields['ee-msg-deleted'] = [
1710
+				'name'       => 'MTP_deleted',
1711
+				'label'      => null,
1712
+				'input'      => 'hidden',
1713
+				'type'       => 'int',
1714
+				'required'   => false,
1715
+				'validation' => true,
1716
+				'value'      => $message_template_group->get('MTP_deleted'),
1717
+				'css_class'  => '',
1718
+				'format'     => '%d',
1719
+				'db-col'     => 'MTP_deleted',
1720
+			];
1721
+			$sidebar_form_fields['ee-msg-author']  = [
1722
+				'name'       => 'MTP_user_id',
1723
+				'label'      => esc_html__('Author', 'event_espresso'),
1724
+				'input'      => 'hidden',
1725
+				'type'       => 'int',
1726
+				'required'   => false,
1727
+				'validation' => false,
1728
+				'value'      => $message_template_group->user(),
1729
+				'format'     => '%d',
1730
+				'db-col'     => 'MTP_user_id',
1731
+			];
1732
+
1733
+			$sidebar_form_fields['ee-msg-route'] = [
1734
+				'name'  => 'action',
1735
+				'input' => 'hidden',
1736
+				'type'  => 'string',
1737
+				'value' => $action,
1738
+			];
1739
+
1740
+			$sidebar_form_fields['ee-msg-id']        = [
1741
+				'name'  => 'id',
1742
+				'input' => 'hidden',
1743
+				'type'  => 'int',
1744
+				'value' => $GRP_ID,
1745
+			];
1746
+			$sidebar_form_fields['ee-msg-evt-nonce'] = [
1747
+				'name'  => $action . '_nonce',
1748
+				'input' => 'hidden',
1749
+				'type'  => 'string',
1750
+				'value' => wp_create_nonce($action . '_nonce'),
1751
+			];
1752
+
1753
+			$template_switch = $this->request->getRequestParam('template_switch');
1754
+			if ($template_switch) {
1755
+				$sidebar_form_fields['ee-msg-template-switch'] = [
1756
+					'name'  => 'template_switch',
1757
+					'input' => 'hidden',
1758
+					'type'  => 'int',
1759
+					'value' => 1,
1760
+				];
1761
+			}
1762
+
1763
+
1764
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1765
+			$sidebar_fields  = $this->_generate_admin_form_fields($sidebar_form_fields);
1766
+		} //end if ( !empty($template_field_structure) )
1767
+
1768
+		// set extra content for publish box
1769
+		$this->_template_args['publish_box_extra_content'] = $sidebar_fields;
1770
+		$this->_set_publish_post_box_vars(
1771
+			'id',
1772
+			$GRP_ID,
1773
+			false,
1774
+			add_query_arg(
1775
+				['action' => 'global_mtps'],
1776
+				$this->_admin_base_url
1777
+			)
1778
+		);
1779
+
1780
+		// add preview button
1781
+		$preview_url    = parent::add_query_args_and_nonce(
1782
+			[
1783
+				'message_type' => $message_template_group->message_type(),
1784
+				'messenger'    => $message_template_group->messenger(),
1785
+				'context'      => $context,
1786
+				'GRP_ID'       => $GRP_ID,
1787
+				'evt_id'       => $EVT_ID ?: false,
1788
+				'action'       => 'preview_message',
1789
+			],
1790
+			$this->_admin_base_url
1791
+		);
1792
+		$preview_button = '<a href="' . $preview_url . '" class="button--secondary messages-preview-button">'
1793
+						  . esc_html__('Preview', 'event_espresso')
1794
+						  . '</a>';
1795
+
1796
+
1797
+		// setup context switcher
1798
+		$this->_set_context_switcher(
1799
+			$message_template_group,
1800
+			[
1801
+				'page'    => 'espresso_messages',
1802
+				'action'  => 'edit_message_template',
1803
+				'id'      => $GRP_ID,
1804
+				'evt_id'  => $EVT_ID,
1805
+				'context' => $context,
1806
+				'extra'   => $preview_button,
1807
+			]
1808
+		);
1809
+
1810
+
1811
+		// main box
1812
+		$this->_template_args['template_fields']                         = $template_fields;
1813
+		$this->_template_args['sidebar_box_id']                          = 'details';
1814
+		$this->_template_args['action']                                  = $action;
1815
+		$this->_template_args['context']                                 = $context;
1816
+		$this->_template_args['edit_message_template_form_url']          = $edit_message_template_form_url;
1817
+		$this->_template_args['learn_more_about_message_templates_link'] =
1818
+			$this->_learn_more_about_message_templates_link();
1819
+
1820
+
1821
+		$this->_template_args['before_admin_page_content'] = '<div class="ee-msg-admin-header">';
1822
+		$this->_template_args['before_admin_page_content'] .= $this->add_active_context_element(
1823
+			$message_template_group,
1824
+			$context,
1825
+			$context_label
1826
+		);
1827
+		$this->_template_args['before_admin_page_content'] .= $this->add_context_switcher();
1828
+		$this->_template_args['before_admin_page_content'] .= '</div>';
1829
+		$this->_template_args['before_admin_page_content'] .= $this->_add_form_element_before();
1830
+		$this->_template_args['after_admin_page_content']  = $this->_add_form_element_after();
1831
+
1832
+		$this->_template_path = $this->_template_args['GRP_ID']
1833
+			? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1834
+			: EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1835
+
1836
+		// send along EE_Message_Template_Group object for further template use.
1837
+		$this->_template_args['MTP'] = $message_template_group;
1838
+
1839
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1840
+			$this->_template_path,
1841
+			$this->_template_args,
1842
+			true
1843
+		);
1844
+
1845
+
1846
+		// finally, let's set the admin_page title
1847
+		$this->_admin_page_title = sprintf(esc_html__('Editing %s', 'event_espresso'), $title);
1848
+
1849
+
1850
+		// we need to take care of setting the shortcodes property for use elsewhere.
1851
+		$this->_set_shortcodes();
1852
+
1853
+
1854
+		// final template wrapper
1855
+		$this->display_admin_page_with_sidebar();
1856
+	}
1857
+
1858
+
1859
+	public function filter_tinymce_init($mceInit, $editor_id)
1860
+	{
1861
+		return $mceInit;
1862
+	}
1863
+
1864
+
1865
+	public function add_context_switcher()
1866
+	{
1867
+		return $this->_context_switcher;
1868
+	}
1869
+
1870
+
1871
+	/**
1872
+	 * Adds the activation/deactivation toggle for the message template context.
1873
+	 *
1874
+	 * @param EE_Message_Template_Group $message_template_group
1875
+	 * @param string                    $context
1876
+	 * @param string                    $context_label
1877
+	 * @return string
1878
+	 * @throws DomainException
1879
+	 * @throws EE_Error
1880
+	 * @throws InvalidIdentifierException
1881
+	 * @throws ReflectionException
1882
+	 */
1883
+	protected function add_active_context_element(
1884
+		EE_Message_Template_Group $message_template_group,
1885
+		$context,
1886
+		$context_label
1887
+	) {
1888
+		$template_args = [
1889
+			'context'                   => $context,
1890
+			'nonce'                     => wp_create_nonce('activate_' . $context . '_toggle_nonce'),
1891
+			'is_active'                 => $message_template_group->is_context_active($context),
1892
+			'on_off_action'             => $message_template_group->is_context_active($context)
1893
+				? 'context-off'
1894
+				: 'context-on',
1895
+			'context_label'             => str_replace(['(', ')'], '', $context_label),
1896
+			'message_template_group_id' => $message_template_group->ID(),
1897
+		];
1898
+		return EEH_Template::display_template(
1899
+			EE_MSG_TEMPLATE_PATH . 'ee_msg_editor_active_context_element.template.php',
1900
+			$template_args,
1901
+			true
1902
+		);
1903
+	}
1904
+
1905
+
1906
+	/**
1907
+	 * Ajax callback for `toggle_context_template` ajax action.
1908
+	 * Handles toggling the message context on or off.
1909
+	 *
1910
+	 * @throws EE_Error
1911
+	 * @throws InvalidArgumentException
1912
+	 * @throws InvalidDataTypeException
1913
+	 * @throws InvalidIdentifierException
1914
+	 * @throws InvalidInterfaceException
1915
+	 */
1916
+	public function toggle_context_template()
1917
+	{
1918
+		$success = true;
1919
+		// check for required data
1920
+		if (
1921
+			! (
1922
+				$this->request->requestParamIsSet('message_template_group_id')
1923
+				&& $this->request->requestParamIsSet('context')
1924
+				&& $this->request->requestParamIsSet('status')
1925
+			)
1926
+		) {
1927
+			EE_Error::add_error(
1928
+				esc_html__('Required data for doing this action is not available.', 'event_espresso'),
1929
+				__FILE__,
1930
+				__FUNCTION__,
1931
+				__LINE__
1932
+			);
1933
+			$success = false;
1934
+		}
1935
+
1936
+		$nonce   = $this->request->getRequestParam('toggle_context_nonce', '');
1937
+		$context = $this->request->getRequestParam('context', '');
1938
+		$status  = $this->request->getRequestParam('status', '');
1939
+
1940
+		$this->_verify_nonce($nonce, "activate_{$context}_toggle_nonce");
1941
+
1942
+		if ($status !== 'off' && $status !== 'on') {
1943
+			EE_Error::add_error(
1944
+				sprintf(
1945
+					esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
1946
+					$status
1947
+				),
1948
+				__FILE__,
1949
+				__FUNCTION__,
1950
+				__LINE__
1951
+			);
1952
+			$success = false;
1953
+		}
1954
+		$message_template_group_id = $this->request->getRequestParam('message_template_group_id', 0, 'int');
1955
+		$message_template_group    = $this->getMtgModel()->get_one_by_ID($message_template_group_id);
1956
+		if (! $message_template_group instanceof EE_Message_Template_Group) {
1957
+			EE_Error::add_error(
1958
+				sprintf(
1959
+					esc_html__(
1960
+						'Unable to change the active state because the given id "%1$d" does not match a valid "%2$s"',
1961
+						'event_espresso'
1962
+					),
1963
+					$message_template_group_id,
1964
+					'EE_Message_Template_Group'
1965
+				),
1966
+				__FILE__,
1967
+				__FUNCTION__,
1968
+				__LINE__
1969
+			);
1970
+			$success = false;
1971
+		}
1972
+		if ($success) {
1973
+			$success = $status === 'off'
1974
+				? $message_template_group->deactivate_context($context)
1975
+				: $message_template_group->activate_context($context);
1976
+		}
1977
+		$this->_template_args['success'] = $success;
1978
+		$this->_return_json();
1979
+	}
1980
+
1981
+
1982
+	public function _add_form_element_before()
1983
+	{
1984
+		return '<form method="post" action="'
1985
+			   . $this->_template_args['edit_message_template_form_url']
1986
+			   . '" id="ee-msg-edit-frm">';
1987
+	}
1988
+
1989
+
1990
+	public function _add_form_element_after()
1991
+	{
1992
+		return '</form>';
1993
+	}
1994
+
1995
+
1996
+	/**
1997
+	 * This executes switching the template pack for a message template.
1998
+	 *
1999
+	 * @throws EE_Error
2000
+	 * @throws InvalidDataTypeException
2001
+	 * @throws InvalidInterfaceException
2002
+	 * @throws InvalidArgumentException
2003
+	 * @throws ReflectionException
2004
+	 * @since 4.5.0
2005
+	 */
2006
+	public function switch_template_pack()
2007
+	{
2008
+
2009
+		$GRP_ID        = $this->request->getRequestParam('GRP_ID', 0, 'int');
2010
+		$template_pack = $this->request->getRequestParam('template_pack', '');
2011
+
2012
+		// verify we have needed values.
2013
+		if (empty($GRP_ID) || empty($template_pack)) {
2014
+			$this->_template_args['error'] = true;
2015
+			EE_Error::add_error(
2016
+				esc_html__('The required date for switching templates is not available.', 'event_espresso'),
2017
+				__FILE__,
2018
+				__FUNCTION__,
2019
+				__LINE__
2020
+			);
2021
+		} else {
2022
+			// get template, set the new template_pack and then reset to default
2023
+			/** @var EE_Message_Template_Group $message_template_group */
2024
+			$message_template_group = $this->getMtgModel()->get_one_by_ID($GRP_ID);
2025
+
2026
+			$message_template_group->set_template_pack_name($template_pack);
2027
+			$this->request->setRequestParam('msgr', $message_template_group->messenger());
2028
+			$this->request->setRequestParam('mt', $message_template_group->message_type());
2029
+
2030
+			$query_args = $this->_reset_to_default_template();
2031
+
2032
+			if (empty($query_args['id'])) {
2033
+				EE_Error::add_error(
2034
+					esc_html__(
2035
+						'Something went wrong with switching the template pack. Please try again or contact EE support',
2036
+						'event_espresso'
2037
+					),
2038
+					__FILE__,
2039
+					__FUNCTION__,
2040
+					__LINE__
2041
+				);
2042
+				$this->_template_args['error'] = true;
2043
+			} else {
2044
+				$template_label       = $message_template_group->get_template_pack()->label;
2045
+				$template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels();
2046
+				EE_Error::add_success(
2047
+					sprintf(
2048
+						esc_html__(
2049
+							'This message template has been successfully switched to use the %1$s %2$s.  Please wait while the page reloads with your new template.',
2050
+							'event_espresso'
2051
+						),
2052
+						$template_label,
2053
+						$template_pack_labels->template_pack
2054
+					)
2055
+				);
2056
+				// generate the redirect url for js.
2057
+				$url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2058
+
2059
+				$this->_template_args['data']['redirect_url'] = $url;
2060
+				$this->_template_args['success']              = true;
2061
+			}
2062
+
2063
+			$this->_return_json();
2064
+		}
2065
+	}
2066
+
2067
+
2068
+	/**
2069
+	 * This handles resetting the template for the given messenger/message_type so that users can start from scratch if
2070
+	 * they want.
2071
+	 *
2072
+	 * @access protected
2073
+	 * @return array|void
2074
+	 * @throws EE_Error
2075
+	 * @throws InvalidArgumentException
2076
+	 * @throws InvalidDataTypeException
2077
+	 * @throws InvalidInterfaceException
2078
+	 * @throws ReflectionException
2079
+	 */
2080
+	protected function _reset_to_default_template()
2081
+	{
2082
+		$templates    = [];
2083
+		$GRP_ID       = $this->request->getRequestParam('GRP_ID', 0, 'int');
2084
+		$messenger    = $this->request->getRequestParam('msgr');
2085
+		$message_type = $this->request->getRequestParam('mt');
2086
+		// we need to make sure we've got the info we need.
2087
+		if (! ($GRP_ID && $messenger && $message_type)) {
2088
+			EE_Error::add_error(
2089
+				esc_html__(
2090
+					'In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.',
2091
+					'event_espresso'
2092
+				),
2093
+				__FILE__,
2094
+				__FUNCTION__,
2095
+				__LINE__
2096
+			);
2097
+		}
2098
+
2099
+		// all templates will be reset to whatever the defaults are
2100
+		// for the global template matching the messenger and message type.
2101
+		$success = ! empty($GRP_ID);
2102
+
2103
+		if ($success) {
2104
+			// let's first determine if the incoming template is a global template,
2105
+			// if it isn't then we need to get the global template matching messenger and message type.
2106
+			// $MTPG = $this->getMtgModel()->get_one_by_ID( $GRP_ID );
2107
+
2108
+
2109
+			// note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
2110
+			$success = $this->_delete_mtp_permanently($GRP_ID, false);
2111
+
2112
+			if ($success) {
2113
+				// if successfully deleted, lets generate the new ones.
2114
+				// Note. We set GLOBAL to true, because resets on ANY template
2115
+				// will use the related global template defaults for regeneration.
2116
+				// This means that if a custom template is reset it resets to whatever the related global template is.
2117
+				// HOWEVER, we DO keep the template pack and template variation set
2118
+				// for the current custom template when resetting.
2119
+				$templates = $this->_generate_new_templates($messenger, $message_type, $GRP_ID, true);
2120
+			}
2121
+		}
2122
+
2123
+		// any error messages?
2124
+		if (! $success) {
2125
+			EE_Error::add_error(
2126
+				esc_html__(
2127
+					'Something went wrong with deleting existing templates. Unable to reset to default',
2128
+					'event_espresso'
2129
+				),
2130
+				__FILE__,
2131
+				__FUNCTION__,
2132
+				__LINE__
2133
+			);
2134
+		}
2135
+
2136
+		// all good, let's add a success message!
2137
+		if ($success && ! empty($templates)) {
2138
+			// the info for the template we generated is the first element in the returned array
2139
+			EE_Error::overwrite_success();
2140
+			EE_Error::add_success(esc_html__('Templates have been reset to defaults.', 'event_espresso'));
2141
+		}
2142
+
2143
+
2144
+		$query_args = [
2145
+			'id'      => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
2146
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
2147
+			'action'  => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps',
2148
+		];
2149
+
2150
+		// if called via ajax then we return query args otherwise redirect
2151
+		if ($this->request->isAjax()) {
2152
+			return $query_args;
2153
+		}
2154
+		$this->_redirect_after_action(false, '', '', $query_args, true);
2155
+	}
2156
+
2157
+
2158
+	/**
2159
+	 * Retrieve and set the message preview for display.
2160
+	 *
2161
+	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
2162
+	 * @return string
2163
+	 * @throws ReflectionException
2164
+	 * @throws EE_Error
2165
+	 * @throws InvalidArgumentException
2166
+	 * @throws InvalidDataTypeException
2167
+	 * @throws InvalidInterfaceException
2168
+	 */
2169
+	public function _preview_message($send = false)
2170
+	{
2171
+		// first make sure we've got the necessary parameters
2172
+		$GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
2173
+		if (! ($GRP_ID && $this->_active_messenger_name && $this->_active_message_type_name)) {
2174
+			EE_Error::add_error(
2175
+				esc_html__('Missing necessary parameters for displaying preview', 'event_espresso'),
2176
+				__FILE__,
2177
+				__FUNCTION__,
2178
+				__LINE__
2179
+			);
2180
+		}
2181
+
2182
+		$context = $this->request->getRequestParam('context');
2183
+		// get the preview!
2184
+		$preview = EED_Messages::preview_message(
2185
+			$this->_active_message_type_name,
2186
+			$context,
2187
+			$this->_active_messenger_name,
2188
+			$send
2189
+		);
2190
+
2191
+		if ($send) {
2192
+			return $preview;
2193
+		}
2194
+
2195
+		// if we have an evt_id set on the request, use it.
2196
+		$EVT_ID = $this->request->getRequestParam('evt_id', 0, 'int');
2197
+
2198
+		// let's add a button to go back to the edit view
2199
+		$query_args             = [
2200
+			'id'      => $GRP_ID,
2201
+			'evt_id'  => $EVT_ID,
2202
+			'context' => $context,
2203
+			'action'  => 'edit_message_template',
2204
+		];
2205
+		$go_back_url            = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2206
+		$preview_button         = '<a href="'
2207
+								  . $go_back_url
2208
+								  . '" class="button--secondary messages-preview-go-back-button">'
2209
+								  . esc_html__('Go Back to Edit', 'event_espresso')
2210
+								  . '</a>';
2211
+		$message_types          = $this->get_installed_message_types();
2212
+		$active_messenger       = $this->_message_resource_manager->get_active_messenger($this->_active_messenger_name);
2213
+		$active_messenger_label = $active_messenger instanceof EE_messenger
2214
+			? ucwords($active_messenger->label['singular'])
2215
+			: esc_html__('Unknown Messenger', 'event_espresso');
2216
+		// let's provide a helpful title for context
2217
+		$preview_title = sprintf(
2218
+			esc_html__('Viewing Preview for %s %s Message Template', 'event_espresso'),
2219
+			$active_messenger_label,
2220
+			ucwords($message_types[ $this->_active_message_type_name ]->label['singular'])
2221
+		);
2222
+		if (empty($preview)) {
2223
+			$this->noEventsErrorMessage();
2224
+		}
2225
+		// setup display of preview.
2226
+		$this->_admin_page_title                    = $preview_title;
2227
+		$this->_template_args['admin_page_title']   = $preview_title;
2228
+		$this->_template_args['admin_page_content'] = $preview_button . '<br />' . $preview;
2229
+		$this->_template_args['data']['force_json'] = true;
2230
+
2231
+		return '';
2232
+	}
2233
+
2234
+
2235
+	/**
2236
+	 * Used to set an error if there are no events available for generating a preview/test send.
2237
+	 *
2238
+	 * @param bool $test_send Whether the error should be generated for the context of a test send.
2239
+	 */
2240
+	protected function noEventsErrorMessage($test_send = false)
2241
+	{
2242
+		$events_url = parent::add_query_args_and_nonce(
2243
+			[
2244
+				'action' => 'default',
2245
+				'page'   => 'espresso_events',
2246
+			],
2247
+			admin_url('admin.php')
2248
+		);
2249
+		$message    = $test_send
2250
+			? esc_html__(
2251
+				'A test message could not be sent for this message template because there are no events created yet. The preview system uses actual events for generating the test message. %1$sGo see your events%2$s!',
2252
+				'event_espresso'
2253
+			)
2254
+			: esc_html__(
2255
+				'There is no preview for this message template available because there are no events created yet. The preview system uses actual events for generating the preview. %1$sGo see your events%2$s!',
2256
+				'event_espresso'
2257
+			);
2258
+
2259
+		EE_Error::add_attention(
2260
+			sprintf(
2261
+				$message,
2262
+				"<a href='{$events_url}'>",
2263
+				'</a>'
2264
+			)
2265
+		);
2266
+	}
2267
+
2268
+
2269
+	/**
2270
+	 * The initial _preview_message is on a no headers route.  It will optionally call this if necessary otherwise it
2271
+	 * gets called automatically.
2272
+	 *
2273
+	 * @return void
2274
+	 * @throws EE_Error
2275
+	 * @since 4.5.0
2276
+	 *
2277
+	 */
2278
+	protected function _display_preview_message()
2279
+	{
2280
+		$this->display_admin_page_with_no_sidebar();
2281
+	}
2282
+
2283
+
2284
+	/**
2285
+	 * registers metaboxes that should show up on the "edit_message_template" page
2286
+	 *
2287
+	 * @access protected
2288
+	 * @return void
2289
+	 */
2290
+	protected function _register_edit_meta_boxes()
2291
+	{
2292
+		$this->addMetaBox(
2293
+			'mtp_valid_shortcodes',
2294
+			esc_html__('Valid Shortcodes', 'event_espresso'),
2295
+			[$this, 'shortcode_meta_box'],
2296
+			$this->_current_screen->id,
2297
+			'side'
2298
+		);
2299
+		$this->addMetaBox(
2300
+			'mtp_extra_actions',
2301
+			esc_html__('Extra Actions', 'event_espresso'),
2302
+			[$this, 'extra_actions_meta_box'],
2303
+			$this->_current_screen->id,
2304
+			'side',
2305
+			'high'
2306
+		);
2307
+		$this->addMetaBox(
2308
+			'mtp_templates',
2309
+			esc_html__('Template Styles', 'event_espresso'),
2310
+			[$this, 'template_pack_meta_box'],
2311
+			$this->_current_screen->id,
2312
+			'side',
2313
+			'high'
2314
+		);
2315
+	}
2316
+
2317
+
2318
+	/**
2319
+	 * metabox content for all template pack and variation selection.
2320
+	 *
2321
+	 * @return void
2322
+	 * @throws DomainException
2323
+	 * @throws EE_Error
2324
+	 * @throws InvalidArgumentException
2325
+	 * @throws ReflectionException
2326
+	 * @throws InvalidDataTypeException
2327
+	 * @throws InvalidInterfaceException
2328
+	 * @since 4.5.0
2329
+	 */
2330
+	public function template_pack_meta_box()
2331
+	{
2332
+		$this->_set_message_template_group();
2333
+
2334
+		$tp_collection = EEH_MSG_Template::get_template_pack_collection();
2335
+
2336
+		$tp_select_values = [];
2337
+
2338
+		foreach ($tp_collection as $tp) {
2339
+			// only include template packs that support this messenger and message type!
2340
+			$supports = $tp->get_supports();
2341
+			if (
2342
+				! isset($supports[ $this->_message_template_group->messenger() ])
2343
+				|| ! in_array(
2344
+					$this->_message_template_group->message_type(),
2345
+					$supports[ $this->_message_template_group->messenger() ],
2346
+					true
2347
+				)
2348
+			) {
2349
+				// not supported
2350
+				continue;
2351
+			}
2352
+
2353
+			$tp_select_values[] = [
2354
+				'text' => $tp->label,
2355
+				'id'   => $tp->dbref,
2356
+			];
2357
+		}
2358
+
2359
+		// if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by
2360
+		// the default template pack.  This still allows for the odd template pack to override.
2361
+		if (empty($tp_select_values)) {
2362
+			$tp_select_values[] = [
2363
+				'text' => esc_html__('Default', 'event_espresso'),
2364
+				'id'   => 'default',
2365
+			];
2366
+		}
2367
+
2368
+		// setup variation select values for the currently selected template.
2369
+		$variations               = $this->_message_template_group->get_template_pack()->get_variations(
2370
+			$this->_message_template_group->messenger(),
2371
+			$this->_message_template_group->message_type()
2372
+		);
2373
+		$variations_select_values = [];
2374
+		foreach ($variations as $variation => $label) {
2375
+			$variations_select_values[] = [
2376
+				'text' => $label,
2377
+				'id'   => $variation,
2378
+			];
2379
+		}
2380
+
2381
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
2382
+
2383
+		$template_args['template_packs_selector']        = EEH_Form_Fields::select_input(
2384
+			'MTP_template_pack',
2385
+			$tp_select_values,
2386
+			$this->_message_template_group->get_template_pack_name()
2387
+		);
2388
+		$template_args['variations_selector']            = EEH_Form_Fields::select_input(
2389
+			'MTP_template_variation',
2390
+			$variations_select_values,
2391
+			$this->_message_template_group->get_template_pack_variation()
2392
+		);
2393
+		$template_args['template_pack_label']            = $template_pack_labels->template_pack;
2394
+		$template_args['template_variation_label']       = $template_pack_labels->template_variation;
2395
+		$template_args['template_pack_description']      = $template_pack_labels->template_pack_description;
2396
+		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
2397
+
2398
+		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
2399
+
2400
+		EEH_Template::display_template($template, $template_args);
2401
+	}
2402
+
2403
+
2404
+	/**
2405
+	 * This meta box holds any extra actions related to Message Templates
2406
+	 * For now, this includes Resetting templates to defaults and sending a test email.
2407
+	 *
2408
+	 * @access  public
2409
+	 * @return void
2410
+	 * @throws EE_Error
2411
+	 */
2412
+	public function extra_actions_meta_box()
2413
+	{
2414
+		$template_form_fields = [];
2415
+
2416
+		$extra_args = [
2417
+			'msgr'   => $this->_message_template_group->messenger(),
2418
+			'mt'     => $this->_message_template_group->message_type(),
2419
+			'GRP_ID' => $this->_message_template_group->GRP_ID(),
2420
+		];
2421
+		// first we need to see if there are any fields
2422
+		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
2423
+
2424
+		if (! empty($fields)) {
2425
+			// yup there be fields
2426
+			foreach ($fields as $field => $config) {
2427
+				$field_id = $this->_message_template_group->messenger() . '_' . $field;
2428
+				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
2429
+				$default  = isset($config['default']) ? $config['default'] : '';
2430
+				$default  = isset($config['value']) ? $config['value'] : $default;
2431
+
2432
+				// if type is hidden and the value is empty
2433
+				// something may have gone wrong so let's correct with the defaults
2434
+				$fix                = $config['input'] === 'hidden'
2435
+									  && isset($existing[ $field ])
2436
+									  && empty($existing[ $field ])
2437
+					? $default
2438
+					: '';
2439
+				$existing[ $field ] = isset($existing[ $field ]) && empty($fix)
2440
+					? $existing[ $field ]
2441
+					: $fix;
2442
+
2443
+				$template_form_fields[ $field_id ] = [
2444
+					'name'       => 'test_settings_fld[' . $field . ']',
2445
+					'label'      => $config['label'],
2446
+					'input'      => $config['input'],
2447
+					'type'       => $config['type'],
2448
+					'required'   => $config['required'],
2449
+					'validation' => $config['validation'],
2450
+					'value'      => isset($existing[ $field ]) ? $existing[ $field ] : $default,
2451
+					'css_class'  => $config['css_class'],
2452
+					'options'    => isset($config['options']) ? $config['options'] : [],
2453
+					'default'    => $default,
2454
+					'format'     => $config['format'],
2455
+				];
2456
+			}
2457
+		}
2458
+
2459
+		$test_settings_html = ! empty($template_form_fields)
2460
+			? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds')
2461
+			: '';
2462
+
2463
+		// print out $test_settings_fields
2464
+		if (! empty($test_settings_html)) {
2465
+			$test_settings_html .= '<input type="submit" class="button--primary mtp-test-button alignright" ';
2466
+			$test_settings_html .= 'name="test_button" value="';
2467
+			$test_settings_html .= esc_html__('Test Send', 'event_espresso');
2468
+			$test_settings_html .= '" /><div style="clear:both"></div>';
2469
+		}
2470
+
2471
+		// and button
2472
+		$test_settings_html .= '<div class="publishing-action alignright resetbutton">';
2473
+		$test_settings_html .= '<p>';
2474
+		$test_settings_html .= esc_html__('Need to reset this message type and start over?', 'event_espresso');
2475
+		$test_settings_html .= '</p>';
2476
+		$test_settings_html .= $this->get_action_link_or_button(
2477
+			'reset_to_default',
2478
+			'reset',
2479
+			$extra_args,
2480
+			'button--primary reset-default-button'
2481
+		);
2482
+		$test_settings_html .= '</div><div style="clear:both"></div>';
2483
+		echo $test_settings_html; // already escaped
2484
+	}
2485
+
2486
+
2487
+	/**
2488
+	 * This returns the shortcode selector skeleton for a given context and field.
2489
+	 *
2490
+	 * @param string $field           The name of the field retrieving shortcodes for.
2491
+	 * @param string $linked_input_id The css id of the input that the shortcodes get added to.
2492
+	 * @return string
2493
+	 * @throws DomainException
2494
+	 * @throws EE_Error
2495
+	 * @throws InvalidArgumentException
2496
+	 * @throws ReflectionException
2497
+	 * @throws InvalidDataTypeException
2498
+	 * @throws InvalidInterfaceException
2499
+	 * @since 4.9.rc.000
2500
+	 */
2501
+	protected function _get_shortcode_selector($field, $linked_input_id)
2502
+	{
2503
+		$template_args = [
2504
+			'shortcodes'      => $this->_get_shortcodes([$field]),
2505
+			'fieldname'       => $field,
2506
+			'linked_input_id' => $linked_input_id,
2507
+		];
2508
+
2509
+		return EEH_Template::display_template(
2510
+			EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php',
2511
+			$template_args,
2512
+			true
2513
+		);
2514
+	}
2515
+
2516
+
2517
+	/**
2518
+	 * This just takes care of returning the meta box content for shortcodes (only used on the edit message template
2519
+	 * page)
2520
+	 *
2521
+	 * @access public
2522
+	 * @return void
2523
+	 * @throws EE_Error
2524
+	 * @throws InvalidArgumentException
2525
+	 * @throws ReflectionException
2526
+	 * @throws InvalidDataTypeException
2527
+	 * @throws InvalidInterfaceException
2528
+	 */
2529
+	public function shortcode_meta_box()
2530
+	{
2531
+		$shortcodes = $this->_get_shortcodes([], false);
2532
+		// just make sure the shortcodes property is set
2533
+		// $messenger = $this->_message_template_group->messenger_obj();
2534
+		// now let's set the content depending on the status of the shortcodes array
2535
+		if (empty($shortcodes)) {
2536
+			echo '<p>' . esc_html__('There are no valid shortcodes available', 'event_espresso') . '</p>';
2537
+			return;
2538
+		}
2539
+		?>
2540 2540
         <div style="float:right; margin-top:10px">
2541 2541
             <?php echo $this->_get_help_tab_link('message_template_shortcodes'); // already escaped
2542
-            ?>
2542
+			?>
2543 2543
         </div>
2544 2544
         <p class="small-text">
2545 2545
             <?php printf(
2546
-                esc_html__(
2547
-                    'You can view the shortcodes usable in your template by clicking the %s icon next to each field.',
2548
-                    'event_espresso'
2549
-                ),
2550
-                '<span class="dashicons dashicons-shortcode"></span>'
2551
-            ); ?>
2546
+				esc_html__(
2547
+					'You can view the shortcodes usable in your template by clicking the %s icon next to each field.',
2548
+					'event_espresso'
2549
+				),
2550
+				'<span class="dashicons dashicons-shortcode"></span>'
2551
+			); ?>
2552 2552
         </p>
2553 2553
         <?php
2554
-    }
2555
-
2556
-
2557
-    /**
2558
-     * used to set the $_shortcodes property for when its needed elsewhere.
2559
-     *
2560
-     * @access protected
2561
-     * @return void
2562
-     * @throws EE_Error
2563
-     * @throws InvalidArgumentException
2564
-     * @throws ReflectionException
2565
-     * @throws InvalidDataTypeException
2566
-     * @throws InvalidInterfaceException
2567
-     */
2568
-    protected function _set_shortcodes()
2569
-    {
2570
-
2571
-        // no need to run this if the property is already set
2572
-        if (! empty($this->_shortcodes)) {
2573
-            return;
2574
-        }
2575
-
2576
-        $this->_shortcodes = $this->_get_shortcodes();
2577
-    }
2578
-
2579
-
2580
-    /**
2581
-     * gets all shortcodes for a given template group. (typically used by _set_shortcodes to set the $_shortcodes
2582
-     * property)
2583
-     *
2584
-     * @access  protected
2585
-     * @param array   $fields  include an array of specific field names that you want to be used to get the shortcodes
2586
-     *                         for. Defaults to all (for the given context)
2587
-     * @param boolean $merged  Whether to merge all the shortcodes into one list of unique shortcodes
2588
-     * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is
2589
-     *                         true just an array of shortcode/label pairs.
2590
-     * @throws EE_Error
2591
-     * @throws InvalidArgumentException
2592
-     * @throws ReflectionException
2593
-     * @throws InvalidDataTypeException
2594
-     * @throws InvalidInterfaceException
2595
-     */
2596
-    protected function _get_shortcodes($fields = [], $merged = true)
2597
-    {
2598
-        $this->_set_message_template_group();
2599
-
2600
-        // we need the messenger and message template to retrieve the valid shortcodes array.
2601
-        $GRP_ID = $this->request->getRequestParam('id', 0, 'int');
2602
-        if (empty($GRP_ID)) {
2603
-            return [];
2604
-        }
2605
-        $context = $this->request->getRequestParam(
2606
-            'messenger',
2607
-            key($this->_message_template_group->contexts_config())
2608
-        );
2609
-        return $this->_message_template_group->get_shortcodes($context, $fields, $merged);
2610
-    }
2611
-
2612
-
2613
-    /**
2614
-     * This sets the _message_template property (containing the called message_template object)
2615
-     *
2616
-     * @access protected
2617
-     * @return void
2618
-     * @throws EE_Error
2619
-     * @throws InvalidArgumentException
2620
-     * @throws ReflectionException
2621
-     * @throws InvalidDataTypeException
2622
-     * @throws InvalidInterfaceException
2623
-     */
2624
-    protected function _set_message_template_group()
2625
-    {
2626
-        // get out if this is already set.
2627
-        if (! empty($this->_message_template_group)) {
2628
-            return;
2629
-        }
2630
-
2631
-        $GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
2632
-        $GRP_ID = $this->request->getRequestParam('id', $GRP_ID, 'int');
2633
-
2634
-        // let's get the message templates
2635
-        $this->_message_template_group = ! empty($GRP_ID)
2636
-            ? $this->getMtgModel()->get_one_by_ID($GRP_ID)
2637
-            : $this->getMtgModel()->create_default_object();
2638
-
2639
-        $this->_template_pack = $this->_message_template_group->get_template_pack();
2640
-        $this->_variation     = $this->_message_template_group->get_template_pack_variation();
2641
-    }
2642
-
2643
-
2644
-    /**
2645
-     * sets up a context switcher for edit forms
2646
-     *
2647
-     * @access  protected
2648
-     * @param EE_Message_Template_Group $template_group_object the template group object being displayed on the form
2649
-     * @param array                     $args                  various things the context switcher needs.
2650
-     * @throws EE_Error
2651
-     */
2652
-    protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args)
2653
-    {
2654
-        $context_details = $template_group_object->contexts_config();
2655
-        $context_label   = $template_group_object->context_label();
2656
-        ob_start();
2657
-        ?>
2554
+	}
2555
+
2556
+
2557
+	/**
2558
+	 * used to set the $_shortcodes property for when its needed elsewhere.
2559
+	 *
2560
+	 * @access protected
2561
+	 * @return void
2562
+	 * @throws EE_Error
2563
+	 * @throws InvalidArgumentException
2564
+	 * @throws ReflectionException
2565
+	 * @throws InvalidDataTypeException
2566
+	 * @throws InvalidInterfaceException
2567
+	 */
2568
+	protected function _set_shortcodes()
2569
+	{
2570
+
2571
+		// no need to run this if the property is already set
2572
+		if (! empty($this->_shortcodes)) {
2573
+			return;
2574
+		}
2575
+
2576
+		$this->_shortcodes = $this->_get_shortcodes();
2577
+	}
2578
+
2579
+
2580
+	/**
2581
+	 * gets all shortcodes for a given template group. (typically used by _set_shortcodes to set the $_shortcodes
2582
+	 * property)
2583
+	 *
2584
+	 * @access  protected
2585
+	 * @param array   $fields  include an array of specific field names that you want to be used to get the shortcodes
2586
+	 *                         for. Defaults to all (for the given context)
2587
+	 * @param boolean $merged  Whether to merge all the shortcodes into one list of unique shortcodes
2588
+	 * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is
2589
+	 *                         true just an array of shortcode/label pairs.
2590
+	 * @throws EE_Error
2591
+	 * @throws InvalidArgumentException
2592
+	 * @throws ReflectionException
2593
+	 * @throws InvalidDataTypeException
2594
+	 * @throws InvalidInterfaceException
2595
+	 */
2596
+	protected function _get_shortcodes($fields = [], $merged = true)
2597
+	{
2598
+		$this->_set_message_template_group();
2599
+
2600
+		// we need the messenger and message template to retrieve the valid shortcodes array.
2601
+		$GRP_ID = $this->request->getRequestParam('id', 0, 'int');
2602
+		if (empty($GRP_ID)) {
2603
+			return [];
2604
+		}
2605
+		$context = $this->request->getRequestParam(
2606
+			'messenger',
2607
+			key($this->_message_template_group->contexts_config())
2608
+		);
2609
+		return $this->_message_template_group->get_shortcodes($context, $fields, $merged);
2610
+	}
2611
+
2612
+
2613
+	/**
2614
+	 * This sets the _message_template property (containing the called message_template object)
2615
+	 *
2616
+	 * @access protected
2617
+	 * @return void
2618
+	 * @throws EE_Error
2619
+	 * @throws InvalidArgumentException
2620
+	 * @throws ReflectionException
2621
+	 * @throws InvalidDataTypeException
2622
+	 * @throws InvalidInterfaceException
2623
+	 */
2624
+	protected function _set_message_template_group()
2625
+	{
2626
+		// get out if this is already set.
2627
+		if (! empty($this->_message_template_group)) {
2628
+			return;
2629
+		}
2630
+
2631
+		$GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
2632
+		$GRP_ID = $this->request->getRequestParam('id', $GRP_ID, 'int');
2633
+
2634
+		// let's get the message templates
2635
+		$this->_message_template_group = ! empty($GRP_ID)
2636
+			? $this->getMtgModel()->get_one_by_ID($GRP_ID)
2637
+			: $this->getMtgModel()->create_default_object();
2638
+
2639
+		$this->_template_pack = $this->_message_template_group->get_template_pack();
2640
+		$this->_variation     = $this->_message_template_group->get_template_pack_variation();
2641
+	}
2642
+
2643
+
2644
+	/**
2645
+	 * sets up a context switcher for edit forms
2646
+	 *
2647
+	 * @access  protected
2648
+	 * @param EE_Message_Template_Group $template_group_object the template group object being displayed on the form
2649
+	 * @param array                     $args                  various things the context switcher needs.
2650
+	 * @throws EE_Error
2651
+	 */
2652
+	protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args)
2653
+	{
2654
+		$context_details = $template_group_object->contexts_config();
2655
+		$context_label   = $template_group_object->context_label();
2656
+		ob_start();
2657
+		?>
2658 2658
         <div class="ee-msg-switcher-container">
2659 2659
             <form method="get" action="<?php echo esc_url_raw(EE_MSG_ADMIN_URL); ?>" id="ee-msg-context-switcher-frm">
2660 2660
                 <?php
2661
-                foreach ($args as $name => $value) {
2662
-                    if ($name === 'context' || empty($value) || $name === 'extra') {
2663
-                        continue;
2664
-                    }
2665
-                    ?>
2661
+				foreach ($args as $name => $value) {
2662
+					if ($name === 'context' || empty($value) || $name === 'extra') {
2663
+						continue;
2664
+					}
2665
+					?>
2666 2666
                     <input type="hidden"
2667 2667
                            name="<?php echo esc_attr($name); ?>"
2668 2668
                            value="<?php echo esc_attr($value); ?>"
2669 2669
                     />
2670 2670
                     <?php
2671
-                }
2672
-                // setup nonce_url
2673
-                wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2674
-                $id = 'ee-' . sanitize_key($context_label['label']) . '-select';
2675
-                ?>
2671
+				}
2672
+				// setup nonce_url
2673
+				wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2674
+				$id = 'ee-' . sanitize_key($context_label['label']) . '-select';
2675
+				?>
2676 2676
                 <label for='<?php echo esc_attr($id); ?>' class='screen-reader-text'>
2677 2677
                     <?php esc_html_e('message context options', 'event_espresso'); ?>
2678 2678
                 </label>
2679 2679
                 <select id="<?php echo esc_attr($id); ?>" name="context">
2680 2680
                     <?php
2681
-                    $context_templates = $template_group_object->context_templates();
2682
-                    if (is_array($context_templates)) :
2683
-                        foreach ($context_templates as $context => $template_fields) :
2684
-                            $checked = ($context === $args['context']) ? 'selected="selected"' : '';
2685
-                            ?>
2681
+					$context_templates = $template_group_object->context_templates();
2682
+					if (is_array($context_templates)) :
2683
+						foreach ($context_templates as $context => $template_fields) :
2684
+							$checked = ($context === $args['context']) ? 'selected="selected"' : '';
2685
+							?>
2686 2686
                             <option value="<?php echo esc_attr($context); ?>" <?php echo $checked; ?>>
2687 2687
                                 <?php echo $context_details[ $context ]['label']; // already escaped
2688
-                                ?>
2688
+								?>
2689 2689
                             </option>
2690 2690
                         <?php endforeach;
2691
-                    endif; ?>
2691
+					endif; ?>
2692 2692
                 </select>
2693 2693
                 <?php $button_text = sprintf(
2694
-                    esc_html__('Switch %s', 'event_espresso'),
2695
-                    ucwords($context_label['label'])
2696
-                ); ?>
2694
+					esc_html__('Switch %s', 'event_espresso'),
2695
+					ucwords($context_label['label'])
2696
+				); ?>
2697 2697
                 <input class='button--secondary'
2698 2698
                        id="submit-msg-context-switcher-sbmt"
2699 2699
                        type="submit"
@@ -2701,1997 +2701,1997 @@  discard block
 block discarded – undo
2701 2701
                 />
2702 2702
             </form>
2703 2703
             <?php echo $args['extra']; // already escaped
2704
-            ?>
2704
+			?>
2705 2705
         </div> <!-- end .ee-msg-switcher-container -->
2706 2706
         <?php $this->_context_switcher = ob_get_clean();
2707
-    }
2708
-
2709
-
2710
-    /**
2711
-     * @param bool $new
2712
-     * @throws EE_Error
2713
-     * @throws ReflectionException
2714
-     */
2715
-    protected function _insert_or_update_message_template($new = false)
2716
-    {
2717
-        $form_data    = $this->getMessageTemplateFormData();
2718
-        $GRP_ID       = $form_data['GRP_ID'];
2719
-        $messenger    = $form_data['MTP_messenger'];
2720
-        $message_type = $form_data['MTP_message_type'];
2721
-        $context      = $form_data['MTP_context'];
2722
-
2723
-        // if this is "new" then we need to generate the default contexts
2724
-        // for the selected messenger/message_type for user to edit.
2725
-        [$success, $query_args] = $new
2726
-            ? $this->generateNewTemplates($GRP_ID, $messenger, $message_type)
2727
-            : $this->updateExistingTemplates($GRP_ID, $messenger, $message_type, $context, $form_data);
2728
-
2729
-        $success     = $success ? 1 : 0;
2730
-        $action_desc = $new ? 'created' : 'updated';
2731
-        $item_desc   = $this->generateUpdateDescription($messenger, $message_type, $context);
2732
-        $override    = $this->performTestSendAfterUpdate($messenger, $message_type, $context);
2733
-
2734
-        $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2735
-    }
2736
-
2737
-
2738
-    /**
2739
-     * retrieve and sanitize form data
2740
-     *
2741
-     * @return array
2742
-     * @since 4.10.29.p
2743
-     */
2744
-    protected function getMessageTemplateFormData()
2745
-    {
2746
-        return [
2747
-            'GRP_ID'           => $this->request->getRequestParam('GRP_ID', 0, 'int'),
2748
-            'MTP_context'      => strtolower($this->request->getRequestParam('MTP_context', '')),
2749
-            'MTP_messenger'    => strtolower($this->request->getRequestParam('MTP_messenger', '')),
2750
-            'MTP_message_type' => strtolower($this->request->getRequestParam('MTP_message_type', '')),
2751
-            'MTP_user_id'      => $this->request->getRequestParam('MTP_user_id', 0, 'int'),
2752
-            'MTP_is_global'    => $this->request->getRequestParam('MTP_is_global', 0, 'int'),
2753
-            'MTP_is_override'  => $this->request->getRequestParam('MTP_is_override', 0, 'int'),
2754
-            'MTP_deleted'      => $this->request->getRequestParam('MTP_deleted', 0, 'int'),
2755
-            'MTP_is_active'    => $this->request->getRequestParam('MTP_is_active', 0, 'int'),
2756
-        ];
2757
-    }
2758
-
2759
-
2760
-    /**
2761
-     * @param int    $GRP_ID
2762
-     * @param string $messenger
2763
-     * @param string $message_type
2764
-     * @return array no return on AJAX requests
2765
-     * @throws EE_Error
2766
-     * @throws ReflectionException
2767
-     * @since 4.10.29.p
2768
-     */
2769
-    private function generateNewTemplates($GRP_ID, $messenger, $message_type)
2770
-    {
2771
-        $new_templates = $this->_generate_new_templates($messenger, [$message_type], $GRP_ID);
2772
-        $success       = ! empty($new_templates);
2773
-
2774
-        // we return things differently if doing ajax
2775
-        if ($this->request->isAjax()) {
2776
-            $this->_template_args['success'] = $success;
2777
-            $this->_template_args['error']   = ! $success;
2778
-            $this->_template_args['content'] = '';
2779
-            $this->_template_args['data']    = [
2780
-                'grpID'        => $new_templates['GRP_ID'],
2781
-                'templateName' => $new_templates['template_name'],
2782
-            ];
2783
-            if ($success) {
2784
-                EE_Error::overwrite_success();
2785
-                EE_Error::add_success(
2786
-                    esc_html__(
2787
-                        'The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.',
2788
-                        'event_espresso'
2789
-                    )
2790
-                );
2791
-            }
2792
-            $this->_return_json();
2793
-        }
2794
-        return [
2795
-            $success,
2796
-            // 'query_args'
2797
-            [
2798
-                'id'      => $new_templates['GRP_ID'],
2799
-                'context' => $new_templates['MTP_context'],
2800
-                'action'  => 'edit_message_template',
2801
-            ],
2802
-        ];
2803
-    }
2804
-
2805
-
2806
-    /**
2807
-     * @param int    $GRP_ID
2808
-     * @param string $messenger
2809
-     * @param string $message_type
2810
-     * @param string $context
2811
-     * @param array  $form_data
2812
-     * @return array
2813
-     * @throws EE_Error
2814
-     * @since 4.10.29.p
2815
-     */
2816
-    private function updateExistingTemplates(
2817
-        $GRP_ID,
2818
-        $messenger,
2819
-        $message_type,
2820
-        $context,
2821
-        array $form_data
2822
-    ) {
2823
-        $success         = false;
2824
-        $template_fields = $this->getTemplateFields();
2825
-        if ($template_fields) {
2826
-            // if field data is valid, then success will be true
2827
-            $success = $this->validateTemplateFields(
2828
-                $messenger,
2829
-                $message_type,
2830
-                $context,
2831
-                $template_fields
2832
-            );
2833
-            if ($success) {
2834
-                $field_data = [];
2835
-                foreach ($template_fields as $template_field => $content) {
2836
-                    // combine top-level form data with content for this field
2837
-                    $field_data = $this->getTemplateFieldFormData($content, $form_data);
2838
-                    $success    = $this->updateMessageTemplates($template_field, $field_data) ? $success : false;
2839
-                }
2840
-                // we can use the last set_column_values for the MTPG update
2841
-                // (because its the same for all of these specific MTPs)
2842
-                $success = $this->updateMessageTemplateGroup($field_data) ? $success : false;
2843
-            }
2844
-        }
2845
-
2846
-        return [
2847
-            $success,
2848
-            // 'query_args'
2849
-            [
2850
-                'id'      => $GRP_ID,
2851
-                'context' => $context,
2852
-                'action'  => 'edit_message_template',
2853
-            ],
2854
-        ];
2855
-    }
2856
-
2857
-
2858
-    /**
2859
-     * @return array
2860
-     * @since 4.10.29.p
2861
-     */
2862
-    private function getTemplateFields()
2863
-    {
2864
-        $template_fields = $this->request->getRequestParam('MTP_template_fields', null, 'html', true);
2865
-        if (empty($template_fields)) {
2866
-            EE_Error::add_error(
2867
-                esc_html__(
2868
-                    'There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.',
2869
-                    'event_espresso'
2870
-                ),
2871
-                __FILE__,
2872
-                __FUNCTION__,
2873
-                __LINE__
2874
-            );
2875
-            return null;
2876
-        }
2877
-        // messages content is expected to be escaped
2878
-        return EEH_Array::addSlashesRecursively($template_fields);
2879
-    }
2880
-
2881
-
2882
-    /**
2883
-     * @param string $messenger
2884
-     * @param string $message_type
2885
-     * @param string $context
2886
-     * @param array  $template_fields
2887
-     * @return bool
2888
-     * @throws EE_Error
2889
-     * @since   4.10.29.p
2890
-     */
2891
-    private function validateTemplateFields(
2892
-        $messenger,
2893
-        $message_type,
2894
-        $context,
2895
-        array $template_fields
2896
-    ) {
2897
-        // first validate all fields!
2898
-        // this filter allows client code to add its own validation to the template fields as well.
2899
-        // returning an empty array means everything passed validation.
2900
-        // errors in validation should be represented in an array with the following shape:
2901
-        // array(
2902
-        //   'fieldname' => array(
2903
-        //          'msg' => 'error message'
2904
-        //          'value' => 'value for field producing error'
2905
-        // )
2906
-        $custom_validation = (array) apply_filters(
2907
-            'FHEE__Messages_Admin_Page___insert_or_update_message_template__validates',
2908
-            [],
2909
-            $template_fields,
2910
-            $context,
2911
-            $messenger,
2912
-            $message_type
2913
-        );
2914
-
2915
-        $system_validation = $this->getMtgModel()->validate(
2916
-            $template_fields,
2917
-            $context,
2918
-            $messenger,
2919
-            $message_type
2920
-        );
2921
-
2922
-        $system_validation = ! is_array($system_validation) && $system_validation ? [] : $system_validation;
2923
-        $validates         = array_merge($custom_validation, $system_validation);
2924
-
2925
-        // if $validate returned error messages (i.e. is_array()) then we need to process them and setup an
2926
-        // appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.
2927
-        //  WE need to make sure there is no actual error messages in validates.
2928
-        if (empty($validates)) {
2929
-            return true;
2930
-        }
2931
-
2932
-        // add the transient so when the form loads we know which fields to highlight
2933
-        $this->_add_transient('edit_message_template', $validates);
2934
-        // setup notices
2935
-        foreach ($validates as $error) {
2936
-            if (isset($error['msg'])) {
2937
-                EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
2938
-            }
2939
-        }
2940
-        return false;
2941
-    }
2942
-
2943
-
2944
-    /**
2945
-     * @param array $field_data
2946
-     * @param array $form_data
2947
-     * @return array
2948
-     * @since   4.10.29.p
2949
-     */
2950
-    private function getTemplateFieldFormData(array $field_data, array $form_data)
2951
-    {
2952
-        return $form_data + [
2953
-                'MTP_ID'             => $field_data['MTP_ID'],
2954
-                'MTP_template_field' => $field_data['name'],
2955
-                // if they aren't allowed to use all JS, restrict them to standard allowed post tags
2956
-                'MTP_content'        => ! current_user_can('unfiltered_html')
2957
-                    ? $this->sanitizeMessageTemplateContent($field_data['content'])
2958
-                    : $field_data['content'],
2959
-            ];
2960
-    }
2961
-
2962
-
2963
-    /**
2964
-     * @param string $template_field
2965
-     * @param array  $form_data
2966
-     * @return bool
2967
-     * @throws EE_Error
2968
-     * @since 4.10.29.p
2969
-     */
2970
-    private function updateMessageTemplates($template_field, array $form_data)
2971
-    {
2972
-        $MTP_ID                  = $form_data['MTP_ID'];
2973
-        $message_template_fields = [
2974
-            'GRP_ID'             => $form_data['GRP_ID'],
2975
-            'MTP_template_field' => $form_data['MTP_template_field'],
2976
-            'MTP_context'        => $form_data['MTP_context'],
2977
-            'MTP_content'        => $form_data['MTP_content'],
2978
-        ];
2979
-
2980
-        $hasMtpID = ! empty($MTP_ID);
2981
-        // if we have a MTP_ID for this field then update it, otherwise insert.
2982
-        // this has already been through the template field validator and sanitized, so it will be
2983
-        // safe to insert this field.  Why insert?  This typically happens when we introduce a new
2984
-        // message template field in a messenger/message type and existing users don't have the
2985
-        // default setup for it.
2986
-        // @link https://events.codebasehq.com/projects/event-espresso/tickets/9465
2987
-        $updated = $hasMtpID
2988
-            ? $this->getMtpModel()->update($message_template_fields, [['MTP_ID' => $MTP_ID]])
2989
-            : $this->getMtpModel()->insert($message_template_fields);
2990
-
2991
-        $insert_failed = ! $hasMtpID && ! $updated;
2992
-        // updates will return 0 if the field was not changed (ie: no changes = nothing actually updated)
2993
-        // but we won't consider that a problem, but if it returns false, then something went BOOM!
2994
-        $update_failed = $hasMtpID && $updated === false;
2995
-
2996
-        if ($insert_failed || $update_failed) {
2997
-            EE_Error::add_error(
2998
-                sprintf(
2999
-                    esc_html__('%s field was NOT updated for some reason', 'event_espresso'),
3000
-                    $template_field
3001
-                ),
3002
-                __FILE__,
3003
-                __FUNCTION__,
3004
-                __LINE__
3005
-            );
3006
-            return false;
3007
-        }
3008
-        return true;
3009
-    }
3010
-
3011
-
3012
-    /**
3013
-     * @param array $form_data
3014
-     * @return bool
3015
-     * @throws EE_Error
3016
-     * @since 4.10.29.p
3017
-     */
3018
-    private function updateMessageTemplateGroup(array $form_data)
3019
-    {
3020
-        $GRP_ID  = $form_data['GRP_ID'];
3021
-        $updated = $this->getMtgModel()->update(
3022
-        // fields and values
3023
-            [
3024
-                'MTP_user_id'      => $form_data['MTP_user_id'],
3025
-                'MTP_messenger'    => $form_data['MTP_messenger'],
3026
-                'MTP_message_type' => $form_data['MTP_message_type'],
3027
-                'MTP_is_global'    => $form_data['MTP_is_global'],
3028
-                'MTP_is_override'  => $form_data['MTP_is_override'],
3029
-                'MTP_deleted'      => $form_data['MTP_deleted'],
3030
-                'MTP_is_active'    => $form_data['MTP_is_active'],
3031
-                'MTP_name'         => $this->request->getRequestParam('ee_msg_non_global_fields[MTP_name]', ''),
3032
-                'MTP_description'  => $this->request->getRequestParam(
3033
-                    'ee_msg_non_global_fields[MTP_description]',
3034
-                    ''
3035
-                ),
3036
-            ],
3037
-            // where
3038
-            [['GRP_ID' => $GRP_ID]]
3039
-        );
3040
-
3041
-        if ($updated === false) {
3042
-            EE_Error::add_error(
3043
-                sprintf(
3044
-                    esc_html__(
3045
-                        'The Message Template Group (%d) was NOT updated for some reason',
3046
-                        'event_espresso'
3047
-                    ),
3048
-                    $form_data['GRP_ID']
3049
-                ),
3050
-                __FILE__,
3051
-                __FUNCTION__,
3052
-                __LINE__
3053
-            );
3054
-            return false;
3055
-        }
3056
-        // k now we need to ensure the template_pack and template_variation fields are set.
3057
-        $template_pack      = $this->request->getRequestParam('MTP_template_pack', 'default');
3058
-        $template_variation = $this->request->getRequestParam('MTP_template_variation', 'default');
3059
-
3060
-        $message_template_group = $this->getMtgModel()->get_one_by_ID($GRP_ID);
3061
-        if ($message_template_group instanceof EE_Message_Template_Group) {
3062
-            $message_template_group->set_template_pack_name($template_pack);
3063
-            $message_template_group->set_template_pack_variation($template_variation);
3064
-        }
3065
-        return true;
3066
-    }
3067
-
3068
-
3069
-    /**
3070
-     * recursively runs wp_kses() on message template content in a model safe manner
3071
-     *
3072
-     * @param array|string $content
3073
-     * @return array|string
3074
-     * @since   4.10.29.p
3075
-     */
3076
-    private function sanitizeMessageTemplateContent($content)
3077
-    {
3078
-        if (is_array($content)) {
3079
-            foreach ($content as $key => $value) {
3080
-                $content[ $key ] = $this->sanitizeMessageTemplateContent($value);
3081
-            }
3082
-            return $content;
3083
-        }
3084
-        // remove slashes so wp_kses() works properly
3085
-        // wp_kses_stripslashes() only removes slashes from double-quotes,
3086
-        // so attributes using single quotes always appear invalid.
3087
-        $content = stripslashes($content);
3088
-        $content = wp_kses($content, wp_kses_allowed_html('post'));
3089
-        // But currently the models expect slashed data, so after wp_kses()
3090
-        // runs we need to re-slash the data. Sheesh.
3091
-        // See https://events.codebasehq.com/projects/event-espresso/tickets/11211#update-47321587
3092
-        return addslashes($content);
3093
-    }
3094
-
3095
-
3096
-    /**
3097
-     * @param string $messenger
3098
-     * @param string $message_type
3099
-     * @param string $context
3100
-     * @return string
3101
-     * @since 4.10.29.p
3102
-     */
3103
-    private function generateUpdateDescription($messenger, $message_type, $context)
3104
-    {
3105
-        // need the message type and messenger objects to be able to use the labels for the notices
3106
-        $messenger_object = $this->_message_resource_manager->get_messenger($messenger);
3107
-        $messenger_label  = $messenger_object instanceof EE_messenger
3108
-            ? ucwords($messenger_object->label['singular'])
3109
-            : '';
3110
-
3111
-        $message_type_object = $this->_message_resource_manager->get_message_type($message_type);
3112
-        $message_type_label  = $message_type_object instanceof EE_message_type
3113
-            ? ucwords($message_type_object->label['singular'])
3114
-            : '';
3115
-
3116
-        $context   = ucwords(str_replace('_', ' ', $context));
3117
-        $item_desc = $messenger_label && $message_type_label
3118
-            ? $messenger_label . ' ' . $message_type_label . ' ' . $context . ' '
3119
-            : '';
3120
-        $item_desc .= 'Message Template';
3121
-        return $item_desc;
3122
-    }
3123
-
3124
-
3125
-    /**
3126
-     * @param string $messenger
3127
-     * @param string $message_type
3128
-     * @param string $context
3129
-     * @return bool
3130
-     * @throws EE_Error
3131
-     * @throws ReflectionException
3132
-     * @since 4.10.29.p
3133
-     */
3134
-    private function performTestSendAfterUpdate($messenger, $message_type, $context)
3135
-    {
3136
-        // was a test send triggered?
3137
-        if ($this->request->requestParamIsSet('test_button')) {
3138
-            EE_Error::overwrite_success();
3139
-            $this->_do_test_send($context, $messenger, $message_type);
3140
-            return true;
3141
-        }
3142
-        return false;
3143
-    }
3144
-
3145
-
3146
-    /**
3147
-     * processes a test send request to do an actual messenger delivery test for the given message template being tested
3148
-     *
3149
-     * @param string $context      what context being tested
3150
-     * @param string $messenger    messenger being tested
3151
-     * @param string $message_type message type being tested
3152
-     * @throws EE_Error
3153
-     * @throws InvalidArgumentException
3154
-     * @throws InvalidDataTypeException
3155
-     * @throws InvalidInterfaceException
3156
-     * @throws ReflectionException
3157
-     */
3158
-    protected function _do_test_send($context, $messenger, $message_type)
3159
-    {
3160
-        // set things up for preview
3161
-        $this->request->setRequestParam('messenger', $messenger);
3162
-        $this->request->setRequestParam('message_type', $message_type);
3163
-        $this->request->setRequestParam('context', $context);
3164
-        $GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
3165
-        $this->request->setRequestParam('GRP_ID', $GRP_ID);
3166
-
3167
-        $active_messenger  = $this->_message_resource_manager->get_active_messenger($messenger);
3168
-        $test_settings_fld = $this->request->getRequestParam('test_settings_fld', [], 'string', true);
3169
-
3170
-        // let's save any existing fields that might be required by the messenger
3171
-        if (
3172
-            ! empty($test_settings_fld)
3173
-            && $active_messenger instanceof EE_messenger
3174
-            && apply_filters(
3175
-                'FHEE__Messages_Admin_Page__do_test_send__set_existing_test_settings',
3176
-                true,
3177
-                $test_settings_fld,
3178
-                $active_messenger
3179
-            )
3180
-        ) {
3181
-            $active_messenger->set_existing_test_settings($test_settings_fld);
3182
-        }
3183
-
3184
-        /**
3185
-         * Use filter to add additional controls on whether message can send or not
3186
-         */
3187
-        if (
3188
-            apply_filters(
3189
-                'FHEE__Messages_Admin_Page__do_test_send__can_send',
3190
-                true,
3191
-                $context,
3192
-                $this->request->requestParams(),
3193
-                $messenger,
3194
-                $message_type
3195
-            )
3196
-        ) {
3197
-            if (EEM_Event::instance()->count() > 0) {
3198
-                $success = $this->_preview_message(true);
3199
-                if ($success) {
3200
-                    EE_Error::add_success(esc_html__('Test message sent', 'event_espresso'));
3201
-                } else {
3202
-                    EE_Error::add_error(
3203
-                        esc_html__('The test message was not sent', 'event_espresso'),
3204
-                        __FILE__,
3205
-                        __FUNCTION__,
3206
-                        __LINE__
3207
-                    );
3208
-                }
3209
-            } else {
3210
-                $this->noEventsErrorMessage(true);
3211
-            }
3212
-        }
3213
-    }
3214
-
3215
-
3216
-    /**
3217
-     * _generate_new_templates
3218
-     * This will handle the messenger, message_type selection when "adding a new custom template" for an event and will
3219
-     * automatically create the defaults for the event.  The user would then be redirected to edit the default context
3220
-     * for the event.
3221
-     *
3222
-     *
3223
-     * @param string $messenger      the messenger we are generating templates for
3224
-     * @param array  $message_types  array of message types that the templates are generated for.
3225
-     * @param int    $GRP_ID         If this is a custom template being generated then a GRP_ID needs to be included to
3226
-     *                               indicate the message_template_group being used as the base.
3227
-     *
3228
-     * @param bool   $global
3229
-     *
3230
-     * @return array|bool array of data required for the redirect to the correct edit page or bool if
3231
-     *                               encountering problems.
3232
-     * @throws EE_Error
3233
-     * @throws ReflectionException
3234
-     */
3235
-    protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false)
3236
-    {
3237
-        // if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we
3238
-        // just don't generate any templates.
3239
-        if (empty($message_types)) {
3240
-            return [];
3241
-        }
3242
-
3243
-        $templates = EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
3244
-        return $templates[0];
3245
-    }
3246
-
3247
-
3248
-    /**
3249
-     * [_trash_or_restore_message_template]
3250
-     *
3251
-     * @param boolean $trash  whether to move an item to trash/restore (TRUE) or restore it (FALSE)
3252
-     * @param boolean $all    whether this is going to trash/restore all contexts within a template group (TRUE) OR just
3253
-     *                        an individual context (FALSE).
3254
-     * @return void
3255
-     * @throws EE_Error
3256
-     * @throws InvalidArgumentException
3257
-     * @throws InvalidDataTypeException
3258
-     * @throws InvalidInterfaceException
3259
-     */
3260
-    protected function _trash_or_restore_message_template($trash = true, $all = false)
3261
-    {
3262
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3263
-
3264
-        $success = 1;
3265
-
3266
-        // incoming GRP_IDs
3267
-        if ($all) {
3268
-            // Checkboxes
3269
-            $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
3270
-            if (! empty($checkboxes)) {
3271
-                // if array has more than one element then success message should be plural.
3272
-                // todo: what about nonce?
3273
-                $success = count($checkboxes) > 1 ? 2 : 1;
3274
-
3275
-                // cycle through checkboxes
3276
-                while (list($GRP_ID, $value) = each($checkboxes)) {
3277
-                    $trashed_or_restored = $trash
3278
-                        ? $this->getMtgModel()->delete_by_ID($GRP_ID)
3279
-                        : $this->getMtgModel()->restore_by_ID($GRP_ID);
3280
-                    if (! $trashed_or_restored) {
3281
-                        $success = 0;
3282
-                    }
3283
-                }
3284
-            } else {
3285
-                // grab single GRP_ID and handle
3286
-                $GRP_ID = $this->request->getRequestParam('id', 0, 'int');
3287
-                if (! empty($GRP_ID)) {
3288
-                    $trashed_or_restored = $trash
3289
-                        ? $this->getMtgModel()->delete_by_ID($GRP_ID)
3290
-                        : $this->getMtgModel()->restore_by_ID($GRP_ID);
3291
-                    if (! $trashed_or_restored) {
3292
-                        $success = 0;
3293
-                    }
3294
-                } else {
3295
-                    $success = 0;
3296
-                }
3297
-            }
3298
-        }
3299
-
3300
-        $action_desc = $trash
3301
-            ? esc_html__('moved to the trash', 'event_espresso')
3302
-            : esc_html__('restored', 'event_espresso');
3303
-
3304
-        $template_switch = $this->request->getRequestParam('template_switch', false, 'bool');
3305
-        $action_desc     = $template_switch ? esc_html__('switched', 'event_espresso') : $action_desc;
3306
-
3307
-        $item_desc = $all ? _n(
3308
-            'Message Template Group',
3309
-            'Message Template Groups',
3310
-            $success,
3311
-            'event_espresso'
3312
-        ) : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
3313
-
3314
-        $item_desc = $template_switch
3315
-            ? _n('template', 'templates', $success, 'event_espresso')
3316
-            : $item_desc;
3317
-
3318
-        $this->_redirect_after_action($success, $item_desc, $action_desc, []);
3319
-    }
3320
-
3321
-
3322
-    /**
3323
-     * [_delete_message_template]
3324
-     * NOTE: this handles not only the deletion of the groups but also all the templates belonging to that group.
3325
-     *
3326
-     * @return void
3327
-     * @throws EE_Error
3328
-     * @throws InvalidArgumentException
3329
-     * @throws InvalidDataTypeException
3330
-     * @throws InvalidInterfaceException
3331
-     * @throws ReflectionException
3332
-     */
3333
-    protected function _delete_message_template()
3334
-    {
3335
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3336
-
3337
-        // checkboxes
3338
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
3339
-        if (! empty($checkboxes)) {
3340
-            // if array has more than one element then success message should be plural
3341
-            $success = count($checkboxes) > 1 ? 2 : 1;
3342
-
3343
-            // cycle through bulk action checkboxes
3344
-            while (list($GRP_ID, $value) = each($checkboxes)) {
3345
-                $success = $this->_delete_mtp_permanently($GRP_ID) ? $success : false;
3346
-            }
3347
-        } else {
3348
-            // grab single grp_id and delete
3349
-            $GRP_ID  = $this->request->getRequestParam('id', 0, 'int');
3350
-            $success = $this->_delete_mtp_permanently($GRP_ID);
3351
-        }
3352
-
3353
-        $this->_redirect_after_action($success, 'Message Templates', 'deleted', []);
3354
-    }
3355
-
3356
-
3357
-    /**
3358
-     * helper for permanently deleting a mtP group and all related message_templates
3359
-     *
3360
-     * @param int  $GRP_ID        The group being deleted
3361
-     * @param bool $include_group whether to delete the Message Template Group as well.
3362
-     * @return bool boolean to indicate the success of the deletes or not.
3363
-     * @throws EE_Error
3364
-     * @throws InvalidArgumentException
3365
-     * @throws InvalidDataTypeException
3366
-     * @throws InvalidInterfaceException
3367
-     * @throws ReflectionException
3368
-     * @throws ReflectionException
3369
-     */
3370
-    private function _delete_mtp_permanently($GRP_ID, $include_group = true)
3371
-    {
3372
-        $success = true;
3373
-        // first let's GET this group
3374
-        $MTG = $this->getMtgModel()->get_one_by_ID($GRP_ID);
3375
-        // then delete permanently all the related Message Templates
3376
-        $deleted = $MTG->delete_related_permanently('Message_Template');
3377
-
3378
-        if ($deleted === 0) {
3379
-            $success = false;
3380
-        }
3381
-
3382
-        // now delete permanently this particular group
3383
-
3384
-        if ($include_group && ! $MTG->delete_permanently()) {
3385
-            $success = false;
3386
-        }
3387
-
3388
-        return $success;
3389
-    }
3390
-
3391
-
3392
-    /**
3393
-     *    _learn_more_about_message_templates_link
3394
-     *
3395
-     * @access protected
3396
-     * @return string
3397
-     */
3398
-    protected function _learn_more_about_message_templates_link()
3399
-    {
3400
-        return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'
3401
-               . esc_html__('learn more about how message templates works', 'event_espresso')
3402
-               . '</a>';
3403
-    }
3404
-
3405
-
3406
-    /**
3407
-     * Used for setting up messenger/message type activation.  This loads up the initial view.  The rest is handled by
3408
-     * ajax and other routes.
3409
-     *
3410
-     * @return void
3411
-     * @throws DomainException
3412
-     * @throws EE_Error
3413
-     */
3414
-    protected function _settings()
3415
-    {
3416
-        $this->_set_m_mt_settings();
3417
-
3418
-        // let's setup the messenger tabs
3419
-        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
3420
-            $this->_m_mt_settings['messenger_tabs'],
3421
-            'messenger_links',
3422
-            '|',
3423
-            $this->request->getRequestParam('selected_messenger', 'email')
3424
-        );
3425
-
3426
-        $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
3427
-        $this->_template_args['after_admin_page_content']  = '</div><!-- end .ui-widget -->';
3428
-
3429
-        $this->display_admin_page_with_sidebar();
3430
-    }
3431
-
3432
-
3433
-    /**
3434
-     * This sets the $_m_mt_settings property for when needed (used on the Messages settings page)
3435
-     *
3436
-     * @access protected
3437
-     * @return void
3438
-     * @throws DomainException
3439
-     */
3440
-    protected function _set_m_mt_settings()
3441
-    {
3442
-        // first if this is already set then lets get out no need to regenerate data.
3443
-        if (! empty($this->_m_mt_settings)) {
3444
-            return;
3445
-        }
3446
-
3447
-        // get all installed messengers and message_types
3448
-        $messengers    = $this->_message_resource_manager->installed_messengers();
3449
-        $message_types = $this->_message_resource_manager->installed_message_types();
3450
-
3451
-
3452
-        // assemble the array for the _tab_text_links helper
3453
-
3454
-        foreach ($messengers as $messenger) {
3455
-            $active = $this->_message_resource_manager->is_messenger_active($messenger->name);
3456
-            $class = 'ee-messenger-' .  sanitize_key($messenger->label['singular']);
3457
-            $this->_m_mt_settings['messenger_tabs'][ $messenger->name ] = [
3458
-                'label' => ucwords($messenger->label['singular']),
3459
-                'class' => $active ? "{$class} messenger-active" : $class,
3460
-                'href'  => $messenger->name,
3461
-                'title' => esc_html__('Modify this Messenger', 'event_espresso'),
3462
-                'slug'  => $messenger->name,
3463
-                'obj'   => $messenger,
3464
-                'icon' => $active
3465
-                    ? '<span class="dashicons dashicons-yes-alt"></span>'
3466
-                    : '<span class="dashicons dashicons-remove"></span>',
3467
-            ];
3468
-
3469
-
3470
-            $message_types_for_messenger = $messenger->get_valid_message_types();
3471
-
3472
-            foreach ($message_types as $message_type) {
3473
-                // first we need to verify that this message type is valid with this messenger. Cause if it isn't then
3474
-                // it shouldn't show in either the inactive OR active metabox.
3475
-                if (! in_array($message_type->name, $message_types_for_messenger, true)) {
3476
-                    continue;
3477
-                }
3478
-
3479
-                $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger(
3480
-                    $messenger->name,
3481
-                    $message_type->name
3482
-                )
3483
-                    ? 'active'
3484
-                    : 'inactive';
3485
-
3486
-                $this->_m_mt_settings['message_type_tabs'][ $messenger->name ][ $a_or_i ][ $message_type->name ] = [
3487
-                    'label'    => ucwords($message_type->label['singular']),
3488
-                    'class'    => 'message-type-' . $a_or_i,
3489
-                    'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
3490
-                    'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
3491
-                    'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
3492
-                    'title'    => $a_or_i === 'active'
3493
-                        ? esc_html__('Drag this message type to the Inactive window to deactivate', 'event_espresso')
3494
-                        : esc_html__('Drag this message type to the messenger to activate', 'event_espresso'),
3495
-                    'content'  => $a_or_i === 'active'
3496
-                        ? $this->_message_type_settings_content($message_type, $messenger, true)
3497
-                        : $this->_message_type_settings_content($message_type, $messenger),
3498
-                    'slug'     => $message_type->name,
3499
-                    'active'   => $a_or_i === 'active',
3500
-                    'obj'      => $message_type,
3501
-                ];
3502
-            }
3503
-        }
3504
-    }
3505
-
3506
-
3507
-    /**
3508
-     * This just prepares the content for the message type settings
3509
-     *
3510
-     * @param EE_message_type $message_type The message type object
3511
-     * @param EE_messenger    $messenger    The messenger object
3512
-     * @param boolean         $active       Whether the message type is active or not
3513
-     * @return string html output for the content
3514
-     * @throws DomainException
3515
-     */
3516
-    protected function _message_type_settings_content($message_type, $messenger, $active = false)
3517
-    {
3518
-        // get message type fields
3519
-        $fields                                         = $message_type->get_admin_settings_fields();
3520
-        $settings_template_args['template_form_fields'] = '';
3521
-
3522
-        if (! empty($fields) && $active) {
3523
-            $existing_settings = $message_type->get_existing_admin_settings($messenger->name);
3524
-            foreach ($fields as $fldname => $fldprops) {
3525
-                $field_id                         = $messenger->name . '-' . $message_type->name . '-' . $fldname;
3526
-                $template_form_field[ $field_id ] = [
3527
-                    'name'       => 'message_type_settings[' . $fldname . ']',
3528
-                    'label'      => $fldprops['label'],
3529
-                    'input'      => $fldprops['field_type'],
3530
-                    'type'       => $fldprops['value_type'],
3531
-                    'required'   => $fldprops['required'],
3532
-                    'validation' => $fldprops['validation'],
3533
-                    'value'      => isset($existing_settings[ $fldname ])
3534
-                        ? $existing_settings[ $fldname ]
3535
-                        : $fldprops['default'],
3536
-                    'options'    => isset($fldprops['options'])
3537
-                        ? $fldprops['options']
3538
-                        : [],
3539
-                    'default'    => isset($existing_settings[ $fldname ])
3540
-                        ? $existing_settings[ $fldname ]
3541
-                        : $fldprops['default'],
3542
-                    'css_class'  => 'no-drag',
3543
-                    'format'     => $fldprops['format'],
3544
-                ];
3545
-            }
3546
-
3547
-
3548
-            $settings_template_args['template_form_fields'] = ! empty($template_form_field)
3549
-                ? $this->_generate_admin_form_fields(
3550
-                    $template_form_field,
3551
-                    'string',
3552
-                    'ee_mt_activate_form'
3553
-                )
3554
-                : '';
3555
-        }
3556
-
3557
-        $settings_template_args['description'] = $message_type->description;
3558
-        // we also need some hidden fields
3559
-        $hidden_fields = [
3560
-            'message_type_settings[messenger]' . $message_type->name    => [
3561
-                'type'  => 'hidden',
3562
-                'value' => $messenger->name,
3563
-            ],
3564
-            'message_type_settings[message_type]' . $message_type->name => [
3565
-                'type'  => 'hidden',
3566
-                'value' => $message_type->name,
3567
-            ],
3568
-            'type' . $message_type->name                                => [
3569
-                'type'  => 'hidden',
3570
-                'value' => 'message_type',
3571
-            ],
3572
-        ];
3573
-
3574
-        $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3575
-            $hidden_fields,
3576
-            'array'
3577
-        );
3578
-        $settings_template_args['show_form']     = empty($settings_template_args['template_form_fields'])
3579
-            ? ' hidden'
3580
-            : '';
3581
-
3582
-
3583
-        $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
3584
-        return EEH_Template::display_template($template, $settings_template_args, true);
3585
-    }
3586
-
3587
-
3588
-    /**
3589
-     * Generate all the metaboxes for the message types and register them for the messages settings page.
3590
-     *
3591
-     * @access protected
3592
-     * @return void
3593
-     * @throws DomainException
3594
-     */
3595
-    protected function _messages_settings_metaboxes()
3596
-    {
3597
-        $this->_set_m_mt_settings();
3598
-        $m_boxes         = $mt_boxes = [];
3599
-        $m_template_args = $mt_template_args = [];
3600
-
3601
-        $selected_messenger = $this->request->getRequestParam('selected_messenger', 'email');
3602
-
3603
-        if (isset($this->_m_mt_settings['messenger_tabs'])) {
3604
-            foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
3605
-                $is_messenger_active = $this->_message_resource_manager->is_messenger_active($messenger);
3606
-                $hide_on_message     = $is_messenger_active ? '' : 'hidden';
3607
-                $hide_off_message    = $is_messenger_active ? 'hidden' : '';
3608
-
3609
-                // messenger meta boxes
3610
-                $active         = $selected_messenger === $messenger;
3611
-                $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][ $messenger ]['active'])
3612
-                    ? $this->_m_mt_settings['message_type_tabs'][ $messenger ]['active']
3613
-                    : '';
3614
-
3615
-                $m_boxes[ $messenger . '_a_box' ] = sprintf(
3616
-                    esc_html__('%s Settings', 'event_espresso'),
3617
-                    $tab_array['label']
3618
-                );
3619
-
3620
-                $m_template_args[ $messenger . '_a_box' ] = [
3621
-                    'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3622
-                    'inactive_message_types' => isset(
3623
-                        $this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive']
3624
-                    )
3625
-                        ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive'])
3626
-                        : '',
3627
-                    'content'                => $this->_get_messenger_box_content($tab_array['obj']),
3628
-                    'hidden'                 => $active ? '' : ' hidden',
3629
-                    'hide_on_message'        => $hide_on_message,
3630
-                    'messenger'              => $messenger,
3631
-                    'active'                 => $active,
3632
-                ];
3633
-
3634
-                // message type meta boxes
3635
-                // (which is really just the inactive container for each messenger
3636
-                // showing inactive message types for that messenger)
3637
-                $mt_boxes[ $messenger . '_i_box' ]         = esc_html__('Inactive Message Types', 'event_espresso');
3638
-                $mt_template_args[ $messenger . '_i_box' ] = [
3639
-                    'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3640
-                    'inactive_message_types' => isset(
3641
-                        $this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive']
3642
-                    )
3643
-                        ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive'])
3644
-                        : '',
3645
-                    'hidden'                 => $active ? '' : ' hidden',
3646
-                    'hide_on_message'        => $hide_on_message,
3647
-                    'hide_off_message'       => $hide_off_message,
3648
-                    'messenger'              => $messenger,
3649
-                    'active'                 => $active,
3650
-                ];
3651
-            }
3652
-        }
3653
-
3654
-
3655
-        // register messenger metaboxes
3656
-        $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
3657
-        foreach ($m_boxes as $box => $label) {
3658
-            $callback_args = ['template_path' => $m_template_path, 'template_args' => $m_template_args[ $box ]];
3659
-            $msgr          = str_replace('_a_box', '', $box);
3660
-            $this->addMetaBox(
3661
-                'espresso_' . $msgr . '_settings',
3662
-                $label,
3663
-                function ($post, $metabox) {
3664
-                    EEH_Template::display_template(
3665
-                        $metabox['args']['template_path'],
3666
-                        $metabox['args']['template_args']
3667
-                    );
3668
-                },
3669
-                $this->_current_screen->id,
3670
-                'normal',
3671
-                'high',
3672
-                $callback_args
3673
-            );
3674
-        }
3675
-
3676
-        // register message type metaboxes
3677
-        $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
3678
-        foreach ($mt_boxes as $box => $label) {
3679
-            $callback_args = [
3680
-                'template_path' => $mt_template_path,
3681
-                'template_args' => $mt_template_args[ $box ],
3682
-            ];
3683
-            $mt            = str_replace('_i_box', '', $box);
3684
-            $this->addMetaBox(
3685
-                'espresso_' . $mt . '_inactive_mts',
3686
-                $label,
3687
-                function ($post, $metabox) {
3688
-                    EEH_Template::display_template(
3689
-                        $metabox['args']['template_path'],
3690
-                        $metabox['args']['template_args']
3691
-                    );
3692
-                },
3693
-                $this->_current_screen->id,
3694
-                'side',
3695
-                'high',
3696
-                $callback_args
3697
-            );
3698
-        }
3699
-
3700
-        // register metabox for global messages settings but only when on the main site.  On single site installs this
3701
-        // will always result in the metabox showing, on multisite installs the metabox will only show on the main site.
3702
-        if (is_main_site()) {
3703
-            $this->addMetaBox(
3704
-                'espresso_global_message_settings',
3705
-                esc_html__('Global Message Settings', 'event_espresso'),
3706
-                [$this, 'global_messages_settings_metabox_content'],
3707
-                $this->_current_screen->id,
3708
-                'normal',
3709
-                'low',
3710
-                []
3711
-            );
3712
-        }
3713
-    }
3714
-
3715
-
3716
-    /**
3717
-     *  This generates the content for the global messages settings metabox.
3718
-     *
3719
-     * @return void
3720
-     * @throws EE_Error
3721
-     * @throws InvalidArgumentException
3722
-     * @throws ReflectionException
3723
-     * @throws InvalidDataTypeException
3724
-     * @throws InvalidInterfaceException
3725
-     */
3726
-    public function global_messages_settings_metabox_content()
3727
-    {
3728
-        $form = $this->_generate_global_settings_form();
3729
-        // already escaped
3730
-        echo $form->form_open(
3731
-            $this->add_query_args_and_nonce(['action' => 'update_global_settings'], EE_MSG_ADMIN_URL),
3732
-            'POST'
3733
-        );
3734
-        echo $form->get_html();
3735
-        echo $form->form_close();
3736
-    }
3737
-
3738
-
3739
-    /**
3740
-     * This generates and returns the form object for the global messages settings.
3741
-     *
3742
-     * @return EE_Form_Section_Proper
3743
-     * @throws EE_Error
3744
-     * @throws InvalidArgumentException
3745
-     * @throws ReflectionException
3746
-     * @throws InvalidDataTypeException
3747
-     * @throws InvalidInterfaceException
3748
-     */
3749
-    protected function _generate_global_settings_form()
3750
-    {
3751
-        /** @var EE_Network_Core_Config $network_config */
3752
-        $network_config = EE_Registry::instance()->NET_CFG->core;
3753
-
3754
-        return new EE_Form_Section_Proper(
3755
-            [
3756
-                'name'            => 'global_messages_settings',
3757
-                'html_id'         => 'global_messages_settings',
3758
-                'html_class'      => 'form-table',
3759
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
3760
-                'subsections'     => apply_filters(
3761
-                    'FHEE__Messages_Admin_Page__global_messages_settings_metabox_content__form_subsections',
3762
-                    [
3763
-                        'do_messages_on_same_request' => new EE_Select_Input(
3764
-                            [
3765
-                                true  => esc_html__('On the same request', 'event_espresso'),
3766
-                                false => esc_html__('On a separate request', 'event_espresso'),
3767
-                            ],
3768
-                            [
3769
-                                'default'         => $network_config->do_messages_on_same_request,
3770
-                                'html_label_text' => esc_html__(
3771
-                                    'Generate and send all messages:',
3772
-                                    'event_espresso'
3773
-                                ),
3774
-                                'html_help_text'  => esc_html__(
3775
-                                    'By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system.  This makes things execute faster for people registering for your events.  However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.',
3776
-                                    'event_espresso'
3777
-                                ),
3778
-                            ]
3779
-                        ),
3780
-                        'delete_threshold'            => new EE_Select_Input(
3781
-                            [
3782
-                                0  => esc_html__('Forever', 'event_espresso'),
3783
-                                3  => esc_html__('3 Months', 'event_espresso'),
3784
-                                6  => esc_html__('6 Months', 'event_espresso'),
3785
-                                9  => esc_html__('9 Months', 'event_espresso'),
3786
-                                12 => esc_html__('12 Months', 'event_espresso'),
3787
-                                24 => esc_html__('24 Months', 'event_espresso'),
3788
-                                36 => esc_html__('36 Months', 'event_espresso'),
3789
-                            ],
3790
-                            [
3791
-                                'default'         => EE_Registry::instance()->CFG->messages->delete_threshold,
3792
-                                'html_label_text' => esc_html__('Cleanup of old messages:', 'event_espresso'),
3793
-                                'html_help_text'  => esc_html__(
3794
-                                    'You can control how long a record of processed messages is kept via this option.',
3795
-                                    'event_espresso'
3796
-                                ),
3797
-                            ]
3798
-                        ),
3799
-                        'update_settings'             => new EE_Submit_Input(
3800
-                            [
3801
-                                'default'         => esc_html__('Update', 'event_espresso'),
3802
-                                'html_label_text' => '&nbsp',
3803
-                            ]
3804
-                        ),
3805
-                    ]
3806
-                ),
3807
-            ]
3808
-        );
3809
-    }
3810
-
3811
-
3812
-    /**
3813
-     * This handles updating the global settings set on the admin page.
3814
-     *
3815
-     * @throws EE_Error
3816
-     * @throws InvalidDataTypeException
3817
-     * @throws InvalidInterfaceException
3818
-     * @throws InvalidArgumentException
3819
-     * @throws ReflectionException
3820
-     */
3821
-    protected function _update_global_settings()
3822
-    {
3823
-        /** @var EE_Network_Core_Config $network_config */
3824
-        $network_config  = EE_Registry::instance()->NET_CFG->core;
3825
-        $messages_config = EE_Registry::instance()->CFG->messages;
3826
-        $form            = $this->_generate_global_settings_form();
3827
-        if ($form->was_submitted()) {
3828
-            $form->receive_form_submission();
3829
-            if ($form->is_valid()) {
3830
-                $valid_data = $form->valid_data();
3831
-                foreach ($valid_data as $property => $value) {
3832
-                    $setter = 'set_' . $property;
3833
-                    if (method_exists($network_config, $setter)) {
3834
-                        $network_config->{$setter}($value);
3835
-                    } elseif (
3836
-                        property_exists($network_config, $property)
3837
-                        && $network_config->{$property} !== $value
3838
-                    ) {
3839
-                        $network_config->{$property} = $value;
3840
-                    } elseif (
3841
-                        property_exists($messages_config, $property)
3842
-                        && $messages_config->{$property} !== $value
3843
-                    ) {
3844
-                        $messages_config->{$property} = $value;
3845
-                    }
3846
-                }
3847
-                // only update if the form submission was valid!
3848
-                EE_Registry::instance()->NET_CFG->update_config(true, false);
3849
-                EE_Registry::instance()->CFG->update_espresso_config();
3850
-                EE_Error::overwrite_success();
3851
-                EE_Error::add_success(esc_html__('Global message settings were updated', 'event_espresso'));
3852
-            }
3853
-        }
3854
-        $this->_redirect_after_action(0, '', '', ['action' => 'settings'], true);
3855
-    }
3856
-
3857
-
3858
-    /**
3859
-     * this prepares the messenger tabs that can be dragged in and out of messenger boxes to activate/deactivate
3860
-     *
3861
-     * @param array $tab_array This is an array of message type tab details used to generate the tabs
3862
-     * @return string html formatted tabs
3863
-     * @throws DomainException
3864
-     */
3865
-    protected function _get_mt_tabs($tab_array)
3866
-    {
3867
-        $tab_array = (array) $tab_array;
3868
-        $template  = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
3869
-        $tabs      = '';
3870
-
3871
-        foreach ($tab_array as $tab) {
3872
-            $tabs .= EEH_Template::display_template($template, $tab, true);
3873
-        }
3874
-
3875
-        return $tabs;
3876
-    }
3877
-
3878
-
3879
-    /**
3880
-     * This prepares the content of the messenger meta box admin settings
3881
-     *
3882
-     * @param EE_messenger $messenger The messenger we're setting up content for
3883
-     * @return string html formatted content
3884
-     * @throws DomainException
3885
-     */
3886
-    protected function _get_messenger_box_content(EE_messenger $messenger)
3887
-    {
3888
-
3889
-        $fields                                         = $messenger->get_admin_settings_fields();
3890
-        $settings_template_args['template_form_fields'] = '';
3891
-
3892
-        // is $messenger active?
3893
-        $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name);
3894
-
3895
-
3896
-        if (! empty($fields)) {
3897
-            $existing_settings = $messenger->get_existing_admin_settings();
3898
-
3899
-            foreach ($fields as $fldname => $fldprops) {
3900
-                $field_id                         = $messenger->name . '-' . $fldname;
3901
-                $template_form_field[ $field_id ] = [
3902
-                    'name'       => 'messenger_settings[' . $field_id . ']',
3903
-                    'label'      => $fldprops['label'],
3904
-                    'input'      => $fldprops['field_type'],
3905
-                    'type'       => $fldprops['value_type'],
3906
-                    'required'   => $fldprops['required'],
3907
-                    'validation' => $fldprops['validation'],
3908
-                    'value'      => isset($existing_settings[ $field_id ])
3909
-                        ? $existing_settings[ $field_id ]
3910
-                        : $fldprops['default'],
3911
-                    'css_class'  => '',
3912
-                    'format'     => $fldprops['format'],
3913
-                ];
3914
-            }
3915
-
3916
-
3917
-            $settings_template_args['template_form_fields'] = ! empty($template_form_field)
3918
-                ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form')
3919
-                : '';
3920
-        }
3921
-
3922
-        // we also need some hidden fields
3923
-        $settings_template_args['hidden_fields'] = [
3924
-            'messenger_settings[messenger]' . $messenger->name => [
3925
-                'type'  => 'hidden',
3926
-                'value' => $messenger->name,
3927
-            ],
3928
-            'type' . $messenger->name                          => [
3929
-                'type'  => 'hidden',
3930
-                'value' => 'messenger',
3931
-            ],
3932
-        ];
3933
-
3934
-        // make sure any active message types that are existing are included in the hidden fields
3935
-        if (isset($this->_m_mt_settings['message_type_tabs'][ $messenger->name ]['active'])) {
3936
-            foreach ($this->_m_mt_settings['message_type_tabs'][ $messenger->name ]['active'] as $mt => $values) {
3937
-                $settings_template_args['hidden_fields'][ 'messenger_settings[message_types][' . $mt . ']' ] = [
3938
-                    'type'  => 'hidden',
3939
-                    'value' => $mt,
3940
-                ];
3941
-            }
3942
-        }
3943
-        $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3944
-            $settings_template_args['hidden_fields'],
3945
-            'array'
3946
-        );
3947
-        $active                                  =
3948
-            $this->_message_resource_manager->is_messenger_active($messenger->name);
3949
-
3950
-        $settings_template_args['messenger']           = $messenger->name;
3951
-        $settings_template_args['description']         = $messenger->description;
3952
-        $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
3953
-
3954
-
3955
-        $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active(
3956
-            $messenger->name
3957
-        )
3958
-            ? $settings_template_args['show_hide_edit_form']
3959
-            : ' hidden';
3960
-
3961
-        $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields'])
3962
-            ? ' hidden'
3963
-            : $settings_template_args['show_hide_edit_form'];
3964
-
3965
-
3966
-        $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
3967
-        $settings_template_args['nonce']         = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
3968
-        $settings_template_args['on_off_status'] = $active;
3969
-        $template                                = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
3970
-        return EEH_Template::display_template(
3971
-            $template,
3972
-            $settings_template_args,
3973
-            true
3974
-        );
3975
-    }
3976
-
3977
-
3978
-    /**
3979
-     * used by ajax on the messages settings page to activate|deactivate the messenger
3980
-     *
3981
-     * @throws DomainException
3982
-     * @throws EE_Error
3983
-     * @throws InvalidDataTypeException
3984
-     * @throws InvalidInterfaceException
3985
-     * @throws InvalidArgumentException
3986
-     * @throws ReflectionException
3987
-     */
3988
-    public function activate_messenger_toggle()
3989
-    {
3990
-        $success = true;
3991
-        $this->_prep_default_response_for_messenger_or_message_type_toggle();
3992
-        // let's check that we have required data
3993
-
3994
-        if (! $this->_active_messenger_name) {
3995
-            EE_Error::add_error(
3996
-                esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3997
-                __FILE__,
3998
-                __FUNCTION__,
3999
-                __LINE__
4000
-            );
4001
-            $success = false;
4002
-        }
4003
-
4004
-        // do a nonce check here since we're not arriving via a normal route
4005
-        $nonce     = $this->request->getRequestParam('activate_nonce', '');
4006
-        $nonce_ref = "activate_{$this->_active_messenger_name}_toggle_nonce";
4007
-
4008
-        $this->_verify_nonce($nonce, $nonce_ref);
4009
-
4010
-
4011
-        $status = $this->request->getRequestParam('status');
4012
-        if (! $status) {
4013
-            EE_Error::add_error(
4014
-                esc_html__(
4015
-                    'Messenger status needed to know whether activation or deactivation is happening. No status is given',
4016
-                    'event_espresso'
4017
-                ),
4018
-                __FILE__,
4019
-                __FUNCTION__,
4020
-                __LINE__
4021
-            );
4022
-            $success = false;
4023
-        }
4024
-
4025
-        // do check to verify we have a valid status.
4026
-        if ($status !== 'off' && $status !== 'on') {
4027
-            EE_Error::add_error(
4028
-                sprintf(
4029
-                    esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
4030
-                    $status
4031
-                ),
4032
-                __FILE__,
4033
-                __FUNCTION__,
4034
-                __LINE__
4035
-            );
4036
-            $success = false;
4037
-        }
4038
-
4039
-        if ($success) {
4040
-            // made it here?  Stop dawdling then!!
4041
-            $success = $status === 'off'
4042
-                ? $this->_deactivate_messenger($this->_active_messenger_name)
4043
-                : $this->_activate_messenger($this->_active_messenger_name);
4044
-        }
4045
-
4046
-        $this->_template_args['success'] = $success;
4047
-
4048
-        // no special instructions so let's just do the json return (which should automatically do all the special stuff).
4049
-        $this->_return_json();
4050
-    }
4051
-
4052
-
4053
-    /**
4054
-     * used by ajax from the messages settings page to activate|deactivate a message type
4055
-     *
4056
-     * @throws DomainException
4057
-     * @throws EE_Error
4058
-     * @throws ReflectionException
4059
-     * @throws InvalidDataTypeException
4060
-     * @throws InvalidInterfaceException
4061
-     * @throws InvalidArgumentException
4062
-     */
4063
-    public function activate_mt_toggle()
4064
-    {
4065
-        $success = true;
4066
-        $this->_prep_default_response_for_messenger_or_message_type_toggle();
4067
-
4068
-        // let's make sure we have the necessary data
4069
-        if (! $this->_active_message_type_name) {
4070
-            EE_Error::add_error(
4071
-                esc_html__('Message Type name needed to toggle activation. None given', 'event_espresso'),
4072
-                __FILE__,
4073
-                __FUNCTION__,
4074
-                __LINE__
4075
-            );
4076
-            $success = false;
4077
-        }
4078
-
4079
-        if (! $this->_active_messenger_name) {
4080
-            EE_Error::add_error(
4081
-                esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
4082
-                __FILE__,
4083
-                __FUNCTION__,
4084
-                __LINE__
4085
-            );
4086
-            $success = false;
4087
-        }
4088
-
4089
-        $status = $this->request->getRequestParam('status');
4090
-        if (! $status) {
4091
-            EE_Error::add_error(
4092
-                esc_html__(
4093
-                    'Messenger status needed to know whether activation or deactivation is happening. No status is given',
4094
-                    'event_espresso'
4095
-                ),
4096
-                __FILE__,
4097
-                __FUNCTION__,
4098
-                __LINE__
4099
-            );
4100
-            $success = false;
4101
-        }
4102
-
4103
-
4104
-        // do check to verify we have a valid status.
4105
-        if ($status !== 'activate' && $status !== 'deactivate') {
4106
-            EE_Error::add_error(
4107
-                sprintf(
4108
-                    esc_html__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'),
4109
-                    $status
4110
-                ),
4111
-                __FILE__,
4112
-                __FUNCTION__,
4113
-                __LINE__
4114
-            );
4115
-            $success = false;
4116
-        }
4117
-
4118
-
4119
-        // do a nonce check here since we're not arriving via a normal route
4120
-        $nonce = $this->request->getRequestParam('mt_nonce', '');
4121
-        $this->_verify_nonce($nonce, "{$this->_active_message_type_name}_nonce");
4122
-
4123
-        if ($success) {
4124
-            // made it here? um, what are you waiting for then?
4125
-            $success = $status === 'deactivate'
4126
-                ? $this->_deactivate_message_type_for_messenger(
4127
-                    $this->_active_messenger_name,
4128
-                    $this->_active_message_type_name
4129
-                )
4130
-                : $this->_activate_message_type_for_messenger(
4131
-                    $this->_active_messenger_name,
4132
-                    $this->_active_message_type_name
4133
-                );
4134
-        }
4135
-
4136
-        $this->_template_args['success'] = $success;
4137
-        $this->_return_json();
4138
-    }
4139
-
4140
-
4141
-    /**
4142
-     * Takes care of processing activating a messenger and preparing the appropriate response.
4143
-     *
4144
-     * @param string $messenger_name The name of the messenger being activated
4145
-     * @return bool
4146
-     * @throws DomainException
4147
-     * @throws EE_Error
4148
-     * @throws InvalidArgumentException
4149
-     * @throws ReflectionException
4150
-     * @throws InvalidDataTypeException
4151
-     * @throws InvalidInterfaceException
4152
-     */
4153
-    protected function _activate_messenger($messenger_name)
4154
-    {
4155
-        $active_messenger          = $this->_message_resource_manager->get_messenger($messenger_name);
4156
-        $message_types_to_activate = $active_messenger instanceof EE_Messenger
4157
-            ? $active_messenger->get_default_message_types()
4158
-            : [];
4159
-
4160
-        // ensure is active
4161
-        $this->_message_resource_manager->activate_messenger($active_messenger, $message_types_to_activate);
4162
-
4163
-        // set response_data for reload
4164
-        foreach ($message_types_to_activate as $message_type_name) {
4165
-            $message_type = $this->_message_resource_manager->get_message_type($message_type_name);
4166
-            if (
4167
-                $this->_message_resource_manager->is_message_type_active_for_messenger(
4168
-                    $messenger_name,
4169
-                    $message_type_name
4170
-                )
4171
-                && $message_type instanceof EE_message_type
4172
-            ) {
4173
-                $this->_template_args['data']['active_mts'][] = $message_type_name;
4174
-                if ($message_type->get_admin_settings_fields()) {
4175
-                    $this->_template_args['data']['mt_reload'][] = $message_type_name;
4176
-                }
4177
-            }
4178
-        }
4179
-
4180
-        // add success message for activating messenger
4181
-        return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger);
4182
-    }
4183
-
4184
-
4185
-    /**
4186
-     * Takes care of processing deactivating a messenger and preparing the appropriate response.
4187
-     *
4188
-     * @param string $messenger_name The name of the messenger being activated
4189
-     * @return bool
4190
-     * @throws DomainException
4191
-     * @throws EE_Error
4192
-     * @throws InvalidArgumentException
4193
-     * @throws ReflectionException
4194
-     * @throws InvalidDataTypeException
4195
-     * @throws InvalidInterfaceException
4196
-     */
4197
-    protected function _deactivate_messenger($messenger_name)
4198
-    {
4199
-        $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
4200
-        $this->_message_resource_manager->deactivate_messenger($messenger_name);
4201
-
4202
-        return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger);
4203
-    }
4204
-
4205
-
4206
-    /**
4207
-     * Takes care of processing activating a message type for a messenger and preparing the appropriate response.
4208
-     *
4209
-     * @param string $messenger_name    The name of the messenger the message type is being activated for.
4210
-     * @param string $message_type_name The name of the message type being activated for the messenger
4211
-     * @return bool
4212
-     * @throws DomainException
4213
-     * @throws EE_Error
4214
-     * @throws InvalidArgumentException
4215
-     * @throws ReflectionException
4216
-     * @throws InvalidDataTypeException
4217
-     * @throws InvalidInterfaceException
4218
-     */
4219
-    protected function _activate_message_type_for_messenger($messenger_name, $message_type_name)
4220
-    {
4221
-        $active_messenger         = $this->_message_resource_manager->get_messenger($messenger_name);
4222
-        $message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name);
4223
-
4224
-        // ensure is active
4225
-        $this->_message_resource_manager->activate_messenger($active_messenger, $message_type_name);
4226
-
4227
-        // set response for load
4228
-        if (
4229
-            $this->_message_resource_manager->is_message_type_active_for_messenger(
4230
-                $messenger_name,
4231
-                $message_type_name
4232
-            )
4233
-        ) {
4234
-            $this->_template_args['data']['active_mts'][] = $message_type_name;
4235
-            if ($message_type_to_activate->get_admin_settings_fields()) {
4236
-                $this->_template_args['data']['mt_reload'][] = $message_type_name;
4237
-            }
4238
-        }
4239
-
4240
-        return $this->_setup_response_message_for_activating_messenger_with_message_types(
4241
-            $active_messenger,
4242
-            $message_type_to_activate
4243
-        );
4244
-    }
4245
-
4246
-
4247
-    /**
4248
-     * Takes care of processing deactivating a message type for a messenger and preparing the appropriate response.
4249
-     *
4250
-     * @param string $messenger_name    The name of the messenger the message type is being deactivated for.
4251
-     * @param string $message_type_name The name of the message type being deactivated for the messenger
4252
-     * @return bool
4253
-     * @throws DomainException
4254
-     * @throws EE_Error
4255
-     * @throws InvalidArgumentException
4256
-     * @throws ReflectionException
4257
-     * @throws InvalidDataTypeException
4258
-     * @throws InvalidInterfaceException
4259
-     */
4260
-    protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name)
4261
-    {
4262
-        $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
4263
-        /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't */
4264
-        $message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name);
4265
-        $this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name);
4266
-
4267
-        return $this->_setup_response_message_for_deactivating_messenger_with_message_types(
4268
-            $active_messenger,
4269
-            $message_type_to_deactivate
4270
-        );
4271
-    }
4272
-
4273
-
4274
-    /**
4275
-     * This just initializes the defaults for activating messenger and message type responses.
4276
-     */
4277
-    protected function _prep_default_response_for_messenger_or_message_type_toggle()
4278
-    {
4279
-        $this->_template_args['data']['active_mts'] = [];
4280
-        $this->_template_args['data']['mt_reload']  = [];
4281
-    }
4282
-
4283
-
4284
-    /**
4285
-     * Setup appropriate response for activating a messenger and/or message types
4286
-     *
4287
-     * @param EE_messenger         $messenger
4288
-     * @param EE_message_type|null $message_type
4289
-     * @return bool
4290
-     * @throws DomainException
4291
-     * @throws EE_Error
4292
-     * @throws InvalidArgumentException
4293
-     * @throws ReflectionException
4294
-     * @throws InvalidDataTypeException
4295
-     * @throws InvalidInterfaceException
4296
-     */
4297
-    protected function _setup_response_message_for_activating_messenger_with_message_types(
4298
-        $messenger,
4299
-        EE_Message_Type $message_type = null
4300
-    ) {
4301
-        // if $messenger isn't a valid messenger object then get out.
4302
-        if (! $messenger instanceof EE_Messenger) {
4303
-            EE_Error::add_error(
4304
-                esc_html__('The messenger being activated is not a valid messenger', 'event_espresso'),
4305
-                __FILE__,
4306
-                __FUNCTION__,
4307
-                __LINE__
4308
-            );
4309
-            return false;
4310
-        }
4311
-        // activated
4312
-        if ($this->_template_args['data']['active_mts']) {
4313
-            EE_Error::overwrite_success();
4314
-            // activated a message type with the messenger
4315
-            if ($message_type instanceof EE_message_type) {
4316
-                EE_Error::add_success(
4317
-                    sprintf(
4318
-                        esc_html__(
4319
-                            '%s message type has been successfully activated with the %s messenger',
4320
-                            'event_espresso'
4321
-                        ),
4322
-                        ucwords($message_type->label['singular']),
4323
-                        ucwords($messenger->label['singular'])
4324
-                    )
4325
-                );
4326
-
4327
-                // if message type was invoice then let's make sure we activate the invoice payment method.
4328
-                if ($message_type->name === 'invoice') {
4329
-                    EE_Registry::instance()->load_lib('Payment_Method_Manager');
4330
-                    $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
4331
-                    if ($pm instanceof EE_Payment_Method) {
4332
-                        EE_Error::add_attention(
4333
-                            esc_html__(
4334
-                                'Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.',
4335
-                                'event_espresso'
4336
-                            )
4337
-                        );
4338
-                    }
4339
-                }
4340
-                // just toggles the entire messenger
4341
-            } else {
4342
-                EE_Error::add_success(
4343
-                    sprintf(
4344
-                        esc_html__('%s messenger has been successfully activated', 'event_espresso'),
4345
-                        ucwords($messenger->label['singular'])
4346
-                    )
4347
-                );
4348
-            }
4349
-
4350
-            return true;
4351
-
4352
-            // possible error condition. This will happen when our active_mts data is empty because it is validated for actual active
4353
-            // message types after the activation process.  However its possible some messengers don't HAVE any default_message_types
4354
-            // in which case we just give a success message for the messenger being successfully activated.
4355
-        } else {
4356
-            if (! $messenger->get_default_message_types()) {
4357
-                // messenger doesn't have any default message types so still a success.
4358
-                EE_Error::add_success(
4359
-                    sprintf(
4360
-                        esc_html__('%s messenger was successfully activated.', 'event_espresso'),
4361
-                        ucwords($messenger->label['singular'])
4362
-                    )
4363
-                );
4364
-
4365
-                return true;
4366
-            } else {
4367
-                EE_Error::add_error(
4368
-                    $message_type instanceof EE_message_type
4369
-                    ? sprintf(
4370
-                        esc_html__(
4371
-                            '%s message type was not successfully activated with the %s messenger',
4372
-                            'event_espresso'
4373
-                        ),
4374
-                        ucwords($message_type->label['singular']),
4375
-                        ucwords($messenger->label['singular'])
4376
-                    )
4377
-                    : sprintf(
4378
-                        esc_html__('%s messenger was not successfully activated', 'event_espresso'),
4379
-                        ucwords($messenger->label['singular'])
4380
-                    ),
4381
-                    __FILE__,
4382
-                    __FUNCTION__,
4383
-                    __LINE__
4384
-                );
4385
-
4386
-                return false;
4387
-            }
4388
-        }
4389
-    }
4390
-
4391
-
4392
-    /**
4393
-     * This sets up the appropriate response for deactivating a messenger and/or message type.
4394
-     *
4395
-     * @param EE_messenger         $messenger
4396
-     * @param EE_message_type|null $message_type
4397
-     * @return bool
4398
-     * @throws DomainException
4399
-     * @throws EE_Error
4400
-     * @throws InvalidArgumentException
4401
-     * @throws ReflectionException
4402
-     * @throws InvalidDataTypeException
4403
-     * @throws InvalidInterfaceException
4404
-     */
4405
-    protected function _setup_response_message_for_deactivating_messenger_with_message_types(
4406
-        $messenger,
4407
-        EE_message_type $message_type = null
4408
-    ) {
4409
-        EE_Error::overwrite_success();
4410
-
4411
-        // if $messenger isn't a valid messenger object then get out.
4412
-        if (! $messenger instanceof EE_Messenger) {
4413
-            EE_Error::add_error(
4414
-                esc_html__('The messenger being deactivated is not a valid messenger', 'event_espresso'),
4415
-                __FILE__,
4416
-                __FUNCTION__,
4417
-                __LINE__
4418
-            );
4419
-
4420
-            return false;
4421
-        }
4422
-
4423
-        if ($message_type instanceof EE_message_type) {
4424
-            $message_type_name = $message_type->name;
4425
-            EE_Error::add_success(
4426
-                sprintf(
4427
-                    esc_html__(
4428
-                        '%s message type has been successfully deactivated for the %s messenger.',
4429
-                        'event_espresso'
4430
-                    ),
4431
-                    ucwords($message_type->label['singular']),
4432
-                    ucwords($messenger->label['singular'])
4433
-                )
4434
-            );
4435
-        } else {
4436
-            $message_type_name = '';
4437
-            EE_Error::add_success(
4438
-                sprintf(
4439
-                    esc_html__('%s messenger has been successfully deactivated.', 'event_espresso'),
4440
-                    ucwords($messenger->label['singular'])
4441
-                )
4442
-            );
4443
-        }
4444
-
4445
-        // if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
4446
-        if (
4447
-            $messenger->name === 'html'
4448
-            && (
4449
-                is_null($message_type)
4450
-                || $message_type_name === 'invoice'
4451
-            )
4452
-        ) {
4453
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
4454
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
4455
-            if ($count_updated > 0) {
4456
-                $msg = $message_type_name === 'invoice'
4457
-                    ? esc_html__(
4458
-                        'Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.',
4459
-                        'event_espresso'
4460
-                    )
4461
-                    : esc_html__(
4462
-                        'Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.',
4463
-                        'event_espresso'
4464
-                    );
4465
-                EE_Error::add_attention($msg);
4466
-            }
4467
-        }
4468
-
4469
-        return true;
4470
-    }
4471
-
4472
-
4473
-    /**
4474
-     * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax)
4475
-     *
4476
-     * @throws DomainException
4477
-     * @throws EE_Error
4478
-     * @throws EE_Error
4479
-     */
4480
-    public function update_mt_form()
4481
-    {
4482
-        if (! $this->_active_messenger_name || ! $this->_active_message_type_name) {
4483
-            EE_Error::add_error(
4484
-                esc_html__('Require message type or messenger to send an updated form', 'event_espresso'),
4485
-                __FILE__,
4486
-                __FUNCTION__,
4487
-                __LINE__
4488
-            );
4489
-            $this->_return_json();
4490
-        }
4491
-
4492
-        $message_types = $this->get_installed_message_types();
4493
-        $message_type  = $message_types[ $this->_active_message_type_name ];
4494
-        $messenger     = $this->_message_resource_manager->get_active_messenger($this->_active_messenger_name);
4495
-        $content       = $this->_message_type_settings_content($message_type, $messenger, true);
4496
-
4497
-        $this->_template_args['success'] = true;
4498
-        $this->_template_args['content'] = $content;
4499
-        $this->_return_json();
4500
-    }
4501
-
4502
-
4503
-    /**
4504
-     * this handles saving the settings for a messenger or message type
4505
-     *
4506
-     * @throws EE_Error
4507
-     * @throws EE_Error
4508
-     */
4509
-    public function save_settings()
4510
-    {
4511
-        $type = $this->request->getRequestParam('type');
4512
-        if (! $type) {
4513
-            EE_Error::add_error(
4514
-                esc_html__(
4515
-                    'Cannot save settings because type is unknown (messenger settings or message type settings?)',
4516
-                    'event_espresso'
4517
-                ),
4518
-                __FILE__,
4519
-                __FUNCTION__,
4520
-                __LINE__
4521
-            );
4522
-            $this->_template_args['error'] = true;
4523
-            $this->_return_json();
4524
-        }
4525
-
4526
-
4527
-        if ($type === 'messenger') {
4528
-            // this should be an array.
4529
-            $settings  = $this->request->getRequestParam('messenger_settings', [], 'string', true);
4530
-            $messenger = $settings['messenger'];
4531
-            // remove messenger and message_types from settings array
4532
-            unset($settings['messenger'], $settings['message_types']);
4533
-            $this->_message_resource_manager->add_settings_for_messenger($messenger, $settings);
4534
-        } elseif ($type === 'message_type') {
4535
-            $settings     = $this->request->getRequestParam('message_type_settings', [], 'string', true);
4536
-            $messenger    = $settings['messenger'];
4537
-            $message_type = $settings['message_type'];
4538
-            // remove messenger and message_types from settings array
4539
-            unset($settings['messenger'], $settings['message_types']);
4540
-            $this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings);
4541
-        }
4542
-
4543
-        // okay we should have the data all setup.  Now we just update!
4544
-        $success = $this->_message_resource_manager->update_active_messengers_option();
4545
-
4546
-        if ($success) {
4547
-            EE_Error::add_success(esc_html__('Settings updated', 'event_espresso'));
4548
-        } else {
4549
-            EE_Error::add_error(
4550
-                esc_html__('Settings did not get updated', 'event_espresso'),
4551
-                __FILE__,
4552
-                __FUNCTION__,
4553
-                __LINE__
4554
-            );
4555
-        }
4556
-
4557
-        $this->_template_args['success'] = $success;
4558
-        $this->_return_json();
4559
-    }
4560
-
4561
-
4562
-
4563
-
4564
-    /**  EE MESSAGE PROCESSING ACTIONS **/
4565
-
4566
-
4567
-    /**
4568
-     * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete
4569
-     * However, this does not send immediately, it just queues for sending.
4570
-     *
4571
-     * @throws EE_Error
4572
-     * @throws InvalidDataTypeException
4573
-     * @throws InvalidInterfaceException
4574
-     * @throws InvalidArgumentException
4575
-     * @throws ReflectionException
4576
-     * @since 4.9.0
4577
-     */
4578
-    protected function _generate_now()
4579
-    {
4580
-        EED_Messages::generate_now($this->_get_msg_ids_from_request());
4581
-        $this->_redirect_after_action(false, '', '', [], true);
4582
-    }
4583
-
4584
-
4585
-    /**
4586
-     * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that
4587
-     * are EEM_Message::status_resend or EEM_Message::status_idle
4588
-     *
4589
-     * @throws EE_Error
4590
-     * @throws InvalidDataTypeException
4591
-     * @throws InvalidInterfaceException
4592
-     * @throws InvalidArgumentException
4593
-     * @throws ReflectionException
4594
-     * @since 4.9.0
4595
-     */
4596
-    protected function _generate_and_send_now()
4597
-    {
4598
-        EED_Messages::generate_and_send_now($this->_get_msg_ids_from_request());
4599
-        $this->_redirect_after_action(false, '', '', [], true);
4600
-    }
4601
-
4602
-
4603
-    /**
4604
-     * This queues any EEM_Message::status_sent EE_Message ids in the request for resending.
4605
-     *
4606
-     * @throws EE_Error
4607
-     * @throws InvalidDataTypeException
4608
-     * @throws InvalidInterfaceException
4609
-     * @throws InvalidArgumentException
4610
-     * @throws ReflectionException
4611
-     * @since 4.9.0
4612
-     */
4613
-    protected function _queue_for_resending()
4614
-    {
4615
-        EED_Messages::queue_for_resending($this->_get_msg_ids_from_request());
4616
-        $this->_redirect_after_action(false, '', '', [], true);
4617
-    }
4618
-
4619
-
4620
-    /**
4621
-     *  This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue
4622
-     *
4623
-     * @throws EE_Error
4624
-     * @throws InvalidDataTypeException
4625
-     * @throws InvalidInterfaceException
4626
-     * @throws InvalidArgumentException
4627
-     * @throws ReflectionException
4628
-     * @since 4.9.0
4629
-     */
4630
-    protected function _send_now()
4631
-    {
4632
-        EED_Messages::send_now($this->_get_msg_ids_from_request());
4633
-        $this->_redirect_after_action(false, '', '', [], true);
4634
-    }
4635
-
4636
-
4637
-    /**
4638
-     * Deletes EE_messages for IDs in the request.
4639
-     *
4640
-     * @throws EE_Error
4641
-     * @throws InvalidDataTypeException
4642
-     * @throws InvalidInterfaceException
4643
-     * @throws InvalidArgumentException
4644
-     * @since 4.9.0
4645
-     */
4646
-    protected function _delete_ee_messages()
4647
-    {
4648
-        $MSG_IDs       = $this->_get_msg_ids_from_request();
4649
-        $deleted_count = 0;
4650
-        foreach ($MSG_IDs as $MSG_ID) {
4651
-            if ($this->getMsgModel()->delete_by_ID($MSG_ID)) {
4652
-                $deleted_count++;
4653
-            }
4654
-        }
4655
-        if ($deleted_count) {
4656
-            EE_Error::add_success(
4657
-                esc_html(
4658
-                    _n(
4659
-                        'Message successfully deleted',
4660
-                        'Messages successfully deleted',
4661
-                        $deleted_count,
4662
-                        'event_espresso'
4663
-                    )
4664
-                )
4665
-            );
4666
-        } else {
4667
-            EE_Error::add_error(
4668
-                _n('The message was not deleted.', 'The messages were not deleted', count($MSG_IDs), 'event_espresso'),
4669
-                __FILE__,
4670
-                __FUNCTION__,
4671
-                __LINE__
4672
-            );
4673
-        }
4674
-        $this->_redirect_after_action(false, '', '', [], true);
4675
-    }
4676
-
4677
-
4678
-    /**
4679
-     *  This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present.
4680
-     *
4681
-     * @return array
4682
-     * @since 4.9.0
4683
-     */
4684
-    protected function _get_msg_ids_from_request()
4685
-    {
4686
-        $MSG_IDs = $this->request->getRequestParam('MSG_ID', [], 'string', true);
4687
-        if (empty($MSG_IDs)) {
4688
-            return [];
4689
-        }
4690
-        // if 'MSG_ID' was just a single ID (not an array)
4691
-        // then $MSG_IDs will be something like [123] so $MSG_IDs[0] should be 123
4692
-        // otherwise, $MSG_IDs was already an array where message IDs were used as the keys
4693
-        return count($MSG_IDs) === 1 && isset($MSG_IDs[0])
4694
-            ? $MSG_IDs
4695
-            : array_keys($MSG_IDs);
4696
-    }
2707
+	}
2708
+
2709
+
2710
+	/**
2711
+	 * @param bool $new
2712
+	 * @throws EE_Error
2713
+	 * @throws ReflectionException
2714
+	 */
2715
+	protected function _insert_or_update_message_template($new = false)
2716
+	{
2717
+		$form_data    = $this->getMessageTemplateFormData();
2718
+		$GRP_ID       = $form_data['GRP_ID'];
2719
+		$messenger    = $form_data['MTP_messenger'];
2720
+		$message_type = $form_data['MTP_message_type'];
2721
+		$context      = $form_data['MTP_context'];
2722
+
2723
+		// if this is "new" then we need to generate the default contexts
2724
+		// for the selected messenger/message_type for user to edit.
2725
+		[$success, $query_args] = $new
2726
+			? $this->generateNewTemplates($GRP_ID, $messenger, $message_type)
2727
+			: $this->updateExistingTemplates($GRP_ID, $messenger, $message_type, $context, $form_data);
2728
+
2729
+		$success     = $success ? 1 : 0;
2730
+		$action_desc = $new ? 'created' : 'updated';
2731
+		$item_desc   = $this->generateUpdateDescription($messenger, $message_type, $context);
2732
+		$override    = $this->performTestSendAfterUpdate($messenger, $message_type, $context);
2733
+
2734
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2735
+	}
2736
+
2737
+
2738
+	/**
2739
+	 * retrieve and sanitize form data
2740
+	 *
2741
+	 * @return array
2742
+	 * @since 4.10.29.p
2743
+	 */
2744
+	protected function getMessageTemplateFormData()
2745
+	{
2746
+		return [
2747
+			'GRP_ID'           => $this->request->getRequestParam('GRP_ID', 0, 'int'),
2748
+			'MTP_context'      => strtolower($this->request->getRequestParam('MTP_context', '')),
2749
+			'MTP_messenger'    => strtolower($this->request->getRequestParam('MTP_messenger', '')),
2750
+			'MTP_message_type' => strtolower($this->request->getRequestParam('MTP_message_type', '')),
2751
+			'MTP_user_id'      => $this->request->getRequestParam('MTP_user_id', 0, 'int'),
2752
+			'MTP_is_global'    => $this->request->getRequestParam('MTP_is_global', 0, 'int'),
2753
+			'MTP_is_override'  => $this->request->getRequestParam('MTP_is_override', 0, 'int'),
2754
+			'MTP_deleted'      => $this->request->getRequestParam('MTP_deleted', 0, 'int'),
2755
+			'MTP_is_active'    => $this->request->getRequestParam('MTP_is_active', 0, 'int'),
2756
+		];
2757
+	}
2758
+
2759
+
2760
+	/**
2761
+	 * @param int    $GRP_ID
2762
+	 * @param string $messenger
2763
+	 * @param string $message_type
2764
+	 * @return array no return on AJAX requests
2765
+	 * @throws EE_Error
2766
+	 * @throws ReflectionException
2767
+	 * @since 4.10.29.p
2768
+	 */
2769
+	private function generateNewTemplates($GRP_ID, $messenger, $message_type)
2770
+	{
2771
+		$new_templates = $this->_generate_new_templates($messenger, [$message_type], $GRP_ID);
2772
+		$success       = ! empty($new_templates);
2773
+
2774
+		// we return things differently if doing ajax
2775
+		if ($this->request->isAjax()) {
2776
+			$this->_template_args['success'] = $success;
2777
+			$this->_template_args['error']   = ! $success;
2778
+			$this->_template_args['content'] = '';
2779
+			$this->_template_args['data']    = [
2780
+				'grpID'        => $new_templates['GRP_ID'],
2781
+				'templateName' => $new_templates['template_name'],
2782
+			];
2783
+			if ($success) {
2784
+				EE_Error::overwrite_success();
2785
+				EE_Error::add_success(
2786
+					esc_html__(
2787
+						'The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.',
2788
+						'event_espresso'
2789
+					)
2790
+				);
2791
+			}
2792
+			$this->_return_json();
2793
+		}
2794
+		return [
2795
+			$success,
2796
+			// 'query_args'
2797
+			[
2798
+				'id'      => $new_templates['GRP_ID'],
2799
+				'context' => $new_templates['MTP_context'],
2800
+				'action'  => 'edit_message_template',
2801
+			],
2802
+		];
2803
+	}
2804
+
2805
+
2806
+	/**
2807
+	 * @param int    $GRP_ID
2808
+	 * @param string $messenger
2809
+	 * @param string $message_type
2810
+	 * @param string $context
2811
+	 * @param array  $form_data
2812
+	 * @return array
2813
+	 * @throws EE_Error
2814
+	 * @since 4.10.29.p
2815
+	 */
2816
+	private function updateExistingTemplates(
2817
+		$GRP_ID,
2818
+		$messenger,
2819
+		$message_type,
2820
+		$context,
2821
+		array $form_data
2822
+	) {
2823
+		$success         = false;
2824
+		$template_fields = $this->getTemplateFields();
2825
+		if ($template_fields) {
2826
+			// if field data is valid, then success will be true
2827
+			$success = $this->validateTemplateFields(
2828
+				$messenger,
2829
+				$message_type,
2830
+				$context,
2831
+				$template_fields
2832
+			);
2833
+			if ($success) {
2834
+				$field_data = [];
2835
+				foreach ($template_fields as $template_field => $content) {
2836
+					// combine top-level form data with content for this field
2837
+					$field_data = $this->getTemplateFieldFormData($content, $form_data);
2838
+					$success    = $this->updateMessageTemplates($template_field, $field_data) ? $success : false;
2839
+				}
2840
+				// we can use the last set_column_values for the MTPG update
2841
+				// (because its the same for all of these specific MTPs)
2842
+				$success = $this->updateMessageTemplateGroup($field_data) ? $success : false;
2843
+			}
2844
+		}
2845
+
2846
+		return [
2847
+			$success,
2848
+			// 'query_args'
2849
+			[
2850
+				'id'      => $GRP_ID,
2851
+				'context' => $context,
2852
+				'action'  => 'edit_message_template',
2853
+			],
2854
+		];
2855
+	}
2856
+
2857
+
2858
+	/**
2859
+	 * @return array
2860
+	 * @since 4.10.29.p
2861
+	 */
2862
+	private function getTemplateFields()
2863
+	{
2864
+		$template_fields = $this->request->getRequestParam('MTP_template_fields', null, 'html', true);
2865
+		if (empty($template_fields)) {
2866
+			EE_Error::add_error(
2867
+				esc_html__(
2868
+					'There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.',
2869
+					'event_espresso'
2870
+				),
2871
+				__FILE__,
2872
+				__FUNCTION__,
2873
+				__LINE__
2874
+			);
2875
+			return null;
2876
+		}
2877
+		// messages content is expected to be escaped
2878
+		return EEH_Array::addSlashesRecursively($template_fields);
2879
+	}
2880
+
2881
+
2882
+	/**
2883
+	 * @param string $messenger
2884
+	 * @param string $message_type
2885
+	 * @param string $context
2886
+	 * @param array  $template_fields
2887
+	 * @return bool
2888
+	 * @throws EE_Error
2889
+	 * @since   4.10.29.p
2890
+	 */
2891
+	private function validateTemplateFields(
2892
+		$messenger,
2893
+		$message_type,
2894
+		$context,
2895
+		array $template_fields
2896
+	) {
2897
+		// first validate all fields!
2898
+		// this filter allows client code to add its own validation to the template fields as well.
2899
+		// returning an empty array means everything passed validation.
2900
+		// errors in validation should be represented in an array with the following shape:
2901
+		// array(
2902
+		//   'fieldname' => array(
2903
+		//          'msg' => 'error message'
2904
+		//          'value' => 'value for field producing error'
2905
+		// )
2906
+		$custom_validation = (array) apply_filters(
2907
+			'FHEE__Messages_Admin_Page___insert_or_update_message_template__validates',
2908
+			[],
2909
+			$template_fields,
2910
+			$context,
2911
+			$messenger,
2912
+			$message_type
2913
+		);
2914
+
2915
+		$system_validation = $this->getMtgModel()->validate(
2916
+			$template_fields,
2917
+			$context,
2918
+			$messenger,
2919
+			$message_type
2920
+		);
2921
+
2922
+		$system_validation = ! is_array($system_validation) && $system_validation ? [] : $system_validation;
2923
+		$validates         = array_merge($custom_validation, $system_validation);
2924
+
2925
+		// if $validate returned error messages (i.e. is_array()) then we need to process them and setup an
2926
+		// appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.
2927
+		//  WE need to make sure there is no actual error messages in validates.
2928
+		if (empty($validates)) {
2929
+			return true;
2930
+		}
2931
+
2932
+		// add the transient so when the form loads we know which fields to highlight
2933
+		$this->_add_transient('edit_message_template', $validates);
2934
+		// setup notices
2935
+		foreach ($validates as $error) {
2936
+			if (isset($error['msg'])) {
2937
+				EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
2938
+			}
2939
+		}
2940
+		return false;
2941
+	}
2942
+
2943
+
2944
+	/**
2945
+	 * @param array $field_data
2946
+	 * @param array $form_data
2947
+	 * @return array
2948
+	 * @since   4.10.29.p
2949
+	 */
2950
+	private function getTemplateFieldFormData(array $field_data, array $form_data)
2951
+	{
2952
+		return $form_data + [
2953
+				'MTP_ID'             => $field_data['MTP_ID'],
2954
+				'MTP_template_field' => $field_data['name'],
2955
+				// if they aren't allowed to use all JS, restrict them to standard allowed post tags
2956
+				'MTP_content'        => ! current_user_can('unfiltered_html')
2957
+					? $this->sanitizeMessageTemplateContent($field_data['content'])
2958
+					: $field_data['content'],
2959
+			];
2960
+	}
2961
+
2962
+
2963
+	/**
2964
+	 * @param string $template_field
2965
+	 * @param array  $form_data
2966
+	 * @return bool
2967
+	 * @throws EE_Error
2968
+	 * @since 4.10.29.p
2969
+	 */
2970
+	private function updateMessageTemplates($template_field, array $form_data)
2971
+	{
2972
+		$MTP_ID                  = $form_data['MTP_ID'];
2973
+		$message_template_fields = [
2974
+			'GRP_ID'             => $form_data['GRP_ID'],
2975
+			'MTP_template_field' => $form_data['MTP_template_field'],
2976
+			'MTP_context'        => $form_data['MTP_context'],
2977
+			'MTP_content'        => $form_data['MTP_content'],
2978
+		];
2979
+
2980
+		$hasMtpID = ! empty($MTP_ID);
2981
+		// if we have a MTP_ID for this field then update it, otherwise insert.
2982
+		// this has already been through the template field validator and sanitized, so it will be
2983
+		// safe to insert this field.  Why insert?  This typically happens when we introduce a new
2984
+		// message template field in a messenger/message type and existing users don't have the
2985
+		// default setup for it.
2986
+		// @link https://events.codebasehq.com/projects/event-espresso/tickets/9465
2987
+		$updated = $hasMtpID
2988
+			? $this->getMtpModel()->update($message_template_fields, [['MTP_ID' => $MTP_ID]])
2989
+			: $this->getMtpModel()->insert($message_template_fields);
2990
+
2991
+		$insert_failed = ! $hasMtpID && ! $updated;
2992
+		// updates will return 0 if the field was not changed (ie: no changes = nothing actually updated)
2993
+		// but we won't consider that a problem, but if it returns false, then something went BOOM!
2994
+		$update_failed = $hasMtpID && $updated === false;
2995
+
2996
+		if ($insert_failed || $update_failed) {
2997
+			EE_Error::add_error(
2998
+				sprintf(
2999
+					esc_html__('%s field was NOT updated for some reason', 'event_espresso'),
3000
+					$template_field
3001
+				),
3002
+				__FILE__,
3003
+				__FUNCTION__,
3004
+				__LINE__
3005
+			);
3006
+			return false;
3007
+		}
3008
+		return true;
3009
+	}
3010
+
3011
+
3012
+	/**
3013
+	 * @param array $form_data
3014
+	 * @return bool
3015
+	 * @throws EE_Error
3016
+	 * @since 4.10.29.p
3017
+	 */
3018
+	private function updateMessageTemplateGroup(array $form_data)
3019
+	{
3020
+		$GRP_ID  = $form_data['GRP_ID'];
3021
+		$updated = $this->getMtgModel()->update(
3022
+		// fields and values
3023
+			[
3024
+				'MTP_user_id'      => $form_data['MTP_user_id'],
3025
+				'MTP_messenger'    => $form_data['MTP_messenger'],
3026
+				'MTP_message_type' => $form_data['MTP_message_type'],
3027
+				'MTP_is_global'    => $form_data['MTP_is_global'],
3028
+				'MTP_is_override'  => $form_data['MTP_is_override'],
3029
+				'MTP_deleted'      => $form_data['MTP_deleted'],
3030
+				'MTP_is_active'    => $form_data['MTP_is_active'],
3031
+				'MTP_name'         => $this->request->getRequestParam('ee_msg_non_global_fields[MTP_name]', ''),
3032
+				'MTP_description'  => $this->request->getRequestParam(
3033
+					'ee_msg_non_global_fields[MTP_description]',
3034
+					''
3035
+				),
3036
+			],
3037
+			// where
3038
+			[['GRP_ID' => $GRP_ID]]
3039
+		);
3040
+
3041
+		if ($updated === false) {
3042
+			EE_Error::add_error(
3043
+				sprintf(
3044
+					esc_html__(
3045
+						'The Message Template Group (%d) was NOT updated for some reason',
3046
+						'event_espresso'
3047
+					),
3048
+					$form_data['GRP_ID']
3049
+				),
3050
+				__FILE__,
3051
+				__FUNCTION__,
3052
+				__LINE__
3053
+			);
3054
+			return false;
3055
+		}
3056
+		// k now we need to ensure the template_pack and template_variation fields are set.
3057
+		$template_pack      = $this->request->getRequestParam('MTP_template_pack', 'default');
3058
+		$template_variation = $this->request->getRequestParam('MTP_template_variation', 'default');
3059
+
3060
+		$message_template_group = $this->getMtgModel()->get_one_by_ID($GRP_ID);
3061
+		if ($message_template_group instanceof EE_Message_Template_Group) {
3062
+			$message_template_group->set_template_pack_name($template_pack);
3063
+			$message_template_group->set_template_pack_variation($template_variation);
3064
+		}
3065
+		return true;
3066
+	}
3067
+
3068
+
3069
+	/**
3070
+	 * recursively runs wp_kses() on message template content in a model safe manner
3071
+	 *
3072
+	 * @param array|string $content
3073
+	 * @return array|string
3074
+	 * @since   4.10.29.p
3075
+	 */
3076
+	private function sanitizeMessageTemplateContent($content)
3077
+	{
3078
+		if (is_array($content)) {
3079
+			foreach ($content as $key => $value) {
3080
+				$content[ $key ] = $this->sanitizeMessageTemplateContent($value);
3081
+			}
3082
+			return $content;
3083
+		}
3084
+		// remove slashes so wp_kses() works properly
3085
+		// wp_kses_stripslashes() only removes slashes from double-quotes,
3086
+		// so attributes using single quotes always appear invalid.
3087
+		$content = stripslashes($content);
3088
+		$content = wp_kses($content, wp_kses_allowed_html('post'));
3089
+		// But currently the models expect slashed data, so after wp_kses()
3090
+		// runs we need to re-slash the data. Sheesh.
3091
+		// See https://events.codebasehq.com/projects/event-espresso/tickets/11211#update-47321587
3092
+		return addslashes($content);
3093
+	}
3094
+
3095
+
3096
+	/**
3097
+	 * @param string $messenger
3098
+	 * @param string $message_type
3099
+	 * @param string $context
3100
+	 * @return string
3101
+	 * @since 4.10.29.p
3102
+	 */
3103
+	private function generateUpdateDescription($messenger, $message_type, $context)
3104
+	{
3105
+		// need the message type and messenger objects to be able to use the labels for the notices
3106
+		$messenger_object = $this->_message_resource_manager->get_messenger($messenger);
3107
+		$messenger_label  = $messenger_object instanceof EE_messenger
3108
+			? ucwords($messenger_object->label['singular'])
3109
+			: '';
3110
+
3111
+		$message_type_object = $this->_message_resource_manager->get_message_type($message_type);
3112
+		$message_type_label  = $message_type_object instanceof EE_message_type
3113
+			? ucwords($message_type_object->label['singular'])
3114
+			: '';
3115
+
3116
+		$context   = ucwords(str_replace('_', ' ', $context));
3117
+		$item_desc = $messenger_label && $message_type_label
3118
+			? $messenger_label . ' ' . $message_type_label . ' ' . $context . ' '
3119
+			: '';
3120
+		$item_desc .= 'Message Template';
3121
+		return $item_desc;
3122
+	}
3123
+
3124
+
3125
+	/**
3126
+	 * @param string $messenger
3127
+	 * @param string $message_type
3128
+	 * @param string $context
3129
+	 * @return bool
3130
+	 * @throws EE_Error
3131
+	 * @throws ReflectionException
3132
+	 * @since 4.10.29.p
3133
+	 */
3134
+	private function performTestSendAfterUpdate($messenger, $message_type, $context)
3135
+	{
3136
+		// was a test send triggered?
3137
+		if ($this->request->requestParamIsSet('test_button')) {
3138
+			EE_Error::overwrite_success();
3139
+			$this->_do_test_send($context, $messenger, $message_type);
3140
+			return true;
3141
+		}
3142
+		return false;
3143
+	}
3144
+
3145
+
3146
+	/**
3147
+	 * processes a test send request to do an actual messenger delivery test for the given message template being tested
3148
+	 *
3149
+	 * @param string $context      what context being tested
3150
+	 * @param string $messenger    messenger being tested
3151
+	 * @param string $message_type message type being tested
3152
+	 * @throws EE_Error
3153
+	 * @throws InvalidArgumentException
3154
+	 * @throws InvalidDataTypeException
3155
+	 * @throws InvalidInterfaceException
3156
+	 * @throws ReflectionException
3157
+	 */
3158
+	protected function _do_test_send($context, $messenger, $message_type)
3159
+	{
3160
+		// set things up for preview
3161
+		$this->request->setRequestParam('messenger', $messenger);
3162
+		$this->request->setRequestParam('message_type', $message_type);
3163
+		$this->request->setRequestParam('context', $context);
3164
+		$GRP_ID = $this->request->getRequestParam('GRP_ID', 0, 'int');
3165
+		$this->request->setRequestParam('GRP_ID', $GRP_ID);
3166
+
3167
+		$active_messenger  = $this->_message_resource_manager->get_active_messenger($messenger);
3168
+		$test_settings_fld = $this->request->getRequestParam('test_settings_fld', [], 'string', true);
3169
+
3170
+		// let's save any existing fields that might be required by the messenger
3171
+		if (
3172
+			! empty($test_settings_fld)
3173
+			&& $active_messenger instanceof EE_messenger
3174
+			&& apply_filters(
3175
+				'FHEE__Messages_Admin_Page__do_test_send__set_existing_test_settings',
3176
+				true,
3177
+				$test_settings_fld,
3178
+				$active_messenger
3179
+			)
3180
+		) {
3181
+			$active_messenger->set_existing_test_settings($test_settings_fld);
3182
+		}
3183
+
3184
+		/**
3185
+		 * Use filter to add additional controls on whether message can send or not
3186
+		 */
3187
+		if (
3188
+			apply_filters(
3189
+				'FHEE__Messages_Admin_Page__do_test_send__can_send',
3190
+				true,
3191
+				$context,
3192
+				$this->request->requestParams(),
3193
+				$messenger,
3194
+				$message_type
3195
+			)
3196
+		) {
3197
+			if (EEM_Event::instance()->count() > 0) {
3198
+				$success = $this->_preview_message(true);
3199
+				if ($success) {
3200
+					EE_Error::add_success(esc_html__('Test message sent', 'event_espresso'));
3201
+				} else {
3202
+					EE_Error::add_error(
3203
+						esc_html__('The test message was not sent', 'event_espresso'),
3204
+						__FILE__,
3205
+						__FUNCTION__,
3206
+						__LINE__
3207
+					);
3208
+				}
3209
+			} else {
3210
+				$this->noEventsErrorMessage(true);
3211
+			}
3212
+		}
3213
+	}
3214
+
3215
+
3216
+	/**
3217
+	 * _generate_new_templates
3218
+	 * This will handle the messenger, message_type selection when "adding a new custom template" for an event and will
3219
+	 * automatically create the defaults for the event.  The user would then be redirected to edit the default context
3220
+	 * for the event.
3221
+	 *
3222
+	 *
3223
+	 * @param string $messenger      the messenger we are generating templates for
3224
+	 * @param array  $message_types  array of message types that the templates are generated for.
3225
+	 * @param int    $GRP_ID         If this is a custom template being generated then a GRP_ID needs to be included to
3226
+	 *                               indicate the message_template_group being used as the base.
3227
+	 *
3228
+	 * @param bool   $global
3229
+	 *
3230
+	 * @return array|bool array of data required for the redirect to the correct edit page or bool if
3231
+	 *                               encountering problems.
3232
+	 * @throws EE_Error
3233
+	 * @throws ReflectionException
3234
+	 */
3235
+	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false)
3236
+	{
3237
+		// if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we
3238
+		// just don't generate any templates.
3239
+		if (empty($message_types)) {
3240
+			return [];
3241
+		}
3242
+
3243
+		$templates = EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
3244
+		return $templates[0];
3245
+	}
3246
+
3247
+
3248
+	/**
3249
+	 * [_trash_or_restore_message_template]
3250
+	 *
3251
+	 * @param boolean $trash  whether to move an item to trash/restore (TRUE) or restore it (FALSE)
3252
+	 * @param boolean $all    whether this is going to trash/restore all contexts within a template group (TRUE) OR just
3253
+	 *                        an individual context (FALSE).
3254
+	 * @return void
3255
+	 * @throws EE_Error
3256
+	 * @throws InvalidArgumentException
3257
+	 * @throws InvalidDataTypeException
3258
+	 * @throws InvalidInterfaceException
3259
+	 */
3260
+	protected function _trash_or_restore_message_template($trash = true, $all = false)
3261
+	{
3262
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3263
+
3264
+		$success = 1;
3265
+
3266
+		// incoming GRP_IDs
3267
+		if ($all) {
3268
+			// Checkboxes
3269
+			$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
3270
+			if (! empty($checkboxes)) {
3271
+				// if array has more than one element then success message should be plural.
3272
+				// todo: what about nonce?
3273
+				$success = count($checkboxes) > 1 ? 2 : 1;
3274
+
3275
+				// cycle through checkboxes
3276
+				while (list($GRP_ID, $value) = each($checkboxes)) {
3277
+					$trashed_or_restored = $trash
3278
+						? $this->getMtgModel()->delete_by_ID($GRP_ID)
3279
+						: $this->getMtgModel()->restore_by_ID($GRP_ID);
3280
+					if (! $trashed_or_restored) {
3281
+						$success = 0;
3282
+					}
3283
+				}
3284
+			} else {
3285
+				// grab single GRP_ID and handle
3286
+				$GRP_ID = $this->request->getRequestParam('id', 0, 'int');
3287
+				if (! empty($GRP_ID)) {
3288
+					$trashed_or_restored = $trash
3289
+						? $this->getMtgModel()->delete_by_ID($GRP_ID)
3290
+						: $this->getMtgModel()->restore_by_ID($GRP_ID);
3291
+					if (! $trashed_or_restored) {
3292
+						$success = 0;
3293
+					}
3294
+				} else {
3295
+					$success = 0;
3296
+				}
3297
+			}
3298
+		}
3299
+
3300
+		$action_desc = $trash
3301
+			? esc_html__('moved to the trash', 'event_espresso')
3302
+			: esc_html__('restored', 'event_espresso');
3303
+
3304
+		$template_switch = $this->request->getRequestParam('template_switch', false, 'bool');
3305
+		$action_desc     = $template_switch ? esc_html__('switched', 'event_espresso') : $action_desc;
3306
+
3307
+		$item_desc = $all ? _n(
3308
+			'Message Template Group',
3309
+			'Message Template Groups',
3310
+			$success,
3311
+			'event_espresso'
3312
+		) : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
3313
+
3314
+		$item_desc = $template_switch
3315
+			? _n('template', 'templates', $success, 'event_espresso')
3316
+			: $item_desc;
3317
+
3318
+		$this->_redirect_after_action($success, $item_desc, $action_desc, []);
3319
+	}
3320
+
3321
+
3322
+	/**
3323
+	 * [_delete_message_template]
3324
+	 * NOTE: this handles not only the deletion of the groups but also all the templates belonging to that group.
3325
+	 *
3326
+	 * @return void
3327
+	 * @throws EE_Error
3328
+	 * @throws InvalidArgumentException
3329
+	 * @throws InvalidDataTypeException
3330
+	 * @throws InvalidInterfaceException
3331
+	 * @throws ReflectionException
3332
+	 */
3333
+	protected function _delete_message_template()
3334
+	{
3335
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3336
+
3337
+		// checkboxes
3338
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
3339
+		if (! empty($checkboxes)) {
3340
+			// if array has more than one element then success message should be plural
3341
+			$success = count($checkboxes) > 1 ? 2 : 1;
3342
+
3343
+			// cycle through bulk action checkboxes
3344
+			while (list($GRP_ID, $value) = each($checkboxes)) {
3345
+				$success = $this->_delete_mtp_permanently($GRP_ID) ? $success : false;
3346
+			}
3347
+		} else {
3348
+			// grab single grp_id and delete
3349
+			$GRP_ID  = $this->request->getRequestParam('id', 0, 'int');
3350
+			$success = $this->_delete_mtp_permanently($GRP_ID);
3351
+		}
3352
+
3353
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', []);
3354
+	}
3355
+
3356
+
3357
+	/**
3358
+	 * helper for permanently deleting a mtP group and all related message_templates
3359
+	 *
3360
+	 * @param int  $GRP_ID        The group being deleted
3361
+	 * @param bool $include_group whether to delete the Message Template Group as well.
3362
+	 * @return bool boolean to indicate the success of the deletes or not.
3363
+	 * @throws EE_Error
3364
+	 * @throws InvalidArgumentException
3365
+	 * @throws InvalidDataTypeException
3366
+	 * @throws InvalidInterfaceException
3367
+	 * @throws ReflectionException
3368
+	 * @throws ReflectionException
3369
+	 */
3370
+	private function _delete_mtp_permanently($GRP_ID, $include_group = true)
3371
+	{
3372
+		$success = true;
3373
+		// first let's GET this group
3374
+		$MTG = $this->getMtgModel()->get_one_by_ID($GRP_ID);
3375
+		// then delete permanently all the related Message Templates
3376
+		$deleted = $MTG->delete_related_permanently('Message_Template');
3377
+
3378
+		if ($deleted === 0) {
3379
+			$success = false;
3380
+		}
3381
+
3382
+		// now delete permanently this particular group
3383
+
3384
+		if ($include_group && ! $MTG->delete_permanently()) {
3385
+			$success = false;
3386
+		}
3387
+
3388
+		return $success;
3389
+	}
3390
+
3391
+
3392
+	/**
3393
+	 *    _learn_more_about_message_templates_link
3394
+	 *
3395
+	 * @access protected
3396
+	 * @return string
3397
+	 */
3398
+	protected function _learn_more_about_message_templates_link()
3399
+	{
3400
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'
3401
+			   . esc_html__('learn more about how message templates works', 'event_espresso')
3402
+			   . '</a>';
3403
+	}
3404
+
3405
+
3406
+	/**
3407
+	 * Used for setting up messenger/message type activation.  This loads up the initial view.  The rest is handled by
3408
+	 * ajax and other routes.
3409
+	 *
3410
+	 * @return void
3411
+	 * @throws DomainException
3412
+	 * @throws EE_Error
3413
+	 */
3414
+	protected function _settings()
3415
+	{
3416
+		$this->_set_m_mt_settings();
3417
+
3418
+		// let's setup the messenger tabs
3419
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
3420
+			$this->_m_mt_settings['messenger_tabs'],
3421
+			'messenger_links',
3422
+			'|',
3423
+			$this->request->getRequestParam('selected_messenger', 'email')
3424
+		);
3425
+
3426
+		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
3427
+		$this->_template_args['after_admin_page_content']  = '</div><!-- end .ui-widget -->';
3428
+
3429
+		$this->display_admin_page_with_sidebar();
3430
+	}
3431
+
3432
+
3433
+	/**
3434
+	 * This sets the $_m_mt_settings property for when needed (used on the Messages settings page)
3435
+	 *
3436
+	 * @access protected
3437
+	 * @return void
3438
+	 * @throws DomainException
3439
+	 */
3440
+	protected function _set_m_mt_settings()
3441
+	{
3442
+		// first if this is already set then lets get out no need to regenerate data.
3443
+		if (! empty($this->_m_mt_settings)) {
3444
+			return;
3445
+		}
3446
+
3447
+		// get all installed messengers and message_types
3448
+		$messengers    = $this->_message_resource_manager->installed_messengers();
3449
+		$message_types = $this->_message_resource_manager->installed_message_types();
3450
+
3451
+
3452
+		// assemble the array for the _tab_text_links helper
3453
+
3454
+		foreach ($messengers as $messenger) {
3455
+			$active = $this->_message_resource_manager->is_messenger_active($messenger->name);
3456
+			$class = 'ee-messenger-' .  sanitize_key($messenger->label['singular']);
3457
+			$this->_m_mt_settings['messenger_tabs'][ $messenger->name ] = [
3458
+				'label' => ucwords($messenger->label['singular']),
3459
+				'class' => $active ? "{$class} messenger-active" : $class,
3460
+				'href'  => $messenger->name,
3461
+				'title' => esc_html__('Modify this Messenger', 'event_espresso'),
3462
+				'slug'  => $messenger->name,
3463
+				'obj'   => $messenger,
3464
+				'icon' => $active
3465
+					? '<span class="dashicons dashicons-yes-alt"></span>'
3466
+					: '<span class="dashicons dashicons-remove"></span>',
3467
+			];
3468
+
3469
+
3470
+			$message_types_for_messenger = $messenger->get_valid_message_types();
3471
+
3472
+			foreach ($message_types as $message_type) {
3473
+				// first we need to verify that this message type is valid with this messenger. Cause if it isn't then
3474
+				// it shouldn't show in either the inactive OR active metabox.
3475
+				if (! in_array($message_type->name, $message_types_for_messenger, true)) {
3476
+					continue;
3477
+				}
3478
+
3479
+				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger(
3480
+					$messenger->name,
3481
+					$message_type->name
3482
+				)
3483
+					? 'active'
3484
+					: 'inactive';
3485
+
3486
+				$this->_m_mt_settings['message_type_tabs'][ $messenger->name ][ $a_or_i ][ $message_type->name ] = [
3487
+					'label'    => ucwords($message_type->label['singular']),
3488
+					'class'    => 'message-type-' . $a_or_i,
3489
+					'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
3490
+					'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
3491
+					'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
3492
+					'title'    => $a_or_i === 'active'
3493
+						? esc_html__('Drag this message type to the Inactive window to deactivate', 'event_espresso')
3494
+						: esc_html__('Drag this message type to the messenger to activate', 'event_espresso'),
3495
+					'content'  => $a_or_i === 'active'
3496
+						? $this->_message_type_settings_content($message_type, $messenger, true)
3497
+						: $this->_message_type_settings_content($message_type, $messenger),
3498
+					'slug'     => $message_type->name,
3499
+					'active'   => $a_or_i === 'active',
3500
+					'obj'      => $message_type,
3501
+				];
3502
+			}
3503
+		}
3504
+	}
3505
+
3506
+
3507
+	/**
3508
+	 * This just prepares the content for the message type settings
3509
+	 *
3510
+	 * @param EE_message_type $message_type The message type object
3511
+	 * @param EE_messenger    $messenger    The messenger object
3512
+	 * @param boolean         $active       Whether the message type is active or not
3513
+	 * @return string html output for the content
3514
+	 * @throws DomainException
3515
+	 */
3516
+	protected function _message_type_settings_content($message_type, $messenger, $active = false)
3517
+	{
3518
+		// get message type fields
3519
+		$fields                                         = $message_type->get_admin_settings_fields();
3520
+		$settings_template_args['template_form_fields'] = '';
3521
+
3522
+		if (! empty($fields) && $active) {
3523
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
3524
+			foreach ($fields as $fldname => $fldprops) {
3525
+				$field_id                         = $messenger->name . '-' . $message_type->name . '-' . $fldname;
3526
+				$template_form_field[ $field_id ] = [
3527
+					'name'       => 'message_type_settings[' . $fldname . ']',
3528
+					'label'      => $fldprops['label'],
3529
+					'input'      => $fldprops['field_type'],
3530
+					'type'       => $fldprops['value_type'],
3531
+					'required'   => $fldprops['required'],
3532
+					'validation' => $fldprops['validation'],
3533
+					'value'      => isset($existing_settings[ $fldname ])
3534
+						? $existing_settings[ $fldname ]
3535
+						: $fldprops['default'],
3536
+					'options'    => isset($fldprops['options'])
3537
+						? $fldprops['options']
3538
+						: [],
3539
+					'default'    => isset($existing_settings[ $fldname ])
3540
+						? $existing_settings[ $fldname ]
3541
+						: $fldprops['default'],
3542
+					'css_class'  => 'no-drag',
3543
+					'format'     => $fldprops['format'],
3544
+				];
3545
+			}
3546
+
3547
+
3548
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field)
3549
+				? $this->_generate_admin_form_fields(
3550
+					$template_form_field,
3551
+					'string',
3552
+					'ee_mt_activate_form'
3553
+				)
3554
+				: '';
3555
+		}
3556
+
3557
+		$settings_template_args['description'] = $message_type->description;
3558
+		// we also need some hidden fields
3559
+		$hidden_fields = [
3560
+			'message_type_settings[messenger]' . $message_type->name    => [
3561
+				'type'  => 'hidden',
3562
+				'value' => $messenger->name,
3563
+			],
3564
+			'message_type_settings[message_type]' . $message_type->name => [
3565
+				'type'  => 'hidden',
3566
+				'value' => $message_type->name,
3567
+			],
3568
+			'type' . $message_type->name                                => [
3569
+				'type'  => 'hidden',
3570
+				'value' => 'message_type',
3571
+			],
3572
+		];
3573
+
3574
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3575
+			$hidden_fields,
3576
+			'array'
3577
+		);
3578
+		$settings_template_args['show_form']     = empty($settings_template_args['template_form_fields'])
3579
+			? ' hidden'
3580
+			: '';
3581
+
3582
+
3583
+		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
3584
+		return EEH_Template::display_template($template, $settings_template_args, true);
3585
+	}
3586
+
3587
+
3588
+	/**
3589
+	 * Generate all the metaboxes for the message types and register them for the messages settings page.
3590
+	 *
3591
+	 * @access protected
3592
+	 * @return void
3593
+	 * @throws DomainException
3594
+	 */
3595
+	protected function _messages_settings_metaboxes()
3596
+	{
3597
+		$this->_set_m_mt_settings();
3598
+		$m_boxes         = $mt_boxes = [];
3599
+		$m_template_args = $mt_template_args = [];
3600
+
3601
+		$selected_messenger = $this->request->getRequestParam('selected_messenger', 'email');
3602
+
3603
+		if (isset($this->_m_mt_settings['messenger_tabs'])) {
3604
+			foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
3605
+				$is_messenger_active = $this->_message_resource_manager->is_messenger_active($messenger);
3606
+				$hide_on_message     = $is_messenger_active ? '' : 'hidden';
3607
+				$hide_off_message    = $is_messenger_active ? 'hidden' : '';
3608
+
3609
+				// messenger meta boxes
3610
+				$active         = $selected_messenger === $messenger;
3611
+				$active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][ $messenger ]['active'])
3612
+					? $this->_m_mt_settings['message_type_tabs'][ $messenger ]['active']
3613
+					: '';
3614
+
3615
+				$m_boxes[ $messenger . '_a_box' ] = sprintf(
3616
+					esc_html__('%s Settings', 'event_espresso'),
3617
+					$tab_array['label']
3618
+				);
3619
+
3620
+				$m_template_args[ $messenger . '_a_box' ] = [
3621
+					'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3622
+					'inactive_message_types' => isset(
3623
+						$this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive']
3624
+					)
3625
+						? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive'])
3626
+						: '',
3627
+					'content'                => $this->_get_messenger_box_content($tab_array['obj']),
3628
+					'hidden'                 => $active ? '' : ' hidden',
3629
+					'hide_on_message'        => $hide_on_message,
3630
+					'messenger'              => $messenger,
3631
+					'active'                 => $active,
3632
+				];
3633
+
3634
+				// message type meta boxes
3635
+				// (which is really just the inactive container for each messenger
3636
+				// showing inactive message types for that messenger)
3637
+				$mt_boxes[ $messenger . '_i_box' ]         = esc_html__('Inactive Message Types', 'event_espresso');
3638
+				$mt_template_args[ $messenger . '_i_box' ] = [
3639
+					'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3640
+					'inactive_message_types' => isset(
3641
+						$this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive']
3642
+					)
3643
+						? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][ $messenger ]['inactive'])
3644
+						: '',
3645
+					'hidden'                 => $active ? '' : ' hidden',
3646
+					'hide_on_message'        => $hide_on_message,
3647
+					'hide_off_message'       => $hide_off_message,
3648
+					'messenger'              => $messenger,
3649
+					'active'                 => $active,
3650
+				];
3651
+			}
3652
+		}
3653
+
3654
+
3655
+		// register messenger metaboxes
3656
+		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
3657
+		foreach ($m_boxes as $box => $label) {
3658
+			$callback_args = ['template_path' => $m_template_path, 'template_args' => $m_template_args[ $box ]];
3659
+			$msgr          = str_replace('_a_box', '', $box);
3660
+			$this->addMetaBox(
3661
+				'espresso_' . $msgr . '_settings',
3662
+				$label,
3663
+				function ($post, $metabox) {
3664
+					EEH_Template::display_template(
3665
+						$metabox['args']['template_path'],
3666
+						$metabox['args']['template_args']
3667
+					);
3668
+				},
3669
+				$this->_current_screen->id,
3670
+				'normal',
3671
+				'high',
3672
+				$callback_args
3673
+			);
3674
+		}
3675
+
3676
+		// register message type metaboxes
3677
+		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
3678
+		foreach ($mt_boxes as $box => $label) {
3679
+			$callback_args = [
3680
+				'template_path' => $mt_template_path,
3681
+				'template_args' => $mt_template_args[ $box ],
3682
+			];
3683
+			$mt            = str_replace('_i_box', '', $box);
3684
+			$this->addMetaBox(
3685
+				'espresso_' . $mt . '_inactive_mts',
3686
+				$label,
3687
+				function ($post, $metabox) {
3688
+					EEH_Template::display_template(
3689
+						$metabox['args']['template_path'],
3690
+						$metabox['args']['template_args']
3691
+					);
3692
+				},
3693
+				$this->_current_screen->id,
3694
+				'side',
3695
+				'high',
3696
+				$callback_args
3697
+			);
3698
+		}
3699
+
3700
+		// register metabox for global messages settings but only when on the main site.  On single site installs this
3701
+		// will always result in the metabox showing, on multisite installs the metabox will only show on the main site.
3702
+		if (is_main_site()) {
3703
+			$this->addMetaBox(
3704
+				'espresso_global_message_settings',
3705
+				esc_html__('Global Message Settings', 'event_espresso'),
3706
+				[$this, 'global_messages_settings_metabox_content'],
3707
+				$this->_current_screen->id,
3708
+				'normal',
3709
+				'low',
3710
+				[]
3711
+			);
3712
+		}
3713
+	}
3714
+
3715
+
3716
+	/**
3717
+	 *  This generates the content for the global messages settings metabox.
3718
+	 *
3719
+	 * @return void
3720
+	 * @throws EE_Error
3721
+	 * @throws InvalidArgumentException
3722
+	 * @throws ReflectionException
3723
+	 * @throws InvalidDataTypeException
3724
+	 * @throws InvalidInterfaceException
3725
+	 */
3726
+	public function global_messages_settings_metabox_content()
3727
+	{
3728
+		$form = $this->_generate_global_settings_form();
3729
+		// already escaped
3730
+		echo $form->form_open(
3731
+			$this->add_query_args_and_nonce(['action' => 'update_global_settings'], EE_MSG_ADMIN_URL),
3732
+			'POST'
3733
+		);
3734
+		echo $form->get_html();
3735
+		echo $form->form_close();
3736
+	}
3737
+
3738
+
3739
+	/**
3740
+	 * This generates and returns the form object for the global messages settings.
3741
+	 *
3742
+	 * @return EE_Form_Section_Proper
3743
+	 * @throws EE_Error
3744
+	 * @throws InvalidArgumentException
3745
+	 * @throws ReflectionException
3746
+	 * @throws InvalidDataTypeException
3747
+	 * @throws InvalidInterfaceException
3748
+	 */
3749
+	protected function _generate_global_settings_form()
3750
+	{
3751
+		/** @var EE_Network_Core_Config $network_config */
3752
+		$network_config = EE_Registry::instance()->NET_CFG->core;
3753
+
3754
+		return new EE_Form_Section_Proper(
3755
+			[
3756
+				'name'            => 'global_messages_settings',
3757
+				'html_id'         => 'global_messages_settings',
3758
+				'html_class'      => 'form-table',
3759
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
3760
+				'subsections'     => apply_filters(
3761
+					'FHEE__Messages_Admin_Page__global_messages_settings_metabox_content__form_subsections',
3762
+					[
3763
+						'do_messages_on_same_request' => new EE_Select_Input(
3764
+							[
3765
+								true  => esc_html__('On the same request', 'event_espresso'),
3766
+								false => esc_html__('On a separate request', 'event_espresso'),
3767
+							],
3768
+							[
3769
+								'default'         => $network_config->do_messages_on_same_request,
3770
+								'html_label_text' => esc_html__(
3771
+									'Generate and send all messages:',
3772
+									'event_espresso'
3773
+								),
3774
+								'html_help_text'  => esc_html__(
3775
+									'By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system.  This makes things execute faster for people registering for your events.  However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.',
3776
+									'event_espresso'
3777
+								),
3778
+							]
3779
+						),
3780
+						'delete_threshold'            => new EE_Select_Input(
3781
+							[
3782
+								0  => esc_html__('Forever', 'event_espresso'),
3783
+								3  => esc_html__('3 Months', 'event_espresso'),
3784
+								6  => esc_html__('6 Months', 'event_espresso'),
3785
+								9  => esc_html__('9 Months', 'event_espresso'),
3786
+								12 => esc_html__('12 Months', 'event_espresso'),
3787
+								24 => esc_html__('24 Months', 'event_espresso'),
3788
+								36 => esc_html__('36 Months', 'event_espresso'),
3789
+							],
3790
+							[
3791
+								'default'         => EE_Registry::instance()->CFG->messages->delete_threshold,
3792
+								'html_label_text' => esc_html__('Cleanup of old messages:', 'event_espresso'),
3793
+								'html_help_text'  => esc_html__(
3794
+									'You can control how long a record of processed messages is kept via this option.',
3795
+									'event_espresso'
3796
+								),
3797
+							]
3798
+						),
3799
+						'update_settings'             => new EE_Submit_Input(
3800
+							[
3801
+								'default'         => esc_html__('Update', 'event_espresso'),
3802
+								'html_label_text' => '&nbsp',
3803
+							]
3804
+						),
3805
+					]
3806
+				),
3807
+			]
3808
+		);
3809
+	}
3810
+
3811
+
3812
+	/**
3813
+	 * This handles updating the global settings set on the admin page.
3814
+	 *
3815
+	 * @throws EE_Error
3816
+	 * @throws InvalidDataTypeException
3817
+	 * @throws InvalidInterfaceException
3818
+	 * @throws InvalidArgumentException
3819
+	 * @throws ReflectionException
3820
+	 */
3821
+	protected function _update_global_settings()
3822
+	{
3823
+		/** @var EE_Network_Core_Config $network_config */
3824
+		$network_config  = EE_Registry::instance()->NET_CFG->core;
3825
+		$messages_config = EE_Registry::instance()->CFG->messages;
3826
+		$form            = $this->_generate_global_settings_form();
3827
+		if ($form->was_submitted()) {
3828
+			$form->receive_form_submission();
3829
+			if ($form->is_valid()) {
3830
+				$valid_data = $form->valid_data();
3831
+				foreach ($valid_data as $property => $value) {
3832
+					$setter = 'set_' . $property;
3833
+					if (method_exists($network_config, $setter)) {
3834
+						$network_config->{$setter}($value);
3835
+					} elseif (
3836
+						property_exists($network_config, $property)
3837
+						&& $network_config->{$property} !== $value
3838
+					) {
3839
+						$network_config->{$property} = $value;
3840
+					} elseif (
3841
+						property_exists($messages_config, $property)
3842
+						&& $messages_config->{$property} !== $value
3843
+					) {
3844
+						$messages_config->{$property} = $value;
3845
+					}
3846
+				}
3847
+				// only update if the form submission was valid!
3848
+				EE_Registry::instance()->NET_CFG->update_config(true, false);
3849
+				EE_Registry::instance()->CFG->update_espresso_config();
3850
+				EE_Error::overwrite_success();
3851
+				EE_Error::add_success(esc_html__('Global message settings were updated', 'event_espresso'));
3852
+			}
3853
+		}
3854
+		$this->_redirect_after_action(0, '', '', ['action' => 'settings'], true);
3855
+	}
3856
+
3857
+
3858
+	/**
3859
+	 * this prepares the messenger tabs that can be dragged in and out of messenger boxes to activate/deactivate
3860
+	 *
3861
+	 * @param array $tab_array This is an array of message type tab details used to generate the tabs
3862
+	 * @return string html formatted tabs
3863
+	 * @throws DomainException
3864
+	 */
3865
+	protected function _get_mt_tabs($tab_array)
3866
+	{
3867
+		$tab_array = (array) $tab_array;
3868
+		$template  = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
3869
+		$tabs      = '';
3870
+
3871
+		foreach ($tab_array as $tab) {
3872
+			$tabs .= EEH_Template::display_template($template, $tab, true);
3873
+		}
3874
+
3875
+		return $tabs;
3876
+	}
3877
+
3878
+
3879
+	/**
3880
+	 * This prepares the content of the messenger meta box admin settings
3881
+	 *
3882
+	 * @param EE_messenger $messenger The messenger we're setting up content for
3883
+	 * @return string html formatted content
3884
+	 * @throws DomainException
3885
+	 */
3886
+	protected function _get_messenger_box_content(EE_messenger $messenger)
3887
+	{
3888
+
3889
+		$fields                                         = $messenger->get_admin_settings_fields();
3890
+		$settings_template_args['template_form_fields'] = '';
3891
+
3892
+		// is $messenger active?
3893
+		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name);
3894
+
3895
+
3896
+		if (! empty($fields)) {
3897
+			$existing_settings = $messenger->get_existing_admin_settings();
3898
+
3899
+			foreach ($fields as $fldname => $fldprops) {
3900
+				$field_id                         = $messenger->name . '-' . $fldname;
3901
+				$template_form_field[ $field_id ] = [
3902
+					'name'       => 'messenger_settings[' . $field_id . ']',
3903
+					'label'      => $fldprops['label'],
3904
+					'input'      => $fldprops['field_type'],
3905
+					'type'       => $fldprops['value_type'],
3906
+					'required'   => $fldprops['required'],
3907
+					'validation' => $fldprops['validation'],
3908
+					'value'      => isset($existing_settings[ $field_id ])
3909
+						? $existing_settings[ $field_id ]
3910
+						: $fldprops['default'],
3911
+					'css_class'  => '',
3912
+					'format'     => $fldprops['format'],
3913
+				];
3914
+			}
3915
+
3916
+
3917
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field)
3918
+				? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form')
3919
+				: '';
3920
+		}
3921
+
3922
+		// we also need some hidden fields
3923
+		$settings_template_args['hidden_fields'] = [
3924
+			'messenger_settings[messenger]' . $messenger->name => [
3925
+				'type'  => 'hidden',
3926
+				'value' => $messenger->name,
3927
+			],
3928
+			'type' . $messenger->name                          => [
3929
+				'type'  => 'hidden',
3930
+				'value' => 'messenger',
3931
+			],
3932
+		];
3933
+
3934
+		// make sure any active message types that are existing are included in the hidden fields
3935
+		if (isset($this->_m_mt_settings['message_type_tabs'][ $messenger->name ]['active'])) {
3936
+			foreach ($this->_m_mt_settings['message_type_tabs'][ $messenger->name ]['active'] as $mt => $values) {
3937
+				$settings_template_args['hidden_fields'][ 'messenger_settings[message_types][' . $mt . ']' ] = [
3938
+					'type'  => 'hidden',
3939
+					'value' => $mt,
3940
+				];
3941
+			}
3942
+		}
3943
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3944
+			$settings_template_args['hidden_fields'],
3945
+			'array'
3946
+		);
3947
+		$active                                  =
3948
+			$this->_message_resource_manager->is_messenger_active($messenger->name);
3949
+
3950
+		$settings_template_args['messenger']           = $messenger->name;
3951
+		$settings_template_args['description']         = $messenger->description;
3952
+		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
3953
+
3954
+
3955
+		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active(
3956
+			$messenger->name
3957
+		)
3958
+			? $settings_template_args['show_hide_edit_form']
3959
+			: ' hidden';
3960
+
3961
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields'])
3962
+			? ' hidden'
3963
+			: $settings_template_args['show_hide_edit_form'];
3964
+
3965
+
3966
+		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
3967
+		$settings_template_args['nonce']         = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
3968
+		$settings_template_args['on_off_status'] = $active;
3969
+		$template                                = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
3970
+		return EEH_Template::display_template(
3971
+			$template,
3972
+			$settings_template_args,
3973
+			true
3974
+		);
3975
+	}
3976
+
3977
+
3978
+	/**
3979
+	 * used by ajax on the messages settings page to activate|deactivate the messenger
3980
+	 *
3981
+	 * @throws DomainException
3982
+	 * @throws EE_Error
3983
+	 * @throws InvalidDataTypeException
3984
+	 * @throws InvalidInterfaceException
3985
+	 * @throws InvalidArgumentException
3986
+	 * @throws ReflectionException
3987
+	 */
3988
+	public function activate_messenger_toggle()
3989
+	{
3990
+		$success = true;
3991
+		$this->_prep_default_response_for_messenger_or_message_type_toggle();
3992
+		// let's check that we have required data
3993
+
3994
+		if (! $this->_active_messenger_name) {
3995
+			EE_Error::add_error(
3996
+				esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3997
+				__FILE__,
3998
+				__FUNCTION__,
3999
+				__LINE__
4000
+			);
4001
+			$success = false;
4002
+		}
4003
+
4004
+		// do a nonce check here since we're not arriving via a normal route
4005
+		$nonce     = $this->request->getRequestParam('activate_nonce', '');
4006
+		$nonce_ref = "activate_{$this->_active_messenger_name}_toggle_nonce";
4007
+
4008
+		$this->_verify_nonce($nonce, $nonce_ref);
4009
+
4010
+
4011
+		$status = $this->request->getRequestParam('status');
4012
+		if (! $status) {
4013
+			EE_Error::add_error(
4014
+				esc_html__(
4015
+					'Messenger status needed to know whether activation or deactivation is happening. No status is given',
4016
+					'event_espresso'
4017
+				),
4018
+				__FILE__,
4019
+				__FUNCTION__,
4020
+				__LINE__
4021
+			);
4022
+			$success = false;
4023
+		}
4024
+
4025
+		// do check to verify we have a valid status.
4026
+		if ($status !== 'off' && $status !== 'on') {
4027
+			EE_Error::add_error(
4028
+				sprintf(
4029
+					esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
4030
+					$status
4031
+				),
4032
+				__FILE__,
4033
+				__FUNCTION__,
4034
+				__LINE__
4035
+			);
4036
+			$success = false;
4037
+		}
4038
+
4039
+		if ($success) {
4040
+			// made it here?  Stop dawdling then!!
4041
+			$success = $status === 'off'
4042
+				? $this->_deactivate_messenger($this->_active_messenger_name)
4043
+				: $this->_activate_messenger($this->_active_messenger_name);
4044
+		}
4045
+
4046
+		$this->_template_args['success'] = $success;
4047
+
4048
+		// no special instructions so let's just do the json return (which should automatically do all the special stuff).
4049
+		$this->_return_json();
4050
+	}
4051
+
4052
+
4053
+	/**
4054
+	 * used by ajax from the messages settings page to activate|deactivate a message type
4055
+	 *
4056
+	 * @throws DomainException
4057
+	 * @throws EE_Error
4058
+	 * @throws ReflectionException
4059
+	 * @throws InvalidDataTypeException
4060
+	 * @throws InvalidInterfaceException
4061
+	 * @throws InvalidArgumentException
4062
+	 */
4063
+	public function activate_mt_toggle()
4064
+	{
4065
+		$success = true;
4066
+		$this->_prep_default_response_for_messenger_or_message_type_toggle();
4067
+
4068
+		// let's make sure we have the necessary data
4069
+		if (! $this->_active_message_type_name) {
4070
+			EE_Error::add_error(
4071
+				esc_html__('Message Type name needed to toggle activation. None given', 'event_espresso'),
4072
+				__FILE__,
4073
+				__FUNCTION__,
4074
+				__LINE__
4075
+			);
4076
+			$success = false;
4077
+		}
4078
+
4079
+		if (! $this->_active_messenger_name) {
4080
+			EE_Error::add_error(
4081
+				esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
4082
+				__FILE__,
4083
+				__FUNCTION__,
4084
+				__LINE__
4085
+			);
4086
+			$success = false;
4087
+		}
4088
+
4089
+		$status = $this->request->getRequestParam('status');
4090
+		if (! $status) {
4091
+			EE_Error::add_error(
4092
+				esc_html__(
4093
+					'Messenger status needed to know whether activation or deactivation is happening. No status is given',
4094
+					'event_espresso'
4095
+				),
4096
+				__FILE__,
4097
+				__FUNCTION__,
4098
+				__LINE__
4099
+			);
4100
+			$success = false;
4101
+		}
4102
+
4103
+
4104
+		// do check to verify we have a valid status.
4105
+		if ($status !== 'activate' && $status !== 'deactivate') {
4106
+			EE_Error::add_error(
4107
+				sprintf(
4108
+					esc_html__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'),
4109
+					$status
4110
+				),
4111
+				__FILE__,
4112
+				__FUNCTION__,
4113
+				__LINE__
4114
+			);
4115
+			$success = false;
4116
+		}
4117
+
4118
+
4119
+		// do a nonce check here since we're not arriving via a normal route
4120
+		$nonce = $this->request->getRequestParam('mt_nonce', '');
4121
+		$this->_verify_nonce($nonce, "{$this->_active_message_type_name}_nonce");
4122
+
4123
+		if ($success) {
4124
+			// made it here? um, what are you waiting for then?
4125
+			$success = $status === 'deactivate'
4126
+				? $this->_deactivate_message_type_for_messenger(
4127
+					$this->_active_messenger_name,
4128
+					$this->_active_message_type_name
4129
+				)
4130
+				: $this->_activate_message_type_for_messenger(
4131
+					$this->_active_messenger_name,
4132
+					$this->_active_message_type_name
4133
+				);
4134
+		}
4135
+
4136
+		$this->_template_args['success'] = $success;
4137
+		$this->_return_json();
4138
+	}
4139
+
4140
+
4141
+	/**
4142
+	 * Takes care of processing activating a messenger and preparing the appropriate response.
4143
+	 *
4144
+	 * @param string $messenger_name The name of the messenger being activated
4145
+	 * @return bool
4146
+	 * @throws DomainException
4147
+	 * @throws EE_Error
4148
+	 * @throws InvalidArgumentException
4149
+	 * @throws ReflectionException
4150
+	 * @throws InvalidDataTypeException
4151
+	 * @throws InvalidInterfaceException
4152
+	 */
4153
+	protected function _activate_messenger($messenger_name)
4154
+	{
4155
+		$active_messenger          = $this->_message_resource_manager->get_messenger($messenger_name);
4156
+		$message_types_to_activate = $active_messenger instanceof EE_Messenger
4157
+			? $active_messenger->get_default_message_types()
4158
+			: [];
4159
+
4160
+		// ensure is active
4161
+		$this->_message_resource_manager->activate_messenger($active_messenger, $message_types_to_activate);
4162
+
4163
+		// set response_data for reload
4164
+		foreach ($message_types_to_activate as $message_type_name) {
4165
+			$message_type = $this->_message_resource_manager->get_message_type($message_type_name);
4166
+			if (
4167
+				$this->_message_resource_manager->is_message_type_active_for_messenger(
4168
+					$messenger_name,
4169
+					$message_type_name
4170
+				)
4171
+				&& $message_type instanceof EE_message_type
4172
+			) {
4173
+				$this->_template_args['data']['active_mts'][] = $message_type_name;
4174
+				if ($message_type->get_admin_settings_fields()) {
4175
+					$this->_template_args['data']['mt_reload'][] = $message_type_name;
4176
+				}
4177
+			}
4178
+		}
4179
+
4180
+		// add success message for activating messenger
4181
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger);
4182
+	}
4183
+
4184
+
4185
+	/**
4186
+	 * Takes care of processing deactivating a messenger and preparing the appropriate response.
4187
+	 *
4188
+	 * @param string $messenger_name The name of the messenger being activated
4189
+	 * @return bool
4190
+	 * @throws DomainException
4191
+	 * @throws EE_Error
4192
+	 * @throws InvalidArgumentException
4193
+	 * @throws ReflectionException
4194
+	 * @throws InvalidDataTypeException
4195
+	 * @throws InvalidInterfaceException
4196
+	 */
4197
+	protected function _deactivate_messenger($messenger_name)
4198
+	{
4199
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
4200
+		$this->_message_resource_manager->deactivate_messenger($messenger_name);
4201
+
4202
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger);
4203
+	}
4204
+
4205
+
4206
+	/**
4207
+	 * Takes care of processing activating a message type for a messenger and preparing the appropriate response.
4208
+	 *
4209
+	 * @param string $messenger_name    The name of the messenger the message type is being activated for.
4210
+	 * @param string $message_type_name The name of the message type being activated for the messenger
4211
+	 * @return bool
4212
+	 * @throws DomainException
4213
+	 * @throws EE_Error
4214
+	 * @throws InvalidArgumentException
4215
+	 * @throws ReflectionException
4216
+	 * @throws InvalidDataTypeException
4217
+	 * @throws InvalidInterfaceException
4218
+	 */
4219
+	protected function _activate_message_type_for_messenger($messenger_name, $message_type_name)
4220
+	{
4221
+		$active_messenger         = $this->_message_resource_manager->get_messenger($messenger_name);
4222
+		$message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name);
4223
+
4224
+		// ensure is active
4225
+		$this->_message_resource_manager->activate_messenger($active_messenger, $message_type_name);
4226
+
4227
+		// set response for load
4228
+		if (
4229
+			$this->_message_resource_manager->is_message_type_active_for_messenger(
4230
+				$messenger_name,
4231
+				$message_type_name
4232
+			)
4233
+		) {
4234
+			$this->_template_args['data']['active_mts'][] = $message_type_name;
4235
+			if ($message_type_to_activate->get_admin_settings_fields()) {
4236
+				$this->_template_args['data']['mt_reload'][] = $message_type_name;
4237
+			}
4238
+		}
4239
+
4240
+		return $this->_setup_response_message_for_activating_messenger_with_message_types(
4241
+			$active_messenger,
4242
+			$message_type_to_activate
4243
+		);
4244
+	}
4245
+
4246
+
4247
+	/**
4248
+	 * Takes care of processing deactivating a message type for a messenger and preparing the appropriate response.
4249
+	 *
4250
+	 * @param string $messenger_name    The name of the messenger the message type is being deactivated for.
4251
+	 * @param string $message_type_name The name of the message type being deactivated for the messenger
4252
+	 * @return bool
4253
+	 * @throws DomainException
4254
+	 * @throws EE_Error
4255
+	 * @throws InvalidArgumentException
4256
+	 * @throws ReflectionException
4257
+	 * @throws InvalidDataTypeException
4258
+	 * @throws InvalidInterfaceException
4259
+	 */
4260
+	protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name)
4261
+	{
4262
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
4263
+		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't */
4264
+		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name);
4265
+		$this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name);
4266
+
4267
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types(
4268
+			$active_messenger,
4269
+			$message_type_to_deactivate
4270
+		);
4271
+	}
4272
+
4273
+
4274
+	/**
4275
+	 * This just initializes the defaults for activating messenger and message type responses.
4276
+	 */
4277
+	protected function _prep_default_response_for_messenger_or_message_type_toggle()
4278
+	{
4279
+		$this->_template_args['data']['active_mts'] = [];
4280
+		$this->_template_args['data']['mt_reload']  = [];
4281
+	}
4282
+
4283
+
4284
+	/**
4285
+	 * Setup appropriate response for activating a messenger and/or message types
4286
+	 *
4287
+	 * @param EE_messenger         $messenger
4288
+	 * @param EE_message_type|null $message_type
4289
+	 * @return bool
4290
+	 * @throws DomainException
4291
+	 * @throws EE_Error
4292
+	 * @throws InvalidArgumentException
4293
+	 * @throws ReflectionException
4294
+	 * @throws InvalidDataTypeException
4295
+	 * @throws InvalidInterfaceException
4296
+	 */
4297
+	protected function _setup_response_message_for_activating_messenger_with_message_types(
4298
+		$messenger,
4299
+		EE_Message_Type $message_type = null
4300
+	) {
4301
+		// if $messenger isn't a valid messenger object then get out.
4302
+		if (! $messenger instanceof EE_Messenger) {
4303
+			EE_Error::add_error(
4304
+				esc_html__('The messenger being activated is not a valid messenger', 'event_espresso'),
4305
+				__FILE__,
4306
+				__FUNCTION__,
4307
+				__LINE__
4308
+			);
4309
+			return false;
4310
+		}
4311
+		// activated
4312
+		if ($this->_template_args['data']['active_mts']) {
4313
+			EE_Error::overwrite_success();
4314
+			// activated a message type with the messenger
4315
+			if ($message_type instanceof EE_message_type) {
4316
+				EE_Error::add_success(
4317
+					sprintf(
4318
+						esc_html__(
4319
+							'%s message type has been successfully activated with the %s messenger',
4320
+							'event_espresso'
4321
+						),
4322
+						ucwords($message_type->label['singular']),
4323
+						ucwords($messenger->label['singular'])
4324
+					)
4325
+				);
4326
+
4327
+				// if message type was invoice then let's make sure we activate the invoice payment method.
4328
+				if ($message_type->name === 'invoice') {
4329
+					EE_Registry::instance()->load_lib('Payment_Method_Manager');
4330
+					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
4331
+					if ($pm instanceof EE_Payment_Method) {
4332
+						EE_Error::add_attention(
4333
+							esc_html__(
4334
+								'Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.',
4335
+								'event_espresso'
4336
+							)
4337
+						);
4338
+					}
4339
+				}
4340
+				// just toggles the entire messenger
4341
+			} else {
4342
+				EE_Error::add_success(
4343
+					sprintf(
4344
+						esc_html__('%s messenger has been successfully activated', 'event_espresso'),
4345
+						ucwords($messenger->label['singular'])
4346
+					)
4347
+				);
4348
+			}
4349
+
4350
+			return true;
4351
+
4352
+			// possible error condition. This will happen when our active_mts data is empty because it is validated for actual active
4353
+			// message types after the activation process.  However its possible some messengers don't HAVE any default_message_types
4354
+			// in which case we just give a success message for the messenger being successfully activated.
4355
+		} else {
4356
+			if (! $messenger->get_default_message_types()) {
4357
+				// messenger doesn't have any default message types so still a success.
4358
+				EE_Error::add_success(
4359
+					sprintf(
4360
+						esc_html__('%s messenger was successfully activated.', 'event_espresso'),
4361
+						ucwords($messenger->label['singular'])
4362
+					)
4363
+				);
4364
+
4365
+				return true;
4366
+			} else {
4367
+				EE_Error::add_error(
4368
+					$message_type instanceof EE_message_type
4369
+					? sprintf(
4370
+						esc_html__(
4371
+							'%s message type was not successfully activated with the %s messenger',
4372
+							'event_espresso'
4373
+						),
4374
+						ucwords($message_type->label['singular']),
4375
+						ucwords($messenger->label['singular'])
4376
+					)
4377
+					: sprintf(
4378
+						esc_html__('%s messenger was not successfully activated', 'event_espresso'),
4379
+						ucwords($messenger->label['singular'])
4380
+					),
4381
+					__FILE__,
4382
+					__FUNCTION__,
4383
+					__LINE__
4384
+				);
4385
+
4386
+				return false;
4387
+			}
4388
+		}
4389
+	}
4390
+
4391
+
4392
+	/**
4393
+	 * This sets up the appropriate response for deactivating a messenger and/or message type.
4394
+	 *
4395
+	 * @param EE_messenger         $messenger
4396
+	 * @param EE_message_type|null $message_type
4397
+	 * @return bool
4398
+	 * @throws DomainException
4399
+	 * @throws EE_Error
4400
+	 * @throws InvalidArgumentException
4401
+	 * @throws ReflectionException
4402
+	 * @throws InvalidDataTypeException
4403
+	 * @throws InvalidInterfaceException
4404
+	 */
4405
+	protected function _setup_response_message_for_deactivating_messenger_with_message_types(
4406
+		$messenger,
4407
+		EE_message_type $message_type = null
4408
+	) {
4409
+		EE_Error::overwrite_success();
4410
+
4411
+		// if $messenger isn't a valid messenger object then get out.
4412
+		if (! $messenger instanceof EE_Messenger) {
4413
+			EE_Error::add_error(
4414
+				esc_html__('The messenger being deactivated is not a valid messenger', 'event_espresso'),
4415
+				__FILE__,
4416
+				__FUNCTION__,
4417
+				__LINE__
4418
+			);
4419
+
4420
+			return false;
4421
+		}
4422
+
4423
+		if ($message_type instanceof EE_message_type) {
4424
+			$message_type_name = $message_type->name;
4425
+			EE_Error::add_success(
4426
+				sprintf(
4427
+					esc_html__(
4428
+						'%s message type has been successfully deactivated for the %s messenger.',
4429
+						'event_espresso'
4430
+					),
4431
+					ucwords($message_type->label['singular']),
4432
+					ucwords($messenger->label['singular'])
4433
+				)
4434
+			);
4435
+		} else {
4436
+			$message_type_name = '';
4437
+			EE_Error::add_success(
4438
+				sprintf(
4439
+					esc_html__('%s messenger has been successfully deactivated.', 'event_espresso'),
4440
+					ucwords($messenger->label['singular'])
4441
+				)
4442
+			);
4443
+		}
4444
+
4445
+		// if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
4446
+		if (
4447
+			$messenger->name === 'html'
4448
+			&& (
4449
+				is_null($message_type)
4450
+				|| $message_type_name === 'invoice'
4451
+			)
4452
+		) {
4453
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
4454
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
4455
+			if ($count_updated > 0) {
4456
+				$msg = $message_type_name === 'invoice'
4457
+					? esc_html__(
4458
+						'Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.',
4459
+						'event_espresso'
4460
+					)
4461
+					: esc_html__(
4462
+						'Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.',
4463
+						'event_espresso'
4464
+					);
4465
+				EE_Error::add_attention($msg);
4466
+			}
4467
+		}
4468
+
4469
+		return true;
4470
+	}
4471
+
4472
+
4473
+	/**
4474
+	 * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax)
4475
+	 *
4476
+	 * @throws DomainException
4477
+	 * @throws EE_Error
4478
+	 * @throws EE_Error
4479
+	 */
4480
+	public function update_mt_form()
4481
+	{
4482
+		if (! $this->_active_messenger_name || ! $this->_active_message_type_name) {
4483
+			EE_Error::add_error(
4484
+				esc_html__('Require message type or messenger to send an updated form', 'event_espresso'),
4485
+				__FILE__,
4486
+				__FUNCTION__,
4487
+				__LINE__
4488
+			);
4489
+			$this->_return_json();
4490
+		}
4491
+
4492
+		$message_types = $this->get_installed_message_types();
4493
+		$message_type  = $message_types[ $this->_active_message_type_name ];
4494
+		$messenger     = $this->_message_resource_manager->get_active_messenger($this->_active_messenger_name);
4495
+		$content       = $this->_message_type_settings_content($message_type, $messenger, true);
4496
+
4497
+		$this->_template_args['success'] = true;
4498
+		$this->_template_args['content'] = $content;
4499
+		$this->_return_json();
4500
+	}
4501
+
4502
+
4503
+	/**
4504
+	 * this handles saving the settings for a messenger or message type
4505
+	 *
4506
+	 * @throws EE_Error
4507
+	 * @throws EE_Error
4508
+	 */
4509
+	public function save_settings()
4510
+	{
4511
+		$type = $this->request->getRequestParam('type');
4512
+		if (! $type) {
4513
+			EE_Error::add_error(
4514
+				esc_html__(
4515
+					'Cannot save settings because type is unknown (messenger settings or message type settings?)',
4516
+					'event_espresso'
4517
+				),
4518
+				__FILE__,
4519
+				__FUNCTION__,
4520
+				__LINE__
4521
+			);
4522
+			$this->_template_args['error'] = true;
4523
+			$this->_return_json();
4524
+		}
4525
+
4526
+
4527
+		if ($type === 'messenger') {
4528
+			// this should be an array.
4529
+			$settings  = $this->request->getRequestParam('messenger_settings', [], 'string', true);
4530
+			$messenger = $settings['messenger'];
4531
+			// remove messenger and message_types from settings array
4532
+			unset($settings['messenger'], $settings['message_types']);
4533
+			$this->_message_resource_manager->add_settings_for_messenger($messenger, $settings);
4534
+		} elseif ($type === 'message_type') {
4535
+			$settings     = $this->request->getRequestParam('message_type_settings', [], 'string', true);
4536
+			$messenger    = $settings['messenger'];
4537
+			$message_type = $settings['message_type'];
4538
+			// remove messenger and message_types from settings array
4539
+			unset($settings['messenger'], $settings['message_types']);
4540
+			$this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings);
4541
+		}
4542
+
4543
+		// okay we should have the data all setup.  Now we just update!
4544
+		$success = $this->_message_resource_manager->update_active_messengers_option();
4545
+
4546
+		if ($success) {
4547
+			EE_Error::add_success(esc_html__('Settings updated', 'event_espresso'));
4548
+		} else {
4549
+			EE_Error::add_error(
4550
+				esc_html__('Settings did not get updated', 'event_espresso'),
4551
+				__FILE__,
4552
+				__FUNCTION__,
4553
+				__LINE__
4554
+			);
4555
+		}
4556
+
4557
+		$this->_template_args['success'] = $success;
4558
+		$this->_return_json();
4559
+	}
4560
+
4561
+
4562
+
4563
+
4564
+	/**  EE MESSAGE PROCESSING ACTIONS **/
4565
+
4566
+
4567
+	/**
4568
+	 * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete
4569
+	 * However, this does not send immediately, it just queues for sending.
4570
+	 *
4571
+	 * @throws EE_Error
4572
+	 * @throws InvalidDataTypeException
4573
+	 * @throws InvalidInterfaceException
4574
+	 * @throws InvalidArgumentException
4575
+	 * @throws ReflectionException
4576
+	 * @since 4.9.0
4577
+	 */
4578
+	protected function _generate_now()
4579
+	{
4580
+		EED_Messages::generate_now($this->_get_msg_ids_from_request());
4581
+		$this->_redirect_after_action(false, '', '', [], true);
4582
+	}
4583
+
4584
+
4585
+	/**
4586
+	 * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that
4587
+	 * are EEM_Message::status_resend or EEM_Message::status_idle
4588
+	 *
4589
+	 * @throws EE_Error
4590
+	 * @throws InvalidDataTypeException
4591
+	 * @throws InvalidInterfaceException
4592
+	 * @throws InvalidArgumentException
4593
+	 * @throws ReflectionException
4594
+	 * @since 4.9.0
4595
+	 */
4596
+	protected function _generate_and_send_now()
4597
+	{
4598
+		EED_Messages::generate_and_send_now($this->_get_msg_ids_from_request());
4599
+		$this->_redirect_after_action(false, '', '', [], true);
4600
+	}
4601
+
4602
+
4603
+	/**
4604
+	 * This queues any EEM_Message::status_sent EE_Message ids in the request for resending.
4605
+	 *
4606
+	 * @throws EE_Error
4607
+	 * @throws InvalidDataTypeException
4608
+	 * @throws InvalidInterfaceException
4609
+	 * @throws InvalidArgumentException
4610
+	 * @throws ReflectionException
4611
+	 * @since 4.9.0
4612
+	 */
4613
+	protected function _queue_for_resending()
4614
+	{
4615
+		EED_Messages::queue_for_resending($this->_get_msg_ids_from_request());
4616
+		$this->_redirect_after_action(false, '', '', [], true);
4617
+	}
4618
+
4619
+
4620
+	/**
4621
+	 *  This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue
4622
+	 *
4623
+	 * @throws EE_Error
4624
+	 * @throws InvalidDataTypeException
4625
+	 * @throws InvalidInterfaceException
4626
+	 * @throws InvalidArgumentException
4627
+	 * @throws ReflectionException
4628
+	 * @since 4.9.0
4629
+	 */
4630
+	protected function _send_now()
4631
+	{
4632
+		EED_Messages::send_now($this->_get_msg_ids_from_request());
4633
+		$this->_redirect_after_action(false, '', '', [], true);
4634
+	}
4635
+
4636
+
4637
+	/**
4638
+	 * Deletes EE_messages for IDs in the request.
4639
+	 *
4640
+	 * @throws EE_Error
4641
+	 * @throws InvalidDataTypeException
4642
+	 * @throws InvalidInterfaceException
4643
+	 * @throws InvalidArgumentException
4644
+	 * @since 4.9.0
4645
+	 */
4646
+	protected function _delete_ee_messages()
4647
+	{
4648
+		$MSG_IDs       = $this->_get_msg_ids_from_request();
4649
+		$deleted_count = 0;
4650
+		foreach ($MSG_IDs as $MSG_ID) {
4651
+			if ($this->getMsgModel()->delete_by_ID($MSG_ID)) {
4652
+				$deleted_count++;
4653
+			}
4654
+		}
4655
+		if ($deleted_count) {
4656
+			EE_Error::add_success(
4657
+				esc_html(
4658
+					_n(
4659
+						'Message successfully deleted',
4660
+						'Messages successfully deleted',
4661
+						$deleted_count,
4662
+						'event_espresso'
4663
+					)
4664
+				)
4665
+			);
4666
+		} else {
4667
+			EE_Error::add_error(
4668
+				_n('The message was not deleted.', 'The messages were not deleted', count($MSG_IDs), 'event_espresso'),
4669
+				__FILE__,
4670
+				__FUNCTION__,
4671
+				__LINE__
4672
+			);
4673
+		}
4674
+		$this->_redirect_after_action(false, '', '', [], true);
4675
+	}
4676
+
4677
+
4678
+	/**
4679
+	 *  This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present.
4680
+	 *
4681
+	 * @return array
4682
+	 * @since 4.9.0
4683
+	 */
4684
+	protected function _get_msg_ids_from_request()
4685
+	{
4686
+		$MSG_IDs = $this->request->getRequestParam('MSG_ID', [], 'string', true);
4687
+		if (empty($MSG_IDs)) {
4688
+			return [];
4689
+		}
4690
+		// if 'MSG_ID' was just a single ID (not an array)
4691
+		// then $MSG_IDs will be something like [123] so $MSG_IDs[0] should be 123
4692
+		// otherwise, $MSG_IDs was already an array where message IDs were used as the keys
4693
+		return count($MSG_IDs) === 1 && isset($MSG_IDs[0])
4694
+			? $MSG_IDs
4695
+			: array_keys($MSG_IDs);
4696
+	}
4697 4697
 }
Please login to merge, or discard this patch.
vendor/composer/installed.php 2 patches
Indentation   +410 added lines, -410 removed lines patch added patch discarded remove patch
@@ -1,412 +1,412 @@
 block discarded – undo
1 1
 <?php return array(
2
-    'root' => array(
3
-        'pretty_version' => 'dev-master',
4
-        'version' => 'dev-master',
5
-        'type' => 'wordpress-plugin',
6
-        'install_path' => __DIR__ . '/../../',
7
-        'aliases' => array(),
8
-        'reference' => '0e53f0e0064f5ede83f65f5db1f079e4e70ac602',
9
-        'name' => 'eventespresso/event-espresso-core',
10
-        'dev' => true,
11
-    ),
12
-    'versions' => array(
13
-        'composer/installers' => array(
14
-            'pretty_version' => 'v2.0.1',
15
-            'version' => '2.0.1.0',
16
-            'type' => 'composer-plugin',
17
-            'install_path' => __DIR__ . '/./installers',
18
-            'aliases' => array(),
19
-            'reference' => 'a241e78aaeb09781f5f5b92ac01ffd13ab43e5e8',
20
-            'dev_requirement' => false,
21
-        ),
22
-        'doctrine/instantiator' => array(
23
-            'pretty_version' => '1.4.1',
24
-            'version' => '1.4.1.0',
25
-            'type' => 'library',
26
-            'install_path' => __DIR__ . '/../doctrine/instantiator',
27
-            'aliases' => array(),
28
-            'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc',
29
-            'dev_requirement' => true,
30
-        ),
31
-        'eventespresso/ee-coding-standards' => array(
32
-            'pretty_version' => 'dev-master',
33
-            'version' => 'dev-master',
34
-            'type' => 'phpcodesniffer-standard',
35
-            'install_path' => __DIR__ . '/../eventespresso/ee-coding-standards',
36
-            'aliases' => array(
37
-                0 => '9999999-dev',
38
-            ),
39
-            'reference' => '4bbdbb4ed08aeb7ac719b19d8adbd0974c8b63ae',
40
-            'dev_requirement' => true,
41
-        ),
42
-        'eventespresso/event-espresso-core' => array(
43
-            'pretty_version' => 'dev-master',
44
-            'version' => 'dev-master',
45
-            'type' => 'wordpress-plugin',
46
-            'install_path' => __DIR__ . '/../../',
47
-            'aliases' => array(),
48
-            'reference' => '0e53f0e0064f5ede83f65f5db1f079e4e70ac602',
49
-            'dev_requirement' => false,
50
-        ),
51
-        'myclabs/deep-copy' => array(
52
-            'pretty_version' => '1.11.0',
53
-            'version' => '1.11.0.0',
54
-            'type' => 'library',
55
-            'install_path' => __DIR__ . '/../myclabs/deep-copy',
56
-            'aliases' => array(),
57
-            'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614',
58
-            'dev_requirement' => true,
59
-        ),
60
-        'nikic/php-parser' => array(
61
-            'pretty_version' => 'v4.13.2',
62
-            'version' => '4.13.2.0',
63
-            'type' => 'library',
64
-            'install_path' => __DIR__ . '/../nikic/php-parser',
65
-            'aliases' => array(),
66
-            'reference' => '210577fe3cf7badcc5814d99455df46564f3c077',
67
-            'dev_requirement' => true,
68
-        ),
69
-        'phar-io/manifest' => array(
70
-            'pretty_version' => '2.0.3',
71
-            'version' => '2.0.3.0',
72
-            'type' => 'library',
73
-            'install_path' => __DIR__ . '/../phar-io/manifest',
74
-            'aliases' => array(),
75
-            'reference' => '97803eca37d319dfa7826cc2437fc020857acb53',
76
-            'dev_requirement' => true,
77
-        ),
78
-        'phar-io/version' => array(
79
-            'pretty_version' => '3.2.1',
80
-            'version' => '3.2.1.0',
81
-            'type' => 'library',
82
-            'install_path' => __DIR__ . '/../phar-io/version',
83
-            'aliases' => array(),
84
-            'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
85
-            'dev_requirement' => true,
86
-        ),
87
-        'phpcompatibility/php-compatibility' => array(
88
-            'pretty_version' => '9.3.5',
89
-            'version' => '9.3.5.0',
90
-            'type' => 'phpcodesniffer-standard',
91
-            'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility',
92
-            'aliases' => array(),
93
-            'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243',
94
-            'dev_requirement' => true,
95
-        ),
96
-        'phpcompatibility/phpcompatibility-paragonie' => array(
97
-            'pretty_version' => '1.3.1',
98
-            'version' => '1.3.1.0',
99
-            'type' => 'phpcodesniffer-standard',
100
-            'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie',
101
-            'aliases' => array(),
102
-            'reference' => 'ddabec839cc003651f2ce695c938686d1086cf43',
103
-            'dev_requirement' => true,
104
-        ),
105
-        'phpcompatibility/phpcompatibility-wp' => array(
106
-            'pretty_version' => '2.1.3',
107
-            'version' => '2.1.3.0',
108
-            'type' => 'phpcodesniffer-standard',
109
-            'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp',
110
-            'aliases' => array(),
111
-            'reference' => 'd55de55f88697b9cdb94bccf04f14eb3b11cf308',
112
-            'dev_requirement' => true,
113
-        ),
114
-        'phpdocumentor/reflection-common' => array(
115
-            'pretty_version' => '2.2.0',
116
-            'version' => '2.2.0.0',
117
-            'type' => 'library',
118
-            'install_path' => __DIR__ . '/../phpdocumentor/reflection-common',
119
-            'aliases' => array(),
120
-            'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b',
121
-            'dev_requirement' => true,
122
-        ),
123
-        'phpdocumentor/reflection-docblock' => array(
124
-            'pretty_version' => '5.3.0',
125
-            'version' => '5.3.0.0',
126
-            'type' => 'library',
127
-            'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock',
128
-            'aliases' => array(),
129
-            'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170',
130
-            'dev_requirement' => true,
131
-        ),
132
-        'phpdocumentor/type-resolver' => array(
133
-            'pretty_version' => '1.6.0',
134
-            'version' => '1.6.0.0',
135
-            'type' => 'library',
136
-            'install_path' => __DIR__ . '/../phpdocumentor/type-resolver',
137
-            'aliases' => array(),
138
-            'reference' => '93ebd0014cab80c4ea9f5e297ea48672f1b87706',
139
-            'dev_requirement' => true,
140
-        ),
141
-        'phpspec/prophecy' => array(
142
-            'pretty_version' => 'v1.15.0',
143
-            'version' => '1.15.0.0',
144
-            'type' => 'library',
145
-            'install_path' => __DIR__ . '/../phpspec/prophecy',
146
-            'aliases' => array(),
147
-            'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13',
148
-            'dev_requirement' => true,
149
-        ),
150
-        'phpunit/php-code-coverage' => array(
151
-            'pretty_version' => '9.2.15',
152
-            'version' => '9.2.15.0',
153
-            'type' => 'library',
154
-            'install_path' => __DIR__ . '/../phpunit/php-code-coverage',
155
-            'aliases' => array(),
156
-            'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f',
157
-            'dev_requirement' => true,
158
-        ),
159
-        'phpunit/php-file-iterator' => array(
160
-            'pretty_version' => '3.0.6',
161
-            'version' => '3.0.6.0',
162
-            'type' => 'library',
163
-            'install_path' => __DIR__ . '/../phpunit/php-file-iterator',
164
-            'aliases' => array(),
165
-            'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf',
166
-            'dev_requirement' => true,
167
-        ),
168
-        'phpunit/php-invoker' => array(
169
-            'pretty_version' => '3.1.1',
170
-            'version' => '3.1.1.0',
171
-            'type' => 'library',
172
-            'install_path' => __DIR__ . '/../phpunit/php-invoker',
173
-            'aliases' => array(),
174
-            'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67',
175
-            'dev_requirement' => true,
176
-        ),
177
-        'phpunit/php-text-template' => array(
178
-            'pretty_version' => '2.0.4',
179
-            'version' => '2.0.4.0',
180
-            'type' => 'library',
181
-            'install_path' => __DIR__ . '/../phpunit/php-text-template',
182
-            'aliases' => array(),
183
-            'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28',
184
-            'dev_requirement' => true,
185
-        ),
186
-        'phpunit/php-timer' => array(
187
-            'pretty_version' => '5.0.3',
188
-            'version' => '5.0.3.0',
189
-            'type' => 'library',
190
-            'install_path' => __DIR__ . '/../phpunit/php-timer',
191
-            'aliases' => array(),
192
-            'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2',
193
-            'dev_requirement' => true,
194
-        ),
195
-        'phpunit/phpunit' => array(
196
-            'pretty_version' => '9.5.19',
197
-            'version' => '9.5.19.0',
198
-            'type' => 'library',
199
-            'install_path' => __DIR__ . '/../phpunit/phpunit',
200
-            'aliases' => array(),
201
-            'reference' => '35ea4b7f3acabb26f4bb640f8c30866c401da807',
202
-            'dev_requirement' => true,
203
-        ),
204
-        'roave/security-advisories' => array(
205
-            'pretty_version' => 'dev-master',
206
-            'version' => 'dev-master',
207
-            'type' => 'metapackage',
208
-            'install_path' => NULL,
209
-            'aliases' => array(),
210
-            'reference' => '86b842d48cdaaab1bf3dc24fdc830bf7b58cfcab',
211
-            'dev_requirement' => true,
212
-        ),
213
-        'sebastian/cli-parser' => array(
214
-            'pretty_version' => '1.0.1',
215
-            'version' => '1.0.1.0',
216
-            'type' => 'library',
217
-            'install_path' => __DIR__ . '/../sebastian/cli-parser',
218
-            'aliases' => array(),
219
-            'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2',
220
-            'dev_requirement' => true,
221
-        ),
222
-        'sebastian/code-unit' => array(
223
-            'pretty_version' => '1.0.8',
224
-            'version' => '1.0.8.0',
225
-            'type' => 'library',
226
-            'install_path' => __DIR__ . '/../sebastian/code-unit',
227
-            'aliases' => array(),
228
-            'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120',
229
-            'dev_requirement' => true,
230
-        ),
231
-        'sebastian/code-unit-reverse-lookup' => array(
232
-            'pretty_version' => '2.0.3',
233
-            'version' => '2.0.3.0',
234
-            'type' => 'library',
235
-            'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup',
236
-            'aliases' => array(),
237
-            'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5',
238
-            'dev_requirement' => true,
239
-        ),
240
-        'sebastian/comparator' => array(
241
-            'pretty_version' => '4.0.6',
242
-            'version' => '4.0.6.0',
243
-            'type' => 'library',
244
-            'install_path' => __DIR__ . '/../sebastian/comparator',
245
-            'aliases' => array(),
246
-            'reference' => '55f4261989e546dc112258c7a75935a81a7ce382',
247
-            'dev_requirement' => true,
248
-        ),
249
-        'sebastian/complexity' => array(
250
-            'pretty_version' => '2.0.2',
251
-            'version' => '2.0.2.0',
252
-            'type' => 'library',
253
-            'install_path' => __DIR__ . '/../sebastian/complexity',
254
-            'aliases' => array(),
255
-            'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88',
256
-            'dev_requirement' => true,
257
-        ),
258
-        'sebastian/diff' => array(
259
-            'pretty_version' => '4.0.4',
260
-            'version' => '4.0.4.0',
261
-            'type' => 'library',
262
-            'install_path' => __DIR__ . '/../sebastian/diff',
263
-            'aliases' => array(),
264
-            'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d',
265
-            'dev_requirement' => true,
266
-        ),
267
-        'sebastian/environment' => array(
268
-            'pretty_version' => '5.1.3',
269
-            'version' => '5.1.3.0',
270
-            'type' => 'library',
271
-            'install_path' => __DIR__ . '/../sebastian/environment',
272
-            'aliases' => array(),
273
-            'reference' => '388b6ced16caa751030f6a69e588299fa09200ac',
274
-            'dev_requirement' => true,
275
-        ),
276
-        'sebastian/exporter' => array(
277
-            'pretty_version' => '4.0.4',
278
-            'version' => '4.0.4.0',
279
-            'type' => 'library',
280
-            'install_path' => __DIR__ . '/../sebastian/exporter',
281
-            'aliases' => array(),
282
-            'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9',
283
-            'dev_requirement' => true,
284
-        ),
285
-        'sebastian/global-state' => array(
286
-            'pretty_version' => '5.0.5',
287
-            'version' => '5.0.5.0',
288
-            'type' => 'library',
289
-            'install_path' => __DIR__ . '/../sebastian/global-state',
290
-            'aliases' => array(),
291
-            'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2',
292
-            'dev_requirement' => true,
293
-        ),
294
-        'sebastian/lines-of-code' => array(
295
-            'pretty_version' => '1.0.3',
296
-            'version' => '1.0.3.0',
297
-            'type' => 'library',
298
-            'install_path' => __DIR__ . '/../sebastian/lines-of-code',
299
-            'aliases' => array(),
300
-            'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc',
301
-            'dev_requirement' => true,
302
-        ),
303
-        'sebastian/object-enumerator' => array(
304
-            'pretty_version' => '4.0.4',
305
-            'version' => '4.0.4.0',
306
-            'type' => 'library',
307
-            'install_path' => __DIR__ . '/../sebastian/object-enumerator',
308
-            'aliases' => array(),
309
-            'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71',
310
-            'dev_requirement' => true,
311
-        ),
312
-        'sebastian/object-reflector' => array(
313
-            'pretty_version' => '2.0.4',
314
-            'version' => '2.0.4.0',
315
-            'type' => 'library',
316
-            'install_path' => __DIR__ . '/../sebastian/object-reflector',
317
-            'aliases' => array(),
318
-            'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7',
319
-            'dev_requirement' => true,
320
-        ),
321
-        'sebastian/recursion-context' => array(
322
-            'pretty_version' => '4.0.4',
323
-            'version' => '4.0.4.0',
324
-            'type' => 'library',
325
-            'install_path' => __DIR__ . '/../sebastian/recursion-context',
326
-            'aliases' => array(),
327
-            'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172',
328
-            'dev_requirement' => true,
329
-        ),
330
-        'sebastian/resource-operations' => array(
331
-            'pretty_version' => '3.0.3',
332
-            'version' => '3.0.3.0',
333
-            'type' => 'library',
334
-            'install_path' => __DIR__ . '/../sebastian/resource-operations',
335
-            'aliases' => array(),
336
-            'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8',
337
-            'dev_requirement' => true,
338
-        ),
339
-        'sebastian/type' => array(
340
-            'pretty_version' => '3.0.0',
341
-            'version' => '3.0.0.0',
342
-            'type' => 'library',
343
-            'install_path' => __DIR__ . '/../sebastian/type',
344
-            'aliases' => array(),
345
-            'reference' => 'b233b84bc4465aff7b57cf1c4bc75c86d00d6dad',
346
-            'dev_requirement' => true,
347
-        ),
348
-        'sebastian/version' => array(
349
-            'pretty_version' => '3.0.2',
350
-            'version' => '3.0.2.0',
351
-            'type' => 'library',
352
-            'install_path' => __DIR__ . '/../sebastian/version',
353
-            'aliases' => array(),
354
-            'reference' => 'c6c1022351a901512170118436c764e473f6de8c',
355
-            'dev_requirement' => true,
356
-        ),
357
-        'squizlabs/php_codesniffer' => array(
358
-            'pretty_version' => '3.6.2',
359
-            'version' => '3.6.2.0',
360
-            'type' => 'library',
361
-            'install_path' => __DIR__ . '/../squizlabs/php_codesniffer',
362
-            'aliases' => array(),
363
-            'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a',
364
-            'dev_requirement' => true,
365
-        ),
366
-        'symfony/polyfill-ctype' => array(
367
-            'pretty_version' => 'v1.25.0',
368
-            'version' => '1.25.0.0',
369
-            'type' => 'library',
370
-            'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
371
-            'aliases' => array(),
372
-            'reference' => '30885182c981ab175d4d034db0f6f469898070ab',
373
-            'dev_requirement' => true,
374
-        ),
375
-        'theseer/tokenizer' => array(
376
-            'pretty_version' => '1.2.1',
377
-            'version' => '1.2.1.0',
378
-            'type' => 'library',
379
-            'install_path' => __DIR__ . '/../theseer/tokenizer',
380
-            'aliases' => array(),
381
-            'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e',
382
-            'dev_requirement' => true,
383
-        ),
384
-        'webmozart/assert' => array(
385
-            'pretty_version' => '1.10.0',
386
-            'version' => '1.10.0.0',
387
-            'type' => 'library',
388
-            'install_path' => __DIR__ . '/../webmozart/assert',
389
-            'aliases' => array(),
390
-            'reference' => '6964c76c7804814a842473e0c8fd15bab0f18e25',
391
-            'dev_requirement' => true,
392
-        ),
393
-        'wp-coding-standards/wpcs' => array(
394
-            'pretty_version' => '2.3.0',
395
-            'version' => '2.3.0.0',
396
-            'type' => 'phpcodesniffer-standard',
397
-            'install_path' => __DIR__ . '/../wp-coding-standards/wpcs',
398
-            'aliases' => array(),
399
-            'reference' => '7da1894633f168fe244afc6de00d141f27517b62',
400
-            'dev_requirement' => true,
401
-        ),
402
-        'yoast/phpunit-polyfills' => array(
403
-            'pretty_version' => '1.0.3',
404
-            'version' => '1.0.3.0',
405
-            'type' => 'library',
406
-            'install_path' => __DIR__ . '/../yoast/phpunit-polyfills',
407
-            'aliases' => array(),
408
-            'reference' => '5ea3536428944955f969bc764bbe09738e151ada',
409
-            'dev_requirement' => true,
410
-        ),
411
-    ),
2
+	'root' => array(
3
+		'pretty_version' => 'dev-master',
4
+		'version' => 'dev-master',
5
+		'type' => 'wordpress-plugin',
6
+		'install_path' => __DIR__ . '/../../',
7
+		'aliases' => array(),
8
+		'reference' => '0e53f0e0064f5ede83f65f5db1f079e4e70ac602',
9
+		'name' => 'eventespresso/event-espresso-core',
10
+		'dev' => true,
11
+	),
12
+	'versions' => array(
13
+		'composer/installers' => array(
14
+			'pretty_version' => 'v2.0.1',
15
+			'version' => '2.0.1.0',
16
+			'type' => 'composer-plugin',
17
+			'install_path' => __DIR__ . '/./installers',
18
+			'aliases' => array(),
19
+			'reference' => 'a241e78aaeb09781f5f5b92ac01ffd13ab43e5e8',
20
+			'dev_requirement' => false,
21
+		),
22
+		'doctrine/instantiator' => array(
23
+			'pretty_version' => '1.4.1',
24
+			'version' => '1.4.1.0',
25
+			'type' => 'library',
26
+			'install_path' => __DIR__ . '/../doctrine/instantiator',
27
+			'aliases' => array(),
28
+			'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc',
29
+			'dev_requirement' => true,
30
+		),
31
+		'eventespresso/ee-coding-standards' => array(
32
+			'pretty_version' => 'dev-master',
33
+			'version' => 'dev-master',
34
+			'type' => 'phpcodesniffer-standard',
35
+			'install_path' => __DIR__ . '/../eventespresso/ee-coding-standards',
36
+			'aliases' => array(
37
+				0 => '9999999-dev',
38
+			),
39
+			'reference' => '4bbdbb4ed08aeb7ac719b19d8adbd0974c8b63ae',
40
+			'dev_requirement' => true,
41
+		),
42
+		'eventespresso/event-espresso-core' => array(
43
+			'pretty_version' => 'dev-master',
44
+			'version' => 'dev-master',
45
+			'type' => 'wordpress-plugin',
46
+			'install_path' => __DIR__ . '/../../',
47
+			'aliases' => array(),
48
+			'reference' => '0e53f0e0064f5ede83f65f5db1f079e4e70ac602',
49
+			'dev_requirement' => false,
50
+		),
51
+		'myclabs/deep-copy' => array(
52
+			'pretty_version' => '1.11.0',
53
+			'version' => '1.11.0.0',
54
+			'type' => 'library',
55
+			'install_path' => __DIR__ . '/../myclabs/deep-copy',
56
+			'aliases' => array(),
57
+			'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614',
58
+			'dev_requirement' => true,
59
+		),
60
+		'nikic/php-parser' => array(
61
+			'pretty_version' => 'v4.13.2',
62
+			'version' => '4.13.2.0',
63
+			'type' => 'library',
64
+			'install_path' => __DIR__ . '/../nikic/php-parser',
65
+			'aliases' => array(),
66
+			'reference' => '210577fe3cf7badcc5814d99455df46564f3c077',
67
+			'dev_requirement' => true,
68
+		),
69
+		'phar-io/manifest' => array(
70
+			'pretty_version' => '2.0.3',
71
+			'version' => '2.0.3.0',
72
+			'type' => 'library',
73
+			'install_path' => __DIR__ . '/../phar-io/manifest',
74
+			'aliases' => array(),
75
+			'reference' => '97803eca37d319dfa7826cc2437fc020857acb53',
76
+			'dev_requirement' => true,
77
+		),
78
+		'phar-io/version' => array(
79
+			'pretty_version' => '3.2.1',
80
+			'version' => '3.2.1.0',
81
+			'type' => 'library',
82
+			'install_path' => __DIR__ . '/../phar-io/version',
83
+			'aliases' => array(),
84
+			'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
85
+			'dev_requirement' => true,
86
+		),
87
+		'phpcompatibility/php-compatibility' => array(
88
+			'pretty_version' => '9.3.5',
89
+			'version' => '9.3.5.0',
90
+			'type' => 'phpcodesniffer-standard',
91
+			'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility',
92
+			'aliases' => array(),
93
+			'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243',
94
+			'dev_requirement' => true,
95
+		),
96
+		'phpcompatibility/phpcompatibility-paragonie' => array(
97
+			'pretty_version' => '1.3.1',
98
+			'version' => '1.3.1.0',
99
+			'type' => 'phpcodesniffer-standard',
100
+			'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie',
101
+			'aliases' => array(),
102
+			'reference' => 'ddabec839cc003651f2ce695c938686d1086cf43',
103
+			'dev_requirement' => true,
104
+		),
105
+		'phpcompatibility/phpcompatibility-wp' => array(
106
+			'pretty_version' => '2.1.3',
107
+			'version' => '2.1.3.0',
108
+			'type' => 'phpcodesniffer-standard',
109
+			'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp',
110
+			'aliases' => array(),
111
+			'reference' => 'd55de55f88697b9cdb94bccf04f14eb3b11cf308',
112
+			'dev_requirement' => true,
113
+		),
114
+		'phpdocumentor/reflection-common' => array(
115
+			'pretty_version' => '2.2.0',
116
+			'version' => '2.2.0.0',
117
+			'type' => 'library',
118
+			'install_path' => __DIR__ . '/../phpdocumentor/reflection-common',
119
+			'aliases' => array(),
120
+			'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b',
121
+			'dev_requirement' => true,
122
+		),
123
+		'phpdocumentor/reflection-docblock' => array(
124
+			'pretty_version' => '5.3.0',
125
+			'version' => '5.3.0.0',
126
+			'type' => 'library',
127
+			'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock',
128
+			'aliases' => array(),
129
+			'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170',
130
+			'dev_requirement' => true,
131
+		),
132
+		'phpdocumentor/type-resolver' => array(
133
+			'pretty_version' => '1.6.0',
134
+			'version' => '1.6.0.0',
135
+			'type' => 'library',
136
+			'install_path' => __DIR__ . '/../phpdocumentor/type-resolver',
137
+			'aliases' => array(),
138
+			'reference' => '93ebd0014cab80c4ea9f5e297ea48672f1b87706',
139
+			'dev_requirement' => true,
140
+		),
141
+		'phpspec/prophecy' => array(
142
+			'pretty_version' => 'v1.15.0',
143
+			'version' => '1.15.0.0',
144
+			'type' => 'library',
145
+			'install_path' => __DIR__ . '/../phpspec/prophecy',
146
+			'aliases' => array(),
147
+			'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13',
148
+			'dev_requirement' => true,
149
+		),
150
+		'phpunit/php-code-coverage' => array(
151
+			'pretty_version' => '9.2.15',
152
+			'version' => '9.2.15.0',
153
+			'type' => 'library',
154
+			'install_path' => __DIR__ . '/../phpunit/php-code-coverage',
155
+			'aliases' => array(),
156
+			'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f',
157
+			'dev_requirement' => true,
158
+		),
159
+		'phpunit/php-file-iterator' => array(
160
+			'pretty_version' => '3.0.6',
161
+			'version' => '3.0.6.0',
162
+			'type' => 'library',
163
+			'install_path' => __DIR__ . '/../phpunit/php-file-iterator',
164
+			'aliases' => array(),
165
+			'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf',
166
+			'dev_requirement' => true,
167
+		),
168
+		'phpunit/php-invoker' => array(
169
+			'pretty_version' => '3.1.1',
170
+			'version' => '3.1.1.0',
171
+			'type' => 'library',
172
+			'install_path' => __DIR__ . '/../phpunit/php-invoker',
173
+			'aliases' => array(),
174
+			'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67',
175
+			'dev_requirement' => true,
176
+		),
177
+		'phpunit/php-text-template' => array(
178
+			'pretty_version' => '2.0.4',
179
+			'version' => '2.0.4.0',
180
+			'type' => 'library',
181
+			'install_path' => __DIR__ . '/../phpunit/php-text-template',
182
+			'aliases' => array(),
183
+			'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28',
184
+			'dev_requirement' => true,
185
+		),
186
+		'phpunit/php-timer' => array(
187
+			'pretty_version' => '5.0.3',
188
+			'version' => '5.0.3.0',
189
+			'type' => 'library',
190
+			'install_path' => __DIR__ . '/../phpunit/php-timer',
191
+			'aliases' => array(),
192
+			'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2',
193
+			'dev_requirement' => true,
194
+		),
195
+		'phpunit/phpunit' => array(
196
+			'pretty_version' => '9.5.19',
197
+			'version' => '9.5.19.0',
198
+			'type' => 'library',
199
+			'install_path' => __DIR__ . '/../phpunit/phpunit',
200
+			'aliases' => array(),
201
+			'reference' => '35ea4b7f3acabb26f4bb640f8c30866c401da807',
202
+			'dev_requirement' => true,
203
+		),
204
+		'roave/security-advisories' => array(
205
+			'pretty_version' => 'dev-master',
206
+			'version' => 'dev-master',
207
+			'type' => 'metapackage',
208
+			'install_path' => NULL,
209
+			'aliases' => array(),
210
+			'reference' => '86b842d48cdaaab1bf3dc24fdc830bf7b58cfcab',
211
+			'dev_requirement' => true,
212
+		),
213
+		'sebastian/cli-parser' => array(
214
+			'pretty_version' => '1.0.1',
215
+			'version' => '1.0.1.0',
216
+			'type' => 'library',
217
+			'install_path' => __DIR__ . '/../sebastian/cli-parser',
218
+			'aliases' => array(),
219
+			'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2',
220
+			'dev_requirement' => true,
221
+		),
222
+		'sebastian/code-unit' => array(
223
+			'pretty_version' => '1.0.8',
224
+			'version' => '1.0.8.0',
225
+			'type' => 'library',
226
+			'install_path' => __DIR__ . '/../sebastian/code-unit',
227
+			'aliases' => array(),
228
+			'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120',
229
+			'dev_requirement' => true,
230
+		),
231
+		'sebastian/code-unit-reverse-lookup' => array(
232
+			'pretty_version' => '2.0.3',
233
+			'version' => '2.0.3.0',
234
+			'type' => 'library',
235
+			'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup',
236
+			'aliases' => array(),
237
+			'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5',
238
+			'dev_requirement' => true,
239
+		),
240
+		'sebastian/comparator' => array(
241
+			'pretty_version' => '4.0.6',
242
+			'version' => '4.0.6.0',
243
+			'type' => 'library',
244
+			'install_path' => __DIR__ . '/../sebastian/comparator',
245
+			'aliases' => array(),
246
+			'reference' => '55f4261989e546dc112258c7a75935a81a7ce382',
247
+			'dev_requirement' => true,
248
+		),
249
+		'sebastian/complexity' => array(
250
+			'pretty_version' => '2.0.2',
251
+			'version' => '2.0.2.0',
252
+			'type' => 'library',
253
+			'install_path' => __DIR__ . '/../sebastian/complexity',
254
+			'aliases' => array(),
255
+			'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88',
256
+			'dev_requirement' => true,
257
+		),
258
+		'sebastian/diff' => array(
259
+			'pretty_version' => '4.0.4',
260
+			'version' => '4.0.4.0',
261
+			'type' => 'library',
262
+			'install_path' => __DIR__ . '/../sebastian/diff',
263
+			'aliases' => array(),
264
+			'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d',
265
+			'dev_requirement' => true,
266
+		),
267
+		'sebastian/environment' => array(
268
+			'pretty_version' => '5.1.3',
269
+			'version' => '5.1.3.0',
270
+			'type' => 'library',
271
+			'install_path' => __DIR__ . '/../sebastian/environment',
272
+			'aliases' => array(),
273
+			'reference' => '388b6ced16caa751030f6a69e588299fa09200ac',
274
+			'dev_requirement' => true,
275
+		),
276
+		'sebastian/exporter' => array(
277
+			'pretty_version' => '4.0.4',
278
+			'version' => '4.0.4.0',
279
+			'type' => 'library',
280
+			'install_path' => __DIR__ . '/../sebastian/exporter',
281
+			'aliases' => array(),
282
+			'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9',
283
+			'dev_requirement' => true,
284
+		),
285
+		'sebastian/global-state' => array(
286
+			'pretty_version' => '5.0.5',
287
+			'version' => '5.0.5.0',
288
+			'type' => 'library',
289
+			'install_path' => __DIR__ . '/../sebastian/global-state',
290
+			'aliases' => array(),
291
+			'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2',
292
+			'dev_requirement' => true,
293
+		),
294
+		'sebastian/lines-of-code' => array(
295
+			'pretty_version' => '1.0.3',
296
+			'version' => '1.0.3.0',
297
+			'type' => 'library',
298
+			'install_path' => __DIR__ . '/../sebastian/lines-of-code',
299
+			'aliases' => array(),
300
+			'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc',
301
+			'dev_requirement' => true,
302
+		),
303
+		'sebastian/object-enumerator' => array(
304
+			'pretty_version' => '4.0.4',
305
+			'version' => '4.0.4.0',
306
+			'type' => 'library',
307
+			'install_path' => __DIR__ . '/../sebastian/object-enumerator',
308
+			'aliases' => array(),
309
+			'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71',
310
+			'dev_requirement' => true,
311
+		),
312
+		'sebastian/object-reflector' => array(
313
+			'pretty_version' => '2.0.4',
314
+			'version' => '2.0.4.0',
315
+			'type' => 'library',
316
+			'install_path' => __DIR__ . '/../sebastian/object-reflector',
317
+			'aliases' => array(),
318
+			'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7',
319
+			'dev_requirement' => true,
320
+		),
321
+		'sebastian/recursion-context' => array(
322
+			'pretty_version' => '4.0.4',
323
+			'version' => '4.0.4.0',
324
+			'type' => 'library',
325
+			'install_path' => __DIR__ . '/../sebastian/recursion-context',
326
+			'aliases' => array(),
327
+			'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172',
328
+			'dev_requirement' => true,
329
+		),
330
+		'sebastian/resource-operations' => array(
331
+			'pretty_version' => '3.0.3',
332
+			'version' => '3.0.3.0',
333
+			'type' => 'library',
334
+			'install_path' => __DIR__ . '/../sebastian/resource-operations',
335
+			'aliases' => array(),
336
+			'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8',
337
+			'dev_requirement' => true,
338
+		),
339
+		'sebastian/type' => array(
340
+			'pretty_version' => '3.0.0',
341
+			'version' => '3.0.0.0',
342
+			'type' => 'library',
343
+			'install_path' => __DIR__ . '/../sebastian/type',
344
+			'aliases' => array(),
345
+			'reference' => 'b233b84bc4465aff7b57cf1c4bc75c86d00d6dad',
346
+			'dev_requirement' => true,
347
+		),
348
+		'sebastian/version' => array(
349
+			'pretty_version' => '3.0.2',
350
+			'version' => '3.0.2.0',
351
+			'type' => 'library',
352
+			'install_path' => __DIR__ . '/../sebastian/version',
353
+			'aliases' => array(),
354
+			'reference' => 'c6c1022351a901512170118436c764e473f6de8c',
355
+			'dev_requirement' => true,
356
+		),
357
+		'squizlabs/php_codesniffer' => array(
358
+			'pretty_version' => '3.6.2',
359
+			'version' => '3.6.2.0',
360
+			'type' => 'library',
361
+			'install_path' => __DIR__ . '/../squizlabs/php_codesniffer',
362
+			'aliases' => array(),
363
+			'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a',
364
+			'dev_requirement' => true,
365
+		),
366
+		'symfony/polyfill-ctype' => array(
367
+			'pretty_version' => 'v1.25.0',
368
+			'version' => '1.25.0.0',
369
+			'type' => 'library',
370
+			'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
371
+			'aliases' => array(),
372
+			'reference' => '30885182c981ab175d4d034db0f6f469898070ab',
373
+			'dev_requirement' => true,
374
+		),
375
+		'theseer/tokenizer' => array(
376
+			'pretty_version' => '1.2.1',
377
+			'version' => '1.2.1.0',
378
+			'type' => 'library',
379
+			'install_path' => __DIR__ . '/../theseer/tokenizer',
380
+			'aliases' => array(),
381
+			'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e',
382
+			'dev_requirement' => true,
383
+		),
384
+		'webmozart/assert' => array(
385
+			'pretty_version' => '1.10.0',
386
+			'version' => '1.10.0.0',
387
+			'type' => 'library',
388
+			'install_path' => __DIR__ . '/../webmozart/assert',
389
+			'aliases' => array(),
390
+			'reference' => '6964c76c7804814a842473e0c8fd15bab0f18e25',
391
+			'dev_requirement' => true,
392
+		),
393
+		'wp-coding-standards/wpcs' => array(
394
+			'pretty_version' => '2.3.0',
395
+			'version' => '2.3.0.0',
396
+			'type' => 'phpcodesniffer-standard',
397
+			'install_path' => __DIR__ . '/../wp-coding-standards/wpcs',
398
+			'aliases' => array(),
399
+			'reference' => '7da1894633f168fe244afc6de00d141f27517b62',
400
+			'dev_requirement' => true,
401
+		),
402
+		'yoast/phpunit-polyfills' => array(
403
+			'pretty_version' => '1.0.3',
404
+			'version' => '1.0.3.0',
405
+			'type' => 'library',
406
+			'install_path' => __DIR__ . '/../yoast/phpunit-polyfills',
407
+			'aliases' => array(),
408
+			'reference' => '5ea3536428944955f969bc764bbe09738e151ada',
409
+			'dev_requirement' => true,
410
+		),
411
+	),
412 412
 );
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
         'pretty_version' => 'dev-master',
4 4
         'version' => 'dev-master',
5 5
         'type' => 'wordpress-plugin',
6
-        'install_path' => __DIR__ . '/../../',
6
+        'install_path' => __DIR__.'/../../',
7 7
         'aliases' => array(),
8 8
         'reference' => '0e53f0e0064f5ede83f65f5db1f079e4e70ac602',
9 9
         'name' => 'eventespresso/event-espresso-core',
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
             'pretty_version' => 'v2.0.1',
15 15
             'version' => '2.0.1.0',
16 16
             'type' => 'composer-plugin',
17
-            'install_path' => __DIR__ . '/./installers',
17
+            'install_path' => __DIR__.'/./installers',
18 18
             'aliases' => array(),
19 19
             'reference' => 'a241e78aaeb09781f5f5b92ac01ffd13ab43e5e8',
20 20
             'dev_requirement' => false,
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             'pretty_version' => '1.4.1',
24 24
             'version' => '1.4.1.0',
25 25
             'type' => 'library',
26
-            'install_path' => __DIR__ . '/../doctrine/instantiator',
26
+            'install_path' => __DIR__.'/../doctrine/instantiator',
27 27
             'aliases' => array(),
28 28
             'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc',
29 29
             'dev_requirement' => true,
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             'pretty_version' => 'dev-master',
33 33
             'version' => 'dev-master',
34 34
             'type' => 'phpcodesniffer-standard',
35
-            'install_path' => __DIR__ . '/../eventespresso/ee-coding-standards',
35
+            'install_path' => __DIR__.'/../eventespresso/ee-coding-standards',
36 36
             'aliases' => array(
37 37
                 0 => '9999999-dev',
38 38
             ),
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             'pretty_version' => 'dev-master',
44 44
             'version' => 'dev-master',
45 45
             'type' => 'wordpress-plugin',
46
-            'install_path' => __DIR__ . '/../../',
46
+            'install_path' => __DIR__.'/../../',
47 47
             'aliases' => array(),
48 48
             'reference' => '0e53f0e0064f5ede83f65f5db1f079e4e70ac602',
49 49
             'dev_requirement' => false,
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             'pretty_version' => '1.11.0',
53 53
             'version' => '1.11.0.0',
54 54
             'type' => 'library',
55
-            'install_path' => __DIR__ . '/../myclabs/deep-copy',
55
+            'install_path' => __DIR__.'/../myclabs/deep-copy',
56 56
             'aliases' => array(),
57 57
             'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614',
58 58
             'dev_requirement' => true,
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             'pretty_version' => 'v4.13.2',
62 62
             'version' => '4.13.2.0',
63 63
             'type' => 'library',
64
-            'install_path' => __DIR__ . '/../nikic/php-parser',
64
+            'install_path' => __DIR__.'/../nikic/php-parser',
65 65
             'aliases' => array(),
66 66
             'reference' => '210577fe3cf7badcc5814d99455df46564f3c077',
67 67
             'dev_requirement' => true,
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             'pretty_version' => '2.0.3',
71 71
             'version' => '2.0.3.0',
72 72
             'type' => 'library',
73
-            'install_path' => __DIR__ . '/../phar-io/manifest',
73
+            'install_path' => __DIR__.'/../phar-io/manifest',
74 74
             'aliases' => array(),
75 75
             'reference' => '97803eca37d319dfa7826cc2437fc020857acb53',
76 76
             'dev_requirement' => true,
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             'pretty_version' => '3.2.1',
80 80
             'version' => '3.2.1.0',
81 81
             'type' => 'library',
82
-            'install_path' => __DIR__ . '/../phar-io/version',
82
+            'install_path' => __DIR__.'/../phar-io/version',
83 83
             'aliases' => array(),
84 84
             'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74',
85 85
             'dev_requirement' => true,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
             'pretty_version' => '9.3.5',
89 89
             'version' => '9.3.5.0',
90 90
             'type' => 'phpcodesniffer-standard',
91
-            'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility',
91
+            'install_path' => __DIR__.'/../phpcompatibility/php-compatibility',
92 92
             'aliases' => array(),
93 93
             'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243',
94 94
             'dev_requirement' => true,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             'pretty_version' => '1.3.1',
98 98
             'version' => '1.3.1.0',
99 99
             'type' => 'phpcodesniffer-standard',
100
-            'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie',
100
+            'install_path' => __DIR__.'/../phpcompatibility/phpcompatibility-paragonie',
101 101
             'aliases' => array(),
102 102
             'reference' => 'ddabec839cc003651f2ce695c938686d1086cf43',
103 103
             'dev_requirement' => true,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             'pretty_version' => '2.1.3',
107 107
             'version' => '2.1.3.0',
108 108
             'type' => 'phpcodesniffer-standard',
109
-            'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp',
109
+            'install_path' => __DIR__.'/../phpcompatibility/phpcompatibility-wp',
110 110
             'aliases' => array(),
111 111
             'reference' => 'd55de55f88697b9cdb94bccf04f14eb3b11cf308',
112 112
             'dev_requirement' => true,
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             'pretty_version' => '2.2.0',
116 116
             'version' => '2.2.0.0',
117 117
             'type' => 'library',
118
-            'install_path' => __DIR__ . '/../phpdocumentor/reflection-common',
118
+            'install_path' => __DIR__.'/../phpdocumentor/reflection-common',
119 119
             'aliases' => array(),
120 120
             'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b',
121 121
             'dev_requirement' => true,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             'pretty_version' => '5.3.0',
125 125
             'version' => '5.3.0.0',
126 126
             'type' => 'library',
127
-            'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock',
127
+            'install_path' => __DIR__.'/../phpdocumentor/reflection-docblock',
128 128
             'aliases' => array(),
129 129
             'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170',
130 130
             'dev_requirement' => true,
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             'pretty_version' => '1.6.0',
134 134
             'version' => '1.6.0.0',
135 135
             'type' => 'library',
136
-            'install_path' => __DIR__ . '/../phpdocumentor/type-resolver',
136
+            'install_path' => __DIR__.'/../phpdocumentor/type-resolver',
137 137
             'aliases' => array(),
138 138
             'reference' => '93ebd0014cab80c4ea9f5e297ea48672f1b87706',
139 139
             'dev_requirement' => true,
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
             'pretty_version' => 'v1.15.0',
143 143
             'version' => '1.15.0.0',
144 144
             'type' => 'library',
145
-            'install_path' => __DIR__ . '/../phpspec/prophecy',
145
+            'install_path' => __DIR__.'/../phpspec/prophecy',
146 146
             'aliases' => array(),
147 147
             'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13',
148 148
             'dev_requirement' => true,
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             'pretty_version' => '9.2.15',
152 152
             'version' => '9.2.15.0',
153 153
             'type' => 'library',
154
-            'install_path' => __DIR__ . '/../phpunit/php-code-coverage',
154
+            'install_path' => __DIR__.'/../phpunit/php-code-coverage',
155 155
             'aliases' => array(),
156 156
             'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f',
157 157
             'dev_requirement' => true,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             'pretty_version' => '3.0.6',
161 161
             'version' => '3.0.6.0',
162 162
             'type' => 'library',
163
-            'install_path' => __DIR__ . '/../phpunit/php-file-iterator',
163
+            'install_path' => __DIR__.'/../phpunit/php-file-iterator',
164 164
             'aliases' => array(),
165 165
             'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf',
166 166
             'dev_requirement' => true,
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             'pretty_version' => '3.1.1',
170 170
             'version' => '3.1.1.0',
171 171
             'type' => 'library',
172
-            'install_path' => __DIR__ . '/../phpunit/php-invoker',
172
+            'install_path' => __DIR__.'/../phpunit/php-invoker',
173 173
             'aliases' => array(),
174 174
             'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67',
175 175
             'dev_requirement' => true,
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             'pretty_version' => '2.0.4',
179 179
             'version' => '2.0.4.0',
180 180
             'type' => 'library',
181
-            'install_path' => __DIR__ . '/../phpunit/php-text-template',
181
+            'install_path' => __DIR__.'/../phpunit/php-text-template',
182 182
             'aliases' => array(),
183 183
             'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28',
184 184
             'dev_requirement' => true,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             'pretty_version' => '5.0.3',
188 188
             'version' => '5.0.3.0',
189 189
             'type' => 'library',
190
-            'install_path' => __DIR__ . '/../phpunit/php-timer',
190
+            'install_path' => __DIR__.'/../phpunit/php-timer',
191 191
             'aliases' => array(),
192 192
             'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2',
193 193
             'dev_requirement' => true,
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             'pretty_version' => '9.5.19',
197 197
             'version' => '9.5.19.0',
198 198
             'type' => 'library',
199
-            'install_path' => __DIR__ . '/../phpunit/phpunit',
199
+            'install_path' => __DIR__.'/../phpunit/phpunit',
200 200
             'aliases' => array(),
201 201
             'reference' => '35ea4b7f3acabb26f4bb640f8c30866c401da807',
202 202
             'dev_requirement' => true,
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             'pretty_version' => '1.0.1',
215 215
             'version' => '1.0.1.0',
216 216
             'type' => 'library',
217
-            'install_path' => __DIR__ . '/../sebastian/cli-parser',
217
+            'install_path' => __DIR__.'/../sebastian/cli-parser',
218 218
             'aliases' => array(),
219 219
             'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2',
220 220
             'dev_requirement' => true,
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
             'pretty_version' => '1.0.8',
224 224
             'version' => '1.0.8.0',
225 225
             'type' => 'library',
226
-            'install_path' => __DIR__ . '/../sebastian/code-unit',
226
+            'install_path' => __DIR__.'/../sebastian/code-unit',
227 227
             'aliases' => array(),
228 228
             'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120',
229 229
             'dev_requirement' => true,
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
             'pretty_version' => '2.0.3',
233 233
             'version' => '2.0.3.0',
234 234
             'type' => 'library',
235
-            'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup',
235
+            'install_path' => __DIR__.'/../sebastian/code-unit-reverse-lookup',
236 236
             'aliases' => array(),
237 237
             'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5',
238 238
             'dev_requirement' => true,
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             'pretty_version' => '4.0.6',
242 242
             'version' => '4.0.6.0',
243 243
             'type' => 'library',
244
-            'install_path' => __DIR__ . '/../sebastian/comparator',
244
+            'install_path' => __DIR__.'/../sebastian/comparator',
245 245
             'aliases' => array(),
246 246
             'reference' => '55f4261989e546dc112258c7a75935a81a7ce382',
247 247
             'dev_requirement' => true,
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             'pretty_version' => '2.0.2',
251 251
             'version' => '2.0.2.0',
252 252
             'type' => 'library',
253
-            'install_path' => __DIR__ . '/../sebastian/complexity',
253
+            'install_path' => __DIR__.'/../sebastian/complexity',
254 254
             'aliases' => array(),
255 255
             'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88',
256 256
             'dev_requirement' => true,
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             'pretty_version' => '4.0.4',
260 260
             'version' => '4.0.4.0',
261 261
             'type' => 'library',
262
-            'install_path' => __DIR__ . '/../sebastian/diff',
262
+            'install_path' => __DIR__.'/../sebastian/diff',
263 263
             'aliases' => array(),
264 264
             'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d',
265 265
             'dev_requirement' => true,
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
             'pretty_version' => '5.1.3',
269 269
             'version' => '5.1.3.0',
270 270
             'type' => 'library',
271
-            'install_path' => __DIR__ . '/../sebastian/environment',
271
+            'install_path' => __DIR__.'/../sebastian/environment',
272 272
             'aliases' => array(),
273 273
             'reference' => '388b6ced16caa751030f6a69e588299fa09200ac',
274 274
             'dev_requirement' => true,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             'pretty_version' => '4.0.4',
278 278
             'version' => '4.0.4.0',
279 279
             'type' => 'library',
280
-            'install_path' => __DIR__ . '/../sebastian/exporter',
280
+            'install_path' => __DIR__.'/../sebastian/exporter',
281 281
             'aliases' => array(),
282 282
             'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9',
283 283
             'dev_requirement' => true,
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
             'pretty_version' => '5.0.5',
287 287
             'version' => '5.0.5.0',
288 288
             'type' => 'library',
289
-            'install_path' => __DIR__ . '/../sebastian/global-state',
289
+            'install_path' => __DIR__.'/../sebastian/global-state',
290 290
             'aliases' => array(),
291 291
             'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2',
292 292
             'dev_requirement' => true,
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             'pretty_version' => '1.0.3',
296 296
             'version' => '1.0.3.0',
297 297
             'type' => 'library',
298
-            'install_path' => __DIR__ . '/../sebastian/lines-of-code',
298
+            'install_path' => __DIR__.'/../sebastian/lines-of-code',
299 299
             'aliases' => array(),
300 300
             'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc',
301 301
             'dev_requirement' => true,
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             'pretty_version' => '4.0.4',
305 305
             'version' => '4.0.4.0',
306 306
             'type' => 'library',
307
-            'install_path' => __DIR__ . '/../sebastian/object-enumerator',
307
+            'install_path' => __DIR__.'/../sebastian/object-enumerator',
308 308
             'aliases' => array(),
309 309
             'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71',
310 310
             'dev_requirement' => true,
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
             'pretty_version' => '2.0.4',
314 314
             'version' => '2.0.4.0',
315 315
             'type' => 'library',
316
-            'install_path' => __DIR__ . '/../sebastian/object-reflector',
316
+            'install_path' => __DIR__.'/../sebastian/object-reflector',
317 317
             'aliases' => array(),
318 318
             'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7',
319 319
             'dev_requirement' => true,
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
             'pretty_version' => '4.0.4',
323 323
             'version' => '4.0.4.0',
324 324
             'type' => 'library',
325
-            'install_path' => __DIR__ . '/../sebastian/recursion-context',
325
+            'install_path' => __DIR__.'/../sebastian/recursion-context',
326 326
             'aliases' => array(),
327 327
             'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172',
328 328
             'dev_requirement' => true,
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
             'pretty_version' => '3.0.3',
332 332
             'version' => '3.0.3.0',
333 333
             'type' => 'library',
334
-            'install_path' => __DIR__ . '/../sebastian/resource-operations',
334
+            'install_path' => __DIR__.'/../sebastian/resource-operations',
335 335
             'aliases' => array(),
336 336
             'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8',
337 337
             'dev_requirement' => true,
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             'pretty_version' => '3.0.0',
341 341
             'version' => '3.0.0.0',
342 342
             'type' => 'library',
343
-            'install_path' => __DIR__ . '/../sebastian/type',
343
+            'install_path' => __DIR__.'/../sebastian/type',
344 344
             'aliases' => array(),
345 345
             'reference' => 'b233b84bc4465aff7b57cf1c4bc75c86d00d6dad',
346 346
             'dev_requirement' => true,
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             'pretty_version' => '3.0.2',
350 350
             'version' => '3.0.2.0',
351 351
             'type' => 'library',
352
-            'install_path' => __DIR__ . '/../sebastian/version',
352
+            'install_path' => __DIR__.'/../sebastian/version',
353 353
             'aliases' => array(),
354 354
             'reference' => 'c6c1022351a901512170118436c764e473f6de8c',
355 355
             'dev_requirement' => true,
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
             'pretty_version' => '3.6.2',
359 359
             'version' => '3.6.2.0',
360 360
             'type' => 'library',
361
-            'install_path' => __DIR__ . '/../squizlabs/php_codesniffer',
361
+            'install_path' => __DIR__.'/../squizlabs/php_codesniffer',
362 362
             'aliases' => array(),
363 363
             'reference' => '5e4e71592f69da17871dba6e80dd51bce74a351a',
364 364
             'dev_requirement' => true,
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
             'pretty_version' => 'v1.25.0',
368 368
             'version' => '1.25.0.0',
369 369
             'type' => 'library',
370
-            'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
370
+            'install_path' => __DIR__.'/../symfony/polyfill-ctype',
371 371
             'aliases' => array(),
372 372
             'reference' => '30885182c981ab175d4d034db0f6f469898070ab',
373 373
             'dev_requirement' => true,
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
             'pretty_version' => '1.2.1',
377 377
             'version' => '1.2.1.0',
378 378
             'type' => 'library',
379
-            'install_path' => __DIR__ . '/../theseer/tokenizer',
379
+            'install_path' => __DIR__.'/../theseer/tokenizer',
380 380
             'aliases' => array(),
381 381
             'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e',
382 382
             'dev_requirement' => true,
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
             'pretty_version' => '1.10.0',
386 386
             'version' => '1.10.0.0',
387 387
             'type' => 'library',
388
-            'install_path' => __DIR__ . '/../webmozart/assert',
388
+            'install_path' => __DIR__.'/../webmozart/assert',
389 389
             'aliases' => array(),
390 390
             'reference' => '6964c76c7804814a842473e0c8fd15bab0f18e25',
391 391
             'dev_requirement' => true,
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
             'pretty_version' => '2.3.0',
395 395
             'version' => '2.3.0.0',
396 396
             'type' => 'phpcodesniffer-standard',
397
-            'install_path' => __DIR__ . '/../wp-coding-standards/wpcs',
397
+            'install_path' => __DIR__.'/../wp-coding-standards/wpcs',
398 398
             'aliases' => array(),
399 399
             'reference' => '7da1894633f168fe244afc6de00d141f27517b62',
400 400
             'dev_requirement' => true,
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             'pretty_version' => '1.0.3',
404 404
             'version' => '1.0.3.0',
405 405
             'type' => 'library',
406
-            'install_path' => __DIR__ . '/../yoast/phpunit-polyfills',
406
+            'install_path' => __DIR__.'/../yoast/phpunit-polyfills',
407 407
             'aliases' => array(),
408 408
             'reference' => '5ea3536428944955f969bc764bbe09738e151ada',
409 409
             'dev_requirement' => true,
Please login to merge, or discard this patch.