Completed
Branch fix-dummy-related-question-qst... (e5efcf)
by
unknown
07:49 queued 03:45
created
admin_pages/messages/templates/ee_msg_messages_help_tab.template.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <h2><?php esc_html_e('What is the Event Espresso Messages System?', 'event_espresso'); ?></h2>
2 2
 <p>
3 3
     <?php printf(
4
-        esc_html__(
5
-            'The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.',
6
-            'event_espresso'
7
-        ),
8
-        '<strong>',
9
-        '</strong>'
10
-    ); ?>
4
+		esc_html__(
5
+			'The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.',
6
+			'event_espresso'
7
+		),
8
+		'<strong>',
9
+		'</strong>'
10
+	); ?>
11 11
 </p>
12 12
 <p>
13 13
     <?php esc_html_e(
14
-        'We\'ve intentionally created this framework so that we have as much flexibility as possible for future ideas that we think of (or customers think of) for the kinds of messages that get sent out related to your events.',
15
-        'event_espresso'
16
-    ); ?>
14
+		'We\'ve intentionally created this framework so that we have as much flexibility as possible for future ideas that we think of (or customers think of) for the kinds of messages that get sent out related to your events.',
15
+		'event_espresso'
16
+	); ?>
17 17
 </p>
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Template_List_Table.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function _setup_data()
35 35
     {
36
-        $this->_data           = $this->get_admin_page()->get_message_templates(
36
+        $this->_data = $this->get_admin_page()->get_message_templates(
37 37
             $this->_per_page,
38 38
             $this->_view
39 39
         );
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             'ajax'     => true, // for now,
58 58
             'screen'   => $this->get_admin_page()->get_current_screen()->id,
59 59
         ];
60
-        $this->_columns      = [
60
+        $this->_columns = [
61 61
             // 'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
62 62
             'message_type' => esc_html__('Message Type', 'event_espresso'),
63 63
             'messenger'    => esc_html__('Messenger', 'event_espresso'),
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     protected function _add_view_counts()
139 139
     {
140 140
         foreach ($this->_views as $view => $args) {
141
-            $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
+            $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates(
142 142
                 $this->_per_page,
143 143
                 $view,
144 144
                 true,
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function column_description($item)
167 167
     {
168
-        return '<p>' . $item->message_type_obj()->description . '</p>';
168
+        return '<p>'.$item->message_type_obj()->description.'</p>';
169 169
     }
170 170
 
171 171
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                 $messenger_label                      = $messenger instanceof EE_messenger
232 232
                     ? $messenger->label['singular']
233 233
                     : $messenger_name;
234
-                $messenger_options[ $messenger_name ] = ucwords($messenger_label);
234
+                $messenger_options[$messenger_name] = ucwords($messenger_label);
235 235
             }
236 236
         }
237 237
         return $this->get_admin_page()->get_messengers_select_input($messenger_options);
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
                 $message_type_label                         = $message_type instanceof EE_message_type
266 266
                     ? $message_type->label['singular']
267 267
                     : $message_type_name;
268
-                $message_type_options[ $message_type_name ] = ucwords($message_type_label);
268
+                $message_type_options[$message_type_name] = ucwords($message_type_label);
269 269
             }
270 270
         }
271 271
         return $this->get_admin_page()->get_message_types_select_input($message_type_options);
@@ -331,20 +331,20 @@  discard block
 block discarded – undo
331 331
         $context_array     = [];
332 332
         $context_templates = $item->context_templates();
333 333
         foreach ($context_templates as $context => $template_fields) {
334
-            $mtp_to          = ! empty($template_fields['to'])
334
+            $mtp_to = ! empty($template_fields['to'])
335 335
                                && $template_fields['to'] instanceof EE_Message_Template
336 336
                 ? $template_fields['to']->get('MTP_content')
337 337
                 : null;
338
-            $inactive_class  = (empty($mtp_to) && ! empty($template_fields['to']))
338
+            $inactive_class = (empty($mtp_to) && ! empty($template_fields['to']))
339 339
                                || ! $item->is_context_active($context)
340 340
                 ? ' mtp-inactive'
341 341
                 : '';
342
-            $context_title   = sprintf(
342
+            $context_title = sprintf(
343 343
             /* translators: Placeholder represents the context label. Example "Edit Event Admin" */
344 344
                 esc_html__('Edit %1$s', 'event_espresso'),
345
-                ucwords($c_configs[ $context ]['label'])
345
+                ucwords($c_configs[$context]['label'])
346 346
             );
347
-            $edit_link       = EE_Admin_Page::add_query_args_and_nonce(
347
+            $edit_link = EE_Admin_Page::add_query_args_and_nonce(
348 348
                 [
349 349
                     'action'  => 'edit_message_template',
350 350
                     'id'      => $item->GRP_ID(),
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
                 ],
353 353
                 EE_MSG_ADMIN_URL
354 354
             );
355
-            $context_array[] = '<a href="' . $edit_link . '"'
356
-                               . ' class="' . "{$item->message_type()}-{$context}-edit-link{$inactive_class}" . '"'
357
-                               . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
355
+            $context_array[] = '<a href="'.$edit_link.'"'
356
+                               . ' class="'."{$item->message_type()}-{$context}-edit-link{$inactive_class}".'"'
357
+                               . ' title="'.esc_attr__('Edit Context', 'event_espresso').'">'
358 358
                                . $context_title
359 359
                                . '</a>';
360 360
         }
361 361
 
362
-        return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $context_array);
362
+        return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])).implode(' | ', $context_array);
363 363
     }
