@@ -151,7 +151,7 @@ |
||
151 | 151 | * This provides a count of events using this custom template |
152 | 152 | * |
153 | 153 | * @param EE_Message_Template_Group $item message_template group data |
154 | - * @return string column output |
|
154 | + * @return integer column output |
|
155 | 155 | */ |
156 | 156 | public function column_events($item) |
157 | 157 | { |
@@ -12,246 +12,246 @@ |
||
12 | 12 | class Custom_Messages_Template_List_Table extends Messages_Template_List_Table |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Setup initial data. |
|
17 | - */ |
|
18 | - protected function _setup_data() |
|
19 | - { |
|
20 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | - $this->_per_page, |
|
22 | - $this->_view, |
|
23 | - false, |
|
24 | - false, |
|
25 | - false |
|
26 | - ); |
|
27 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | - $this->_per_page, |
|
29 | - $this->_view, |
|
30 | - true, |
|
31 | - true, |
|
32 | - false |
|
33 | - ); |
|
34 | - } |
|
15 | + /** |
|
16 | + * Setup initial data. |
|
17 | + */ |
|
18 | + protected function _setup_data() |
|
19 | + { |
|
20 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | + $this->_per_page, |
|
22 | + $this->_view, |
|
23 | + false, |
|
24 | + false, |
|
25 | + false |
|
26 | + ); |
|
27 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | + $this->_per_page, |
|
29 | + $this->_view, |
|
30 | + true, |
|
31 | + true, |
|
32 | + false |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Set initial properties |
|
39 | - */ |
|
40 | - protected function _set_properties() |
|
41 | - { |
|
42 | - parent::_set_properties(); |
|
43 | - $this->_wp_list_args = array( |
|
44 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | - 'ajax' => true, //for now, |
|
47 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | - ); |
|
37 | + /** |
|
38 | + * Set initial properties |
|
39 | + */ |
|
40 | + protected function _set_properties() |
|
41 | + { |
|
42 | + parent::_set_properties(); |
|
43 | + $this->_wp_list_args = array( |
|
44 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | + 'ajax' => true, //for now, |
|
47 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | + ); |
|
49 | 49 | |
50 | - $this->_columns = array_merge( |
|
51 | - array( |
|
52 | - 'cb' => '<input type="checkbox" />', |
|
53 | - 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | - ), |
|
55 | - $this->_columns, |
|
56 | - array( |
|
57 | - 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | - 'actions' => '' |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
50 | + $this->_columns = array_merge( |
|
51 | + array( |
|
52 | + 'cb' => '<input type="checkbox" />', |
|
53 | + 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | + ), |
|
55 | + $this->_columns, |
|
56 | + array( |
|
57 | + 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | + 'actions' => '' |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Custom message for when there are no items found. |
|
66 | - * |
|
67 | - * @since 4.3.0 |
|
68 | - */ |
|
69 | - public function no_items() |
|
70 | - { |
|
71 | - if ($this->_view !== 'trashed') { |
|
72 | - printf( |
|
73 | - esc_html__( |
|
74 | - '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - '<strong>', |
|
78 | - '</strong>' |
|
79 | - ); |
|
80 | - } else { |
|
81 | - parent::no_items(); |
|
82 | - } |
|
83 | - } |
|
64 | + /** |
|
65 | + * Custom message for when there are no items found. |
|
66 | + * |
|
67 | + * @since 4.3.0 |
|
68 | + */ |
|
69 | + public function no_items() |
|
70 | + { |
|
71 | + if ($this->_view !== 'trashed') { |
|
72 | + printf( |
|
73 | + esc_html__( |
|
74 | + '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + '<strong>', |
|
78 | + '</strong>' |
|
79 | + ); |
|
80 | + } else { |
|
81 | + parent::no_items(); |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param EE_Message_Template_Group $item |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function column_cb($item) |
|
91 | - { |
|
92 | - return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | - } |
|
86 | + /** |
|
87 | + * @param EE_Message_Template_Group $item |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function column_cb($item) |
|
91 | + { |
|
92 | + return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * @param EE_Message_Template_Group $item |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function column_name($item) |
|
101 | - { |
|
102 | - return '<p>' . $item->name() . '</p>'; |
|
103 | - } |
|
96 | + /** |
|
97 | + * @param EE_Message_Template_Group $item |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function column_name($item) |
|
101 | + { |
|
102 | + return '<p>' . $item->name() . '</p>'; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * @param EE_Message_Template_Group $item |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function column_actions($item) |
|
111 | - { |
|
112 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
113 | - 'ee_edit_messages', |
|
114 | - 'espresso_messages_add_new_message_template' |
|
115 | - )) { |
|
116 | - $create_args = array( |
|
117 | - 'GRP_ID' => $item->ID(), |
|
118 | - 'messenger' => $item->messenger(), |
|
119 | - 'message_type' => $item->message_type(), |
|
120 | - 'action' => 'add_new_message_template', |
|
121 | - ); |
|
122 | - $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
123 | - return sprintf( |
|
124 | - '<p><a href="%s" class="button button-small">%s</a></p>', |
|
125 | - $create_link, |
|
126 | - esc_html__('Create Custom', 'event_espresso') |
|
127 | - ); |
|
128 | - } |
|
129 | - return ''; |
|
130 | - } |
|
106 | + /** |
|
107 | + * @param EE_Message_Template_Group $item |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function column_actions($item) |
|
111 | + { |
|
112 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
113 | + 'ee_edit_messages', |
|
114 | + 'espresso_messages_add_new_message_template' |
|
115 | + )) { |
|
116 | + $create_args = array( |
|
117 | + 'GRP_ID' => $item->ID(), |
|
118 | + 'messenger' => $item->messenger(), |
|
119 | + 'message_type' => $item->message_type(), |
|
120 | + 'action' => 'add_new_message_template', |
|
121 | + ); |
|
122 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
123 | + return sprintf( |
|
124 | + '<p><a href="%s" class="button button-small">%s</a></p>', |
|
125 | + $create_link, |
|
126 | + esc_html__('Create Custom', 'event_espresso') |
|
127 | + ); |
|
128 | + } |
|
129 | + return ''; |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Set the view counts on the _views property |
|
134 | - */ |
|
135 | - protected function _add_view_counts() |
|
136 | - { |
|
137 | - foreach ($this->_views as $view => $args) { |
|
138 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
139 | - $this->_per_page, |
|
140 | - $view, |
|
141 | - true, |
|
142 | - true, |
|
143 | - false |
|
144 | - ); |
|
145 | - } |
|
146 | - } |
|
132 | + /** |
|
133 | + * Set the view counts on the _views property |
|
134 | + */ |
|
135 | + protected function _add_view_counts() |
|
136 | + { |
|
137 | + foreach ($this->_views as $view => $args) { |
|
138 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
139 | + $this->_per_page, |
|
140 | + $view, |
|
141 | + true, |
|
142 | + true, |
|
143 | + false |
|
144 | + ); |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | 148 | |
149 | - /** |
|
150 | - * column_events |
|
151 | - * This provides a count of events using this custom template |
|
152 | - * |
|
153 | - * @param EE_Message_Template_Group $item message_template group data |
|
154 | - * @return string column output |
|
155 | - */ |
|
156 | - public function column_events($item) |
|
157 | - { |
|
158 | - return $item->count_events(); |
|
159 | - } |
|
149 | + /** |
|
150 | + * column_events |
|
151 | + * This provides a count of events using this custom template |
|
152 | + * |
|
153 | + * @param EE_Message_Template_Group $item message_template group data |
|
154 | + * @return string column output |
|
155 | + */ |
|
156 | + public function column_events($item) |
|
157 | + { |
|
158 | + return $item->count_events(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * Add additional actions for custom message template list view. |
|
164 | - * @param EE_Message_Template_Group $item |
|
165 | - * @return array |
|
166 | - * @throws EE_Error |
|
167 | - */ |
|
168 | - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
169 | - { |
|
170 | - $actions = parent::_get_actions_for_messenger_column($item); |
|
162 | + /** |
|
163 | + * Add additional actions for custom message template list view. |
|
164 | + * @param EE_Message_Template_Group $item |
|
165 | + * @return array |
|
166 | + * @throws EE_Error |
|
167 | + */ |
|
168 | + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
169 | + { |
|
170 | + $actions = parent::_get_actions_for_messenger_column($item); |
|
171 | 171 | |
172 | - //add additional actions for trash/restore etc. |
|
173 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'trash_message_template', |
|
174 | - 'id' => $item->GRP_ID(), |
|
175 | - 'noheader' => true, |
|
176 | - ), EE_MSG_ADMIN_URL); |
|
177 | - // restore link |
|
178 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'restore_message_template', |
|
179 | - 'id' => $item->GRP_ID(), |
|
180 | - 'noheader' => true, |
|
181 | - ), EE_MSG_ADMIN_URL); |
|
182 | - // delete price link |
|
183 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_message_template', |
|
184 | - 'id' => $item->GRP_ID(), |
|
185 | - 'noheader' => true, |
|
186 | - ), EE_MSG_ADMIN_URL); |
|
172 | + //add additional actions for trash/restore etc. |
|
173 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'trash_message_template', |
|
174 | + 'id' => $item->GRP_ID(), |
|
175 | + 'noheader' => true, |
|
176 | + ), EE_MSG_ADMIN_URL); |
|
177 | + // restore link |
|
178 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'restore_message_template', |
|
179 | + 'id' => $item->GRP_ID(), |
|
180 | + 'noheader' => true, |
|
181 | + ), EE_MSG_ADMIN_URL); |
|
182 | + // delete price link |
|
183 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'delete_message_template', |
|
184 | + 'id' => $item->GRP_ID(), |
|
185 | + 'noheader' => true, |
|
186 | + ), EE_MSG_ADMIN_URL); |
|
187 | 187 | |
188 | - if (! $item->get('MTP_deleted') |
|
189 | - && EE_Registry::instance()->CAP->current_user_can( |
|
190 | - 'ee_delete_message', |
|
191 | - 'espresso_messages_trash_message_template', |
|
192 | - $item->ID() |
|
193 | - ) |
|
194 | - ) { |
|
195 | - $actions['trash'] = '<a href="' |
|
196 | - . $trash_lnk_url |
|
197 | - . '" title="' |
|
198 | - . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
199 | - . '">' |
|
200 | - . esc_html__('Move to Trash', 'event_espresso') |
|
201 | - . '</a>'; |
|
202 | - } else { |
|
203 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
204 | - 'ee_delete_message', |
|
205 | - 'espresso_messages_restore_message_template', |
|
206 | - $item->ID() |
|
207 | - )) { |
|
208 | - $actions['restore'] = '<a href="' |
|
209 | - . $restore_lnk_url |
|
210 | - . '" title="' |
|
211 | - . esc_attr__('Restore Message Template', 'event_espresso') |
|
212 | - . '">' |
|
213 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
214 | - } |
|
188 | + if (! $item->get('MTP_deleted') |
|
189 | + && EE_Registry::instance()->CAP->current_user_can( |
|
190 | + 'ee_delete_message', |
|
191 | + 'espresso_messages_trash_message_template', |
|
192 | + $item->ID() |
|
193 | + ) |
|
194 | + ) { |
|
195 | + $actions['trash'] = '<a href="' |
|
196 | + . $trash_lnk_url |
|
197 | + . '" title="' |
|
198 | + . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
199 | + . '">' |
|
200 | + . esc_html__('Move to Trash', 'event_espresso') |
|
201 | + . '</a>'; |
|
202 | + } else { |
|
203 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
204 | + 'ee_delete_message', |
|
205 | + 'espresso_messages_restore_message_template', |
|
206 | + $item->ID() |
|
207 | + )) { |
|
208 | + $actions['restore'] = '<a href="' |
|
209 | + . $restore_lnk_url |
|
210 | + . '" title="' |
|
211 | + . esc_attr__('Restore Message Template', 'event_espresso') |
|
212 | + . '">' |
|
213 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
214 | + } |
|
215 | 215 | |
216 | - if ($this->_view === 'trashed' |
|
217 | - && EE_Registry::instance()->CAP->current_user_can( |
|
218 | - 'ee_delete_message', |
|
219 | - 'espresso_messages_delete_message_template', |
|
220 | - $item->ID() |
|
221 | - )) { |
|
222 | - $actions['delete'] = '<a href="' |
|
223 | - . $delete_lnk_url |
|
224 | - . '" title="' |
|
225 | - . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
226 | - . '">' |
|
227 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
228 | - . '</a>'; |
|
229 | - } |
|
230 | - } |
|
231 | - return $actions; |
|
232 | - } |
|
216 | + if ($this->_view === 'trashed' |
|
217 | + && EE_Registry::instance()->CAP->current_user_can( |
|
218 | + 'ee_delete_message', |
|
219 | + 'espresso_messages_delete_message_template', |
|
220 | + $item->ID() |
|
221 | + )) { |
|
222 | + $actions['delete'] = '<a href="' |
|
223 | + . $delete_lnk_url |
|
224 | + . '" title="' |
|
225 | + . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
226 | + . '">' |
|
227 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
228 | + . '</a>'; |
|
229 | + } |
|
230 | + } |
|
231 | + return $actions; |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - /** |
|
236 | - * Generate dropdown filter select input for messengers |
|
237 | - * @param bool $global |
|
238 | - * @return string |
|
239 | - * @throws EE_Error |
|
240 | - */ |
|
241 | - protected function _get_messengers_dropdown_filter($global = true) |
|
242 | - { |
|
243 | - return parent::_get_messengers_dropdown_filter(false); |
|
244 | - } |
|
235 | + /** |
|
236 | + * Generate dropdown filter select input for messengers |
|
237 | + * @param bool $global |
|
238 | + * @return string |
|
239 | + * @throws EE_Error |
|
240 | + */ |
|
241 | + protected function _get_messengers_dropdown_filter($global = true) |
|
242 | + { |
|
243 | + return parent::_get_messengers_dropdown_filter(false); |
|
244 | + } |
|
245 | 245 | |
246 | 246 | |
247 | - /** |
|
248 | - * Generate dropdown filter select input for message types |
|
249 | - * @param bool $global |
|
250 | - * @return string |
|
251 | - * @throws EE_Error |
|
252 | - */ |
|
253 | - protected function _get_message_types_dropdown_filter($global = true) |
|
254 | - { |
|
255 | - return parent::_get_message_types_dropdown_filter(false); |
|
256 | - } |
|
247 | + /** |
|
248 | + * Generate dropdown filter select input for message types |
|
249 | + * @param bool $global |
|
250 | + * @return string |
|
251 | + * @throws EE_Error |
|
252 | + */ |
|
253 | + protected function _get_message_types_dropdown_filter($global = true) |
|
254 | + { |
|
255 | + return parent::_get_message_types_dropdown_filter(false); |
|
256 | + } |
|
257 | 257 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | protected function _setup_data() |
19 | 19 | { |
20 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
20 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | 21 | $this->_per_page, |
22 | 22 | $this->_view, |
23 | 23 | false, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function column_name($item) |
101 | 101 | { |
102 | - return '<p>' . $item->name() . '</p>'; |
|
102 | + return '<p>'.$item->name().'</p>'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'noheader' => true, |
186 | 186 | ), EE_MSG_ADMIN_URL); |
187 | 187 | |
188 | - if (! $item->get('MTP_deleted') |
|
188 | + if ( ! $item->get('MTP_deleted') |
|
189 | 189 | && EE_Registry::instance()->CAP->current_user_can( |
190 | 190 | 'ee_delete_message', |
191 | 191 | 'espresso_messages_trash_message_template', |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | . '" title="' |
211 | 211 | . esc_attr__('Restore Message Template', 'event_espresso') |
212 | 212 | . '">' |
213 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
213 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | if ($this->_view === 'trashed' |
@@ -13,366 +13,366 @@ |
||
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 | - */ |
|
95 | - protected function _get_table_filters() |
|
96 | - { |
|
97 | - $filters = array(); |
|
98 | - |
|
99 | - //get select inputs |
|
100 | - $select_inputs = array( |
|
101 | - $this->_get_messengers_dropdown_filter(), |
|
102 | - $this->_get_message_types_dropdown_filter(), |
|
103 | - ); |
|
104 | - |
|
105 | - //set filters to select inputs if they aren't empty |
|
106 | - foreach ($select_inputs as $select_input) { |
|
107 | - if ($select_input) { |
|
108 | - $filters[] = $select_input; |
|
109 | - } |
|
110 | - } |
|
111 | - return $filters; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * We're just removing the search box for message templates, not needed. |
|
116 | - * |
|
117 | - * @param string $text |
|
118 | - * @param string $input_id |
|
119 | - * @return string ; |
|
120 | - */ |
|
121 | - public function search_box($text, $input_id) |
|
122 | - { |
|
123 | - return ''; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * Add counts to the _views property |
|
129 | - */ |
|
130 | - protected function _add_view_counts() |
|
131 | - { |
|
132 | - foreach ($this->_views as $view => $args) { |
|
133 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
134 | - $this->_per_page, |
|
135 | - $view, |
|
136 | - true, |
|
137 | - true |
|
138 | - ); |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @param EE_Message_Template_Group $item |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function column_cb($item) |
|
148 | - { |
|
149 | - return ''; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @param EE_Message_Template_Group $item |
|
155 | - * @return string |
|
156 | - */ |
|
157 | - public function column_description($item) |
|
158 | - { |
|
159 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @param EE_Message_Template_Group $item |
|
165 | - * @return string |
|
166 | - */ |
|
167 | - public function column_messenger($item) |
|
168 | - { |
|
169 | - //Return the name contents |
|
170 | - return sprintf( |
|
171 | - '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s', |
|
172 | - /* $1%s */ |
|
173 | - $this->_get_name_link_for_messenger($item), |
|
174 | - /* $2%s */ |
|
175 | - $item->GRP_ID(), |
|
176 | - /* %4$s */ |
|
177 | - $this->_get_context_links($item), |
|
178 | - /* $3%s */ |
|
179 | - $this->row_actions($this->_get_actions_for_messenger_column($item)) |
|
180 | - ); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * column_message_type |
|
185 | - * |
|
186 | - * @param EE_Message_Template_Group $item message info for the row |
|
187 | - * @return string message_type name |
|
188 | - */ |
|
189 | - public function column_message_type($item) |
|
190 | - { |
|
191 | - return ucwords($item->message_type_obj()->label['singular']); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * Generate dropdown filter select input for messengers |
|
197 | - * |
|
198 | - * @param bool $global |
|
199 | - * @return string |
|
200 | - * @throws EE_Error |
|
201 | - */ |
|
202 | - protected function _get_messengers_dropdown_filter($global = true) |
|
203 | - { |
|
204 | - $messenger_options = array(); |
|
205 | - $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
206 | - array( |
|
207 | - array( |
|
208 | - 'MTP_is_active' => true, |
|
209 | - 'MTP_is_global' => $global, |
|
210 | - ), |
|
211 | - 'group_by' => 'MTP_messenger', |
|
212 | - ) |
|
213 | - ); |
|
214 | - |
|
215 | - foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
216 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
217 | - $messenger = $active_message_template_group->messenger_obj(); |
|
218 | - $messenger_label = $messenger instanceof EE_messenger |
|
219 | - ? $messenger->label['singular'] |
|
220 | - : $active_message_template_group->messenger(); |
|
221 | - $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
222 | - } |
|
223 | - } |
|
224 | - return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Generate dropdown filter select input for message types |
|
230 | - * |
|
231 | - * @param bool $global |
|
232 | - * @return string |
|
233 | - * @throws EE_Error |
|
234 | - */ |
|
235 | - protected function _get_message_types_dropdown_filter($global = true) |
|
236 | - { |
|
237 | - $message_type_options = array(); |
|
238 | - $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
239 | - array( |
|
240 | - array( |
|
241 | - 'MTP_is_active' => true, |
|
242 | - 'MTP_is_global' => true, |
|
243 | - ), |
|
244 | - 'group_by' => 'MTP_message_type', |
|
245 | - ) |
|
246 | - ); |
|
247 | - |
|
248 | - foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
249 | - if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
250 | - $message_type = $active_message_template_group->message_type_obj(); |
|
251 | - $message_type_label = $message_type instanceof EE_message_type |
|
252 | - ? $message_type->label['singular'] |
|
253 | - : $active_message_template_group->message_type(); |
|
254 | - $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
255 | - } |
|
256 | - } |
|
257 | - return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * Return the edit url for the message template group. |
|
263 | - * @param EE_Message_Template_Group $item |
|
264 | - * @return string |
|
265 | - * @throws EE_Error |
|
266 | - */ |
|
267 | - protected function _get_edit_url(EE_Message_Template_Group $item) |
|
268 | - { |
|
269 | - $edit_url = ''; |
|
270 | - // edit link but only if item isn't trashed. |
|
271 | - if (! $item->get('MTP_deleted') |
|
272 | - && EE_Registry::instance()->CAP->current_user_can( |
|
273 | - 'ee_edit_message', |
|
274 | - 'espresso_messages_edit_message_template', |
|
275 | - $item->ID() |
|
276 | - )) { |
|
277 | - $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
278 | - array( |
|
279 | - 'action' => 'edit_message_template', |
|
280 | - 'id' => $item->GRP_ID(), |
|
281 | - ), |
|
282 | - EE_MSG_ADMIN_URL |
|
283 | - ); |
|
284 | - } |
|
285 | - return $edit_url; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * Get the context link string for the messenger column. |
|
291 | - * @param EE_Message_Template_Group $item |
|
292 | - * @return string |
|
293 | - * @throws EE_Error |
|
294 | - */ |
|
295 | - protected function _get_context_links(EE_Message_Template_Group $item) |
|
296 | - { |
|
297 | - //first check if we even show the context links or not. |
|
298 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
299 | - 'ee_edit_message', |
|
300 | - 'espresso_messages_edit_message_template', |
|
301 | - $item->ID() |
|
302 | - ) |
|
303 | - || $item->get('MTP_deleted') |
|
304 | - ) { |
|
305 | - return ''; |
|
306 | - } |
|
307 | - //we want to display the contexts in here so we need to set them up |
|
308 | - $c_label = $item->context_label(); |
|
309 | - $c_configs = $item->contexts_config(); |
|
310 | - $ctxt = array(); |
|
311 | - $context_templates = $item->context_templates(); |
|
312 | - foreach ($context_templates as $context => $template_fields) { |
|
313 | - $mtp_to = ! empty($context_templates[$context]['to']) |
|
314 | - && $context_templates[$context]['to'] instanceof EE_Message_Template |
|
315 | - ? $context_templates[$context]['to']->get('MTP_content') |
|
316 | - : null; |
|
317 | - $inactive = empty($mtp_to) |
|
318 | - && ! empty($context_templates[$context]['to']) |
|
319 | - ? ' class="mtp-inactive"' |
|
320 | - : ''; |
|
321 | - $context_title = ucwords($c_configs[$context]['label']); |
|
322 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce(array( |
|
323 | - 'action' => 'edit_message_template', |
|
324 | - 'id' => $item->GRP_ID(), |
|
325 | - 'context' => $context, |
|
326 | - ), EE_MSG_ADMIN_URL); |
|
327 | - $ctxt[] = '<a' . $inactive |
|
328 | - . ' href="' . $edit_link . '"' |
|
329 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
330 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
331 | - . $context_title |
|
332 | - . '</a>'; |
|
333 | - } |
|
334 | - |
|
335 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * Get the Name string from the messenger column (linked to edit if the context allows for that). |
|
341 | - * @param EE_Message_Template_Group $item |
|
342 | - * @return string |
|
343 | - * @throws EE_Error |
|
344 | - */ |
|
345 | - protected function _get_name_link_for_messenger(EE_Message_Template_Group $item) |
|
346 | - { |
|
347 | - $edit_url = $this->_get_edit_url($item); |
|
348 | - return $edit_url |
|
349 | - ? '<a href="' . $edit_url . '"' |
|
350 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
351 | - . ucwords($item->messenger_obj()->label['singular']) |
|
352 | - . '</a>' |
|
353 | - : ucwords($item->messenger_obj()->label['singular']); |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * Return the actions array for the messenger column. |
|
359 | - * @param EE_Message_Template_Group $item |
|
360 | - * @return array |
|
361 | - * @throws EE_Error |
|
362 | - */ |
|
363 | - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
364 | - { |
|
365 | - $actions = array(); |
|
366 | - if ($edit_url = $this->_get_edit_url($item)) { |
|
367 | - $actions = array( |
|
368 | - 'edit' => '<a href="' . $edit_url . '"' |
|
369 | - . ' class="' . $item->message_type() . '-edit-link"' |
|
370 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
371 | - . esc_html__('Edit', 'event_espresso') |
|
372 | - . '</a>' |
|
373 | - ); |
|
374 | - } |
|
375 | - return $actions; |
|
376 | - } |
|
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 | + */ |
|
95 | + protected function _get_table_filters() |
|
96 | + { |
|
97 | + $filters = array(); |
|
98 | + |
|
99 | + //get select inputs |
|
100 | + $select_inputs = array( |
|
101 | + $this->_get_messengers_dropdown_filter(), |
|
102 | + $this->_get_message_types_dropdown_filter(), |
|
103 | + ); |
|
104 | + |
|
105 | + //set filters to select inputs if they aren't empty |
|
106 | + foreach ($select_inputs as $select_input) { |
|
107 | + if ($select_input) { |
|
108 | + $filters[] = $select_input; |
|
109 | + } |
|
110 | + } |
|
111 | + return $filters; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * We're just removing the search box for message templates, not needed. |
|
116 | + * |
|
117 | + * @param string $text |
|
118 | + * @param string $input_id |
|
119 | + * @return string ; |
|
120 | + */ |
|
121 | + public function search_box($text, $input_id) |
|
122 | + { |
|
123 | + return ''; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * Add counts to the _views property |
|
129 | + */ |
|
130 | + protected function _add_view_counts() |
|
131 | + { |
|
132 | + foreach ($this->_views as $view => $args) { |
|
133 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
134 | + $this->_per_page, |
|
135 | + $view, |
|
136 | + true, |
|
137 | + true |
|
138 | + ); |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @param EE_Message_Template_Group $item |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function column_cb($item) |
|
148 | + { |
|
149 | + return ''; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @param EE_Message_Template_Group $item |
|
155 | + * @return string |
|
156 | + */ |
|
157 | + public function column_description($item) |
|
158 | + { |
|
159 | + return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @param EE_Message_Template_Group $item |
|
165 | + * @return string |
|
166 | + */ |
|
167 | + public function column_messenger($item) |
|
168 | + { |
|
169 | + //Return the name contents |
|
170 | + return sprintf( |
|
171 | + '%1$s <span style="color:silver">(id:%2$s)</span><br />%3$s%4$s', |
|
172 | + /* $1%s */ |
|
173 | + $this->_get_name_link_for_messenger($item), |
|
174 | + /* $2%s */ |
|
175 | + $item->GRP_ID(), |
|
176 | + /* %4$s */ |
|
177 | + $this->_get_context_links($item), |
|
178 | + /* $3%s */ |
|
179 | + $this->row_actions($this->_get_actions_for_messenger_column($item)) |
|
180 | + ); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * column_message_type |
|
185 | + * |
|
186 | + * @param EE_Message_Template_Group $item message info for the row |
|
187 | + * @return string message_type name |
|
188 | + */ |
|
189 | + public function column_message_type($item) |
|
190 | + { |
|
191 | + return ucwords($item->message_type_obj()->label['singular']); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * Generate dropdown filter select input for messengers |
|
197 | + * |
|
198 | + * @param bool $global |
|
199 | + * @return string |
|
200 | + * @throws EE_Error |
|
201 | + */ |
|
202 | + protected function _get_messengers_dropdown_filter($global = true) |
|
203 | + { |
|
204 | + $messenger_options = array(); |
|
205 | + $active_message_template_groups_grouped_by_messenger = EEM_Message_Template_Group::instance()->get_all( |
|
206 | + array( |
|
207 | + array( |
|
208 | + 'MTP_is_active' => true, |
|
209 | + 'MTP_is_global' => $global, |
|
210 | + ), |
|
211 | + 'group_by' => 'MTP_messenger', |
|
212 | + ) |
|
213 | + ); |
|
214 | + |
|
215 | + foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
216 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
217 | + $messenger = $active_message_template_group->messenger_obj(); |
|
218 | + $messenger_label = $messenger instanceof EE_messenger |
|
219 | + ? $messenger->label['singular'] |
|
220 | + : $active_message_template_group->messenger(); |
|
221 | + $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
222 | + } |
|
223 | + } |
|
224 | + return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Generate dropdown filter select input for message types |
|
230 | + * |
|
231 | + * @param bool $global |
|
232 | + * @return string |
|
233 | + * @throws EE_Error |
|
234 | + */ |
|
235 | + protected function _get_message_types_dropdown_filter($global = true) |
|
236 | + { |
|
237 | + $message_type_options = array(); |
|
238 | + $active_message_template_groups_grouped_by_message_type = EEM_Message_Template_Group::instance()->get_all( |
|
239 | + array( |
|
240 | + array( |
|
241 | + 'MTP_is_active' => true, |
|
242 | + 'MTP_is_global' => true, |
|
243 | + ), |
|
244 | + 'group_by' => 'MTP_message_type', |
|
245 | + ) |
|
246 | + ); |
|
247 | + |
|
248 | + foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
249 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
250 | + $message_type = $active_message_template_group->message_type_obj(); |
|
251 | + $message_type_label = $message_type instanceof EE_message_type |
|
252 | + ? $message_type->label['singular'] |
|
253 | + : $active_message_template_group->message_type(); |
|
254 | + $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
255 | + } |
|
256 | + } |
|
257 | + return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * Return the edit url for the message template group. |
|
263 | + * @param EE_Message_Template_Group $item |
|
264 | + * @return string |
|
265 | + * @throws EE_Error |
|
266 | + */ |
|
267 | + protected function _get_edit_url(EE_Message_Template_Group $item) |
|
268 | + { |
|
269 | + $edit_url = ''; |
|
270 | + // edit link but only if item isn't trashed. |
|
271 | + if (! $item->get('MTP_deleted') |
|
272 | + && EE_Registry::instance()->CAP->current_user_can( |
|
273 | + 'ee_edit_message', |
|
274 | + 'espresso_messages_edit_message_template', |
|
275 | + $item->ID() |
|
276 | + )) { |
|
277 | + $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
278 | + array( |
|
279 | + 'action' => 'edit_message_template', |
|
280 | + 'id' => $item->GRP_ID(), |
|
281 | + ), |
|
282 | + EE_MSG_ADMIN_URL |
|
283 | + ); |
|
284 | + } |
|
285 | + return $edit_url; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * Get the context link string for the messenger column. |
|
291 | + * @param EE_Message_Template_Group $item |
|
292 | + * @return string |
|
293 | + * @throws EE_Error |
|
294 | + */ |
|
295 | + protected function _get_context_links(EE_Message_Template_Group $item) |
|
296 | + { |
|
297 | + //first check if we even show the context links or not. |
|
298 | + if (! EE_Registry::instance()->CAP->current_user_can( |
|
299 | + 'ee_edit_message', |
|
300 | + 'espresso_messages_edit_message_template', |
|
301 | + $item->ID() |
|
302 | + ) |
|
303 | + || $item->get('MTP_deleted') |
|
304 | + ) { |
|
305 | + return ''; |
|
306 | + } |
|
307 | + //we want to display the contexts in here so we need to set them up |
|
308 | + $c_label = $item->context_label(); |
|
309 | + $c_configs = $item->contexts_config(); |
|
310 | + $ctxt = array(); |
|
311 | + $context_templates = $item->context_templates(); |
|
312 | + foreach ($context_templates as $context => $template_fields) { |
|
313 | + $mtp_to = ! empty($context_templates[$context]['to']) |
|
314 | + && $context_templates[$context]['to'] instanceof EE_Message_Template |
|
315 | + ? $context_templates[$context]['to']->get('MTP_content') |
|
316 | + : null; |
|
317 | + $inactive = empty($mtp_to) |
|
318 | + && ! empty($context_templates[$context]['to']) |
|
319 | + ? ' class="mtp-inactive"' |
|
320 | + : ''; |
|
321 | + $context_title = ucwords($c_configs[$context]['label']); |
|
322 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array( |
|
323 | + 'action' => 'edit_message_template', |
|
324 | + 'id' => $item->GRP_ID(), |
|
325 | + 'context' => $context, |
|
326 | + ), EE_MSG_ADMIN_URL); |
|
327 | + $ctxt[] = '<a' . $inactive |
|
328 | + . ' href="' . $edit_link . '"' |
|
329 | + . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
330 | + . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
331 | + . $context_title |
|
332 | + . '</a>'; |
|
333 | + } |
|
334 | + |
|
335 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * Get the Name string from the messenger column (linked to edit if the context allows for that). |
|
341 | + * @param EE_Message_Template_Group $item |
|
342 | + * @return string |
|
343 | + * @throws EE_Error |
|
344 | + */ |
|
345 | + protected function _get_name_link_for_messenger(EE_Message_Template_Group $item) |
|
346 | + { |
|
347 | + $edit_url = $this->_get_edit_url($item); |
|
348 | + return $edit_url |
|
349 | + ? '<a href="' . $edit_url . '"' |
|
350 | + . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
351 | + . ucwords($item->messenger_obj()->label['singular']) |
|
352 | + . '</a>' |
|
353 | + : ucwords($item->messenger_obj()->label['singular']); |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * Return the actions array for the messenger column. |
|
359 | + * @param EE_Message_Template_Group $item |
|
360 | + * @return array |
|
361 | + * @throws EE_Error |
|
362 | + */ |
|
363 | + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
364 | + { |
|
365 | + $actions = array(); |
|
366 | + if ($edit_url = $this->_get_edit_url($item)) { |
|
367 | + $actions = array( |
|
368 | + 'edit' => '<a href="' . $edit_url . '"' |
|
369 | + . ' class="' . $item->message_type() . '-edit-link"' |
|
370 | + . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
371 | + . esc_html__('Edit', 'event_espresso') |
|
372 | + . '</a>' |
|
373 | + ); |
|
374 | + } |
|
375 | + return $actions; |
|
376 | + } |
|
377 | 377 | } |
378 | 378 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | protected function _setup_data() |
29 | 29 | { |
30 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
30 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
31 | 31 | $this->_per_page, |
32 | 32 | $this->_view, |
33 | 33 | false |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'ajax' => true, //for now, |
53 | 53 | 'screen' => $this->get_admin_page()->get_current_screen()->id, |
54 | 54 | ); |
55 | - $this->_columns = array( |
|
55 | + $this->_columns = array( |
|
56 | 56 | //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
57 | 57 | 'message_type' => esc_html__('Message Type', 'event_espresso'), |
58 | 58 | 'messenger' => esc_html__('Messenger', 'event_espresso'), |
@@ -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 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function column_description($item) |
158 | 158 | { |
159 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
159 | + return '<p>'.$item->message_type_obj()->description.'</p>'; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | $edit_url = ''; |
270 | 270 | // edit link but only if item isn't trashed. |
271 | - if (! $item->get('MTP_deleted') |
|
271 | + if ( ! $item->get('MTP_deleted') |
|
272 | 272 | && EE_Registry::instance()->CAP->current_user_can( |
273 | 273 | 'ee_edit_message', |
274 | 274 | 'espresso_messages_edit_message_template', |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | protected function _get_context_links(EE_Message_Template_Group $item) |
296 | 296 | { |
297 | 297 | //first check if we even show the context links or not. |
298 | - if (! EE_Registry::instance()->CAP->current_user_can( |
|
298 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
299 | 299 | 'ee_edit_message', |
300 | 300 | 'espresso_messages_edit_message_template', |
301 | 301 | $item->ID() |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | && $context_templates[$context]['to'] instanceof EE_Message_Template |
315 | 315 | ? $context_templates[$context]['to']->get('MTP_content') |
316 | 316 | : null; |
317 | - $inactive = empty($mtp_to) |
|
317 | + $inactive = empty($mtp_to) |
|
318 | 318 | && ! empty($context_templates[$context]['to']) |
319 | 319 | ? ' class="mtp-inactive"' |
320 | 320 | : ''; |
@@ -324,15 +324,15 @@ discard block |
||
324 | 324 | 'id' => $item->GRP_ID(), |
325 | 325 | 'context' => $context, |
326 | 326 | ), EE_MSG_ADMIN_URL); |
327 | - $ctxt[] = '<a' . $inactive |
|
328 | - . ' href="' . $edit_link . '"' |
|
329 | - . ' class="' . $item->message_type() . '-' . $context . '-edit-link"' |
|
330 | - . ' title="' . esc_attr__('Edit Context', 'event_espresso') . '">' |
|
327 | + $ctxt[] = '<a'.$inactive |
|
328 | + . ' href="'.$edit_link.'"' |
|
329 | + . ' class="'.$item->message_type().'-'.$context.'-edit-link"' |
|
330 | + . ' title="'.esc_attr__('Edit Context', 'event_espresso').'">' |
|
331 | 331 | . $context_title |
332 | 332 | . '</a>'; |
333 | 333 | } |
334 | 334 | |
335 | - return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])) . implode(' | ', $ctxt); |
|
335 | + return sprintf('<strong>%s:</strong> ', ucwords($c_label['plural'])).implode(' | ', $ctxt); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | { |
347 | 347 | $edit_url = $this->_get_edit_url($item); |
348 | 348 | return $edit_url |
349 | - ? '<a href="' . $edit_url . '"' |
|
350 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
349 | + ? '<a href="'.$edit_url.'"' |
|
350 | + . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">' |
|
351 | 351 | . ucwords($item->messenger_obj()->label['singular']) |
352 | 352 | . '</a>' |
353 | 353 | : ucwords($item->messenger_obj()->label['singular']); |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | $actions = array(); |
366 | 366 | if ($edit_url = $this->_get_edit_url($item)) { |
367 | 367 | $actions = array( |
368 | - 'edit' => '<a href="' . $edit_url . '"' |
|
369 | - . ' class="' . $item->message_type() . '-edit-link"' |
|
370 | - . ' title="' . esc_attr__('Edit Template Group', 'event_espresso') . '">' |
|
368 | + 'edit' => '<a href="'.$edit_url.'"' |
|
369 | + . ' class="'.$item->message_type().'-edit-link"' |
|
370 | + . ' title="'.esc_attr__('Edit Template Group', 'event_espresso').'">' |
|
371 | 371 | . esc_html__('Edit', 'event_espresso') |
372 | 372 | . '</a>' |
373 | 373 | ); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | 11 | |
12 | 12 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @subpackage messages |
21 | 21 | * @author Darren Ethier |
22 | 22 | */ |
23 | -class EE_Pdf_messenger extends EE_messenger { |
|
23 | +class EE_Pdf_messenger extends EE_messenger { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @see abstract declaration in EE_messenger for details. |
94 | 94 | */ |
95 | 95 | protected function _set_admin_pages() { |
96 | - $this->admin_registered_pages = array( 'events_edit' => false ); |
|
96 | + $this->admin_registered_pages = array('events_edit' => false); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | protected function _set_validator_config() { |
114 | 114 | $this->_validator_config = array( |
115 | 115 | 'subject' => array( |
116 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
116 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
117 | 117 | ), |
118 | 118 | 'content' => array( |
119 | - 'shortcodes' => array( 'recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email','event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
119 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
120 | 120 | ), |
121 | 121 | 'attendee_list' => array( |
122 | 122 | 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'required' => array('[EVENT_LIST]') |
128 | 128 | ), |
129 | 129 | 'ticket_list' => array( |
130 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list','primary_registration_details', 'recipient_details'), |
|
130 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
131 | 131 | 'required' => array('[TICKET_LIST]') |
132 | 132 | ), |
133 | 133 | 'datetime_list' => array( |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function enqueue_scripts_styles() { |
149 | 149 | parent::enqueue_scripts_styles(); |
150 | - do_action( 'AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
150 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -273,18 +273,18 @@ discard block |
||
273 | 273 | */ |
274 | 274 | protected function _send_message() { |
275 | 275 | $this->_template_args = array( |
276 | - 'page_title' => html_entity_decode( stripslashes( $this->_subject ), ENT_QUOTES, "UTF-8"), |
|
277 | - 'base_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation ), |
|
278 | - 'print_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation ), |
|
279 | - 'main_css' => $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation ), |
|
280 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
281 | - 'main_body' => apply_filters( 'FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep( html_entity_decode($this->_content, ENT_QUOTES,"UTF-8" ) )), $this->_content ) |
|
276 | + 'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
277 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation), |
|
278 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation), |
|
279 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation), |
|
280 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
281 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))), $this->_content) |
|
282 | 282 | ); |
283 | 283 | $this->_deregister_wp_hooks(); |
284 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) ); |
|
284 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
285 | 285 | $content = $this->_get_main_template(); |
286 | 286 | // die( $content ); |
287 | - $this->_do_pdf( $content ); |
|
287 | + $this->_do_pdf($content); |
|
288 | 288 | exit(0); |
289 | 289 | } |
290 | 290 | |
@@ -308,8 +308,8 @@ discard block |
||
308 | 308 | |
309 | 309 | //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
310 | 310 | add_action('wp_head', 'wp_enqueue_scripts'); |
311 | - add_action( 'wp_footer', 'wp_print_footer_scripts' ); |
|
312 | - add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); |
|
311 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
312 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | * @param bool $preview |
323 | 323 | * @return string |
324 | 324 | */ |
325 | - protected function _get_main_template( $preview = FALSE ) { |
|
326 | - $wrapper_template = $this->_tmp_pack->get_wrapper( 'html', 'main' ); |
|
325 | + protected function _get_main_template($preview = FALSE) { |
|
326 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
327 | 327 | //add message type to template_args |
328 | 328 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
329 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
329 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | |
@@ -339,15 +339,15 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - protected function _do_pdf( $content = '' ) { |
|
343 | - $invoice_name = html_entity_decode( $this->_subject, ENT_QUOTES, "UTF-8"); |
|
342 | + protected function _do_pdf($content = '') { |
|
343 | + $invoice_name = html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8"); |
|
344 | 344 | |
345 | 345 | //only load dompdf if nobody else has yet... |
346 | - if( ! defined('DOMPDF_DIR')){ |
|
346 | + if ( ! defined('DOMPDF_DIR')) { |
|
347 | 347 | define('DOMPDF_ENABLE_REMOTE', TRUE); |
348 | 348 | define('DOMPDF_ENABLE_JAVASCRIPT', FALSE); |
349 | 349 | define('DOMPDF_ENABLE_CSS_FLOAT', TRUE); |
350 | - require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php'); |
|
350 | + require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php'); |
|
351 | 351 | } |
352 | 352 | $dompdf = new DOMPDF(); |
353 | 353 | if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $dompdf->load_html($content); |
357 | 357 | $dompdf->render(); |
358 | 358 | //forcing the browser to open a download dialog. |
359 | - $dompdf->stream($invoice_name . ".pdf", array( 'Attachment' => TRUE )); |
|
359 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => TRUE)); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.45.rc.015'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.45.rc.015'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |