@@ -13,339 +13,339 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @return Messages_Admin_Page |
|
18 | - */ |
|
19 | - public function get_admin_page() |
|
20 | - { |
|
21 | - return $this->_admin_page; |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Setup data object |
|
27 | - */ |
|
28 | - protected function _setup_data() |
|
29 | - { |
|
30 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | - $this->_per_page, |
|
32 | - $this->_view, |
|
33 | - false |
|
34 | - ); |
|
35 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
36 | - $this->_per_page, |
|
37 | - $this->_view, |
|
38 | - true, |
|
39 | - true |
|
40 | - ); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Set internal properties |
|
46 | - */ |
|
47 | - protected function _set_properties() |
|
48 | - { |
|
49 | - $this->_wp_list_args = array( |
|
50 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
51 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
52 | - 'ajax' => true, // for now, |
|
53 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
54 | - ); |
|
55 | - $this->_columns = array( |
|
56 | - // 'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
|
57 | - 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
58 | - 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
59 | - 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | - ); |
|
61 | - |
|
62 | - $this->_sortable_columns = array( |
|
63 | - 'messenger' => array('MTP_messenger' => true), |
|
64 | - ); |
|
65 | - |
|
66 | - $this->_hidden_columns = array(); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Overriding the single_row method from parent to verify whether the $item has an accessible |
|
72 | - * message_type or messenger object before generating the row. |
|
73 | - * |
|
74 | - * @param EE_Message_Template_Group $item |
|
75 | - * @return string |
|
76 | - * @throws EE_Error |
|
77 | - */ |
|
78 | - public function single_row($item) |
|
79 | - { |
|
80 | - $message_type = $item->message_type_obj(); |
|
81 | - $messenger = $item->messenger_obj(); |
|
82 | - |
|
83 | - if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | - echo ''; |
|
85 | - return; |
|
86 | - } |
|
87 | - |
|
88 | - parent::single_row($item); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @return array |
|
94 | - * @throws EE_Error |
|
95 | - */ |
|
96 | - protected function _get_table_filters() |
|
97 | - { |
|
98 | - $filters = array(); |
|
99 | - |
|
100 | - // get select inputs |
|
101 | - $select_inputs = array( |
|
102 | - $this->_get_messengers_dropdown_filter(), |
|
103 | - $this->_get_message_types_dropdown_filter(), |
|
104 | - ); |
|
105 | - |
|
106 | - // set filters to select inputs if they aren't empty |
|
107 | - foreach ($select_inputs as $select_input) { |
|
108 | - if ($select_input) { |
|
109 | - $filters[] = $select_input; |
|
110 | - } |
|
111 | - } |
|
112 | - return $filters; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * We're just removing the search box for message templates, not needed. |
|
117 | - * |
|
118 | - * @param string $text |
|
119 | - * @param string $input_id |
|
120 | - * @return string ; |
|
121 | - */ |
|
122 | - public function search_box($text, $input_id) |
|
123 | - { |
|
124 | - return ''; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * Add counts to the _views property |
|
130 | - */ |
|
131 | - protected function _add_view_counts() |
|
132 | - { |
|
133 | - foreach ($this->_views as $view => $args) { |
|
134 | - $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
135 | - $this->_per_page, |
|
136 | - $view, |
|
137 | - true, |
|
138 | - true |
|
139 | - ); |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param EE_Message_Template_Group $item |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public function column_cb($item) |
|
149 | - { |
|
150 | - return ''; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @param EE_Message_Template_Group $item |
|
156 | - * @return string |
|
157 | - * @throws EE_Error |
|
158 | - */ |
|
159 | - public function column_description($item) |
|
160 | - { |
|
161 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @param EE_Message_Template_Group $item |
|
167 | - * @return string |
|
168 | - * @throws EE_Error |
|
169 | - */ |
|
170 | - public function column_messenger($item) |
|
171 | - { |
|
172 | - // Return the name contents |
|
173 | - return sprintf( |
|
174 | - '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s', |
|
175 | - /* $1%s */ |
|
176 | - ucwords($item->messenger_obj()->label['singular']), |
|
177 | - /* $2%s */ |
|
178 | - $item->GRP_ID(), |
|
179 | - /* %4$s */ |
|
180 | - $this->_get_context_links($item) |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * column_message_type |
|
186 | - * |
|
187 | - * @param EE_Message_Template_Group $item message info for the row |
|
188 | - * @return string message_type name |
|
189 | - * @throws EE_Error |
|
190 | - */ |
|
191 | - public function column_message_type($item) |
|
192 | - { |
|
193 | - return ucwords($item->message_type_obj()->label['singular']); |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * Generate dropdown filter select input for messengers |
|
199 | - * |
|
200 | - * @param bool $global |
|
201 | - * @return string |
|
202 | - * @throws EE_Error |
|
203 | - */ |
|
204 | - protected function _get_messengers_dropdown_filter($global = true) |
|
205 | - { |
|
206 | - $messenger_options = array(); |
|
207 | - $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
208 | - array( |
|
209 | - array( |
|
210 | - 'MTP_is_active' => true, |
|
211 | - 'MTP_is_global' => $global, |
|
212 | - ), |
|
213 | - 'group_by' => 'MTP_messenger', |
|
214 | - ) |
|
215 | - ); |
|
216 | - |
|
217 | - foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
218 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
219 | - $messenger = $active_message_template_group->messenger_obj(); |
|
220 | - $messenger_label = $messenger instanceof EE_messenger |
|
221 | - ? $messenger->label['singular'] |
|
222 | - : $active_message_template_group->messenger(); |
|
223 | - $messenger_options[ $active_message_template_group->messenger() ] = ucwords($messenger_label); |
|
224 | - } |
|
225 | - } |
|
226 | - return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * Generate dropdown filter select input for message types |
|
232 | - * |
|
233 | - * @param bool $global |
|
234 | - * @return string |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - protected function _get_message_types_dropdown_filter($global = true) |
|
238 | - { |
|
239 | - $message_type_options = array(); |
|
240 | - $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
241 | - array( |
|
242 | - array( |
|
243 | - 'MTP_is_active' => true, |
|
244 | - 'MTP_is_global' => true, |
|
245 | - ), |
|
246 | - 'group_by' => 'MTP_message_type', |
|
247 | - ) |
|
248 | - ); |
|
249 | - |
|
250 | - foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
251 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
252 | - $message_type = $active_message_template_group->message_type_obj(); |
|
253 | - $message_type_label = $message_type instanceof EE_message_type |
|
254 | - ? $message_type->label['singular'] |
|
255 | - : $active_message_template_group->message_type(); |
|
256 | - $message_type_options[ $active_message_template_group->message_type() ] = ucwords($message_type_label); |
|
257 | - } |
|
258 | - } |
|
259 | - return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * Return the edit url for the message template group. |
|
265 | - * |
|
266 | - * @param EE_Message_Template_Group $item |
|
267 | - * @return string |
|
268 | - * @throws EE_Error |
|
269 | - */ |
|
270 | - protected function _get_edit_url(EE_Message_Template_Group $item) |
|
271 | - { |
|
272 | - $edit_url = ''; |
|
273 | - // edit link but only if item isn't trashed. |
|
274 | - if (! $item->get('MTP_deleted') |
|
275 | - && EE_Registry::instance()->CAP->current_user_can( |
|
276 | - 'ee_edit_message', |
|
277 | - 'espresso_messages_edit_message_template', |
|
278 | - $item->ID() |
|
279 | - )) { |
|
280 | - $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
281 | - array( |
|
282 | - 'action' => 'edit_message_template', |
|
283 | - 'id' => $item->GRP_ID(), |
|
284 | - ), |
|
285 | - EE_MSG_ADMIN_URL |
|
286 | - ); |
|
287 | - } |
|
288 | - return $edit_url; |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * Get the context link string for the messenger column. |
|
294 | - * |
|
295 | - * @param EE_Message_Template_Group $item |
|
296 | - * @return string |
|
297 | - * @throws EE_Error |
|
298 | - */ |
|
299 | - protected function _get_context_links(EE_Message_Template_Group $item) |
|
300 | - { |
|
301 | - // first check if we even show the context links or not. |
|
302 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
303 | - 'ee_edit_message', |
|
304 | - 'espresso_messages_edit_message_template', |
|
305 | - $item->ID() |
|
306 | - ) |
|
307 | - || $item->get('MTP_deleted') |
|
308 | - ) { |
|
309 | - return ''; |
|
310 | - } |
|
311 | - // we want to display the contexts in here so we need to set them up |
|
312 | - $c_label = $item->context_label(); |
|
313 | - $c_configs = $item->contexts_config(); |
|
314 | - $ctxt = array(); |
|
315 | - $context_templates = $item->context_templates(); |
|
316 | - foreach ($context_templates as $context => $template_fields) { |
|
317 | - $mtp_to = ! empty($context_templates[ $context ]['to']) |
|
318 | - && $context_templates[ $context ]['to'] instanceof EE_Message_Template |
|
319 | - ? $context_templates[ $context ]['to']->get('MTP_content') |
|
320 | - : null; |
|
321 | - $inactive_class = ( |
|
322 | - empty($mtp_to) |
|
323 | - && ! empty($context_templates[ $context ]['to']) |
|
324 | - ) |
|
325 | - || ! $item->is_context_active($context) |
|
326 | - ? ' mtp-inactive' |
|
327 | - : ''; |
|
328 | - $context_title = sprintf( |
|
329 | - /* translators: Placeholder represents the context label. Example "Edit Event Admin" */ |
|
330 | - esc_html__('Edit %1$s', 'event_espresso'), |
|
331 | - ucwords($c_configs[ $context ]['label']) |
|
332 | - ); |
|
333 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
334 | - array( |
|
335 | - 'action' => 'edit_message_template', |
|
336 | - 'id' => $item->GRP_ID(), |
|
337 | - 'context' => $context, |
|
338 | - ), |
|
339 | - EE_MSG_ADMIN_URL |
|
340 | - ); |
|
341 | - $ctxt[] = '<a' |
|
342 | - . ' href="' . $edit_link . '"' |
|
343 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link' . $inactive_class . '"' |
|
344 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
345 | - . $context_title |
|
346 | - . '</a>'; |
|
347 | - } |
|
348 | - |
|
349 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
350 | - } |
|
16 | + /** |
|
17 | + * @return Messages_Admin_Page |
|
18 | + */ |
|
19 | + public function get_admin_page() |
|
20 | + { |
|
21 | + return $this->_admin_page; |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Setup data object |
|
27 | + */ |
|
28 | + protected function _setup_data() |
|
29 | + { |
|
30 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | + $this->_per_page, |
|
32 | + $this->_view, |
|
33 | + false |
|
34 | + ); |
|
35 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
36 | + $this->_per_page, |
|
37 | + $this->_view, |
|
38 | + true, |
|
39 | + true |
|
40 | + ); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Set internal properties |
|
46 | + */ |
|
47 | + protected function _set_properties() |
|
48 | + { |
|
49 | + $this->_wp_list_args = array( |
|
50 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
51 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
52 | + 'ajax' => true, // for now, |
|
53 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
54 | + ); |
|
55 | + $this->_columns = array( |
|
56 | + // 'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
|
57 | + 'message_type' => esc_html__('Message Type', 'event_espresso'), |
|
58 | + 'messenger' => esc_html__('Messenger', 'event_espresso'), |
|
59 | + 'description' => esc_html__('Description', 'event_espresso'), |
|
60 | + ); |
|
61 | + |
|
62 | + $this->_sortable_columns = array( |
|
63 | + 'messenger' => array('MTP_messenger' => true), |
|
64 | + ); |
|
65 | + |
|
66 | + $this->_hidden_columns = array(); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Overriding the single_row method from parent to verify whether the $item has an accessible |
|
72 | + * message_type or messenger object before generating the row. |
|
73 | + * |
|
74 | + * @param EE_Message_Template_Group $item |
|
75 | + * @return string |
|
76 | + * @throws EE_Error |
|
77 | + */ |
|
78 | + public function single_row($item) |
|
79 | + { |
|
80 | + $message_type = $item->message_type_obj(); |
|
81 | + $messenger = $item->messenger_obj(); |
|
82 | + |
|
83 | + if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | + echo ''; |
|
85 | + return; |
|
86 | + } |
|
87 | + |
|
88 | + parent::single_row($item); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + * @throws EE_Error |
|
95 | + */ |
|
96 | + protected function _get_table_filters() |
|
97 | + { |
|
98 | + $filters = array(); |
|
99 | + |
|
100 | + // get select inputs |
|
101 | + $select_inputs = array( |
|
102 | + $this->_get_messengers_dropdown_filter(), |
|
103 | + $this->_get_message_types_dropdown_filter(), |
|
104 | + ); |
|
105 | + |
|
106 | + // set filters to select inputs if they aren't empty |
|
107 | + foreach ($select_inputs as $select_input) { |
|
108 | + if ($select_input) { |
|
109 | + $filters[] = $select_input; |
|
110 | + } |
|
111 | + } |
|
112 | + return $filters; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * We're just removing the search box for message templates, not needed. |
|
117 | + * |
|
118 | + * @param string $text |
|
119 | + * @param string $input_id |
|
120 | + * @return string ; |
|
121 | + */ |
|
122 | + public function search_box($text, $input_id) |
|
123 | + { |
|
124 | + return ''; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * Add counts to the _views property |
|
130 | + */ |
|
131 | + protected function _add_view_counts() |
|
132 | + { |
|
133 | + foreach ($this->_views as $view => $args) { |
|
134 | + $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
135 | + $this->_per_page, |
|
136 | + $view, |
|
137 | + true, |
|
138 | + true |
|
139 | + ); |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param EE_Message_Template_Group $item |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public function column_cb($item) |
|
149 | + { |
|
150 | + return ''; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @param EE_Message_Template_Group $item |
|
156 | + * @return string |
|
157 | + * @throws EE_Error |
|
158 | + */ |
|
159 | + public function column_description($item) |
|
160 | + { |
|
161 | + return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @param EE_Message_Template_Group $item |
|
167 | + * @return string |
|
168 | + * @throws EE_Error |
|
169 | + */ |
|
170 | + public function column_messenger($item) |
|
171 | + { |
|
172 | + // Return the name contents |
|
173 | + return sprintf( |
|
174 | + '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s', |
|
175 | + /* $1%s */ |
|
176 | + ucwords($item->messenger_obj()->label['singular']), |
|
177 | + /* $2%s */ |
|
178 | + $item->GRP_ID(), |
|
179 | + /* %4$s */ |
|
180 | + $this->_get_context_links($item) |
|
181 | + ); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * column_message_type |
|
186 | + * |
|
187 | + * @param EE_Message_Template_Group $item message info for the row |
|
188 | + * @return string message_type name |
|
189 | + * @throws EE_Error |
|
190 | + */ |
|
191 | + public function column_message_type($item) |
|
192 | + { |
|
193 | + return ucwords($item->message_type_obj()->label['singular']); |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * Generate dropdown filter select input for messengers |
|
199 | + * |
|
200 | + * @param bool $global |
|
201 | + * @return string |
|
202 | + * @throws EE_Error |
|
203 | + */ |
|
204 | + protected function _get_messengers_dropdown_filter($global = true) |
|
205 | + { |
|
206 | + $messenger_options = array(); |
|
207 | + $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
208 | + array( |
|
209 | + array( |
|
210 | + 'MTP_is_active' => true, |
|
211 | + 'MTP_is_global' => $global, |
|
212 | + ), |
|
213 | + 'group_by' => 'MTP_messenger', |
|
214 | + ) |
|
215 | + ); |
|
216 | + |
|
217 | + foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
218 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
219 | + $messenger = $active_message_template_group->messenger_obj(); |
|
220 | + $messenger_label = $messenger instanceof EE_messenger |
|
221 | + ? $messenger->label['singular'] |
|
222 | + : $active_message_template_group->messenger(); |
|
223 | + $messenger_options[ $active_message_template_group->messenger() ] = ucwords($messenger_label); |
|
224 | + } |
|
225 | + } |
|
226 | + return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * Generate dropdown filter select input for message types |
|
232 | + * |
|
233 | + * @param bool $global |
|
234 | + * @return string |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + protected function _get_message_types_dropdown_filter($global = true) |
|
238 | + { |
|
239 | + $message_type_options = array(); |
|
240 | + $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
241 | + array( |
|
242 | + array( |
|
243 | + 'MTP_is_active' => true, |
|
244 | + 'MTP_is_global' => true, |
|
245 | + ), |
|
246 | + 'group_by' => 'MTP_message_type', |
|
247 | + ) |
|
248 | + ); |
|
249 | + |
|
250 | + foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
251 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
252 | + $message_type = $active_message_template_group->message_type_obj(); |
|
253 | + $message_type_label = $message_type instanceof EE_message_type |
|
254 | + ? $message_type->label['singular'] |
|
255 | + : $active_message_template_group->message_type(); |
|
256 | + $message_type_options[ $active_message_template_group->message_type() ] = ucwords($message_type_label); |
|
257 | + } |
|
258 | + } |
|
259 | + return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * Return the edit url for the message template group. |
|
265 | + * |
|
266 | + * @param EE_Message_Template_Group $item |
|
267 | + * @return string |
|
268 | + * @throws EE_Error |
|
269 | + */ |
|
270 | + protected function _get_edit_url(EE_Message_Template_Group $item) |
|
271 | + { |
|
272 | + $edit_url = ''; |
|
273 | + // edit link but only if item isn't trashed. |
|
274 | + if (! $item->get('MTP_deleted') |
|
275 | + && EE_Registry::instance()->CAP->current_user_can( |
|
276 | + 'ee_edit_message', |
|
277 | + 'espresso_messages_edit_message_template', |
|
278 | + $item->ID() |
|
279 | + )) { |
|
280 | + $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
281 | + array( |
|
282 | + 'action' => 'edit_message_template', |
|
283 | + 'id' => $item->GRP_ID(), |
|
284 | + ), |
|
285 | + EE_MSG_ADMIN_URL |
|
286 | + ); |
|
287 | + } |
|
288 | + return $edit_url; |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * Get the context link string for the messenger column. |
|
294 | + * |
|
295 | + * @param EE_Message_Template_Group $item |
|
296 | + * @return string |
|
297 | + * @throws EE_Error |
|
298 | + */ |
|
299 | + protected function _get_context_links(EE_Message_Template_Group $item) |
|
300 | + { |
|
301 | + // first check if we even show the context links or not. |
|
302 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
303 | + 'ee_edit_message', |
|
304 | + 'espresso_messages_edit_message_template', |
|
305 | + $item->ID() |
|
306 | + ) |
|
307 | + || $item->get('MTP_deleted') |
|
308 | + ) { |
|
309 | + return ''; |
|
310 | + } |
|
311 | + // we want to display the contexts in here so we need to set them up |
|
312 | + $c_label = $item->context_label(); |
|
313 | + $c_configs = $item->contexts_config(); |
|
314 | + $ctxt = array(); |
|
315 | + $context_templates = $item->context_templates(); |
|
316 | + foreach ($context_templates as $context => $template_fields) { |
|
317 | + $mtp_to = ! empty($context_templates[ $context ]['to']) |
|
318 | + && $context_templates[ $context ]['to'] instanceof EE_Message_Template |
|
319 | + ? $context_templates[ $context ]['to']->get('MTP_content') |
|
320 | + : null; |
|
321 | + $inactive_class = ( |
|
322 | + empty($mtp_to) |
|
323 | + && ! empty($context_templates[ $context ]['to']) |
|
324 | + ) |
|
325 | + || ! $item->is_context_active($context) |
|
326 | + ? ' mtp-inactive' |
|
327 | + : ''; |
|
328 | + $context_title = sprintf( |
|
329 | + /* translators: Placeholder represents the context label. Example "Edit Event Admin" */ |
|
330 | + esc_html__('Edit %1$s', 'event_espresso'), |
|
331 | + ucwords($c_configs[ $context ]['label']) |
|
332 | + ); |
|
333 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
334 | + array( |
|
335 | + 'action' => 'edit_message_template', |
|
336 | + 'id' => $item->GRP_ID(), |
|
337 | + 'context' => $context, |
|
338 | + ), |
|
339 | + EE_MSG_ADMIN_URL |
|
340 | + ); |
|
341 | + $ctxt[] = '<a' |
|
342 | + . ' href="' . $edit_link . '"' |
|
343 | + . ' class="' . $item->message_type() . '-' . $context . '-edit-link' . $inactive_class . '"' |
|
344 | + . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
345 | + . $context_title |
|
346 | + . '</a>'; |
|
347 | + } |
|
348 | + |
|
349 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
350 | + } |
|
351 | 351 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $message_type = $item->message_type_obj(); |
81 | 81 | $messenger = $item->messenger_obj(); |
82 | 82 | |
83 | - if (! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
83 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
84 | 84 | echo ''; |
85 | 85 | return; |
86 | 86 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | protected function _add_view_counts() |
132 | 132 | { |
133 | 133 | foreach ($this->_views as $view => $args) { |
134 | - $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
134 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
135 | 135 | $this->_per_page, |
136 | 136 | $view, |
137 | 137 | true, |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function column_description($item) |
160 | 160 | { |
161 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
161 | + return '<p>'.$item->message_type_obj()->description.'</p>'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $messenger_label = $messenger instanceof EE_messenger |
221 | 221 | ? $messenger->label['singular'] |
222 | 222 | : $active_message_template_group->messenger(); |
223 | - $messenger_options[ $active_message_template_group->messenger() ] = ucwords($messenger_label); |
|
223 | + $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $message_type_label = $message_type instanceof EE_message_type |
254 | 254 | ? $message_type->label['singular'] |
255 | 255 | : $active_message_template_group->message_type(); |
256 | - $message_type_options[ $active_message_template_group->message_type() ] = ucwords($message_type_label); |
|
256 | + $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | { |
272 | 272 | $edit_url = ''; |
273 | 273 | // edit link but only if item isn't trashed. |
274 | - if (! $item->get('MTP_deleted') |
|
274 | + if ( ! $item->get('MTP_deleted') |
|
275 | 275 | && EE_Registry::instance()->CAP->current_user_can( |
276 | 276 | 'ee_edit_message', |
277 | 277 | 'espresso_messages_edit_message_template', |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | protected function _get_context_links(EE_Message_Template_Group $item) |
300 | 300 | { |
301 | 301 | // first check if we even show the context links or not. |
302 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
302 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
303 | 303 | 'ee_edit_message', |
304 | 304 | 'espresso_messages_edit_message_template', |
305 | 305 | $item->ID() |
@@ -314,13 +314,13 @@ discard block |
||
314 | 314 | $ctxt = array(); |
315 | 315 | $context_templates = $item->context_templates(); |
316 | 316 | foreach ($context_templates as $context => $template_fields) { |
317 | - $mtp_to = ! empty($context_templates[ $context ]['to']) |
|
318 | - && $context_templates[ $context ]['to'] instanceof EE_Message_Template |
|
319 | - ? $context_templates[ $context ]['to']->get('MTP_content') |
|
317 | + $mtp_to = ! empty($context_templates[$context]['to']) |
|
318 | + && $context_templates[$context]['to'] instanceof EE_Message_Template |
|
319 | + ? $context_templates[$context]['to']->get('MTP_content') |
|
320 | 320 | : null; |
321 | 321 | $inactive_class = ( |
322 | 322 | empty($mtp_to) |
323 | - && ! empty($context_templates[ $context ]['to']) |
|
323 | + && ! empty($context_templates[$context]['to']) |
|
324 | 324 | ) |
325 | 325 | || ! $item->is_context_active($context) |
326 | 326 | ? ' mtp-inactive' |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $context_title = sprintf( |
329 | 329 | /* translators: Placeholder represents the context label. Example "Edit Event Admin" */ |
330 | 330 | esc_html__('Edit %1$s', 'event_espresso'), |
331 | - ucwords($c_configs[ $context ]['label']) |
|
331 | + ucwords($c_configs[$context]['label']) |
|
332 | 332 | ); |
333 | 333 | $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
334 | 334 | array( |
@@ -339,13 +339,13 @@ discard block |
||
339 | 339 | EE_MSG_ADMIN_URL |
340 | 340 | ); |
341 | 341 | $ctxt[] = '<a' |
342 | - . ' href="' . $edit_link . '"' |
|
343 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link' . $inactive_class . '"' |
|
344 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
342 | + . ' href="'.$edit_link.'"' |
|
343 | + . ' class="'.$item->message_type().'-'.$context.'-edit-link'.$inactive_class.'"' |
|
344 | + . ' title="'.esc_attr__('Edit Context', 'event_espresso').'">' |
|
345 | 345 | . $context_title |
346 | 346 | . '</a>'; |
347 | 347 | } |
348 | 348 | |
349 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
349 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])).implode(' | ', $ctxt); |
|
350 | 350 | } |
351 | 351 | } |