364 364
 
365 365
 
Please login to merge, or discard this patch.
Indentation   +364 added lines, -364 removed lines patch added patch discarded remove patch
@@ -10,368 +10,368 @@
 block discarded – undo
10 10
  */
11 11
 class Messages_Template_List_Table extends EE_Admin_List_Table
12 12
 {
13
-    /**
14
-     * @var Messages_Admin_Page
15
-     */
16
-    protected $_admin_page;
17
-
18
-
19
-    /**
20
-     * @return Messages_Admin_Page
21
-     */
22
-    public function get_admin_page()
23
-    {
24
-        return $this->_admin_page;
25
-    }
26
-
27
-
28
-    /**
29
-     * Setup data object
30
-     *
31
-     * @throws EE_Error
32
-     */
33
-    protected function _setup_data()
34
-    {
35
-        $this->_data           = $this->get_admin_page()->get_message_templates(
36
-            $this->_per_page,
37
-            $this->_view
38
-        );
39
-        $this->_all_data_count = $this->get_admin_page()->get_message_templates(
40
-            $this->_per_page,
41
-            $this->_view,
42
-            true,
43
-            true
44
-        );
45
-    }
46
-
47
-
48
-    /**
49
-     * Set internal properties
50
-     */
51
-    protected function _set_properties()
52
-    {
53
-        $this->_wp_list_args = [
54
-            'singular' => esc_html__('Message Template Group', 'event_espresso'),
55
-            'plural'   => esc_html__('Message Template', 'event_espresso'),
56
-            'ajax'     => true, // for now,
57
-            'screen'   => $this->get_admin_page()->get_current_screen()->id,
58
-        ];
59
-        $this->_columns      = [
60
-            // 'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
61
-            'message_type' => esc_html__('Message Type', 'event_espresso'),
62
-            'messenger'    => esc_html__('Messenger', 'event_espresso'),
63
-            'description'  => esc_html__('Description', 'event_espresso'),
64
-        ];
65
-
66
-        $this->_sortable_columns = [
67
-            'messenger' => ['MTP_messenger' => true],
68
-        ];
69
-
70
-        $this->_hidden_columns = [];
71
-    }
72
-
73
-
74
-    /**
75
-     * Overriding the single_row method from parent to verify whether the $item has an accessible
76
-     * message_type or messenger object before generating the row.
77
-     *
78
-     * @param EE_Message_Template_Group $item
79
-     * @return void
80
-     * @throws EE_Error
81
-     */
82
-    public function single_row($item)
83
-    {
84
-        if (
85
-            ! $item->message_type_obj() instanceof EE_message_type
86
-            || ! $item->messenger_obj() instanceof EE_messenger
87
-        ) {
88
-            return;
89
-        }
90
-
91
-        parent::single_row($item);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return array
97
-     * @throws EE_Error
98
-     */
99
-    protected function _get_table_filters()
100
-    {
101
-        $filters = [];
102
-
103
-        // get select inputs
104
-        $select_inputs = [
105
-            $this->_get_messengers_dropdown_filter(),
106
-            $this->_get_message_types_dropdown_filter(),
107
-        ];
108
-
109
-        // set filters to select inputs if they aren't empty
110
-        foreach ($select_inputs as $select_input) {
111
-            if ($select_input) {
112
-                $filters[] = $select_input;
113
-            }
114
-        }
115
-        return $filters;
116
-    }
117
-
118
-
119
-    /**
120
-     * We're just removing the search box for message templates, not needed.
121
-     *
122
-     * @param string $text
123
-     * @param string $input_id
124
-     * @return string ;
125
-     */
126
-    public function search_box($text, $input_id)
127
-    {
128
-        return '';
129
-    }
130
-
131
-
132
-    /**
133
-     * Add counts to the _views property
134
-     *
135
-     * @throws EE_Error
136
-     */
137
-    protected function _add_view_counts()
138
-    {
139
-        foreach ($this->_views as $view => $args) {
140
-            $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
-                $this->_per_page,
142
-                $view,
143
-                true,
144
-                true
145
-            );
146
-        }
147
-    }
148
-
149
-
150
-    /**
151
-     * @param EE_Message_Template_Group $item
152
-     * @return string
153
-     */
154
-    public function column_cb($item)
155
-    {
156
-        return '';
157
-    }
158
-
159
-
160
-    /**
161
-     * @param EE_Message_Template_Group $item
162
-     * @return string
163
-     * @throws EE_Error
164
-     */
165
-    public function column_description($item)
166
-    {
167
-        return '<p>' . $item->message_type_obj()->description . '</p>';
168
-    }
169
-
170
-
171
-    /**
172
-     * @param EE_Message_Template_Group $item
173
-     * @return string
174
-     * @throws EE_Error
175
-     * @throws ReflectionException
176
-     */
177
-    public function column_messenger($item)
178
-    {
179
-        // Return the name contents
180
-        return sprintf(
181
-            '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
182
-            /* $1%s */
183
-            ucwords($item->messenger_obj()->label['singular']),
184
-            /* $2%s */
185
-            $item->GRP_ID(),
186
-            /* %4$s */
187
-            $this->_get_context_links($item),
188
-            $this->row_actions($this->_get_actions_for_messenger_column($item))
189
-        );
190
-    }
191
-
192
-
193
-    /**
194
-     * column_message_type
195
-     *
196
-     * @param EE_Message_Template_Group $item message info for the row
197
-     * @return string message_type name
198
-     * @throws EE_Error
199
-     */
200
-    public function column_message_type($item)
201
-    {
202
-        return ucwords($item->message_type_obj()->label['singular']);
203
-    }
204
-
205
-
206
-    /**
207
-     * Generate dropdown filter select input for messengers
208
-     *
209
-     * @param bool $global
210
-     * @return string
211
-     * @throws EE_Error
212
-     */
213
-    protected function _get_messengers_dropdown_filter($global = true)
214
-    {
215
-        $messenger_options                                   = [];
216
-        $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
217
-            [
218
-                [
219
-                    'MTP_is_active' => true,
220
-                    'MTP_is_global' => $global,
221
-                ],
222
-                'group_by' => 'MTP_messenger',
223
-            ]
224
-        );
225
-
226
-        foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
227
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
228
-                $messenger                            = $active_message_template_group->messenger_obj();
229
-                $messenger_name                       = $active_message_template_group->messenger();
230
-                $messenger_label                      = $messenger instanceof EE_messenger
231
-                    ? $messenger->label['singular']
232
-                    : $messenger_name;
233
-                $messenger_options[ $messenger_name ] = ucwords($messenger_label);
234
-            }
235
-        }
236
-        return $this->get_admin_page()->get_messengers_select_input($messenger_options);
237
-    }
238
-
239
-
240
-    /**
241
-     * Generate dropdown filter select input for message types
242
-     *
243
-     * @param bool $global
244
-     * @return string
245
-     * @throws EE_Error
246
-     */
247
-    protected function _get_message_types_dropdown_filter($global = true)
248
-    {
249
-        $message_type_options                                   = [];
250
-        $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
251
-            [
252
-                [
253
-                    'MTP_is_active' => true,
254
-                    'MTP_is_global' => $global,
255
-                ],
256
-                'group_by' => 'MTP_message_type',
257
-            ]
258
-        );
259
-
260
-        foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
261
-            if ($active_message_template_group instanceof EE_Message_Template_Group) {
262
-                $message_type                               = $active_message_template_group->message_type_obj();
263
-                $message_type_name                          = $active_message_template_group->message_type();
264
-                $message_type_label                         = $message_type instanceof EE_message_type
265
-                    ? $message_type->label['singular']
266
-                    : $message_type_name;
267
-                $message_type_options[ $message_type_name ] = ucwords($message_type_label);
268
-            }
269
-        }
270
-        return $this->get_admin_page()->get_message_types_select_input($message_type_options);
271
-    }
272
-
273
-
274
-    /**
275
-     * Return the edit url for the message template group.
276
-     *
277
-     * @param EE_Message_Template_Group $item
278
-     * @return string
279
-     * @throws EE_Error
280
-     * @throws ReflectionException
281
-     */
282
-    protected function _get_edit_url(EE_Message_Template_Group $item)
283
-    {
284
-        $edit_url = '';
285
-        // edit link but only if item isn't trashed.
286
-        if (
287
-            ! $item->get('MTP_deleted')
288
-            && EE_Registry::instance()->CAP->current_user_can(
289
-                'ee_edit_message',
290
-                'espresso_messages_edit_message_template',
291
-                $item->ID()
292
-            )
293
-        ) {
294
-            $edit_url = EE_Admin_Page::add_query_args_and_nonce(
295
-                [
296
-                    'action' => 'edit_message_template',
297
-                    'id'     => $item->GRP_ID(),
298
-                ],
299
-                EE_MSG_ADMIN_URL
300
-            );
301
-        }
302
-        return $edit_url;
303
-    }
304
-
305
-
306
-    /**
307
-     * Get the context link string for the messenger column.
308
-     *
309
-     * @param EE_Message_Template_Group $item
310
-     * @return string
311
-     * @throws EE_Error
312
-     * @throws ReflectionException
313
-     */
314
-    protected function _get_context_links(EE_Message_Template_Group $item)
315
-    {
316
-        // first check if we even show the context links or not.
317
-        if (
318
-            ! EE_Registry::instance()->CAP->current_user_can(
319
-                'ee_edit_message',
320
-                'espresso_messages_edit_message_template',
321
-                $item->ID()
322
-            )
323
-            || $item->get('MTP_deleted')
324
-        ) {
325
-            return '';
326
-        }
327
-        // we want to display the contexts in here, so we need to set them up
328
-        $c_label           = $item->context_label();
329
-        $c_configs         = $item->contexts_config();
330
-        $context_array     = [];
331
-        $context_templates = $item->context_templates();
332
-        foreach ($context_templates as $context => $template_fields) {
333
-            $mtp_to          = ! empty($template_fields['to'])
334
-                               && $template_fields['to'] instanceof EE_Message_Template
335
-                ? $template_fields['to']->get('MTP_content')
336
-                : null;
337
-            $inactive_class  = (empty($mtp_to) && ! empty($template_fields['to']))
338
-                               || ! $item->is_context_active($context)
339
-                ? ' mtp-inactive'
340
-                : '';
341
-            $context_title   = sprintf(
342
-            /* translators: Placeholder represents the context label. Example "Edit Event Admin" */
343
-                esc_html__('Edit %1$s', 'event_espresso'),
344
-                ucwords($c_configs[ $context ]['label'])
345
-            );
346
-            $edit_link       = EE_Admin_Page::add_query_args_and_nonce(
347
-                [
348
-                    'action'  => 'edit_message_template',
349
-                    'id'      => $item->GRP_ID(),
350
-                    'context' => $context,
351
-                ],
352
-                EE_MSG_ADMIN_URL
353
-            );
354
-            $context_array[] = '<a href="' . $edit_link . '"'
355
-                               . ' class="' . "{$item->message_type()}-{$context}-edit-link{$inactive_class}" . '"'
356
-                               . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
357
-                               . $context_title
358
-                               . '</a>';
359
-        }
360
-
361
-        return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $context_array);
362
-    }
363
-
364
-
365
-    /**
366
-     * Returns the actions for the messenger column.
367
-     *
368
-     * Note: Children classes may override this, so do not remove it.
369
-     *
370
-     * @param EE_Message_Template_Group $item
371
-     * @return array
372
-     */
373
-    protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
374
-    {
375
-        return [];
376
-    }
13
+	/**
14
+	 * @var Messages_Admin_Page
15
+	 */
16
+	protected $_admin_page;
17
+
18
+
19
+	/**
20
+	 * @return Messages_Admin_Page
21
+	 */
22
+	public function get_admin_page()
23
+	{
24
+		return $this->_admin_page;
25
+	}
26
+
27
+
28
+	/**
29
+	 * Setup data object
30
+	 *
31
+	 * @throws EE_Error
32
+	 */
33
+	protected function _setup_data()
34
+	{
35
+		$this->_data           = $this->get_admin_page()->get_message_templates(
36
+			$this->_per_page,
37
+			$this->_view
38
+		);
39
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates(
40
+			$this->_per_page,
41
+			$this->_view,
42
+			true,
43
+			true
44
+		);
45
+	}
46
+
47
+
48
+	/**
49
+	 * Set internal properties
50
+	 */
51
+	protected function _set_properties()
52
+	{
53
+		$this->_wp_list_args = [
54
+			'singular' => esc_html__('Message Template Group', 'event_espresso'),
55
+			'plural'   => esc_html__('Message Template', 'event_espresso'),
56
+			'ajax'     => true, // for now,
57
+			'screen'   => $this->get_admin_page()->get_current_screen()->id,
58
+		];
59
+		$this->_columns      = [
60
+			// 'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
61
+			'message_type' => esc_html__('Message Type', 'event_espresso'),
62
+			'messenger'    => esc_html__('Messenger', 'event_espresso'),
63
+			'description'  => esc_html__('Description', 'event_espresso'),
64
+		];
65
+
66
+		$this->_sortable_columns = [
67
+			'messenger' => ['MTP_messenger' => true],
68
+		];
69
+
70
+		$this->_hidden_columns = [];
71
+	}
72
+
73
+
74
+	/**
75
+	 * Overriding the single_row method from parent to verify whether the $item has an accessible
76
+	 * message_type or messenger object before generating the row.
77
+	 *
78
+	 * @param EE_Message_Template_Group $item
79
+	 * @return void
80
+	 * @throws EE_Error
81
+	 */
82
+	public function single_row($item)
83
+	{
84
+		if (
85
+			! $item->message_type_obj() instanceof EE_message_type
86
+			|| ! $item->messenger_obj() instanceof EE_messenger
87
+		) {
88
+			return;
89
+		}
90
+
91
+		parent::single_row($item);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return array
97
+	 * @throws EE_Error
98
+	 */
99
+	protected function _get_table_filters()
100
+	{
101
+		$filters = [];
102
+
103
+		// get select inputs
104
+		$select_inputs = [
105
+			$this->_get_messengers_dropdown_filter(),
106
+			$this->_get_message_types_dropdown_filter(),
107
+		];
108
+
109
+		// set filters to select inputs if they aren't empty
110
+		foreach ($select_inputs as $select_input) {
111
+			if ($select_input) {
112
+				$filters[] = $select_input;
113
+			}
114
+		}
115
+		return $filters;
116
+	}
117
+
118
+
119
+	/**
120
+	 * We're just removing the search box for message templates, not needed.
121
+	 *
122
+	 * @param string $text
123
+	 * @param string $input_id
124
+	 * @return string ;
125
+	 */
126
+	public function search_box($text, $input_id)
127
+	{
128
+		return '';
129
+	}
130
+
131
+
132
+	/**
133
+	 * Add counts to the _views property
134
+	 *
135
+	 * @throws EE_Error
136
+	 */
137
+	protected function _add_view_counts()
138
+	{
139
+		foreach ($this->_views as $view => $args) {
140
+			$this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates(
141
+				$this->_per_page,
142
+				$view,
143
+				true,
144
+				true
145
+			);
146
+		}
147
+	}
148
+
149
+
150
+	/**
151
+	 * @param EE_Message_Template_Group $item
152
+	 * @return string
153
+	 */
154
+	public function column_cb($item)
155
+	{
156
+		return '';
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param EE_Message_Template_Group $item
162
+	 * @return string
163
+	 * @throws EE_Error
164
+	 */
165
+	public function column_description($item)
166
+	{
167
+		return '<p>' . $item->message_type_obj()->description . '</p>';
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param EE_Message_Template_Group $item
173
+	 * @return string
174
+	 * @throws EE_Error
175
+	 * @throws ReflectionException
176
+	 */
177
+	public function column_messenger($item)
178
+	{
179
+		// Return the name contents
180
+		return sprintf(
181
+			'%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s',
182
+			/* $1%s */
183
+			ucwords($item->messenger_obj()->label['singular']),
184
+			/* $2%s */
185
+			$item->GRP_ID(),
186
+			/* %4$s */
187
+			$this->_get_context_links($item),
188
+			$this->row_actions($this->_get_actions_for_messenger_column($item))
189
+		);
190
+	}
191
+
192
+
193
+	/**
194
+	 * column_message_type
195
+	 *
196
+	 * @param EE_Message_Template_Group $item message info for the row
197
+	 * @return string message_type name
198
+	 * @throws EE_Error
199
+	 */
200
+	public function column_message_type($item)
201
+	{
202
+		return ucwords($item->message_type_obj()->label['singular']);
203
+	}
204
+
205
+
206
+	/**
207
+	 * Generate dropdown filter select input for messengers
208
+	 *
209
+	 * @param bool $global
210
+	 * @return string
211
+	 * @throws EE_Error
212
+	 */
213
+	protected function _get_messengers_dropdown_filter($global = true)
214
+	{
215
+		$messenger_options                                   = [];
216
+		$active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all(
217
+			[
218
+				[
219
+					'MTP_is_active' => true,
220
+					'MTP_is_global' => $global,
221
+				],
222
+				'group_by' => 'MTP_messenger',
223
+			]
224
+		);
225
+
226
+		foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) {
227
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
228
+				$messenger                            = $active_message_template_group->messenger_obj();
229
+				$messenger_name                       = $active_message_template_group->messenger();
230
+				$messenger_label                      = $messenger instanceof EE_messenger
231
+					? $messenger->label['singular']
232
+					: $messenger_name;
233
+				$messenger_options[ $messenger_name ] = ucwords($messenger_label);
234
+			}
235
+		}
236
+		return $this->get_admin_page()->get_messengers_select_input($messenger_options);
237
+	}
238
+
239
+
240
+	/**
241
+	 * Generate dropdown filter select input for message types
242
+	 *
243
+	 * @param bool $global
244
+	 * @return string
245
+	 * @throws EE_Error
246
+	 */
247
+	protected function _get_message_types_dropdown_filter($global = true)
248
+	{
249
+		$message_type_options                                   = [];
250
+		$active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all(
251
+			[
252
+				[
253
+					'MTP_is_active' => true,
254
+					'MTP_is_global' => $global,
255
+				],
256
+				'group_by' => 'MTP_message_type',
257
+			]
258
+		);
259
+
260
+		foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) {
261
+			if ($active_message_template_group instanceof EE_Message_Template_Group) {
262
+				$message_type                               = $active_message_template_group->message_type_obj();
263
+				$message_type_name                          = $active_message_template_group->message_type();
264
+				$message_type_label                         = $message_type instanceof EE_message_type
265
+					? $message_type->label['singular']
266
+					: $message_type_name;
267
+				$message_type_options[ $message_type_name ] = ucwords($message_type_label);
268
+			}
269
+		}
270
+		return $this->get_admin_page()->get_message_types_select_input($message_type_options);
271
+	}
272
+
273
+
274
+	/**
275
+	 * Return the edit url for the message template group.
276
+	 *
277
+	 * @param EE_Message_Template_Group $item
278
+	 * @return string
279
+	 * @throws EE_Error
280
+	 * @throws ReflectionException
281
+	 */
282
+	protected function _get_edit_url(EE_Message_Template_Group $item)
283
+	{
284
+		$edit_url = '';
285
+		// edit link but only if item isn't trashed.
286
+		if (
287
+			! $item->get('MTP_deleted')
288
+			&& EE_Registry::instance()->CAP->current_user_can(
289
+				'ee_edit_message',
290
+				'espresso_messages_edit_message_template',
291
+				$item->ID()
292
+			)
293
+		) {
294
+			$edit_url = EE_Admin_Page::add_query_args_and_nonce(
295
+				[
296
+					'action' => 'edit_message_template',
297
+					'id'     => $item->GRP_ID(),
298
+				],
299
+				EE_MSG_ADMIN_URL
300
+			);
301
+		}
302
+		return $edit_url;
303
+	}
304
+
305
+
306
+	/**
307
+	 * Get the context link string for the messenger column.
308
+	 *
309
+	 * @param EE_Message_Template_Group $item
310
+	 * @return string
311
+	 * @throws EE_Error
312
+	 * @throws ReflectionException
313
+	 */
314
+	protected function _get_context_links(EE_Message_Template_Group $item)
315
+	{
316
+		// first check if we even show the context links or not.
317
+		if (
318
+			! EE_Registry::instance()->CAP->current_user_can(
319
+				'ee_edit_message',
320
+				'espresso_messages_edit_message_template',
321
+				$item->ID()
322
+			)
323
+			|| $item->get('MTP_deleted')
324
+		) {
325
+			return '';
326
+		}
327
+		// we want to display the contexts in here, so we need to set them up
328
+		$c_label           = $item->context_label();
329
+		$c_configs         = $item->contexts_config();
330
+		$context_array     = [];
331
+		$context_templates = $item->context_templates();
332
+		foreach ($context_templates as $context => $template_fields) {
333
+			$mtp_to          = ! empty($template_fields['to'])
334
+							   && $template_fields['to'] instanceof EE_Message_Template
335
+				? $template_fields['to']->get('MTP_content')
336
+				: null;
337
+			$inactive_class  = (empty($mtp_to) && ! empty($template_fields['to']))
338
+							   || ! $item->is_context_active($context)
339
+				? ' mtp-inactive'
340
+				: '';
341
+			$context_title   = sprintf(
342
+			/* translators: Placeholder represents the context label. Example "Edit Event Admin" */
343
+				esc_html__('Edit %1$s', 'event_espresso'),
344
+				ucwords($c_configs[ $context ]['label'])
345
+			);
346
+			$edit_link       = EE_Admin_Page::add_query_args_and_nonce(
347
+				[
348
+					'action'  => 'edit_message_template',
349
+					'id'      => $item->GRP_ID(),
350
+					'context' => $context,
351
+				],
352
+				EE_MSG_ADMIN_URL
353
+			);
354
+			$context_array[] = '<a href="' . $edit_link . '"'
355
+							   . ' class="' . "{$item->message_type()}-{$context}-edit-link{$inactive_class}" . '"'
356
+							   . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">'
357
+							   . $context_title
358
+							   . '</a>';
359
+		}
360
+
361
+		return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $context_array);
362
+	}
363
+
364
+
365
+	/**
366
+	 * Returns the actions for the messenger column.
367
+	 *
368
+	 * Note: Children classes may override this, so do not remove it.
369
+	 *
370
+	 * @param EE_Message_Template_Group $item
371
+	 * @return array
372
+	 */
373
+	protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item)
374
+	{
375
+		return [];
376
+	}
377 377
 }
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_overview_views.help_tab.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <p><strong><?php esc_html_e('Message Views', 'event_espresso'); ?></strong></p>
2 2
 <p>
