@@ -20,81 +20,81 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Newsletter_Shortcodes extends EE_Shortcodes { |
22 | 22 | |
23 | - protected function _init_props() { |
|
24 | - $this->label = __("Batch Messages Shortcodes", 'event_espresso'); |
|
25 | - $this->description = __('All shortcodes used for the batch message type', 'event_espresso'); |
|
26 | - $this->_shortcodes = array( |
|
27 | - '[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field. Note that when triggering a batch message, whatever is added for the custom message will be inserted where this shortcode is placed.', 'event_espresso') |
|
28 | - ); |
|
29 | - } |
|
23 | + protected function _init_props() { |
|
24 | + $this->label = __("Batch Messages Shortcodes", 'event_espresso'); |
|
25 | + $this->description = __('All shortcodes used for the batch message type', 'event_espresso'); |
|
26 | + $this->_shortcodes = array( |
|
27 | + '[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field. Note that when triggering a batch message, whatever is added for the custom message will be inserted where this shortcode is placed.', 'event_espresso') |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - protected function _parser( $shortcode ) { |
|
34 | - if ( $shortcode == '[NEWSLETTER_CONTENT]' ) { |
|
35 | - $this->_validate_list_requirements(); |
|
36 | - $valid_shortcodes = array('recipient_details', 'organization'); |
|
37 | - $template = $this->_data['template']['newsletter_content']; |
|
38 | - $data = $this->_data; |
|
39 | - return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
40 | - } |
|
41 | - } |
|
33 | + protected function _parser( $shortcode ) { |
|
34 | + if ( $shortcode == '[NEWSLETTER_CONTENT]' ) { |
|
35 | + $this->_validate_list_requirements(); |
|
36 | + $valid_shortcodes = array('recipient_details', 'organization'); |
|
37 | + $template = $this->_data['template']['newsletter_content']; |
|
38 | + $data = $this->_data; |
|
39 | + return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'. |
|
46 | - * |
|
47 | - * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
48 | - * 'FHEE__EE_messenger__get_validator_config' filter. |
|
49 | - * |
|
50 | - * @since 4.3.0 |
|
51 | - * @param array $validator_config current validator configuration array |
|
52 | - * @param EE_messenger $messenger |
|
53 | - * @return array new validator config. |
|
54 | - */ |
|
55 | - public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) { |
|
56 | - if ( $messenger->name !== 'email' ) |
|
57 | - return $validator_config; |
|
44 | + /** |
|
45 | + * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'. |
|
46 | + * |
|
47 | + * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
48 | + * 'FHEE__EE_messenger__get_validator_config' filter. |
|
49 | + * |
|
50 | + * @since 4.3.0 |
|
51 | + * @param array $validator_config current validator configuration array |
|
52 | + * @param EE_messenger $messenger |
|
53 | + * @return array new validator config. |
|
54 | + */ |
|
55 | + public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) { |
|
56 | + if ( $messenger->name !== 'email' ) |
|
57 | + return $validator_config; |
|
58 | 58 | |
59 | - $validator_config['content']['shortcodes'][] = 'newsletter'; |
|
60 | - $validator_config['newsletter_content'] = array( |
|
61 | - 'shortcodes' => array('recipient_details', 'organization'), |
|
62 | - 'required' => array('[NEWSLETTER_CONTENT]') |
|
63 | - ); |
|
64 | - return $validator_config; |
|
65 | - } |
|
59 | + $validator_config['content']['shortcodes'][] = 'newsletter'; |
|
60 | + $validator_config['newsletter_content'] = array( |
|
61 | + 'shortcodes' => array('recipient_details', 'organization'), |
|
62 | + 'required' => array('[NEWSLETTER_CONTENT]') |
|
63 | + ); |
|
64 | + return $validator_config; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Callback set in args for EE_Register_Messages_Shortcode_Library::register for |
|
72 | - * 'msgr_template_fields_callback'. |
|
73 | - * |
|
74 | - * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
75 | - * FHEE__EE_messenger__get_template_fields filter. |
|
76 | - * |
|
77 | - * @since 4.3.0 |
|
78 | - * |
|
79 | - * @param array $template_fields current template fields setup array. |
|
80 | - * @param EE_messenger $messenger |
|
81 | - * @return array new/modified template fields array. |
|
82 | - */ |
|
83 | - public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) { |
|
84 | - if ( $messenger->name !== 'email' ) |
|
85 | - return $template_fields; |
|
70 | + /** |
|
71 | + * Callback set in args for EE_Register_Messages_Shortcode_Library::register for |
|
72 | + * 'msgr_template_fields_callback'. |
|
73 | + * |
|
74 | + * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
75 | + * FHEE__EE_messenger__get_template_fields filter. |
|
76 | + * |
|
77 | + * @since 4.3.0 |
|
78 | + * |
|
79 | + * @param array $template_fields current template fields setup array. |
|
80 | + * @param EE_messenger $messenger |
|
81 | + * @return array new/modified template fields array. |
|
82 | + */ |
|
83 | + public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) { |
|
84 | + if ( $messenger->name !== 'email' ) |
|
85 | + return $template_fields; |
|
86 | 86 | |
87 | - $template_fields['extra']['content']['newsletter_content'] = array( |
|
88 | - 'input' => 'wp_editor', |
|
89 | - 'label' => '[NEWSLETTER_CONTENT]', |
|
90 | - 'type' => 'string', |
|
91 | - 'required' => TRUE, |
|
92 | - 'validation' => TRUE, |
|
93 | - 'format' => '%s', |
|
94 | - 'rows' => '15', |
|
95 | - 'shortcodes_required' => array('[NEWSLETTER_CONTENT]') |
|
96 | - ); |
|
97 | - return $template_fields; |
|
98 | - } |
|
87 | + $template_fields['extra']['content']['newsletter_content'] = array( |
|
88 | + 'input' => 'wp_editor', |
|
89 | + 'label' => '[NEWSLETTER_CONTENT]', |
|
90 | + 'type' => 'string', |
|
91 | + 'required' => TRUE, |
|
92 | + 'validation' => TRUE, |
|
93 | + 'format' => '%s', |
|
94 | + 'rows' => '15', |
|
95 | + 'shortcodes_required' => array('[NEWSLETTER_CONTENT]') |
|
96 | + ); |
|
97 | + return $template_fields; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | } //end class EE_Newsletter_Shortcodes |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ); |
64 | 64 | add_action( |
65 | 65 | 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
66 | - array( $this, 'verify_event_edit' ) |
|
66 | + array($this, 'verify_event_edit') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | $this->_admin_page_title = EVENTS_LABEL; |
80 | 80 | $this->_labels = array( |
81 | 81 | 'buttons' => array( |
82 | - 'add' => esc_html__( 'Add New Event', 'event_espresso' ), |
|
83 | - 'edit' => esc_html__( 'Edit Event', 'event_espresso' ), |
|
84 | - 'delete' => esc_html__( 'Delete Event', 'event_espresso' ), |
|
85 | - 'add_category' => esc_html__( 'Add New Category', 'event_espresso' ), |
|
86 | - 'edit_category' => esc_html__( 'Edit Category', 'event_espresso' ), |
|
87 | - 'delete_category' => esc_html__( 'Delete Category', 'event_espresso' ), |
|
82 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
83 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
84 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
85 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
86 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
87 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
88 | 88 | ), |
89 | 89 | 'editor_title' => array( |
90 | - 'espresso_events' => esc_html__( 'Enter event title here', 'event_espresso' ), |
|
90 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
91 | 91 | ), |
92 | 92 | 'publishbox' => array( |
93 | - 'create_new' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
94 | - 'edit' => esc_html__( 'Update Event', 'event_espresso' ), |
|
95 | - 'add_category' => esc_html__( 'Save New Category', 'event_espresso' ), |
|
96 | - 'edit_category' => esc_html__( 'Update Category', 'event_espresso' ), |
|
97 | - 'template_settings' => esc_html__( 'Update Settings', 'event_espresso' ), |
|
93 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
94 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
95 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
96 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
97 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
98 | 98 | ), |
99 | 99 | ); |
100 | 100 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | //load formatter helper |
106 | 106 | //load field generator helper |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
109 | 109 | ? $this->_req_data['EVT_ID'] : 0; |
110 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
110 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
111 | 111 | $this->_page_routes = array( |
112 | 112 | 'default' => array( |
113 | 113 | 'func' => '_events_overview_list_table', |
@@ -130,27 +130,27 @@ discard block |
||
130 | 130 | ), |
131 | 131 | 'trash_event' => array( |
132 | 132 | 'func' => '_trash_or_restore_event', |
133 | - 'args' => array( 'event_status' => 'trash' ), |
|
133 | + 'args' => array('event_status' => 'trash'), |
|
134 | 134 | 'capability' => 'ee_delete_event', |
135 | 135 | 'obj_id' => $evt_id, |
136 | 136 | 'noheader' => true, |
137 | 137 | ), |
138 | 138 | 'trash_events' => array( |
139 | 139 | 'func' => '_trash_or_restore_events', |
140 | - 'args' => array( 'event_status' => 'trash' ), |
|
140 | + 'args' => array('event_status' => 'trash'), |
|
141 | 141 | 'capability' => 'ee_delete_events', |
142 | 142 | 'noheader' => true, |
143 | 143 | ), |
144 | 144 | 'restore_event' => array( |
145 | 145 | 'func' => '_trash_or_restore_event', |
146 | - 'args' => array( 'event_status' => 'draft' ), |
|
146 | + 'args' => array('event_status' => 'draft'), |
|
147 | 147 | 'capability' => 'ee_delete_event', |
148 | 148 | 'obj_id' => $evt_id, |
149 | 149 | 'noheader' => true, |
150 | 150 | ), |
151 | 151 | 'restore_events' => array( |
152 | 152 | 'func' => '_trash_or_restore_events', |
153 | - 'args' => array( 'event_status' => 'draft' ), |
|
153 | + 'args' => array('event_status' => 'draft'), |
|
154 | 154 | 'capability' => 'ee_delete_events', |
155 | 155 | 'noheader' => true, |
156 | 156 | ), |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | 'add_category' => array( |
187 | 187 | 'func' => '_category_details', |
188 | 188 | 'capability' => 'ee_edit_event_category', |
189 | - 'args' => array( 'add' ), |
|
189 | + 'args' => array('add'), |
|
190 | 190 | ), |
191 | 191 | 'edit_category' => array( |
192 | 192 | 'func' => '_category_details', |
193 | 193 | 'capability' => 'ee_edit_event_category', |
194 | - 'args' => array( 'edit' ), |
|
194 | + 'args' => array('edit'), |
|
195 | 195 | ), |
196 | 196 | 'delete_categories' => array( |
197 | 197 | 'func' => '_delete_categories', |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | ), |
206 | 206 | 'insert_category' => array( |
207 | 207 | 'func' => '_insert_or_update_category', |
208 | - 'args' => array( 'new_category' => true ), |
|
208 | + 'args' => array('new_category' => true), |
|
209 | 209 | 'capability' => 'ee_edit_event_category', |
210 | 210 | 'noheader' => true, |
211 | 211 | ), |
212 | 212 | 'update_category' => array( |
213 | 213 | 'func' => '_insert_or_update_category', |
214 | - 'args' => array( 'new_category' => false ), |
|
214 | + 'args' => array('new_category' => false), |
|
215 | 215 | 'capability' => 'ee_edit_event_category', |
216 | 216 | 'noheader' => true, |
217 | 217 | ), |
@@ -228,29 +228,29 @@ discard block |
||
228 | 228 | $this->_page_config = array( |
229 | 229 | 'default' => array( |
230 | 230 | 'nav' => array( |
231 | - 'label' => esc_html__( 'Overview', 'event_espresso' ), |
|
231 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
232 | 232 | 'order' => 10, |
233 | 233 | ), |
234 | 234 | 'list_table' => 'Events_Admin_List_Table', |
235 | 235 | 'help_tabs' => array( |
236 | 236 | 'events_overview_help_tab' => array( |
237 | - 'title' => esc_html__( 'Events Overview', 'event_espresso' ), |
|
237 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
238 | 238 | 'filename' => 'events_overview', |
239 | 239 | ), |
240 | 240 | 'events_overview_table_column_headings_help_tab' => array( |
241 | - 'title' => esc_html__( 'Events Overview Table Column Headings', 'event_espresso' ), |
|
241 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
242 | 242 | 'filename' => 'events_overview_table_column_headings', |
243 | 243 | ), |
244 | 244 | 'events_overview_filters_help_tab' => array( |
245 | - 'title' => esc_html__( 'Events Overview Filters', 'event_espresso' ), |
|
245 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
246 | 246 | 'filename' => 'events_overview_filters', |
247 | 247 | ), |
248 | 248 | 'events_overview_view_help_tab' => array( |
249 | - 'title' => esc_html__( 'Events Overview Views', 'event_espresso' ), |
|
249 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
250 | 250 | 'filename' => 'events_overview_views', |
251 | 251 | ), |
252 | 252 | 'events_overview_other_help_tab' => array( |
253 | - 'title' => esc_html__( 'Events Overview Other', 'event_espresso' ), |
|
253 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
254 | 254 | 'filename' => 'events_overview_other', |
255 | 255 | ), |
256 | 256 | ), |
@@ -265,218 +265,218 @@ discard block |
||
265 | 265 | ), |
266 | 266 | 'create_new' => array( |
267 | 267 | 'nav' => array( |
268 | - 'label' => esc_html__( 'Add Event', 'event_espresso' ), |
|
268 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
269 | 269 | 'order' => 5, |
270 | 270 | 'persistent' => false, |
271 | 271 | ), |
272 | - 'metaboxes' => array( '_register_event_editor_meta_boxes' ), |
|
272 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
273 | 273 | 'help_tabs' => array( |
274 | 274 | 'event_editor_help_tab' => array( |
275 | - 'title' => esc_html__( 'Event Editor', 'event_espresso' ), |
|
275 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
276 | 276 | 'filename' => 'event_editor', |
277 | 277 | ), |
278 | 278 | 'event_editor_title_richtexteditor_help_tab' => array( |
279 | - 'title' => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ), |
|
279 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
280 | 280 | 'filename' => 'event_editor_title_richtexteditor', |
281 | 281 | ), |
282 | 282 | 'event_editor_venue_details_help_tab' => array( |
283 | - 'title' => esc_html__( 'Event Venue Details', 'event_espresso' ), |
|
283 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
284 | 284 | 'filename' => 'event_editor_venue_details', |
285 | 285 | ), |
286 | 286 | 'event_editor_event_datetimes_help_tab' => array( |
287 | - 'title' => esc_html__( 'Event Datetimes', 'event_espresso' ), |
|
287 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
288 | 288 | 'filename' => 'event_editor_event_datetimes', |
289 | 289 | ), |
290 | 290 | 'event_editor_event_tickets_help_tab' => array( |
291 | - 'title' => esc_html__( 'Event Tickets', 'event_espresso' ), |
|
291 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
292 | 292 | 'filename' => 'event_editor_event_tickets', |
293 | 293 | ), |
294 | 294 | 'event_editor_event_registration_options_help_tab' => array( |
295 | - 'title' => esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
295 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
296 | 296 | 'filename' => 'event_editor_event_registration_options', |
297 | 297 | ), |
298 | 298 | 'event_editor_tags_categories_help_tab' => array( |
299 | - 'title' => esc_html__( 'Event Tags & Categories', 'event_espresso' ), |
|
299 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
300 | 300 | 'filename' => 'event_editor_tags_categories', |
301 | 301 | ), |
302 | 302 | 'event_editor_questions_registrants_help_tab' => array( |
303 | - 'title' => esc_html__( 'Questions for Registrants', 'event_espresso' ), |
|
303 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
304 | 304 | 'filename' => 'event_editor_questions_registrants', |
305 | 305 | ), |
306 | 306 | 'event_editor_save_new_event_help_tab' => array( |
307 | - 'title' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
307 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
308 | 308 | 'filename' => 'event_editor_save_new_event', |
309 | 309 | ), |
310 | 310 | 'event_editor_other_help_tab' => array( |
311 | - 'title' => esc_html__( 'Event Other', 'event_espresso' ), |
|
311 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
312 | 312 | 'filename' => 'event_editor_other', |
313 | 313 | ), |
314 | 314 | ), |
315 | 315 | 'help_tour' => array( |
316 | 316 | 'Event_Editor_Help_Tour', |
317 | 317 | ), |
318 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
318 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
319 | 319 | 'require_nonce' => false, |
320 | 320 | ), |
321 | 321 | 'edit' => array( |
322 | 322 | 'nav' => array( |
323 | - 'label' => esc_html__( 'Edit Event', 'event_espresso' ), |
|
323 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
324 | 324 | 'order' => 5, |
325 | 325 | 'persistent' => false, |
326 | - 'url' => isset( $this->_req_data['post'] ) |
|
326 | + 'url' => isset($this->_req_data['post']) |
|
327 | 327 | ? EE_Admin_Page::add_query_args_and_nonce( |
328 | - array( 'post' => $this->_req_data['post'], 'action' => 'edit' ), |
|
328 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
329 | 329 | $this->_current_page_view_url |
330 | 330 | ) |
331 | 331 | : $this->_admin_base_url, |
332 | 332 | ), |
333 | - 'metaboxes' => array( '_register_event_editor_meta_boxes' ), |
|
333 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
334 | 334 | 'help_tabs' => array( |
335 | 335 | 'event_editor_help_tab' => array( |
336 | - 'title' => esc_html__( 'Event Editor', 'event_espresso' ), |
|
336 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
337 | 337 | 'filename' => 'event_editor', |
338 | 338 | ), |
339 | 339 | 'event_editor_title_richtexteditor_help_tab' => array( |
340 | - 'title' => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ), |
|
340 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
341 | 341 | 'filename' => 'event_editor_title_richtexteditor', |
342 | 342 | ), |
343 | 343 | 'event_editor_venue_details_help_tab' => array( |
344 | - 'title' => esc_html__( 'Event Venue Details', 'event_espresso' ), |
|
344 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
345 | 345 | 'filename' => 'event_editor_venue_details', |
346 | 346 | ), |
347 | 347 | 'event_editor_event_datetimes_help_tab' => array( |
348 | - 'title' => esc_html__( 'Event Datetimes', 'event_espresso' ), |
|
348 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
349 | 349 | 'filename' => 'event_editor_event_datetimes', |
350 | 350 | ), |
351 | 351 | 'event_editor_event_tickets_help_tab' => array( |
352 | - 'title' => esc_html__( 'Event Tickets', 'event_espresso' ), |
|
352 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
353 | 353 | 'filename' => 'event_editor_event_tickets', |
354 | 354 | ), |
355 | 355 | 'event_editor_event_registration_options_help_tab' => array( |
356 | - 'title' => esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
356 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
357 | 357 | 'filename' => 'event_editor_event_registration_options', |
358 | 358 | ), |
359 | 359 | 'event_editor_tags_categories_help_tab' => array( |
360 | - 'title' => esc_html__( 'Event Tags & Categories', 'event_espresso' ), |
|
360 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
361 | 361 | 'filename' => 'event_editor_tags_categories', |
362 | 362 | ), |
363 | 363 | 'event_editor_questions_registrants_help_tab' => array( |
364 | - 'title' => esc_html__( 'Questions for Registrants', 'event_espresso' ), |
|
364 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
365 | 365 | 'filename' => 'event_editor_questions_registrants', |
366 | 366 | ), |
367 | 367 | 'event_editor_save_new_event_help_tab' => array( |
368 | - 'title' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
368 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
369 | 369 | 'filename' => 'event_editor_save_new_event', |
370 | 370 | ), |
371 | 371 | 'event_editor_other_help_tab' => array( |
372 | - 'title' => esc_html__( 'Event Other', 'event_espresso' ), |
|
372 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
373 | 373 | 'filename' => 'event_editor_other', |
374 | 374 | ), |
375 | 375 | ), |
376 | 376 | /*'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ),*/ |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => false, |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
383 | 383 | 'nav' => array( |
384 | - 'label' => esc_html__( 'Default Settings', 'event_espresso' ), |
|
384 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
385 | 385 | 'order' => 40, |
386 | 386 | ), |
387 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
387 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
388 | 388 | 'labels' => array( |
389 | - 'publishbox' => esc_html__( 'Update Settings', 'event_espresso' ), |
|
389 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
390 | 390 | ), |
391 | 391 | 'help_tabs' => array( |
392 | 392 | 'default_settings_help_tab' => array( |
393 | - 'title' => esc_html__( 'Default Event Settings', 'event_espresso' ), |
|
393 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
394 | 394 | 'filename' => 'events_default_settings', |
395 | 395 | ), |
396 | 396 | 'default_settings_status_help_tab' => array( |
397 | - 'title' => esc_html__( 'Default Registration Status', 'event_espresso' ), |
|
397 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
398 | 398 | 'filename' => 'events_default_settings_status', |
399 | 399 | ), |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour' ), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => false, |
403 | 403 | ), |
404 | 404 | //template settings |
405 | 405 | 'template_settings' => array( |
406 | 406 | 'nav' => array( |
407 | - 'label' => esc_html__( 'Templates', 'event_espresso' ), |
|
407 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
408 | 408 | 'order' => 30, |
409 | 409 | ), |
410 | 410 | 'metaboxes' => $this->_default_espresso_metaboxes, |
411 | 411 | 'help_tabs' => array( |
412 | 412 | 'general_settings_templates_help_tab' => array( |
413 | - 'title' => esc_html__( 'Templates', 'event_espresso' ), |
|
413 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
414 | 414 | 'filename' => 'general_settings_templates', |
415 | 415 | ), |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => false, |
419 | 419 | ), |
420 | 420 | //event category stuff |
421 | 421 | 'add_category' => array( |
422 | 422 | 'nav' => array( |
423 | - 'label' => esc_html__( 'Add Category', 'event_espresso' ), |
|
423 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
424 | 424 | 'order' => 15, |
425 | 425 | 'persistent' => false, |
426 | 426 | ), |
427 | 427 | 'help_tabs' => array( |
428 | 428 | 'add_category_help_tab' => array( |
429 | - 'title' => esc_html__( 'Add New Event Category', 'event_espresso' ), |
|
429 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
430 | 430 | 'filename' => 'events_add_category', |
431 | 431 | ), |
432 | 432 | ), |
433 | - 'help_tour' => array( 'Event_Add_Category_Help_Tour' ), |
|
434 | - 'metaboxes' => array( '_publish_post_box' ), |
|
433 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
434 | + 'metaboxes' => array('_publish_post_box'), |
|
435 | 435 | 'require_nonce' => false, |
436 | 436 | ), |
437 | 437 | 'edit_category' => array( |
438 | 438 | 'nav' => array( |
439 | - 'label' => esc_html__( 'Edit Category', 'event_espresso' ), |
|
439 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
440 | 440 | 'order' => 15, |
441 | 441 | 'persistent' => false, |
442 | - 'url' => isset( $this->_req_data['EVT_CAT_ID'] ) |
|
442 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
443 | 443 | ? add_query_arg( |
444 | - array( 'EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), |
|
444 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
445 | 445 | $this->_current_page_view_url |
446 | 446 | ) |
447 | 447 | : $this->_admin_base_url, |
448 | 448 | ), |
449 | 449 | 'help_tabs' => array( |
450 | 450 | 'edit_category_help_tab' => array( |
451 | - 'title' => esc_html__( 'Edit Event Category', 'event_espresso' ), |
|
451 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
452 | 452 | 'filename' => 'events_edit_category', |
453 | 453 | ), |
454 | 454 | ), |
455 | 455 | /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
456 | - 'metaboxes' => array( '_publish_post_box' ), |
|
456 | + 'metaboxes' => array('_publish_post_box'), |
|
457 | 457 | 'require_nonce' => false, |
458 | 458 | ), |
459 | 459 | 'category_list' => array( |
460 | 460 | 'nav' => array( |
461 | - 'label' => esc_html__( 'Categories', 'event_espresso' ), |
|
461 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
462 | 462 | 'order' => 20, |
463 | 463 | ), |
464 | 464 | 'list_table' => 'Event_Categories_Admin_List_Table', |
465 | 465 | 'help_tabs' => array( |
466 | 466 | 'events_categories_help_tab' => array( |
467 | - 'title' => esc_html__( 'Event Categories', 'event_espresso' ), |
|
467 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
468 | 468 | 'filename' => 'events_categories', |
469 | 469 | ), |
470 | 470 | 'events_categories_table_column_headings_help_tab' => array( |
471 | - 'title' => esc_html__( 'Event Categories Table Column Headings', 'event_espresso' ), |
|
471 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
472 | 472 | 'filename' => 'events_categories_table_column_headings', |
473 | 473 | ), |
474 | 474 | 'events_categories_view_help_tab' => array( |
475 | - 'title' => esc_html__( 'Event Categories Views', 'event_espresso' ), |
|
475 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
476 | 476 | 'filename' => 'events_categories_views', |
477 | 477 | ), |
478 | 478 | 'events_categories_other_help_tab' => array( |
479 | - 'title' => esc_html__( 'Event Categories Other', 'event_espresso' ), |
|
479 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
480 | 480 | 'filename' => 'events_categories_other', |
481 | 481 | ), |
482 | 482 | ), |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | protected function _add_screen_options_category_list() { |
507 | 507 | $page_title = $this->_admin_page_title; |
508 | - $this->_admin_page_title = esc_html__( 'Categories', 'event_espresso' ); |
|
508 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
509 | 509 | $this->_per_page_screen_option(); |
510 | 510 | $this->_admin_page_title = $page_title; |
511 | 511 | } |
@@ -521,20 +521,20 @@ discard block |
||
521 | 521 | public function load_scripts_styles() { |
522 | 522 | wp_register_style( |
523 | 523 | 'events-admin-css', |
524 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
524 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
525 | 525 | array(), |
526 | 526 | EVENT_ESPRESSO_VERSION |
527 | 527 | ); |
528 | - wp_register_style( 'ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
529 | - wp_enqueue_style( 'events-admin-css' ); |
|
530 | - wp_enqueue_style( 'ee-cat-admin' ); |
|
528 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
529 | + wp_enqueue_style('events-admin-css'); |
|
530 | + wp_enqueue_style('ee-cat-admin'); |
|
531 | 531 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
532 | 532 | //registers for all views |
533 | 533 | //scripts |
534 | 534 | wp_register_script( |
535 | 535 | 'event_editor_js', |
536 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
537 | - array( 'ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon' ), |
|
536 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
537 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
538 | 538 | EVENT_ESPRESSO_VERSION, |
539 | 539 | true |
540 | 540 | ); |
@@ -560,22 +560,22 @@ discard block |
||
560 | 560 | */ |
561 | 561 | public function load_scripts_styles_edit() { |
562 | 562 | //styles |
563 | - wp_enqueue_style( 'espresso-ui-theme' ); |
|
563 | + wp_enqueue_style('espresso-ui-theme'); |
|
564 | 564 | wp_register_style( |
565 | 565 | 'event-editor-css', |
566 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
567 | - array( 'ee-admin-css' ), |
|
566 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
567 | + array('ee-admin-css'), |
|
568 | 568 | EVENT_ESPRESSO_VERSION |
569 | 569 | ); |
570 | - wp_enqueue_style( 'event-editor-css' ); |
|
570 | + wp_enqueue_style('event-editor-css'); |
|
571 | 571 | //scripts |
572 | 572 | wp_register_script( |
573 | 573 | 'event-datetime-metabox', |
574 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
575 | - array( 'event_editor_js', 'ee-datepicker' ), |
|
574 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
575 | + array('event_editor_js', 'ee-datepicker'), |
|
576 | 576 | EVENT_ESPRESSO_VERSION |
577 | 577 | ); |
578 | - wp_enqueue_script( 'event-datetime-metabox' ); |
|
578 | + wp_enqueue_script('event-datetime-metabox'); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | $this->_views = array( |
596 | 596 | 'all' => array( |
597 | 597 | 'slug' => 'all', |
598 | - 'label' => esc_html__( 'All', 'event_espresso' ), |
|
598 | + 'label' => esc_html__('All', 'event_espresso'), |
|
599 | 599 | 'count' => 0, |
600 | 600 | 'bulk_action' => array( |
601 | - 'delete_categories' => esc_html__( 'Delete Permanently', 'event_espresso' ), |
|
601 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
602 | 602 | ), |
603 | 603 | ), |
604 | 604 | ); |
@@ -634,14 +634,14 @@ discard block |
||
634 | 634 | * @access public |
635 | 635 | * @return void |
636 | 636 | */ |
637 | - public function verify_event_edit( $event = null ) { |
|
637 | + public function verify_event_edit($event = null) { |
|
638 | 638 | // no event? |
639 | - if ( empty( $event ) ) { |
|
639 | + if (empty($event)) { |
|
640 | 640 | // set event |
641 | 641 | $event = $this->_cpt_model_obj; |
642 | 642 | } |
643 | 643 | // STILL no event? |
644 | - if ( empty ( $event ) ) { |
|
644 | + if (empty ($event)) { |
|
645 | 645 | return; |
646 | 646 | } |
647 | 647 | $orig_status = $event->status(); |
@@ -655,32 +655,32 @@ discard block |
||
655 | 655 | return; |
656 | 656 | } |
657 | 657 | //made it here so it IS active... next check that any of the tickets are sold. |
658 | - if ( $event->is_sold_out( true ) ) { |
|
659 | - if ( $orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status ) { |
|
658 | + if ($event->is_sold_out(true)) { |
|
659 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
660 | 660 | EE_Error::add_attention( |
661 | 661 | sprintf( |
662 | 662 | esc_html__( |
663 | 663 | 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
664 | 664 | 'event_espresso' |
665 | 665 | ), |
666 | - EEH_Template::pretty_status( EEM_Event::sold_out, false, 'sentence' ) |
|
666 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
667 | 667 | ) |
668 | 668 | ); |
669 | 669 | } |
670 | 670 | return; |
671 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
671 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
672 | 672 | EE_Error::add_attention( |
673 | 673 | sprintf( |
674 | 674 | esc_html__( |
675 | 675 | 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
676 | 676 | 'event_espresso' |
677 | 677 | ), |
678 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
678 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
679 | 679 | ) |
680 | 680 | ); |
681 | 681 | } |
682 | 682 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
683 | - if ( ! $event->tickets_on_sale() ) { |
|
683 | + if ( ! $event->tickets_on_sale()) { |
|
684 | 684 | return; |
685 | 685 | } |
686 | 686 | //made it here so show warning |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | */ |
699 | 699 | protected function _edit_event_warning() { |
700 | 700 | // we don't want to add warnings during these requests |
701 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] === 'editpost' ) { |
|
701 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
702 | 702 | return; |
703 | 703 | } |
704 | 704 | EE_Error::add_attention( |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | * @return string |
718 | 718 | */ |
719 | 719 | protected function _create_new_cpt_item() { |
720 | - $gmt_offset = get_option( 'gmt_offset' ); |
|
720 | + $gmt_offset = get_option('gmt_offset'); |
|
721 | 721 | //only nag them about setting their timezone if it's their first event, and they haven't already done it |
722 | - if( $gmt_offset === '0' && ! EEM_Event::instance()->exists(array()) ) { |
|
722 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
723 | 723 | EE_Error::add_attention( |
724 | 724 | sprintf( |
725 | - __( 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
725 | + __('Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
726 | 726 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.'), |
727 | - '<a href="' . admin_url( 'options-general.php' ) . '">', |
|
727 | + '<a href="'.admin_url('options-general.php').'">', |
|
728 | 728 | '</a>' |
729 | 729 | ), |
730 | 730 | __FILE__, |
@@ -741,29 +741,29 @@ discard block |
||
741 | 741 | $this->_views = array( |
742 | 742 | 'all' => array( |
743 | 743 | 'slug' => 'all', |
744 | - 'label' => esc_html__( 'View All Events', 'event_espresso' ), |
|
744 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
745 | 745 | 'count' => 0, |
746 | 746 | 'bulk_action' => array( |
747 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
747 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
748 | 748 | ), |
749 | 749 | ), |
750 | 750 | 'draft' => array( |
751 | 751 | 'slug' => 'draft', |
752 | - 'label' => esc_html__( 'Draft', 'event_espresso' ), |
|
752 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
753 | 753 | 'count' => 0, |
754 | 754 | 'bulk_action' => array( |
755 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
755 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
756 | 756 | ), |
757 | 757 | ), |
758 | 758 | ); |
759 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
759 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
760 | 760 | $this->_views['trash'] = array( |
761 | 761 | 'slug' => 'trash', |
762 | - 'label' => esc_html__( 'Trash', 'event_espresso' ), |
|
762 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
763 | 763 | 'count' => 0, |
764 | 764 | 'bulk_action' => array( |
765 | - 'restore_events' => esc_html__( 'Restore From Trash', 'event_espresso' ), |
|
766 | - 'delete_events' => esc_html__( 'Delete Permanently', 'event_espresso' ), |
|
765 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
766 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
767 | 767 | ), |
768 | 768 | ); |
769 | 769 | } |
@@ -778,50 +778,50 @@ discard block |
||
778 | 778 | $items = array( |
779 | 779 | 'view_details' => array( |
780 | 780 | 'class' => 'dashicons dashicons-search', |
781 | - 'desc' => esc_html__( 'View Event', 'event_espresso' ), |
|
781 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
782 | 782 | ), |
783 | 783 | 'edit_event' => array( |
784 | 784 | 'class' => 'ee-icon ee-icon-calendar-edit', |
785 | - 'desc' => esc_html__( 'Edit Event Details', 'event_espresso' ), |
|
785 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
786 | 786 | ), |
787 | 787 | 'view_attendees' => array( |
788 | 788 | 'class' => 'dashicons dashicons-groups', |
789 | - 'desc' => esc_html__( 'View Registrations for Event', 'event_espresso' ), |
|
789 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
790 | 790 | ), |
791 | 791 | ); |
792 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
792 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
793 | 793 | $statuses = array( |
794 | 794 | 'sold_out_status' => array( |
795 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
796 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, false, 'sentence' ), |
|
795 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
796 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
797 | 797 | ), |
798 | 798 | 'active_status' => array( |
799 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
800 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, false, 'sentence' ), |
|
799 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
800 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
801 | 801 | ), |
802 | 802 | 'upcoming_status' => array( |
803 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
804 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, false, 'sentence' ), |
|
803 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
804 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
805 | 805 | ), |
806 | 806 | 'postponed_status' => array( |
807 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
808 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, false, 'sentence' ), |
|
807 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
808 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
809 | 809 | ), |
810 | 810 | 'cancelled_status' => array( |
811 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
812 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, false, 'sentence' ), |
|
811 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
812 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
813 | 813 | ), |
814 | 814 | 'expired_status' => array( |
815 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
816 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, false, 'sentence' ), |
|
815 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
816 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
817 | 817 | ), |
818 | 818 | 'inactive_status' => array( |
819 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
820 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, false, 'sentence' ), |
|
819 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
820 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
821 | 821 | ), |
822 | 822 | ); |
823 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
824 | - return array_merge( $items, $statuses ); |
|
823 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
824 | + return array_merge($items, $statuses); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | * @return EEM_Event |
833 | 833 | */ |
834 | 834 | private function _event_model() { |
835 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
836 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
835 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
836 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
837 | 837 | } |
838 | 838 | return $this->_event_model; |
839 | 839 | } |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | * @param string $new_slug what the slug is |
851 | 851 | * @return string The new html string for the permalink area |
852 | 852 | */ |
853 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
853 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
854 | 854 | //make sure this is only when editing |
855 | - if ( ! empty( $id ) ) { |
|
856 | - $post = get_post( $id ); |
|
855 | + if ( ! empty($id)) { |
|
856 | + $post = get_post($id); |
|
857 | 857 | $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
858 | - . esc_html__( 'Shortcode', 'event_espresso' ) |
|
858 | + . esc_html__('Shortcode', 'event_espresso') |
|
859 | 859 | . '</a> '; |
860 | 860 | $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
861 | 861 | . $post->ID |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | * @return void |
875 | 875 | */ |
876 | 876 | protected function _events_overview_list_table() { |
877 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
877 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
878 | 878 | $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( |
879 | - get_post_type_archive_link( 'espresso_events' ), |
|
880 | - esc_html__( "View Event Archive Page", "event_espresso" ), |
|
879 | + get_post_type_archive_link('espresso_events'), |
|
880 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
881 | 881 | 'button' |
882 | 882 | ); |
883 | - $this->_template_args['after_list_table'] .= $this->_display_legend( $this->_event_legend_items() ); |
|
884 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
883 | + $this->_template_args['after_list_table'] .= $this->_display_legend($this->_event_legend_items()); |
|
884 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
885 | 885 | 'create_new', |
886 | 886 | 'add', |
887 | 887 | array(), |
@@ -907,48 +907,48 @@ discard block |
||
907 | 907 | * @param string $post_id |
908 | 908 | * @param object $post |
909 | 909 | */ |
910 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
911 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
910 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
911 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
912 | 912 | //get out we're not processing an event save. |
913 | 913 | return; |
914 | 914 | } |
915 | 915 | $event_values = array( |
916 | - 'EVT_display_desc' => ! empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
917 | - 'EVT_display_ticket_selector' => ! empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
916 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
917 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
918 | 918 | 'EVT_additional_limit' => min( |
919 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
920 | - ! empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : null |
|
919 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
920 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
921 | 921 | ), |
922 | - 'EVT_default_registration_status' => ! empty( $this->_req_data['EVT_default_registration_status'] ) |
|
922 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
923 | 923 | ? $this->_req_data['EVT_default_registration_status'] |
924 | 924 | : EE_Registry::instance()->CFG->registration->default_STS_ID, |
925 | - 'EVT_member_only' => ! empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
926 | - 'EVT_allow_overflow' => ! empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
927 | - 'EVT_timezone_string' => ! empty( $this->_req_data['timezone_string'] ) |
|
925 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
926 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
927 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
928 | 928 | ? $this->_req_data['timezone_string'] : null, |
929 | - 'EVT_external_URL' => ! empty( $this->_req_data['externalURL'] ) |
|
929 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
930 | 930 | ? $this->_req_data['externalURL'] : null, |
931 | - 'EVT_phone' => ! empty( $this->_req_data['event_phone'] ) |
|
931 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
932 | 932 | ? $this->_req_data['event_phone'] : null, |
933 | 933 | ); |
934 | 934 | //update event |
935 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
935 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
936 | 936 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
937 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
938 | - $event = $this->_event_model()->get_one( array( $get_one_where ) ); |
|
937 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
938 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
939 | 939 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
940 | 940 | $event_update_callbacks = apply_filters( |
941 | 941 | 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
942 | - array( array( $this, '_default_venue_update' ), array( $this, '_default_tickets_update' ) ) |
|
942 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
943 | 943 | ); |
944 | 944 | $att_success = true; |
945 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
946 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
945 | + foreach ($event_update_callbacks as $e_callback) { |
|
946 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
947 | 947 | $att_success = ! $att_success ? $att_success |
948 | 948 | : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
949 | 949 | } |
950 | 950 | //any errors? |
951 | - if ( $success && false === $att_success ) { |
|
951 | + if ($success && false === $att_success) { |
|
952 | 952 | EE_Error::add_error( |
953 | 953 | esc_html__( |
954 | 954 | 'Event Details saved successfully but something went wrong with saving attachments.', |
@@ -958,9 +958,9 @@ discard block |
||
958 | 958 | __FUNCTION__, |
959 | 959 | __LINE__ |
960 | 960 | ); |
961 | - } else if ( $success === false ) { |
|
961 | + } else if ($success === false) { |
|
962 | 962 | EE_Error::add_error( |
963 | - esc_html__( 'Event Details did not save successfully.', 'event_espresso' ), |
|
963 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
964 | 964 | __FILE__, |
965 | 965 | __FUNCTION__, |
966 | 966 | __LINE__ |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | * @param int $post_id |
976 | 976 | * @param int $revision_id |
977 | 977 | */ |
978 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
978 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
979 | 979 | //copy existing event meta to new post |
980 | - $post_evt = $this->_event_model()->get_one_by_ID( $post_id ); |
|
981 | - if ( $post_evt instanceof EE_Event ) { |
|
980 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
981 | + if ($post_evt instanceof EE_Event) { |
|
982 | 982 | //meta revision restore |
983 | - $post_evt->restore_revision( $revision_id ); |
|
983 | + $post_evt->restore_revision($revision_id); |
|
984 | 984 | //related objs restore |
985 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
985 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | |
@@ -995,49 +995,49 @@ discard block |
||
995 | 995 | * @param array $data The request data from the form |
996 | 996 | * @return bool Success or fail. |
997 | 997 | */ |
998 | - protected function _default_venue_update( \EE_Event $evtobj, $data ) { |
|
999 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
1000 | - $venue_model = EE_Registry::instance()->load_model( 'Venue' ); |
|
998 | + protected function _default_venue_update(\EE_Event $evtobj, $data) { |
|
999 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
1000 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1001 | 1001 | $rows_affected = null; |
1002 | - $venue_id = ! empty( $data['venue_id'] ) ? $data['venue_id'] : null; |
|
1002 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1003 | 1003 | // very important. If we don't have a venue name... |
1004 | 1004 | // then we'll get out because not necessary to create empty venue |
1005 | - if ( empty( $data['venue_title'] ) ) { |
|
1005 | + if (empty($data['venue_title'])) { |
|
1006 | 1006 | return false; |
1007 | 1007 | } |
1008 | 1008 | $venue_array = array( |
1009 | - 'VNU_wp_user' => $evtobj->get( 'EVT_wp_user' ), |
|
1010 | - 'VNU_name' => ! empty( $data['venue_title'] ) ? $data['venue_title'] : null, |
|
1011 | - 'VNU_desc' => ! empty( $data['venue_description'] ) ? $data['venue_description'] : null, |
|
1012 | - 'VNU_identifier' => ! empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : null, |
|
1013 | - 'VNU_short_desc' => ! empty( $data['venue_short_description'] ) ? $data['venue_short_description'] |
|
1009 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1010 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1011 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1012 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1013 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1014 | 1014 | : null, |
1015 | - 'VNU_address' => ! empty( $data['address'] ) ? $data['address'] : null, |
|
1016 | - 'VNU_address2' => ! empty( $data['address2'] ) ? $data['address2'] : null, |
|
1017 | - 'VNU_city' => ! empty( $data['city'] ) ? $data['city'] : null, |
|
1018 | - 'STA_ID' => ! empty( $data['state'] ) ? $data['state'] : null, |
|
1019 | - 'CNT_ISO' => ! empty( $data['countries'] ) ? $data['countries'] : null, |
|
1020 | - 'VNU_zip' => ! empty( $data['zip'] ) ? $data['zip'] : null, |
|
1021 | - 'VNU_phone' => ! empty( $data['venue_phone'] ) ? $data['venue_phone'] : null, |
|
1022 | - 'VNU_capacity' => ! empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : null, |
|
1023 | - 'VNU_url' => ! empty( $data['venue_url'] ) ? $data['venue_url'] : null, |
|
1024 | - 'VNU_virtual_phone' => ! empty( $data['virtual_phone'] ) ? $data['virtual_phone'] : null, |
|
1025 | - 'VNU_virtual_url' => ! empty( $data['virtual_url'] ) ? $data['virtual_url'] : null, |
|
1026 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
1015 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1016 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1017 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1018 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1019 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1020 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1021 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1022 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1023 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1024 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1025 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1026 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1027 | 1027 | 'status' => 'publish', |
1028 | 1028 | ); |
1029 | 1029 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
1030 | - if ( ! empty( $venue_id ) ) { |
|
1031 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
1032 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
1030 | + if ( ! empty($venue_id)) { |
|
1031 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1032 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1033 | 1033 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
1034 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
1034 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1035 | 1035 | return $rows_affected > 0 ? true : false; |
1036 | 1036 | } else { |
1037 | 1037 | //we insert the venue |
1038 | - $venue_id = $venue_model->insert( $venue_array ); |
|
1039 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
1040 | - return ! empty( $venue_id ) ? true : false; |
|
1038 | + $venue_id = $venue_model->insert($venue_array); |
|
1039 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1040 | + return ! empty($venue_id) ? true : false; |
|
1041 | 1041 | } |
1042 | 1042 | //when we have the ancestor come in it's already been handled by the revision save. |
1043 | 1043 | } |
@@ -1051,51 +1051,51 @@ discard block |
||
1051 | 1051 | * @param array $data The request data from the form |
1052 | 1052 | * @return array |
1053 | 1053 | */ |
1054 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
1054 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
1055 | 1055 | $success = true; |
1056 | 1056 | $saved_dtt = null; |
1057 | 1057 | $saved_tickets = array(); |
1058 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1059 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
1058 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1059 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1060 | 1060 | //trim all values to ensure any excess whitespace is removed. |
1061 | - $dtt = array_map( 'trim', $dtt ); |
|
1062 | - $dtt['DTT_EVT_end'] = isset( $dtt['DTT_EVT_end'] ) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] |
|
1061 | + $dtt = array_map('trim', $dtt); |
|
1062 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1063 | 1063 | : $dtt['DTT_EVT_start']; |
1064 | 1064 | $datetime_values = array( |
1065 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : null, |
|
1065 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1066 | 1066 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
1067 | 1067 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
1068 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1068 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1069 | 1069 | 'DTT_order' => $row, |
1070 | 1070 | ); |
1071 | 1071 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
1072 | - if ( ! empty( $dtt['DTT_ID'] ) ) { |
|
1072 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1073 | 1073 | $DTM = EE_Registry::instance() |
1074 | - ->load_model( 'Datetime', array( $evtobj->get_timezone() ) ) |
|
1075 | - ->get_one_by_ID( $dtt['DTT_ID'] ); |
|
1076 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
1077 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
1078 | - foreach ( $datetime_values as $field => $value ) { |
|
1079 | - $DTM->set( $field, $value ); |
|
1074 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1075 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1076 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1077 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1078 | + foreach ($datetime_values as $field => $value) { |
|
1079 | + $DTM->set($field, $value); |
|
1080 | 1080 | } |
1081 | 1081 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
1082 | - $saved_dtts[ $DTM->ID() ] = $DTM; |
|
1082 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1083 | 1083 | } else { |
1084 | - $DTM = EE_Registry::instance()->load_class( 'Datetime', array( $datetime_values ), false, false ); |
|
1085 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
1086 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
1087 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
1088 | - foreach ( $datetime_values as $field => $value ) { |
|
1089 | - $DTM->set( $field, $value ); |
|
1084 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), false, false); |
|
1085 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1086 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1087 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
1088 | + foreach ($datetime_values as $field => $value) { |
|
1089 | + $DTM->set($field, $value); |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | $DTM->save(); |
1093 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
1093 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1094 | 1094 | //load DTT helper |
1095 | 1095 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1096 | - if ( $DTT->get_raw( 'DTT_EVT_start' ) > $DTT->get_raw( 'DTT_EVT_end' ) ) { |
|
1097 | - $DTT->set( 'DTT_EVT_end', $DTT->get( 'DTT_EVT_start' ) ); |
|
1098 | - $DTT = EEH_DTT_Helper::date_time_add( $DTT, 'DTT_EVT_end', 'days' ); |
|
1096 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1097 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1098 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1099 | 1099 | $DTT->save(); |
1100 | 1100 | } |
1101 | 1101 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
@@ -1106,20 +1106,20 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | //no dtts get deleted so we don't do any of that logic here. |
1108 | 1108 | //update tickets next |
1109 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode( ',', $data['ticket_IDs'] ) : array(); |
|
1110 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1111 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1109 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1110 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1111 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1112 | 1112 | $update_prices = false; |
1113 | - $ticket_price = isset( $data['edit_prices'][ $row ][1]['PRC_amount'] ) |
|
1114 | - ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0; |
|
1113 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1114 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1115 | 1115 | // trim inputs to ensure any excess whitespace is removed. |
1116 | - $tkt = array_map( 'trim', $tkt ); |
|
1117 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1116 | + $tkt = array_map('trim', $tkt); |
|
1117 | + if (empty($tkt['TKT_start_date'])) { |
|
1118 | 1118 | //let's use now in the set timezone. |
1119 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1120 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1119 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1120 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1121 | 1121 | } |
1122 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1122 | + if (empty($tkt['TKT_end_date'])) { |
|
1123 | 1123 | //use the start date of the first datetime |
1124 | 1124 | $dtt = $evtobj->first_datetime(); |
1125 | 1125 | $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
@@ -1128,22 +1128,22 @@ discard block |
||
1128 | 1128 | ); |
1129 | 1129 | } |
1130 | 1130 | $TKT_values = array( |
1131 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : null, |
|
1132 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1133 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1134 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1131 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1132 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1133 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1134 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1135 | 1135 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1136 | 1136 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1137 | - 'TKT_qty' => ! isset( $tkt['TKT_qty'] ) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1138 | - 'TKT_uses' => ! isset( $tkt['TKT_uses'] ) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1139 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1140 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1137 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1138 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1139 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1140 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1141 | 1141 | 'TKT_row' => $row, |
1142 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1142 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1143 | 1143 | 'TKT_price' => $ticket_price, |
1144 | 1144 | ); |
1145 | 1145 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1146 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1146 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1147 | 1147 | $TKT_values['TKT_ID'] = 0; |
1148 | 1148 | $TKT_values['TKT_is_default'] = 0; |
1149 | 1149 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1152,110 +1152,110 @@ discard block |
||
1152 | 1152 | //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
1153 | 1153 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1154 | 1154 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1155 | - if ( ! empty( $tkt['TKT_ID'] ) ) { |
|
1155 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1156 | 1156 | $TKT = EE_Registry::instance() |
1157 | - ->load_model( 'Ticket', array( $evtobj->get_timezone() ) ) |
|
1158 | - ->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1159 | - if ( $TKT instanceof EE_Ticket ) { |
|
1157 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1158 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1159 | + if ($TKT instanceof EE_Ticket) { |
|
1160 | 1160 | $ticket_sold = $TKT->count_related( |
1161 | 1161 | 'Registration', |
1162 | 1162 | array( |
1163 | 1163 | array( |
1164 | 1164 | 'STS_ID' => array( |
1165 | 1165 | 'NOT IN', |
1166 | - array( EEM_Registration::status_id_incomplete ), |
|
1166 | + array(EEM_Registration::status_id_incomplete), |
|
1167 | 1167 | ), |
1168 | 1168 | ), |
1169 | 1169 | ) |
1170 | 1170 | ) > 0 ? true : false; |
1171 | 1171 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1172 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) |
|
1172 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1173 | 1173 | && ! $TKT->get( |
1174 | 1174 | 'TKT_deleted' |
1175 | 1175 | ) ? true : false; |
1176 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1177 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1176 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1177 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1178 | 1178 | //set new values |
1179 | - foreach ( $TKT_values as $field => $value ) { |
|
1180 | - if ( $field == 'TKT_qty' ) { |
|
1181 | - $TKT->set_qty( $value ); |
|
1179 | + foreach ($TKT_values as $field => $value) { |
|
1180 | + if ($field == 'TKT_qty') { |
|
1181 | + $TKT->set_qty($value); |
|
1182 | 1182 | } else { |
1183 | - $TKT->set( $field, $value ); |
|
1183 | + $TKT->set($field, $value); |
|
1184 | 1184 | } |
1185 | 1185 | } |
1186 | 1186 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1187 | - if ( $create_new_TKT ) { |
|
1187 | + if ($create_new_TKT) { |
|
1188 | 1188 | //archive the old ticket first |
1189 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1189 | + $TKT->set('TKT_deleted', 1); |
|
1190 | 1190 | $TKT->save(); |
1191 | 1191 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1192 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1192 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1193 | 1193 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1194 | 1194 | $TKT = clone $TKT; |
1195 | - $TKT->set( 'TKT_ID', 0 ); |
|
1196 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1197 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1198 | - $TKT->set( 'TKT_sold', 0 ); |
|
1195 | + $TKT->set('TKT_ID', 0); |
|
1196 | + $TKT->set('TKT_deleted', 0); |
|
1197 | + $TKT->set('TKT_price', $ticket_price); |
|
1198 | + $TKT->set('TKT_sold', 0); |
|
1199 | 1199 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1200 | 1200 | $update_prices = true; |
1201 | 1201 | } |
1202 | 1202 | //make sure price is set if it hasn't been already |
1203 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1203 | + $TKT->set('TKT_price', $ticket_price); |
|
1204 | 1204 | } |
1205 | 1205 | } else { |
1206 | 1206 | //no TKT_id so a new TKT |
1207 | 1207 | $TKT_values['TKT_price'] = $ticket_price; |
1208 | - $TKT = EE_Registry::instance()->load_class( 'Ticket', array( $TKT_values ), false, false ); |
|
1209 | - if ( $TKT instanceof EE_Ticket ) { |
|
1208 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1209 | + if ($TKT instanceof EE_Ticket) { |
|
1210 | 1210 | //need to reset values to properly account for the date formats |
1211 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1212 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1213 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1211 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1212 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1213 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1214 | 1214 | //set new values |
1215 | - foreach ( $TKT_values as $field => $value ) { |
|
1216 | - if ( $field == 'TKT_qty' ) { |
|
1217 | - $TKT->set_qty( $value ); |
|
1215 | + foreach ($TKT_values as $field => $value) { |
|
1216 | + if ($field == 'TKT_qty') { |
|
1217 | + $TKT->set_qty($value); |
|
1218 | 1218 | } else { |
1219 | - $TKT->set( $field, $value ); |
|
1219 | + $TKT->set($field, $value); |
|
1220 | 1220 | } |
1221 | 1221 | } |
1222 | 1222 | $update_prices = true; |
1223 | 1223 | } |
1224 | 1224 | } |
1225 | 1225 | // cap ticket qty by datetime reg limits |
1226 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1226 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1227 | 1227 | //update ticket. |
1228 | 1228 | $TKT->save(); |
1229 | 1229 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1230 | - if ( $TKT->get_raw( 'TKT_start_date' ) > $TKT->get_raw( 'TKT_end_date' ) ) { |
|
1231 | - $TKT->set( 'TKT_end_date', $TKT->get( 'TKT_start_date' ) ); |
|
1232 | - $TKT = EEH_DTT_Helper::date_time_add( $TKT, 'TKT_end_date', 'days' ); |
|
1230 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1231 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1232 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1233 | 1233 | $TKT->save(); |
1234 | 1234 | } |
1235 | 1235 | //initially let's add the ticket to the dtt |
1236 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1237 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1236 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1237 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1238 | 1238 | //add prices to ticket |
1239 | - $this->_add_prices_to_ticket( $data['edit_prices'][ $row ], $TKT, $update_prices ); |
|
1239 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1240 | 1240 | } |
1241 | 1241 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1242 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1243 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1244 | - foreach ( $tickets_removed as $id ) { |
|
1245 | - $id = absint( $id ); |
|
1242 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1243 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1244 | + foreach ($tickets_removed as $id) { |
|
1245 | + $id = absint($id); |
|
1246 | 1246 | //get the ticket for this id |
1247 | - $tkt_to_remove = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $id ); |
|
1247 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1248 | 1248 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1249 | - $dtts = $tkt_to_remove->get_many_related( 'Datetime' ); |
|
1250 | - foreach ( $dtts as $dtt ) { |
|
1251 | - $tkt_to_remove->_remove_relation_to( $dtt, 'Datetime' ); |
|
1249 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1250 | + foreach ($dtts as $dtt) { |
|
1251 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1252 | 1252 | } |
1253 | 1253 | //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
1254 | - $tkt_to_remove->delete_related_permanently( 'Price' ); |
|
1254 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1255 | 1255 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1256 | 1256 | $tkt_to_remove->delete_permanently(); |
1257 | 1257 | } |
1258 | - return array( $saved_dtt, $saved_tickets ); |
|
1258 | + return array($saved_dtt, $saved_tickets); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | |
@@ -1272,29 +1272,29 @@ discard block |
||
1272 | 1272 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1273 | 1273 | * @return void |
1274 | 1274 | */ |
1275 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = false ) { |
|
1276 | - foreach ( $prices as $row => $prc ) { |
|
1275 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) { |
|
1276 | + foreach ($prices as $row => $prc) { |
|
1277 | 1277 | $PRC_values = array( |
1278 | - 'PRC_ID' => ! empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : null, |
|
1279 | - 'PRT_ID' => ! empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : null, |
|
1280 | - 'PRC_amount' => ! empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1281 | - 'PRC_name' => ! empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1282 | - 'PRC_desc' => ! empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1278 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1279 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1280 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1281 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1282 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1283 | 1283 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1284 | 1284 | 'PRC_order' => $row, |
1285 | 1285 | ); |
1286 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1286 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1287 | 1287 | $PRC_values['PRC_ID'] = 0; |
1288 | - $PRC = EE_Registry::instance()->load_class( 'Price', array( $PRC_values ), false, false ); |
|
1288 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1289 | 1289 | } else { |
1290 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1290 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1291 | 1291 | //update this price with new values |
1292 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1293 | - $PRC->set( $field, $newprc ); |
|
1292 | + foreach ($PRC_values as $field => $newprc) { |
|
1293 | + $PRC->set($field, $newprc); |
|
1294 | 1294 | } |
1295 | 1295 | $PRC->save(); |
1296 | 1296 | } |
1297 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1297 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | private function _generate_publish_box_extra_content() { |
1327 | 1327 | //load formatter helper |
1328 | 1328 | //args for getting related registrations |
1329 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1329 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1330 | 1330 | $not_approved_query_args = array( |
1331 | 1331 | array( |
1332 | 1332 | 'REG_deleted' => 0, |
@@ -1397,7 +1397,7 @@ discard block |
||
1397 | 1397 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
1398 | 1398 | // load template |
1399 | 1399 | EEH_Template::display_template( |
1400 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1400 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
1401 | 1401 | $publish_box_extra_args |
1402 | 1402 | ); |
1403 | 1403 | } |
@@ -1431,16 +1431,16 @@ discard block |
||
1431 | 1431 | $this->verify_cpt_object(); |
1432 | 1432 | add_meta_box( |
1433 | 1433 | 'espresso_event_editor_tickets', |
1434 | - esc_html__( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1435 | - array( $this, 'ticket_metabox' ), |
|
1434 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1435 | + array($this, 'ticket_metabox'), |
|
1436 | 1436 | $this->page_slug, |
1437 | 1437 | 'normal', |
1438 | 1438 | 'high' |
1439 | 1439 | ); |
1440 | 1440 | add_meta_box( |
1441 | 1441 | 'espresso_event_editor_event_options', |
1442 | - esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
1443 | - array( $this, 'registration_options_meta_box' ), |
|
1442 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1443 | + array($this, 'registration_options_meta_box'), |
|
1444 | 1444 | $this->page_slug, |
1445 | 1445 | 'side', |
1446 | 1446 | 'default' |
@@ -1468,65 +1468,65 @@ discard block |
||
1468 | 1468 | 'trash_icon' => 'ee-lock-icon', |
1469 | 1469 | 'disabled' => '', |
1470 | 1470 | ); |
1471 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : null; |
|
1472 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1471 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1472 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1473 | 1473 | /** |
1474 | 1474 | * 1. Start with retrieving Datetimes |
1475 | 1475 | * 2. Fore each datetime get related tickets |
1476 | 1476 | * 3. For each ticket get related prices |
1477 | 1477 | */ |
1478 | - $times = EE_Registry::instance()->load_model( 'Datetime' )->get_all_event_dates( $event_id ); |
|
1478 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1479 | 1479 | /** @type EE_Datetime $first_datetime */ |
1480 | - $first_datetime = reset( $times ); |
|
1480 | + $first_datetime = reset($times); |
|
1481 | 1481 | //do we get related tickets? |
1482 | - if ( $first_datetime instanceof EE_Datetime |
|
1482 | + if ($first_datetime instanceof EE_Datetime |
|
1483 | 1483 | && $first_datetime->ID() !== 0 |
1484 | 1484 | ) { |
1485 | - $existing_datetime_ids[] = $first_datetime->get( 'DTT_ID' ); |
|
1485 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1486 | 1486 | $template_args['time'] = $first_datetime; |
1487 | 1487 | $related_tickets = $first_datetime->tickets( |
1488 | 1488 | array( |
1489 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1489 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1490 | 1490 | 'default_where_conditions' => 'none', |
1491 | 1491 | ) |
1492 | 1492 | ); |
1493 | - if ( ! empty( $related_tickets ) ) { |
|
1494 | - $template_args['total_ticket_rows'] = count( $related_tickets ); |
|
1493 | + if ( ! empty($related_tickets)) { |
|
1494 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1495 | 1495 | $row = 0; |
1496 | - foreach ( $related_tickets as $ticket ) { |
|
1497 | - $existing_ticket_ids[] = $ticket->get( 'TKT_ID' ); |
|
1498 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket, false, $row ); |
|
1496 | + foreach ($related_tickets as $ticket) { |
|
1497 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1498 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1499 | 1499 | $row++; |
1500 | 1500 | } |
1501 | 1501 | } else { |
1502 | 1502 | $template_args['total_ticket_rows'] = 1; |
1503 | 1503 | /** @type EE_Ticket $ticket */ |
1504 | - $ticket = EE_Registry::instance()->load_model( 'Ticket' )->create_default_object(); |
|
1505 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1504 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1505 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1506 | 1506 | } |
1507 | 1507 | } else { |
1508 | 1508 | $template_args['time'] = $times[0]; |
1509 | 1509 | /** @type EE_Ticket $ticket */ |
1510 | - $ticket = EE_Registry::instance()->load_model( 'Ticket' )->get_all_default_tickets(); |
|
1511 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1510 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1511 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1512 | 1512 | // NOTE: we're just sending the first default row |
1513 | 1513 | // (decaf can't manage default tickets so this should be sufficient); |
1514 | 1514 | } |
1515 | 1515 | $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
1516 | 1516 | 'event_editor_event_datetimes_help_tab' |
1517 | 1517 | ); |
1518 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link( 'ticket_options_info' ); |
|
1519 | - $template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
1520 | - $template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
1518 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1519 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1520 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1521 | 1521 | $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
1522 | - EE_Registry::instance()->load_model( 'Ticket' )->create_default_object(), |
|
1522 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1523 | 1523 | true |
1524 | 1524 | ); |
1525 | 1525 | $template = apply_filters( |
1526 | 1526 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
1527 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1527 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
1528 | 1528 | ); |
1529 | - EEH_Template::display_template( $template, $template_args ); |
|
1529 | + EEH_Template::display_template($template, $template_args); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | |
@@ -1540,74 +1540,74 @@ discard block |
||
1540 | 1540 | * @param int $row |
1541 | 1541 | * @return string generated html for the ticket row. |
1542 | 1542 | */ |
1543 | - private function _get_ticket_row( $ticket, $skeleton = false, $row = 0 ) { |
|
1543 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) { |
|
1544 | 1544 | $template_args = array( |
1545 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1545 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1546 | 1546 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
1547 | 1547 | : '', |
1548 | 1548 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1549 | - 'TKT_ID' => $ticket->get( 'TKT_ID' ), |
|
1550 | - 'TKT_name' => $ticket->get( 'TKT_name' ), |
|
1551 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date( 'TKT_start_date', 'Y-m-d h:i a' ), |
|
1552 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date( 'TKT_end_date', 'Y-m-d h:i a' ), |
|
1553 | - 'TKT_is_default' => $ticket->get( 'TKT_is_default' ), |
|
1554 | - 'TKT_qty' => $ticket->get_pretty( 'TKT_qty', 'input' ), |
|
1549 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1550 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1551 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1552 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1553 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1554 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1555 | 1555 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1556 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get( 'TKT_sold' ), |
|
1557 | - 'trash_icon' => ( $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ) |
|
1558 | - && ( ! empty( $ticket ) && $ticket->get( 'TKT_sold' ) === 0 ) |
|
1556 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1557 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1558 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1559 | 1559 | ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
1560 | - 'disabled' => $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ? '' |
|
1560 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1561 | 1561 | : ' disabled=disabled', |
1562 | 1562 | ); |
1563 | 1563 | $price = $ticket->ID() !== 0 |
1564 | - ? $ticket->get_first_related( 'Price', array( 'default_where_conditions' => 'none' ) ) |
|
1565 | - : EE_Registry::instance()->load_model( 'Price' )->create_default_object(); |
|
1564 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1565 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1566 | 1566 | $price_args = array( |
1567 | 1567 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1568 | - 'PRC_amount' => $price->get( 'PRC_amount' ), |
|
1569 | - 'PRT_ID' => $price->get( 'PRT_ID' ), |
|
1570 | - 'PRC_ID' => $price->get( 'PRC_ID' ), |
|
1571 | - 'PRC_is_default' => $price->get( 'PRC_is_default' ), |
|
1568 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1569 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1570 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1571 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1572 | 1572 | ); |
1573 | 1573 | //make sure we have default start and end dates if skeleton |
1574 | 1574 | //handle rows that should NOT be empty |
1575 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1575 | + if (empty($template_args['TKT_start_date'])) { |
|
1576 | 1576 | //if empty then the start date will be now. |
1577 | - $template_args['TKT_start_date'] = date( 'Y-m-d h:i a', current_time( 'timestamp' ) ); |
|
1577 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1578 | 1578 | } |
1579 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1579 | + if (empty($template_args['TKT_end_date'])) { |
|
1580 | 1580 | //get the earliest datetime (if present); |
1581 | 1581 | $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
1582 | 1582 | ? $this->_cpt_model_obj->get_first_related( |
1583 | 1583 | 'Datetime', |
1584 | - array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) |
|
1584 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1585 | 1585 | ) |
1586 | 1586 | : null; |
1587 | - if ( ! empty( $earliest_dtt ) ) { |
|
1588 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime( 'DTT_EVT_start', 'Y-m-d', 'h:i a' ); |
|
1587 | + if ( ! empty($earliest_dtt)) { |
|
1588 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1589 | 1589 | } else { |
1590 | 1590 | $template_args['TKT_end_date'] = date( |
1591 | 1591 | 'Y-m-d h:i a', |
1592 | - mktime( 0, 0, 0, date( "m" ), date( "d" ) + 7, date( "Y" ) ) |
|
1592 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1593 | 1593 | ); |
1594 | 1594 | } |
1595 | 1595 | } |
1596 | - $template_args = array_merge( $template_args, $price_args ); |
|
1596 | + $template_args = array_merge($template_args, $price_args); |
|
1597 | 1597 | $template = apply_filters( |
1598 | 1598 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
1599 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1599 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
1600 | 1600 | $ticket |
1601 | 1601 | ); |
1602 | - return EEH_Template::display_template( $template, $template_args, true ); |
|
1602 | + return EEH_Template::display_template($template, $template_args, true); |
|
1603 | 1603 | } |
1604 | 1604 | |
1605 | 1605 | |
1606 | 1606 | |
1607 | 1607 | public function registration_options_meta_box() { |
1608 | 1608 | $yes_no_values = array( |
1609 | - array( 'id' => true, 'text' => esc_html__( 'Yes', 'event_espresso' ) ), |
|
1610 | - array( 'id' => false, 'text' => esc_html__( 'No', 'event_espresso' ) ), |
|
1609 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1610 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1611 | 1611 | ); |
1612 | 1612 | $default_reg_status_values = EEM_Registration::reg_status_array( |
1613 | 1613 | array( |
@@ -1619,7 +1619,7 @@ discard block |
||
1619 | 1619 | ); |
1620 | 1620 | //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
1621 | 1621 | $template_args['_event'] = $this->_cpt_model_obj; |
1622 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status( false ); |
|
1622 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1623 | 1623 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
1624 | 1624 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
1625 | 1625 | 'default_reg_status', |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | $default_reg_status_values |
1648 | 1648 | ); |
1649 | 1649 | EEH_Template::display_template( |
1650 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1650 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1651 | 1651 | $template_args |
1652 | 1652 | ); |
1653 | 1653 | } |
@@ -1666,97 +1666,97 @@ discard block |
||
1666 | 1666 | * that match the given _view and paging parameters. |
1667 | 1667 | * @return array an array of event objects. |
1668 | 1668 | */ |
1669 | - public function get_events( $per_page = 10, $current_page = 1, $count = false ) { |
|
1669 | + public function get_events($per_page = 10, $current_page = 1, $count = false) { |
|
1670 | 1670 | $EEME = $this->_event_model(); |
1671 | - $offset = ( $current_page - 1 ) * $per_page; |
|
1672 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1673 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1674 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : "DESC"; |
|
1675 | - if ( isset( $this->_req_data['month_range'] ) ) { |
|
1676 | - $pieces = explode( ' ', $this->_req_data['month_range'], 3 ); |
|
1677 | - $month_r = ! empty( $pieces[0] ) ? date( 'm', strtotime( $pieces[0] ) ) : ''; |
|
1678 | - $year_r = ! empty( $pieces[1] ) ? $pieces[1] : ''; |
|
1671 | + $offset = ($current_page - 1) * $per_page; |
|
1672 | + $limit = $count ? null : $offset.','.$per_page; |
|
1673 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1674 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1675 | + if (isset($this->_req_data['month_range'])) { |
|
1676 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1677 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1678 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1679 | 1679 | } |
1680 | 1680 | $where = array(); |
1681 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : null; |
|
1681 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1682 | 1682 | //determine what post_status our condition will have for the query. |
1683 | - switch ( $status ) { |
|
1683 | + switch ($status) { |
|
1684 | 1684 | case 'month' : |
1685 | 1685 | case 'today' : |
1686 | 1686 | case null : |
1687 | 1687 | case 'all' : |
1688 | 1688 | break; |
1689 | 1689 | case 'draft' : |
1690 | - $where['status'] = array( 'IN', array( 'draft', 'auto-draft' ) ); |
|
1690 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1691 | 1691 | break; |
1692 | 1692 | default : |
1693 | 1693 | $where['status'] = $status; |
1694 | 1694 | } |
1695 | 1695 | //categories? |
1696 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 |
|
1696 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1697 | 1697 | ? $this->_req_data['EVT_CAT'] : null; |
1698 | - if ( ! empty ( $category ) ) { |
|
1698 | + if ( ! empty ($category)) { |
|
1699 | 1699 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1700 | 1700 | $where['Term_Taxonomy.term_id'] = $category; |
1701 | 1701 | } |
1702 | 1702 | //date where conditions |
1703 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1704 | - if ( isset( $this->_req_data['month_range'] ) && $this->_req_data['month_range'] != '' ) { |
|
1703 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1704 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1705 | 1705 | $DateTime = new DateTime( |
1706 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1707 | - new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) |
|
1706 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
1707 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1708 | 1708 | ); |
1709 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1710 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format( 't' ) )->setTime( 23, 59, 59 )->format( |
|
1711 | - implode( ' ', $start_formats ) |
|
1709 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1710 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format( |
|
1711 | + implode(' ', $start_formats) |
|
1712 | 1712 | ); |
1713 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1714 | - } else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'today' ) { |
|
1715 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1716 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1717 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1718 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1719 | - } else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'month' ) { |
|
1720 | - $now = date( 'Y-m-01' ); |
|
1721 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1722 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1723 | - $end = $DateTime->setDate( date( 'Y' ), date( 'm' ), $DateTime->format( 't' ) ) |
|
1724 | - ->setTime( 23, 59, 59 ) |
|
1725 | - ->format( implode( ' ', $start_formats ) ); |
|
1726 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1713 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1714 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1715 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1716 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1717 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1718 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1719 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1720 | + $now = date('Y-m-01'); |
|
1721 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1722 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1723 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1724 | + ->setTime(23, 59, 59) |
|
1725 | + ->format(implode(' ', $start_formats)); |
|
1726 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1727 | 1727 | } |
1728 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1728 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1729 | 1729 | $where['EVT_wp_user'] = get_current_user_id(); |
1730 | 1730 | } else { |
1731 | - if ( ! isset( $where['status'] ) ) { |
|
1732 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1731 | + if ( ! isset($where['status'])) { |
|
1732 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1733 | 1733 | $where['OR'] = array( |
1734 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1734 | + 'status*restrict_private' => array('!=', 'private'), |
|
1735 | 1735 | 'AND' => array( |
1736 | - 'status*inclusive' => array( '=', 'private' ), |
|
1736 | + 'status*inclusive' => array('=', 'private'), |
|
1737 | 1737 | 'EVT_wp_user' => get_current_user_id(), |
1738 | 1738 | ), |
1739 | 1739 | ); |
1740 | 1740 | } |
1741 | 1741 | } |
1742 | 1742 | } |
1743 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1744 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1745 | - && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) |
|
1743 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1744 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1745 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1746 | 1746 | ) { |
1747 | 1747 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1748 | 1748 | } |
1749 | 1749 | } |
1750 | 1750 | //search query handling |
1751 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1752 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1751 | + if (isset($this->_req_data['s'])) { |
|
1752 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1753 | 1753 | $where['OR'] = array( |
1754 | - 'EVT_name' => array( 'LIKE', $search_string ), |
|
1755 | - 'EVT_desc' => array( 'LIKE', $search_string ), |
|
1756 | - 'EVT_short_desc' => array( 'LIKE', $search_string ), |
|
1754 | + 'EVT_name' => array('LIKE', $search_string), |
|
1755 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1756 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1757 | 1757 | ); |
1758 | 1758 | } |
1759 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1759 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1760 | 1760 | $query_params = apply_filters( |
1761 | 1761 | 'FHEE__Events_Admin_Page__get_events__query_params', |
1762 | 1762 | array( |
@@ -1769,23 +1769,23 @@ discard block |
||
1769 | 1769 | $this->_req_data |
1770 | 1770 | ); |
1771 | 1771 | //let's first check if we have special requests coming in. |
1772 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1773 | - switch ( $this->_req_data['active_status'] ) { |
|
1772 | + if (isset($this->_req_data['active_status'])) { |
|
1773 | + switch ($this->_req_data['active_status']) { |
|
1774 | 1774 | case 'upcoming' : |
1775 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1775 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1776 | 1776 | break; |
1777 | 1777 | case 'expired' : |
1778 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1778 | + return $EEME->get_expired_events($query_params, $count); |
|
1779 | 1779 | break; |
1780 | 1780 | case 'active' : |
1781 | - return $EEME->get_active_events( $query_params, $count ); |
|
1781 | + return $EEME->get_active_events($query_params, $count); |
|
1782 | 1782 | break; |
1783 | 1783 | case 'inactive' : |
1784 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1784 | + return $EEME->get_inactive_events($query_params, $count); |
|
1785 | 1785 | break; |
1786 | 1786 | } |
1787 | 1787 | } |
1788 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1788 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1789 | 1789 | return $events; |
1790 | 1790 | } |
1791 | 1791 | |
@@ -1796,9 +1796,9 @@ discard block |
||
1796 | 1796 | * |
1797 | 1797 | * @param string $post_id |
1798 | 1798 | */ |
1799 | - public function trash_cpt_item( $post_id ) { |
|
1799 | + public function trash_cpt_item($post_id) { |
|
1800 | 1800 | $this->_req_data['EVT_ID'] = $post_id; |
1801 | - $this->_trash_or_restore_event( 'trash', false ); |
|
1801 | + $this->_trash_or_restore_event('trash', false); |
|
1802 | 1802 | } |
1803 | 1803 | |
1804 | 1804 | |
@@ -1806,9 +1806,9 @@ discard block |
||
1806 | 1806 | /** |
1807 | 1807 | * @param string $post_id |
1808 | 1808 | */ |
1809 | - public function restore_cpt_item( $post_id ) { |
|
1809 | + public function restore_cpt_item($post_id) { |
|
1810 | 1810 | $this->_req_data['EVT_ID'] = $post_id; |
1811 | - $this->_trash_or_restore_event( 'draft', false ); |
|
1811 | + $this->_trash_or_restore_event('draft', false); |
|
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | |
@@ -1816,9 +1816,9 @@ discard block |
||
1816 | 1816 | /** |
1817 | 1817 | * @param string $post_id |
1818 | 1818 | */ |
1819 | - public function delete_cpt_item( $post_id ) { |
|
1819 | + public function delete_cpt_item($post_id) { |
|
1820 | 1820 | $this->_req_data['EVT_ID'] = $post_id; |
1821 | - $this->_delete_event( false ); |
|
1821 | + $this->_delete_event(false); |
|
1822 | 1822 | } |
1823 | 1823 | |
1824 | 1824 | |
@@ -1830,23 +1830,23 @@ discard block |
||
1830 | 1830 | * @param string $event_status |
1831 | 1831 | * @param bool $redirect_after |
1832 | 1832 | */ |
1833 | - protected function _trash_or_restore_event( $event_status = 'trash', $redirect_after = true ) { |
|
1833 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) { |
|
1834 | 1834 | //determine the event id and set to array. |
1835 | - $EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : false; |
|
1835 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1836 | 1836 | // loop thru events |
1837 | - if ( $EVT_ID ) { |
|
1837 | + if ($EVT_ID) { |
|
1838 | 1838 | // clean status |
1839 | - $event_status = sanitize_key( $event_status ); |
|
1839 | + $event_status = sanitize_key($event_status); |
|
1840 | 1840 | // grab status |
1841 | - if ( ! empty( $event_status ) ) { |
|
1842 | - $success = $this->_change_event_status( $EVT_ID, $event_status ); |
|
1841 | + if ( ! empty($event_status)) { |
|
1842 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1843 | 1843 | } else { |
1844 | 1844 | $success = false; |
1845 | 1845 | $msg = esc_html__( |
1846 | 1846 | 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
1847 | 1847 | 'event_espresso' |
1848 | 1848 | ); |
1849 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1849 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1850 | 1850 | } |
1851 | 1851 | } else { |
1852 | 1852 | $success = false; |
@@ -1854,11 +1854,11 @@ discard block |
||
1854 | 1854 | 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
1855 | 1855 | 'event_espresso' |
1856 | 1856 | ); |
1857 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1857 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1858 | 1858 | } |
1859 | 1859 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1860 | - if ( $redirect_after ) { |
|
1861 | - $this->_redirect_after_action( $success, 'Event', $action, array( 'action' => 'default' ) ); |
|
1860 | + if ($redirect_after) { |
|
1861 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1862 | 1862 | } |
1863 | 1863 | } |
1864 | 1864 | |
@@ -1871,18 +1871,18 @@ discard block |
||
1871 | 1871 | * @param string $event_status |
1872 | 1872 | * @return void |
1873 | 1873 | */ |
1874 | - protected function _trash_or_restore_events( $event_status = 'trash' ) { |
|
1874 | + protected function _trash_or_restore_events($event_status = 'trash') { |
|
1875 | 1875 | // clean status |
1876 | - $event_status = sanitize_key( $event_status ); |
|
1876 | + $event_status = sanitize_key($event_status); |
|
1877 | 1877 | // grab status |
1878 | - if ( ! empty( $event_status ) ) { |
|
1878 | + if ( ! empty($event_status)) { |
|
1879 | 1879 | $success = true; |
1880 | 1880 | //determine the event id and set to array. |
1881 | - $EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1881 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1882 | 1882 | // loop thru events |
1883 | - foreach ( $EVT_IDs as $EVT_ID ) { |
|
1884 | - if ( $EVT_ID = absint( $EVT_ID ) ) { |
|
1885 | - $results = $this->_change_event_status( $EVT_ID, $event_status ); |
|
1883 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1884 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1885 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1886 | 1886 | $success = $results !== false ? $success : false; |
1887 | 1887 | } else { |
1888 | 1888 | $msg = sprintf( |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | ), |
1893 | 1893 | $EVT_ID |
1894 | 1894 | ); |
1895 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1895 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1896 | 1896 | $success = false; |
1897 | 1897 | } |
1898 | 1898 | } |
@@ -1902,12 +1902,12 @@ discard block |
||
1902 | 1902 | 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
1903 | 1903 | 'event_espresso' |
1904 | 1904 | ); |
1905 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1905 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1906 | 1906 | } |
1907 | 1907 | // in order to force a pluralized result message we need to send back a success status greater than 1 |
1908 | 1908 | $success = $success ? 2 : false; |
1909 | 1909 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1910 | - $this->_redirect_after_action( $success, 'Events', $action, array( 'action' => 'default' ) ); |
|
1910 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1911 | 1911 | } |
1912 | 1912 | |
1913 | 1913 | |
@@ -1920,30 +1920,30 @@ discard block |
||
1920 | 1920 | * @param string $event_status |
1921 | 1921 | * @return bool |
1922 | 1922 | */ |
1923 | - private function _change_event_status( $EVT_ID = 0, $event_status = '' ) { |
|
1923 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1924 | 1924 | // grab event id |
1925 | - if ( ! $EVT_ID ) { |
|
1925 | + if ( ! $EVT_ID) { |
|
1926 | 1926 | $msg = esc_html__( |
1927 | 1927 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
1928 | 1928 | 'event_espresso' |
1929 | 1929 | ); |
1930 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1930 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1931 | 1931 | return false; |
1932 | 1932 | } |
1933 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1933 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1934 | 1934 | // clean status |
1935 | - $event_status = sanitize_key( $event_status ); |
|
1935 | + $event_status = sanitize_key($event_status); |
|
1936 | 1936 | // grab status |
1937 | - if ( empty( $event_status ) ) { |
|
1937 | + if (empty($event_status)) { |
|
1938 | 1938 | $msg = esc_html__( |
1939 | 1939 | 'An error occurred. No Event Status or an invalid Event Status was received.', |
1940 | 1940 | 'event_espresso' |
1941 | 1941 | ); |
1942 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1942 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1943 | 1943 | return false; |
1944 | 1944 | } |
1945 | 1945 | // was event trashed or restored ? |
1946 | - switch ( $event_status ) { |
|
1946 | + switch ($event_status) { |
|
1947 | 1947 | case 'draft' : |
1948 | 1948 | $action = 'restored from the trash'; |
1949 | 1949 | $hook = 'AHEE_event_restored_from_trash'; |
@@ -1957,15 +1957,15 @@ discard block |
||
1957 | 1957 | $hook = false; |
1958 | 1958 | } |
1959 | 1959 | //use class to change status |
1960 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1960 | + $this->_cpt_model_obj->set_status($event_status); |
|
1961 | 1961 | $success = $this->_cpt_model_obj->save(); |
1962 | - if ( $success === false ) { |
|
1963 | - $msg = sprintf( esc_html__( 'An error occurred. The event could not be %s.', 'event_espresso' ), $action ); |
|
1964 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1962 | + if ($success === false) { |
|
1963 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
1964 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1965 | 1965 | return false; |
1966 | 1966 | } |
1967 | - if ( $hook ) { |
|
1968 | - do_action( $hook ); |
|
1967 | + if ($hook) { |
|
1968 | + do_action($hook); |
|
1969 | 1969 | } |
1970 | 1970 | return true; |
1971 | 1971 | } |
@@ -1978,34 +1978,34 @@ discard block |
||
1978 | 1978 | * @access protected |
1979 | 1979 | * @param bool $redirect_after |
1980 | 1980 | */ |
1981 | - protected function _delete_event( $redirect_after = true ) { |
|
1981 | + protected function _delete_event($redirect_after = true) { |
|
1982 | 1982 | //determine the event id and set to array. |
1983 | - $EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : null; |
|
1984 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1983 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
1984 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1985 | 1985 | // loop thru events |
1986 | - if ( $EVT_ID ) { |
|
1987 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1986 | + if ($EVT_ID) { |
|
1987 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1988 | 1988 | // get list of events with no prices |
1989 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() ); |
|
1989 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
1990 | 1990 | // remove this event from the list of events with no prices |
1991 | - if ( isset( $espresso_no_ticket_prices[ $EVT_ID ] ) ) { |
|
1992 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1991 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
1992 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1993 | 1993 | } |
1994 | - update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices ); |
|
1994 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
1995 | 1995 | } else { |
1996 | 1996 | $success = false; |
1997 | 1997 | $msg = esc_html__( |
1998 | 1998 | 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
1999 | 1999 | 'event_espresso' |
2000 | 2000 | ); |
2001 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2001 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2002 | 2002 | } |
2003 | - if ( $redirect_after ) { |
|
2003 | + if ($redirect_after) { |
|
2004 | 2004 | $this->_redirect_after_action( |
2005 | 2005 | $success, |
2006 | 2006 | 'Event', |
2007 | 2007 | 'deleted', |
2008 | - array( 'action' => 'default', 'status' => 'trash' ) |
|
2008 | + array('action' => 'default', 'status' => 'trash') |
|
2009 | 2009 | ); |
2010 | 2010 | } |
2011 | 2011 | } |
@@ -2021,30 +2021,30 @@ discard block |
||
2021 | 2021 | protected function _delete_events() { |
2022 | 2022 | $success = true; |
2023 | 2023 | // get list of events with no prices |
2024 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() ); |
|
2024 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2025 | 2025 | //determine the event id and set to array. |
2026 | - $EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2026 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2027 | 2027 | // loop thru events |
2028 | - foreach ( $EVT_IDs as $EVT_ID ) { |
|
2029 | - $EVT_ID = absint( $EVT_ID ); |
|
2030 | - if ( $EVT_ID ) { |
|
2031 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
2028 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2029 | + $EVT_ID = absint($EVT_ID); |
|
2030 | + if ($EVT_ID) { |
|
2031 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2032 | 2032 | $success = $results !== false ? $success : false; |
2033 | 2033 | // remove this event from the list of events with no prices |
2034 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
2034 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2035 | 2035 | } else { |
2036 | 2036 | $success = false; |
2037 | 2037 | $msg = esc_html__( |
2038 | 2038 | 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
2039 | 2039 | 'event_espresso' |
2040 | 2040 | ); |
2041 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2041 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2042 | 2042 | } |
2043 | 2043 | } |
2044 | - update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices ); |
|
2044 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2045 | 2045 | // in order to force a pluralized result message we need to send back a success status greater than 1 |
2046 | 2046 | $success = $success ? 2 : false; |
2047 | - $this->_redirect_after_action( $success, 'Events', 'deleted', array( 'action' => 'default' ) ); |
|
2047 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | |
@@ -2056,70 +2056,70 @@ discard block |
||
2056 | 2056 | * @param int $EVT_ID |
2057 | 2057 | * @return bool |
2058 | 2058 | */ |
2059 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
2059 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
2060 | 2060 | // grab event id |
2061 | - if ( ! $EVT_ID ) { |
|
2061 | + if ( ! $EVT_ID) { |
|
2062 | 2062 | $msg = esc_html__( |
2063 | 2063 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
2064 | 2064 | 'event_espresso' |
2065 | 2065 | ); |
2066 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2066 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2067 | 2067 | return false; |
2068 | 2068 | } |
2069 | 2069 | if ( |
2070 | 2070 | ! $this->_cpt_model_obj instanceof EE_Event |
2071 | 2071 | || $this->_cpt_model_obj->ID() !== $EVT_ID |
2072 | 2072 | ) { |
2073 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
2073 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2074 | 2074 | } |
2075 | - if ( ! $this->_cpt_model_obj instanceof EE_Event ) { |
|
2075 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2076 | 2076 | return false; |
2077 | 2077 | } |
2078 | 2078 | //need to delete related tickets and prices first. |
2079 | - $datetimes = $this->_cpt_model_obj->get_many_related( 'Datetime' ); |
|
2080 | - foreach ( $datetimes as $datetime ) { |
|
2081 | - $this->_cpt_model_obj->_remove_relation_to( $datetime, 'Datetime' ); |
|
2082 | - $tickets = $datetime->get_many_related( 'Ticket' ); |
|
2083 | - foreach ( $tickets as $ticket ) { |
|
2084 | - $ticket->_remove_relation_to( $datetime, 'Datetime' ); |
|
2085 | - $ticket->delete_related_permanently( 'Price' ); |
|
2079 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2080 | + foreach ($datetimes as $datetime) { |
|
2081 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2082 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2083 | + foreach ($tickets as $ticket) { |
|
2084 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2085 | + $ticket->delete_related_permanently('Price'); |
|
2086 | 2086 | $ticket->delete_permanently(); |
2087 | 2087 | } |
2088 | 2088 | $datetime->delete(); |
2089 | 2089 | } |
2090 | 2090 | //what about related venues or terms? |
2091 | - $venues = $this->_cpt_model_obj->get_many_related( 'Venue' ); |
|
2092 | - foreach ( $venues as $venue ) { |
|
2093 | - $this->_cpt_model_obj->_remove_relation_to( $venue, 'Venue' ); |
|
2091 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2092 | + foreach ($venues as $venue) { |
|
2093 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2094 | 2094 | } |
2095 | 2095 | //any attached question groups? |
2096 | - $question_groups = $this->_cpt_model_obj->get_many_related( 'Question_Group' ); |
|
2097 | - if ( ! empty( $question_groups ) ) { |
|
2098 | - foreach ( $question_groups as $question_group ) { |
|
2099 | - $this->_cpt_model_obj->_remove_relation_to( $question_group, 'Question_Group' ); |
|
2096 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2097 | + if ( ! empty($question_groups)) { |
|
2098 | + foreach ($question_groups as $question_group) { |
|
2099 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2100 | 2100 | } |
2101 | 2101 | } |
2102 | 2102 | //Message Template Groups |
2103 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
2103 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2104 | 2104 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
2105 | 2105 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
2106 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
2107 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy( $term_taxonomy ); |
|
2106 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2107 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2108 | 2108 | } |
2109 | 2109 | $success = $this->_cpt_model_obj->delete_permanently(); |
2110 | 2110 | // did it all go as planned ? |
2111 | - if ( $success ) { |
|
2112 | - $msg = sprintf( esc_html__( 'Event ID # %d has been deleted.', 'event_espresso' ), $EVT_ID ); |
|
2113 | - EE_Error::add_success( $msg ); |
|
2111 | + if ($success) { |
|
2112 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2113 | + EE_Error::add_success($msg); |
|
2114 | 2114 | } else { |
2115 | 2115 | $msg = sprintf( |
2116 | - esc_html__( 'An error occurred. Event ID # %d could not be deleted.', 'event_espresso' ), |
|
2116 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2117 | 2117 | $EVT_ID |
2118 | 2118 | ); |
2119 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2119 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2120 | 2120 | return false; |
2121 | 2121 | } |
2122 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
2122 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2123 | 2123 | return true; |
2124 | 2124 | } |
2125 | 2125 | |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | * @return int |
2133 | 2133 | */ |
2134 | 2134 | public function total_events() { |
2135 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2135 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2136 | 2136 | return $count; |
2137 | 2137 | } |
2138 | 2138 | |
@@ -2146,9 +2146,9 @@ discard block |
||
2146 | 2146 | */ |
2147 | 2147 | public function total_events_draft() { |
2148 | 2148 | $where = array( |
2149 | - 'status' => array( 'IN', array( 'draft', 'auto-draft' ) ), |
|
2149 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2150 | 2150 | ); |
2151 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2151 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2152 | 2152 | return $count; |
2153 | 2153 | } |
2154 | 2154 | |
@@ -2164,7 +2164,7 @@ discard block |
||
2164 | 2164 | $where = array( |
2165 | 2165 | 'status' => 'trash', |
2166 | 2166 | ); |
2167 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2167 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2168 | 2168 | return $count; |
2169 | 2169 | } |
2170 | 2170 | |
@@ -2195,12 +2195,12 @@ discard block |
||
2195 | 2195 | EE_Registry::instance()->CFG->registration->default_STS_ID, |
2196 | 2196 | $this->_template_args['reg_status_array'] |
2197 | 2197 | ) |
2198 | - ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) |
|
2198 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2199 | 2199 | : EEM_Registration::status_id_pending_payment; |
2200 | - $this->_set_add_edit_form_tags( 'update_default_event_settings' ); |
|
2201 | - $this->_set_publish_post_box_vars( null, false, false, null, false ); |
|
2200 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2201 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2202 | 2202 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2203 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2203 | + EVENTS_TEMPLATE_PATH.'event_settings.template.php', |
|
2204 | 2204 | $this->_template_args, |
2205 | 2205 | true |
2206 | 2206 | ); |
@@ -2216,8 +2216,8 @@ discard block |
||
2216 | 2216 | * @return void |
2217 | 2217 | */ |
2218 | 2218 | protected function _update_default_event_settings() { |
2219 | - EE_Config::instance()->registration->default_STS_ID = isset( $this->_req_data['default_reg_status'] ) |
|
2220 | - ? sanitize_text_field( $this->_req_data['default_reg_status'] ) |
|
2219 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2220 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2221 | 2221 | : EEM_Registration::status_id_pending_payment; |
2222 | 2222 | $what = 'Default Event Settings'; |
2223 | 2223 | $success = $this->_update_espresso_configuration( |
@@ -2227,7 +2227,7 @@ discard block |
||
2227 | 2227 | __FUNCTION__, |
2228 | 2228 | __LINE__ |
2229 | 2229 | ); |
2230 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default_event_settings' ) ); |
|
2230 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | |
@@ -2237,20 +2237,20 @@ discard block |
||
2237 | 2237 | |
2238 | 2238 | |
2239 | 2239 | protected function _template_settings() { |
2240 | - $this->_admin_page_title = esc_html__( 'Template Settings (Preview)', 'event_espresso' ); |
|
2240 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2241 | 2241 | $this->_template_args['preview_img'] = '<img src="' |
2242 | 2242 | . EVENTS_ASSETS_URL |
2243 | 2243 | . DS |
2244 | 2244 | . 'images' |
2245 | 2245 | . DS |
2246 | 2246 | . 'caffeinated_template_features.jpg" alt="' |
2247 | - . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) |
|
2247 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2248 | 2248 | . '" />'; |
2249 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2249 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
2250 | 2250 | 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
2251 | 2251 | 'event_espresso' |
2252 | - ) . '</strong>'; |
|
2253 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2252 | + ).'</strong>'; |
|
2253 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | 2256 | |
@@ -2262,18 +2262,18 @@ discard block |
||
2262 | 2262 | * @return void |
2263 | 2263 | */ |
2264 | 2264 | private function _set_category_object() { |
2265 | - if ( isset( $this->_category->id ) && ! empty( $this->_category->id ) ) { |
|
2265 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2266 | 2266 | return; |
2267 | 2267 | } //already have the category object so get out. |
2268 | 2268 | //set default category object |
2269 | 2269 | $this->_set_empty_category_object(); |
2270 | 2270 | //only set if we've got an id |
2271 | - if ( ! isset( $this->_req_data['EVT_CAT_ID'] ) ) { |
|
2271 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2272 | 2272 | return; |
2273 | 2273 | } |
2274 | - $category_id = absint( $this->_req_data['EVT_CAT_ID'] ); |
|
2275 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2276 | - if ( ! empty( $term ) ) { |
|
2274 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2275 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2276 | + if ( ! empty($term)) { |
|
2277 | 2277 | $this->_category->category_name = $term->name; |
2278 | 2278 | $this->_category->category_identifier = $term->slug; |
2279 | 2279 | $this->_category->category_desc = $term->description; |
@@ -2293,9 +2293,9 @@ discard block |
||
2293 | 2293 | |
2294 | 2294 | |
2295 | 2295 | protected function _category_list_table() { |
2296 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2297 | - $this->_search_btn_label = esc_html__( 'Categories', 'event_espresso' ); |
|
2298 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2296 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2297 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2298 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
2299 | 2299 | 'add_category', |
2300 | 2300 | 'add_category', |
2301 | 2301 | array(), |
@@ -2309,20 +2309,20 @@ discard block |
||
2309 | 2309 | /** |
2310 | 2310 | * @param $view |
2311 | 2311 | */ |
2312 | - protected function _category_details( $view ) { |
|
2312 | + protected function _category_details($view) { |
|
2313 | 2313 | //load formatter helper |
2314 | 2314 | //load field generator helper |
2315 | 2315 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2316 | - $this->_set_add_edit_form_tags( $route ); |
|
2316 | + $this->_set_add_edit_form_tags($route); |
|
2317 | 2317 | $this->_set_category_object(); |
2318 | - $id = ! empty( $this->_category->id ) ? $this->_category->id : ''; |
|
2318 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2319 | 2319 | $delete_action = 'delete_category'; |
2320 | 2320 | //custom redirect |
2321 | 2321 | $redirect = EE_Admin_Page::add_query_args_and_nonce( |
2322 | - array( 'action' => 'category_list' ), |
|
2322 | + array('action' => 'category_list'), |
|
2323 | 2323 | $this->_admin_base_url |
2324 | 2324 | ); |
2325 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2325 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2326 | 2326 | //take care of contents |
2327 | 2327 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
2328 | 2328 | $this->display_admin_page_with_sidebar(); |
@@ -2336,21 +2336,21 @@ discard block |
||
2336 | 2336 | protected function _category_details_content() { |
2337 | 2337 | $editor_args['category_desc'] = array( |
2338 | 2338 | 'type' => 'wp_editor', |
2339 | - 'value' => EEH_Formatter::admin_format_content( $this->_category->category_desc ), |
|
2339 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2340 | 2340 | 'class' => 'my_editor_custom', |
2341 | - 'wpeditor_args' => array( 'media_buttons' => false ), |
|
2341 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2342 | 2342 | ); |
2343 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2343 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2344 | 2344 | $all_terms = get_terms( |
2345 | - array( 'espresso_event_categories' ), |
|
2346 | - array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) |
|
2345 | + array('espresso_event_categories'), |
|
2346 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2347 | 2347 | ); |
2348 | 2348 | //setup category select for term parents. |
2349 | 2349 | $category_select_values[] = array( |
2350 | - 'text' => esc_html__( 'No Parent', 'event_espresso' ), |
|
2350 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2351 | 2351 | 'id' => 0, |
2352 | 2352 | ); |
2353 | - foreach ( $all_terms as $term ) { |
|
2353 | + foreach ($all_terms as $term) { |
|
2354 | 2354 | $category_select_values[] = array( |
2355 | 2355 | 'text' => $term->name, |
2356 | 2356 | 'id' => $term->term_id, |
@@ -2364,28 +2364,28 @@ discard block |
||
2364 | 2364 | $template_args = array( |
2365 | 2365 | 'category' => $this->_category, |
2366 | 2366 | 'category_select' => $category_select, |
2367 | - 'unique_id_info_help_link' => $this->_get_help_tab_link( 'unique_id_info' ), |
|
2367 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2368 | 2368 | 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
2369 | 2369 | 'disable' => '', |
2370 | 2370 | 'disabled_message' => false, |
2371 | 2371 | ); |
2372 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2373 | - return EEH_Template::display_template( $template, $template_args, true ); |
|
2372 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2373 | + return EEH_Template::display_template($template, $template_args, true); |
|
2374 | 2374 | } |
2375 | 2375 | |
2376 | 2376 | |
2377 | 2377 | |
2378 | 2378 | protected function _delete_categories() { |
2379 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2379 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2380 | 2380 | : (array) $this->_req_data['category_id']; |
2381 | - foreach ( $cat_ids as $cat_id ) { |
|
2382 | - $this->_delete_category( $cat_id ); |
|
2381 | + foreach ($cat_ids as $cat_id) { |
|
2382 | + $this->_delete_category($cat_id); |
|
2383 | 2383 | } |
2384 | 2384 | //doesn't matter what page we're coming from... we're going to the same place after delete. |
2385 | 2385 | $query_args = array( |
2386 | 2386 | 'action' => 'category_list', |
2387 | 2387 | ); |
2388 | - $this->_redirect_after_action( 0, '', '', $query_args ); |
|
2388 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2389 | 2389 | } |
2390 | 2390 | |
2391 | 2391 | |
@@ -2393,9 +2393,9 @@ discard block |
||
2393 | 2393 | /** |
2394 | 2394 | * @param $cat_id |
2395 | 2395 | */ |
2396 | - protected function _delete_category( $cat_id ) { |
|
2397 | - $cat_id = absint( $cat_id ); |
|
2398 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2396 | + protected function _delete_category($cat_id) { |
|
2397 | + $cat_id = absint($cat_id); |
|
2398 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2399 | 2399 | } |
2400 | 2400 | |
2401 | 2401 | |
@@ -2403,18 +2403,18 @@ discard block |
||
2403 | 2403 | /** |
2404 | 2404 | * @param $new_category |
2405 | 2405 | */ |
2406 | - protected function _insert_or_update_category( $new_category ) { |
|
2407 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( true ); |
|
2406 | + protected function _insert_or_update_category($new_category) { |
|
2407 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2408 | 2408 | $success = 0; //we already have a success message so lets not send another. |
2409 | - if ( $cat_id ) { |
|
2409 | + if ($cat_id) { |
|
2410 | 2410 | $query_args = array( |
2411 | 2411 | 'action' => 'edit_category', |
2412 | 2412 | 'EVT_CAT_ID' => $cat_id, |
2413 | 2413 | ); |
2414 | 2414 | } else { |
2415 | - $query_args = array( 'action' => 'add_category' ); |
|
2415 | + $query_args = array('action' => 'add_category'); |
|
2416 | 2416 | } |
2417 | - $this->_redirect_after_action( $success, '', '', $query_args, true ); |
|
2417 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2418 | 2418 | } |
2419 | 2419 | |
2420 | 2420 | |
@@ -2423,14 +2423,14 @@ discard block |
||
2423 | 2423 | * @param bool $update |
2424 | 2424 | * @return bool|mixed|string |
2425 | 2425 | */ |
2426 | - private function _insert_category( $update = false ) { |
|
2426 | + private function _insert_category($update = false) { |
|
2427 | 2427 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2428 | - $category_name = isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2429 | - $category_desc = isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2430 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2431 | - if ( empty( $category_name ) ) { |
|
2432 | - $msg = esc_html__( 'You must add a name for the category.', 'event_espresso' ); |
|
2433 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2428 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2429 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2430 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2431 | + if (empty($category_name)) { |
|
2432 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2433 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2434 | 2434 | return false; |
2435 | 2435 | } |
2436 | 2436 | $term_args = array( |
@@ -2439,22 +2439,22 @@ discard block |
||
2439 | 2439 | 'parent' => $category_parent, |
2440 | 2440 | ); |
2441 | 2441 | //was the category_identifier input disabled? |
2442 | - if ( isset( $this->_req_data['category_identifier'] ) ) { |
|
2442 | + if (isset($this->_req_data['category_identifier'])) { |
|
2443 | 2443 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2444 | 2444 | } |
2445 | 2445 | $insert_ids = $update |
2446 | - ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) |
|
2447 | - : wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2448 | - if ( ! is_array( $insert_ids ) ) { |
|
2446 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2447 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2448 | + if ( ! is_array($insert_ids)) { |
|
2449 | 2449 | $msg = esc_html__( |
2450 | 2450 | 'An error occurred and the category has not been saved to the database.', |
2451 | 2451 | 'event_espresso' |
2452 | 2452 | ); |
2453 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2453 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2454 | 2454 | } else { |
2455 | 2455 | $cat_id = $insert_ids['term_id']; |
2456 | - $msg = sprintf( esc_html__( 'The category %s was successfully saved', 'event_espresso' ), $category_name ); |
|
2457 | - EE_Error::add_success( $msg ); |
|
2456 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2457 | + EE_Error::add_success($msg); |
|
2458 | 2458 | } |
2459 | 2459 | return $cat_id; |
2460 | 2460 | } |
@@ -2467,28 +2467,28 @@ discard block |
||
2467 | 2467 | * @param bool $count |
2468 | 2468 | * @return \EE_Base_Class[]|int |
2469 | 2469 | */ |
2470 | - public function get_categories( $per_page = 10, $current_page = 1, $count = false ) { |
|
2470 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) { |
|
2471 | 2471 | //testing term stuff |
2472 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2473 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2474 | - $limit = ( $current_page - 1 ) * $per_page; |
|
2475 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2476 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2477 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2472 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2473 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2474 | + $limit = ($current_page - 1) * $per_page; |
|
2475 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2476 | + if (isset($this->_req_data['s'])) { |
|
2477 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2478 | 2478 | $where['OR'] = array( |
2479 | - 'Term.name' => array( 'LIKE', $sstr ), |
|
2480 | - 'description' => array( 'LIKE', $sstr ), |
|
2479 | + 'Term.name' => array('LIKE', $sstr), |
|
2480 | + 'description' => array('LIKE', $sstr), |
|
2481 | 2481 | ); |
2482 | 2482 | } |
2483 | 2483 | $query_params = array( |
2484 | 2484 | $where, |
2485 | - 'order_by' => array( $orderby => $order ), |
|
2486 | - 'limit' => $limit . ',' . $per_page, |
|
2487 | - 'force_join' => array( 'Term' ), |
|
2485 | + 'order_by' => array($orderby => $order), |
|
2486 | + 'limit' => $limit.','.$per_page, |
|
2487 | + 'force_join' => array('Term'), |
|
2488 | 2488 | ); |
2489 | 2489 | $categories = $count |
2490 | - ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) |
|
2491 | - : EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2490 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2491 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2492 | 2492 | return $categories; |
2493 | 2493 | } |
2494 | 2494 |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() { |
24 | 24 | $this->name = 'newsletter'; |
25 | - $this->description = __( 'Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso' ); |
|
25 | + $this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso'); |
|
26 | 26 | $this->label = array( |
27 | - 'singular' => __( 'batch', 'event_espresso' ), |
|
28 | - 'plural' => __( 'batches', 'event_espresso' ) |
|
27 | + 'singular' => __('batch', 'event_espresso'), |
|
28 | + 'plural' => __('batches', 'event_espresso') |
|
29 | 29 | ); |
30 | 30 | $this->_master_templates = array( |
31 | 31 | 'email' => 'registration', |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - protected function _get_data_for_context( $context, EE_Registration $registration, $id ) { |
|
52 | + protected function _get_data_for_context($context, EE_Registration $registration, $id) { |
|
53 | 53 | //newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects. |
54 | - return array( $registration ); |
|
54 | + return array($registration); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | |
65 | 65 | protected function _set_contexts() { |
66 | 66 | $this->_context_label = array( |
67 | - 'label' => __( 'recipient', 'event_espresso' ), |
|
68 | - 'plural' => __( 'recipients', 'event_espresso' ), |
|
69 | - 'description' => __( 'Recipient\'s are who will receive the message.', 'event_espresso' ) |
|
67 | + 'label' => __('recipient', 'event_espresso'), |
|
68 | + 'plural' => __('recipients', 'event_espresso'), |
|
69 | + 'description' => __('Recipient\'s are who will receive the message.', 'event_espresso') |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $this->_contexts = array( |
73 | 73 | 'attendee' => array( |
74 | - 'label' => __( 'Registrant', 'event_espresso' ), |
|
75 | - 'description' => __( 'This template goes to selected registrants.', 'event_espresso' ) |
|
74 | + 'label' => __('Registrant', 'event_espresso'), |
|
75 | + 'description' => __('This template goes to selected registrants.', 'event_espresso') |
|
76 | 76 | ) |
77 | 77 | ); |
78 | 78 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | 'newsletter', |
99 | 99 | ); |
100 | 100 | |
101 | - foreach ( $this->_valid_shortcodes as $context => $shortcodes ) { |
|
102 | - foreach ( $shortcodes as $key => $shortcode ) { |
|
103 | - if ( ! in_array( $shortcode, $included_shortcodes ) ) { |
|
104 | - unset( $this->_valid_shortcodes[ $context ][ $key ] ); |
|
101 | + foreach ($this->_valid_shortcodes as $context => $shortcodes) { |
|
102 | + foreach ($shortcodes as $key => $shortcode) { |
|
103 | + if ( ! in_array($shortcode, $included_shortcodes)) { |
|
104 | + unset($this->_valid_shortcodes[$context][$key]); |
|
105 | 105 | } |
106 | 106 | } |
107 | - $this->_valid_shortcodes[ $context ][] = 'newsletter'; |
|
107 | + $this->_valid_shortcodes[$context][] = 'newsletter'; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | } |
@@ -118,44 +118,44 @@ discard block |
||
118 | 118 | $addressee = array(); |
119 | 119 | |
120 | 120 | //looping through registrations |
121 | - foreach ( $this->_data->registrations as $reg_id => $details ) { |
|
121 | + foreach ($this->_data->registrations as $reg_id => $details) { |
|
122 | 122 | //set $attendee array to blank on each loop |
123 | 123 | $aee = array(); |
124 | 124 | |
125 | 125 | //need to get the attendee from this registration. |
126 | - $attendee = isset( $details['att_obj'] ) && $details['att_obj'] instanceof EE_Attendee |
|
126 | + $attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee |
|
127 | 127 | ? $details['att_obj'] |
128 | 128 | : null; |
129 | 129 | |
130 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
130 | + if ( ! $attendee instanceof EE_Attendee) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
134 | 134 | //set $aee from attendee object |
135 | 135 | $aee['att_obj'] = $attendee; |
136 | - $aee['reg_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['reg_objs'] ) |
|
137 | - ? $this->_data->attendees[ $attendee->ID() ]['reg_objs'] |
|
136 | + $aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs']) |
|
137 | + ? $this->_data->attendees[$attendee->ID()]['reg_objs'] |
|
138 | 138 | : array(); |
139 | 139 | $aee['attendee_email'] = $attendee->email(); |
140 | - $aee['tkt_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] ) |
|
141 | - ? $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] |
|
140 | + $aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs']) |
|
141 | + ? $this->_data->attendees[$attendee->ID()]['tkt_objs'] |
|
142 | 142 | : array(); |
143 | 143 | |
144 | - if ( isset( $this->_data->attendees[ $attendee->ID() ]['evt_objs'] ) ) { |
|
145 | - $aee['evt_objs'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs']; |
|
146 | - $aee['events'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs']; |
|
144 | + if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) { |
|
145 | + $aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
146 | + $aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs']; |
|
147 | 147 | } else { |
148 | 148 | $aee['evt_objs'] = $aee['events'] = array(); |
149 | 149 | } |
150 | 150 | |
151 | - $aee['reg_obj'] = isset( $details['reg_obj'] ) |
|
151 | + $aee['reg_obj'] = isset($details['reg_obj']) |
|
152 | 152 | ? $details['reg_obj'] |
153 | 153 | : null; |
154 | 154 | $aee['attendees'] = $this->_data->attendees; |
155 | 155 | |
156 | 156 | //merge in the primary attendee data |
157 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
158 | - $addressee[] = new EE_Messages_Addressee( $aee ); |
|
157 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
158 | + $addressee[] = new EE_Messages_Addressee($aee); |
|
159 | 159 | } |
160 | 160 | return $addressee; |
161 | 161 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | - {exit('NO direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | + {exit('NO direct script access allowed'); } |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * @param bool $routing |
76 | 76 | */ |
77 | - public function __construct( $routing = true ) { |
|
77 | + public function __construct($routing = true) { |
|
78 | 78 | //make sure messages autoloader is running |
79 | 79 | EED_Messages::set_autoloaders(); |
80 | - parent::__construct( $routing ); |
|
80 | + parent::__construct($routing); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array(); |
93 | 93 | |
94 | - $this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null; |
|
94 | + $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null; |
|
95 | 95 | $this->_load_message_resource_manager(); |
96 | 96 | } |
97 | 97 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @throws EE_Error |
106 | 106 | */ |
107 | 107 | protected function _load_message_resource_manager() { |
108 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
108 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -116,21 +116,21 @@ discard block |
||
116 | 116 | public function get_messengers_for_list_table() { |
117 | 117 | EE_Error::doing_it_wrong( |
118 | 118 | __METHOD__, |
119 | - __( 'This method is no longer in use. There is no replacement for it. The method was used to generate a set of |
|
119 | + __('This method is no longer in use. There is no replacement for it. The method was used to generate a set of |
|
120 | 120 | values for use in creating a messenger filter dropdown which is now generated differently via |
121 | - Messages_Admin_Page::get_messengers_select_input', 'event_espresso' ), |
|
121 | + Messages_Admin_Page::get_messengers_select_input', 'event_espresso'), |
|
122 | 122 | '4.9.9.rc.014' |
123 | 123 | ); |
124 | 124 | |
125 | 125 | $m_values = array(); |
126 | - $active_messengers = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_messenger' ) ); |
|
126 | + $active_messengers = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger')); |
|
127 | 127 | //setup messengers for selects |
128 | 128 | $i = 1; |
129 | - foreach ( $active_messengers as $active_messenger ) { |
|
130 | - if ( $active_messenger instanceof EE_Message ) { |
|
131 | - $m_values[ $i ]['id'] = $active_messenger->messenger(); |
|
132 | - $m_values[ $i ]['text'] = ucwords( $active_messenger->messenger_label() ); |
|
133 | - $i ++; |
|
129 | + foreach ($active_messengers as $active_messenger) { |
|
130 | + if ($active_messenger instanceof EE_Message) { |
|
131 | + $m_values[$i]['id'] = $active_messenger->messenger(); |
|
132 | + $m_values[$i]['text'] = ucwords($active_messenger->messenger_label()); |
|
133 | + $i++; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | return $m_values; |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | public function get_message_types_for_list_table() { |
145 | 145 | EE_Error::doing_it_wrong( |
146 | 146 | __METHOD__, |
147 | - __( 'This method is no longer in use. There is no replacement for it. The method was used to generate a set of |
|
147 | + __('This method is no longer in use. There is no replacement for it. The method was used to generate a set of |
|
148 | 148 | values for use in creating a message type filter dropdown which is now generated differently via |
149 | - Messages_Admin_Page::get_message_types_select_input', 'event_espresso' ), |
|
149 | + Messages_Admin_Page::get_message_types_select_input', 'event_espresso'), |
|
150 | 150 | '4.9.9.rc.014' |
151 | 151 | ); |
152 | 152 | |
153 | 153 | $mt_values = array(); |
154 | - $active_messages = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_message_type' ) ); |
|
154 | + $active_messages = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type')); |
|
155 | 155 | $i = 1; |
156 | - foreach ( $active_messages as $active_message ) { |
|
157 | - if ( $active_message instanceof EE_Message ) { |
|
158 | - $mt_values[ $i ]['id'] = $active_message->message_type(); |
|
159 | - $mt_values[ $i ]['text'] = ucwords( $active_message->message_type_label() ); |
|
160 | - $i ++; |
|
156 | + foreach ($active_messages as $active_message) { |
|
157 | + if ($active_message instanceof EE_Message) { |
|
158 | + $mt_values[$i]['id'] = $active_message->message_type(); |
|
159 | + $mt_values[$i]['text'] = ucwords($active_message->message_type_label()); |
|
160 | + $i++; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | return $mt_values; |
@@ -171,21 +171,21 @@ discard block |
||
171 | 171 | public function get_contexts_for_message_types_for_list_table() { |
172 | 172 | EE_Error::doing_it_wrong( |
173 | 173 | __METHOD__, |
174 | - __( 'This method is no longer in use. There is no replacement for it. The method was used to generate a set of |
|
174 | + __('This method is no longer in use. There is no replacement for it. The method was used to generate a set of |
|
175 | 175 | values for use in creating a message type context filter dropdown which is now generated differently via |
176 | - Messages_Admin_Page::get_contexts_for_message_types_select_input', 'event_espresso' ), |
|
176 | + Messages_Admin_Page::get_contexts_for_message_types_select_input', 'event_espresso'), |
|
177 | 177 | '4.9.9.rc.014' |
178 | 178 | ); |
179 | 179 | |
180 | 180 | $contexts = array(); |
181 | - $active_message_contexts = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_context' ) ); |
|
182 | - foreach ( $active_message_contexts as $active_message ) { |
|
183 | - if ( $active_message instanceof EE_Message ) { |
|
181 | + $active_message_contexts = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context')); |
|
182 | + foreach ($active_message_contexts as $active_message) { |
|
183 | + if ($active_message instanceof EE_Message) { |
|
184 | 184 | $message_type = $active_message->message_type_object(); |
185 | - if ( $message_type instanceof EE_message_type ) { |
|
185 | + if ($message_type instanceof EE_message_type) { |
|
186 | 186 | $message_type_contexts = $message_type->get_contexts(); |
187 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
188 | - $contexts[ $context ] = $context_details['label']; |
|
187 | + foreach ($message_type_contexts as $context => $context_details) { |
|
188 | + $contexts[$context] = $context_details['label']; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function get_messengers_select_input( $messenger_options ) { |
|
204 | + public function get_messengers_select_input($messenger_options) { |
|
205 | 205 | //if empty or just one value then just return an empty string |
206 | - if ( empty( $messenger_options ) |
|
207 | - || ! is_array( $messenger_options ) |
|
208 | - || count( $messenger_options ) === 1 |
|
206 | + if (empty($messenger_options) |
|
207 | + || ! is_array($messenger_options) |
|
208 | + || count($messenger_options) === 1 |
|
209 | 209 | ) { |
210 | 210 | return ''; |
211 | 211 | } |
212 | 212 | //merge in default |
213 | 213 | $messenger_options = array_merge( |
214 | - array( 'none_selected' => __( 'Show All Messengers', 'event_espresso' ) ), |
|
214 | + array('none_selected' => __('Show All Messengers', 'event_espresso')), |
|
215 | 215 | $messenger_options |
216 | 216 | ); |
217 | 217 | $input = new EE_Select_Input( |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | 'html_name' => 'ee_messenger_filter_by', |
221 | 221 | 'html_id' => 'ee_messenger_filter_by', |
222 | 222 | 'html_class' => 'wide', |
223 | - 'default' => isset( $this->_req_data['ee_messenger_filter_by'] ) |
|
224 | - ? sanitize_title( $this->_req_data['ee_messenger_filter_by'] ) |
|
223 | + 'default' => isset($this->_req_data['ee_messenger_filter_by']) |
|
224 | + ? sanitize_title($this->_req_data['ee_messenger_filter_by']) |
|
225 | 225 | : 'none_selected' |
226 | 226 | ) |
227 | 227 | ); |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public function get_message_types_select_input( $message_type_options ) { |
|
240 | + public function get_message_types_select_input($message_type_options) { |
|
241 | 241 | //if empty or count of options is 1 then just return an empty string |
242 | - if ( empty( $message_type_options ) |
|
243 | - || ! is_array( $message_type_options ) |
|
244 | - || count( $message_type_options ) === 1 |
|
242 | + if (empty($message_type_options) |
|
243 | + || ! is_array($message_type_options) |
|
244 | + || count($message_type_options) === 1 |
|
245 | 245 | ) { |
246 | 246 | return ''; |
247 | 247 | } |
248 | 248 | //merge in default |
249 | 249 | $message_type_options = array_merge( |
250 | - array( 'none_selected' => __( 'Show All Message Types', 'event_espresso' ) ), |
|
250 | + array('none_selected' => __('Show All Message Types', 'event_espresso')), |
|
251 | 251 | $message_type_options |
252 | 252 | ); |
253 | 253 | $input = new EE_Select_Input( |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | 'html_name' => 'ee_message_type_filter_by', |
257 | 257 | 'html_id' => 'ee_message_type_filter_by', |
258 | 258 | 'html_class' => 'wide', |
259 | - 'default' => isset( $this->_req_data['ee_message_type_filter_by'] ) |
|
260 | - ? sanitize_title( $this->_req_data['ee_message_type_filter_by'] ) |
|
259 | + 'default' => isset($this->_req_data['ee_message_type_filter_by']) |
|
260 | + ? sanitize_title($this->_req_data['ee_message_type_filter_by']) |
|
261 | 261 | : 'none_selected', |
262 | 262 | ) |
263 | 263 | ); |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return string |
275 | 275 | */ |
276 | - public function get_contexts_for_message_types_select_input( $context_options ) { |
|
276 | + public function get_contexts_for_message_types_select_input($context_options) { |
|
277 | 277 | //if empty or count of options is one then just return empty string |
278 | - if ( empty( $context_options ) |
|
279 | - || ! is_array( $context_options ) |
|
280 | - || count( $context_options ) === 1 |
|
278 | + if (empty($context_options) |
|
279 | + || ! is_array($context_options) |
|
280 | + || count($context_options) === 1 |
|
281 | 281 | ) { |
282 | 282 | return ''; |
283 | 283 | } |
284 | 284 | //merge in default |
285 | 285 | $context_options = array_merge( |
286 | - array( 'none_selected' => __( 'Show all Contexts', 'event_espresso' ) ), |
|
286 | + array('none_selected' => __('Show all Contexts', 'event_espresso')), |
|
287 | 287 | $context_options |
288 | 288 | ); |
289 | 289 | $input = new EE_Select_Input( |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | 'html_name' => 'ee_context_filter_by', |
293 | 293 | 'html_id' => 'ee_context_filter_by', |
294 | 294 | 'html_class' => 'wide', |
295 | - 'default' => isset( $this->_req_data['ee_context_filter_by'] ) |
|
296 | - ? sanitize_title( $this->_req_data['ee_context_filter_by'] ) |
|
295 | + 'default' => isset($this->_req_data['ee_context_filter_by']) |
|
296 | + ? sanitize_title($this->_req_data['ee_context_filter_by']) |
|
297 | 297 | : 'none_selected', |
298 | 298 | ) |
299 | 299 | ); |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | |
304 | 304 | |
305 | 305 | protected function _ajax_hooks() { |
306 | - add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) ); |
|
307 | - add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') ); |
|
308 | - add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') ); |
|
309 | - add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) ); |
|
310 | - add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) ); |
|
306 | + add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle')); |
|
307 | + add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle')); |
|
308 | + add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings')); |
|
309 | + add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form')); |
|
310 | + add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack')); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -339,13 +339,13 @@ discard block |
||
339 | 339 | * @return void |
340 | 340 | */ |
341 | 341 | protected function _set_page_routes() { |
342 | - $grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) |
|
342 | + $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) |
|
343 | 343 | ? $this->_req_data['GRP_ID'] |
344 | 344 | : 0; |
345 | - $grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) |
|
345 | + $grp_id = empty($grp_id) && ! empty($this->_req_data['id']) |
|
346 | 346 | ? $this->_req_data['id'] |
347 | 347 | : $grp_id; |
348 | - $msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] ) |
|
348 | + $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID']) |
|
349 | 349 | ? $this->_req_data['MSG_ID'] |
350 | 350 | : 0; |
351 | 351 | |
@@ -387,35 +387,35 @@ discard block |
||
387 | 387 | 'insert_message_template' => array( |
388 | 388 | 'func' => '_insert_or_update_message_template', |
389 | 389 | 'capability' => 'ee_edit_messages', |
390 | - 'args' => array( 'new_template' => true ), |
|
390 | + 'args' => array('new_template' => true), |
|
391 | 391 | 'noheader' => true |
392 | 392 | ), |
393 | 393 | 'update_message_template' => array( |
394 | 394 | 'func' => '_insert_or_update_message_template', |
395 | 395 | 'capability' => 'ee_edit_message', |
396 | 396 | 'obj_id' => $grp_id, |
397 | - 'args' => array( 'new_template' => false ), |
|
397 | + 'args' => array('new_template' => false), |
|
398 | 398 | 'noheader' => true |
399 | 399 | ), |
400 | 400 | 'trash_message_template' => array( |
401 | 401 | 'func' => '_trash_or_restore_message_template', |
402 | 402 | 'capability' => 'ee_delete_message', |
403 | 403 | 'obj_id' => $grp_id, |
404 | - 'args' => array( 'trash' => true, 'all' => true ), |
|
404 | + 'args' => array('trash' => true, 'all' => true), |
|
405 | 405 | 'noheader' => true |
406 | 406 | ), |
407 | 407 | 'trash_message_template_context' => array( |
408 | 408 | 'func' => '_trash_or_restore_message_template', |
409 | 409 | 'capability' => 'ee_delete_message', |
410 | 410 | 'obj_id' => $grp_id, |
411 | - 'args' => array( 'trash' => true ), |
|
411 | + 'args' => array('trash' => true), |
|
412 | 412 | 'noheader' => true |
413 | 413 | ), |
414 | 414 | 'restore_message_template' => array( |
415 | 415 | 'func' => '_trash_or_restore_message_template', |
416 | 416 | 'capability' => 'ee_delete_message', |
417 | 417 | 'obj_id' => $grp_id, |
418 | - 'args' => array( 'trash' => false, 'all' => true ), |
|
418 | + 'args' => array('trash' => false, 'all' => true), |
|
419 | 419 | 'noheader' => true |
420 | 420 | ), |
421 | 421 | 'restore_message_template_context' => array( |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | 'filename' => 'messages_overview_other', |
535 | 535 | ), |
536 | 536 | ), |
537 | - 'help_tour' => array( 'Messages_Overview_Help_Tour' ), |
|
537 | + 'help_tour' => array('Messages_Overview_Help_Tour'), |
|
538 | 538 | 'require_nonce' => false |
539 | 539 | ), |
540 | 540 | 'custom_mtps' => array( |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | ), |
570 | 570 | 'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'), |
571 | 571 | 'has_metaboxes' => true, |
572 | - 'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ), |
|
572 | + 'help_tour' => array('Message_Templates_Edit_Help_Tour'), |
|
573 | 573 | 'help_tabs' => array( |
574 | 574 | 'edit_message_template' => array( |
575 | 575 | 'title' => __('Message Template Editor', 'event_espresso'), |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | 'filename' => 'messages_settings_messengers' |
626 | 626 | ), |
627 | 627 | ), |
628 | - 'help_tour' => array( 'Messages_Settings_Help_Tour' ), |
|
628 | + 'help_tour' => array('Messages_Settings_Help_Tour'), |
|
629 | 629 | 'require_nonce' => false |
630 | 630 | ) |
631 | 631 | ); |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | |
659 | 659 | |
660 | 660 | protected function _add_screen_options_default() { |
661 | - $this->_admin_page_title = __( 'Message Activity', 'event_espresso' ); |
|
661 | + $this->_admin_page_title = __('Message Activity', 'event_espresso'); |
|
662 | 662 | $this->_per_page_screen_option(); |
663 | 663 | } |
664 | 664 | |
@@ -680,37 +680,37 @@ discard block |
||
680 | 680 | |
681 | 681 | |
682 | 682 | public function messages_help_tab() { |
683 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' ); |
|
683 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | |
687 | 687 | public function messengers_help_tab() { |
688 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' ); |
|
688 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
692 | 692 | public function message_types_help_tab() { |
693 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' ); |
|
693 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | |
697 | 697 | public function messages_overview_help_tab() { |
698 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' ); |
|
698 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | |
702 | 702 | public function message_templates_help_tab() { |
703 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' ); |
|
703 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
707 | 707 | public function edit_message_template_help_tab() { |
708 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />'; |
|
709 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />'; |
|
710 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />'; |
|
711 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />'; |
|
712 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />'; |
|
713 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
708 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />'; |
|
709 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />'; |
|
710 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />'; |
|
711 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />'; |
|
712 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />'; |
|
713 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | |
@@ -718,22 +718,22 @@ discard block |
||
718 | 718 | public function message_template_shortcodes_help_tab() { |
719 | 719 | $this->_set_shortcodes(); |
720 | 720 | $args['shortcodes'] = $this->_shortcodes; |
721 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args ); |
|
721 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | |
725 | 725 | |
726 | 726 | public function preview_message_help_tab() { |
727 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' ); |
|
727 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
731 | 731 | public function settings_help_tab() { |
732 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'; |
|
733 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'; |
|
732 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'; |
|
733 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'; |
|
734 | 734 | $args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>'; |
735 | 735 | $args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>'; |
736 | - EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
736 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -741,31 +741,31 @@ discard block |
||
741 | 741 | |
742 | 742 | |
743 | 743 | public function load_scripts_styles() { |
744 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION ); |
|
744 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
745 | 745 | wp_enqueue_style('espresso_ee_msg'); |
746 | 746 | |
747 | - wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true ); |
|
748 | - wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION ); |
|
747 | + wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true); |
|
748 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | |
752 | 752 | |
753 | 753 | public function load_scripts_styles_default() { |
754 | - wp_enqueue_script( 'ee-msg-list-table-js' ); |
|
754 | + wp_enqueue_script('ee-msg-list-table-js'); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | |
758 | 758 | |
759 | 759 | |
760 | 760 | |
761 | - public function wp_editor_css( $mce_css ) { |
|
761 | + public function wp_editor_css($mce_css) { |
|
762 | 762 | //if we're on the edit_message_template route |
763 | - if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger ) { |
|
763 | + if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) { |
|
764 | 764 | $message_type_name = $this->_active_message_type_name; |
765 | 765 | |
766 | 766 | //we're going to REPLACE the existing mce css |
767 | 767 | //we need to get the css file location from the active messenger |
768 | - $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation ); |
|
768 | + $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | return $mce_css; |
@@ -783,15 +783,15 @@ discard block |
||
783 | 783 | $this->_message_template_group->messenger_obj()->label['singular'], |
784 | 784 | $this->_message_template_group->message_type_obj()->label['singular'] |
785 | 785 | ); |
786 | - EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' ); |
|
786 | + EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso'); |
|
787 | 787 | |
788 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION ); |
|
788 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION); |
|
789 | 789 | |
790 | 790 | wp_enqueue_script('ee_admin_js'); |
791 | 791 | wp_enqueue_script('ee_msgs_edit_js'); |
792 | 792 | |
793 | 793 | //add in special css for tiny_mce |
794 | - add_filter( 'mce_css', array( $this, 'wp_editor_css' ) ); |
|
794 | + add_filter('mce_css', array($this, 'wp_editor_css')); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | |
@@ -800,22 +800,22 @@ discard block |
||
800 | 800 | |
801 | 801 | $this->_set_message_template_group(); |
802 | 802 | |
803 | - if ( isset( $this->_req_data['messenger'] ) ) { |
|
804 | - $this->_active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
803 | + if (isset($this->_req_data['messenger'])) { |
|
804 | + $this->_active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
805 | 805 | } |
806 | 806 | |
807 | - $message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : ''; |
|
807 | + $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : ''; |
|
808 | 808 | |
809 | 809 | |
810 | - wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) ); |
|
810 | + wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation)); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | |
814 | 814 | |
815 | 815 | public function load_scripts_styles_settings() { |
816 | - wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION ); |
|
817 | - wp_enqueue_style( 'ee-text-links' ); |
|
818 | - wp_enqueue_style( 'ee-message-settings' ); |
|
816 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION); |
|
817 | + wp_enqueue_style('ee-text-links'); |
|
818 | + wp_enqueue_style('ee-message-settings'); |
|
819 | 819 | |
820 | 820 | wp_enqueue_script('ee-messages-settings'); |
821 | 821 | } |
@@ -845,40 +845,40 @@ discard block |
||
845 | 845 | * set views array for message queue list table |
846 | 846 | */ |
847 | 847 | public function _set_list_table_views_default() { |
848 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
848 | + EE_Registry::instance()->load_helper('Template'); |
|
849 | 849 | |
850 | - $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' ) |
|
850 | + $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions') |
|
851 | 851 | ? array( |
852 | - 'generate_now' => __( 'Generate Now', 'event_espresso' ), |
|
853 | - 'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ), |
|
854 | - 'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ), |
|
855 | - 'send_now' => __( 'Send Now', 'event_espresso' ) |
|
852 | + 'generate_now' => __('Generate Now', 'event_espresso'), |
|
853 | + 'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'), |
|
854 | + 'queue_for_resending' => __('Queue for Resending', 'event_espresso'), |
|
855 | + 'send_now' => __('Send Now', 'event_espresso') |
|
856 | 856 | ) |
857 | 857 | : array(); |
858 | 858 | |
859 | - $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' ) |
|
860 | - ? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) ) |
|
859 | + $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions') |
|
860 | + ? array('delete_ee_messages' => __('Delete Messages', 'event_espresso')) |
|
861 | 861 | : array(); |
862 | 862 | |
863 | 863 | |
864 | 864 | $this->_views = array( |
865 | 865 | 'all' => array( |
866 | 866 | 'slug' => 'all', |
867 | - 'label' => __( 'All', 'event_espresso' ), |
|
867 | + 'label' => __('All', 'event_espresso'), |
|
868 | 868 | 'count' => 0, |
869 | - 'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action ) |
|
869 | + 'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action) |
|
870 | 870 | ) |
871 | 871 | ); |
872 | 872 | |
873 | 873 | |
874 | - foreach ( EEM_Message::instance()->all_statuses() as $status ) { |
|
875 | - if ( $status === EEM_Message::status_debug_only && ! EEM_Message::debug() ) { |
|
874 | + foreach (EEM_Message::instance()->all_statuses() as $status) { |
|
875 | + if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) { |
|
876 | 876 | continue; |
877 | 877 | } |
878 | 878 | $status_bulk_actions = $common_bulk_actions; |
879 | 879 | //unset bulk actions not applying to status |
880 | - if ( ! empty( $status_bulk_actions ) ) { |
|
881 | - switch ( $status ) { |
|
880 | + if ( ! empty($status_bulk_actions)) { |
|
881 | + switch ($status) { |
|
882 | 882 | case EEM_Message::status_idle : |
883 | 883 | case EEM_Message::status_resend : |
884 | 884 | $status_bulk_actions['send_now'] = $common_bulk_actions['send_now']; |
@@ -890,21 +890,21 @@ discard block |
||
890 | 890 | break; |
891 | 891 | |
892 | 892 | case EEM_Message::status_incomplete : |
893 | - unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] ); |
|
893 | + unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']); |
|
894 | 894 | break; |
895 | 895 | |
896 | 896 | case EEM_Message::status_retry : |
897 | 897 | case EEM_Message::status_sent : |
898 | - unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] ); |
|
898 | + unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']); |
|
899 | 899 | break; |
900 | 900 | } |
901 | 901 | } |
902 | 902 | |
903 | - $this->_views[ strtolower( $status ) ] = array( |
|
904 | - 'slug' => strtolower( $status ), |
|
905 | - 'label' => EEH_Template::pretty_status( $status, false, 'sentence' ), |
|
903 | + $this->_views[strtolower($status)] = array( |
|
904 | + 'slug' => strtolower($status), |
|
905 | + 'label' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
906 | 906 | 'count' => 0, |
907 | - 'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action ) |
|
907 | + 'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action) |
|
908 | 908 | ); |
909 | 909 | } |
910 | 910 | } |
@@ -923,8 +923,8 @@ discard block |
||
923 | 923 | protected function _message_queue_list_table() { |
924 | 924 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
925 | 925 | $this->_template_args['per_column'] = 6; |
926 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() ); |
|
927 | - $this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>'; |
|
926 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
|
927 | + $this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>'; |
|
928 | 928 | $this->display_admin_list_table_page_with_no_sidebar(); |
929 | 929 | } |
930 | 930 | |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | $action_css_classes = EEH_MSG_Template::get_message_action_icons(); |
938 | 938 | $action_items = array(); |
939 | 939 | |
940 | - foreach( $action_css_classes as $action_item => $action_details ) { |
|
941 | - if ( $action_item === 'see_notifications_for' ) { |
|
940 | + foreach ($action_css_classes as $action_item => $action_details) { |
|
941 | + if ($action_item === 'see_notifications_for') { |
|
942 | 942 | continue; |
943 | 943 | } |
944 | 944 | $action_items[$action_item] = array( |
@@ -950,37 +950,37 @@ discard block |
||
950 | 950 | /** @type array $status_items status legend setup*/ |
951 | 951 | $status_items = array( |
952 | 952 | 'sent_status' => array( |
953 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
954 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, false, 'sentence' ) |
|
953 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
954 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence') |
|
955 | 955 | ), |
956 | 956 | 'idle_status' => array( |
957 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
958 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, false, 'sentence' ) |
|
957 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
958 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence') |
|
959 | 959 | ), |
960 | 960 | 'failed_status' => array( |
961 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
962 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, false, 'sentence' ) |
|
961 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
962 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence') |
|
963 | 963 | ), |
964 | 964 | 'resend_status' => array( |
965 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
966 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, false, 'sentence' ) |
|
965 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
966 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence') |
|
967 | 967 | ), |
968 | 968 | 'incomplete_status' => array( |
969 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
970 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, false, 'sentence' ) |
|
969 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
970 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence') |
|
971 | 971 | ), |
972 | 972 | 'retry_status' => array( |
973 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
974 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, false, 'sentence' ) |
|
973 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
974 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence') |
|
975 | 975 | ) |
976 | 976 | ); |
977 | - if ( EEM_Message::debug() ) { |
|
977 | + if (EEM_Message::debug()) { |
|
978 | 978 | $status_items['debug_only_status'] = array( |
979 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only, |
|
980 | - 'desc' => EEH_Template::pretty_status( EEM_Message::status_debug_only, false, 'sentence' ) |
|
979 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only, |
|
980 | + 'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence') |
|
981 | 981 | ); |
982 | 982 | } |
983 | - return array_merge( $action_items, $status_items ); |
|
983 | + return array_merge($action_items, $status_items); |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | |
@@ -990,9 +990,9 @@ discard block |
||
990 | 990 | |
991 | 991 | protected function _custom_mtps_preview() { |
992 | 992 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
993 | - $this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />'; |
|
993 | + $this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />'; |
|
994 | 994 | $this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso. With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>'; |
995 | - $this->display_admin_caf_preview_page( 'custom_message_types', false ); |
|
995 | + $this->display_admin_caf_preview_page('custom_message_types', false); |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | |
@@ -1016,31 +1016,31 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return array |
1018 | 1018 | */ |
1019 | - public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) { |
|
1019 | + public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) { |
|
1020 | 1020 | |
1021 | 1021 | $MTP = EEM_Message_Template_Group::instance(); |
1022 | 1022 | |
1023 | 1023 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby']; |
1024 | 1024 | $orderby = $this->_req_data['orderby']; |
1025 | 1025 | |
1026 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC'; |
|
1026 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
1027 | 1027 | |
1028 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1029 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage; |
|
1028 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1029 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage; |
|
1030 | 1030 | |
1031 | - $offset = ($current_page-1)*$per_page; |
|
1032 | - $limit = $all ? null : array( $offset, $per_page ); |
|
1031 | + $offset = ($current_page - 1) * $per_page; |
|
1032 | + $limit = $all ? null : array($offset, $per_page); |
|
1033 | 1033 | |
1034 | 1034 | |
1035 | 1035 | //options will match what is in the _views array property |
1036 | - switch( $type ) { |
|
1036 | + switch ($type) { |
|
1037 | 1037 | |
1038 | 1038 | case 'in_use': |
1039 | - $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true ); |
|
1039 | + $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true); |
|
1040 | 1040 | break; |
1041 | 1041 | |
1042 | 1042 | default: |
1043 | - $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global ); |
|
1043 | + $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global); |
|
1044 | 1044 | |
1045 | 1045 | } |
1046 | 1046 | |
@@ -1059,8 +1059,8 @@ discard block |
||
1059 | 1059 | $installed_message_types = $this->_message_resource_manager->installed_message_types(); |
1060 | 1060 | $installed = array(); |
1061 | 1061 | |
1062 | - foreach ( $installed_message_types as $message_type ) { |
|
1063 | - $installed[ $message_type->name ] = $message_type; |
|
1062 | + foreach ($installed_message_types as $message_type) { |
|
1063 | + $installed[$message_type->name] = $message_type; |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | return $installed; |
@@ -1079,24 +1079,24 @@ discard block |
||
1079 | 1079 | * |
1080 | 1080 | * @throws EE_error |
1081 | 1081 | */ |
1082 | - protected function _add_message_template( $message_type = '', $messenger='', $GRP_ID = '' ) { |
|
1082 | + protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') { |
|
1083 | 1083 | //set values override any request data |
1084 | - $message_type = !empty( $message_type ) ? $message_type : ''; |
|
1085 | - $message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type; |
|
1084 | + $message_type = ! empty($message_type) ? $message_type : ''; |
|
1085 | + $message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type; |
|
1086 | 1086 | |
1087 | - $messenger = !empty( $messenger ) ? $messenger : ''; |
|
1088 | - $messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger; |
|
1087 | + $messenger = ! empty($messenger) ? $messenger : ''; |
|
1088 | + $messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger; |
|
1089 | 1089 | |
1090 | - $GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : ''; |
|
1091 | - $GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
1090 | + $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : ''; |
|
1091 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID; |
|
1092 | 1092 | |
1093 | 1093 | //we need messenger and message type. They should be coming from the event editor. If not here then return error |
1094 | - if ( empty( $message_type ) || empty( $messenger ) ) |
|
1095 | - {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));} |
|
1094 | + if (empty($message_type) || empty($messenger)) |
|
1095 | + {throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); } |
|
1096 | 1096 | |
1097 | 1097 | //we need the GRP_ID for the template being used as the base for the new template |
1098 | - if ( empty( $GRP_ID ) ) |
|
1099 | - {throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );} |
|
1098 | + if (empty($GRP_ID)) |
|
1099 | + {throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso')); } |
|
1100 | 1100 | |
1101 | 1101 | //let's just make sure the template gets generated! |
1102 | 1102 | |
@@ -1117,8 +1117,8 @@ discard block |
||
1117 | 1117 | * @param int $GRP_ID GRP_ID for the related message template group this new template will be based |
1118 | 1118 | * off of. |
1119 | 1119 | */ |
1120 | - public function add_message_template( $message_type, $messenger, $GRP_ID ) { |
|
1121 | - $this->_add_message_template( $message_type, $messenger, $GRP_ID ); |
|
1120 | + public function add_message_template($message_type, $messenger, $GRP_ID) { |
|
1121 | + $this->_add_message_template($message_type, $messenger, $GRP_ID); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | |
@@ -1129,14 +1129,14 @@ discard block |
||
1129 | 1129 | * @return void |
1130 | 1130 | */ |
1131 | 1131 | protected function _edit_message_template() { |
1132 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1132 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1133 | 1133 | $template_fields = ''; |
1134 | 1134 | $sidebar_fields = ''; |
1135 | 1135 | //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates. |
1136 | - add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 ); |
|
1136 | + add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2); |
|
1137 | 1137 | |
1138 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) |
|
1139 | - ? absint( $this->_req_data['id'] ) |
|
1138 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) |
|
1139 | + ? absint($this->_req_data['id']) |
|
1140 | 1140 | : false; |
1141 | 1141 | |
1142 | 1142 | $this->_set_shortcodes(); //this also sets the _message_template property. |
@@ -1144,20 +1144,20 @@ discard block |
||
1144 | 1144 | $c_label = $message_template_group->context_label(); |
1145 | 1145 | $c_config = $message_template_group->contexts_config(); |
1146 | 1146 | |
1147 | - reset( $c_config ); |
|
1148 | - $context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) |
|
1147 | + reset($c_config); |
|
1148 | + $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) |
|
1149 | 1149 | ? strtolower($this->_req_data['context']) |
1150 | 1150 | : key($c_config); |
1151 | 1151 | |
1152 | 1152 | |
1153 | - if ( empty($GRP_ID) ) { |
|
1153 | + if (empty($GRP_ID)) { |
|
1154 | 1154 | $action = 'insert_message_template'; |
1155 | 1155 | //$button_both = false; |
1156 | 1156 | //$button_text = array( __( 'Save','event_espresso') ); |
1157 | 1157 | //$button_actions = array('something_different'); |
1158 | 1158 | //$referrer = false; |
1159 | 1159 | $edit_message_template_form_url = add_query_arg( |
1160 | - array( 'action' => $action, 'noheader' => true ), |
|
1160 | + array('action' => $action, 'noheader' => true), |
|
1161 | 1161 | EE_MSG_ADMIN_URL |
1162 | 1162 | ); |
1163 | 1163 | } else { |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | //$button_actions = array(); |
1168 | 1168 | //$referrer = $this->_admin_base_url; |
1169 | 1169 | $edit_message_template_form_url = add_query_arg( |
1170 | - array( 'action' => $action, 'noheader' => true ), |
|
1170 | + array('action' => $action, 'noheader' => true), |
|
1171 | 1171 | EE_MSG_ADMIN_URL |
1172 | 1172 | ); |
1173 | 1173 | } |
@@ -1181,14 +1181,14 @@ discard block |
||
1181 | 1181 | |
1182 | 1182 | //Do we have any validation errors? |
1183 | 1183 | $validators = $this->_get_transient(); |
1184 | - $v_fields = !empty($validators) ? array_keys($validators) : array(); |
|
1184 | + $v_fields = ! empty($validators) ? array_keys($validators) : array(); |
|
1185 | 1185 | |
1186 | 1186 | |
1187 | 1187 | //we need to assemble the title from Various details |
1188 | 1188 | $context_label = sprintf( |
1189 | 1189 | __('(%s %s)', 'event_espresso'), |
1190 | 1190 | $c_config[$context]['label'], |
1191 | - ucwords($c_label['label'] ) |
|
1191 | + ucwords($c_label['label']) |
|
1192 | 1192 | ); |
1193 | 1193 | |
1194 | 1194 | $title = sprintf( |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | $message_template_group->message_type() |
1210 | 1210 | ); |
1211 | 1211 | |
1212 | - if ( !$template_field_structure ) { |
|
1212 | + if ( ! $template_field_structure) { |
|
1213 | 1213 | $template_field_structure = false; |
1214 | 1214 | $template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso'); |
1215 | 1215 | } |
@@ -1219,51 +1219,51 @@ discard block |
||
1219 | 1219 | |
1220 | 1220 | |
1221 | 1221 | //if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array. |
1222 | - if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) { |
|
1223 | - foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) { |
|
1224 | - unset( $template_field_structure[$context][$reference_field] ); |
|
1222 | + if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) { |
|
1223 | + foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) { |
|
1224 | + unset($template_field_structure[$context][$reference_field]); |
|
1225 | 1225 | } |
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | //let's loop through the template_field_structure and actually assemble the input fields! |
1229 | - if ( !empty($template_field_structure) ) { |
|
1230 | - foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) { |
|
1229 | + if ( ! empty($template_field_structure)) { |
|
1230 | + foreach ($template_field_structure[$context] as $template_field => $field_setup_array) { |
|
1231 | 1231 | //if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them. |
1232 | - if ( $template_field == 'extra' ) { |
|
1232 | + if ($template_field == 'extra') { |
|
1233 | 1233 | $this->_template_args['is_extra_fields'] = true; |
1234 | - foreach ( $field_setup_array as $reference_field => $new_fields_array ) { |
|
1235 | - $message_template = $message_templates[ $context ][ $reference_field ]; |
|
1234 | + foreach ($field_setup_array as $reference_field => $new_fields_array) { |
|
1235 | + $message_template = $message_templates[$context][$reference_field]; |
|
1236 | 1236 | $content = $message_template instanceof EE_Message_Template |
1237 | - ? $message_template->get( 'MTP_content' ) |
|
1237 | + ? $message_template->get('MTP_content') |
|
1238 | 1238 | : ''; |
1239 | - foreach ( $new_fields_array as $extra_field => $extra_array ) { |
|
1239 | + foreach ($new_fields_array as $extra_field => $extra_array) { |
|
1240 | 1240 | //let's verify if we need this extra field via the shortcodes parameter. |
1241 | 1241 | $continue = false; |
1242 | - if ( isset( $extra_array['shortcodes_required'] ) ) { |
|
1243 | - foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) { |
|
1244 | - if ( !array_key_exists( $shortcode, $this->_shortcodes ) ) |
|
1245 | - {$continue = true;} |
|
1242 | + if (isset($extra_array['shortcodes_required'])) { |
|
1243 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
1244 | + if ( ! array_key_exists($shortcode, $this->_shortcodes)) |
|
1245 | + {$continue = true; } |
|
1246 | 1246 | } |
1247 | - if ( $continue ) {continue;} |
|
1247 | + if ($continue) {continue; } |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
1250 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
1251 | 1251 | $template_form_fields[$field_id] = $extra_array; |
1252 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
1253 | - $css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : ''; |
|
1252 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
1253 | + $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
|
1254 | 1254 | |
1255 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1255 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1256 | 1256 | && in_array($extra_field, $v_fields) |
1257 | 1257 | && |
1258 | 1258 | ( |
1259 | - is_array($validators[$extra_field] ) |
|
1260 | - && isset( $validators[$extra_field]['msg'] ) |
|
1259 | + is_array($validators[$extra_field]) |
|
1260 | + && isset($validators[$extra_field]['msg']) |
|
1261 | 1261 | ) |
1262 | - ? 'validate-error ' . $css_class |
|
1262 | + ? 'validate-error '.$css_class |
|
1263 | 1263 | : $css_class; |
1264 | 1264 | |
1265 | - $template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) |
|
1266 | - ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) |
|
1265 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
|
1266 | + ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) |
|
1267 | 1267 | : ''; |
1268 | 1268 | |
1269 | 1269 | //do we have a validation error? if we do then let's use that value instead |
@@ -1279,32 +1279,32 @@ discard block |
||
1279 | 1279 | $field_id |
1280 | 1280 | ); |
1281 | 1281 | |
1282 | - if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) { |
|
1282 | + if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') { |
|
1283 | 1283 | //we want to decode the entities |
1284 | 1284 | $template_form_fields[$field_id]['value'] = stripslashes( |
1285 | - html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1285 | + html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") |
|
1286 | 1286 | ); |
1287 | 1287 | |
1288 | 1288 | }/**/ |
1289 | 1289 | } |
1290 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
1291 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
1290 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
1291 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
1292 | 1292 | |
1293 | 1293 | $template_form_fields[$templatefield_MTP_id] = array( |
1294 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
1294 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
1295 | 1295 | 'label' => null, |
1296 | 1296 | 'input' => 'hidden', |
1297 | 1297 | 'type' => 'int', |
1298 | 1298 | 'required' => false, |
1299 | 1299 | 'validation' => false, |
1300 | - 'value' => !empty($message_templates) ? $message_template->ID() : '', |
|
1300 | + 'value' => ! empty($message_templates) ? $message_template->ID() : '', |
|
1301 | 1301 | 'css_class' => '', |
1302 | 1302 | 'format' => '%d', |
1303 | 1303 | 'db-col' => 'MTP_ID' |
1304 | 1304 | ); |
1305 | 1305 | |
1306 | 1306 | $template_form_fields[$templatefield_templatename_id] = array( |
1307 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
1307 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
1308 | 1308 | 'label' => null, |
1309 | 1309 | 'input' => 'hidden', |
1310 | 1310 | 'type' => 'string', |
@@ -1318,14 +1318,14 @@ discard block |
||
1318 | 1318 | } |
1319 | 1319 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
1320 | 1320 | } else { |
1321 | - $field_id = $template_field . '-content'; |
|
1321 | + $field_id = $template_field.'-content'; |
|
1322 | 1322 | $template_form_fields[$field_id] = $field_setup_array; |
1323 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
1324 | - $message_template = isset( $message_templates[ $context ][ $template_field ] ) |
|
1325 | - ? $message_templates[ $context ][ $template_field ] |
|
1323 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
1324 | + $message_template = isset($message_templates[$context][$template_field]) |
|
1325 | + ? $message_templates[$context][$template_field] |
|
1326 | 1326 | : null; |
1327 | - $template_form_fields[$field_id]['value'] = ! empty( $message_templates ) |
|
1328 | - && is_array( $message_templates[$context] ) |
|
1327 | + $template_form_fields[$field_id]['value'] = ! empty($message_templates) |
|
1328 | + && is_array($message_templates[$context]) |
|
1329 | 1329 | && $message_template instanceof EE_Message_Template |
1330 | 1330 | ? $message_template->get('MTP_content') |
1331 | 1331 | : ''; |
@@ -1338,10 +1338,10 @@ discard block |
||
1338 | 1338 | |
1339 | 1339 | $template_form_fields[$field_id]['db-col'] = 'MTP_content'; |
1340 | 1340 | $css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : ''; |
1341 | - $template_form_fields[$field_id]['css_class'] = ! empty( $v_fields ) |
|
1342 | - && in_array( $template_field, $v_fields ) |
|
1343 | - && isset( $validators[$template_field]['msg'] ) |
|
1344 | - ? 'validate-error ' . $css_class |
|
1341 | + $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
|
1342 | + && in_array($template_field, $v_fields) |
|
1343 | + && isset($validators[$template_field]['msg']) |
|
1344 | + ? 'validate-error '.$css_class |
|
1345 | 1345 | : $css_class; |
1346 | 1346 | |
1347 | 1347 | //shortcode selector |
@@ -1352,12 +1352,12 @@ discard block |
||
1352 | 1352 | |
1353 | 1353 | //k took care of content field(s) now let's take care of others. |
1354 | 1354 | |
1355 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
1356 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
1355 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
1356 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
1357 | 1357 | |
1358 | 1358 | //foreach template field there are actually two form fields created |
1359 | 1359 | $template_form_fields[$templatefield_MTP_id] = array( |
1360 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
1360 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
1361 | 1361 | 'label' => null, |
1362 | 1362 | 'input' => 'hidden', |
1363 | 1363 | 'type' => 'int', |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | ); |
1371 | 1371 | |
1372 | 1372 | $template_form_fields[$templatefield_field_templatename_id] = array( |
1373 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
1373 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
1374 | 1374 | 'label' => null, |
1375 | 1375 | 'input' => 'hidden', |
1376 | 1376 | 'type' => 'string', |
@@ -1514,13 +1514,13 @@ discard block |
||
1514 | 1514 | 'value' => $GRP_ID |
1515 | 1515 | ); |
1516 | 1516 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
1517 | - 'name' => $action . '_nonce', |
|
1517 | + 'name' => $action.'_nonce', |
|
1518 | 1518 | 'input' => 'hidden', |
1519 | 1519 | 'type' => 'string', |
1520 | - 'value' => wp_create_nonce( $action . '_nonce') |
|
1520 | + 'value' => wp_create_nonce($action.'_nonce') |
|
1521 | 1521 | ); |
1522 | 1522 | |
1523 | - if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) { |
|
1523 | + if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
|
1524 | 1524 | $sidebar_form_fields['ee-msg-template-switch'] = array( |
1525 | 1525 | 'name' => 'template_switch', |
1526 | 1526 | 'input' => 'hidden', |
@@ -1530,8 +1530,8 @@ discard block |
||
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | |
1533 | - $template_fields = $this->_generate_admin_form_fields( $template_form_fields ); |
|
1534 | - $sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields ); |
|
1533 | + $template_fields = $this->_generate_admin_form_fields($template_form_fields); |
|
1534 | + $sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields); |
|
1535 | 1535 | |
1536 | 1536 | |
1537 | 1537 | } //end if ( !empty($template_field_structure) ) |
@@ -1543,7 +1543,7 @@ discard block |
||
1543 | 1543 | $GRP_ID, |
1544 | 1544 | false, |
1545 | 1545 | add_query_arg( |
1546 | - array( 'action' => 'global_mtps' ), |
|
1546 | + array('action' => 'global_mtps'), |
|
1547 | 1547 | $this->_admin_base_url |
1548 | 1548 | ) |
1549 | 1549 | ); |
@@ -1559,7 +1559,7 @@ discard block |
||
1559 | 1559 | ), |
1560 | 1560 | $this->_admin_base_url |
1561 | 1561 | ); |
1562 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>'; |
|
1562 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>'; |
|
1563 | 1563 | |
1564 | 1564 | |
1565 | 1565 | //setup context switcher |
@@ -1587,17 +1587,17 @@ discard block |
||
1587 | 1587 | $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after(); |
1588 | 1588 | |
1589 | 1589 | $this->_template_path = $this->_template_args['GRP_ID'] |
1590 | - ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
|
1591 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
1590 | + ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' |
|
1591 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
1592 | 1592 | |
1593 | 1593 | //send along EE_Message_Template_Group object for further template use. |
1594 | 1594 | $this->_template_args['MTP'] = $message_template_group; |
1595 | 1595 | |
1596 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true ); |
|
1596 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true); |
|
1597 | 1597 | |
1598 | 1598 | |
1599 | 1599 | //finally, let's set the admin_page title |
1600 | - $this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title ); |
|
1600 | + $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title); |
|
1601 | 1601 | |
1602 | 1602 | |
1603 | 1603 | //we need to take care of setting the shortcodes property for use elsewhere. |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | |
1613 | - public function filter_tinymce_init( $mceInit, $editor_id ) { |
|
1613 | + public function filter_tinymce_init($mceInit, $editor_id) { |
|
1614 | 1614 | return $mceInit; |
1615 | 1615 | } |
1616 | 1616 | |
@@ -1621,7 +1621,7 @@ discard block |
||
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | public function _add_form_element_before() { |
1624 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
1624 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
1625 | 1625 | } |
1626 | 1626 | |
1627 | 1627 | public function _add_form_element_after() { |
@@ -1638,25 +1638,25 @@ discard block |
||
1638 | 1638 | * |
1639 | 1639 | */ |
1640 | 1640 | public function switch_template_pack() { |
1641 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1642 | - $template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : ''; |
|
1641 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1642 | + $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : ''; |
|
1643 | 1643 | |
1644 | 1644 | //verify we have needed values. |
1645 | - if ( empty( $GRP_ID ) || empty( $template_pack ) ) { |
|
1645 | + if (empty($GRP_ID) || empty($template_pack)) { |
|
1646 | 1646 | $this->_template_args['error'] = true; |
1647 | - EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1647 | + EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1648 | 1648 | } else { |
1649 | 1649 | //get template, set the new template_pack and then reset to default |
1650 | 1650 | /** @type EE_Message_Template_Group $message_template_group */ |
1651 | - $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1651 | + $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1652 | 1652 | |
1653 | - $message_template_group->set_template_pack_name( $template_pack ); |
|
1653 | + $message_template_group->set_template_pack_name($template_pack); |
|
1654 | 1654 | $this->_req_data['msgr'] = $message_template_group->messenger(); |
1655 | 1655 | $this->_req_data['mt'] = $message_template_group->message_type(); |
1656 | 1656 | |
1657 | 1657 | $query_args = $this->_reset_to_default_template(); |
1658 | 1658 | |
1659 | - if ( empty( $query_args['id'] ) ) { |
|
1659 | + if (empty($query_args['id'])) { |
|
1660 | 1660 | EE_Error::add_error( |
1661 | 1661 | __( |
1662 | 1662 | 'Something went wrong with switching the template pack. Please try again or contact EE support', |
@@ -1666,7 +1666,7 @@ discard block |
||
1666 | 1666 | ); |
1667 | 1667 | $this->_template_args['error'] = true; |
1668 | 1668 | } else { |
1669 | - $template_label =$message_template_group->get_template_pack()->label; |
|
1669 | + $template_label = $message_template_group->get_template_pack()->label; |
|
1670 | 1670 | $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels(); |
1671 | 1671 | EE_Error::add_success( |
1672 | 1672 | sprintf( |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | ) |
1680 | 1680 | ); |
1681 | 1681 | //generate the redirect url for js. |
1682 | - $url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1682 | + $url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1683 | 1683 | $this->_template_args['data']['redirect_url'] = $url; |
1684 | 1684 | $this->_template_args['success'] = true; |
1685 | 1685 | } |
@@ -1701,9 +1701,9 @@ discard block |
||
1701 | 1701 | protected function _reset_to_default_template() { |
1702 | 1702 | |
1703 | 1703 | $templates = array(); |
1704 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
1704 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
1705 | 1705 | //we need to make sure we've got the info we need. |
1706 | - if ( ! isset( $this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'] ) ) { |
|
1706 | + if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) { |
|
1707 | 1707 | EE_Error::add_error( |
1708 | 1708 | __( |
1709 | 1709 | 'In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset. At least one of these is missing.', |
@@ -1715,9 +1715,9 @@ discard block |
||
1715 | 1715 | |
1716 | 1716 | // all templates will be reset to whatever the defaults are |
1717 | 1717 | // for the global template matching the messenger and message type. |
1718 | - $success = !empty( $GRP_ID ) ? true : false; |
|
1718 | + $success = ! empty($GRP_ID) ? true : false; |
|
1719 | 1719 | |
1720 | - if ( $success ) { |
|
1720 | + if ($success) { |
|
1721 | 1721 | |
1722 | 1722 | //let's first determine if the incoming template is a global template, |
1723 | 1723 | // if it isn't then we need to get the global template matching messenger and message type. |
@@ -1725,9 +1725,9 @@ discard block |
||
1725 | 1725 | |
1726 | 1726 | |
1727 | 1727 | //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group. |
1728 | - $success = $this->_delete_mtp_permanently( $GRP_ID, false ); |
|
1728 | + $success = $this->_delete_mtp_permanently($GRP_ID, false); |
|
1729 | 1729 | |
1730 | - if ( $success ) { |
|
1730 | + if ($success) { |
|
1731 | 1731 | // if successfully deleted, lets generate the new ones. |
1732 | 1732 | // Note. We set GLOBAL to true, because resets on ANY template |
1733 | 1733 | // will use the related global template defaults for regeneration. |
@@ -1745,32 +1745,32 @@ discard block |
||
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | //any error messages? |
1748 | - if ( !$success ) { |
|
1748 | + if ( ! $success) { |
|
1749 | 1749 | EE_Error::add_error( |
1750 | - __( 'Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso' ), |
|
1750 | + __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), |
|
1751 | 1751 | __FILE__, __FUNCTION__, __LINE__ |
1752 | 1752 | ); |
1753 | 1753 | } |
1754 | 1754 | |
1755 | 1755 | //all good, let's add a success message! |
1756 | - if ( $success && ! empty( $templates ) ) { |
|
1756 | + if ($success && ! empty($templates)) { |
|
1757 | 1757 | $templates = $templates[0]; //the info for the template we generated is the first element in the returned array. |
1758 | 1758 | EE_Error::overwrite_success(); |
1759 | - EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') ); |
|
1759 | + EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso')); |
|
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | |
1763 | 1763 | $query_args = array( |
1764 | - 'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null, |
|
1765 | - 'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null, |
|
1766 | - 'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps' |
|
1764 | + 'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null, |
|
1765 | + 'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null, |
|
1766 | + 'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps' |
|
1767 | 1767 | ); |
1768 | 1768 | |
1769 | 1769 | //if called via ajax then we return query args otherwise redirect |
1770 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
1770 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
1771 | 1771 | return $query_args; |
1772 | 1772 | } else { |
1773 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
1773 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
1774 | 1774 | return null; |
1775 | 1775 | } |
1776 | 1776 | } |
@@ -1783,7 +1783,7 @@ discard block |
||
1783 | 1783 | * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. |
1784 | 1784 | * @return string |
1785 | 1785 | */ |
1786 | - public function _preview_message( $send = false ) { |
|
1786 | + public function _preview_message($send = false) { |
|
1787 | 1787 | //first make sure we've got the necessary parameters |
1788 | 1788 | if ( |
1789 | 1789 | ! isset( |
@@ -1799,13 +1799,13 @@ discard block |
||
1799 | 1799 | ); |
1800 | 1800 | } |
1801 | 1801 | |
1802 | - EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] ); |
|
1802 | + EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); |
|
1803 | 1803 | |
1804 | 1804 | |
1805 | 1805 | //get the preview! |
1806 | - $preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send ); |
|
1806 | + $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); |
|
1807 | 1807 | |
1808 | - if ( $send ) { |
|
1808 | + if ($send) { |
|
1809 | 1809 | return $preview; |
1810 | 1810 | } |
1811 | 1811 | |
@@ -1815,22 +1815,22 @@ discard block |
||
1815 | 1815 | 'context' => $this->_req_data['context'], |
1816 | 1816 | 'action' => 'edit_message_template' |
1817 | 1817 | ); |
1818 | - $go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1819 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; |
|
1818 | + $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1819 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>'; |
|
1820 | 1820 | $message_types = $this->get_installed_message_types(); |
1821 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
1821 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
1822 | 1822 | $active_messenger_label = $active_messenger instanceof EE_messenger |
1823 | - ? ucwords( $active_messenger->label['singular'] ) |
|
1824 | - : esc_html__( 'Unknown Messenger', 'event_espresso' ); |
|
1823 | + ? ucwords($active_messenger->label['singular']) |
|
1824 | + : esc_html__('Unknown Messenger', 'event_espresso'); |
|
1825 | 1825 | //let's provide a helpful title for context |
1826 | 1826 | $preview_title = sprintf( |
1827 | - __( 'Viewing Preview for %s %s Message Template', 'event_espresso' ), |
|
1827 | + __('Viewing Preview for %s %s Message Template', 'event_espresso'), |
|
1828 | 1828 | $active_messenger_label, |
1829 | - ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] ) |
|
1829 | + ucwords($message_types[$this->_req_data['message_type']]->label['singular']) |
|
1830 | 1830 | ); |
1831 | 1831 | //setup display of preview. |
1832 | 1832 | $this->_admin_page_title = $preview_title; |
1833 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview); |
|
1833 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
1834 | 1834 | $this->_template_args['data']['force_json'] = true; |
1835 | 1835 | return ''; |
1836 | 1836 | } |
@@ -1860,9 +1860,9 @@ discard block |
||
1860 | 1860 | * @return void |
1861 | 1861 | */ |
1862 | 1862 | protected function _register_edit_meta_boxes() { |
1863 | - add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' ); |
|
1864 | - add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1865 | - add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' ); |
|
1863 | + add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default'); |
|
1864 | + add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1865 | + add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high'); |
|
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | |
@@ -1881,14 +1881,14 @@ discard block |
||
1881 | 1881 | |
1882 | 1882 | $tp_select_values = array(); |
1883 | 1883 | |
1884 | - foreach ( $tp_collection as $tp ) { |
|
1884 | + foreach ($tp_collection as $tp) { |
|
1885 | 1885 | //only include template packs that support this messenger and message type! |
1886 | 1886 | $supports = $tp->get_supports(); |
1887 | 1887 | if ( |
1888 | - ! isset( $supports[ $this->_message_template_group->messenger() ] ) |
|
1888 | + ! isset($supports[$this->_message_template_group->messenger()]) |
|
1889 | 1889 | || ! in_array( |
1890 | 1890 | $this->_message_template_group->message_type(), |
1891 | - $supports[ $this->_message_template_group->messenger() ] |
|
1891 | + $supports[$this->_message_template_group->messenger()] |
|
1892 | 1892 | ) |
1893 | 1893 | ) { |
1894 | 1894 | //not supported |
@@ -1902,7 +1902,7 @@ discard block |
||
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | //if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack. This still allows for the odd template pack to override. |
1905 | - if ( empty( $tp_select_values ) ) { |
|
1905 | + if (empty($tp_select_values)) { |
|
1906 | 1906 | $tp_select_values[] = array( |
1907 | 1907 | 'text' => __('Default', 'event_espresso'), |
1908 | 1908 | 'id' => 'default' |
@@ -1915,14 +1915,14 @@ discard block |
||
1915 | 1915 | $this->_message_template_group->message_type() |
1916 | 1916 | ); |
1917 | 1917 | $variations_select_values = array(); |
1918 | - foreach ( $variations as $variation => $label ) { |
|
1918 | + foreach ($variations as $variation => $label) { |
|
1919 | 1919 | $variations_select_values[] = array( |
1920 | 1920 | 'text' => $label, |
1921 | 1921 | 'id' => $variation |
1922 | 1922 | ); |
1923 | 1923 | } |
1924 | 1924 | |
1925 | - $template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1925 | + $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
|
1926 | 1926 | |
1927 | 1927 | $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( |
1928 | 1928 | 'MTP_template_pack', |
@@ -1939,9 +1939,9 @@ discard block |
||
1939 | 1939 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
1940 | 1940 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
1941 | 1941 | |
1942 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
1942 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
1943 | 1943 | |
1944 | - EEH_Template::display_template( $template, $template_args ); |
|
1944 | + EEH_Template::display_template($template, $template_args); |
|
1945 | 1945 | } |
1946 | 1946 | |
1947 | 1947 | |
@@ -1965,46 +1965,46 @@ discard block |
||
1965 | 1965 | //first we need to see if there are any fields |
1966 | 1966 | $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields(); |
1967 | 1967 | |
1968 | - if ( !empty( $fields ) ) { |
|
1968 | + if ( ! empty($fields)) { |
|
1969 | 1969 | //yup there be fields |
1970 | - foreach ( $fields as $field => $config ) { |
|
1971 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
1970 | + foreach ($fields as $field => $config) { |
|
1971 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
1972 | 1972 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
1973 | - $default = isset( $config['default'] ) ? $config['default'] : ''; |
|
1974 | - $default = isset( $config['value'] ) ? $config['value'] : $default; |
|
1973 | + $default = isset($config['default']) ? $config['default'] : ''; |
|
1974 | + $default = isset($config['value']) ? $config['value'] : $default; |
|
1975 | 1975 | |
1976 | 1976 | // if type is hidden and the value is empty |
1977 | 1977 | // something may have gone wrong so let's correct with the defaults |
1978 | 1978 | $fix = $config['input'] === 'hidden' && isset($existing[$field]) && empty($existing[$field]) |
1979 | 1979 | ? $default |
1980 | 1980 | : ''; |
1981 | - $existing[$field] = isset( $existing[$field] ) && empty( $fix ) |
|
1981 | + $existing[$field] = isset($existing[$field]) && empty($fix) |
|
1982 | 1982 | ? $existing[$field] |
1983 | 1983 | : $fix; |
1984 | 1984 | |
1985 | 1985 | $template_form_fields[$field_id] = array( |
1986 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
1986 | + 'name' => 'test_settings_fld['.$field.']', |
|
1987 | 1987 | 'label' => $config['label'], |
1988 | 1988 | 'input' => $config['input'], |
1989 | 1989 | 'type' => $config['type'], |
1990 | 1990 | 'required' => $config['required'], |
1991 | 1991 | 'validation' => $config['validation'], |
1992 | - 'value' => isset( $existing[ $field ] ) ? $existing[ $field ] : $default, |
|
1992 | + 'value' => isset($existing[$field]) ? $existing[$field] : $default, |
|
1993 | 1993 | 'css_class' => $config['css_class'], |
1994 | - 'options' => isset( $config['options'] ) ? $config['options'] : array(), |
|
1994 | + 'options' => isset($config['options']) ? $config['options'] : array(), |
|
1995 | 1995 | 'default' => $default, |
1996 | 1996 | 'format' => $config['format'] |
1997 | 1997 | ); |
1998 | 1998 | } |
1999 | 1999 | } |
2000 | 2000 | |
2001 | - $test_settings_fields = !empty( $template_form_fields) |
|
2002 | - ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) |
|
2001 | + $test_settings_fields = ! empty($template_form_fields) |
|
2002 | + ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') |
|
2003 | 2003 | : ''; |
2004 | 2004 | |
2005 | 2005 | $test_settings_html = ''; |
2006 | 2006 | //print out $test_settings_fields |
2007 | - if ( !empty( $test_settings_fields ) ) { |
|
2007 | + if ( ! empty($test_settings_fields)) { |
|
2008 | 2008 | echo $test_settings_fields; |
2009 | 2009 | $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" '; |
2010 | 2010 | $test_settings_html .= 'name="test_button" value="'; |
@@ -2013,7 +2013,7 @@ discard block |
||
2013 | 2013 | } |
2014 | 2014 | |
2015 | 2015 | //and button |
2016 | - $test_settings_html .= '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>'; |
|
2016 | + $test_settings_html .= '<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'; |
|
2017 | 2017 | $test_settings_html .= '<div class="publishing-action alignright resetbutton">'; |
2018 | 2018 | $test_settings_html .= $this->get_action_link_or_button( |
2019 | 2019 | 'reset_to_default', |
@@ -2037,13 +2037,13 @@ discard block |
||
2037 | 2037 | * @param string $linked_input_id The css id of the input that the shortcodes get added to. |
2038 | 2038 | * @return string |
2039 | 2039 | */ |
2040 | - protected function _get_shortcode_selector( $field, $linked_input_id ) { |
|
2040 | + protected function _get_shortcode_selector($field, $linked_input_id) { |
|
2041 | 2041 | $template_args = array( |
2042 | - 'shortcodes' => $this->_get_shortcodes( array( $field ), true ), |
|
2042 | + 'shortcodes' => $this->_get_shortcodes(array($field), true), |
|
2043 | 2043 | 'fieldname' => $field, |
2044 | 2044 | 'linked_input_id' => $linked_input_id |
2045 | 2045 | ); |
2046 | - return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true ); |
|
2046 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true); |
|
2047 | 2047 | } |
2048 | 2048 | |
2049 | 2049 | |
@@ -2058,13 +2058,13 @@ discard block |
||
2058 | 2058 | $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set |
2059 | 2059 | //$messenger = $this->_message_template_group->messenger_obj(); |
2060 | 2060 | //now let's set the content depending on the status of the shortcodes array |
2061 | - if ( empty( $shortcodes ) ) { |
|
2062 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
2061 | + if (empty($shortcodes)) { |
|
2062 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
2063 | 2063 | echo $content; |
2064 | 2064 | } else { |
2065 | 2065 | //$alt = 0; |
2066 | 2066 | ?> |
2067 | - <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p> |
|
2067 | + <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p> |
|
2068 | 2068 | <?php |
2069 | 2069 | } |
2070 | 2070 | |
@@ -2081,7 +2081,7 @@ discard block |
||
2081 | 2081 | protected function _set_shortcodes() { |
2082 | 2082 | |
2083 | 2083 | //no need to run this if the property is already set |
2084 | - if ( !empty($this->_shortcodes ) ) {return;} |
|
2084 | + if ( ! empty($this->_shortcodes)) {return; } |
|
2085 | 2085 | |
2086 | 2086 | $this->_shortcodes = $this->_get_shortcodes(); |
2087 | 2087 | } |
@@ -2103,14 +2103,14 @@ discard block |
||
2103 | 2103 | * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true |
2104 | 2104 | * just an array of shortcode/label pairs. |
2105 | 2105 | */ |
2106 | - protected function _get_shortcodes( $fields = array(), $merged = true ) { |
|
2106 | + protected function _get_shortcodes($fields = array(), $merged = true) { |
|
2107 | 2107 | $this->_set_message_template_group(); |
2108 | 2108 | |
2109 | 2109 | //we need the messenger and message template to retrieve the valid shortcodes array. |
2110 | - $GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false; |
|
2111 | - $context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() ); |
|
2110 | + $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false; |
|
2111 | + $context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config()); |
|
2112 | 2112 | |
2113 | - return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array(); |
|
2113 | + return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array(); |
|
2114 | 2114 | } |
2115 | 2115 | |
2116 | 2116 | |
@@ -2123,19 +2123,19 @@ discard block |
||
2123 | 2123 | */ |
2124 | 2124 | protected function _set_message_template_group() { |
2125 | 2125 | |
2126 | - if ( !empty( $this->_message_template_group ) ) |
|
2127 | - {return;} //get out if this is already set. |
|
2126 | + if ( ! empty($this->_message_template_group)) |
|
2127 | + {return; } //get out if this is already set. |
|
2128 | 2128 | |
2129 | - $GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false; |
|
2130 | - $GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID; |
|
2129 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false; |
|
2130 | + $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID; |
|
2131 | 2131 | |
2132 | 2132 | //let's get the message templates |
2133 | 2133 | $MTP = EEM_Message_Template_Group::instance(); |
2134 | 2134 | |
2135 | - if ( empty($GRP_ID) ) |
|
2136 | - {$this->_message_template_group = $MTP->create_default_object();} |
|
2135 | + if (empty($GRP_ID)) |
|
2136 | + {$this->_message_template_group = $MTP->create_default_object(); } |
|
2137 | 2137 | else |
2138 | - {$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );} |
|
2138 | + {$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); } |
|
2139 | 2139 | |
2140 | 2140 | $this->_template_pack = $this->_message_template_group->get_template_pack(); |
2141 | 2141 | $this->_variation = $this->_message_template_group->get_template_pack_variation(); |
@@ -2154,7 +2154,7 @@ discard block |
||
2154 | 2154 | * @param array $args various things the context switcher needs. |
2155 | 2155 | * |
2156 | 2156 | */ |
2157 | - protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) { |
|
2157 | + protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) { |
|
2158 | 2158 | $context_details = $template_group_object->contexts_config(); |
2159 | 2159 | $context_label = $template_group_object->context_label(); |
2160 | 2160 | ob_start(); |
@@ -2162,20 +2162,20 @@ discard block |
||
2162 | 2162 | <div class="ee-msg-switcher-container"> |
2163 | 2163 | <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm"> |
2164 | 2164 | <?php |
2165 | - foreach ( $args as $name => $value ) { |
|
2166 | - if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;} |
|
2165 | + foreach ($args as $name => $value) { |
|
2166 | + if ($name == 'context' || empty($value) || $name == 'extra') {continue; } |
|
2167 | 2167 | ?> |
2168 | 2168 | <input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" /> |
2169 | 2169 | <?php |
2170 | 2170 | } |
2171 | 2171 | //setup nonce_url |
2172 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
2172 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
2173 | 2173 | ?> |
2174 | 2174 | <select name="context"> |
2175 | 2175 | <?php |
2176 | 2176 | $context_templates = $template_group_object->context_templates(); |
2177 | - if ( is_array($context_templates) ) : |
|
2178 | - foreach ( $context_templates as $context => $template_fields ) : |
|
2177 | + if (is_array($context_templates)) : |
|
2178 | + foreach ($context_templates as $context => $template_fields) : |
|
2179 | 2179 | $checked = ($context == $args['context']) ? 'selected="selected"' : ''; |
2180 | 2180 | ?> |
2181 | 2181 | <option value="<?php echo $context; ?>" <?php echo $checked; ?>> |
@@ -2183,7 +2183,7 @@ discard block |
||
2183 | 2183 | </option> |
2184 | 2184 | <?php endforeach; endif; ?> |
2185 | 2185 | </select> |
2186 | - <?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?> |
|
2186 | + <?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?> |
|
2187 | 2187 | <input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>"> |
2188 | 2188 | </form> |
2189 | 2189 | <?php echo $args['extra']; ?> |
@@ -2210,8 +2210,8 @@ discard block |
||
2210 | 2210 | * @return array |
2211 | 2211 | */ |
2212 | 2212 | protected function _set_message_template_column_values($index) { |
2213 | - if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) { |
|
2214 | - foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) { |
|
2213 | + if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) { |
|
2214 | + foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) { |
|
2215 | 2215 | $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value; |
2216 | 2216 | } |
2217 | 2217 | } /*else { |
@@ -2220,22 +2220,22 @@ discard block |
||
2220 | 2220 | |
2221 | 2221 | |
2222 | 2222 | $set_column_values = array( |
2223 | - 'MTP_ID' => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ), |
|
2224 | - 'GRP_ID' => absint( $this->_req_data[ 'GRP_ID' ] ), |
|
2225 | - 'MTP_user_id' => absint( $this->_req_data[ 'MTP_user_id' ] ), |
|
2226 | - 'MTP_messenger' => strtolower( $this->_req_data[ 'MTP_messenger' ] ), |
|
2227 | - 'MTP_message_type' => strtolower( $this->_req_data[ 'MTP_message_type' ] ), |
|
2228 | - 'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ), |
|
2229 | - 'MTP_context' => strtolower( $this->_req_data[ 'MTP_context' ] ), |
|
2230 | - 'MTP_content' => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ], |
|
2231 | - 'MTP_is_global' => isset( $this->_req_data[ 'MTP_is_global' ] ) |
|
2232 | - ? absint( $this->_req_data[ 'MTP_is_global' ] ) |
|
2223 | + 'MTP_ID' => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']), |
|
2224 | + 'GRP_ID' => absint($this->_req_data['GRP_ID']), |
|
2225 | + 'MTP_user_id' => absint($this->_req_data['MTP_user_id']), |
|
2226 | + 'MTP_messenger' => strtolower($this->_req_data['MTP_messenger']), |
|
2227 | + 'MTP_message_type' => strtolower($this->_req_data['MTP_message_type']), |
|
2228 | + 'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']), |
|
2229 | + 'MTP_context' => strtolower($this->_req_data['MTP_context']), |
|
2230 | + 'MTP_content' => $this->_req_data['MTP_template_fields'][$index]['content'], |
|
2231 | + 'MTP_is_global' => isset($this->_req_data['MTP_is_global']) |
|
2232 | + ? absint($this->_req_data['MTP_is_global']) |
|
2233 | 2233 | : 0, |
2234 | - 'MTP_is_override' => isset( $this->_req_data[ 'MTP_is_override' ] ) |
|
2235 | - ? absint( $this->_req_data[ 'MTP_is_override' ] ) |
|
2234 | + 'MTP_is_override' => isset($this->_req_data['MTP_is_override']) |
|
2235 | + ? absint($this->_req_data['MTP_is_override']) |
|
2236 | 2236 | : 0, |
2237 | - 'MTP_deleted' => absint( $this->_req_data[ 'MTP_deleted' ] ), |
|
2238 | - 'MTP_is_active' => absint( $this->_req_data[ 'MTP_is_active' ] ) |
|
2237 | + 'MTP_deleted' => absint($this->_req_data['MTP_deleted']), |
|
2238 | + 'MTP_is_active' => absint($this->_req_data['MTP_is_active']) |
|
2239 | 2239 | ); |
2240 | 2240 | |
2241 | 2241 | |
@@ -2247,42 +2247,42 @@ discard block |
||
2247 | 2247 | |
2248 | 2248 | |
2249 | 2249 | |
2250 | - protected function _insert_or_update_message_template($new = false ) { |
|
2250 | + protected function _insert_or_update_message_template($new = false) { |
|
2251 | 2251 | |
2252 | - do_action ( 'AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2252 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2253 | 2253 | $success = 0; |
2254 | 2254 | $override = false; |
2255 | 2255 | |
2256 | 2256 | //setup notices description |
2257 | - $messenger_slug = ! empty( $this->_req_data['MTP_messenger'] ) ? $this->_req_data['MTP_messenger'] : ''; |
|
2257 | + $messenger_slug = ! empty($this->_req_data['MTP_messenger']) ? $this->_req_data['MTP_messenger'] : ''; |
|
2258 | 2258 | |
2259 | 2259 | //need the message type and messenger objects to be able to use the labels for the notices |
2260 | - $messenger_object = $this->_message_resource_manager->get_messenger( $messenger_slug ); |
|
2261 | - $messenger_label = $messenger_object instanceof EE_messenger ? ucwords( $messenger_object->label['singular'] ) : ''; |
|
2260 | + $messenger_object = $this->_message_resource_manager->get_messenger($messenger_slug); |
|
2261 | + $messenger_label = $messenger_object instanceof EE_messenger ? ucwords($messenger_object->label['singular']) : ''; |
|
2262 | 2262 | |
2263 | - $message_type_slug = ! empty( $this->_req_data['MTP_message_type'] ) ? $this->_req_data['MTP_message_type'] : ''; |
|
2264 | - $message_type_object = $this->_message_resource_manager->get_message_type( $message_type_slug ); |
|
2263 | + $message_type_slug = ! empty($this->_req_data['MTP_message_type']) ? $this->_req_data['MTP_message_type'] : ''; |
|
2264 | + $message_type_object = $this->_message_resource_manager->get_message_type($message_type_slug); |
|
2265 | 2265 | |
2266 | 2266 | $message_type_label = $message_type_object instanceof EE_message_type |
2267 | - ? ucwords( $message_type_object->label['singular'] ) |
|
2267 | + ? ucwords($message_type_object->label['singular']) |
|
2268 | 2268 | : ''; |
2269 | 2269 | |
2270 | - $context_slug = ! empty( $this->_req_data['MTP_context'] ) |
|
2270 | + $context_slug = ! empty($this->_req_data['MTP_context']) |
|
2271 | 2271 | ? $this->_req_data['MTP_context'] |
2272 | 2272 | : ''; |
2273 | - $context = ucwords( str_replace( '_', ' ', $context_slug ) ); |
|
2273 | + $context = ucwords(str_replace('_', ' ', $context_slug)); |
|
2274 | 2274 | |
2275 | - $item_desc = $messenger_label && $message_type_label ? $messenger_label. ' ' . $message_type_label . ' ' . $context . ' ' : ''; |
|
2275 | + $item_desc = $messenger_label && $message_type_label ? $messenger_label.' '.$message_type_label.' '.$context.' ' : ''; |
|
2276 | 2276 | $item_desc .= 'Message Template'; |
2277 | 2277 | $query_args = array(); |
2278 | 2278 | $edit_array = array(); |
2279 | 2279 | $action_desc = ''; |
2280 | 2280 | |
2281 | 2281 | //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit. |
2282 | - if ( $new ) { |
|
2283 | - $GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0; |
|
2284 | - if ( $edit_array = $this->_generate_new_templates($messenger_slug, $message_type_slug, $GRP_ID ) ) { |
|
2285 | - if ( empty($edit_array) ) { |
|
2282 | + if ($new) { |
|
2283 | + $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0; |
|
2284 | + if ($edit_array = $this->_generate_new_templates($messenger_slug, $message_type_slug, $GRP_ID)) { |
|
2285 | + if (empty($edit_array)) { |
|
2286 | 2286 | $success = 0; |
2287 | 2287 | } else { |
2288 | 2288 | $success = 1; |
@@ -2301,7 +2301,7 @@ discard block |
||
2301 | 2301 | |
2302 | 2302 | |
2303 | 2303 | //run update for each template field in displayed context |
2304 | - if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) { |
|
2304 | + if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) { |
|
2305 | 2305 | EE_Error::add_error( |
2306 | 2306 | __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), |
2307 | 2307 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2310,25 +2310,25 @@ discard block |
||
2310 | 2310 | |
2311 | 2311 | } else { |
2312 | 2312 | //first validate all fields! |
2313 | - $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $context_slug, $messenger_slug, $message_type_slug); |
|
2313 | + $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $context_slug, $messenger_slug, $message_type_slug); |
|
2314 | 2314 | |
2315 | 2315 | //if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array. WE need to make sure there is no actual error messages in validates. |
2316 | - if ( is_array($validates) && !empty($validates) ) { |
|
2316 | + if (is_array($validates) && ! empty($validates)) { |
|
2317 | 2317 | //add the transient so when the form loads we know which fields to highlight |
2318 | - $this->_add_transient( 'edit_message_template', $validates ); |
|
2318 | + $this->_add_transient('edit_message_template', $validates); |
|
2319 | 2319 | |
2320 | 2320 | $success = 0; |
2321 | 2321 | |
2322 | 2322 | //setup notices |
2323 | - foreach ( $validates as $field => $error ) { |
|
2324 | - if ( isset($error['msg'] ) ) { |
|
2325 | - EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ ); |
|
2323 | + foreach ($validates as $field => $error) { |
|
2324 | + if (isset($error['msg'])) { |
|
2325 | + EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); |
|
2326 | 2326 | } |
2327 | 2327 | } |
2328 | 2328 | |
2329 | 2329 | } else { |
2330 | 2330 | $set_column_values = array(); |
2331 | - foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) { |
|
2331 | + foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) { |
|
2332 | 2332 | $set_column_values = $this->_set_message_template_column_values($template_field); |
2333 | 2333 | |
2334 | 2334 | $where_cols_n_values = array( |
@@ -2341,11 +2341,11 @@ discard block |
||
2341 | 2341 | 'MTP_context' => $set_column_values['MTP_context'], |
2342 | 2342 | 'MTP_content' => $set_column_values['MTP_content'] |
2343 | 2343 | ); |
2344 | - if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) { |
|
2345 | - if ( $updated === false ) { |
|
2344 | + if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) { |
|
2345 | + if ($updated === false) { |
|
2346 | 2346 | EE_Error::add_error( |
2347 | 2347 | sprintf( |
2348 | - __( '%s field was NOT updated for some reason', 'event_espresso' ), |
|
2348 | + __('%s field was NOT updated for some reason', 'event_espresso'), |
|
2349 | 2349 | $template_field |
2350 | 2350 | ), |
2351 | 2351 | __FILE__, __FUNCTION__, __LINE__ |
@@ -2359,46 +2359,46 @@ discard block |
||
2359 | 2359 | |
2360 | 2360 | //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs) |
2361 | 2361 | $mtpg_fields = array( |
2362 | - 'MTP_user_id' => $set_column_values[ 'MTP_user_id' ], |
|
2363 | - 'MTP_messenger' => $set_column_values[ 'MTP_messenger' ], |
|
2364 | - 'MTP_message_type' => $set_column_values[ 'MTP_message_type' ], |
|
2365 | - 'MTP_is_global' => $set_column_values[ 'MTP_is_global' ], |
|
2366 | - 'MTP_is_override' => $set_column_values[ 'MTP_is_override' ], |
|
2367 | - 'MTP_deleted' => $set_column_values[ 'MTP_deleted' ], |
|
2368 | - 'MTP_is_active' => $set_column_values[ 'MTP_is_active' ], |
|
2369 | - 'MTP_name' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] ) |
|
2370 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] |
|
2362 | + 'MTP_user_id' => $set_column_values['MTP_user_id'], |
|
2363 | + 'MTP_messenger' => $set_column_values['MTP_messenger'], |
|
2364 | + 'MTP_message_type' => $set_column_values['MTP_message_type'], |
|
2365 | + 'MTP_is_global' => $set_column_values['MTP_is_global'], |
|
2366 | + 'MTP_is_override' => $set_column_values['MTP_is_override'], |
|
2367 | + 'MTP_deleted' => $set_column_values['MTP_deleted'], |
|
2368 | + 'MTP_is_active' => $set_column_values['MTP_is_active'], |
|
2369 | + 'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) |
|
2370 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] |
|
2371 | 2371 | : '', |
2372 | - 'MTP_description' => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] ) |
|
2373 | - ? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] |
|
2372 | + 'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) |
|
2373 | + ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] |
|
2374 | 2374 | : '' |
2375 | 2375 | ); |
2376 | 2376 | |
2377 | - $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] ); |
|
2378 | - $updated = $MTPG->update( $mtpg_fields, array($mtpg_where) ); |
|
2377 | + $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']); |
|
2378 | + $updated = $MTPG->update($mtpg_fields, array($mtpg_where)); |
|
2379 | 2379 | |
2380 | - if ( $updated === false ) { |
|
2380 | + if ($updated === false) { |
|
2381 | 2381 | EE_Error::add_error( |
2382 | 2382 | sprintf( |
2383 | - __( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ), |
|
2384 | - $set_column_values[ 'GRP_ID' ] |
|
2383 | + __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), |
|
2384 | + $set_column_values['GRP_ID'] |
|
2385 | 2385 | ), |
2386 | 2386 | __FILE__, __FUNCTION__, __LINE__ |
2387 | 2387 | ); |
2388 | 2388 | } else { |
2389 | 2389 | //k now we need to ensure the template_pack and template_variation fields are set. |
2390 | - $template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) |
|
2390 | + $template_pack = ! empty($this->_req_data['MTP_template_pack']) |
|
2391 | 2391 | ? $this->_req_data['MTP_template_pack'] |
2392 | 2392 | : 'default'; |
2393 | 2393 | |
2394 | - $template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) |
|
2394 | + $template_variation = ! empty($this->_req_data['MTP_template_variation']) |
|
2395 | 2395 | ? $this->_req_data['MTP_template_variation'] |
2396 | 2396 | : 'default'; |
2397 | 2397 | |
2398 | - $mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] ); |
|
2399 | - if ( $mtpg_obj instanceof EE_Message_Template_Group ) { |
|
2400 | - $mtpg_obj->set_template_pack_name( $template_pack ); |
|
2401 | - $mtpg_obj->set_template_pack_variation( $template_variation ); |
|
2398 | + $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']); |
|
2399 | + if ($mtpg_obj instanceof EE_Message_Template_Group) { |
|
2400 | + $mtpg_obj->set_template_pack_name($template_pack); |
|
2401 | + $mtpg_obj->set_template_pack_variation($template_variation); |
|
2402 | 2402 | } |
2403 | 2403 | $success = 1; |
2404 | 2404 | } |
@@ -2408,7 +2408,7 @@ discard block |
||
2408 | 2408 | } |
2409 | 2409 | |
2410 | 2410 | //we return things differently if doing ajax |
2411 | - if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2411 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2412 | 2412 | $this->_template_args['success'] = $success; |
2413 | 2413 | $this->_template_args['error'] = ! $success ? true : false; |
2414 | 2414 | $this->_template_args['content'] = ''; |
@@ -2416,9 +2416,9 @@ discard block |
||
2416 | 2416 | 'grpID' => $edit_array['GRP_ID'], |
2417 | 2417 | 'templateName' => $edit_array['template_name'] |
2418 | 2418 | ); |
2419 | - if ( $success ) { |
|
2419 | + if ($success) { |
|
2420 | 2420 | EE_Error::overwrite_success(); |
2421 | - EE_Error::add_success( __('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso') ); |
|
2421 | + EE_Error::add_success(__('The new template has been created and automatically selected for this event. You can edit the new template by clicking the edit button. Note before this template is assigned to this event, the event must be saved.', 'event_espresso')); |
|
2422 | 2422 | } |
2423 | 2423 | |
2424 | 2424 | $this->_return_json(); |
@@ -2426,13 +2426,13 @@ discard block |
||
2426 | 2426 | |
2427 | 2427 | |
2428 | 2428 | //was a test send triggered? |
2429 | - if ( isset( $this->_req_data['test_button'] ) ) { |
|
2429 | + if (isset($this->_req_data['test_button'])) { |
|
2430 | 2430 | EE_Error::overwrite_success(); |
2431 | - $this->_do_test_send( $context, $messenger_slug, $message_type_slug ); |
|
2431 | + $this->_do_test_send($context, $messenger_slug, $message_type_slug); |
|
2432 | 2432 | $override = true; |
2433 | 2433 | } |
2434 | 2434 | |
2435 | - if ( empty( $query_args ) ) { |
|
2435 | + if (empty($query_args)) { |
|
2436 | 2436 | $query_args = array( |
2437 | 2437 | 'id' => $this->_req_data['GRP_ID'], |
2438 | 2438 | 'context' => $context_slug, |
@@ -2440,7 +2440,7 @@ discard block |
||
2440 | 2440 | ); |
2441 | 2441 | } |
2442 | 2442 | |
2443 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override ); |
|
2443 | + $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override); |
|
2444 | 2444 | } |
2445 | 2445 | |
2446 | 2446 | |
@@ -2454,28 +2454,28 @@ discard block |
||
2454 | 2454 | * @param string $message_type message type being tested |
2455 | 2455 | * |
2456 | 2456 | */ |
2457 | - protected function _do_test_send( $context, $messenger, $message_type ) { |
|
2457 | + protected function _do_test_send($context, $messenger, $message_type) { |
|
2458 | 2458 | //set things up for preview |
2459 | 2459 | $this->_req_data['messenger'] = $messenger; |
2460 | 2460 | $this->_req_data['message_type'] = $message_type; |
2461 | 2461 | $this->_req_data['context'] = $context; |
2462 | - $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : ''; |
|
2463 | - $active_messenger = $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
2462 | + $this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : ''; |
|
2463 | + $active_messenger = $this->_message_resource_manager->get_active_messenger($messenger); |
|
2464 | 2464 | |
2465 | 2465 | //let's save any existing fields that might be required by the messenger |
2466 | 2466 | if ( |
2467 | - isset( $this->_req_data['test_settings_fld'] ) |
|
2467 | + isset($this->_req_data['test_settings_fld']) |
|
2468 | 2468 | && $active_messenger instanceof EE_messenger |
2469 | 2469 | ) { |
2470 | - $active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] ); |
|
2470 | + $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']); |
|
2471 | 2471 | } |
2472 | 2472 | |
2473 | 2473 | $success = $this->_preview_message(true); |
2474 | 2474 | |
2475 | - if ( $success ) { |
|
2476 | - EE_Error::add_success( __('Test message sent', 'event_espresso') ); |
|
2475 | + if ($success) { |
|
2476 | + EE_Error::add_success(__('Test message sent', 'event_espresso')); |
|
2477 | 2477 | } else { |
2478 | - EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2478 | + EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2479 | 2479 | } |
2480 | 2480 | } |
2481 | 2481 | |
@@ -2501,11 +2501,11 @@ discard block |
||
2501 | 2501 | protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
2502 | 2502 | |
2503 | 2503 | //if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates. |
2504 | - if ( empty( $message_types ) ) { |
|
2504 | + if (empty($message_types)) { |
|
2505 | 2505 | return true; |
2506 | 2506 | } |
2507 | 2507 | |
2508 | - return EEH_MSG_Template::generate_new_templates( $messenger, $message_types, $GRP_ID, $global ); |
|
2508 | + return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global); |
|
2509 | 2509 | } |
2510 | 2510 | |
2511 | 2511 | |
@@ -2521,33 +2521,33 @@ discard block |
||
2521 | 2521 | * |
2522 | 2522 | * @return void |
2523 | 2523 | */ |
2524 | - protected function _trash_or_restore_message_template($trash = true, $all = false ) { |
|
2525 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2524 | + protected function _trash_or_restore_message_template($trash = true, $all = false) { |
|
2525 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2526 | 2526 | $MTP = EEM_Message_Template_Group::instance(); |
2527 | 2527 | |
2528 | 2528 | $success = 1; |
2529 | 2529 | |
2530 | 2530 | //incoming GRP_IDs |
2531 | - if ( $all ) { |
|
2531 | + if ($all) { |
|
2532 | 2532 | //Checkboxes |
2533 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) { |
|
2533 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2534 | 2534 | //if array has more than one element then success message should be plural. |
2535 | 2535 | //todo: what about nonce? |
2536 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2536 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2537 | 2537 | |
2538 | 2538 | //cycle through checkboxes |
2539 | - while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) { |
|
2540 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2541 | - if ( ! $trashed_or_restored ) { |
|
2539 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2540 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2541 | + if ( ! $trashed_or_restored) { |
|
2542 | 2542 | $success = 0; |
2543 | 2543 | } |
2544 | 2544 | } |
2545 | 2545 | } else { |
2546 | 2546 | //grab single GRP_ID and handle |
2547 | - $GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
2548 | - if ( ! empty( $GRP_ID ) ) { |
|
2549 | - $trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID ); |
|
2550 | - if ( ! $trashed_or_restored ) { |
|
2547 | + $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
2548 | + if ( ! empty($GRP_ID)) { |
|
2549 | + $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID); |
|
2550 | + if ( ! $trashed_or_restored) { |
|
2551 | 2551 | $success = 0; |
2552 | 2552 | } |
2553 | 2553 | } else { |
@@ -2559,13 +2559,13 @@ discard block |
||
2559 | 2559 | |
2560 | 2560 | $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
2561 | 2561 | |
2562 | - $action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc; |
|
2562 | + $action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc; |
|
2563 | 2563 | |
2564 | 2564 | $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso'); |
2565 | 2565 | |
2566 | - $item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2566 | + $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc; |
|
2567 | 2567 | |
2568 | - $this->_redirect_after_action( $success, $item_desc, $action_desc, array() ); |
|
2568 | + $this->_redirect_after_action($success, $item_desc, $action_desc, array()); |
|
2569 | 2569 | |
2570 | 2570 | } |
2571 | 2571 | |
@@ -2581,24 +2581,24 @@ discard block |
||
2581 | 2581 | * @return void |
2582 | 2582 | */ |
2583 | 2583 | protected function _delete_message_template() { |
2584 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2584 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2585 | 2585 | |
2586 | 2586 | //checkboxes |
2587 | - if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) { |
|
2587 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2588 | 2588 | //if array has more than one element then success message should be plural |
2589 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2589 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2590 | 2590 | |
2591 | 2591 | //cycle through bulk action checkboxes |
2592 | - while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) { |
|
2593 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2592 | + while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2593 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2594 | 2594 | } |
2595 | 2595 | } else { |
2596 | 2596 | //grab single grp_id and delete |
2597 | - $GRP_ID = absint($this->_req_data['id'] ); |
|
2598 | - $success = $this->_delete_mtp_permanently( $GRP_ID ); |
|
2597 | + $GRP_ID = absint($this->_req_data['id']); |
|
2598 | + $success = $this->_delete_mtp_permanently($GRP_ID); |
|
2599 | 2599 | } |
2600 | 2600 | |
2601 | - $this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() ); |
|
2601 | + $this->_redirect_after_action($success, 'Message Templates', 'deleted', array()); |
|
2602 | 2602 | |
2603 | 2603 | } |
2604 | 2604 | |
@@ -2613,20 +2613,20 @@ discard block |
||
2613 | 2613 | * |
2614 | 2614 | * @return bool boolean to indicate the success of the deletes or not. |
2615 | 2615 | */ |
2616 | - private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) { |
|
2616 | + private function _delete_mtp_permanently($GRP_ID, $include_group = true) { |
|
2617 | 2617 | $success = 1; |
2618 | 2618 | $MTPG = EEM_Message_Template_Group::instance(); |
2619 | 2619 | //first let's GET this group |
2620 | - $MTG = $MTPG->get_one_by_ID( $GRP_ID ); |
|
2620 | + $MTG = $MTPG->get_one_by_ID($GRP_ID); |
|
2621 | 2621 | //then delete permanently all the related Message Templates |
2622 | - $deleted = $MTG->delete_related_permanently( 'Message_Template' ); |
|
2622 | + $deleted = $MTG->delete_related_permanently('Message_Template'); |
|
2623 | 2623 | |
2624 | - if ( $deleted === 0 ) |
|
2625 | - {$success = 0;} |
|
2624 | + if ($deleted === 0) |
|
2625 | + {$success = 0; } |
|
2626 | 2626 | |
2627 | 2627 | //now delete permanently this particular group |
2628 | 2628 | |
2629 | - if ( $include_group && ! $MTG->delete_permanently() ) { |
|
2629 | + if ($include_group && ! $MTG->delete_permanently()) { |
|
2630 | 2630 | $success = 0; |
2631 | 2631 | } |
2632 | 2632 | return $success; |
@@ -2644,7 +2644,7 @@ discard block |
||
2644 | 2644 | * @return string |
2645 | 2645 | */ |
2646 | 2646 | protected function _learn_more_about_message_templates_link() { |
2647 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>'; |
|
2647 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>'; |
|
2648 | 2648 | } |
2649 | 2649 | |
2650 | 2650 | |
@@ -2662,10 +2662,10 @@ discard block |
||
2662 | 2662 | |
2663 | 2663 | $this->_set_m_mt_settings(); |
2664 | 2664 | |
2665 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2665 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2666 | 2666 | |
2667 | 2667 | //let's setup the messenger tabs |
2668 | - $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger ); |
|
2668 | + $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger); |
|
2669 | 2669 | $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">'; |
2670 | 2670 | $this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->'; |
2671 | 2671 | |
@@ -2684,7 +2684,7 @@ discard block |
||
2684 | 2684 | */ |
2685 | 2685 | protected function _set_m_mt_settings() { |
2686 | 2686 | //first if this is already set then lets get out no need to regenerate data. |
2687 | - if ( !empty($this->_m_mt_settings) ) { |
|
2687 | + if ( ! empty($this->_m_mt_settings)) { |
|
2688 | 2688 | return; |
2689 | 2689 | } |
2690 | 2690 | |
@@ -2699,10 +2699,10 @@ discard block |
||
2699 | 2699 | |
2700 | 2700 | //assemble the array for the _tab_text_links helper |
2701 | 2701 | |
2702 | - foreach ( $messengers as $messenger ) { |
|
2702 | + foreach ($messengers as $messenger) { |
|
2703 | 2703 | $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array( |
2704 | 2704 | 'label' => ucwords($messenger->label['singular']), |
2705 | - 'class' => $this->_message_resource_manager->is_messenger_active( $messenger->name ) ? 'messenger-active' : '', |
|
2705 | + 'class' => $this->_message_resource_manager->is_messenger_active($messenger->name) ? 'messenger-active' : '', |
|
2706 | 2706 | 'href' => $messenger->name, |
2707 | 2707 | 'title' => __('Modify this Messenger', 'event_espresso'), |
2708 | 2708 | 'slug' => $messenger->name, |
@@ -2712,26 +2712,26 @@ discard block |
||
2712 | 2712 | |
2713 | 2713 | $message_types_for_messenger = $messenger->get_valid_message_types(); |
2714 | 2714 | |
2715 | - foreach ( $message_types as $message_type ) { |
|
2715 | + foreach ($message_types as $message_type) { |
|
2716 | 2716 | //first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox. |
2717 | - if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) { |
|
2717 | + if ( ! in_array($message_type->name, $message_types_for_messenger)) { |
|
2718 | 2718 | continue; |
2719 | 2719 | } |
2720 | 2720 | |
2721 | - $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) ? 'active' : 'inactive'; |
|
2721 | + $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger($messenger->name, $message_type->name) ? 'active' : 'inactive'; |
|
2722 | 2722 | |
2723 | 2723 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
2724 | - 'label' => ucwords( $message_type->label[ 'singular' ] ), |
|
2725 | - 'class' => 'message-type-' . $a_or_i, |
|
2726 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
2727 | - 'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ), |
|
2728 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
2724 | + 'label' => ucwords($message_type->label['singular']), |
|
2725 | + 'class' => 'message-type-'.$a_or_i, |
|
2726 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
2727 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
2728 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
2729 | 2729 | 'title' => $a_or_i == 'active' |
2730 | - ? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' ) |
|
2731 | - : __( 'Drag this message type to the messenger to activate', 'event_espresso' ), |
|
2730 | + ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
|
2731 | + : __('Drag this message type to the messenger to activate', 'event_espresso'), |
|
2732 | 2732 | 'content' => $a_or_i == 'active' |
2733 | - ? $this->_message_type_settings_content( $message_type, $messenger, true ) |
|
2734 | - : $this->_message_type_settings_content( $message_type, $messenger ), |
|
2733 | + ? $this->_message_type_settings_content($message_type, $messenger, true) |
|
2734 | + : $this->_message_type_settings_content($message_type, $messenger), |
|
2735 | 2735 | 'slug' => $message_type->name, |
2736 | 2736 | 'active' => $a_or_i == 'active' ? true : false, |
2737 | 2737 | 'obj' => $message_type |
@@ -2750,34 +2750,34 @@ discard block |
||
2750 | 2750 | * |
2751 | 2751 | * @return string html output for the content |
2752 | 2752 | */ |
2753 | - protected function _message_type_settings_content( $message_type, $messenger, $active = false ) { |
|
2753 | + protected function _message_type_settings_content($message_type, $messenger, $active = false) { |
|
2754 | 2754 | //get message type fields |
2755 | 2755 | $fields = $message_type->get_admin_settings_fields(); |
2756 | - $settings_template_args['template_form_fields']= ''; |
|
2756 | + $settings_template_args['template_form_fields'] = ''; |
|
2757 | 2757 | |
2758 | - if ( !empty( $fields ) && $active ) { |
|
2758 | + if ( ! empty($fields) && $active) { |
|
2759 | 2759 | |
2760 | - $existing_settings = $message_type->get_existing_admin_settings( $messenger->name ); |
|
2760 | + $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
|
2761 | 2761 | |
2762 | - foreach( $fields as $fldname => $fldprops ) { |
|
2763 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
2762 | + foreach ($fields as $fldname => $fldprops) { |
|
2763 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
2764 | 2764 | $template_form_field[$field_id] = array( |
2765 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
2765 | + 'name' => 'message_type_settings['.$fldname.']', |
|
2766 | 2766 | 'label' => $fldprops['label'], |
2767 | 2767 | 'input' => $fldprops['field_type'], |
2768 | 2768 | 'type' => $fldprops['value_type'], |
2769 | 2769 | 'required' => $fldprops['required'], |
2770 | 2770 | 'validation' => $fldprops['validation'], |
2771 | - 'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2772 | - 'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(), |
|
2773 | - 'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2771 | + 'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2772 | + 'options' => isset($fldprops['options']) ? $fldprops['options'] : array(), |
|
2773 | + 'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'], |
|
2774 | 2774 | 'css_class' => 'no-drag', |
2775 | 2775 | 'format' => $fldprops['format'] |
2776 | 2776 | ); |
2777 | 2777 | } |
2778 | 2778 | |
2779 | 2779 | |
2780 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : ''; |
|
2780 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : ''; |
|
2781 | 2781 | } |
2782 | 2782 | |
2783 | 2783 | $settings_template_args['description'] = $message_type->description; |
@@ -2797,13 +2797,13 @@ discard block |
||
2797 | 2797 | ) |
2798 | 2798 | ); |
2799 | 2799 | |
2800 | - $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' ); |
|
2801 | - $settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : ''; |
|
2800 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array'); |
|
2801 | + $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
|
2802 | 2802 | |
2803 | 2803 | |
2804 | 2804 | |
2805 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
2806 | - $content = EEH_Template::display_template( $template, $settings_template_args, true ); |
|
2805 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
2806 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
2807 | 2807 | return $content; |
2808 | 2808 | } |
2809 | 2809 | |
@@ -2820,27 +2820,27 @@ discard block |
||
2820 | 2820 | $m_boxes = $mt_boxes = array(); |
2821 | 2821 | $m_template_args = $mt_template_args = array(); |
2822 | 2822 | |
2823 | - $selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2823 | + $selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email'; |
|
2824 | 2824 | |
2825 | - if ( isset( $this->_m_mt_settings[ 'messenger_tabs' ] ) ) { |
|
2826 | - foreach ( $this->_m_mt_settings[ 'messenger_tabs' ] as $messenger => $tab_array ) { |
|
2827 | - $hide_on_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? '' : 'hidden'; |
|
2828 | - $hide_off_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? 'hidden' : ''; |
|
2825 | + if (isset($this->_m_mt_settings['messenger_tabs'])) { |
|
2826 | + foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) { |
|
2827 | + $hide_on_message = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden'; |
|
2828 | + $hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : ''; |
|
2829 | 2829 | //messenger meta boxes |
2830 | 2830 | $active = $selected_messenger == $messenger ? true : false; |
2831 | - $active_mt_tabs = isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] ) |
|
2832 | - ? $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] |
|
2831 | + $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) |
|
2832 | + ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] |
|
2833 | 2833 | : ''; |
2834 | - $m_boxes[ $messenger . '_a_box' ] = sprintf( |
|
2835 | - __( '%s Settings', 'event_espresso' ), |
|
2836 | - $tab_array[ 'label' ] |
|
2834 | + $m_boxes[$messenger.'_a_box'] = sprintf( |
|
2835 | + __('%s Settings', 'event_espresso'), |
|
2836 | + $tab_array['label'] |
|
2837 | 2837 | ); |
2838 | - $m_template_args[ $messenger . '_a_box' ] = array( |
|
2839 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2840 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2841 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2838 | + $m_template_args[$messenger.'_a_box'] = array( |
|
2839 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2840 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2841 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2842 | 2842 | : '', |
2843 | - 'content' => $this->_get_messenger_box_content( $tab_array[ 'obj' ] ), |
|
2843 | + 'content' => $this->_get_messenger_box_content($tab_array['obj']), |
|
2844 | 2844 | 'hidden' => $active ? '' : ' hidden', |
2845 | 2845 | 'hide_on_message' => $hide_on_message, |
2846 | 2846 | 'messenger' => $messenger, |
@@ -2849,11 +2849,11 @@ discard block |
||
2849 | 2849 | // message type meta boxes |
2850 | 2850 | // (which is really just the inactive container for each messenger |
2851 | 2851 | // showing inactive message types for that messenger) |
2852 | - $mt_boxes[ $messenger . '_i_box' ] = __( 'Inactive Message Types', 'event_espresso' ); |
|
2853 | - $mt_template_args[ $messenger . '_i_box' ] = array( |
|
2854 | - 'active_message_types' => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '', |
|
2855 | - 'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2856 | - ? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] ) |
|
2852 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
2853 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
2854 | + 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
|
2855 | + 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2856 | + ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
|
2857 | 2857 | : '', |
2858 | 2858 | 'hidden' => $active ? '' : ' hidden', |
2859 | 2859 | 'hide_on_message' => $hide_on_message, |
@@ -2866,15 +2866,15 @@ discard block |
||
2866 | 2866 | |
2867 | 2867 | |
2868 | 2868 | //register messenger metaboxes |
2869 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2870 | - foreach ( $m_boxes as $box => $label ) { |
|
2871 | - $callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] ); |
|
2872 | - $msgr = str_replace( '_a_box', '', $box ); |
|
2869 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
2870 | + foreach ($m_boxes as $box => $label) { |
|
2871 | + $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
|
2872 | + $msgr = str_replace('_a_box', '', $box); |
|
2873 | 2873 | add_meta_box( |
2874 | - 'espresso_' . $msgr . '_settings', |
|
2874 | + 'espresso_'.$msgr.'_settings', |
|
2875 | 2875 | $label, |
2876 | - function( $post, $metabox ) { |
|
2877 | - echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE ); |
|
2876 | + function($post, $metabox) { |
|
2877 | + echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE); |
|
2878 | 2878 | }, |
2879 | 2879 | $this->_current_screen->id, |
2880 | 2880 | 'normal', |
@@ -2884,17 +2884,17 @@ discard block |
||
2884 | 2884 | } |
2885 | 2885 | |
2886 | 2886 | //register message type metaboxes |
2887 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
2888 | - foreach ( $mt_boxes as $box => $label ) { |
|
2887 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
2888 | + foreach ($mt_boxes as $box => $label) { |
|
2889 | 2889 | $callback_args = array( |
2890 | - 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[ $box ] |
|
2890 | + 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] |
|
2891 | 2891 | ); |
2892 | - $mt = str_replace( '_i_box', '', $box ); |
|
2892 | + $mt = str_replace('_i_box', '', $box); |
|
2893 | 2893 | add_meta_box( |
2894 | - 'espresso_' . $mt . '_inactive_mts', |
|
2894 | + 'espresso_'.$mt.'_inactive_mts', |
|
2895 | 2895 | $label, |
2896 | - function( $post, $metabox ) { |
|
2897 | - echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE ); |
|
2896 | + function($post, $metabox) { |
|
2897 | + echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE); |
|
2898 | 2898 | }, |
2899 | 2899 | $this->_current_screen->id, |
2900 | 2900 | 'side', |
@@ -2905,11 +2905,11 @@ discard block |
||
2905 | 2905 | |
2906 | 2906 | //register metabox for global messages settings but only when on the main site. On single site installs this will |
2907 | 2907 | //always result in the metabox showing, on multisite installs the metabox will only show on the main site. |
2908 | - if ( is_main_site() ) { |
|
2908 | + if (is_main_site()) { |
|
2909 | 2909 | add_meta_box( |
2910 | 2910 | 'espresso_global_message_settings', |
2911 | - __( 'Global Message Settings', 'event_espresso' ), |
|
2912 | - array( $this, 'global_messages_settings_metabox_content' ), |
|
2911 | + __('Global Message Settings', 'event_espresso'), |
|
2912 | + array($this, 'global_messages_settings_metabox_content'), |
|
2913 | 2913 | $this->_current_screen->id, |
2914 | 2914 | 'normal', |
2915 | 2915 | 'low', |
@@ -2929,7 +2929,7 @@ discard block |
||
2929 | 2929 | public function global_messages_settings_metabox_content() { |
2930 | 2930 | $form = $this->_generate_global_settings_form(); |
2931 | 2931 | echo $form->form_open( |
2932 | - $this->add_query_args_and_nonce( array( 'action' => 'update_global_settings' ), EE_MSG_ADMIN_URL ), |
|
2932 | + $this->add_query_args_and_nonce(array('action' => 'update_global_settings'), EE_MSG_ADMIN_URL), |
|
2933 | 2933 | 'POST' |
2934 | 2934 | ) |
2935 | 2935 | . $form->get_html() |
@@ -2942,7 +2942,7 @@ discard block |
||
2942 | 2942 | * @return EE_Form_Section_Proper |
2943 | 2943 | */ |
2944 | 2944 | protected function _generate_global_settings_form() { |
2945 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
2945 | + EE_Registry::instance()->load_helper('HTML'); |
|
2946 | 2946 | /** @var EE_Network_Core_Config $network_config */ |
2947 | 2947 | $network_config = EE_Registry::instance()->NET_CFG->core; |
2948 | 2948 | return new EE_Form_Section_Proper( |
@@ -2961,13 +2961,13 @@ discard block |
||
2961 | 2961 | ), |
2962 | 2962 | array( |
2963 | 2963 | 'default' => $network_config->do_messages_on_same_request, |
2964 | - 'html_label_text' => __( 'Generate and send all messages:', 'event_espresso' ), |
|
2965 | - 'html_help_text' => __( 'By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system. This makes things execute faster for people registering for your events. However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.', 'event_espresso' ), |
|
2964 | + 'html_label_text' => __('Generate and send all messages:', 'event_espresso'), |
|
2965 | + 'html_help_text' => __('By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system. This makes things execute faster for people registering for your events. However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.', 'event_espresso'), |
|
2966 | 2966 | ) |
2967 | 2967 | ), |
2968 | 2968 | 'update_settings' => new EE_Submit_Input( |
2969 | 2969 | array( |
2970 | - 'default' => __( 'Update', 'event_espresso' ), |
|
2970 | + 'default' => __('Update', 'event_espresso'), |
|
2971 | 2971 | 'html_label_text' => ' ' |
2972 | 2972 | ) |
2973 | 2973 | ) |
@@ -2986,28 +2986,28 @@ discard block |
||
2986 | 2986 | /** @var EE_Network_Core_Config $network_config */ |
2987 | 2987 | $network_config = EE_Registry::instance()->NET_CFG->core; |
2988 | 2988 | $form = $this->_generate_global_settings_form(); |
2989 | - if ( $form->was_submitted() ) { |
|
2989 | + if ($form->was_submitted()) { |
|
2990 | 2990 | $form->receive_form_submission(); |
2991 | - if ( $form->is_valid() ) { |
|
2991 | + if ($form->is_valid()) { |
|
2992 | 2992 | $valid_data = $form->valid_data(); |
2993 | - foreach( $valid_data as $property => $value ) { |
|
2994 | - $setter = 'set_' . $property; |
|
2995 | - if ( method_exists( $network_config, $setter ) ) { |
|
2996 | - $network_config->{$setter}( $value ); |
|
2993 | + foreach ($valid_data as $property => $value) { |
|
2994 | + $setter = 'set_'.$property; |
|
2995 | + if (method_exists($network_config, $setter)) { |
|
2996 | + $network_config->{$setter}($value); |
|
2997 | 2997 | } else if ( |
2998 | - property_exists( $network_config, $property ) |
|
2998 | + property_exists($network_config, $property) |
|
2999 | 2999 | && $network_config->{$property} !== $value |
3000 | 3000 | ) { |
3001 | 3001 | $network_config->{$property} = $value; |
3002 | 3002 | } |
3003 | 3003 | } |
3004 | 3004 | //only update if the form submission was valid! |
3005 | - EE_Registry::instance()->NET_CFG->update_config( true, false ); |
|
3005 | + EE_Registry::instance()->NET_CFG->update_config(true, false); |
|
3006 | 3006 | EE_Error::overwrite_success(); |
3007 | - EE_Error::add_success( __( 'Global message settings were updated', 'event_espresso' ) ); |
|
3007 | + EE_Error::add_success(__('Global message settings were updated', 'event_espresso')); |
|
3008 | 3008 | } |
3009 | 3009 | } |
3010 | - $this->_redirect_after_action( 0, '', '', array( 'action' => 'settings' ), true ); |
|
3010 | + $this->_redirect_after_action(0, '', '', array('action' => 'settings'), true); |
|
3011 | 3011 | } |
3012 | 3012 | |
3013 | 3013 | |
@@ -3018,13 +3018,13 @@ discard block |
||
3018 | 3018 | * |
3019 | 3019 | * @return string html formatted tabs |
3020 | 3020 | */ |
3021 | - protected function _get_mt_tabs( $tab_array ) { |
|
3021 | + protected function _get_mt_tabs($tab_array) { |
|
3022 | 3022 | $tab_array = (array) $tab_array; |
3023 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
3023 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
3024 | 3024 | $tabs = ''; |
3025 | 3025 | |
3026 | - foreach ( $tab_array as $tab ) { |
|
3027 | - $tabs .= EEH_Template::display_template( $template, $tab, true ); |
|
3026 | + foreach ($tab_array as $tab) { |
|
3027 | + $tabs .= EEH_Template::display_template($template, $tab, true); |
|
3028 | 3028 | } |
3029 | 3029 | |
3030 | 3030 | return $tabs; |
@@ -3040,29 +3040,29 @@ discard block |
||
3040 | 3040 | * |
3041 | 3041 | * @return string html formatted content |
3042 | 3042 | */ |
3043 | - protected function _get_messenger_box_content( EE_messenger $messenger ) { |
|
3043 | + protected function _get_messenger_box_content(EE_messenger $messenger) { |
|
3044 | 3044 | |
3045 | 3045 | $fields = $messenger->get_admin_settings_fields(); |
3046 | 3046 | $settings_template_args['template_form_fields'] = ''; |
3047 | 3047 | |
3048 | 3048 | //is $messenger active? |
3049 | - $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
3049 | + $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
3050 | 3050 | |
3051 | 3051 | |
3052 | - if ( ! empty( $fields ) ) { |
|
3052 | + if ( ! empty($fields)) { |
|
3053 | 3053 | |
3054 | 3054 | $existing_settings = $messenger->get_existing_admin_settings(); |
3055 | 3055 | |
3056 | - foreach( $fields as $fldname => $fldprops ) { |
|
3057 | - $field_id = $messenger->name . '-' . $fldname; |
|
3056 | + foreach ($fields as $fldname => $fldprops) { |
|
3057 | + $field_id = $messenger->name.'-'.$fldname; |
|
3058 | 3058 | $template_form_field[$field_id] = array( |
3059 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
3059 | + 'name' => 'messenger_settings['.$field_id.']', |
|
3060 | 3060 | 'label' => $fldprops['label'], |
3061 | 3061 | 'input' => $fldprops['field_type'], |
3062 | 3062 | 'type' => $fldprops['value_type'], |
3063 | 3063 | 'required' => $fldprops['required'], |
3064 | 3064 | 'validation' => $fldprops['validation'], |
3065 | - 'value' => isset( $existing_settings[$field_id]) |
|
3065 | + 'value' => isset($existing_settings[$field_id]) |
|
3066 | 3066 | ? $existing_settings[$field_id] |
3067 | 3067 | : $fldprops['default'], |
3068 | 3068 | 'css_class' => '', |
@@ -3071,8 +3071,8 @@ discard block |
||
3071 | 3071 | } |
3072 | 3072 | |
3073 | 3073 | |
3074 | - $settings_template_args['template_form_fields'] = !empty($template_form_field) |
|
3075 | - ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) |
|
3074 | + $settings_template_args['template_form_fields'] = ! empty($template_form_field) |
|
3075 | + ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') |
|
3076 | 3076 | : ''; |
3077 | 3077 | } |
3078 | 3078 | |
@@ -3089,39 +3089,39 @@ discard block |
||
3089 | 3089 | ); |
3090 | 3090 | |
3091 | 3091 | //make sure any active message types that are existing are included in the hidden fields |
3092 | - if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) { |
|
3093 | - foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) { |
|
3092 | + if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
|
3093 | + foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
|
3094 | 3094 | $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
3095 | 3095 | 'type' => 'hidden', |
3096 | 3096 | 'value' => $mt |
3097 | 3097 | ); |
3098 | 3098 | } |
3099 | 3099 | } |
3100 | - $settings_template_args[ 'hidden_fields' ] = $this->_generate_admin_form_fields( |
|
3101 | - $settings_template_args[ 'hidden_fields' ], |
|
3100 | + $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( |
|
3101 | + $settings_template_args['hidden_fields'], |
|
3102 | 3102 | 'array' |
3103 | 3103 | ); |
3104 | - $active = $this->_message_resource_manager->is_messenger_active( $messenger->name ); |
|
3104 | + $active = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
3105 | 3105 | |
3106 | 3106 | $settings_template_args['messenger'] = $messenger->name; |
3107 | 3107 | $settings_template_args['description'] = $messenger->description; |
3108 | 3108 | $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden'; |
3109 | 3109 | |
3110 | 3110 | |
3111 | - $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active( $messenger->name ) |
|
3111 | + $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active($messenger->name) |
|
3112 | 3112 | ? $settings_template_args['show_hide_edit_form'] |
3113 | 3113 | : ' hidden'; |
3114 | 3114 | |
3115 | - $settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) |
|
3115 | + $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) |
|
3116 | 3116 | ? ' hidden' |
3117 | 3117 | : $settings_template_args['show_hide_edit_form']; |
3118 | 3118 | |
3119 | 3119 | |
3120 | 3120 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
3121 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
3121 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
3122 | 3122 | $settings_template_args['on_off_status'] = $active ? true : false; |
3123 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
3124 | - $content = EEH_Template::display_template( $template, $settings_template_args, true); |
|
3123 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
3124 | + $content = EEH_Template::display_template($template, $settings_template_args, true); |
|
3125 | 3125 | return $content; |
3126 | 3126 | } |
3127 | 3127 | |
@@ -3135,9 +3135,9 @@ discard block |
||
3135 | 3135 | $success = true; |
3136 | 3136 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
3137 | 3137 | //let's check that we have required data |
3138 | - if ( !isset( $this->_req_data[ 'messenger' ] ) ) { |
|
3138 | + if ( ! isset($this->_req_data['messenger'])) { |
|
3139 | 3139 | EE_Error::add_error( |
3140 | - __( 'Messenger name needed to toggle activation. None given', 'event_espresso' ), |
|
3140 | + __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
|
3141 | 3141 | __FILE__, |
3142 | 3142 | __FUNCTION__, |
3143 | 3143 | __LINE__ |
@@ -3146,14 +3146,14 @@ discard block |
||
3146 | 3146 | } |
3147 | 3147 | |
3148 | 3148 | //do a nonce check here since we're not arriving via a normal route |
3149 | - $nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : ''; |
|
3150 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
3149 | + $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
|
3150 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
3151 | 3151 | |
3152 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
3152 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
3153 | 3153 | |
3154 | 3154 | |
3155 | 3155 | |
3156 | - if ( !isset( $this->_req_data[ 'status' ])) { |
|
3156 | + if ( ! isset($this->_req_data['status'])) { |
|
3157 | 3157 | EE_Error::add_error( |
3158 | 3158 | __( |
3159 | 3159 | 'Messenger status needed to know whether activation or deactivation is happening. No status is given', |
@@ -3169,11 +3169,11 @@ discard block |
||
3169 | 3169 | //do check to verify we have a valid status. |
3170 | 3170 | $status = $this->_req_data['status']; |
3171 | 3171 | |
3172 | - if ( $status != 'off' && $status != 'on' ) { |
|
3172 | + if ($status != 'off' && $status != 'on') { |
|
3173 | 3173 | EE_Error::add_error( |
3174 | 3174 | sprintf( |
3175 | - __( 'The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso' ), |
|
3176 | - $this->_req_data[ 'status' ] |
|
3175 | + __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), |
|
3176 | + $this->_req_data['status'] |
|
3177 | 3177 | ), |
3178 | 3178 | __FILE__, |
3179 | 3179 | __FUNCTION__, |
@@ -3182,11 +3182,11 @@ discard block |
||
3182 | 3182 | $success = false; |
3183 | 3183 | } |
3184 | 3184 | |
3185 | - if ( $success ) { |
|
3185 | + if ($success) { |
|
3186 | 3186 | //made it here? Stop dawdling then!! |
3187 | 3187 | $success = $status == 'off' |
3188 | - ? $this->_deactivate_messenger( $this->_req_data['messenger'] ) |
|
3189 | - : $this->_activate_messenger( $this->_req_data['messenger'] ); |
|
3188 | + ? $this->_deactivate_messenger($this->_req_data['messenger']) |
|
3189 | + : $this->_activate_messenger($this->_req_data['messenger']); |
|
3190 | 3190 | } |
3191 | 3191 | |
3192 | 3192 | $this->_template_args['success'] = $success; |
@@ -3209,7 +3209,7 @@ discard block |
||
3209 | 3209 | $this->_prep_default_response_for_messenger_or_message_type_toggle(); |
3210 | 3210 | |
3211 | 3211 | //let's make sure we have the necessary data |
3212 | - if ( ! isset( $this->_req_data[ 'message_type' ] ) ) { |
|
3212 | + if ( ! isset($this->_req_data['message_type'])) { |
|
3213 | 3213 | EE_Error::add_error( |
3214 | 3214 | __('Message Type name needed to toggle activation. None given', 'event_espresso'), |
3215 | 3215 | __FILE__, __FUNCTION__, __LINE__ |
@@ -3217,7 +3217,7 @@ discard block |
||
3217 | 3217 | $success = false; |
3218 | 3218 | } |
3219 | 3219 | |
3220 | - if ( ! isset( $this->_req_data[ 'messenger' ] ) ) { |
|
3220 | + if ( ! isset($this->_req_data['messenger'])) { |
|
3221 | 3221 | EE_Error::add_error( |
3222 | 3222 | __('Messenger name needed to toggle activation. None given', 'event_espresso'), |
3223 | 3223 | __FILE__, __FUNCTION__, __LINE__ |
@@ -3225,7 +3225,7 @@ discard block |
||
3225 | 3225 | $success = false; |
3226 | 3226 | } |
3227 | 3227 | |
3228 | - if ( ! isset( $this->_req_data[ 'status' ])) { |
|
3228 | + if ( ! isset($this->_req_data['status'])) { |
|
3229 | 3229 | EE_Error::add_error( |
3230 | 3230 | __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), |
3231 | 3231 | __FILE__, __FUNCTION__, __LINE__ |
@@ -3237,7 +3237,7 @@ discard block |
||
3237 | 3237 | //do check to verify we have a valid status. |
3238 | 3238 | $status = $this->_req_data['status']; |
3239 | 3239 | |
3240 | - if ( $status != 'activate' && $status != 'deactivate' ) { |
|
3240 | + if ($status != 'activate' && $status != 'deactivate') { |
|
3241 | 3241 | EE_Error::add_error( |
3242 | 3242 | sprintf( |
3243 | 3243 | __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), |
@@ -3250,16 +3250,16 @@ discard block |
||
3250 | 3250 | |
3251 | 3251 | |
3252 | 3252 | //do a nonce check here since we're not arriving via a normal route |
3253 | - $nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : ''; |
|
3254 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
3253 | + $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
|
3254 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
3255 | 3255 | |
3256 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
3256 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
3257 | 3257 | |
3258 | - if ( $success ) { |
|
3258 | + if ($success) { |
|
3259 | 3259 | //made it here? um, what are you waiting for then? |
3260 | 3260 | $success = $status == 'deactivate' |
3261 | - ? $this->_deactivate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ) |
|
3262 | - : $this->_activate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] ); |
|
3261 | + ? $this->_deactivate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']) |
|
3262 | + : $this->_activate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']); |
|
3263 | 3263 | } |
3264 | 3264 | |
3265 | 3265 | $this->_template_args['success'] = $success; |
@@ -3273,30 +3273,30 @@ discard block |
||
3273 | 3273 | * @param string $messenger_name The name of the messenger being activated |
3274 | 3274 | * @return bool |
3275 | 3275 | */ |
3276 | - protected function _activate_messenger( $messenger_name ) { |
|
3276 | + protected function _activate_messenger($messenger_name) { |
|
3277 | 3277 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3278 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3278 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3279 | 3279 | $message_types_to_activate = $active_messenger instanceof EE_Messenger ? $active_messenger->get_default_message_types() : array(); |
3280 | 3280 | |
3281 | 3281 | //ensure is active |
3282 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_types_to_activate ); |
|
3282 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate); |
|
3283 | 3283 | |
3284 | 3284 | //set response_data for reload |
3285 | - foreach( $message_types_to_activate as $message_type_name ) { |
|
3285 | + foreach ($message_types_to_activate as $message_type_name) { |
|
3286 | 3286 | /** @var EE_message_type $message_type */ |
3287 | - $message_type = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3288 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
3287 | + $message_type = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3288 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
3289 | 3289 | && $message_type instanceof EE_message_type |
3290 | 3290 | ) { |
3291 | 3291 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3292 | - if ( $message_type->get_admin_settings_fields() ) { |
|
3292 | + if ($message_type->get_admin_settings_fields()) { |
|
3293 | 3293 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3294 | 3294 | } |
3295 | 3295 | } |
3296 | 3296 | } |
3297 | 3297 | |
3298 | 3298 | //add success message for activating messenger |
3299 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger ); |
|
3299 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger); |
|
3300 | 3300 | |
3301 | 3301 | } |
3302 | 3302 | |
@@ -3307,11 +3307,11 @@ discard block |
||
3307 | 3307 | * @param string $messenger_name The name of the messenger being activated |
3308 | 3308 | * @return bool |
3309 | 3309 | */ |
3310 | - protected function _deactivate_messenger( $messenger_name ) { |
|
3310 | + protected function _deactivate_messenger($messenger_name) { |
|
3311 | 3311 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3312 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3313 | - $this->_message_resource_manager->deactivate_messenger( $messenger_name ); |
|
3314 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger ); |
|
3312 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3313 | + $this->_message_resource_manager->deactivate_messenger($messenger_name); |
|
3314 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger); |
|
3315 | 3315 | } |
3316 | 3316 | |
3317 | 3317 | |
@@ -3322,23 +3322,23 @@ discard block |
||
3322 | 3322 | * @param string $message_type_name The name of the message type being activated for the messenger |
3323 | 3323 | * @return bool |
3324 | 3324 | */ |
3325 | - protected function _activate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3325 | + protected function _activate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3326 | 3326 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3327 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3327 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3328 | 3328 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3329 | - $message_type_to_activate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3329 | + $message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3330 | 3330 | |
3331 | 3331 | //ensure is active |
3332 | - $this->_message_resource_manager->activate_messenger( $messenger_name, $message_type_name ); |
|
3332 | + $this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name); |
|
3333 | 3333 | |
3334 | 3334 | //set response for load |
3335 | - if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
3335 | + if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
3336 | 3336 | $this->_template_args['data']['active_mts'][] = $message_type_name; |
3337 | - if ( $message_type_to_activate->get_admin_settings_fields() ) { |
|
3337 | + if ($message_type_to_activate->get_admin_settings_fields()) { |
|
3338 | 3338 | $this->_template_args['data']['mt_reload'][] = $message_type_name; |
3339 | 3339 | } |
3340 | 3340 | } |
3341 | - return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger, $message_type_to_activate ); |
|
3341 | + return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger, $message_type_to_activate); |
|
3342 | 3342 | } |
3343 | 3343 | |
3344 | 3344 | |
@@ -3350,13 +3350,13 @@ discard block |
||
3350 | 3350 | * @param string $message_type_name The name of the message type being deactivated for the messenger |
3351 | 3351 | * @return bool |
3352 | 3352 | */ |
3353 | - protected function _deactivate_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
3353 | + protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name) { |
|
3354 | 3354 | /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't*/ |
3355 | - $active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name ); |
|
3355 | + $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name); |
|
3356 | 3356 | /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/ |
3357 | - $message_type_to_deactivate = $this->_message_resource_manager->get_message_type( $message_type_name ); |
|
3358 | - $this->_message_resource_manager->deactivate_message_type_for_messenger( $message_type_name, $messenger_name ); |
|
3359 | - return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger, $message_type_to_deactivate ); |
|
3357 | + $message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name); |
|
3358 | + $this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name); |
|
3359 | + return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger, $message_type_to_deactivate); |
|
3360 | 3360 | } |
3361 | 3361 | |
3362 | 3362 | |
@@ -3387,9 +3387,9 @@ discard block |
||
3387 | 3387 | EE_Message_Type $message_type = null |
3388 | 3388 | ) { |
3389 | 3389 | //if $messenger isn't a valid messenger object then get out. |
3390 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3390 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3391 | 3391 | EE_Error::add_error( |
3392 | - __( 'The messenger being activated is not a valid messenger', 'event_espresso' ), |
|
3392 | + __('The messenger being activated is not a valid messenger', 'event_espresso'), |
|
3393 | 3393 | __FILE__, |
3394 | 3394 | __FUNCTION__, |
3395 | 3395 | __LINE__ |
@@ -3397,32 +3397,32 @@ discard block |
||
3397 | 3397 | return false; |
3398 | 3398 | } |
3399 | 3399 | //activated |
3400 | - if ( $this->_template_args['data']['active_mts'] ) { |
|
3400 | + if ($this->_template_args['data']['active_mts']) { |
|
3401 | 3401 | EE_Error::overwrite_success(); |
3402 | 3402 | //activated a message type with the messenger |
3403 | - if ( $message_type instanceof EE_message_type ) { |
|
3403 | + if ($message_type instanceof EE_message_type) { |
|
3404 | 3404 | EE_Error::add_success( |
3405 | 3405 | sprintf( |
3406 | 3406 | __('%s message type has been successfully activated with the %s messenger', 'event_espresso'), |
3407 | - ucwords( $message_type->label['singular'] ), |
|
3408 | - ucwords( $messenger->label['singular'] ) |
|
3407 | + ucwords($message_type->label['singular']), |
|
3408 | + ucwords($messenger->label['singular']) |
|
3409 | 3409 | ) |
3410 | 3410 | ); |
3411 | 3411 | |
3412 | 3412 | //if message type was invoice then let's make sure we activate the invoice payment method. |
3413 | - if ( $message_type->name == 'invoice' ) { |
|
3414 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3415 | - $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
3416 | - if ( $pm instanceof EE_Payment_Method ) { |
|
3417 | - EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) ); |
|
3413 | + if ($message_type->name == 'invoice') { |
|
3414 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3415 | + $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
3416 | + if ($pm instanceof EE_Payment_Method) { |
|
3417 | + EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method. If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso')); |
|
3418 | 3418 | } |
3419 | 3419 | } |
3420 | 3420 | //just toggles the entire messenger |
3421 | 3421 | } else { |
3422 | 3422 | EE_Error::add_success( |
3423 | 3423 | sprintf( |
3424 | - __( '%s messenger has been successfully activated', 'event_espresso' ), |
|
3425 | - ucwords( $messenger->label[ 'singular' ] ) |
|
3424 | + __('%s messenger has been successfully activated', 'event_espresso'), |
|
3425 | + ucwords($messenger->label['singular']) |
|
3426 | 3426 | ) |
3427 | 3427 | ); |
3428 | 3428 | } |
@@ -3432,12 +3432,12 @@ discard block |
||
3432 | 3432 | //message types after the activation process. However its possible some messengers don't HAVE any default_message_types |
3433 | 3433 | //in which case we just give a success message for the messenger being successfully activated. |
3434 | 3434 | } else { |
3435 | - if ( ! $messenger->get_default_message_types() ) { |
|
3435 | + if ( ! $messenger->get_default_message_types()) { |
|
3436 | 3436 | //messenger doesn't have any default message types so still a success. |
3437 | 3437 | EE_Error::add_success( |
3438 | 3438 | sprintf( |
3439 | - __('%s messenger was successfully activated.', 'event_espresso' ), |
|
3440 | - ucwords( $messenger->label['singular'] ) |
|
3439 | + __('%s messenger was successfully activated.', 'event_espresso'), |
|
3440 | + ucwords($messenger->label['singular']) |
|
3441 | 3441 | ) |
3442 | 3442 | ); |
3443 | 3443 | return true; |
@@ -3445,13 +3445,13 @@ discard block |
||
3445 | 3445 | EE_Error::add_error( |
3446 | 3446 | $message_type instanceof EE_message_type |
3447 | 3447 | ? sprintf( |
3448 | - __( '%s message type was not successfully activated with the %s messenger', 'event_espresso' ), |
|
3449 | - ucwords( $message_type->label['singular'] ), |
|
3450 | - ucwords( $messenger->label['singular'] ) |
|
3448 | + __('%s message type was not successfully activated with the %s messenger', 'event_espresso'), |
|
3449 | + ucwords($message_type->label['singular']), |
|
3450 | + ucwords($messenger->label['singular']) |
|
3451 | 3451 | ) |
3452 | 3452 | : sprintf( |
3453 | - __( '%s messenger was not successfully activated', 'event_espresso' ), |
|
3454 | - ucwords( $messenger->label['singular'] ) |
|
3453 | + __('%s messenger was not successfully activated', 'event_espresso'), |
|
3454 | + ucwords($messenger->label['singular']) |
|
3455 | 3455 | ), |
3456 | 3456 | __FILE__, |
3457 | 3457 | __FUNCTION__, |
@@ -3479,9 +3479,9 @@ discard block |
||
3479 | 3479 | EE_Error::overwrite_success(); |
3480 | 3480 | |
3481 | 3481 | //if $messenger isn't a valid messenger object then get out. |
3482 | - if ( ! $messenger instanceof EE_Messenger ) { |
|
3482 | + if ( ! $messenger instanceof EE_Messenger) { |
|
3483 | 3483 | EE_Error::add_error( |
3484 | - __( 'The messenger being deactivated is not a valid messenger', 'event_espresso' ), |
|
3484 | + __('The messenger being deactivated is not a valid messenger', 'event_espresso'), |
|
3485 | 3485 | __FILE__, |
3486 | 3486 | __FUNCTION__, |
3487 | 3487 | __LINE__ |
@@ -3489,13 +3489,13 @@ discard block |
||
3489 | 3489 | return false; |
3490 | 3490 | } |
3491 | 3491 | |
3492 | - if ( $message_type instanceof EE_message_type ) { |
|
3492 | + if ($message_type instanceof EE_message_type) { |
|
3493 | 3493 | $message_type_name = $message_type->name; |
3494 | 3494 | EE_Error::add_success( |
3495 | 3495 | sprintf( |
3496 | 3496 | __('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'), |
3497 | - ucwords( $message_type->label['singular'] ), |
|
3498 | - ucwords ( $messenger->label['singular'] ) |
|
3497 | + ucwords($message_type->label['singular']), |
|
3498 | + ucwords($messenger->label['singular']) |
|
3499 | 3499 | ) |
3500 | 3500 | ); |
3501 | 3501 | } else { |
@@ -3503,20 +3503,20 @@ discard block |
||
3503 | 3503 | EE_Error::add_success( |
3504 | 3504 | sprintf( |
3505 | 3505 | __('%s messenger has been successfully deactivated.', 'event_espresso'), |
3506 | - ucwords( $messenger->label['singular'] ) |
|
3506 | + ucwords($messenger->label['singular']) |
|
3507 | 3507 | ) |
3508 | 3508 | ); |
3509 | 3509 | } |
3510 | 3510 | |
3511 | 3511 | //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method. |
3512 | - if ( $messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3513 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
3514 | - $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' ); |
|
3515 | - if ( $count_updated > 0 ) { |
|
3512 | + if ($messenger->name == 'html' || $message_type_name == 'invoice') { |
|
3513 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
3514 | + $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice'); |
|
3515 | + if ($count_updated > 0) { |
|
3516 | 3516 | $msg = $message_type_name == 'invoice' |
3517 | - ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ) |
|
3518 | - : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ); |
|
3519 | - EE_Error::add_attention( $msg ); |
|
3517 | + ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso') |
|
3518 | + : __('Deactivating the html messenger also automatically deactivates the invoice payment method. In order for invoices to be generated the html messenger must be be active. If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso'); |
|
3519 | + EE_Error::add_attention($msg); |
|
3520 | 3520 | } |
3521 | 3521 | } |
3522 | 3522 | return true; |
@@ -3527,17 +3527,17 @@ discard block |
||
3527 | 3527 | * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax) |
3528 | 3528 | */ |
3529 | 3529 | public function update_mt_form() { |
3530 | - if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) { |
|
3531 | - EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3530 | + if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) { |
|
3531 | + EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__); |
|
3532 | 3532 | $this->_return_json(); |
3533 | 3533 | } |
3534 | 3534 | |
3535 | 3535 | $message_types = $this->get_installed_message_types(); |
3536 | 3536 | |
3537 | - $message_type = $message_types[ $this->_req_data['message_type'] ]; |
|
3538 | - $messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] ); |
|
3537 | + $message_type = $message_types[$this->_req_data['message_type']]; |
|
3538 | + $messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
|
3539 | 3539 | |
3540 | - $content = $this->_message_type_settings_content ( $message_type, $messenger, true ); |
|
3540 | + $content = $this->_message_type_settings_content($message_type, $messenger, true); |
|
3541 | 3541 | $this->_template_args['success'] = true; |
3542 | 3542 | $this->_template_args['content'] = $content; |
3543 | 3543 | $this->_return_json(); |
@@ -3551,45 +3551,45 @@ discard block |
||
3551 | 3551 | * |
3552 | 3552 | */ |
3553 | 3553 | public function save_settings() { |
3554 | - if ( !isset( $this->_req_data['type'] ) ) { |
|
3555 | - EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3554 | + if ( ! isset($this->_req_data['type'])) { |
|
3555 | + EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3556 | 3556 | $this->_template_args['error'] = true; |
3557 | 3557 | $this->_return_json(); |
3558 | 3558 | } |
3559 | 3559 | |
3560 | 3560 | |
3561 | - if ( $this->_req_data['type'] == 'messenger' ) { |
|
3561 | + if ($this->_req_data['type'] == 'messenger') { |
|
3562 | 3562 | $settings = $this->_req_data['messenger_settings']; //this should be an array. |
3563 | 3563 | $messenger = $settings['messenger']; |
3564 | 3564 | //let's setup the settings data |
3565 | - foreach ( $settings as $key => $value ) { |
|
3566 | - switch ( $key ) { |
|
3565 | + foreach ($settings as $key => $value) { |
|
3566 | + switch ($key) { |
|
3567 | 3567 | case 'messenger' : |
3568 | - unset( $settings['messenger'] ); |
|
3568 | + unset($settings['messenger']); |
|
3569 | 3569 | break; |
3570 | 3570 | case 'message_types' : |
3571 | - unset( $settings['message_types'] ); |
|
3571 | + unset($settings['message_types']); |
|
3572 | 3572 | break; |
3573 | 3573 | default : |
3574 | 3574 | $settings[$key] = $value; |
3575 | 3575 | break; |
3576 | 3576 | } |
3577 | 3577 | } |
3578 | - $this->_message_resource_manager->add_settings_for_messenger( $messenger, $settings ); |
|
3578 | + $this->_message_resource_manager->add_settings_for_messenger($messenger, $settings); |
|
3579 | 3579 | } |
3580 | 3580 | |
3581 | - else if ( $this->_req_data['type'] == 'message_type' ) { |
|
3581 | + else if ($this->_req_data['type'] == 'message_type') { |
|
3582 | 3582 | $settings = $this->_req_data['message_type_settings']; |
3583 | 3583 | $messenger = $settings['messenger']; |
3584 | 3584 | $message_type = $settings['message_type']; |
3585 | 3585 | |
3586 | - foreach ( $settings as $key => $value ) { |
|
3587 | - switch ( $key ) { |
|
3586 | + foreach ($settings as $key => $value) { |
|
3587 | + switch ($key) { |
|
3588 | 3588 | case 'messenger' : |
3589 | - unset( $settings['messenger'] ); |
|
3589 | + unset($settings['messenger']); |
|
3590 | 3590 | break; |
3591 | 3591 | case 'message_type' : |
3592 | - unset( $settings['message_type'] ); |
|
3592 | + unset($settings['message_type']); |
|
3593 | 3593 | break; |
3594 | 3594 | default : |
3595 | 3595 | $settings[$key] = $value; |
@@ -3597,16 +3597,16 @@ discard block |
||
3597 | 3597 | } |
3598 | 3598 | } |
3599 | 3599 | |
3600 | - $this->_message_resource_manager->add_settings_for_message_type( $messenger, $message_type, $settings ); |
|
3600 | + $this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings); |
|
3601 | 3601 | } |
3602 | 3602 | |
3603 | 3603 | //okay we should have the data all setup. Now we just update! |
3604 | 3604 | $success = $this->_message_resource_manager->update_active_messengers_option(); |
3605 | 3605 | |
3606 | - if ( $success ) { |
|
3607 | - EE_Error::add_success( __('Settings updated', 'event_espresso') ); |
|
3606 | + if ($success) { |
|
3607 | + EE_Error::add_success(__('Settings updated', 'event_espresso')); |
|
3608 | 3608 | } else { |
3609 | - EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
3609 | + EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
3610 | 3610 | } |
3611 | 3611 | |
3612 | 3612 | $this->_template_args['success'] = $success; |
@@ -3628,8 +3628,8 @@ discard block |
||
3628 | 3628 | */ |
3629 | 3629 | protected function _generate_now() { |
3630 | 3630 | $msg_ids = $this->_get_msg_ids_from_request(); |
3631 | - EED_Messages::generate_now( $msg_ids ); |
|
3632 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3631 | + EED_Messages::generate_now($msg_ids); |
|
3632 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3633 | 3633 | } |
3634 | 3634 | |
3635 | 3635 | |
@@ -3644,7 +3644,7 @@ discard block |
||
3644 | 3644 | protected function _generate_and_send_now() { |
3645 | 3645 | $this->_generate_now(); |
3646 | 3646 | $this->_send_now(); |
3647 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3647 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3648 | 3648 | } |
3649 | 3649 | |
3650 | 3650 | |
@@ -3658,8 +3658,8 @@ discard block |
||
3658 | 3658 | */ |
3659 | 3659 | protected function _queue_for_resending() { |
3660 | 3660 | $msg_ids = $this->_get_msg_ids_from_request(); |
3661 | - EED_Messages::queue_for_resending( $msg_ids ); |
|
3662 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3661 | + EED_Messages::queue_for_resending($msg_ids); |
|
3662 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3663 | 3663 | } |
3664 | 3664 | |
3665 | 3665 | |
@@ -3672,8 +3672,8 @@ discard block |
||
3672 | 3672 | */ |
3673 | 3673 | protected function _send_now() { |
3674 | 3674 | $msg_ids = $this->_get_msg_ids_from_request(); |
3675 | - EED_Messages::send_now( $msg_ids ); |
|
3676 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3675 | + EED_Messages::send_now($msg_ids); |
|
3676 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3677 | 3677 | } |
3678 | 3678 | |
3679 | 3679 | |
@@ -3687,23 +3687,23 @@ discard block |
||
3687 | 3687 | protected function _delete_ee_messages() { |
3688 | 3688 | $msg_ids = $this->_get_msg_ids_from_request(); |
3689 | 3689 | $deleted_count = 0; |
3690 | - foreach ( $msg_ids as $msg_id ) { |
|
3691 | - if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) { |
|
3690 | + foreach ($msg_ids as $msg_id) { |
|
3691 | + if (EEM_Message::instance()->delete_by_ID($msg_id)) { |
|
3692 | 3692 | $deleted_count++; |
3693 | 3693 | } |
3694 | 3694 | } |
3695 | - if ( $deleted_count ) { |
|
3695 | + if ($deleted_count) { |
|
3696 | 3696 | $this->_redirect_after_action( |
3697 | 3697 | true, |
3698 | - _n( 'message', 'messages', $deleted_count, 'event_espresso' ), |
|
3698 | + _n('message', 'messages', $deleted_count, 'event_espresso'), |
|
3699 | 3699 | __('deleted', 'event_espresso') |
3700 | 3700 | ); |
3701 | 3701 | } else { |
3702 | 3702 | EE_Error::add_error( |
3703 | - _n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ), |
|
3703 | + _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'), |
|
3704 | 3704 | __FILE__, __FUNCTION__, __LINE__ |
3705 | 3705 | ); |
3706 | - $this->_redirect_after_action( false, '', '', array(), true ); |
|
3706 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
3707 | 3707 | } |
3708 | 3708 | } |
3709 | 3709 | |
@@ -3716,10 +3716,10 @@ discard block |
||
3716 | 3716 | * @return array |
3717 | 3717 | */ |
3718 | 3718 | protected function _get_msg_ids_from_request() { |
3719 | - if ( ! isset( $this->_req_data['MSG_ID'] ) ) { |
|
3719 | + if ( ! isset($this->_req_data['MSG_ID'])) { |
|
3720 | 3720 | return array(); |
3721 | 3721 | } |
3722 | - return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] ); |
|
3722 | + return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']); |
|
3723 | 3723 | } |
3724 | 3724 | |
3725 | 3725 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | class Support_Admin_Page extends EE_Admin_Page { |
31 | 31 | |
32 | 32 | |
33 | - public function __construct( $routing = TRUE ) { |
|
34 | - parent::__construct( $routing ); |
|
33 | + public function __construct($routing = TRUE) { |
|
34 | + parent::__construct($routing); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'nav' => array( |
85 | 85 | 'label' => __('Support', 'event_espresso'), |
86 | 86 | 'order' => 30), |
87 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_support_boxes' ) ), |
|
87 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')), |
|
88 | 88 | 'require_nonce' => FALSE |
89 | 89 | ), |
90 | 90 | 'developers' => array( |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | 'nav' => array( |
99 | 99 | 'label' => __('Shortcodes', 'event_espresso'), |
100 | 100 | 'order' => 60), |
101 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_shortcodes_boxes' ) ), |
|
101 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')), |
|
102 | 102 | 'require_nonce' => FALSE |
103 | 103 | ), |
104 | 104 | ); |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | |
120 | 120 | |
121 | 121 | protected function _installation() { |
122 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
123 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE); |
|
122 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php'; |
|
123 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE); |
|
124 | 124 | $this->display_admin_page_with_sidebar(); |
125 | 125 | } |
126 | 126 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | 'other_resources' => __('Other Resources', 'event_espresso') |
146 | 146 | ); |
147 | 147 | |
148 | - foreach ( $boxes as $box => $label ) { |
|
149 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
148 | + foreach ($boxes as $box => $label) { |
|
149 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
150 | 150 | $callback_args = array('template_path' => $template_path); |
151 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
151 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | 'shortcodes_event_listings' => __('Event Listings', 'event_espresso'), |
170 | 170 | 'shortcodes_ticket_selector' => __('Event Ticket Selector', 'event_espresso'), |
171 | 171 | 'shortcodes_category' => __('Event Categories', 'event_espresso'), |
172 | - 'shortcodes_attendee' => __( 'Event Attendees', 'event_espresso' ) |
|
172 | + 'shortcodes_attendee' => __('Event Attendees', 'event_espresso') |
|
173 | 173 | /*'shortcodes_single_events' => __('Single Events', 'event_espresso'),*/ |
174 | 174 | /*'shortcodes_attendee_listings' => __('Attendee Listings', 'event_espresso'),*/ |
175 | 175 | ); |
176 | 176 | |
177 | - foreach ( $boxes as $box => $label ) { |
|
178 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
177 | + foreach ($boxes as $box => $label) { |
|
178 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
179 | 179 | $callback_args = array('template_path' => $template_path); |
180 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
180 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -196,17 +196,17 @@ discard block |
||
196 | 196 | 'important_information' => __('Important Information', 'event_espresso') |
197 | 197 | ); |
198 | 198 | |
199 | - foreach ( $boxes as $box => $label ) { |
|
200 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php'; |
|
199 | + foreach ($boxes as $box => $label) { |
|
200 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php'; |
|
201 | 201 | $callback_args = array('template_path' => $template_path, 'template_args' => $this->_template_args); |
202 | - add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
202 | + add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | 206 | |
207 | 207 | protected function _developers() { |
208 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php'; |
|
209 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true ); |
|
208 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php'; |
|
209 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true); |
|
210 | 210 | $this->display_admin_page_with_sidebar(); |
211 | 211 | } |
212 | 212 | } //end Support_Admin_Page class |
@@ -274,26 +274,26 @@ discard block |
||
274 | 274 | if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
275 | 275 | return $payment; |
276 | 276 | } |
277 | - // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction, |
|
278 | - // registrations, ticket counts, etc) |
|
279 | - if ( |
|
280 | - ( |
|
281 | - $update_info[ 'payment_status' ] === 'Refunded' |
|
282 | - || $update_info[ 'payment_status' ] === 'Partially_Refunded' |
|
283 | - ) |
|
284 | - && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) |
|
285 | - ) { |
|
286 | - throw new EventEspresso\core\exceptions\IpnException( |
|
287 | - sprintf( |
|
288 | - esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'), |
|
289 | - $update_info['payment_status'] |
|
290 | - ), |
|
291 | - EventEspresso\core\exceptions\IpnException::UNSUPPORTED, |
|
292 | - null, |
|
293 | - $payment, |
|
294 | - $update_info |
|
295 | - ); |
|
296 | - } |
|
277 | + // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction, |
|
278 | + // registrations, ticket counts, etc) |
|
279 | + if ( |
|
280 | + ( |
|
281 | + $update_info[ 'payment_status' ] === 'Refunded' |
|
282 | + || $update_info[ 'payment_status' ] === 'Partially_Refunded' |
|
283 | + ) |
|
284 | + && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) |
|
285 | + ) { |
|
286 | + throw new EventEspresso\core\exceptions\IpnException( |
|
287 | + sprintf( |
|
288 | + esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'), |
|
289 | + $update_info['payment_status'] |
|
290 | + ), |
|
291 | + EventEspresso\core\exceptions\IpnException::UNSUPPORTED, |
|
292 | + null, |
|
293 | + $payment, |
|
294 | + $update_info |
|
295 | + ); |
|
296 | + } |
|
297 | 297 | //ok, well let's process this payment then! |
298 | 298 | switch ( $update_info[ 'payment_status' ] ) { |
299 | 299 | |
@@ -541,17 +541,17 @@ discard block |
||
541 | 541 | |
542 | 542 | //might paypal have changed the taxes? |
543 | 543 | if( $this->_paypal_taxes && $payment_was_itemized ) { |
544 | - // note that we're doing this BEFORE adding shipping; |
|
544 | + // note that we're doing this BEFORE adding shipping; |
|
545 | 545 | // we actually want PayPal's shipping to remain non-taxable |
546 | - $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' ); |
|
547 | - $this->_line_item->set_total_tax_to( |
|
548 | - $transaction_total_line_item, |
|
549 | - (float)$update_info['tax'], |
|
550 | - esc_html__( 'Taxes', 'event_espresso' ), |
|
551 | - esc_html__( 'Calculated by Paypal', 'event_espresso' ), |
|
552 | - 'paypal_tax' |
|
553 | - ); |
|
554 | - $grand_total_needs_resaving = TRUE; |
|
546 | + $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' ); |
|
547 | + $this->_line_item->set_total_tax_to( |
|
548 | + $transaction_total_line_item, |
|
549 | + (float)$update_info['tax'], |
|
550 | + esc_html__( 'Taxes', 'event_espresso' ), |
|
551 | + esc_html__( 'Calculated by Paypal', 'event_espresso' ), |
|
552 | + 'paypal_tax' |
|
553 | + ); |
|
554 | + $grand_total_needs_resaving = TRUE; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | $shipping_amount = (float)$update_info[ 'mc_shipping' ]; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return EEG_Paypal_Standard |
71 | 71 | */ |
72 | 72 | public function __construct() { |
73 | - $this->set_uses_separate_IPN_request( true ) ; |
|
73 | + $this->set_uses_separate_IPN_request(true); |
|
74 | 74 | parent::__construct(); |
75 | 75 | } |
76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * Also sets the gateway url class variable based on whether debug mode is enabled or not |
81 | 81 | * @param array $settings_array |
82 | 82 | */ |
83 | - public function set_settings($settings_array){ |
|
83 | + public function set_settings($settings_array) { |
|
84 | 84 | parent::set_settings($settings_array); |
85 | 85 | $this->_gateway_url = $this->_debug_mode |
86 | 86 | ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' |
@@ -114,42 +114,42 @@ discard block |
||
114 | 114 | |
115 | 115 | $total_discounts_to_cart_total = $transaction->paid(); |
116 | 116 | //only itemize the order if we're paying for the rest of the order's amount |
117 | - if( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
118 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true ); |
|
117 | + if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
118 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true); |
|
119 | 119 | //this payment is for the remaining transaction amount, |
120 | 120 | //keep track of exactly how much the itemized order amount equals |
121 | 121 | $itemized_sum = 0; |
122 | 122 | $shipping_previously_added = 0; |
123 | 123 | //so let's show all the line items |
124 | - foreach($total_line_item->get_items() as $line_item){ |
|
125 | - if ( $line_item instanceof EE_Line_Item ) { |
|
124 | + foreach ($total_line_item->get_items() as $line_item) { |
|
125 | + if ($line_item instanceof EE_Line_Item) { |
|
126 | 126 | //it's some kind of discount |
127 | - if( $line_item->total() < 0 ) { |
|
128 | - $total_discounts_to_cart_total += abs( $line_item->total() ); |
|
127 | + if ($line_item->total() < 0) { |
|
128 | + $total_discounts_to_cart_total += abs($line_item->total()); |
|
129 | 129 | $itemized_sum += $line_item->total(); |
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | //dont include shipping again. |
133 | - if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) { |
|
133 | + if (strpos($line_item->code(), 'paypal_shipping_') === 0) { |
|
134 | 134 | $shipping_previously_added = $line_item->total(); |
135 | 135 | continue; |
136 | 136 | } |
137 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
138 | - $this->_format_line_item_name( $line_item, $payment ), |
|
137 | + $redirect_args['item_name_'.$item_num] = substr( |
|
138 | + $this->_format_line_item_name($line_item, $payment), |
|
139 | 139 | 0, 127 |
140 | 140 | ); |
141 | - $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price(); |
|
142 | - $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity(); |
|
141 | + $redirect_args['amount_'.$item_num] = $line_item->unit_price(); |
|
142 | + $redirect_args['quantity_'.$item_num] = $line_item->quantity(); |
|
143 | 143 | //if we're not letting PayPal calculate shipping, tell them its 0 |
144 | - if ( ! $this->_paypal_shipping ) { |
|
145 | - $redirect_args[ 'shipping_' . $item_num ] = '0'; |
|
146 | - $redirect_args[ 'shipping2_' . $item_num ] = '0'; |
|
144 | + if ( ! $this->_paypal_shipping) { |
|
145 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
146 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
147 | 147 | } |
148 | 148 | $item_num++; |
149 | 149 | $itemized_sum += $line_item->total(); |
150 | 150 | } |
151 | 151 | } |
152 | - $taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item ); |
|
152 | + $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item); |
|
153 | 153 | //ideally itemized sum equals the transaction total. but if not (which is weird) |
154 | 154 | //and the itemized sum is LESS than the transaction total |
155 | 155 | //add another line item |
@@ -159,47 +159,47 @@ discard block |
||
159 | 159 | $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added, |
160 | 160 | 2 |
161 | 161 | ); |
162 | - if( $itemized_sum_diff_from_txn_total < 0 ) { |
|
162 | + if ($itemized_sum_diff_from_txn_total < 0) { |
|
163 | 163 | //itemized sum is too big |
164 | - $total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total ); |
|
165 | - } elseif( $itemized_sum_diff_from_txn_total > 0 ) { |
|
166 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
167 | - __( 'Other charges', 'event_espresso' ), 0, 127 ); |
|
168 | - $redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
169 | - $redirect_args[ 'quantity_' . $item_num ] = 1; |
|
164 | + $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total); |
|
165 | + } elseif ($itemized_sum_diff_from_txn_total > 0) { |
|
166 | + $redirect_args['item_name_'.$item_num] = substr( |
|
167 | + __('Other charges', 'event_espresso'), 0, 127 ); |
|
168 | + $redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
169 | + $redirect_args['quantity_'.$item_num] = 1; |
|
170 | 170 | $item_num++; |
171 | 171 | } |
172 | - if( $total_discounts_to_cart_total > 0 ) { |
|
173 | - $redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total ); |
|
172 | + if ($total_discounts_to_cart_total > 0) { |
|
173 | + $redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total); |
|
174 | 174 | } |
175 | 175 | //add our taxes to the order if we're NOT using PayPal's |
176 | - if( ! $this->_paypal_taxes ){ |
|
176 | + if ( ! $this->_paypal_taxes) { |
|
177 | 177 | $redirect_args['tax_cart'] = $total_line_item->get_total_tax(); |
178 | 178 | } |
179 | 179 | } else { |
180 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false ); |
|
180 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false); |
|
181 | 181 | //partial payment that's not for the remaining amount, so we can't send an itemized list |
182 | - $redirect_args['item_name_' . $item_num] = substr( |
|
183 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
182 | + $redirect_args['item_name_'.$item_num] = substr( |
|
183 | + $this->_format_partial_payment_line_item_name($payment), |
|
184 | 184 | 0, 127 |
185 | 185 | ); |
186 | - $redirect_args['amount_' . $item_num] = $payment->amount(); |
|
187 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
188 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
186 | + $redirect_args['amount_'.$item_num] = $payment->amount(); |
|
187 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
188 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
189 | 189 | $redirect_args['tax_cart'] = '0'; |
190 | 190 | $item_num++; |
191 | 191 | } |
192 | 192 | |
193 | - if($this->_debug_mode){ |
|
194 | - $redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
195 | - $redirect_args['amount_' . $item_num] = 0; |
|
193 | + if ($this->_debug_mode) { |
|
194 | + $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
195 | + $redirect_args['amount_'.$item_num] = 0; |
|
196 | 196 | $redirect_args['on0_'.$item_num] = 'NOTIFY URL'; |
197 | - $redirect_args['os0_' . $item_num] = $notify_url; |
|
197 | + $redirect_args['os0_'.$item_num] = $notify_url; |
|
198 | 198 | $redirect_args['on1_'.$item_num] = 'RETURN URL'; |
199 | - $redirect_args['os1_' . $item_num] = $return_url; |
|
199 | + $redirect_args['os1_'.$item_num] = $return_url; |
|
200 | 200 | // $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ? |
201 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
202 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
201 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
202 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $redirect_args['business'] = $this->_paypal_id; |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | $redirect_args['cmd'] = '_cart'; |
210 | 210 | $redirect_args['upload'] = 1; |
211 | 211 | $redirect_args['currency_code'] = $payment->currency_code(); |
212 | - $redirect_args['rm'] = 2;//makes the user return with method=POST |
|
213 | - if($this->_image_url){ |
|
212 | + $redirect_args['rm'] = 2; //makes the user return with method=POST |
|
213 | + if ($this->_image_url) { |
|
214 | 214 | $redirect_args['image_url'] = $this->_image_url; |
215 | 215 | } |
216 | 216 | $redirect_args['no_shipping'] = $this->_shipping_details; |
217 | - $redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this |
|
217 | + $redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this |
|
218 | 218 | |
219 | - $redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this ); |
|
219 | + $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this); |
|
220 | 220 | |
221 | 221 | $payment->set_redirect_url($this->_gateway_url); |
222 | 222 | $payment->set_redirect_args($redirect_args); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $this->log( |
225 | 225 | array( |
226 | 226 | 'message' => sprintf( |
227 | - __( 'PayPal payment request initiated.', 'event_espresso' ) |
|
227 | + __('PayPal payment request initiated.', 'event_espresso') |
|
228 | 228 | ), |
229 | 229 | 'transaction' => $transaction->model_field_array(), |
230 | 230 | ), |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | * @return \EEI_Payment updated |
245 | 245 | * @throws \EE_Error, IpnException |
246 | 246 | */ |
247 | - public function handle_payment_update( $update_info, $transaction ){ |
|
247 | + public function handle_payment_update($update_info, $transaction) { |
|
248 | 248 | // verify there's payment data that's been sent |
249 | - if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) { |
|
249 | + if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) { |
|
250 | 250 | // log the results |
251 | 251 | $this->log( |
252 | 252 | array( |
253 | 253 | 'message' => sprintf( |
254 | - __( 'PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso' ) |
|
254 | + __('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso') |
|
255 | 255 | ), |
256 | 256 | 'update_info' => $update_info, |
257 | 257 | ), |
@@ -259,33 +259,33 @@ discard block |
||
259 | 259 | ); |
260 | 260 | // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/) |
261 | 261 | // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes |
262 | - if ( isset( $update_info[ 'tx' ] ) ) { |
|
262 | + if (isset($update_info['tx'])) { |
|
263 | 263 | return $transaction->last_payment(); |
264 | 264 | } else { |
265 | 265 | return null; |
266 | 266 | } |
267 | 267 | } |
268 | - $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
269 | - if ( ! $payment instanceof EEI_Payment ) { |
|
268 | + $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']); |
|
269 | + if ( ! $payment instanceof EEI_Payment) { |
|
270 | 270 | $payment = $transaction->last_payment(); |
271 | 271 | } |
272 | 272 | // ok, then validate the IPN. Even if we've already processed this payment, |
273 | 273 | // let PayPal know we don't want to hear from them anymore! |
274 | - if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
|
274 | + if ( ! $this->validate_ipn($update_info, $payment)) { |
|
275 | 275 | return $payment; |
276 | 276 | } |
277 | 277 | // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction, |
278 | 278 | // registrations, ticket counts, etc) |
279 | 279 | if ( |
280 | 280 | ( |
281 | - $update_info[ 'payment_status' ] === 'Refunded' |
|
282 | - || $update_info[ 'payment_status' ] === 'Partially_Refunded' |
|
281 | + $update_info['payment_status'] === 'Refunded' |
|
282 | + || $update_info['payment_status'] === 'Partially_Refunded' |
|
283 | 283 | ) |
284 | - && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) |
|
284 | + && apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true) |
|
285 | 285 | ) { |
286 | 286 | throw new EventEspresso\core\exceptions\IpnException( |
287 | 287 | sprintf( |
288 | - esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'), |
|
288 | + esc_html__('Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'), |
|
289 | 289 | $update_info['payment_status'] |
290 | 290 | ), |
291 | 291 | EventEspresso\core\exceptions\IpnException::UNSUPPORTED, |
@@ -295,34 +295,34 @@ discard block |
||
295 | 295 | ); |
296 | 296 | } |
297 | 297 | //ok, well let's process this payment then! |
298 | - switch ( $update_info[ 'payment_status' ] ) { |
|
298 | + switch ($update_info['payment_status']) { |
|
299 | 299 | |
300 | 300 | case 'Completed' : |
301 | 301 | $status = $this->_pay_model->approved_status(); |
302 | - $gateway_response = esc_html__( 'The payment is approved.', 'event_espresso' ); |
|
302 | + $gateway_response = esc_html__('The payment is approved.', 'event_espresso'); |
|
303 | 303 | break; |
304 | 304 | |
305 | 305 | case 'Pending' : |
306 | 306 | $status = $this->_pay_model->pending_status(); |
307 | - $gateway_response = esc_html__( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' ); |
|
307 | + $gateway_response = esc_html__('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso'); |
|
308 | 308 | break; |
309 | 309 | |
310 | 310 | case 'Denied' : |
311 | 311 | $status = $this->_pay_model->declined_status(); |
312 | - $gateway_response = esc_html__( 'The payment has been declined.', 'event_espresso' ); |
|
312 | + $gateway_response = esc_html__('The payment has been declined.', 'event_espresso'); |
|
313 | 313 | break; |
314 | 314 | |
315 | 315 | case 'Expired' : |
316 | 316 | case 'Failed' : |
317 | 317 | $status = $this->_pay_model->failed_status(); |
318 | - $gateway_response = esc_html__( 'The payment failed for technical reasons or expired.', 'event_espresso' ); |
|
318 | + $gateway_response = esc_html__('The payment failed for technical reasons or expired.', 'event_espresso'); |
|
319 | 319 | break; |
320 | 320 | |
321 | 321 | case 'Refunded' : |
322 | 322 | case 'Partially_Refunded' : |
323 | 323 | // even though it's a refund, we consider the payment as approved, it just has a negative value |
324 | 324 | $status = $this->_pay_model->approved_status(); |
325 | - $gateway_response = esc_html__( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' ); |
|
325 | + $gateway_response = esc_html__('The payment has been refunded. Please update registrations accordingly.', 'event_espresso'); |
|
326 | 326 | break; |
327 | 327 | |
328 | 328 | case 'Voided' : |
@@ -330,19 +330,19 @@ discard block |
||
330 | 330 | case 'Canceled_Reversal' : |
331 | 331 | default : |
332 | 332 | $status = $this->_pay_model->cancelled_status(); |
333 | - $gateway_response = esc_html__( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' ); |
|
333 | + $gateway_response = esc_html__('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso'); |
|
334 | 334 | break; |
335 | 335 | |
336 | 336 | } |
337 | 337 | |
338 | 338 | //check if we've already processed this payment |
339 | - if ( $payment instanceof EEI_Payment ) { |
|
339 | + if ($payment instanceof EEI_Payment) { |
|
340 | 340 | //payment exists. if this has the exact same status and amount, don't bother updating. just return |
341 | - if ( $payment->status() === $status && (float)$payment->amount() === (float)$update_info[ 'mc_gross' ] ) { |
|
341 | + if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) { |
|
342 | 342 | // DUPLICATED IPN! don't bother updating transaction |
343 | 343 | throw new IpnException( |
344 | 344 | sprintf( |
345 | - esc_html__( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), |
|
345 | + esc_html__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), |
|
346 | 346 | $payment->ID() |
347 | 347 | ), |
348 | 348 | IpnException::DUPLICATE, |
@@ -352,14 +352,14 @@ discard block |
||
352 | 352 | ); |
353 | 353 | } else { |
354 | 354 | // new payment yippee !!! |
355 | - $payment->set_status( $status ); |
|
356 | - $payment->set_amount( (float)$update_info[ 'mc_gross' ] ); |
|
357 | - $payment->set_gateway_response( $gateway_response ); |
|
358 | - $payment->set_details( $update_info ); |
|
359 | - $payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
355 | + $payment->set_status($status); |
|
356 | + $payment->set_amount((float) $update_info['mc_gross']); |
|
357 | + $payment->set_gateway_response($gateway_response); |
|
358 | + $payment->set_details($update_info); |
|
359 | + $payment->set_txn_id_chq_nmbr($update_info['txn_id']); |
|
360 | 360 | $this->log( |
361 | 361 | array( |
362 | - 'message' => esc_html__( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ), |
|
362 | + 'message' => esc_html__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'), |
|
363 | 363 | 'url' => $this->_process_response_url(), |
364 | 364 | 'payment' => $payment->model_field_array(), |
365 | 365 | 'IPN_data' => $update_info |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
372 | - do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this ); |
|
372 | + do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this); |
|
373 | 373 | return $payment; |
374 | 374 | } |
375 | 375 | |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | * @return boolean |
385 | 385 | * @throws \EE_Error |
386 | 386 | */ |
387 | - public function validate_ipn( $update_info, $payment ) { |
|
387 | + public function validate_ipn($update_info, $payment) { |
|
388 | 388 | //allow us to skip validating IPNs with PayPal (useful for testing) |
389 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) { |
|
389 | + if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) { |
|
390 | 390 | return true; |
391 | 391 | } |
392 | 392 | //...otherwise, we actually don't care what the $update_info is, we need to look |
@@ -394,22 +394,22 @@ discard block |
||
394 | 394 | // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. |
395 | 395 | // Instead, read raw POST data from the input stream. |
396 | 396 | // @see https://gist.github.com/xcommerce-gists/3440401 |
397 | - $raw_post_data = file_get_contents( 'php://input' ); |
|
398 | - $raw_post_array = explode( '&', $raw_post_data ); |
|
397 | + $raw_post_data = file_get_contents('php://input'); |
|
398 | + $raw_post_array = explode('&', $raw_post_data); |
|
399 | 399 | $update_info = array(); |
400 | - foreach ( $raw_post_array as $keyval ) { |
|
401 | - $keyval = explode( '=', $keyval ); |
|
402 | - if ( count( $keyval ) === 2 ) { |
|
403 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
400 | + foreach ($raw_post_array as $keyval) { |
|
401 | + $keyval = explode('=', $keyval); |
|
402 | + if (count($keyval) === 2) { |
|
403 | + $update_info[$keyval[0]] = urldecode($keyval[1]); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
407 | 407 | $req = 'cmd=_notify-validate'; |
408 | - $uses_get_magic_quotes = function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1 |
|
408 | + $uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1 |
|
409 | 409 | ? true |
410 | 410 | : false; |
411 | - foreach ( $update_info as $key => $value ) { |
|
412 | - $value = $uses_get_magic_quotes ? urlencode( stripslashes( $value ) ) : urlencode( $value ); |
|
411 | + foreach ($update_info as $key => $value) { |
|
412 | + $value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value); |
|
413 | 413 | $req .= "&$key=$value"; |
414 | 414 | } |
415 | 415 | // HTTP POST the complete, unaltered IPN back to PayPal |
@@ -418,38 +418,38 @@ discard block |
||
418 | 418 | array( |
419 | 419 | 'body' => $req, |
420 | 420 | 'sslverify' => false, |
421 | - 'timeout' => 60 , |
|
421 | + 'timeout' => 60, |
|
422 | 422 | // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal |
423 | 423 | // plz see: https://github.com/websharks/s2member/issues/610 |
424 | - 'user-agent' => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(), |
|
424 | + 'user-agent' => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(), |
|
425 | 425 | 'httpversion' => '1.1' |
426 | 426 | ) |
427 | 427 | ); |
428 | 428 | // then check the response |
429 | 429 | if ( |
430 | - array_key_exists( 'body', $response ) |
|
431 | - && ! is_wp_error( $response ) |
|
432 | - && strcmp( $response[ 'body' ], "VERIFIED" ) === 0 |
|
430 | + array_key_exists('body', $response) |
|
431 | + && ! is_wp_error($response) |
|
432 | + && strcmp($response['body'], "VERIFIED") === 0 |
|
433 | 433 | ) { |
434 | 434 | return true; |
435 | 435 | } |
436 | 436 | // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly, |
437 | 437 | // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html |
438 | - if( $response instanceof WP_Error ) { |
|
438 | + if ($response instanceof WP_Error) { |
|
439 | 439 | $error_msg = sprintf( |
440 | - esc_html__( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ), |
|
440 | + esc_html__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'), |
|
441 | 441 | $response->get_error_code(), |
442 | 442 | $response->get_error_message(), |
443 | - print_r( $response->get_error_data(), true ) |
|
443 | + print_r($response->get_error_data(), true) |
|
444 | 444 | ); |
445 | - } elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) { |
|
446 | - $error_msg = $response[ 'body' ]; |
|
445 | + } elseif (is_array($response) && isset($response['body'])) { |
|
446 | + $error_msg = $response['body']; |
|
447 | 447 | } else { |
448 | - $error_msg = print_r( $response, true ); |
|
448 | + $error_msg = print_r($response, true); |
|
449 | 449 | } |
450 | - $payment->set_gateway_response( sprintf( esc_html__( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) ); |
|
451 | - $payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) ); |
|
452 | - $payment->set_status( EEM_Payment::status_id_failed ); |
|
450 | + $payment->set_gateway_response(sprintf(esc_html__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg)); |
|
451 | + $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response)); |
|
452 | + $payment->set_status(EEM_Payment::status_id_failed); |
|
453 | 453 | // log the results |
454 | 454 | $this->log( |
455 | 455 | array( |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | * @return string |
470 | 470 | */ |
471 | 471 | protected function _process_response_url() { |
472 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
472 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
473 | 473 | $url = is_ssl() ? 'https://' : 'http://'; |
474 | - $url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
474 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
475 | 475 | $url .= EEH_URL::filter_input_server_url(); |
476 | 476 | } else { |
477 | 477 | $url = 'unknown'; |
@@ -488,12 +488,12 @@ discard block |
||
488 | 488 | * @param EEI_Payment $payment |
489 | 489 | * @throws \EE_Error |
490 | 490 | */ |
491 | - public function update_txn_based_on_payment( $payment ) { |
|
491 | + public function update_txn_based_on_payment($payment) { |
|
492 | 492 | $update_info = $payment->details(); |
493 | 493 | /** @var EE_Transaction $transaction */ |
494 | 494 | $transaction = $payment->transaction(); |
495 | - $payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false ); |
|
496 | - if( ! $transaction ){ |
|
495 | + $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false); |
|
496 | + if ( ! $transaction) { |
|
497 | 497 | $this->log( |
498 | 498 | esc_html__( |
499 | 499 | 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', |
@@ -503,10 +503,10 @@ discard block |
||
503 | 503 | ); |
504 | 504 | return; |
505 | 505 | } |
506 | - if( |
|
507 | - ! is_array( $update_info ) |
|
508 | - || ! isset( $update_info[ 'mc_shipping' ] ) |
|
509 | - || ! isset( $update_info[ 'tax' ] ) |
|
506 | + if ( |
|
507 | + ! is_array($update_info) |
|
508 | + || ! isset($update_info['mc_shipping']) |
|
509 | + || ! isset($update_info['tax']) |
|
510 | 510 | ) { |
511 | 511 | $this->log( |
512 | 512 | array( |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | ); |
522 | 522 | return; |
523 | 523 | } |
524 | - if( $payment->status() !== $this->_pay_model->approved_status() ) { |
|
524 | + if ($payment->status() !== $this->_pay_model->approved_status()) { |
|
525 | 525 | $this->log( |
526 | 526 | array( |
527 | 527 | 'message' => esc_html__( |
@@ -540,44 +540,44 @@ discard block |
||
540 | 540 | $transaction_total_line_item = $transaction->total_line_item(); |
541 | 541 | |
542 | 542 | //might paypal have changed the taxes? |
543 | - if( $this->_paypal_taxes && $payment_was_itemized ) { |
|
543 | + if ($this->_paypal_taxes && $payment_was_itemized) { |
|
544 | 544 | // note that we're doing this BEFORE adding shipping; |
545 | 545 | // we actually want PayPal's shipping to remain non-taxable |
546 | - $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' ); |
|
546 | + $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping'); |
|
547 | 547 | $this->_line_item->set_total_tax_to( |
548 | 548 | $transaction_total_line_item, |
549 | - (float)$update_info['tax'], |
|
550 | - esc_html__( 'Taxes', 'event_espresso' ), |
|
551 | - esc_html__( 'Calculated by Paypal', 'event_espresso' ), |
|
549 | + (float) $update_info['tax'], |
|
550 | + esc_html__('Taxes', 'event_espresso'), |
|
551 | + esc_html__('Calculated by Paypal', 'event_espresso'), |
|
552 | 552 | 'paypal_tax' |
553 | 553 | ); |
554 | 554 | $grand_total_needs_resaving = TRUE; |
555 | 555 | } |
556 | 556 | |
557 | - $shipping_amount = (float)$update_info[ 'mc_shipping' ]; |
|
557 | + $shipping_amount = (float) $update_info['mc_shipping']; |
|
558 | 558 | //might paypal have added shipping? |
559 | - if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){ |
|
559 | + if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) { |
|
560 | 560 | $this->_line_item->add_unrelated_item( |
561 | 561 | $transaction_total_line_item, |
562 | - sprintf( esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ), |
|
562 | + sprintf(esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()), |
|
563 | 563 | $shipping_amount, |
564 | 564 | esc_html__('Shipping charges calculated by Paypal', 'event_espresso'), |
565 | 565 | 1, |
566 | 566 | false, |
567 | - 'paypal_shipping_' . $transaction->ID() |
|
567 | + 'paypal_shipping_'.$transaction->ID() |
|
568 | 568 | ); |
569 | 569 | $grand_total_needs_resaving = true; |
570 | 570 | } |
571 | 571 | |
572 | - if( $grand_total_needs_resaving ){ |
|
573 | - $transaction_total_line_item->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
572 | + if ($grand_total_needs_resaving) { |
|
573 | + $transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
574 | 574 | /** @var EE_Registration_Processor $registration_processor */ |
575 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
576 | - $registration_processor->update_registration_final_prices( $transaction ); |
|
575 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
576 | + $registration_processor->update_registration_final_prices($transaction); |
|
577 | 577 | } |
578 | 578 | $this->log( |
579 | 579 | array( |
580 | - 'message' => esc_html__( 'Updated transaction related to payment', 'event_espresso' ), |
|
580 | + 'message' => esc_html__('Updated transaction related to payment', 'event_espresso'), |
|
581 | 581 | 'url' => $this->_process_response_url(), |
582 | 582 | 'transaction (updated)' => $transaction->model_field_array(), |
583 | 583 | 'payment (updated)' => $payment->model_field_array(), |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance; |
20 | 20 | |
21 | 21 | |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
52 | 52 | * Saves the payment that is generated |
53 | - |
|
54 | 53 | * |
55 | 54 | *@param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | |
131 | 130 | |
132 | 131 | /** |
133 | - |
|
134 | 132 | * @param EE_Transaction|int $transaction |
135 | 133 | * @param EE_Payment_Method $payment_method |
136 | 134 | * @throws EE_Error |
@@ -221,22 +219,22 @@ discard block |
||
221 | 219 | /** @type EE_Payment_Method $payment_method */ |
222 | 220 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
223 | 221 | if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
224 | - try { |
|
225 | - $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
226 | - $log->set_object($payment); |
|
227 | - } catch( EventEspresso\core\exceptions\IpnException $e ) { |
|
228 | - EEM_Change_Log::instance()->log( |
|
229 | - EEM_Change_Log::type_gateway, |
|
230 | - array( |
|
231 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
232 | - 'current_url' => EEH_URL::current_url(), |
|
233 | - 'payment' => $e->getPaymentProperties(), |
|
234 | - 'IPN_data' => $e->getIpnData() |
|
235 | - ), |
|
236 | - $obj_for_log |
|
237 | - ); |
|
238 | - return $e->getPayment(); |
|
239 | - } |
|
222 | + try { |
|
223 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
224 | + $log->set_object($payment); |
|
225 | + } catch( EventEspresso\core\exceptions\IpnException $e ) { |
|
226 | + EEM_Change_Log::instance()->log( |
|
227 | + EEM_Change_Log::type_gateway, |
|
228 | + array( |
|
229 | + 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
230 | + 'current_url' => EEH_URL::current_url(), |
|
231 | + 'payment' => $e->getPaymentProperties(), |
|
232 | + 'IPN_data' => $e->getIpnData() |
|
233 | + ), |
|
234 | + $obj_for_log |
|
235 | + ); |
|
236 | + return $e->getPayment(); |
|
237 | + } |
|
240 | 238 | } else { |
241 | 239 | // not a payment |
242 | 240 | EE_Error::add_error( |
@@ -262,18 +260,18 @@ discard block |
||
262 | 260 | ); |
263 | 261 | break; |
264 | 262 | } catch( EventEspresso\core\exceptions\IpnException $e ) { |
265 | - EEM_Change_Log::instance()->log( |
|
266 | - EEM_Change_Log::type_gateway, |
|
267 | - array( |
|
268 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
269 | - 'current_url' => EEH_URL::current_url(), |
|
270 | - 'payment' => $e->getPaymentProperties(), |
|
271 | - 'IPN_data' => $e->getIpnData() |
|
272 | - ), |
|
273 | - $obj_for_log |
|
274 | - ); |
|
275 | - return $e->getPayment(); |
|
276 | - } catch( EE_Error $e ) { |
|
263 | + EEM_Change_Log::instance()->log( |
|
264 | + EEM_Change_Log::type_gateway, |
|
265 | + array( |
|
266 | + 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
267 | + 'current_url' => EEH_URL::current_url(), |
|
268 | + 'payment' => $e->getPaymentProperties(), |
|
269 | + 'IPN_data' => $e->getIpnData() |
|
270 | + ), |
|
271 | + $obj_for_log |
|
272 | + ); |
|
273 | + return $e->getPayment(); |
|
274 | + } catch( EE_Error $e ) { |
|
277 | 275 | //that's fine- it apparently couldn't handle the IPN |
278 | 276 | } |
279 | 277 | } |
@@ -709,12 +707,12 @@ discard block |
||
709 | 707 | } |
710 | 708 | |
711 | 709 | /** |
712 | - * Force posts to PayPal to use TLS v1.2. See: |
|
713 | - * https://core.trac.wordpress.org/ticket/36320 |
|
714 | - * https://core.trac.wordpress.org/ticket/34924#comment:15 |
|
715 | - * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
|
710 | + * Force posts to PayPal to use TLS v1.2. See: |
|
711 | + * https://core.trac.wordpress.org/ticket/36320 |
|
712 | + * https://core.trac.wordpress.org/ticket/34924#comment:15 |
|
713 | + * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
|
716 | 714 | * This will affect paypal standard, pro, express, and payflow. |
717 | - */ |
|
715 | + */ |
|
718 | 716 | public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) { |
719 | 717 | if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) { |
720 | 718 | //Use the value of the constant CURL_SSLVERSION_TLSv1 = 1 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | *@access private |
42 | 42 | */ |
43 | 43 | private function __construct() { |
44 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | - add_action( 'http_api_curl', array( $this, '_curl_requests_to_paypal_use_tls' ), 10, 3 ); |
|
44 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
45 | + add_action('http_api_curl', array($this, '_curl_requests_to_paypal_use_tls'), 10, 3); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $update_txn = true, |
82 | 82 | $cancel_url = '' |
83 | 83 | ) { |
84 | - if( (float)$amount < 0 ) { |
|
84 | + if ((float) $amount < 0) { |
|
85 | 85 | throw new EE_Error( |
86 | 86 | sprintf( |
87 | 87 | __( |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | // verify payment method |
97 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
97 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
98 | 98 | // verify transaction |
99 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
100 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
99 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
100 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
101 | 101 | // verify payment method type |
102 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
102 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
103 | 103 | $payment = $payment_method->type_obj()->process_payment( |
104 | 104 | $transaction, |
105 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
105 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
106 | 106 | $billing_form, |
107 | 107 | $return_url, |
108 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
108 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
109 | 109 | $method, |
110 | 110 | $by_admin |
111 | 111 | ); |
112 | 112 | // check if payment method uses an off-site gateway |
113 | - if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) { |
|
113 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
114 | 114 | // don't process payments for off-site gateways yet because no payment has occurred yet |
115 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
115 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
116 | 116 | } |
117 | 117 | return $payment; |
118 | 118 | } else { |
119 | 119 | EE_Error::add_error( |
120 | 120 | sprintf( |
121 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
121 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
122 | 122 | '<br/>', |
123 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
123 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
124 | 124 | ), __FILE__, __FUNCTION__, __LINE__ |
125 | 125 | ); |
126 | 126 | return NULL; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * @throws EE_Error |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
139 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
140 | 140 | /** @type \EE_Transaction $transaction */ |
141 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
141 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
142 | 142 | $primary_reg = $transaction->primary_registration(); |
143 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
143 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
144 | 144 | throw new EE_Error( |
145 | 145 | sprintf( |
146 | 146 | __( |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | } |
154 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
154 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
155 | 155 | $url = add_query_arg( |
156 | 156 | array( |
157 | 157 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -188,47 +188,47 @@ discard block |
||
188 | 188 | $update_txn = true, |
189 | 189 | $separate_IPN_request = true |
190 | 190 | ) { |
191 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
192 | - $_req_data = $this->_remove_unusable_characters_from_array( (array)$_req_data ); |
|
193 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
191 | + EE_Registry::instance()->load_model('Change_Log'); |
|
192 | + $_req_data = $this->_remove_unusable_characters_from_array((array) $_req_data); |
|
193 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
194 | 194 | $obj_for_log = null; |
195 | - if( $transaction instanceof EE_Transaction ){ |
|
195 | + if ($transaction instanceof EE_Transaction) { |
|
196 | 196 | $obj_for_log = $transaction; |
197 | - if( $payment_method instanceof EE_Payment_Method ) { |
|
197 | + if ($payment_method instanceof EE_Payment_Method) { |
|
198 | 198 | $obj_for_log = EEM_Payment::instance()->get_one( |
199 | 199 | array( |
200 | - array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), |
|
201 | - 'order_by' => array( 'PAY_timestamp' => 'desc' ) |
|
200 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
201 | + 'order_by' => array('PAY_timestamp' => 'desc') |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | - } else if( $payment_method instanceof EE_Payment ) { |
|
205 | + } else if ($payment_method instanceof EE_Payment) { |
|
206 | 206 | $obj_for_log = $payment_method; |
207 | 207 | } |
208 | 208 | $log = EEM_Change_Log::instance()->log( |
209 | 209 | EEM_Change_Log::type_gateway, |
210 | - array( 'IPN data received' => $_req_data ), |
|
210 | + array('IPN data received' => $_req_data), |
|
211 | 211 | $obj_for_log |
212 | 212 | ); |
213 | - try{ |
|
213 | + try { |
|
214 | 214 | /** |
215 | 215 | * @var EE_Payment $payment |
216 | 216 | */ |
217 | 217 | $payment = NULL; |
218 | - if($transaction && $payment_method){ |
|
218 | + if ($transaction && $payment_method) { |
|
219 | 219 | /** @type EE_Transaction $transaction */ |
220 | 220 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
221 | 221 | /** @type EE_Payment_Method $payment_method */ |
222 | 222 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
223 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
223 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
224 | 224 | try { |
225 | 225 | $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
226 | 226 | $log->set_object($payment); |
227 | - } catch( EventEspresso\core\exceptions\IpnException $e ) { |
|
227 | + } catch (EventEspresso\core\exceptions\IpnException $e) { |
|
228 | 228 | EEM_Change_Log::instance()->log( |
229 | 229 | EEM_Change_Log::type_gateway, |
230 | 230 | array( |
231 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
231 | + 'message' => 'IPN Exception: '.$e->getMessage(), |
|
232 | 232 | 'current_url' => EEH_URL::current_url(), |
233 | 233 | 'payment' => $e->getPaymentProperties(), |
234 | 234 | 'IPN_data' => $e->getIpnData() |
@@ -241,31 +241,31 @@ discard block |
||
241 | 241 | // not a payment |
242 | 242 | EE_Error::add_error( |
243 | 243 | sprintf( |
244 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
244 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
245 | 245 | '<br/>', |
246 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
246 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
247 | 247 | ), |
248 | 248 | __FILE__, __FUNCTION__, __LINE__ |
249 | 249 | ); |
250 | 250 | } |
251 | - }else{ |
|
251 | + } else { |
|
252 | 252 | //that's actually pretty ok. The IPN just wasn't able |
253 | 253 | //to identify which transaction or payment method this was for |
254 | 254 | // give all active payment methods a chance to claim it |
255 | 255 | $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
256 | - foreach( $active_payment_methods as $active_payment_method ){ |
|
257 | - try{ |
|
258 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
256 | + foreach ($active_payment_methods as $active_payment_method) { |
|
257 | + try { |
|
258 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
259 | 259 | $payment_method = $active_payment_method; |
260 | 260 | EEM_Change_Log::instance()->log( |
261 | 261 | EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment |
262 | 262 | ); |
263 | 263 | break; |
264 | - } catch( EventEspresso\core\exceptions\IpnException $e ) { |
|
264 | + } catch (EventEspresso\core\exceptions\IpnException $e) { |
|
265 | 265 | EEM_Change_Log::instance()->log( |
266 | 266 | EEM_Change_Log::type_gateway, |
267 | 267 | array( |
268 | - 'message' => 'IPN Exception: ' . $e->getMessage(), |
|
268 | + 'message' => 'IPN Exception: '.$e->getMessage(), |
|
269 | 269 | 'current_url' => EEH_URL::current_url(), |
270 | 270 | 'payment' => $e->getPaymentProperties(), |
271 | 271 | 'IPN_data' => $e->getIpnData() |
@@ -273,33 +273,33 @@ discard block |
||
273 | 273 | $obj_for_log |
274 | 274 | ); |
275 | 275 | return $e->getPayment(); |
276 | - } catch( EE_Error $e ) { |
|
276 | + } catch (EE_Error $e) { |
|
277 | 277 | //that's fine- it apparently couldn't handle the IPN |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | 281 | } |
282 | 282 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
283 | - if( $payment instanceof EE_Payment){ |
|
283 | + if ($payment instanceof EE_Payment) { |
|
284 | 284 | $payment->save(); |
285 | 285 | // update the TXN |
286 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
287 | - }else{ |
|
286 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
287 | + } else { |
|
288 | 288 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
289 | - if($payment_method){ |
|
289 | + if ($payment_method) { |
|
290 | 290 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
291 | - }elseif($transaction){ |
|
291 | + }elseif ($transaction) { |
|
292 | 292 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
293 | 293 | } |
294 | 294 | } |
295 | 295 | return $payment; |
296 | 296 | |
297 | - } catch( EE_Error $e ) { |
|
297 | + } catch (EE_Error $e) { |
|
298 | 298 | do_action( |
299 | 299 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
300 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
301 | - print_r( $transaction, TRUE ), |
|
302 | - print_r( $_req_data, TRUE ), |
|
300 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
301 | + print_r($transaction, TRUE), |
|
302 | + print_r($_req_data, TRUE), |
|
303 | 303 | $e->getMessage() |
304 | 304 | ) |
305 | 305 | ); |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * @param array $request_data |
315 | 315 | * @return array |
316 | 316 | */ |
317 | - protected function _remove_unusable_characters_from_array( array $request_data ) { |
|
317 | + protected function _remove_unusable_characters_from_array(array $request_data) { |
|
318 | 318 | $return_data = array(); |
319 | - foreach( $request_data as $key => $value ) { |
|
320 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
319 | + foreach ($request_data as $key => $value) { |
|
320 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
321 | 321 | } |
322 | 322 | return $return_data; |
323 | 323 | } |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | * @param string $request_data |
330 | 330 | * @return string |
331 | 331 | */ |
332 | - protected function _remove_unusable_characters( $request_data ) { |
|
333 | - return preg_replace( '/[^[:print:]]/', '', $request_data ); |
|
332 | + protected function _remove_unusable_characters($request_data) { |
|
333 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -352,13 +352,13 @@ discard block |
||
352 | 352 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
353 | 353 | * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
354 | 354 | */ |
355 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
355 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
356 | 356 | /** @var $transaction EE_Transaction */ |
357 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
357 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
358 | 358 | $last_payment_method = $transaction->payment_method(); |
359 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
360 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
361 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
359 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
360 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
361 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
362 | 362 | return $payment; |
363 | 363 | } else { |
364 | 364 | return NULL; |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | EE_Payment $payment_to_refund, |
382 | 382 | $refund_info = array() |
383 | 383 | ) { |
384 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
385 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
386 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
384 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
385 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
386 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
387 | 387 | } |
388 | 388 | return $payment_to_refund; |
389 | 389 | } |
@@ -424,12 +424,12 @@ discard block |
||
424 | 424 | * TXN is locked before updating |
425 | 425 | * @throws \EE_Error |
426 | 426 | */ |
427 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
427 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
428 | 428 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
429 | 429 | /** @type EE_Transaction $transaction */ |
430 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
430 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
431 | 431 | // can we freely update the TXN at this moment? |
432 | - if ( $IPN && $transaction->is_locked() ) { |
|
432 | + if ($IPN && $transaction->is_locked()) { |
|
433 | 433 | // don't update the transaction at this exact moment |
434 | 434 | // because the TXN is active in another request |
435 | 435 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -439,38 +439,38 @@ discard block |
||
439 | 439 | ); |
440 | 440 | } else { |
441 | 441 | // verify payment and that it has been saved |
442 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
443 | - if( |
|
442 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
443 | + if ( |
|
444 | 444 | $payment->payment_method() instanceof EE_Payment_Method |
445 | 445 | && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
446 | - ){ |
|
447 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
446 | + ) { |
|
447 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
448 | 448 | // update TXN registrations with payment info |
449 | - $this->process_registration_payments( $transaction, $payment ); |
|
449 | + $this->process_registration_payments($transaction, $payment); |
|
450 | 450 | } |
451 | 451 | $do_action = $payment->just_approved() |
452 | 452 | ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
453 | 453 | : $do_action; |
454 | 454 | } else { |
455 | 455 | // send out notifications |
456 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
456 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
457 | 457 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
458 | 458 | } |
459 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
459 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
460 | 460 | /** @type EE_Transaction_Payments $transaction_payments */ |
461 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
461 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
462 | 462 | // set new value for total paid |
463 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
463 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
464 | 464 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
465 | - if ( $update_txn ) { |
|
466 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
465 | + if ($update_txn) { |
|
466 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | // granular hook for others to use. |
470 | - do_action( $do_action, $transaction, $payment ); |
|
471 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
470 | + do_action($do_action, $transaction, $payment); |
|
471 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
472 | 472 | //global hook for others to use. |
473 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
473 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | |
@@ -490,25 +490,25 @@ discard block |
||
490 | 490 | $registrations = array() |
491 | 491 | ) { |
492 | 492 | // only process if payment was successful |
493 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
493 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
494 | 494 | return; |
495 | 495 | } |
496 | 496 | //EEM_Registration::instance()->show_next_x_db_queries(); |
497 | - if ( empty( $registrations )) { |
|
497 | + if (empty($registrations)) { |
|
498 | 498 | // find registrations with monies owing that can receive a payment |
499 | 499 | $registrations = $transaction->registrations( |
500 | 500 | array( |
501 | 501 | array( |
502 | 502 | // only these reg statuses can receive payments |
503 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
504 | - 'REG_final_price' => array( '!=', 0 ), |
|
505 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
503 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
504 | + 'REG_final_price' => array('!=', 0), |
|
505 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
506 | 506 | ) |
507 | 507 | ) |
508 | 508 | ); |
509 | 509 | } |
510 | 510 | // still nothing ??!?? |
511 | - if ( empty( $registrations )) { |
|
511 | + if (empty($registrations)) { |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | // todo: break out the following logic into a separate strategy class |
@@ -520,28 +520,28 @@ discard block |
||
520 | 520 | |
521 | 521 | $refund = $payment->is_a_refund(); |
522 | 522 | // how much is available to apply to registrations? |
523 | - $available_payment_amount = abs( $payment->amount() ); |
|
524 | - foreach ( $registrations as $registration ) { |
|
525 | - if ( $registration instanceof EE_Registration ) { |
|
523 | + $available_payment_amount = abs($payment->amount()); |
|
524 | + foreach ($registrations as $registration) { |
|
525 | + if ($registration instanceof EE_Registration) { |
|
526 | 526 | // nothing left? |
527 | - if ( $available_payment_amount <= 0 ) { |
|
527 | + if ($available_payment_amount <= 0) { |
|
528 | 528 | break; |
529 | 529 | } |
530 | - if ( $refund ) { |
|
531 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
530 | + if ($refund) { |
|
531 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
532 | 532 | } else { |
533 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
533 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | } |
537 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
537 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
538 | 538 | EE_Error::add_attention( |
539 | 539 | sprintf( |
540 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
541 | - EEH_Template::format_currency( $available_payment_amount ), |
|
542 | - implode( ', ', array_keys( $registrations ) ), |
|
540 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
541 | + EEH_Template::format_currency($available_payment_amount), |
|
542 | + implode(', ', array_keys($registrations)), |
|
543 | 543 | '<br/>', |
544 | - EEH_Template::format_currency( $payment->amount() ) |
|
544 | + EEH_Template::format_currency($payment->amount()) |
|
545 | 545 | ), |
546 | 546 | __FILE__, __FUNCTION__, __LINE__ |
547 | 547 | ); |
@@ -559,17 +559,17 @@ discard block |
||
559 | 559 | * @return float |
560 | 560 | * @throws \EE_Error |
561 | 561 | */ |
562 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
562 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
563 | 563 | $owing = $registration->final_price() - $registration->paid(); |
564 | - if ( $owing > 0 ) { |
|
564 | + if ($owing > 0) { |
|
565 | 565 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
566 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
566 | + $payment_amount = min($available_payment_amount, $owing); |
|
567 | 567 | // update $available_payment_amount |
568 | 568 | $available_payment_amount -= $payment_amount; |
569 | 569 | //calculate and set new REG_paid |
570 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
570 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
571 | 571 | // now save it |
572 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
572 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
573 | 573 | } |
574 | 574 | return $available_payment_amount; |
575 | 575 | } |
@@ -585,19 +585,19 @@ discard block |
||
585 | 585 | * @return void |
586 | 586 | * @throws \EE_Error |
587 | 587 | */ |
588 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
588 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
589 | 589 | // find any existing reg payment records for this registration and payment |
590 | 590 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
591 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
591 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
592 | 592 | ); |
593 | 593 | // if existing registration payment exists |
594 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
594 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
595 | 595 | // then update that record |
596 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
596 | + $existing_reg_payment->set_amount($payment_amount); |
|
597 | 597 | $existing_reg_payment->save(); |
598 | 598 | } else { |
599 | 599 | // or add new relation between registration and payment and set amount |
600 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
600 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
601 | 601 | // make it stick |
602 | 602 | $registration->save(); |
603 | 603 | } |
@@ -614,21 +614,21 @@ discard block |
||
614 | 614 | * @return float |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
617 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
618 | 618 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
619 | - if ( $registration->paid() > 0 ) { |
|
619 | + if ($registration->paid() > 0) { |
|
620 | 620 | // ensure $available_refund_amount is NOT negative |
621 | - $available_refund_amount = (float)abs( $available_refund_amount ); |
|
621 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
622 | 622 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
623 | - $refund_amount = min( $available_refund_amount, (float)$registration->paid() ); |
|
623 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
624 | 624 | // update $available_payment_amount |
625 | 625 | $available_refund_amount -= $refund_amount; |
626 | 626 | //calculate and set new REG_paid |
627 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
627 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
628 | 628 | // convert payment amount back to a negative value for storage in the db |
629 | - $refund_amount = (float)abs( $refund_amount ) * -1; |
|
629 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
630 | 630 | // now save it |
631 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
631 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
632 | 632 | } |
633 | 633 | return $available_refund_amount; |
634 | 634 | } |
@@ -647,53 +647,53 @@ discard block |
||
647 | 647 | * @param bool $IPN |
648 | 648 | * @throws \EE_Error |
649 | 649 | */ |
650 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
650 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
651 | 651 | |
652 | 652 | /** @type EE_Transaction_Processor $transaction_processor */ |
653 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
653 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
654 | 654 | // is the Payment Options Reg Step completed ? |
655 | - $payment_options_step_completed = $transaction->reg_step_completed( 'payment_options' ); |
|
655 | + $payment_options_step_completed = $transaction->reg_step_completed('payment_options'); |
|
656 | 656 | // if the Payment Options Reg Step is completed... |
657 | 657 | $revisit = $payment_options_step_completed === true ? true : false; |
658 | 658 | // then this is kinda sorta a revisit with regards to payments at least |
659 | - $transaction_processor->set_revisit( $revisit ); |
|
659 | + $transaction_processor->set_revisit($revisit); |
|
660 | 660 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
661 | 661 | if ( |
662 | 662 | $IPN && |
663 | 663 | $payment_options_step_completed !== true && |
664 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
664 | + ($payment->is_approved() || $payment->is_pending()) |
|
665 | 665 | ) { |
666 | 666 | $payment_options_step_completed = $transaction->set_reg_step_completed( |
667 | 667 | 'payment_options' |
668 | 668 | ); |
669 | 669 | } |
670 | 670 | // maybe update status, but don't save transaction just yet |
671 | - $transaction->update_status_based_on_total_paid( false ); |
|
671 | + $transaction->update_status_based_on_total_paid(false); |
|
672 | 672 | // check if 'finalize_registration' step has been completed... |
673 | - $finalized = $transaction->reg_step_completed( 'finalize_registration' ); |
|
673 | + $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
674 | 674 | // if this is an IPN and the final step has not been initiated |
675 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
675 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
676 | 676 | // and if it hasn't already been set as being started... |
677 | - $finalized = $transaction->set_reg_step_initiated( 'finalize_registration' ); |
|
677 | + $finalized = $transaction->set_reg_step_initiated('finalize_registration'); |
|
678 | 678 | } |
679 | 679 | $transaction->save(); |
680 | 680 | // because the above will return false if the final step was not fully completed, we need to check again... |
681 | - if ( $IPN && $finalized !== false ) { |
|
681 | + if ($IPN && $finalized !== false) { |
|
682 | 682 | // and if we are all good to go, then send out notifications |
683 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
683 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
684 | 684 | //ok, now process the transaction according to the payment |
685 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
685 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
686 | 686 | } |
687 | 687 | // DEBUG LOG |
688 | 688 | $payment_method = $payment->payment_method(); |
689 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
689 | + if ($payment_method instanceof EE_Payment_Method) { |
|
690 | 690 | $payment_method_type_obj = $payment_method->type_obj(); |
691 | - if ( $payment_method_type_obj instanceof EE_PMT_Base ) { |
|
691 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
692 | 692 | $gateway = $payment_method_type_obj->get_gateway(); |
693 | - if ( $gateway instanceof EE_Gateway ){ |
|
693 | + if ($gateway instanceof EE_Gateway) { |
|
694 | 694 | $gateway->log( |
695 | 695 | array( |
696 | - 'message' => __( 'Post Payment Transaction Details', 'event_espresso' ), |
|
696 | + 'message' => __('Post Payment Transaction Details', 'event_espresso'), |
|
697 | 697 | 'transaction' => $transaction->model_field_array(), |
698 | 698 | 'finalized' => $finalized, |
699 | 699 | 'IPN' => $IPN, |
@@ -715,11 +715,11 @@ discard block |
||
715 | 715 | * https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US |
716 | 716 | * This will affect paypal standard, pro, express, and payflow. |
717 | 717 | */ |
718 | - public static function _curl_requests_to_paypal_use_tls( $handle, $r, $url ) { |
|
719 | - if ( strstr( $url, 'https://' ) && strstr( $url, '.paypal.com' ) ) { |
|
718 | + public static function _curl_requests_to_paypal_use_tls($handle, $r, $url) { |
|
719 | + if (strstr($url, 'https://') && strstr($url, '.paypal.com')) { |
|
720 | 720 | //Use the value of the constant CURL_SSLVERSION_TLSv1 = 1 |
721 | 721 | //instead of the constant because it might not be defined |
722 | - curl_setopt( $handle, CURLOPT_SSLVERSION, 1 ); |
|
722 | + curl_setopt($handle, CURLOPT_SSLVERSION, 1); |
|
723 | 723 | } |
724 | 724 | } |
725 | 725 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\exceptions; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -21,71 +21,71 @@ discard block |
||
21 | 21 | class IpnException extends \LogicException |
22 | 22 | { |
23 | 23 | |
24 | - const DUPLICATE = 1; |
|
24 | + const DUPLICATE = 1; |
|
25 | 25 | |
26 | - const UNABLE_TO_VALIDATE = 2; |
|
26 | + const UNABLE_TO_VALIDATE = 2; |
|
27 | 27 | |
28 | - const UNSUPPORTED = 3; |
|
28 | + const UNSUPPORTED = 3; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var \EE_Payment |
|
32 | - */ |
|
33 | - protected $payment; |
|
30 | + /** |
|
31 | + * @var \EE_Payment |
|
32 | + */ |
|
33 | + protected $payment; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @var mixed IPN data, usually an array or object |
|
37 | - */ |
|
38 | - protected $ipn_data; |
|
35 | + /** |
|
36 | + * @var mixed IPN data, usually an array or object |
|
37 | + */ |
|
38 | + protected $ipn_data; |
|
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | - public function __construct( |
|
43 | - $message, |
|
44 | - $code = 0, |
|
45 | - \Exception $previous = null, |
|
46 | - \EE_Payment $payment = null, |
|
47 | - $ipn_data = array() |
|
48 | - ) { |
|
49 | - parent::__construct($message, $code, $previous); |
|
50 | - $this->payment = $payment; |
|
51 | - $this->ipn_data = $ipn_data; |
|
52 | - } |
|
42 | + public function __construct( |
|
43 | + $message, |
|
44 | + $code = 0, |
|
45 | + \Exception $previous = null, |
|
46 | + \EE_Payment $payment = null, |
|
47 | + $ipn_data = array() |
|
48 | + ) { |
|
49 | + parent::__construct($message, $code, $previous); |
|
50 | + $this->payment = $payment; |
|
51 | + $this->ipn_data = $ipn_data; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Gets the payment associated with this IPN, if known |
|
58 | - * |
|
59 | - * @return \EE_Payment |
|
60 | - */ |
|
61 | - public function getPayment() |
|
62 | - { |
|
63 | - return $this->payment; |
|
64 | - } |
|
56 | + /** |
|
57 | + * Gets the payment associated with this IPN, if known |
|
58 | + * |
|
59 | + * @return \EE_Payment |
|
60 | + */ |
|
61 | + public function getPayment() |
|
62 | + { |
|
63 | + return $this->payment; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * Returns the payment's properties as an array (even if there is no payment, in which case it's an empty array) |
|
70 | - * |
|
71 | - * @return array |
|
72 | - * @throws \EE_Error |
|
73 | - */ |
|
74 | - public function getPaymentProperties() |
|
75 | - { |
|
76 | - return $this->getPayment() instanceof \EE_Payment ? $this->getPayment()->model_field_array() : array(); |
|
77 | - } |
|
68 | + /** |
|
69 | + * Returns the payment's properties as an array (even if there is no payment, in which case it's an empty array) |
|
70 | + * |
|
71 | + * @return array |
|
72 | + * @throws \EE_Error |
|
73 | + */ |
|
74 | + public function getPaymentProperties() |
|
75 | + { |
|
76 | + return $this->getPayment() instanceof \EE_Payment ? $this->getPayment()->model_field_array() : array(); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Returns an array, object, or string, however, the IPN data was received |
|
83 | - * |
|
84 | - * @return mixed |
|
85 | - */ |
|
86 | - public function getIpnData() |
|
87 | - { |
|
88 | - return $this->ipn_data; |
|
89 | - } |
|
81 | + /** |
|
82 | + * Returns an array, object, or string, however, the IPN data was received |
|
83 | + * |
|
84 | + * @return mixed |
|
85 | + */ |
|
86 | + public function getIpnData() |
|
87 | + { |
|
88 | + return $this->ipn_data; |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * ------------------------------------------------------------------------ |
11 | 11 | */ |
12 | -class EEH_URL{ |
|
12 | +class EEH_URL { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * _add_query_arg |
@@ -21,30 +21,30 @@ discard block |
||
21 | 21 | * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public static function add_query_args_and_nonce( $args = array(), $url = '', $exclude_nonce = false ) { |
|
25 | - if ( empty( $url ) ) { |
|
26 | - $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso' ); |
|
27 | - $dev_msg = $user_msg . "\n" . sprintf( |
|
28 | - __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso' ), |
|
24 | + public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) { |
|
25 | + if (empty($url)) { |
|
26 | + $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso'); |
|
27 | + $dev_msg = $user_msg."\n".sprintf( |
|
28 | + __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso'), |
|
29 | 29 | __CLASS__ |
30 | 30 | ); |
31 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
31 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
32 | 32 | } |
33 | 33 | // check that an action exists and add nonce |
34 | - if ( ! $exclude_nonce ) { |
|
35 | - if ( isset( $args['action'] ) && ! empty( $args['action'] ) ) { |
|
36 | - $args = array_merge( $args, array( $args['action'] . '_nonce' => wp_create_nonce( $args['action'] . '_nonce' ) ) ); |
|
34 | + if ( ! $exclude_nonce) { |
|
35 | + if (isset($args['action']) && ! empty($args['action'])) { |
|
36 | + $args = array_merge($args, array($args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce'))); |
|
37 | 37 | } else { |
38 | - $args = array_merge( $args, array( 'action' => 'default', 'default_nonce' => wp_create_nonce( 'default_nonce' ) ) ); |
|
38 | + $args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce'))); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | //finally, let's always add a return address (if present) :) |
43 | - $args = ! empty( $_REQUEST['action'] ) && ! isset( $_REQUEST[ 'return' ] ) |
|
44 | - ? array_merge( $args, array( 'return' => $_REQUEST['action'] ) ) |
|
43 | + $args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return']) |
|
44 | + ? array_merge($args, array('return' => $_REQUEST['action'])) |
|
45 | 45 | : $args; |
46 | 46 | |
47 | - return add_query_arg( $args, $url ); |
|
47 | + return add_query_arg($args, $url); |
|
48 | 48 | |
49 | 49 | } |
50 | 50 | |
@@ -57,17 +57,17 @@ discard block |
||
57 | 57 | * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly |
58 | 58 | * @return boolean |
59 | 59 | */ |
60 | - public static function remote_file_exists( $url, $args = array() ){ |
|
61 | - $results = wp_remote_request($url,array_merge( array( |
|
60 | + public static function remote_file_exists($url, $args = array()) { |
|
61 | + $results = wp_remote_request($url, array_merge(array( |
|
62 | 62 | 'method'=>'GET', |
63 | 63 | 'redirection'=>1 |
64 | - ), $args ) ); |
|
65 | - if( ! $results instanceof WP_Error && |
|
64 | + ), $args)); |
|
65 | + if ( ! $results instanceof WP_Error && |
|
66 | 66 | isset($results['response']) && |
67 | 67 | isset($results['response']['code']) && |
68 | - $results['response']['code'] == '200'){ |
|
68 | + $results['response']['code'] == '200') { |
|
69 | 69 | return true; |
70 | - }else{ |
|
70 | + } else { |
|
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | } |
@@ -83,29 +83,29 @@ discard block |
||
83 | 83 | * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public static function refactor_url( $url = '', $remove_query = TRUE, $base_url_only = FALSE ) { |
|
86 | + public static function refactor_url($url = '', $remove_query = TRUE, $base_url_only = FALSE) { |
|
87 | 87 | // break apart incoming URL |
88 | - $url_bits = parse_url( $url ); |
|
88 | + $url_bits = parse_url($url); |
|
89 | 89 | // HTTP or HTTPS ? |
90 | - $scheme = isset( $url_bits[ 'scheme' ] ) ? $url_bits[ 'scheme' ] . '://' : 'http://'; |
|
90 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://'; |
|
91 | 91 | // domain |
92 | - $host = isset( $url_bits[ 'host' ] ) ? $url_bits[ 'host' ] : ''; |
|
92 | + $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
93 | 93 | // if only the base URL is requested, then return that now |
94 | - if ( $base_url_only ) { |
|
95 | - return $scheme . $host; |
|
94 | + if ($base_url_only) { |
|
95 | + return $scheme.$host; |
|
96 | 96 | } |
97 | - $port = isset( $url_bits[ 'port' ] ) ? ':' . $url_bits[ 'port' ] : ''; |
|
98 | - $user = isset( $url_bits[ 'user' ] ) ? $url_bits[ 'user' ] : ''; |
|
99 | - $pass = isset( $url_bits[ 'pass' ] ) ? ':' . $url_bits[ 'pass' ] : ''; |
|
100 | - $pass = ( $user || $pass ) ? $pass . '@' : ''; |
|
101 | - $path = isset( $url_bits[ 'path' ] ) ? $url_bits[ 'path' ] : ''; |
|
97 | + $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : ''; |
|
98 | + $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
99 | + $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : ''; |
|
100 | + $pass = ($user || $pass) ? $pass.'@' : ''; |
|
101 | + $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
102 | 102 | // if the query string is not required, then return what we have so far |
103 | - if ( $remove_query ) { |
|
104 | - return $scheme . $user . $pass . $host . $port . $path; |
|
103 | + if ($remove_query) { |
|
104 | + return $scheme.$user.$pass.$host.$port.$path; |
|
105 | 105 | } |
106 | - $query = isset( $url_bits[ 'query' ] ) ? '?' . $url_bits[ 'query' ] : ''; |
|
107 | - $fragment = isset( $url_bits[ 'fragment' ] ) ? '#' . $url_bits[ 'fragment' ] : ''; |
|
108 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
106 | + $query = isset($url_bits['query']) ? '?'.$url_bits['query'] : ''; |
|
107 | + $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : ''; |
|
108 | + return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -118,29 +118,29 @@ discard block |
||
118 | 118 | * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will simply return the query string |
119 | 119 | * @return string|array |
120 | 120 | */ |
121 | - public static function get_query_string( $url = '', $as_array = TRUE ) { |
|
121 | + public static function get_query_string($url = '', $as_array = TRUE) { |
|
122 | 122 | // break apart incoming URL |
123 | - $url_bits = parse_url( $url ); |
|
123 | + $url_bits = parse_url($url); |
|
124 | 124 | // grab query string from URL |
125 | - $query = isset( $url_bits[ 'query' ] ) ? $url_bits[ 'query' ] : ''; |
|
125 | + $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
126 | 126 | // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
127 | - if ( ! $as_array ) { |
|
127 | + if ( ! $as_array) { |
|
128 | 128 | return $query; |
129 | 129 | } |
130 | 130 | // if no query string exists then just return an empty array now |
131 | - if ( empty( $query )) { |
|
131 | + if (empty($query)) { |
|
132 | 132 | return array(); |
133 | 133 | } |
134 | 134 | // empty array to hold results |
135 | 135 | $query_params = array(); |
136 | 136 | // now break apart the query string into separate params |
137 | - $query = explode( '&', $query ); |
|
137 | + $query = explode('&', $query); |
|
138 | 138 | // loop thru our query params |
139 | - foreach ( $query as $query_args ) { |
|
139 | + foreach ($query as $query_args) { |
|
140 | 140 | // break apart the key value pairs |
141 | - $query_args = explode( '=', $query_args ); |
|
141 | + $query_args = explode('=', $query_args); |
|
142 | 142 | // and add to our results array |
143 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
143 | + $query_params[$query_args[0]] = $query_args[1]; |
|
144 | 144 | } |
145 | 145 | return $query_params; |
146 | 146 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * prevent_prefetching |
152 | 152 | * @return void |
153 | 153 | */ |
154 | - public static function prevent_prefetching(){ |
|
154 | + public static function prevent_prefetching() { |
|
155 | 155 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
156 | 156 | remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
157 | 157 | } |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | * @param string $prefix Use this to prefix the string with something. |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public static function generate_unique_token( $prefix = '' ) { |
|
170 | - $token = md5( uniqid() . mt_rand() ); |
|
171 | - return $prefix ? $prefix . '_' . $token : $token; |
|
169 | + public static function generate_unique_token($prefix = '') { |
|
170 | + $token = md5(uniqid().mt_rand()); |
|
171 | + return $prefix ? $prefix.'_'.$token : $token; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * add_nocache_headers |
178 | 178 | * @return void |
179 | 179 | */ |
180 | - public static function add_nocache_headers(){ |
|
180 | + public static function add_nocache_headers() { |
|
181 | 181 | // add no cache headers |
182 | 182 | // add_action( 'wp_head' , array( 'EED_Single_Page_Checkout', 'nocache_headers' ), 10 ); |
183 | 183 | // plus a little extra for nginx |
@@ -194,19 +194,19 @@ discard block |
||
194 | 194 | * @param string $server_variable |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public static function filter_input_server_url( $server_variable = 'REQUEST_URI' ){ |
|
197 | + public static function filter_input_server_url($server_variable = 'REQUEST_URI') { |
|
198 | 198 | $URL = ''; |
199 | 199 | $server_variables = array( |
200 | 200 | 'REQUEST_URI' => 1, |
201 | 201 | 'HTTP_HOST' => 1, |
202 | 202 | 'PHP_SELF' => 1, |
203 | 203 | ); |
204 | - $server_variable = strtoupper( $server_variable ); |
|
204 | + $server_variable = strtoupper($server_variable); |
|
205 | 205 | // whitelist INPUT_SERVER var |
206 | - if ( isset( $server_variables[ $server_variable ] ) ) { |
|
207 | - $URL = filter_input( INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE ); |
|
208 | - if ( empty( $URL ) ) { |
|
209 | - $URL = esc_url( $_SERVER[ $server_variable ] ); |
|
206 | + if (isset($server_variables[$server_variable])) { |
|
207 | + $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
208 | + if (empty($URL)) { |
|
209 | + $URL = esc_url($_SERVER[$server_variable]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | return $URL; |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | * @return string |
220 | 220 | */ |
221 | 221 | public static function current_url() { |
222 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
222 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
223 | 223 | $url = is_ssl() ? 'https://' : 'http://'; |
224 | - $url .= \EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
225 | - $url .= \EEH_URL::filter_input_server_url( 'REQUEST_URI' ); |
|
224 | + $url .= \EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
225 | + $url .= \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
226 | 226 | } else { |
227 | 227 | $url = 'unknown'; |
228 | 228 | } |