3 3
     <?php esc_html_e(
4
-        'Views allow you to restrict what you see in the Messages Overview table. The number in parentheses next to each view represents the number of message templates that will be displayed with that view.',
5
-        'event_espresso'
6
-    ); ?>
4
+		'Views allow you to restrict what you see in the Messages Overview table. The number in parentheses next to each view represents the number of message templates that will be displayed with that view.',
5
+		'event_espresso'
6
+	); ?>
7 7
 </p>
8 8
 <ul>
9 9
     <li>
Please login to merge, or discard this patch.
messages/help_tabs/messages_overview_table_column_headings.help_tab.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
     <li>
8 8
         <strong><?php esc_html_e('Messenger', 'event_espresso'); ?></strong><br />
9 9
         <?php esc_html_e(
10
-            'Shows the Messenger that will handle the delivery of messages. Hovering over the Messenger will provide you with an additional option to Edit the current message template. Clicking on Email will take you to the Message Templates Editor so you can edit the message template for an Event Admin. Clicking on Event Admin will also take you to the Message Templates Editor. Clicking on Primary Registrant will take you to the Message Templates Editor so that you can edit the message template that is sent to the Primary Registrant. Clicking on the Edit link will also take you to the Message Templates Editor so that you can edit the message template that is sent to the Event Admin.',
11
-            'event_espresso'
12
-        ); ?>
10
+			'Shows the Messenger that will handle the delivery of messages. Hovering over the Messenger will provide you with an additional option to Edit the current message template. Clicking on Email will take you to the Message Templates Editor so you can edit the message template for an Event Admin. Clicking on Event Admin will also take you to the Message Templates Editor. Clicking on Primary Registrant will take you to the Message Templates Editor so that you can edit the message template that is sent to the Primary Registrant. Clicking on the Edit link will also take you to the Message Templates Editor so that you can edit the message template that is sent to the Event Admin.',
11
+			'event_espresso'
12
+		); ?>
13 13
     </li>
14 14
     <li>
15 15
         <strong><?php esc_html_e('Description', 'event_espresso'); ?></strong><br />
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_overview_filters.help_tab.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <p><strong><?php esc_html_e('Message Filters', 'event_espresso'); ?></strong></p>
2 2
 <p>
3 3
     <?php esc_html_e(
4
-        'Filters are a way to show message templates that fall into certain criteria.',
5
-        'event_espresso'
6
-    ); ?>
4
+		'Filters are a way to show message templates that fall into certain criteria.',
5
+		'event_espresso'
6
+	); ?>
7 7
     <br />
8 8
 </p>
9 9
 <ul>
10 10
     <li>
11 11
         <strong><?php esc_html_e('Filter by Messengers', 'event_espresso'); ?></strong><br />
12 12
         <?php esc_html_e(
13
-            'Select a messenger type and then click the button to enable that filter.',
14
-            'event_espresso'
15
-        ); ?>
13
+			'Select a messenger type and then click the button to enable that filter.',
14
+			'event_espresso'
15
+		); ?>
16 16
     </li>
17 17
     <li>
18 18
         <strong><?php esc_html_e('Filter by Message Types', 'event_espresso'); ?></strong><br />
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_templates.help_tab.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -3,25 +3,25 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php
6
-    printf(
7
-        esc_html__(
8
-            'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.',
9
-            'event_espresso'
10
-        ),
11
-        '<em>',
12
-        '</em>'
13
-    );
14
-    ?>
6
+	printf(
7
+		esc_html__(
8
+			'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.',
9
+			'event_espresso'
10
+		),
11
+		'<em>',
12
+		'</em>'
13
+	);
14
+	?>
15 15
 </p>
16 16
 <p>
17 17
     <?php esc_html_e(
18
-        'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant.  Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).',
19
-        'event_espresso'
20
-    ); ?>
18
+		'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant.  Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).',
19
+		'event_espresso'
20
+	); ?>
21 21
 </p>
22 22
 <p>
23 23
     <?php esc_html_e(
24
-        'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").',
25
-        'event_espresso'
26
-    ); ?>
24
+		'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").',
25
+		'event_espresso'
26
+	); ?>
27 27
 </p>
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_overview_other.help_tab.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'Bulk actions allow you to perform an action to multiple Message Types at once. The following bulk actions are supported: Move to Trash. To use the bulk action feature, place a checkmark next to the message types that you want to include. Then select a bulk action from the menu and click on the Apply button.',
7
-        'event_espresso'
8
-    ); ?>
6
+		'Bulk actions allow you to perform an action to multiple Message Types at once. The following bulk actions are supported: Move to Trash. To use the bulk action feature, place a checkmark next to the message types that you want to include. Then select a bulk action from the menu and click on the Apply button.',
7
+		'event_espresso'
8
+	); ?>
9 9
 </p>
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_settings_message_types.help_tab.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'There may be times where you want to deactivate (or activate new) Message Types for a particular messenger. The messages system makes it easy to do so. To deactivate a Message Type, drag the message type box from the "active area" into the "inactive" area in the right sidebar. To re-activate, simply reverse your steps. Remember that when you deactivate a message type, if that message type has any settings, the settings will be lost. However, any message templates that match the messenger and message type you deactivated will be preserved, they are just marked "inactive" in the database.',
7
-        'event_espresso'
8
-    ); ?>
6
+		'There may be times where you want to deactivate (or activate new) Message Types for a particular messenger. The messages system makes it easy to do so. To deactivate a Message Type, drag the message type box from the "active area" into the "inactive" area in the right sidebar. To re-activate, simply reverse your steps. Remember that when you deactivate a message type, if that message type has any settings, the settings will be lost. However, any message templates that match the messenger and message type you deactivated will be preserved, they are just marked "inactive" in the database.',
7
+		'event_espresso'
8
+	); ?>
9 9
 </p>
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_preview.help_tab.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,48 +3,48 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'The Messages Preview page can be accessed by clicking the Preview button while editing a message template. This feature has been created as a way of previewing what the final generated messages will look like when received by a recipient.  Here\'s how the preview is prepared:',
7
-        'event_espresso'
8
-    ); ?>
6
+		'The Messages Preview page can be accessed by clicking the Preview button while editing a message template. This feature has been created as a way of previewing what the final generated messages will look like when received by a recipient.  Here\'s how the preview is prepared:',
7
+		'event_espresso'
8
+	); ?>
9 9
 </p>
10 10
 <p>
11 11
     <strong>
12 12
         <?php esc_html_e(
13
-            '1. The system retrieves the appropriate template based on the given messenger, message type, and context',
14
-            'event_espresso'
15
-        ); ?>
13
+			'1. The system retrieves the appropriate template based on the given messenger, message type, and context',
14
+			'event_espresso'
15
+		); ?>
16 16
     </strong>
17 17
 </p>
18 18
 <p>
19 19
     <?php esc_html_e(
20
-        'When you click the preview button, the messages system remembers what template is being "previewed" based on the messenger, message_type, context and event (if this is a custom event template).',
21
-        'event_espresso'
22
-    ); ?>
20
+		'When you click the preview button, the messages system remembers what template is being "previewed" based on the messenger, message_type, context and event (if this is a custom event template).',
21
+		'event_espresso'
22
+	); ?>
23 23
 </p>
24 24
 <p>
25 25
     <strong><?php esc_html_e('2. Setup data', 'event_espresso'); ?></strong>
26 26
 </p>
27 27
 <p>
28 28
     <?php esc_html_e(
29
-        'Before any shortcodes in the template can be parsed, the previewer needs to know what data to use for the shortcodes. Some of the data is dummy data that the previewer generates, but wherever possible the previewer will use actual data from your database. For example, all the organization shortcodes will use actual data you\'ve setup for your organization. For global template previews, the previewer will obtain the first active event from your database and use data from it. If you are previewing a custom event template then THAT event will be used for the preview. The only data that is dummy data is typically data that would be entered by a person registering for an event.',
30
-        'event_espresso'
31
-    ); ?>
29
+		'Before any shortcodes in the template can be parsed, the previewer needs to know what data to use for the shortcodes. Some of the data is dummy data that the previewer generates, but wherever possible the previewer will use actual data from your database. For example, all the organization shortcodes will use actual data you\'ve setup for your organization. For global template previews, the previewer will obtain the first active event from your database and use data from it. If you are previewing a custom event template then THAT event will be used for the preview. The only data that is dummy data is typically data that would be entered by a person registering for an event.',
30
+		'event_espresso'
31
+	); ?>
32 32
 </p>
33 33
 <p>
34 34
     <strong><?php esc_html_e('3. Parse shortcodes', 'event_espresso'); ?></strong>
35 35
 </p>
36 36
 <p>
37 37
     <?php esc_html_e(
38
-        'The previewer then goes through all the shortcodes in the template being previewed and replaces them using the prepared data. This is a good way of making sure that the shortcodes are working as you expect, and also clearly seeing what is being displayed for that shortcode when someone receives that message.',
39
-        'event_espresso'
40
-    ); ?>
38
+		'The previewer then goes through all the shortcodes in the template being previewed and replaces them using the prepared data. This is a good way of making sure that the shortcodes are working as you expect, and also clearly seeing what is being displayed for that shortcode when someone receives that message.',
39
+		'event_espresso'
40
+	); ?>
41 41
 </p>
42 42
 <p>
43 43
     <strong><?php esc_html_e('4. Display the preview', 'event_espresso'); ?></strong>
44 44
 </p>
45 45
 <p>
46 46
     <?php esc_html_e(
47
-        'An important thing to remember about the previewer is that for the most part, the previewer uses the same underlying system that will be used for actual outgoing messages, so you can be certain that what you see in the preview is what users will see when they receive the message.  It is yet another tool provided to make it easier for you to customize the look of your outgoing messages.',
48
-        'event_espresso'
49
-    ); ?>
47
+		'An important thing to remember about the previewer is that for the most part, the previewer uses the same underlying system that will be used for actual outgoing messages, so you can be certain that what you see in the preview is what users will see when they receive the message.  It is yet another tool provided to make it easier for you to customize the look of your outgoing messages.',
48
+		'event_espresso'
49
+	); ?>
50 50
 </p>
51 51
\ No newline at end of file
Please login to merge, or discard this patch.