@@ -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 | /** |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | protected $_reports_template_data = array(); |
38 | 38 | |
39 | 39 | |
40 | - public function __construct( $routing = TRUE ) { |
|
41 | - parent::__construct( $routing ); |
|
42 | - define( 'REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
43 | - define( 'REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
44 | - define( 'REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
40 | + public function __construct($routing = TRUE) { |
|
41 | + parent::__construct($routing); |
|
42 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
43 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
44 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | 48 | protected function _extend_page_config() { |
49 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
49 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
50 | 50 | |
51 | - $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
|
52 | - $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
53 | - $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
|
51 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0; |
|
52 | + $att_id = ! empty($this->_req_data['ATT_ID']) ? ! is_array($this->_req_data['ATT_ID']) : 0; |
|
53 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id; |
|
54 | 54 | |
55 | 55 | $new_page_routes = array( |
56 | 56 | 'reports' => array( |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | ) |
90 | 90 | ); |
91 | 91 | |
92 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
92 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
93 | 93 | |
94 | 94 | $new_page_config = array( |
95 | 95 | 'reports' => array( |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | 'filename' => 'registrations_event_checkin_other' |
135 | 135 | ) |
136 | 136 | ), |
137 | - 'help_tour' => array( 'Event_Checkin_Help_Tour' ), |
|
138 | - 'qtips' => array('Registration_List_Table_Tips' ), |
|
137 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
138 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
139 | 139 | 'list_table' => 'EE_Event_Registrations_List_Table', |
140 | 140 | 'metaboxes' => array(), |
141 | 141 | 'require_nonce' => FALSE |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | ), |
154 | 154 | ); |
155 | 155 | |
156 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
156 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
157 | 157 | $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
158 | 158 | $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
159 | 159 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | protected function _ajax_hooks() { |
164 | 164 | parent::_ajax_hooks(); |
165 | - add_action( 'wp_ajax_get_newsletter_form_content', array( $this, 'get_newsletter_form_content' ) ); |
|
165 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -172,20 +172,20 @@ discard block |
||
172 | 172 | |
173 | 173 | //if newsletter message type is active then let's add filter and load js for it. |
174 | 174 | EE_Registry::instance()->load_helper('MSG_Template'); |
175 | - if ( EEH_MSG_Template::is_mt_active('newsletter') ) { |
|
175 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
176 | 176 | //enqueue newsletter js |
177 | - wp_enqueue_script( 'ee-newsletter-trigger', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
178 | - wp_enqueue_style( 'ee-newsletter-trigger-css', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', array(), EVENT_ESPRESSO_VERSION ); |
|
177 | + wp_enqueue_script('ee-newsletter-trigger', REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, TRUE); |
|
178 | + wp_enqueue_style('ee-newsletter-trigger-css', REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', array(), EVENT_ESPRESSO_VERSION); |
|
179 | 179 | //hook in buttons for newsletter message type trigger. |
180 | - add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array( $this, 'add_newsletter_action_buttons'), 10 ); |
|
180 | + add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array($this, 'add_newsletter_action_buttons'), 10); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | 185 | |
186 | 186 | public function load_scripts_styles_reports() { |
187 | - wp_register_script( 'ee-reg-reports-js', REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', array( 'google-charts' ), EVENT_ESPRESSO_VERSION, true ); |
|
188 | - wp_enqueue_script( 'ee-reg-reports-js' ); |
|
187 | + wp_register_script('ee-reg-reports-js', REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', array('google-charts'), EVENT_ESPRESSO_VERSION, true); |
|
188 | + wp_enqueue_script('ee-reg-reports-js'); |
|
189 | 189 | $this->_registration_reports_js_setup(); |
190 | 190 | } |
191 | 191 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | 'slug' => 'all', |
218 | 218 | 'label' => __('All', 'event_espresso'), |
219 | 219 | 'count' => 0, |
220 | - 'bulk_action' => !isset( $this->_req_data['event_id'] ) ? array() : array( |
|
220 | + 'bulk_action' => ! isset($this->_req_data['event_id']) ? array() : array( |
|
221 | 221 | 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
222 | 222 | //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
223 | 223 | ) |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | 'slug' => 'all', |
236 | 236 | 'label' => __('All', 'event_espresso'), |
237 | 237 | 'count' => 0, |
238 | - 'bulk_action' => array( 'delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso') ) |
|
238 | + 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')) |
|
239 | 239 | ), |
240 | 240 | ); |
241 | 241 | } |
@@ -251,20 +251,20 @@ discard block |
||
251 | 251 | */ |
252 | 252 | public function get_newsletter_form_content() { |
253 | 253 | //do a nonce check cause we're not coming in from an normal route here. |
254 | - $nonce = isset( $this->_req_data['get_newsletter_form_content_nonce'] ) ? sanitize_text_field( $this->_req_data['get_newsletter_form_content_nonce'] ) : ''; |
|
254 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field($this->_req_data['get_newsletter_form_content_nonce']) : ''; |
|
255 | 255 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
256 | 256 | |
257 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
257 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
258 | 258 | //let's get the mtp for the incoming MTP_ ID |
259 | - if ( !isset( $this->_req_data['GRP_ID'] ) ) { |
|
260 | - EE_Error::add_error( __('There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
259 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
260 | + EE_Error::add_error(__('There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
261 | 261 | $this->_template_args['success'] = FALSE; |
262 | 262 | $this->_template_args['error'] = TRUE; |
263 | 263 | $this->_return_json(); |
264 | 264 | } |
265 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_req_data['GRP_ID'] ); |
|
266 | - if ( ! $MTPG instanceof EE_Message_Template_Group ) { |
|
267 | - EE_Error::add_error( sprintf( __('The GRP_ID given (%d) does not appear to have a corresponding row in the database.', 'event_espresso'), $this->_req_data['GRP_ID'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
265 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
266 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
267 | + EE_Error::add_error(sprintf(__('The GRP_ID given (%d) does not appear to have a corresponding row in the database.', 'event_espresso'), $this->_req_data['GRP_ID']), __FILE__, __FUNCTION__, __LINE__); |
|
268 | 268 | $this->_template_args['success'] = FALSE; |
269 | 269 | $this->_template_args['error'] = TRUE; |
270 | 270 | $this->_return_json(); |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | $MTPs = $MTPG->context_templates(); |
274 | 274 | $MTPs = $MTPs['attendee']; |
275 | 275 | $template_fields = array(); |
276 | - foreach ( $MTPs as $MTP ) { |
|
276 | + foreach ($MTPs as $MTP) { |
|
277 | 277 | $field = $MTP->get('MTP_template_field'); |
278 | - if ( $field == 'content' ) { |
|
278 | + if ($field == 'content') { |
|
279 | 279 | $content = $MTP->get('MTP_content'); |
280 | - if ( !empty( $content['newsletter_content'] ) ) { |
|
280 | + if ( ! empty($content['newsletter_content'])) { |
|
281 | 281 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
282 | 282 | } |
283 | 283 | continue; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $this->_template_args['data'] = array( |
291 | 291 | 'batch_message_from' => isset($template_fields['from']) ? $template_fields['from'] : '', |
292 | 292 | 'batch_message_subject' => isset($template_fields['subject']) ? $template_fields['subject'] : '', |
293 | - 'batch_message_content' => isset( $template_fields['newsletter_content'] ) ? $template_fields['newsletter_content'] : '' |
|
293 | + 'batch_message_content' => isset($template_fields['newsletter_content']) ? $template_fields['newsletter_content'] : '' |
|
294 | 294 | ); |
295 | 295 | $this->_return_json(); |
296 | 296 | } |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @param EE_Admin_List_Table $list_table |
307 | 307 | * @return string html string for extra buttons |
308 | 308 | */ |
309 | - public function add_newsletter_action_buttons( EE_Admin_List_Table $list_table ) { |
|
310 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_newsletter_selected_send' ) ) { |
|
309 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) { |
|
310 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_newsletter_selected_send')) { |
|
311 | 311 | return ''; |
312 | 312 | } |
313 | 313 | |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | 'event_registrations', |
317 | 317 | 'default' |
318 | 318 | ); |
319 | - if ( $this->_current_page == 'espresso_registrations' && in_array( $this->_req_action, $routes_to_add_to ) ) { |
|
320 | - if ( ( $this->_req_action == 'event_registrations' && empty( $this->_req_data['event_id'] ) ) || ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'trash' ) ) { |
|
319 | + if ($this->_current_page == 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
320 | + if (($this->_req_action == 'event_registrations' && empty($this->_req_data['event_id'])) || (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash')) { |
|
321 | 321 | echo ''; |
322 | 322 | } else { |
323 | - $button_text = sprintf( __('Send Batch Message (%s selected)', 'event_espresso'), '<span class="send-selected-newsletter-count">0</span>' ); |
|
324 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' . $button_text . '</button>'; |
|
325 | - add_action('admin_footer', array( $this, 'newsletter_send_form_skeleton') ); |
|
323 | + $button_text = sprintf(__('Send Batch Message (%s selected)', 'event_espresso'), '<span class="send-selected-newsletter-count">0</span>'); |
|
324 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>'.$button_text.'</button>'; |
|
325 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | } |
@@ -334,38 +334,38 @@ discard block |
||
334 | 334 | $list_table = $this->_list_table_object; |
335 | 335 | $codes = array(); |
336 | 336 | //need to templates for the newsletter message type for the template selector. |
337 | - $values[] = array( 'text' => __('Select Template to Use', 'event_espresso'), 'id' => 0 ); |
|
338 | - $mtps = EEM_Message_Template_Group::instance()->get_all( array( array( 'MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email' ) ) ); |
|
339 | - foreach ( $mtps as $mtp ) { |
|
337 | + $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
338 | + $mtps = EEM_Message_Template_Group::instance()->get_all(array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email'))); |
|
339 | + foreach ($mtps as $mtp) { |
|
340 | 340 | $name = $mtp->name(); |
341 | 341 | $values[] = array( |
342 | - 'text' => empty( $name ) ? __('Global', 'event_espresso') : $name, |
|
342 | + 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
343 | 343 | 'id' => $mtp->ID() |
344 | 344 | ); |
345 | 345 | } |
346 | 346 | |
347 | 347 | //need to get a list of shortcodes that are available for the newsletter message type. |
348 | 348 | EE_Registry::instance()->load_helper('MSG_Template'); |
349 | - $shortcodes = EEH_MSG_Template::get_shortcodes( 'newsletter', 'email', array(), 'attendee', FALSE ); |
|
350 | - foreach ( $shortcodes as $field => $shortcode_array ) { |
|
351 | - $codes[$field] = implode(', ', array_keys($shortcode_array ) ); |
|
349 | + $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', FALSE); |
|
350 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
351 | + $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | $shortcodes = $codes; |
355 | 355 | |
356 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
356 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
357 | 357 | $form_template_args = array( |
358 | 358 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
359 | 359 | 'form_route' => 'newsletter_selected_send', |
360 | 360 | 'form_nonce_name' => 'newsletter_selected_send_nonce', |
361 | - 'form_nonce' => wp_create_nonce( 'newsletter_selected_send_nonce' ), |
|
361 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
362 | 362 | 'redirect_back_to' => $this->_req_action, |
363 | - 'ajax_nonce' => wp_create_nonce( 'get_newsletter_form_content_nonce'), |
|
364 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values ), |
|
363 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
364 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
365 | 365 | 'shortcodes' => $shortcodes, |
366 | 366 | 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration' |
367 | 367 | ); |
368 | - EEH_Template::display_template( $form_template, $form_template_args ); |
|
368 | + EEH_Template::display_template($form_template, $form_template_args); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | protected function _newsletter_selected_send() { |
381 | 381 | $success = TRUE; |
382 | 382 | //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
383 | - if ( empty( $this->_req_data['newsletter_mtp_selected'] ) ) { |
|
383 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
384 | 384 | EE_Error::add_error( |
385 | 385 | __( |
386 | 386 | 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $success = FALSE; |
392 | 392 | } |
393 | 393 | |
394 | - if ( $success ) { |
|
394 | + if ($success) { |
|
395 | 395 | //update Message template in case there are any changes |
396 | 396 | $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
397 | 397 | $this->_req_data['newsletter_mtp_selected'] |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
400 | 400 | ? $Message_Template_Group->context_templates() |
401 | 401 | : array(); |
402 | - if ( empty( $Message_Templates ) ) { |
|
402 | + if (empty($Message_Templates)) { |
|
403 | 403 | EE_Error::add_error( |
404 | 404 | __( |
405 | 405 | 'Unable to retrieve message template fields from the db. Messages not sent.', |
@@ -410,25 +410,25 @@ discard block |
||
410 | 410 | } |
411 | 411 | |
412 | 412 | //let's just update the specific fields |
413 | - foreach ( $Message_Templates['attendee'] as $Message_Template ) { |
|
414 | - if ( $Message_Template instanceof EE_Message_Template ) { |
|
415 | - $field = $Message_Template->get( 'MTP_template_field' ); |
|
416 | - $content = $Message_Template->get( 'MTP_content' ); |
|
413 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
414 | + if ($Message_Template instanceof EE_Message_Template) { |
|
415 | + $field = $Message_Template->get('MTP_template_field'); |
|
416 | + $content = $Message_Template->get('MTP_content'); |
|
417 | 417 | $new_content = $content; |
418 | - switch ( $field ) { |
|
418 | + switch ($field) { |
|
419 | 419 | case 'from' : |
420 | - $new_content = ! empty( $this->_req_data['batch_message']['from'] ) |
|
420 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
421 | 421 | ? $this->_req_data['batch_message']['from'] |
422 | 422 | : $content; |
423 | 423 | break; |
424 | 424 | case 'subject' : |
425 | - $new_content = ! empty( $this->_req_data['batch_message']['subject'] ) |
|
425 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
426 | 426 | ? $this->_req_data['batch_message']['subject'] |
427 | 427 | : $content; |
428 | 428 | break; |
429 | 429 | case 'content' : |
430 | 430 | $new_content = $content; |
431 | - $new_content['newsletter_content'] = ! empty( $this->_req_data['batch_message']['content'] ) |
|
431 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
432 | 432 | ? $this->_req_data['batch_message']['content'] |
433 | 433 | : $content['newsletter_content']; |
434 | 434 | break; |
@@ -436,35 +436,35 @@ discard block |
||
436 | 436 | continue; |
437 | 437 | break; |
438 | 438 | } |
439 | - $Message_Template->set( 'MTP_content', $new_content ); |
|
439 | + $Message_Template->set('MTP_content', $new_content); |
|
440 | 440 | $Message_Template->save(); |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
445 | - $id_type = ! empty( $this->_req_data['batch_message']['id_type'] ) |
|
445 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
446 | 446 | ? $this->_req_data['batch_message']['id_type'] |
447 | 447 | : 'registration'; |
448 | 448 | |
449 | 449 | //id_type will affect how we assemble the ids. |
450 | - $ids = ! empty( $this->_req_data['batch_message']['ids'] ) |
|
451 | - ? json_decode( stripslashes($this->_req_data['batch_message']['ids']) ) |
|
450 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
451 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
452 | 452 | : array(); |
453 | 453 | |
454 | 454 | $registrations_used_for_contact_data = array(); |
455 | 455 | //using switch because eventually we'll have other contexts that will be used for generating messages. |
456 | - switch ( $id_type ) { |
|
456 | + switch ($id_type) { |
|
457 | 457 | case 'registration' : |
458 | 458 | $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
459 | 459 | array( |
460 | 460 | array( |
461 | - 'REG_ID' => array( 'IN', $ids ) |
|
461 | + 'REG_ID' => array('IN', $ids) |
|
462 | 462 | ) |
463 | 463 | ) |
464 | 464 | ); |
465 | 465 | break; |
466 | 466 | case 'contact' : |
467 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_latest_registration_for_each_of_given_contacts( $ids ); |
|
467 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_latest_registration_for_each_of_given_contacts($ids); |
|
468 | 468 | break; |
469 | 469 | } |
470 | 470 | do_action( |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | //kept for backward compat, internally we no longer use this action. |
476 | 476 | //@deprecated 4.8.36.rc.002 |
477 | 477 | $contacts = $id_type == 'registration' |
478 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids( $ids ) |
|
479 | - : EEM_Attendee::instance()->get_all( array( array( 'ATT_ID' => array('in', $ids ) ) ) ); |
|
478 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
479 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
480 | 480 | do_action( |
481 | 481 | 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
482 | 482 | $contacts, |
@@ -484,11 +484,11 @@ discard block |
||
484 | 484 | ); |
485 | 485 | } |
486 | 486 | $query_args = array( |
487 | - 'action' => !empty( $this->_req_data['redirect_back_to'] ) |
|
487 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
488 | 488 | ? $this->_req_data['redirect_back_to'] |
489 | 489 | : 'default' |
490 | 490 | ); |
491 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
491 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | * @return void |
511 | 511 | */ |
512 | 512 | protected function _registration_reports() { |
513 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
514 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_reports_template_data, true ); |
|
513 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
514 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_reports_template_data, true); |
|
515 | 515 | // the final template wrapper |
516 | 516 | $this->display_admin_page_with_no_sidebar(); |
517 | 517 | |
@@ -524,29 +524,29 @@ discard block |
||
524 | 524 | * |
525 | 525 | * @return string |
526 | 526 | */ |
527 | - private function _registrations_per_day_report( $period = '-1 month' ) { |
|
527 | + private function _registrations_per_day_report($period = '-1 month') { |
|
528 | 528 | $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
529 | 529 | |
530 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report( $period ); |
|
531 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
530 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
531 | + EE_Registry::instance()->load_helper('Template'); |
|
532 | 532 | |
533 | 533 | $results = (array) $results; |
534 | 534 | $regs = array(); |
535 | 535 | $subtitle = ''; |
536 | 536 | |
537 | - if( $results ) { |
|
537 | + if ($results) { |
|
538 | 538 | $column_titles = array(); |
539 | 539 | $tracker = 0; |
540 | - foreach ( $results as $result ) { |
|
540 | + foreach ($results as $result) { |
|
541 | 541 | $report_column_values = array(); |
542 | - foreach( $result as $property_name => $property_value ) { |
|
542 | + foreach ($result as $property_name => $property_value) { |
|
543 | 543 | $property_value = $property_name == 'Registration_REG_date' ? $property_value : (int) $property_value; |
544 | 544 | $report_column_values[] = $property_value; |
545 | - if ( $tracker === 0 ) { |
|
546 | - if ( $property_name == 'Registration_REG_date' ) { |
|
547 | - $column_titles[] = __( 'Date (only days with registrations are shown)', 'event_espresso' ); |
|
545 | + if ($tracker === 0) { |
|
546 | + if ($property_name == 'Registration_REG_date') { |
|
547 | + $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
548 | 548 | } else { |
549 | - $column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' ); |
|
549 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | } |
@@ -555,37 +555,37 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | //make sure the column_titles is pushed to the beginning of the array |
558 | - array_unshift( $regs, $column_titles ); |
|
558 | + array_unshift($regs, $column_titles); |
|
559 | 559 | //setup the date range. |
560 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
561 | - $DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() ); |
|
562 | - $beginning_date = new DateTime( "now " . $period, $DateTimeZone ); |
|
563 | - $ending_date = new DateTime( "now", $DateTimeZone ); |
|
560 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
561 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
562 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
563 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
564 | 564 | $subtitle = sprintf( |
565 | - _x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ), |
|
566 | - $beginning_date->format( 'Y-m-d' ), |
|
567 | - $ending_date->format( 'Y-m-d' ) |
|
565 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
566 | + $beginning_date->format('Y-m-d'), |
|
567 | + $ending_date->format('Y-m-d') |
|
568 | 568 | ); |
569 | 569 | } |
570 | 570 | |
571 | - $report_title = __( 'Total Registrations per Day', 'event_espresso' ); |
|
571 | + $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
572 | 572 | |
573 | 573 | $report_params = array( |
574 | 574 | 'title' => $report_title, |
575 | 575 | 'subtitle' => $subtitle, |
576 | 576 | 'id' => $report_ID, |
577 | 577 | 'regs' => $regs, |
578 | - 'noResults' => empty( $regs ), |
|
578 | + 'noResults' => empty($regs), |
|
579 | 579 | 'noRegsMsg' => sprintf( |
580 | 580 | __( |
581 | 581 | '%sThere are currently no registration records in the last month for this report.%s', |
582 | 582 | 'event_espresso' |
583 | 583 | ), |
584 | - '<h2>' . $report_title . '</h2><p>', |
|
584 | + '<h2>'.$report_title.'</h2><p>', |
|
585 | 585 | '</p>' |
586 | 586 | ), |
587 | 587 | ); |
588 | - wp_localize_script( 'ee-reg-reports-js', 'regPerDay', $report_params ); |
|
588 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
589 | 589 | |
590 | 590 | return $report_ID; |
591 | 591 | } |
@@ -597,30 +597,30 @@ discard block |
||
597 | 597 | * |
598 | 598 | * @return string |
599 | 599 | */ |
600 | - private function _registrations_per_event_report( $period = '-1 month' ) { |
|
600 | + private function _registrations_per_event_report($period = '-1 month') { |
|
601 | 601 | |
602 | 602 | $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
603 | 603 | |
604 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report( $period ); |
|
605 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
604 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
605 | + EE_Registry::instance()->load_helper('Template'); |
|
606 | 606 | |
607 | 607 | $results = (array) $results; |
608 | 608 | $regs = array(); |
609 | 609 | $subtitle = ''; |
610 | 610 | |
611 | - if ( $results ) { |
|
611 | + if ($results) { |
|
612 | 612 | $column_titles = array(); |
613 | 613 | $tracker = 0; |
614 | - foreach ( $results as $result ) { |
|
614 | + foreach ($results as $result) { |
|
615 | 615 | $report_column_values = array(); |
616 | - foreach( $result as $property_name => $property_value ) { |
|
617 | - $property_value = $property_name == 'Registration_Event' ? wp_trim_words( $property_value, 4, '...' ) : (int) $property_value; |
|
616 | + foreach ($result as $property_name => $property_value) { |
|
617 | + $property_value = $property_name == 'Registration_Event' ? wp_trim_words($property_value, 4, '...') : (int) $property_value; |
|
618 | 618 | $report_column_values[] = $property_value; |
619 | - if ( $tracker === 0 ) { |
|
620 | - if ( $property_name == 'Registration_Event' ) { |
|
621 | - $column_titles[] = __( 'Event', 'event_espresso' ); |
|
619 | + if ($tracker === 0) { |
|
620 | + if ($property_name == 'Registration_Event') { |
|
621 | + $column_titles[] = __('Event', 'event_espresso'); |
|
622 | 622 | } else { |
623 | - $column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' ); |
|
623 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
624 | 624 | } |
625 | 625 | } |
626 | 626 | } |
@@ -629,38 +629,38 @@ discard block |
||
629 | 629 | } |
630 | 630 | |
631 | 631 | //make sure the column_titles is pushed to the beginning of the array |
632 | - array_unshift( $regs, $column_titles ); |
|
632 | + array_unshift($regs, $column_titles); |
|
633 | 633 | |
634 | 634 | //setup the date range. |
635 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
636 | - $DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() ); |
|
637 | - $beginning_date = new DateTime( "now " . $period, $DateTimeZone ); |
|
638 | - $ending_date = new DateTime( "now", $DateTimeZone ); |
|
635 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
636 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
637 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
638 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
639 | 639 | $subtitle = sprintf( |
640 | - _x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ), |
|
641 | - $beginning_date->format( 'Y-m-d' ), |
|
642 | - $ending_date->format( 'Y-m-d' ) |
|
640 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
641 | + $beginning_date->format('Y-m-d'), |
|
642 | + $ending_date->format('Y-m-d') |
|
643 | 643 | ); |
644 | 644 | } |
645 | 645 | |
646 | - $report_title = __( 'Total Registrations per Event', 'event_espresso' ); |
|
646 | + $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
647 | 647 | |
648 | 648 | $report_params = array( |
649 | 649 | 'title' => $report_title, |
650 | 650 | 'subtitle' => $subtitle, |
651 | 651 | 'id' => $report_ID, |
652 | 652 | 'regs' => $regs, |
653 | - 'noResults' => empty( $regs ), |
|
653 | + 'noResults' => empty($regs), |
|
654 | 654 | 'noRegsMsg' => sprintf( |
655 | 655 | __( |
656 | 656 | '%sThere are currently no registration records in the last month for this report.%s', |
657 | 657 | 'event_espresso' |
658 | 658 | ), |
659 | - '<h2>' . $report_title . '</h2><p>', |
|
659 | + '<h2>'.$report_title.'</h2><p>', |
|
660 | 660 | '</p>' |
661 | 661 | ), |
662 | 662 | ); |
663 | - wp_localize_script( 'ee-reg-reports-js', 'regPerEvent', $report_params ); |
|
663 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
664 | 664 | |
665 | 665 | return $report_ID; |
666 | 666 | } |
@@ -674,8 +674,8 @@ discard block |
||
674 | 674 | * @return void |
675 | 675 | */ |
676 | 676 | protected function _registration_checkin_list_table() { |
677 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
678 | - $reg_id = isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : null; |
|
677 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
678 | + $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
679 | 679 | $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
680 | 680 | $this->_admin_page_title .= $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $reg->event_ID()), 'add-new-h2'); |
681 | 681 | |
@@ -689,15 +689,15 @@ discard block |
||
689 | 689 | 'desc' => __('This indicates the attendee has been checked out', 'event_espresso') |
690 | 690 | ) |
691 | 691 | ); |
692 | - $this->_template_args['after_list_table'] = $this->_display_legend( $legend_items ); |
|
692 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
693 | 693 | |
694 | 694 | |
695 | - $dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL; |
|
696 | - $go_back_url = !empty( $reg_id ) ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), 'DTT_ID' => $dtt_id ), $this->_admin_base_url ) : ''; |
|
695 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL; |
|
696 | + $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), 'DTT_ID' => $dtt_id), $this->_admin_base_url) : ''; |
|
697 | 697 | |
698 | - $this->_template_args['before_list_table'] = !empty( $reg_id ) && !empty( $dtt_id ) ? '<h2>' . sprintf(__("%s's check in records for %s at the event, %s", 'event_espresso'), '<span id="checkin-attendee-name">' . EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Attendee')->full_name() . '</span>', '<span id="checkin-dtt"><a href="' . $go_back_url . '">' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->start_date_and_time() . ' - ' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->end_date_and_time() . '</a></span>', '<span id="checkin-event-name">' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->get_first_related('Event')->get('EVT_name') . '</span>' ) . '</h2>' : ''; |
|
699 | - $this->_template_args['list_table_hidden_fields'] = !empty( $reg_id ) ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
700 | - $this->_template_args['list_table_hidden_fields'] .= !empty( $dtt_id ) ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
698 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) ? '<h2>'.sprintf(__("%s's check in records for %s at the event, %s", 'event_espresso'), '<span id="checkin-attendee-name">'.EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Attendee')->full_name().'</span>', '<span id="checkin-dtt"><a href="'.$go_back_url.'">'.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->start_date_and_time().' - '.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->end_date_and_time().'</a></span>', '<span id="checkin-event-name">'.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->get_first_related('Event')->get('EVT_name').'</span>').'</h2>' : ''; |
|
699 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : ''; |
|
700 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
701 | 701 | |
702 | 702 | $this->display_admin_list_table_page_with_no_sidebar(); |
703 | 703 | } |
@@ -710,24 +710,24 @@ discard block |
||
710 | 710 | */ |
711 | 711 | public function toggle_checkin_status() { |
712 | 712 | //first make sure we have the necessary data |
713 | - if ( !isset( $this->_req_data['_regid'] ) ) { |
|
714 | - EE_Error::add_error( __('There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
713 | + if ( ! isset($this->_req_data['_regid'])) { |
|
714 | + EE_Error::add_error(__('There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
715 | 715 | $this->_template_args['success'] = FALSE; |
716 | 716 | $this->_template_args['error'] = TRUE; |
717 | 717 | $this->_return_json(); |
718 | 718 | }; |
719 | 719 | |
720 | 720 | //do a nonce check cause we're not coming in from an normal route here. |
721 | - $nonce = isset( $this->_req_data['checkinnonce'] ) ? sanitize_text_field( $this->_req_data['checkinnonce'] ) : ''; |
|
721 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) : ''; |
|
722 | 722 | $nonce_ref = 'checkin_nonce'; |
723 | 723 | |
724 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
724 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
725 | 725 | |
726 | 726 | //beautiful! Made it this far so let's get the status. |
727 | 727 | $new_status = $this->_toggle_checkin_status(); |
728 | 728 | |
729 | 729 | //setup new class to return via ajax |
730 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' . $new_status; |
|
730 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-'.$new_status; |
|
731 | 731 | $this->_template_args['success'] = TRUE; |
732 | 732 | $this->_return_json(); |
733 | 733 | } |
@@ -747,32 +747,32 @@ discard block |
||
747 | 747 | //first let's get the query args out of the way for the redirect |
748 | 748 | $query_args = array( |
749 | 749 | 'action' => 'event_registrations', |
750 | - 'event_id' => isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : NULL, |
|
751 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL |
|
750 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : NULL, |
|
751 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL |
|
752 | 752 | ); |
753 | 753 | $new_status = FALSE; |
754 | 754 | |
755 | 755 | // bulk action check in toggle |
756 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) { |
|
756 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
757 | 757 | // cycle thru checkboxes |
758 | - while ( list( $REG_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
759 | - $DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL; |
|
758 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
759 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL; |
|
760 | 760 | $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
761 | 761 | } |
762 | 762 | |
763 | - } elseif ( isset( $this->_req_data['_regid'] ) ) { |
|
763 | + } elseif (isset($this->_req_data['_regid'])) { |
|
764 | 764 | //coming from ajax request |
765 | - $DTT_ID = isset( $this->_req_data['dttid'] ) ? $this->_req_data['dttid'] : NULL; |
|
765 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : NULL; |
|
766 | 766 | $query_args['DTT_ID'] = $DTT_ID; |
767 | 767 | $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
768 | 768 | } else { |
769 | - EE_Error::add_error(__('Missing some required data to toggle the Check-in', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
769 | + EE_Error::add_error(__('Missing some required data to toggle the Check-in', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
770 | 770 | } |
771 | 771 | |
772 | - if ( defined('DOING_AJAX' ) ) |
|
772 | + if (defined('DOING_AJAX')) |
|
773 | 773 | return $new_status; |
774 | 774 | |
775 | - $this->_redirect_after_action( FALSE,'', '', $query_args, TRUE ); |
|
775 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
776 | 776 | |
777 | 777 | } |
778 | 778 | |
@@ -788,11 +788,11 @@ discard block |
||
788 | 788 | */ |
789 | 789 | private function _toggle_checkin($REG_ID, $DTT_ID) { |
790 | 790 | $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
791 | - $new_status = $REG->toggle_checkin_status( $DTT_ID ); |
|
792 | - if ( $new_status !== FALSE ) { |
|
793 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID) ); |
|
791 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
792 | + if ($new_status !== FALSE) { |
|
793 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
794 | 794 | } else { |
795 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, TRUE), __FILE__, __FUNCTION__, __LINE__ ); |
|
795 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, TRUE), __FILE__, __FUNCTION__, __LINE__); |
|
796 | 796 | $new_status = FALSE; |
797 | 797 | } |
798 | 798 | return $new_status; |
@@ -808,28 +808,28 @@ discard block |
||
808 | 808 | protected function _delete_checkin_rows() { |
809 | 809 | $query_args = array( |
810 | 810 | 'action' => 'registration_checkins', |
811 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0, |
|
812 | - '_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0 |
|
811 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
812 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0 |
|
813 | 813 | ); |
814 | - if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
815 | - while ( list( $CHK_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
814 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
815 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
816 | 816 | $errors = 0; |
817 | - if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID ) ) { |
|
817 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
818 | 818 | $errors++; |
819 | 819 | } |
820 | 820 | } |
821 | 821 | } else { |
822 | - EE_Error::add_error(__('So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
823 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
822 | + EE_Error::add_error(__('So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
823 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
824 | 824 | } |
825 | 825 | |
826 | - if ( $errors > 0 ) { |
|
827 | - EE_Error::add_error( sprintf( __('There were %d records that did not delete successfully', 'event_espresso'), $errors ), __FILE__, __FUNCTION__, __LINE__ ); |
|
826 | + if ($errors > 0) { |
|
827 | + EE_Error::add_error(sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), __FILE__, __FUNCTION__, __LINE__); |
|
828 | 828 | } else { |
829 | - EE_Error::add_success( __('Records were successfully deleted', 'event_espresso') ); |
|
829 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
830 | 830 | } |
831 | 831 | |
832 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
832 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | |
@@ -841,20 +841,20 @@ discard block |
||
841 | 841 | protected function _delete_checkin_row() { |
842 | 842 | $query_args = array( |
843 | 843 | 'action' => 'registration_checkins', |
844 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0, |
|
845 | - '_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0 |
|
844 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
845 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0 |
|
846 | 846 | ); |
847 | 847 | |
848 | - if ( !empty( $this->_req_data['CHK_ID'] ) ) { |
|
849 | - if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'] ) ) { |
|
850 | - EE_Error::add_error(__('Something went wrong and this check-in record was not deleted', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
848 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
849 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
850 | + EE_Error::add_error(__('Something went wrong and this check-in record was not deleted', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
851 | 851 | } else { |
852 | - EE_Error::add_success( __('Check-In record successfully deleted', 'event_espresso') ); |
|
852 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
853 | 853 | } |
854 | 854 | } else { |
855 | - EE_Error::add_error(__('In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
855 | + EE_Error::add_error(__('In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
856 | 856 | } |
857 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
857 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | |
@@ -867,8 +867,8 @@ discard block |
||
867 | 867 | * @return void |
868 | 868 | */ |
869 | 869 | protected function _event_registrations_list_table() { |
870 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
871 | - $this->_admin_page_title .= isset( $this->_req_data['event_id'] ) ? $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $this->_req_data['event_id']), 'add-new-h2') : ''; |
|
870 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
871 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) ? $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $this->_req_data['event_id']), 'add-new-h2') : ''; |
|
872 | 872 | |
873 | 873 | $legend_items = array( |
874 | 874 | 'star-icon' => array( |
@@ -892,31 +892,31 @@ discard block |
||
892 | 892 | 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso') |
893 | 893 | ), |
894 | 894 | 'approved_status' => array( |
895 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
896 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) |
|
895 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
896 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') |
|
897 | 897 | ), |
898 | 898 | 'cancelled_status' => array( |
899 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
900 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) |
|
899 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
900 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence') |
|
901 | 901 | ), |
902 | 902 | 'declined_status' => array( |
903 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
904 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) |
|
903 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
904 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence') |
|
905 | 905 | ), |
906 | 906 | 'not_approved' => array( |
907 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
908 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) |
|
907 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
908 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence') |
|
909 | 909 | ), |
910 | 910 | 'pending_status' => array( |
911 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
912 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) |
|
911 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
912 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence') |
|
913 | 913 | )/**/ |
914 | 914 | ); |
915 | - $this->_template_args['after_list_table'] = $this->_display_legend( $legend_items ); |
|
915 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
916 | 916 | |
917 | - $event_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null; |
|
918 | - $this->_template_args['before_list_table'] = !empty( $event_id ) ? '<h2>' . sprintf(__('Viewing Registrations for Event: %s', 'event_espresso'), EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') ) . '</h2>' : ''; |
|
919 | - $this->_template_args['list_table_hidden_fields'] = !empty( $event_id ) ? '<input type="hidden" name="event_id" value="' . $event_id . '">' : ''; |
|
917 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
918 | + $this->_template_args['before_list_table'] = ! empty($event_id) ? '<h2>'.sprintf(__('Viewing Registrations for Event: %s', 'event_espresso'), EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')).'</h2>' : ''; |
|
919 | + $this->_template_args['list_table_hidden_fields'] = ! empty($event_id) ? '<input type="hidden" name="event_id" value="'.$event_id.'">' : ''; |
|
920 | 920 | |
921 | 921 | $this->display_admin_list_table_page_with_no_sidebar(); |
922 | 922 | } |
@@ -930,15 +930,15 @@ discard block |
||
930 | 930 | * @access public |
931 | 931 | * @return array |
932 | 932 | */ |
933 | - public function get_event_attendees( $per_page = 10, $count = FALSE, $trash = FALSE, $orderby = '' ) { |
|
933 | + public function get_event_attendees($per_page = 10, $count = FALSE, $trash = FALSE, $orderby = '') { |
|
934 | 934 | |
935 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
936 | - require_once(EE_MODELS . 'EEM_Attendee.model.php'); |
|
935 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
936 | + require_once(EE_MODELS.'EEM_Attendee.model.php'); |
|
937 | 937 | //$ATT_MDL = EEM_Attendee::instance(); |
938 | 938 | |
939 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
940 | - $CAT_ID = isset($this->_req_data['category_id']) ? absint( $this->_req_data['category_id'] ) : FALSE; |
|
941 | - $DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL; |
|
939 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
940 | + $CAT_ID = isset($this->_req_data['category_id']) ? absint($this->_req_data['category_id']) : FALSE; |
|
941 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL; |
|
942 | 942 | |
943 | 943 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
944 | 944 | |
@@ -951,94 +951,94 @@ discard block |
||
951 | 951 | // $orderby = 'reg.REG_final_price'; |
952 | 952 | } |
953 | 953 | |
954 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
954 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
955 | 955 | |
956 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
957 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
956 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
957 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
958 | 958 | |
959 | 959 | |
960 | - $offset = ($current_page-1)*$per_page; |
|
961 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
962 | - $query_params = array(array('Event.status'=>array('IN', array_keys(EEM_Event::instance()->get_status_array())))); |
|
963 | - if ($EVT_ID){ |
|
964 | - $query_params[0]['EVT_ID']=$EVT_ID; |
|
960 | + $offset = ($current_page - 1) * $per_page; |
|
961 | + $limit = $count ? NULL : array($offset, $per_page); |
|
962 | + $query_params = array(array('Event.status'=>array('IN', array_keys(EEM_Event::instance()->get_status_array())))); |
|
963 | + if ($EVT_ID) { |
|
964 | + $query_params[0]['EVT_ID'] = $EVT_ID; |
|
965 | 965 | } |
966 | - if($CAT_ID){ |
|
966 | + if ($CAT_ID) { |
|
967 | 967 | throw new EE_Error("You specified a Category Id for this query. Thats odd because we are now using terms and taxonomies. So did you mean the term taxonomy id o rthe term id?"); |
968 | 968 | } |
969 | 969 | |
970 | 970 | //if DTT is included we do multiple datetimes. |
971 | - if ( $DTT_ID ) { |
|
971 | + if ($DTT_ID) { |
|
972 | 972 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
973 | 973 | } |
974 | 974 | |
975 | 975 | //make sure we only have default where on the current regs |
976 | 976 | $query_params['default_where_conditions'] = 'this_model_only'; |
977 | 977 | |
978 | - $status_ids_array = apply_filters( 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) ); |
|
978 | + $status_ids_array = apply_filters('FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)); |
|
979 | 979 | |
980 | - $query_params[0]['STS_ID']= array('IN', $status_ids_array ); |
|
980 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
981 | 981 | |
982 | - if($trash){ |
|
983 | - $query_params[0]['Attendee.status']= EEM_CPT_Base::post_status_trashed; |
|
982 | + if ($trash) { |
|
983 | + $query_params[0]['Attendee.status'] = EEM_CPT_Base::post_status_trashed; |
|
984 | 984 | } |
985 | 985 | |
986 | - if ( isset( $this->_req_data['s'] ) ) { |
|
987 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
986 | + if (isset($this->_req_data['s'])) { |
|
987 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
988 | 988 | $query_params[0]['OR'] = array( |
989 | - 'Event.EVT_name' => array( 'LIKE', $sstr), |
|
990 | - 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
991 | - 'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
992 | - 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
|
993 | - 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
|
994 | - 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
|
995 | - 'Attendee.ATT_email' => array('LIKE', $sstr ), |
|
996 | - 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
|
997 | - 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
|
998 | - 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
|
999 | - 'REG_final_price' => array( 'LIKE', $sstr ), |
|
1000 | - 'REG_code' => array( 'LIKE', $sstr ), |
|
1001 | - 'REG_count' => array( 'LIKE' , $sstr ), |
|
1002 | - 'REG_group_size' => array( 'LIKE' , $sstr ), |
|
1003 | - 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
|
1004 | - 'Ticket.TKT_description' => array( 'LIKE', $sstr ) |
|
989 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
990 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
991 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
992 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
993 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
994 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
995 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
996 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
997 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
998 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
999 | + 'REG_final_price' => array('LIKE', $sstr), |
|
1000 | + 'REG_code' => array('LIKE', $sstr), |
|
1001 | + 'REG_count' => array('LIKE', $sstr), |
|
1002 | + 'REG_group_size' => array('LIKE', $sstr), |
|
1003 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
1004 | + 'Ticket.TKT_description' => array('LIKE', $sstr) |
|
1005 | 1005 | ); |
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | $query_params['order_by'][$orderby] = $sort; |
1009 | 1009 | $query_params['limit'] = $limit; |
1010 | - $query_params['force_join'] = array('Attendee');//force join to attendee model so that it gets cached, because we're going to need the attendee for each registration |
|
1011 | - if($count){ |
|
1012 | - $registrations = EEM_Registration::instance()->count(array($query_params[0], 'default_where_conditions' => 'this_model_only' )); |
|
1013 | - }else{ |
|
1010 | + $query_params['force_join'] = array('Attendee'); //force join to attendee model so that it gets cached, because we're going to need the attendee for each registration |
|
1011 | + if ($count) { |
|
1012 | + $registrations = EEM_Registration::instance()->count(array($query_params[0], 'default_where_conditions' => 'this_model_only')); |
|
1013 | + } else { |
|
1014 | 1014 | $registrations = EEM_Registration::instance()->get_all($query_params); |
1015 | 1015 | |
1016 | 1016 | |
1017 | 1017 | // $registrations = EEM_Registration::instance(); |
1018 | 1018 | // $all_attendees = EEM_Attendee::instance()->get_event_attendees( $EVT_ID, $CAT_ID, $reg_status, $trash, $orderby, $sort, $limit, $output ); |
1019 | - if ( isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration ) { |
|
1019 | + if (isset($registrations[0]) && $registrations[0] instanceof EE_Registration) { |
|
1020 | 1020 | //EEH_Debug_Tools::printr( $all_attendees[0], '$all_attendees[0] <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
1021 | 1021 | // name |
1022 | 1022 | $first_registration = $registrations[0]; |
1023 | 1023 | $event_obj = $first_registration->event_obj(); |
1024 | - if($event_obj){ |
|
1024 | + if ($event_obj) { |
|
1025 | 1025 | $event_name = $first_registration->event_obj()->name(); |
1026 | - $event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?';//$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1026 | + $event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?'; //$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1027 | 1027 | // edit event link |
1028 | - if ( $event_name != '' ) { |
|
1029 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
|
1030 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
1031 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
1028 | + if ($event_name != '') { |
|
1029 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL); |
|
1030 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
1031 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | - $back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
|
1035 | - $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
|
1034 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL); |
|
1035 | + $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">« '.__('Back to All Registrations', 'event_espresso').'</a>'; |
|
1036 | 1036 | |
1037 | 1037 | $this->_template_args['before_admin_page_content'] = ' |
1038 | 1038 | <div id="admin-page-header"> |
1039 | - <h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
|
1040 | - <h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
|
1041 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
1039 | + <h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
1040 | + <h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
1041 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
1042 | 1042 | </div> |
1043 | 1043 | '; |
1044 | 1044 | } |
@@ -864,7 +864,7 @@ |
||
864 | 864 | * @param int $ID |
865 | 865 | * @param $shortcode_class |
866 | 866 | * @param $shortcode_posts |
867 | - * @param $page_for_posts |
|
867 | + * @param string $page_for_posts |
|
868 | 868 | * @return bool |
869 | 869 | */ |
870 | 870 | protected static function unset_posts_page_shortcode_for_post( $ID, $shortcode_class, $shortcode_posts, $page_for_posts ) { |
@@ -316,7 +316,7 @@ |
||
316 | 316 | ); |
317 | 317 | // verify that post_shortcodes is set |
318 | 318 | \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
319 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
319 | + && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
320 | 320 | ? \EE_Config::instance()->core->post_shortcodes |
321 | 321 | : array(); |
322 | 322 | // cycle thru post_shortcodes |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\admin; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | public static function set_hooks_admin() { |
29 | 29 | add_action( |
30 | 30 | 'save_post', |
31 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save' ), |
|
31 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'parse_post_content_on_save'), |
|
32 | 32 | 100, |
33 | 33 | 2 |
34 | 34 | ); |
35 | 35 | add_action( |
36 | 36 | 'delete_post', |
37 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete' ), |
|
37 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'unset_post_shortcodes_on_delete'), |
|
38 | 38 | 100, |
39 | 39 | 1 |
40 | 40 | ); |
41 | 41 | add_action( |
42 | 42 | 'add_option_page_for_posts', |
43 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set' ), |
|
43 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_initial_set'), |
|
44 | 44 | 100, |
45 | 45 | 2 |
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'update_option', |
49 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change' ), |
|
49 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_change'), |
|
50 | 50 | 100, |
51 | 51 | 3 |
52 | 52 | ); |
53 | 53 | add_action( |
54 | 54 | 'delete_option', |
55 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete' ), |
|
55 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'reset_page_for_posts_on_delete'), |
|
56 | 56 | 100, |
57 | 57 | 1 |
58 | 58 | ); |
@@ -72,61 +72,61 @@ discard block |
||
72 | 72 | * @param \WP_Post $post |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
75 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
76 | 76 | // if the post is trashed, then let's remove our post shortcode tracking |
77 | - if ( $post instanceof \WP_Post && $post->post_status === 'trash' ) { |
|
78 | - PostShortcodeTracking::unset_post_shortcodes_on_delete( $post_ID ); |
|
77 | + if ($post instanceof \WP_Post && $post->post_status === 'trash') { |
|
78 | + PostShortcodeTracking::unset_post_shortcodes_on_delete($post_ID); |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | // default post types |
82 | - $post_types = array( 'post' => 0, 'page' => 1 ); |
|
82 | + $post_types = array('post' => 0, 'page' => 1); |
|
83 | 83 | // add CPTs |
84 | 84 | $CPTs = \EE_Register_CPTs::get_CPTs(); |
85 | - $post_types = array_merge( $post_types, $CPTs ); |
|
85 | + $post_types = array_merge($post_types, $CPTs); |
|
86 | 86 | // for default or CPT posts... |
87 | - if ( isset( $post_types[ $post->post_type ] ) ) { |
|
87 | + if (isset($post_types[$post->post_type])) { |
|
88 | 88 | // post on frontpage ? |
89 | 89 | $page_for_posts = \EE_Config::get_page_for_posts(); |
90 | - if ( $post->post_name === $page_for_posts ) { |
|
91 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $page_for_posts ); |
|
90 | + if ($post->post_name === $page_for_posts) { |
|
91 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($page_for_posts); |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | // array of shortcodes indexed by post name |
95 | - \EE_Registry::CFG()->core->post_shortcodes = isset( \EE_Registry::CFG()->core->post_shortcodes ) |
|
95 | + \EE_Registry::CFG()->core->post_shortcodes = isset(\EE_Registry::CFG()->core->post_shortcodes) |
|
96 | 96 | ? \EE_Registry::CFG()->core->post_shortcodes |
97 | 97 | : array(); |
98 | 98 | // whether to proceed with update |
99 | 99 | $update_post_shortcodes = false; |
100 | 100 | // empty both arrays |
101 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ] = array(); |
|
101 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name] = array(); |
|
102 | 102 | // check that posts page is already being tracked |
103 | - if ( ! isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] ) ) { |
|
103 | + if ( ! isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts])) { |
|
104 | 104 | // if not, then ensure that it is properly added |
105 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
105 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
106 | 106 | } |
107 | 107 | // loop thru shortcodes |
108 | - foreach ( \EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) { |
|
108 | + foreach (\EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) { |
|
109 | 109 | // convert to UPPERCASE to get actual shortcode |
110 | - $EES_Shortcode = strtoupper( $EES_Shortcode ); |
|
110 | + $EES_Shortcode = strtoupper($EES_Shortcode); |
|
111 | 111 | // is the shortcode in the post_content ? |
112 | - if ( strpos( $post->post_content, $EES_Shortcode ) !== false ) { |
|
112 | + if (strpos($post->post_content, $EES_Shortcode) !== false) { |
|
113 | 113 | // map shortcode to post names and post IDs |
114 | - \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID; |
|
114 | + \EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID; |
|
115 | 115 | // and add this shortcode to the tracking for the blog page |
116 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
116 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
117 | 117 | $update_post_shortcodes = true; |
118 | 118 | } else { |
119 | 119 | // shortcode is not present in post content, so check if we were tracking it previously |
120 | 120 | // stop tracking if shortcode is not used in this specific post |
121 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ) ) { |
|
122 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] ); |
|
121 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode])) { |
|
122 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post->post_name][$EES_Shortcode]); |
|
123 | 123 | $update_post_shortcodes = true; |
124 | 124 | } |
125 | 125 | // make sure that something is set for the shortcode posts (even though we may remove this) |
126 | 126 | $shortcode_posts = isset( |
127 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
127 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
128 | 128 | ) |
129 | - ? \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] |
|
129 | + ? \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] |
|
130 | 130 | : array(); |
131 | 131 | // and stop tracking for this shortcode on the blog page if it is not used |
132 | 132 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | : $update_post_shortcodes; |
141 | 141 | } |
142 | 142 | } |
143 | - if ( $update_post_shortcodes ) { |
|
144 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
143 | + if ($update_post_shortcodes) { |
|
144 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | * @param string $page_for_posts |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - protected static function set_post_shortcodes_for_posts_page( $page_for_posts ) { |
|
162 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ] = array(); |
|
161 | + protected static function set_post_shortcodes_for_posts_page($page_for_posts) { |
|
162 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts] = array(); |
|
163 | 163 | // loop thru shortcodes |
164 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
165 | - foreach ( $post_shortcodes as $EES_Shortcode => $post_ID ) { |
|
166 | - PostShortcodeTracking::set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ); |
|
164 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
165 | + foreach ($post_shortcodes as $EES_Shortcode => $post_ID) { |
|
166 | + PostShortcodeTracking::set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID); |
|
167 | 167 | } |
168 | 168 | } |
169 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
169 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | * @param $EES_Shortcode |
182 | 182 | * @param $post_ID |
183 | 183 | */ |
184 | - protected static function set_post_shortcode_for_posts_page( $page_for_posts, $EES_Shortcode, $post_ID ) { |
|
184 | + protected static function set_post_shortcode_for_posts_page($page_for_posts, $EES_Shortcode, $post_ID) { |
|
185 | 185 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
186 | 186 | $critical_shortcodes = \EE_Registry::CFG()->core->get_critical_pages_shortcodes_array(); |
187 | 187 | // if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE |
188 | - if ( in_array( $EES_Shortcode, $critical_shortcodes ) ) { |
|
188 | + if (in_array($EES_Shortcode, $critical_shortcodes)) { |
|
189 | 189 | return; |
190 | 190 | } |
191 | 191 | // add shortcode to "Posts page" tracking |
192 | - if ( isset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
192 | + if (isset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
193 | 193 | // make sure tracking is in form of an array |
194 | - if ( ! is_array( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] ) ) { |
|
195 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( |
|
196 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] => true |
|
194 | + if ( ! is_array(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode])) { |
|
195 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array( |
|
196 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] => true |
|
197 | 197 | ); |
198 | 198 | } |
199 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] += array( $post_ID => true ); |
|
199 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] += array($post_ID => true); |
|
200 | 200 | } else { |
201 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = array( $post_ID => true ); |
|
201 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = array($post_ID => true); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -211,16 +211,16 @@ discard block |
||
211 | 211 | * @param int $ID |
212 | 212 | * @return void |
213 | 213 | */ |
214 | - public static function unset_post_shortcodes_on_delete( $ID ) { |
|
214 | + public static function unset_post_shortcodes_on_delete($ID) { |
|
215 | 215 | $update_post_shortcodes = false; |
216 | 216 | // post on frontpage ? |
217 | 217 | $page_for_posts = \EE_Config::get_page_for_posts(); |
218 | 218 | // looking for any references to this post |
219 | - foreach ( \EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
219 | + foreach (\EE_Registry::CFG()->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
220 | 220 | // is this the "Posts Page" (blog) ? |
221 | - if ( $post_name === $page_for_posts ) { |
|
221 | + if ($post_name === $page_for_posts) { |
|
222 | 222 | // loop thru shortcodes registered for the posts page |
223 | - foreach ( $post_shortcodes as $shortcode_class => $shortcode_posts ) { |
|
223 | + foreach ($post_shortcodes as $shortcode_class => $shortcode_posts) { |
|
224 | 224 | $update_post_shortcodes = PostShortcodeTracking::unset_posts_page_shortcode_for_post( |
225 | 225 | $ID, |
226 | 226 | $shortcode_class, |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | } |
234 | 234 | } else { |
235 | 235 | // loop thru shortcodes registered for each page |
236 | - foreach ( $post_shortcodes as $shortcode_class => $post_ID ) { |
|
236 | + foreach ($post_shortcodes as $shortcode_class => $post_ID) { |
|
237 | 237 | // if this is page is being deleted, then don't track any post shortcodes for it |
238 | - if ( $post_ID === $ID ) { |
|
239 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $post_name ] ); |
|
238 | + if ($post_ID === $ID) { |
|
239 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$post_name]); |
|
240 | 240 | $update_post_shortcodes = true; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | - if ( $update_post_shortcodes ) { |
|
246 | - PostShortcodeTracking::update_post_shortcodes( $page_for_posts ); |
|
245 | + if ($update_post_shortcodes) { |
|
246 | + PostShortcodeTracking::update_post_shortcodes($page_for_posts); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
@@ -268,20 +268,20 @@ discard block |
||
268 | 268 | $update_post_shortcodes = false |
269 | 269 | ) { |
270 | 270 | // make sure that an array of post IDs is being tracked for each shortcode |
271 | - if ( ! is_array( $shortcode_posts ) ) { |
|
272 | - \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] = array( |
|
271 | + if ( ! is_array($shortcode_posts)) { |
|
272 | + \EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class] = array( |
|
273 | 273 | $shortcode_posts => true |
274 | 274 | ); |
275 | 275 | $update_post_shortcodes = true; |
276 | 276 | } |
277 | 277 | // now if the ID of the post being deleted is in the $shortcode_posts array |
278 | - if ( is_array( $shortcode_posts ) && isset( $shortcode_posts[ $ID ] ) ) { |
|
279 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ][ $ID ] ); |
|
278 | + if (is_array($shortcode_posts) && isset($shortcode_posts[$ID])) { |
|
279 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class][$ID]); |
|
280 | 280 | $update_post_shortcodes = true; |
281 | 281 | } |
282 | 282 | // if nothing is registered for that shortcode anymore, then delete the shortcode altogether |
283 | - if ( empty( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ) ) { |
|
284 | - unset( \EE_Registry::CFG()->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] ); |
|
283 | + if (empty(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
284 | + unset(\EE_Registry::CFG()->core->post_shortcodes[$page_for_posts][$shortcode_class]); |
|
285 | 285 | $update_post_shortcodes = true; |
286 | 286 | } |
287 | 287 | return $update_post_shortcodes; |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * @param $page_for_posts |
297 | 297 | * @return void |
298 | 298 | */ |
299 | - public static function update_post_shortcodes( $page_for_posts = '' ) { |
|
299 | + public static function update_post_shortcodes($page_for_posts = '') { |
|
300 | 300 | // make sure page_for_posts is set |
301 | - $page_for_posts = ! empty( $page_for_posts ) |
|
301 | + $page_for_posts = ! empty($page_for_posts) |
|
302 | 302 | ? $page_for_posts |
303 | 303 | : \EE_Config::get_page_for_posts(); |
304 | 304 | // allow others to mess stuff up :D |
@@ -314,45 +314,45 @@ discard block |
||
314 | 314 | $page_for_posts |
315 | 315 | ); |
316 | 316 | // verify that post_shortcodes is set |
317 | - \EE_Config::instance()->core->post_shortcodes = isset( \EE_Config::instance()->core->post_shortcodes ) |
|
318 | - && is_array( \EE_Config::instance()->core->post_shortcodes ) |
|
317 | + \EE_Config::instance()->core->post_shortcodes = isset(\EE_Config::instance()->core->post_shortcodes) |
|
318 | + && is_array(\EE_Config::instance()->core->post_shortcodes) |
|
319 | 319 | ? \EE_Config::instance()->core->post_shortcodes |
320 | 320 | : array(); |
321 | 321 | // cycle thru post_shortcodes |
322 | - foreach ( \EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes ) { |
|
322 | + foreach (\EE_Config::instance()->core->post_shortcodes as $post_name => $shortcodes) { |
|
323 | 323 | // are there any shortcodes to track ? |
324 | - if ( ! empty( $shortcodes ) ) { |
|
324 | + if ( ! empty($shortcodes)) { |
|
325 | 325 | // loop thru list of tracked shortcodes |
326 | - foreach ( $shortcodes as $shortcode => $post_id ) { |
|
326 | + foreach ($shortcodes as $shortcode => $post_id) { |
|
327 | 327 | // if shortcode is for a critical page, |
328 | 328 | // BUT this is NOT the corresponding critical page for that shortcode |
329 | - if ( $post_name === $page_for_posts ) { |
|
329 | + if ($post_name === $page_for_posts) { |
|
330 | 330 | continue; |
331 | 331 | } |
332 | 332 | // skip the posts page, because we want all shortcodes registered for it |
333 | - if ( $post_name === $page_for_posts ) { |
|
333 | + if ($post_name === $page_for_posts) { |
|
334 | 334 | continue; |
335 | 335 | } |
336 | 336 | // make sure post still exists |
337 | - $post = get_post( $post_id ); |
|
337 | + $post = get_post($post_id); |
|
338 | 338 | // check that the post name matches what we have saved |
339 | - if ( $post && $post->post_name === $post_name ) { |
|
339 | + if ($post && $post->post_name === $post_name) { |
|
340 | 340 | // if so, then break before hitting the unset below |
341 | 341 | continue; |
342 | 342 | } |
343 | 343 | // we don't like missing posts around here >:( |
344 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
344 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
345 | 345 | } |
346 | 346 | } else { |
347 | 347 | // you got no shortcodes to keep track of ! |
348 | - unset( \EE_Config::instance()->core->post_shortcodes[ $post_name ] ); |
|
348 | + unset(\EE_Config::instance()->core->post_shortcodes[$post_name]); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | // critical page shortcodes that we do NOT want added to the Posts page (blog) |
352 | 352 | $critical_shortcodes = \EE_Config::instance()->core->get_critical_pages_shortcodes_array(); |
353 | - $critical_shortcodes = array_flip( $critical_shortcodes ); |
|
354 | - foreach ( $critical_shortcodes as $critical_shortcode ) { |
|
355 | - unset( \EE_Config::instance()->core->post_shortcodes[ $page_for_posts ][ $critical_shortcode ] ); |
|
353 | + $critical_shortcodes = array_flip($critical_shortcodes); |
|
354 | + foreach ($critical_shortcodes as $critical_shortcode) { |
|
355 | + unset(\EE_Config::instance()->core->post_shortcodes[$page_for_posts][$critical_shortcode]); |
|
356 | 356 | } |
357 | 357 | //only show errors |
358 | 358 | \EE_Config::instance()->update_espresso_config(); |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * @param string $value |
373 | 373 | * @return void |
374 | 374 | */ |
375 | - public static function reset_page_for_posts_on_initial_set( $option, $value ) { |
|
376 | - PostShortcodeTracking::reset_page_for_posts_on_change( $option, '', $value ); |
|
375 | + public static function reset_page_for_posts_on_initial_set($option, $value) { |
|
376 | + PostShortcodeTracking::reset_page_for_posts_on_change($option, '', $value); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | * @param string $value |
391 | 391 | * @return void |
392 | 392 | */ |
393 | - public static function reset_page_for_posts_on_change( $option, $old_value = '', $value = '' ) { |
|
394 | - if ( $option === 'page_for_posts' ) { |
|
393 | + public static function reset_page_for_posts_on_change($option, $old_value = '', $value = '') { |
|
394 | + if ($option === 'page_for_posts') { |
|
395 | 395 | global $wpdb; |
396 | 396 | $table = $wpdb->posts; |
397 | 397 | $SQL = "SELECT post_name from $table WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
398 | - $new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value ) ) : 'posts'; |
|
399 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( $new_page_for_posts ); |
|
398 | + $new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts'; |
|
399 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page($new_page_for_posts); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @param string $option |
413 | 413 | * @return void |
414 | 414 | */ |
415 | - public static function reset_page_for_posts_on_delete( $option ) { |
|
416 | - if ( $option === 'page_for_posts' ) { |
|
417 | - PostShortcodeTracking::set_post_shortcodes_for_posts_page( 'posts' ); |
|
415 | + public static function reset_page_for_posts_on_delete($option) { |
|
416 | + if ($option === 'page_for_posts') { |
|
417 | + PostShortcodeTracking::set_post_shortcodes_for_posts_page('posts'); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 |
@@ -577,7 +577,7 @@ |
||
577 | 577 | * @param \EEM_Base $model |
578 | 578 | * @param array $wpdb_row |
579 | 579 | * @param \WP_REST_Request $rest_request |
580 | - * @return array the _calculations item in the entity |
|
580 | + * @return \stdClass the _calculations item in the entity |
|
581 | 581 | */ |
582 | 582 | protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
583 | 583 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | 40 | parent::__construct(); |
41 | - \EE_Registry::instance()->load_helper( 'Inflector' ); |
|
41 | + \EE_Registry::instance()->load_helper('Inflector'); |
|
42 | 42 | $this->_fields_calculator = new Calculated_Model_Fields(); |
43 | 43 | } |
44 | 44 | |
@@ -47,22 +47,22 @@ discard block |
||
47 | 47 | * @param \WP_REST_Request $request |
48 | 48 | * @return \WP_REST_Response|\WP_Error |
49 | 49 | */ |
50 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
50 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
51 | 51 | $controller = new Read(); |
52 | - try{ |
|
52 | + try { |
|
53 | 53 | $matches = $controller->parse_route( |
54 | 54 | $request->get_route(), |
55 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
56 | - array( 'version', 'model' ) |
|
55 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
56 | + array('version', 'model') |
|
57 | 57 | ); |
58 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
59 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
60 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
58 | + $controller->set_requested_version($matches['version']); |
|
59 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
60 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
61 | 61 | return $controller->send_response( |
62 | 62 | new \WP_Error( |
63 | 63 | 'endpoint_parsing_error', |
64 | 64 | sprintf( |
65 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
65 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
66 | 66 | $model_name_singular |
67 | 67 | ) |
68 | 68 | ) |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | } |
71 | 71 | return $controller->send_response( |
72 | 72 | $controller->get_entities_from_model( |
73 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
73 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
74 | 74 | $request |
75 | 75 | ) |
76 | 76 | ); |
77 | - } catch( \Exception $e ) { |
|
78 | - return $controller->send_response( $e ); |
|
77 | + } catch (\Exception $e) { |
|
78 | + return $controller->send_response($e); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -85,21 +85,21 @@ discard block |
||
85 | 85 | * @param \WP_REST_Request $request |
86 | 86 | * @return \WP_REST_Response|\WP_Error |
87 | 87 | */ |
88 | - public static function handle_request_get_one( \WP_REST_Request $request ) { |
|
88 | + public static function handle_request_get_one(\WP_REST_Request $request) { |
|
89 | 89 | $controller = new Read(); |
90 | - try{ |
|
90 | + try { |
|
91 | 91 | $matches = $controller->parse_route( |
92 | 92 | $request->get_route(), |
93 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
94 | - array( 'version', 'model', 'id' ) ); |
|
95 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
96 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
97 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
93 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
94 | + array('version', 'model', 'id') ); |
|
95 | + $controller->set_requested_version($matches['version']); |
|
96 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
97 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
98 | 98 | return $controller->send_response( |
99 | 99 | new \WP_Error( |
100 | 100 | 'endpoint_parsing_error', |
101 | 101 | sprintf( |
102 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
102 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
103 | 103 | $model_name_singular |
104 | 104 | ) |
105 | 105 | ) |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | } |
108 | 108 | return $controller->send_response( |
109 | 109 | $controller->get_entity_from_model( |
110 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
110 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
111 | 111 | $request |
112 | 112 | ) |
113 | 113 | ); |
114 | - } catch( \Exception $e ) { |
|
115 | - return $controller->send_response( $e ); |
|
114 | + } catch (\Exception $e) { |
|
115 | + return $controller->send_response($e); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -124,40 +124,40 @@ discard block |
||
124 | 124 | * @param \WP_REST_Request $request |
125 | 125 | * @return \WP_REST_Response|\WP_Error |
126 | 126 | */ |
127 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
127 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
128 | 128 | $controller = new Read(); |
129 | - try{ |
|
129 | + try { |
|
130 | 130 | $matches = $controller->parse_route( |
131 | 131 | $request->get_route(), |
132 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
133 | - array( 'version', 'model', 'id', 'related_model' ) |
|
132 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
133 | + array('version', 'model', 'id', 'related_model') |
|
134 | 134 | ); |
135 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
136 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
137 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
135 | + $controller->set_requested_version($matches['version']); |
|
136 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
137 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
138 | 138 | return $controller->send_response( |
139 | 139 | new \WP_Error( |
140 | 140 | 'endpoint_parsing_error', |
141 | 141 | sprintf( |
142 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
142 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
143 | 143 | $main_model_name_singular |
144 | 144 | ) |
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | } |
148 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
148 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
149 | 149 | //assume the related model name is plural and try to find the model's name |
150 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
151 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
150 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
151 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
152 | 152 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
153 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
153 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
154 | 154 | } |
155 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
155 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
156 | 156 | return $controller->send_response( |
157 | 157 | new \WP_Error( |
158 | 158 | 'endpoint_parsing_error', |
159 | 159 | sprintf( |
160 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
160 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
161 | 161 | $related_model_name_singular |
162 | 162 | ) |
163 | 163 | ) |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | |
167 | 167 | return $controller->send_response( |
168 | 168 | $controller->get_entities_from_relation( |
169 | - $request->get_param( 'id' ), |
|
170 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
169 | + $request->get_param('id'), |
|
170 | + $main_model->related_settings_for($related_model_name_singular), |
|
171 | 171 | $request |
172 | 172 | ) |
173 | 173 | ); |
174 | - } catch( \Exception $e ) { |
|
175 | - return $controller->send_response( $e ); |
|
174 | + } catch (\Exception $e) { |
|
175 | + return $controller->send_response($e); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -185,28 +185,28 @@ discard block |
||
185 | 185 | * @param \WP_REST_Request $request |
186 | 186 | * @return array |
187 | 187 | */ |
188 | - public function get_entities_from_model( $model, $request) { |
|
189 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
190 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
191 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
188 | + public function get_entities_from_model($model, $request) { |
|
189 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
190 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
191 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
192 | 192 | return new \WP_Error( |
193 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
193 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
194 | 194 | sprintf( |
195 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
195 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
196 | 196 | $model_name_plural, |
197 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
197 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
198 | 198 | ), |
199 | - array( 'status' => 403 ) |
|
199 | + array('status' => 403) |
|
200 | 200 | ); |
201 | 201 | } |
202 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
203 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
202 | + if ( ! $request->get_header('no_rest_headers')) { |
|
203 | + $this->_set_headers_from_query_params($model, $query_params); |
|
204 | 204 | } |
205 | 205 | /** @type array $results */ |
206 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
206 | + $results = $model->get_all_wpdb_results($query_params); |
|
207 | 207 | $nice_results = array( ); |
208 | - foreach ( $results as $result ) { |
|
209 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
208 | + foreach ($results as $result) { |
|
209 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
210 | 210 | $model, |
211 | 211 | $result, |
212 | 212 | $request |
@@ -227,64 +227,64 @@ discard block |
||
227 | 227 | * @param \WP_REST_Request $request |
228 | 228 | * @return array |
229 | 229 | */ |
230 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
231 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
230 | + public function get_entities_from_relation($id, $relation, $request) { |
|
231 | + $context = $this->validate_context($request->get_param('caps')); |
|
232 | 232 | $model = $relation->get_this_model(); |
233 | 233 | $related_model = $relation->get_other_model(); |
234 | 234 | //check if they can access the 1st model object |
235 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
236 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
235 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
236 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
237 | 237 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
238 | 238 | } |
239 | 239 | $restricted_query_params = $query_params; |
240 | - $restricted_query_params[ 'caps' ] = $context; |
|
241 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
242 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
240 | + $restricted_query_params['caps'] = $context; |
|
241 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
242 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
243 | 243 | |
244 | - if( |
|
244 | + if ( |
|
245 | 245 | ! ( |
246 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
247 | - && $model->exists( $restricted_query_params ) |
|
246 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
247 | + && $model->exists($restricted_query_params) |
|
248 | 248 | ) |
249 | - ){ |
|
250 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
251 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
252 | - }else{ |
|
253 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
249 | + ) { |
|
250 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
251 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
252 | + } else { |
|
253 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
254 | 254 | } |
255 | 255 | return new \WP_Error( |
256 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
256 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
257 | 257 | sprintf( |
258 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
258 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
259 | 259 | $related_model_name_maybe_plural, |
260 | 260 | $relation->get_this_model()->get_this_model_name(), |
261 | 261 | implode( |
262 | 262 | ',', |
263 | 263 | array_keys( |
264 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
264 | + Capabilities::get_missing_permissions($related_model, $context) |
|
265 | 265 | ) |
266 | 266 | ) |
267 | 267 | ), |
268 | - array( 'status' => 403 ) |
|
268 | + array('status' => 403) |
|
269 | 269 | ); |
270 | 270 | } |
271 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
272 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
273 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
274 | - $query_params[ 'caps' ] = $context; |
|
275 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
276 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
271 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
272 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
273 | + $query_params['default_where_conditions'] = 'none'; |
|
274 | + $query_params['caps'] = $context; |
|
275 | + if ( ! $request->get_header('no_rest_headers')) { |
|
276 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
277 | 277 | } |
278 | 278 | /** @type array $results */ |
279 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
279 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
280 | 280 | $nice_results = array(); |
281 | - foreach( $results as $result ) { |
|
281 | + foreach ($results as $result) { |
|
282 | 282 | $nice_result = $this->create_entity_from_wpdb_result( |
283 | 283 | $relation->get_other_model(), |
284 | 284 | $result, |
285 | 285 | $request |
286 | 286 | ); |
287 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
287 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
288 | 288 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
289 | 289 | //if there are conflicts we prefer the properties from the main model |
290 | 290 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -292,18 +292,18 @@ discard block |
||
292 | 292 | $result, |
293 | 293 | $request |
294 | 294 | ); |
295 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
295 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
296 | 296 | //but keep the meta stuff from the main model |
297 | - if( isset( $nice_result['meta'] ) ){ |
|
297 | + if (isset($nice_result['meta'])) { |
|
298 | 298 | $joined_result['meta'] = $nice_result['meta']; |
299 | 299 | } |
300 | 300 | $nice_result = $joined_result; |
301 | 301 | } |
302 | 302 | $nice_results[] = $nice_result; |
303 | 303 | } |
304 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
305 | - return array_shift( $nice_results ); |
|
306 | - }else{ |
|
304 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
305 | + return array_shift($nice_results); |
|
306 | + } else { |
|
307 | 307 | return $nice_results; |
308 | 308 | } |
309 | 309 | } |
@@ -316,30 +316,30 @@ discard block |
||
316 | 316 | * @param array $query_params |
317 | 317 | * @return void |
318 | 318 | */ |
319 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
320 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
321 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
319 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
320 | + $this->_set_debug_info('model query params', $query_params); |
|
321 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
322 | 322 | //normally the limit to a 2-part array, where the 2nd item is the limit |
323 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
324 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
323 | + if ( ! isset($query_params['limit'])) { |
|
324 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
325 | 325 | } |
326 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
327 | - $limit_parts = $query_params[ 'limit' ]; |
|
326 | + if (is_array($query_params['limit'])) { |
|
327 | + $limit_parts = $query_params['limit']; |
|
328 | 328 | } else { |
329 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
330 | - if( count( $limit_parts ) == 1 ){ |
|
331 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
329 | + $limit_parts = explode(',', $query_params['limit']); |
|
330 | + if (count($limit_parts) == 1) { |
|
331 | + $limit_parts = array(0, $limit_parts[0]); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | //remove the group by and having parts of the query, as those will |
335 | 335 | //make the sql query return an array of values, instead of just a single value |
336 | - unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] ); |
|
337 | - $count = $model->count( $query_params, null, true ); |
|
336 | + unset($query_params['group_by'], $query_params['having'], $query_params['limit']); |
|
337 | + $count = $model->count($query_params, null, true); |
|
338 | 338 | |
339 | - $pages = $count / $limit_parts[ 1 ]; |
|
340 | - $this->_set_response_header( 'Total', $count, false ); |
|
341 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
342 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
339 | + $pages = $count / $limit_parts[1]; |
|
340 | + $this->_set_response_header('Total', $count, false); |
|
341 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
342 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | |
@@ -352,47 +352,47 @@ discard block |
||
352 | 352 | * @param string $deprecated no longer used |
353 | 353 | * @return array ready for being converted into json for sending to client |
354 | 354 | */ |
355 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
356 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
355 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
356 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
357 | 357 | //ok so this was called in the old style, where the 3rd arg was |
358 | 358 | //$include, and the 4th arg was $context |
359 | 359 | //now setup the request just to avoid fatal errors, although we won't be able |
360 | 360 | //to truly make use of it because it's kinda devoid of info |
361 | 361 | $rest_request = new \WP_REST_Request(); |
362 | - $rest_request->set_param( 'include', $rest_request ); |
|
363 | - $rest_request->set_param( 'caps', $deprecated ); |
|
362 | + $rest_request->set_param('include', $rest_request); |
|
363 | + $rest_request->set_param('caps', $deprecated); |
|
364 | 364 | } |
365 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
366 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
365 | + if ($rest_request->get_param('caps') == null) { |
|
366 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
367 | 367 | } |
368 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
369 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
370 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
371 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
372 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
368 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
369 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
370 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
371 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
372 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
373 | 373 | $entity_array = apply_filters( |
374 | 374 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
375 | 375 | $entity_array, |
376 | 376 | $model, |
377 | - $rest_request->get_param( 'caps' ), |
|
377 | + $rest_request->get_param('caps'), |
|
378 | 378 | $rest_request, |
379 | 379 | $this |
380 | 380 | ); |
381 | 381 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
382 | 382 | $entity_array, |
383 | 383 | $model, |
384 | - $rest_request->get_param( 'caps' ), |
|
384 | + $rest_request->get_param('caps'), |
|
385 | 385 | $this->get_model_version_info() |
386 | 386 | ); |
387 | 387 | $this->_set_debug_info( |
388 | 388 | 'inaccessible fields', |
389 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
389 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
390 | 390 | ); |
391 | 391 | return apply_filters( |
392 | 392 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
393 | 393 | $result_without_inaccessible_fields, |
394 | 394 | $model, |
395 | - $rest_request->get_param( 'caps' ) |
|
395 | + $rest_request->get_param('caps') |
|
396 | 396 | ); |
397 | 397 | } |
398 | 398 | |
@@ -404,38 +404,38 @@ discard block |
||
404 | 404 | * @param array $db_row |
405 | 405 | * @return array entity mostly ready for converting to JSON and sending in the response |
406 | 406 | */ |
407 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
408 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
409 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
410 | - foreach( $result as $field_name => $raw_field_value ) { |
|
407 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
408 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
409 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
410 | + foreach ($result as $field_name => $raw_field_value) { |
|
411 | 411 | $field_obj = $model->field_settings_for($field_name); |
412 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
413 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
414 | - unset( $result[ $field_name ] ); |
|
415 | - }elseif( |
|
416 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
417 | - ){ |
|
418 | - $result[ $field_name ] = array( |
|
419 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
420 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
412 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
413 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
414 | + unset($result[$field_name]); |
|
415 | + }elseif ( |
|
416 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
417 | + ) { |
|
418 | + $result[$field_name] = array( |
|
419 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
420 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
421 | 421 | ); |
422 | - }elseif( |
|
423 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
424 | - ){ |
|
425 | - $result[ $field_name ] = array( |
|
426 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
427 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
422 | + }elseif ( |
|
423 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
424 | + ) { |
|
425 | + $result[$field_name] = array( |
|
426 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
427 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
428 | 428 | ); |
429 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
430 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
429 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
430 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
431 | 431 | $field_obj, |
432 | 432 | $field_value, |
433 | 433 | $this->get_model_version_info()->requested_version() |
434 | 434 | ); |
435 | 435 | } else { |
436 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
436 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
437 | 437 | $field_obj, |
438 | - $field_obj->prepare_for_get( $field_value ), |
|
438 | + $field_obj->prepare_for_get($field_value), |
|
439 | 439 | $this->get_model_version_info()->requested_version() |
440 | 440 | ); |
441 | 441 | } |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | * @param array $entity_array |
451 | 451 | * @return array modified entity |
452 | 452 | */ |
453 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
454 | - if( $model instanceof \EEM_CPT_Base ) { |
|
455 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
453 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
454 | + if ($model instanceof \EEM_CPT_Base) { |
|
455 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
456 | 456 | } |
457 | 457 | return $entity_array; |
458 | 458 | } |
@@ -466,20 +466,20 @@ discard block |
||
466 | 466 | * @param array $entity_array |
467 | 467 | * @return array the _links item in the entity |
468 | 468 | */ |
469 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
469 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
470 | 470 | //add basic links |
471 | 471 | $links = array( |
472 | 472 | 'self' => array( |
473 | 473 | array( |
474 | 474 | 'href' => $this->get_versioned_link_to( |
475 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
475 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
476 | 476 | ) |
477 | 477 | ) |
478 | 478 | ), |
479 | 479 | 'collection' => array( |
480 | 480 | array( |
481 | 481 | 'href' => $this->get_versioned_link_to( |
482 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
482 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
483 | 483 | ) |
484 | 484 | ) |
485 | 485 | ), |
@@ -487,24 +487,24 @@ discard block |
||
487 | 487 | |
488 | 488 | //add link to the wp core endpoint, if wp api is active |
489 | 489 | global $wp_rest_server; |
490 | - if( $model instanceof \EEM_CPT_Base && |
|
490 | + if ($model instanceof \EEM_CPT_Base && |
|
491 | 491 | $wp_rest_server instanceof \WP_REST_Server && |
492 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
493 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
492 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
493 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
494 | 494 | array( |
495 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
495 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
496 | 496 | 'single' => true |
497 | 497 | ) |
498 | 498 | ); |
499 | 499 | } |
500 | 500 | |
501 | 501 | //add links to related models |
502 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
503 | - $related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj ); |
|
504 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
502 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
503 | + $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj); |
|
504 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
505 | 505 | array( |
506 | 506 | 'href' => $this->get_versioned_link_to( |
507 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
507 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
508 | 508 | ), |
509 | 509 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
510 | 510 | ) |
@@ -520,51 +520,51 @@ discard block |
||
520 | 520 | * @param array $entity_array |
521 | 521 | * @return array the modified entity |
522 | 522 | */ |
523 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
524 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
525 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
523 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
524 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
525 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
526 | 526 | //if they passed in * or didn't specify any includes, return everything |
527 | - if( ! in_array( '*', $includes_for_this_model ) |
|
528 | - && ! empty( $includes_for_this_model ) ) { |
|
529 | - if( $model->has_primary_key_field() ) { |
|
527 | + if ( ! in_array('*', $includes_for_this_model) |
|
528 | + && ! empty($includes_for_this_model)) { |
|
529 | + if ($model->has_primary_key_field()) { |
|
530 | 530 | //always include the primary key. ya just gotta know that at least |
531 | 531 | $includes_for_this_model[] = $model->primary_key_name(); |
532 | 532 | } |
533 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
533 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
534 | 534 | $includes_for_this_model[] = '_calculated_fields'; |
535 | 535 | } |
536 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
536 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
537 | 537 | } |
538 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
539 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
538 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
539 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
540 | 540 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
541 | - $rest_request->get_param( 'include' ), |
|
541 | + $rest_request->get_param('include'), |
|
542 | 542 | $relation_name |
543 | 543 | ); |
544 | 544 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
545 | - $rest_request->get_param( 'calculate' ), |
|
545 | + $rest_request->get_param('calculate'), |
|
546 | 546 | $relation_name |
547 | 547 | ); |
548 | 548 | //did they specify they wanted to include a related model, or |
549 | 549 | //specific fields from a related model? |
550 | 550 | //or did they specify to calculate a field from a related model? |
551 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
551 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
552 | 552 | //if so, we should include at least some part of the related model |
553 | 553 | $pretend_related_request = new \WP_REST_Request(); |
554 | 554 | $pretend_related_request->set_query_params( |
555 | 555 | array( |
556 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
556 | + 'caps' => $rest_request->get_param('caps'), |
|
557 | 557 | 'include' => $related_fields_to_include, |
558 | 558 | 'calculate' => $related_fields_to_calculate, |
559 | 559 | ) |
560 | 560 | ); |
561 | - $pretend_related_request->add_header( 'no_rest_headers', true ); |
|
561 | + $pretend_related_request->add_header('no_rest_headers', true); |
|
562 | 562 | $related_results = $this->get_entities_from_relation( |
563 | - $entity_array[ $model->primary_key_name() ], |
|
563 | + $entity_array[$model->primary_key_name()], |
|
564 | 564 | $relation_obj, |
565 | 565 | $pretend_related_request |
566 | 566 | ); |
567 | - $entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error |
|
567 | + $entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error |
|
568 | 568 | ? null |
569 | 569 | : $related_results; |
570 | 570 | } |
@@ -578,8 +578,8 @@ discard block |
||
578 | 578 | * @param array $arr |
579 | 579 | * @return array |
580 | 580 | */ |
581 | - private function _remove_model_names_from_array( $arr ) { |
|
582 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
581 | + private function _remove_model_names_from_array($arr) { |
|
582 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
583 | 583 | } |
584 | 584 | /** |
585 | 585 | * Gets the calculated fields for the response |
@@ -589,15 +589,15 @@ discard block |
||
589 | 589 | * @param \WP_REST_Request $rest_request |
590 | 590 | * @return array the _calculations item in the entity |
591 | 591 | */ |
592 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
592 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
593 | 593 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
594 | - $rest_request->get_param( 'calculate' ), |
|
594 | + $rest_request->get_param('calculate'), |
|
595 | 595 | '' |
596 | 596 | ); |
597 | 597 | //note: setting calculate=* doesn't do anything |
598 | 598 | $calculated_fields_to_return = new \stdClass(); |
599 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
600 | - try{ |
|
599 | + foreach ($calculated_fields as $field_to_calculate) { |
|
600 | + try { |
|
601 | 601 | $calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json( |
602 | 602 | null, |
603 | 603 | $this->_fields_calculator->retrieve_calculated_field_value( |
@@ -609,10 +609,10 @@ discard block |
||
609 | 609 | ), |
610 | 610 | $this->get_model_version_info()->requested_version() |
611 | 611 | ); |
612 | - } catch( Rest_Exception $e ) { |
|
612 | + } catch (Rest_Exception $e) { |
|
613 | 613 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
614 | 614 | $this->_set_response_header( |
615 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
615 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
616 | 616 | $e->getMessage(), |
617 | 617 | true |
618 | 618 | ); |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
627 | 627 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
628 | 628 | */ |
629 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
629 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
630 | 630 | return rest_url( |
631 | 631 | \EED_Core_Rest_Api::ee_api_namespace |
632 | 632 | . $this->get_model_version_info()->requested_version() |
@@ -642,11 +642,11 @@ discard block |
||
642 | 642 | * @param \EE_Model_Relation_Base $relation_obj |
643 | 643 | * @return string |
644 | 644 | */ |
645 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
646 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
647 | - return strtolower( $relation_name ); |
|
648 | - }else{ |
|
649 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
645 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
646 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
647 | + return strtolower($relation_name); |
|
648 | + } else { |
|
649 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
650 | 650 | } |
651 | 651 | } |
652 | 652 | |
@@ -659,43 +659,43 @@ discard block |
||
659 | 659 | * @param \WP_REST_Request $request |
660 | 660 | * @return array |
661 | 661 | */ |
662 | - public function get_entity_from_model( $model, $request ) { |
|
663 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
664 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
662 | + public function get_entity_from_model($model, $request) { |
|
663 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
664 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
665 | 665 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
666 | 666 | } |
667 | 667 | $restricted_query_params = $query_params; |
668 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
669 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
670 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
671 | - if ( ! empty ( $model_rows ) ) { |
|
668 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
669 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
670 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
671 | + if ( ! empty ($model_rows)) { |
|
672 | 672 | return $this->create_entity_from_wpdb_result( |
673 | 673 | $model, |
674 | - array_shift( $model_rows ), |
|
674 | + array_shift($model_rows), |
|
675 | 675 | $request ); |
676 | 676 | } else { |
677 | 677 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
678 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
679 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
680 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
678 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
679 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
680 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
681 | 681 | //you got shafted- it existed but we didn't want to tell you! |
682 | 682 | return new \WP_Error( |
683 | 683 | 'rest_user_cannot_read', |
684 | 684 | sprintf( |
685 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
686 | - strtolower( $model->get_this_model_name() ), |
|
685 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
686 | + strtolower($model->get_this_model_name()), |
|
687 | 687 | Capabilities::get_missing_permissions_string( |
688 | 688 | $model, |
689 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
689 | + $this->validate_context($request->get_param('caps')) ) |
|
690 | 690 | ), |
691 | - array( 'status' => 403 ) |
|
691 | + array('status' => 403) |
|
692 | 692 | ); |
693 | 693 | } else { |
694 | 694 | //it's not you. It just doesn't exist |
695 | 695 | return new \WP_Error( |
696 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
697 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
698 | - array( 'status' => 404 ) |
|
696 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
697 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
698 | + array('status' => 404) |
|
699 | 699 | ); |
700 | 700 | } |
701 | 701 | } |
@@ -708,14 +708,14 @@ discard block |
||
708 | 708 | * @param string $context |
709 | 709 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
710 | 710 | */ |
711 | - public function validate_context( $context ) { |
|
712 | - if( ! $context ) { |
|
711 | + public function validate_context($context) { |
|
712 | + if ( ! $context) { |
|
713 | 713 | $context = \EEM_Base::caps_read; |
714 | 714 | } |
715 | 715 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
716 | - if( in_array( $context, $valid_contexts ) ){ |
|
716 | + if (in_array($context, $valid_contexts)) { |
|
717 | 717 | return $context; |
718 | - }else{ |
|
718 | + } else { |
|
719 | 719 | return \EEM_Base::caps_read; |
720 | 720 | } |
721 | 721 | } |
@@ -734,77 +734,77 @@ discard block |
||
734 | 734 | * that absolutely no results should be returned |
735 | 735 | * @throws \EE_Error |
736 | 736 | */ |
737 | - public function create_model_query_params( $model, $query_parameters ) { |
|
737 | + public function create_model_query_params($model, $query_parameters) { |
|
738 | 738 | $model_query_params = array( ); |
739 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
740 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
741 | - $query_parameters[ 'where' ], |
|
739 | + if (isset($query_parameters['where'])) { |
|
740 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
741 | + $query_parameters['where'], |
|
742 | 742 | $model, |
743 | 743 | $this->get_model_version_info()->requested_version() |
744 | 744 | ); |
745 | 745 | } |
746 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
747 | - $order_by = $query_parameters[ 'order_by' ]; |
|
748 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
749 | - $order_by = $query_parameters[ 'orderby' ]; |
|
750 | - }else{ |
|
746 | + if (isset($query_parameters['order_by'])) { |
|
747 | + $order_by = $query_parameters['order_by']; |
|
748 | + } elseif (isset($query_parameters['orderby'])) { |
|
749 | + $order_by = $query_parameters['orderby']; |
|
750 | + } else { |
|
751 | 751 | $order_by = null; |
752 | 752 | } |
753 | - if( $order_by !== null ){ |
|
754 | - $model_query_params[ 'order_by' ] = $order_by; |
|
753 | + if ($order_by !== null) { |
|
754 | + $model_query_params['order_by'] = $order_by; |
|
755 | 755 | } |
756 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
757 | - $group_by = $query_parameters[ 'group_by' ]; |
|
758 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
759 | - $group_by = $query_parameters[ 'groupby' ]; |
|
760 | - }else{ |
|
761 | - $group_by = array_keys( $model->get_combined_primary_key_fields() ); |
|
756 | + if (isset($query_parameters['group_by'])) { |
|
757 | + $group_by = $query_parameters['group_by']; |
|
758 | + } elseif (isset($query_parameters['groupby'])) { |
|
759 | + $group_by = $query_parameters['groupby']; |
|
760 | + } else { |
|
761 | + $group_by = array_keys($model->get_combined_primary_key_fields()); |
|
762 | 762 | } |
763 | - if( $group_by !== null ){ |
|
764 | - $model_query_params[ 'group_by' ] = $group_by; |
|
763 | + if ($group_by !== null) { |
|
764 | + $model_query_params['group_by'] = $group_by; |
|
765 | 765 | } |
766 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
767 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
768 | - $query_parameters[ 'having' ], |
|
766 | + if (isset($query_parameters['having'])) { |
|
767 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
768 | + $query_parameters['having'], |
|
769 | 769 | $model, |
770 | 770 | $this->get_model_version_info()->requested_version() |
771 | 771 | ); |
772 | 772 | } |
773 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
774 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
773 | + if (isset($query_parameters['order'])) { |
|
774 | + $model_query_params['order'] = $query_parameters['order']; |
|
775 | 775 | } |
776 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
777 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
776 | + if (isset($query_parameters['mine'])) { |
|
777 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
778 | 778 | } |
779 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
779 | + if (isset($query_parameters['limit'])) { |
|
780 | 780 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
781 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
782 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
783 | - }else { |
|
784 | - $limit_array = $query_parameters[ 'limit' ]; |
|
781 | + if ( ! is_array($query_parameters['limit'])) { |
|
782 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
783 | + } else { |
|
784 | + $limit_array = $query_parameters['limit']; |
|
785 | 785 | } |
786 | 786 | $sanitized_limit = array(); |
787 | - foreach( $limit_array as $key => $limit_part ) { |
|
788 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
787 | + foreach ($limit_array as $key => $limit_part) { |
|
788 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
789 | 789 | throw new \EE_Error( |
790 | 790 | sprintf( |
791 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
792 | - json_encode( $query_parameters[ 'limit' ] ) |
|
791 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
792 | + json_encode($query_parameters['limit']) |
|
793 | 793 | ) |
794 | 794 | ); |
795 | 795 | } |
796 | - $sanitized_limit[] = (int)$limit_part; |
|
796 | + $sanitized_limit[] = (int) $limit_part; |
|
797 | 797 | } |
798 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
799 | - }else{ |
|
800 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
798 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
799 | + } else { |
|
800 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
801 | 801 | } |
802 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
803 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
804 | - }else{ |
|
805 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
802 | + if (isset($query_parameters['caps'])) { |
|
803 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
804 | + } else { |
|
805 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
806 | 806 | } |
807 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
807 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
817 | 817 | * @return array |
818 | 818 | */ |
819 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
819 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
820 | 820 | $model_ready_query_params = array(); |
821 | - foreach( $query_params as $key => $value ) { |
|
822 | - if( is_array( $value ) ) { |
|
823 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
824 | - }else{ |
|
825 | - $model_ready_query_params[ $key ] = $value; |
|
821 | + foreach ($query_params as $key => $value) { |
|
822 | + if (is_array($value)) { |
|
823 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
824 | + } else { |
|
825 | + $model_ready_query_params[$key] = $value; |
|
826 | 826 | } |
827 | 827 | } |
828 | 828 | return $model_ready_query_params; |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | * @param $query_params |
837 | 837 | * @return array |
838 | 838 | */ |
839 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
839 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
840 | 840 | $model_ready_query_params = array(); |
841 | - foreach( $query_params as $key => $value ) { |
|
842 | - if( is_array( $value ) ) { |
|
843 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
841 | + foreach ($query_params as $key => $value) { |
|
842 | + if (is_array($value)) { |
|
843 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
844 | 844 | } else { |
845 | - $model_ready_query_params[ $key ] = $value; |
|
845 | + $model_ready_query_params[$key] = $value; |
|
846 | 846 | } |
847 | 847 | } |
848 | 848 | return $model_ready_query_params; |
@@ -857,33 +857,33 @@ discard block |
||
857 | 857 | * we only return strings starting with that and a period; if no prefix was specified |
858 | 858 | * we return all items containing NO periods |
859 | 859 | */ |
860 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
861 | - if( is_string( $string_to_explode ) ) { |
|
862 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
863 | - } else if( is_array( $string_to_explode ) ) { |
|
860 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
861 | + if (is_string($string_to_explode)) { |
|
862 | + $exploded_contents = explode(',', $string_to_explode); |
|
863 | + } else if (is_array($string_to_explode)) { |
|
864 | 864 | $exploded_contents = $string_to_explode; |
865 | 865 | } else { |
866 | 866 | $exploded_contents = array(); |
867 | 867 | } |
868 | 868 | //if the string was empty, we want an empty array |
869 | - $exploded_contents = array_filter( $exploded_contents ); |
|
869 | + $exploded_contents = array_filter($exploded_contents); |
|
870 | 870 | $contents_with_prefix = array(); |
871 | - foreach( $exploded_contents as $item ) { |
|
872 | - $item = trim( $item ); |
|
871 | + foreach ($exploded_contents as $item) { |
|
872 | + $item = trim($item); |
|
873 | 873 | //if no prefix was provided, so we look for items with no "." in them |
874 | - if( ! $prefix ) { |
|
874 | + if ( ! $prefix) { |
|
875 | 875 | //does this item have a period? |
876 | - if( strpos( $item, '.' ) === false ) { |
|
876 | + if (strpos($item, '.') === false) { |
|
877 | 877 | //if not, then its what we're looking for |
878 | 878 | $contents_with_prefix[] = $item; |
879 | 879 | } |
880 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
880 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
881 | 881 | //this item has the prefix and a period, grab it |
882 | 882 | $contents_with_prefix[] = substr( |
883 | 883 | $item, |
884 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
884 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
885 | 885 | ); |
886 | - } else if( $item === $prefix ) { |
|
886 | + } else if ($item === $prefix) { |
|
887 | 887 | //this item is JUST the prefix |
888 | 888 | //so let's grab everything after, which is a blank string |
889 | 889 | $contents_with_prefix[] = ''; |
@@ -906,33 +906,33 @@ discard block |
||
906 | 906 | * the fields for that model, with the model's name removed from each. |
907 | 907 | * If $include_string was blank or '*' returns an empty array |
908 | 908 | */ |
909 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
910 | - if( is_array( $include_string ) ) { |
|
911 | - $include_string = implode( ',', $include_string ); |
|
909 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
910 | + if (is_array($include_string)) { |
|
911 | + $include_string = implode(',', $include_string); |
|
912 | 912 | } |
913 | - if( $include_string === '*' || $include_string === '' ) { |
|
913 | + if ($include_string === '*' || $include_string === '') { |
|
914 | 914 | return array(); |
915 | 915 | } |
916 | - $includes = explode( ',', $include_string ); |
|
916 | + $includes = explode(',', $include_string); |
|
917 | 917 | $extracted_fields_to_include = array(); |
918 | - if( $model_name ){ |
|
919 | - foreach( $includes as $field_to_include ) { |
|
920 | - $field_to_include = trim( $field_to_include ); |
|
921 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
918 | + if ($model_name) { |
|
919 | + foreach ($includes as $field_to_include) { |
|
920 | + $field_to_include = trim($field_to_include); |
|
921 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
922 | 922 | //found the model name at the exact start |
923 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
923 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
924 | 924 | $extracted_fields_to_include[] = $field_sans_model_name; |
925 | - }elseif( $field_to_include == $model_name ){ |
|
925 | + }elseif ($field_to_include == $model_name) { |
|
926 | 926 | $extracted_fields_to_include[] = '*'; |
927 | 927 | } |
928 | 928 | } |
929 | - }else{ |
|
929 | + } else { |
|
930 | 930 | //look for ones with no period |
931 | - foreach( $includes as $field_to_include ) { |
|
932 | - $field_to_include = trim( $field_to_include ); |
|
931 | + foreach ($includes as $field_to_include) { |
|
932 | + $field_to_include = trim($field_to_include); |
|
933 | 933 | if ( |
934 | - strpos( $field_to_include, '.' ) === false |
|
935 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
934 | + strpos($field_to_include, '.') === false |
|
935 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
936 | 936 | ) { |
937 | 937 | $extracted_fields_to_include[] = $field_to_include; |
938 | 938 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public static function instance() { |
104 | 104 | // check if class object is instantiated |
105 | - if ( ! self::$_instance instanceof EE_System ) { |
|
105 | + if ( ! self::$_instance instanceof EE_System) { |
|
106 | 106 | self::$_instance = new self(); |
107 | 107 | } |
108 | 108 | return self::$_instance; |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * resets the instance and returns it |
114 | 114 | * @return EE_System |
115 | 115 | */ |
116 | - public static function reset(){ |
|
116 | + public static function reset() { |
|
117 | 117 | self::$_instance->_req_type = NULL; |
118 | 118 | //we need to reset the migration manager in order for it to detect DMSs properly |
119 | 119 | EE_Data_Migration_Manager::reset(); |
120 | 120 | //make sure none of the old hooks are left hanging around |
121 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
121 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
122 | 122 | self::instance()->detect_activations_or_upgrades(); |
123 | 123 | self::instance()->perform_activations_upgrades_and_migrations(); |
124 | 124 | return self::instance(); |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * @access private |
135 | 135 | */ |
136 | 136 | private function __construct() { |
137 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
137 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
138 | 138 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
139 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
139 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
140 | 140 | // when an ee addon is activated, we want to call the core hook(s) again |
141 | 141 | // because the newly-activated addon didn't get a chance to run at all |
142 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
142 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
143 | 143 | // detect whether install or upgrade |
144 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
144 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
145 | 145 | // load EE_Config, EE_Textdomain, etc |
146 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
146 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
147 | 147 | // load EE_Config, EE_Textdomain, etc |
148 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
148 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
149 | 149 | // you wanna get going? I wanna get going... let's get going! |
150 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
150 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
151 | 151 | //other housekeeping |
152 | 152 | //exclude EE critical pages from wp_list_pages |
153 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
153 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
154 | 154 | // ALL EE Addons should use the following hook point to attach their initial setup too |
155 | 155 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
156 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
156 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -173,30 +173,30 @@ discard block |
||
173 | 173 | public function load_espresso_addons() { |
174 | 174 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
175 | 175 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
176 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
176 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
177 | 177 | //load and setup EE_Capabilities |
178 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
178 | + EE_Registry::instance()->load_core('Capabilities'); |
|
179 | 179 | //caps need to be initialized on every request so that capability maps are set. |
180 | 180 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
181 | 181 | EE_Registry::instance()->CAP->init_caps(); |
182 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
182 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
183 | 183 | //if the WP API basic auth plugin isn't already loaded, load it now. |
184 | 184 | //We want it for mobile apps. Just include the entire plugin |
185 | 185 | //also, don't load the basic auth when a plugin is getting activated, because |
186 | 186 | //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
187 | 187 | //and causes a fatal error |
188 | - if( !function_exists( 'json_basic_auth_handler' ) |
|
189 | - && ! function_exists( 'json_basic_auth_error' ) |
|
188 | + if ( ! function_exists('json_basic_auth_handler') |
|
189 | + && ! function_exists('json_basic_auth_error') |
|
190 | 190 | && ! ( |
191 | - isset( $_GET[ 'action'] ) |
|
192 | - && in_array( $_GET[ 'action' ], array( 'activate', 'activate-selected' ) ) |
|
191 | + isset($_GET['action']) |
|
192 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
193 | 193 | ) |
194 | 194 | && ! ( |
195 | - isset( $_GET['activate' ] ) |
|
196 | - && $_GET['activate' ] === 'true' |
|
195 | + isset($_GET['activate']) |
|
196 | + && $_GET['activate'] === 'true' |
|
197 | 197 | ) |
198 | 198 | ) { |
199 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
199 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @access public |
213 | 213 | * @return void |
214 | 214 | */ |
215 | - public function detect_activations_or_upgrades(){ |
|
215 | + public function detect_activations_or_upgrades() { |
|
216 | 216 | //first off: let's make sure to handle core |
217 | 217 | $this->detect_if_activation_or_upgrade(); |
218 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
218 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
219 | 219 | //detect teh request type for that addon |
220 | 220 | $addon->detect_activation_or_upgrade(); |
221 | 221 | } |
@@ -236,44 +236,44 @@ discard block |
||
236 | 236 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
237 | 237 | |
238 | 238 | // load M-Mode class |
239 | - EE_Registry::instance()->load_core( 'Maintenance_Mode' ); |
|
239 | + EE_Registry::instance()->load_core('Maintenance_Mode'); |
|
240 | 240 | // check if db has been updated, or if its a brand-new installation |
241 | 241 | |
242 | 242 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
243 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
243 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
244 | 244 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
245 | - if( $request_type != EE_System::req_type_normal){ |
|
245 | + if ($request_type != EE_System::req_type_normal) { |
|
246 | 246 | EE_Registry::instance()->load_helper('Activation'); |
247 | 247 | } |
248 | 248 | |
249 | - switch($request_type){ |
|
249 | + switch ($request_type) { |
|
250 | 250 | case EE_System::req_type_new_activation: |
251 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
252 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
251 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
252 | + $this->_handle_core_version_change($espresso_db_update); |
|
253 | 253 | break; |
254 | 254 | case EE_System::req_type_reactivation: |
255 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
256 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
255 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
256 | + $this->_handle_core_version_change($espresso_db_update); |
|
257 | 257 | break; |
258 | 258 | case EE_System::req_type_upgrade: |
259 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
259 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
260 | 260 | //migrations may be required now that we've upgraded |
261 | 261 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
262 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
262 | + $this->_handle_core_version_change($espresso_db_update); |
|
263 | 263 | // echo "done upgrade";die; |
264 | 264 | break; |
265 | 265 | case EE_System::req_type_downgrade: |
266 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
266 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
267 | 267 | //its possible migrations are no longer required |
268 | 268 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
269 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
269 | + $this->_handle_core_version_change($espresso_db_update); |
|
270 | 270 | break; |
271 | 271 | case EE_System::req_type_normal: |
272 | 272 | default: |
273 | 273 | // $this->_maybe_redirect_to_ee_about(); |
274 | 274 | break; |
275 | 275 | } |
276 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
276 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | * initializing the database later during the request |
282 | 282 | * @param array $espresso_db_update |
283 | 283 | */ |
284 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
285 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
284 | + protected function _handle_core_version_change($espresso_db_update) { |
|
285 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
286 | 286 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
287 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
287 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -299,44 +299,44 @@ discard block |
||
299 | 299 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
300 | 300 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
301 | 301 | */ |
302 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
303 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
304 | - if( ! $espresso_db_update){ |
|
305 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
302 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
303 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
304 | + if ( ! $espresso_db_update) { |
|
305 | + $espresso_db_update = get_option('espresso_db_update'); |
|
306 | 306 | } |
307 | 307 | // check that option is an array |
308 | - if( ! is_array( $espresso_db_update )) { |
|
308 | + if ( ! is_array($espresso_db_update)) { |
|
309 | 309 | // if option is FALSE, then it never existed |
310 | - if ( $espresso_db_update === FALSE ) { |
|
310 | + if ($espresso_db_update === FALSE) { |
|
311 | 311 | // make $espresso_db_update an array and save option with autoload OFF |
312 | - $espresso_db_update = array(); |
|
313 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
312 | + $espresso_db_update = array(); |
|
313 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
314 | 314 | } else { |
315 | 315 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
316 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
317 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
316 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
317 | + update_option('espresso_db_update', $espresso_db_update); |
|
318 | 318 | } |
319 | - }else{ |
|
319 | + } else { |
|
320 | 320 | $corrected_db_update = array(); |
321 | 321 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
322 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
323 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
322 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
323 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
324 | 324 | //the key is an int, and the value IS NOT an array |
325 | 325 | //so it must be numerically-indexed, where values are versions installed... |
326 | 326 | //fix it! |
327 | 327 | $version_string = $should_be_array; |
328 | 328 | $corrected_db_update[$version_string] = array('unknown-date'); |
329 | - }else{ |
|
329 | + } else { |
|
330 | 330 | //ok it checks out |
331 | 331 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
332 | 332 | } |
333 | 333 | } |
334 | 334 | $espresso_db_update = $corrected_db_update; |
335 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
335 | + update_option('espresso_db_update', $espresso_db_update); |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | |
339 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
339 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
340 | 340 | return $espresso_db_update; |
341 | 341 | } |
342 | 342 | |
@@ -355,34 +355,34 @@ discard block |
||
355 | 355 | * so we prefer to only do it when necessary |
356 | 356 | * @return void |
357 | 357 | */ |
358 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
358 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
359 | 359 | $request_type = $this->detect_req_type(); |
360 | 360 | //only initialize system if we're not in maintenance mode. |
361 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
362 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
361 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
362 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
363 | 363 | |
364 | - if( $verify_schema ) { |
|
364 | + if ($verify_schema) { |
|
365 | 365 | EEH_Activation::initialize_db_and_folders(); |
366 | 366 | } |
367 | 367 | EEH_Activation::initialize_db_content(); |
368 | 368 | EEH_Activation::system_initialization(); |
369 | - if( $initialize_addons_too ) { |
|
369 | + if ($initialize_addons_too) { |
|
370 | 370 | $this->initialize_addons(); |
371 | 371 | } |
372 | - }else{ |
|
373 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
372 | + } else { |
|
373 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
374 | 374 | } |
375 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
376 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
375 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
376 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
381 | 381 | * Initializes the db for all registered addons |
382 | 382 | */ |
383 | - public function initialize_addons(){ |
|
383 | + public function initialize_addons() { |
|
384 | 384 | //foreach registered addon, make sure its db is up-to-date too |
385 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
385 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
386 | 386 | $addon->initialize_db_if_no_migrations_required(); |
387 | 387 | } |
388 | 388 | } |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * @param string $current_version_to_add version to be added to the version history |
395 | 395 | * @return boolean success as to whether or not this option was changed |
396 | 396 | */ |
397 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
398 | - if( ! $version_history ) { |
|
397 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
398 | + if ( ! $version_history) { |
|
399 | 399 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
400 | 400 | } |
401 | - if( $current_version_to_add == NULL){ |
|
401 | + if ($current_version_to_add == NULL) { |
|
402 | 402 | $current_version_to_add = espresso_version(); |
403 | 403 | } |
404 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
404 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
405 | 405 | // re-save |
406 | - return update_option( 'espresso_db_update', $version_history ); |
|
406 | + return update_option('espresso_db_update', $version_history); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -420,10 +420,10 @@ discard block |
||
420 | 420 | * but still know if this is a new install or not |
421 | 421 | * @return int one of the constants on EE_System::req_type_ |
422 | 422 | */ |
423 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
424 | - if ( $this->_req_type === NULL ){ |
|
425 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
426 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
423 | + public function detect_req_type($espresso_db_update = NULL) { |
|
424 | + if ($this->_req_type === NULL) { |
|
425 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
426 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
427 | 427 | } |
428 | 428 | return $this->_req_type; |
429 | 429 | } |
@@ -439,39 +439,39 @@ discard block |
||
439 | 439 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
440 | 440 | * @return int one of the constants on EE_System::req_type_* |
441 | 441 | */ |
442 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
443 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
444 | - if( $activation_history_for_addon ){ |
|
442 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
443 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
444 | + if ($activation_history_for_addon) { |
|
445 | 445 | //it exists, so this isn't a completely new install |
446 | 446 | //check if this version already in that list of previously installed versions |
447 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
447 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
448 | 448 | //it a version we haven't seen before |
449 | - if( $version_is_higher === 1 ){ |
|
449 | + if ($version_is_higher === 1) { |
|
450 | 450 | $req_type = EE_System::req_type_upgrade; |
451 | - }else{ |
|
451 | + } else { |
|
452 | 452 | $req_type = EE_System::req_type_downgrade; |
453 | 453 | } |
454 | - delete_option( $activation_indicator_option_name ); |
|
454 | + delete_option($activation_indicator_option_name); |
|
455 | 455 | } else { |
456 | 456 | // its not an update. maybe a reactivation? |
457 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
458 | - if ( $version_is_higher === -1 ){ |
|
457 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
458 | + if ($version_is_higher === -1) { |
|
459 | 459 | $req_type = EE_System::req_type_downgrade; |
460 | - }elseif( $version_is_higher === 0 ){ |
|
460 | + }elseif ($version_is_higher === 0) { |
|
461 | 461 | //we've seen this version before, but it's an activation. must be a reactivation |
462 | 462 | $req_type = EE_System::req_type_reactivation; |
463 | - }else{//$version_is_higher === 1 |
|
463 | + } else {//$version_is_higher === 1 |
|
464 | 464 | $req_type = EE_System::req_type_upgrade; |
465 | 465 | } |
466 | - delete_option( $activation_indicator_option_name ); |
|
466 | + delete_option($activation_indicator_option_name); |
|
467 | 467 | } else { |
468 | 468 | //we've seen this version before and the activation indicate doesn't show it was just activated |
469 | - if ( $version_is_higher === -1 ){ |
|
469 | + if ($version_is_higher === -1) { |
|
470 | 470 | $req_type = EE_System::req_type_downgrade; |
471 | - }elseif( $version_is_higher === 0 ){ |
|
471 | + }elseif ($version_is_higher === 0) { |
|
472 | 472 | //we've seen this version before and it's not an activation. its normal request |
473 | 473 | $req_type = EE_System::req_type_normal; |
474 | - }else{//$version_is_higher === 1 |
|
474 | + } else {//$version_is_higher === 1 |
|
475 | 475 | $req_type = EE_System::req_type_upgrade; |
476 | 476 | } |
477 | 477 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | } else { |
480 | 480 | //brand new install |
481 | 481 | $req_type = EE_System::req_type_new_activation; |
482 | - delete_option( $activation_indicator_option_name ); |
|
482 | + delete_option($activation_indicator_option_name); |
|
483 | 483 | } |
484 | 484 | return $req_type; |
485 | 485 | } |
@@ -497,30 +497,30 @@ discard block |
||
497 | 497 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
498 | 498 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
499 | 499 | */ |
500 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
500 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
501 | 501 | //find the most recently-activated version |
502 | 502 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
503 | 503 | $most_recently_active_version = '0.0.0.dev.000'; |
504 | - if( is_array( $activation_history_for_addon ) ){ |
|
505 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
504 | + if (is_array($activation_history_for_addon)) { |
|
505 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
506 | 506 | //check there is a record of when this version was activated. Otherwise, |
507 | 507 | //mark it as unknown |
508 | - if( ! $times_activated ){ |
|
509 | - $times_activated = array( 'unknown-date'); |
|
508 | + if ( ! $times_activated) { |
|
509 | + $times_activated = array('unknown-date'); |
|
510 | 510 | } |
511 | - if( is_string( $times_activated ) ){ |
|
512 | - $times_activated = array( $times_activated ); |
|
511 | + if (is_string($times_activated)) { |
|
512 | + $times_activated = array($times_activated); |
|
513 | 513 | } |
514 | - foreach( $times_activated as $an_activation ){ |
|
515 | - if( $an_activation != 'unknown-date' && |
|
516 | - $an_activation > $most_recently_active_version_activation ){ |
|
514 | + foreach ($times_activated as $an_activation) { |
|
515 | + if ($an_activation != 'unknown-date' && |
|
516 | + $an_activation > $most_recently_active_version_activation) { |
|
517 | 517 | $most_recently_active_version = $version; |
518 | 518 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | } |
522 | 522 | } |
523 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
523 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -530,20 +530,20 @@ discard block |
||
530 | 530 | * @return void |
531 | 531 | */ |
532 | 532 | public function redirect_to_about_ee() { |
533 | - $notices = EE_Error::get_notices( FALSE ); |
|
533 | + $notices = EE_Error::get_notices(FALSE); |
|
534 | 534 | //if current user is an admin and it's not an ajax request |
535 | - if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX ) && ! isset( $notices[ 'errors' ] ) ){ |
|
536 | - $query_params = array( 'page' => 'espresso_about' ); |
|
535 | + if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) { |
|
536 | + $query_params = array('page' => 'espresso_about'); |
|
537 | 537 | |
538 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
538 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
539 | 539 | $query_params['new_activation'] = TRUE; |
540 | 540 | } |
541 | 541 | |
542 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
542 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
543 | 543 | $query_params['reactivation'] = TRUE; |
544 | 544 | } |
545 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
546 | - wp_safe_redirect( $url ); |
|
545 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
546 | + wp_safe_redirect($url); |
|
547 | 547 | exit(); |
548 | 548 | } |
549 | 549 | } |
@@ -557,31 +557,31 @@ discard block |
||
557 | 557 | * |
558 | 558 | * @return void |
559 | 559 | */ |
560 | - public function load_core_configuration(){ |
|
561 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
562 | - EE_Registry::instance()->load_core( 'EE_Load_Textdomain' ); |
|
560 | + public function load_core_configuration() { |
|
561 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
562 | + EE_Registry::instance()->load_core('EE_Load_Textdomain'); |
|
563 | 563 | //load textdomain |
564 | 564 | EE_Load_Textdomain::load_textdomain(); |
565 | 565 | // load and setup EE_Config and EE_Network_Config |
566 | - EE_Registry::instance()->load_core( 'Config' ); |
|
567 | - EE_Registry::instance()->load_core( 'Network_Config' ); |
|
566 | + EE_Registry::instance()->load_core('Config'); |
|
567 | + EE_Registry::instance()->load_core('Network_Config'); |
|
568 | 568 | // setup autoloaders |
569 | 569 | // enable logging? |
570 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
571 | - EE_Registry::instance()->load_core( 'Log' ); |
|
570 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
571 | + EE_Registry::instance()->load_core('Log'); |
|
572 | 572 | } |
573 | 573 | // check for activation errors |
574 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
575 | - if ( $activation_errors ) { |
|
576 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
577 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
574 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
575 | + if ($activation_errors) { |
|
576 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
577 | + update_option('ee_plugin_activation_errors', FALSE); |
|
578 | 578 | } |
579 | 579 | // get model names |
580 | 580 | $this->_parse_model_names(); |
581 | 581 | |
582 | 582 | //load caf stuff a chance to play during the activation process too. |
583 | 583 | $this->_maybe_brew_regular(); |
584 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
584 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -590,23 +590,23 @@ discard block |
||
590 | 590 | * |
591 | 591 | * @return void |
592 | 592 | */ |
593 | - private function _parse_model_names(){ |
|
593 | + private function _parse_model_names() { |
|
594 | 594 | //get all the files in the EE_MODELS folder that end in .model.php |
595 | - $models = glob( EE_MODELS.'*.model.php'); |
|
595 | + $models = glob(EE_MODELS.'*.model.php'); |
|
596 | 596 | $model_names = array(); |
597 | 597 | $non_abstract_db_models = array(); |
598 | - foreach( $models as $model ){ |
|
598 | + foreach ($models as $model) { |
|
599 | 599 | // get model classname |
600 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
601 | - $shortname = str_replace( 'EEM_', '', $classname ); |
|
600 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
601 | + $shortname = str_replace('EEM_', '', $classname); |
|
602 | 602 | $reflectionClass = new ReflectionClass($classname); |
603 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
603 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
604 | 604 | $non_abstract_db_models[$shortname] = $classname; |
605 | 605 | } |
606 | - $model_names[ $shortname ] = $classname; |
|
606 | + $model_names[$shortname] = $classname; |
|
607 | 607 | } |
608 | - EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
609 | - EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
608 | + EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
609 | + EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | * @return void |
617 | 617 | */ |
618 | 618 | private function _maybe_brew_regular() { |
619 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
620 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
619 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
620 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
621 | 621 | } |
622 | 622 | } |
623 | 623 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @return void |
635 | 635 | */ |
636 | 636 | public function register_shortcodes_modules_and_widgets() { |
637 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
637 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
638 | 638 | // check for addons using old hookpoint |
639 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
639 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
640 | 640 | $this->_incompatible_addon_error(); |
641 | 641 | } |
642 | 642 | } |
@@ -650,19 +650,19 @@ discard block |
||
650 | 650 | */ |
651 | 651 | private function _incompatible_addon_error() { |
652 | 652 | // get array of classes hooking into here |
653 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
654 | - if ( ! empty( $class_names )) { |
|
655 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
653 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
654 | + if ( ! empty($class_names)) { |
|
655 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
656 | 656 | $msg .= '<ul>'; |
657 | - foreach ( $class_names as $class_name ) { |
|
658 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
657 | + foreach ($class_names as $class_name) { |
|
658 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
659 | 659 | } |
660 | 660 | $msg .= '</ul>'; |
661 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
661 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
662 | 662 | // save list of incompatible addons to wp-options for later use |
663 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
664 | - if ( is_admin() ) { |
|
665 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
663 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
664 | + if (is_admin()) { |
|
665 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | } |
@@ -679,25 +679,25 @@ discard block |
||
679 | 679 | * |
680 | 680 | * @return void |
681 | 681 | */ |
682 | - public function brew_espresso(){ |
|
683 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
682 | + public function brew_espresso() { |
|
683 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
684 | 684 | // load some final core systems |
685 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
686 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
687 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
688 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
689 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
690 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
691 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
692 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
693 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
694 | - |
|
695 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
685 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
686 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
687 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
688 | + add_action('init', array($this, 'load_controllers'), 7); |
|
689 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
690 | + add_action('init', array($this, 'initialize'), 10); |
|
691 | + add_action('init', array($this, 'initialize_last'), 100); |
|
692 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
693 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
694 | + |
|
695 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
696 | 696 | // pew pew pew |
697 | - EE_Registry::instance()->load_core( 'PUE' ); |
|
698 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
697 | + EE_Registry::instance()->load_core('PUE'); |
|
698 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
699 | 699 | } |
700 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
700 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | */ |
712 | 712 | public function set_hooks_for_core() { |
713 | 713 | $this->_deactivate_incompatible_addons(); |
714 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
714 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | |
@@ -720,15 +720,15 @@ discard block |
||
720 | 720 | * Using the information gathered in EE_System::_incompatible_addon_error, |
721 | 721 | * deactivates any addons considered incompatible with the current version of EE |
722 | 722 | */ |
723 | - private function _deactivate_incompatible_addons(){ |
|
724 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
725 | - if ( ! empty( $incompatible_addons )) { |
|
726 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
727 | - foreach ( $active_plugins as $active_plugin ) { |
|
728 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
729 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
730 | - unset( $_GET['activate'] ); |
|
731 | - espresso_deactivate_plugin( $active_plugin ); |
|
723 | + private function _deactivate_incompatible_addons() { |
|
724 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
725 | + if ( ! empty($incompatible_addons)) { |
|
726 | + $active_plugins = get_option('active_plugins', array()); |
|
727 | + foreach ($active_plugins as $active_plugin) { |
|
728 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
729 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
730 | + unset($_GET['activate']); |
|
731 | + espresso_deactivate_plugin($active_plugin); |
|
732 | 732 | } |
733 | 733 | } |
734 | 734 | } |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | */ |
746 | 746 | public function perform_activations_upgrades_and_migrations() { |
747 | 747 | //first check if we had previously attempted to setup EE's directories but failed |
748 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
748 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
749 | 749 | EEH_Activation::create_upload_directories(); |
750 | 750 | } |
751 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
751 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | * @return void |
761 | 761 | */ |
762 | 762 | public function load_CPTs_and_session() { |
763 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
763 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
764 | 764 | // register Custom Post Types |
765 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
766 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
765 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
766 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -778,19 +778,19 @@ discard block |
||
778 | 778 | * @return void |
779 | 779 | */ |
780 | 780 | public function load_controllers() { |
781 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
781 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
782 | 782 | // let's get it started |
783 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
784 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
785 | - EE_Registry::instance()->load_core( 'Front_Controller' ); |
|
786 | - } else if ( ! EE_FRONT_AJAX ) { |
|
787 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
788 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
789 | - } else if ( EE_Maintenance_Mode::instance()->level() ) { |
|
783 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
784 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
785 | + EE_Registry::instance()->load_core('Front_Controller'); |
|
786 | + } else if ( ! EE_FRONT_AJAX) { |
|
787 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
788 | + EE_Registry::instance()->load_core('Admin'); |
|
789 | + } else if (EE_Maintenance_Mode::instance()->level()) { |
|
790 | 790 | // still need to make sure template helper functions are loaded in M-Mode |
791 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
791 | + EE_Registry::instance()->load_helper('Template'); |
|
792 | 792 | } |
793 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
793 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | |
@@ -804,10 +804,10 @@ discard block |
||
804 | 804 | * @return void |
805 | 805 | */ |
806 | 806 | public function core_loaded_and_ready() { |
807 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
808 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
807 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
808 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
809 | 809 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
810 | - EE_Registry::instance()->load_core( 'Session' ); |
|
810 | + EE_Registry::instance()->load_core('Session'); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * @return void |
822 | 822 | */ |
823 | 823 | public function initialize() { |
824 | - do_action( 'AHEE__EE_System__initialize' ); |
|
824 | + do_action('AHEE__EE_System__initialize'); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @return void |
836 | 836 | */ |
837 | 837 | public function initialize_last() { |
838 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
838 | + do_action('AHEE__EE_System__initialize_last'); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -867,21 +867,21 @@ discard block |
||
867 | 867 | */ |
868 | 868 | public static function do_not_cache() { |
869 | 869 | // set no cache constants |
870 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
871 | - define( 'DONOTCACHEPAGE', true ); |
|
870 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
871 | + define('DONOTCACHEPAGE', true); |
|
872 | 872 | } |
873 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
874 | - define( 'DONOTCACHCEOBJECT', true ); |
|
873 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
874 | + define('DONOTCACHCEOBJECT', true); |
|
875 | 875 | } |
876 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
877 | - define( 'DONOTCACHEDB', true ); |
|
876 | + if ( ! defined('DONOTCACHEDB')) { |
|
877 | + define('DONOTCACHEDB', true); |
|
878 | 878 | } |
879 | 879 | // add no cache headers |
880 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
880 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
881 | 881 | // plus a little extra for nginx and Google Chrome |
882 | - add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 ); |
|
882 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
883 | 883 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
884 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
884 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | * @param $headers |
894 | 894 | * @return array |
895 | 895 | */ |
896 | - public static function extra_nocache_headers ( $headers ) { |
|
896 | + public static function extra_nocache_headers($headers) { |
|
897 | 897 | // for NGINX |
898 | 898 | $headers['X-Accel-Expires'] = 0; |
899 | 899 | // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
@@ -922,15 +922,15 @@ discard block |
||
922 | 922 | * @param $admin_bar |
923 | 923 | * @return void |
924 | 924 | */ |
925 | - public function espresso_toolbar_items( $admin_bar ) { |
|
925 | + public function espresso_toolbar_items($admin_bar) { |
|
926 | 926 | |
927 | 927 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
928 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
928 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
929 | 929 | return; |
930 | 930 | } |
931 | 931 | |
932 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
933 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
932 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
933 | + EE_Registry::instance()->load_helper('URL'); |
|
934 | 934 | $menu_class = 'espresso_menu_item_class'; |
935 | 935 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
936 | 936 | //because they're only defined in each of their respective constructors |
@@ -942,20 +942,20 @@ discard block |
||
942 | 942 | //Top Level |
943 | 943 | $admin_bar->add_menu(array( |
944 | 944 | 'id' => 'espresso-toolbar', |
945 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
945 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
946 | 946 | 'href' => $events_admin_url, |
947 | 947 | 'meta' => array( |
948 | 948 | 'title' => __('Event Espresso', 'event_espresso'), |
949 | - 'class' => $menu_class . 'first' |
|
949 | + 'class' => $menu_class.'first' |
|
950 | 950 | ), |
951 | 951 | )); |
952 | 952 | |
953 | 953 | //Events |
954 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
954 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
955 | 955 | $admin_bar->add_menu(array( |
956 | 956 | 'id' => 'espresso-toolbar-events', |
957 | 957 | 'parent' => 'espresso-toolbar', |
958 | - 'title' => __( 'Events', 'event_espresso' ), |
|
958 | + 'title' => __('Events', 'event_espresso'), |
|
959 | 959 | 'href' => $events_admin_url, |
960 | 960 | 'meta' => array( |
961 | 961 | 'title' => __('Events', 'event_espresso'), |
@@ -966,13 +966,13 @@ discard block |
||
966 | 966 | } |
967 | 967 | |
968 | 968 | |
969 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
969 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
970 | 970 | //Events Add New |
971 | 971 | $admin_bar->add_menu(array( |
972 | 972 | 'id' => 'espresso-toolbar-events-new', |
973 | 973 | 'parent' => 'espresso-toolbar-events', |
974 | 974 | 'title' => __('Add New', 'event_espresso'), |
975 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
975 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
976 | 976 | 'meta' => array( |
977 | 977 | 'title' => __('Add New', 'event_espresso'), |
978 | 978 | 'target' => '', |
@@ -981,18 +981,18 @@ discard block |
||
981 | 981 | )); |
982 | 982 | } |
983 | 983 | |
984 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
984 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
985 | 985 | |
986 | 986 | //Current post |
987 | 987 | global $post; |
988 | 988 | |
989 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
989 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
990 | 990 | //Events Edit Current Event |
991 | 991 | $admin_bar->add_menu(array( |
992 | 992 | 'id' => 'espresso-toolbar-events-edit', |
993 | 993 | 'parent' => 'espresso-toolbar-events', |
994 | 994 | 'title' => __('Edit Event', 'event_espresso'), |
995 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
995 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
996 | 996 | 'meta' => array( |
997 | 997 | 'title' => __('Edit Event', 'event_espresso'), |
998 | 998 | 'target' => '', |
@@ -1004,11 +1004,11 @@ discard block |
||
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | //Events View |
1007 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
1007 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
1008 | 1008 | $admin_bar->add_menu(array( |
1009 | 1009 | 'id' => 'espresso-toolbar-events-view', |
1010 | 1010 | 'parent' => 'espresso-toolbar-events', |
1011 | - 'title' => __( 'View', 'event_espresso' ), |
|
1011 | + 'title' => __('View', 'event_espresso'), |
|
1012 | 1012 | 'href' => $events_admin_url, |
1013 | 1013 | 'meta' => array( |
1014 | 1014 | 'title' => __('View', 'event_espresso'), |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | )); |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
1021 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1022 | 1022 | //Events View All |
1023 | 1023 | $admin_bar->add_menu(array( |
1024 | 1024 | 'id' => 'espresso-toolbar-events-all', |
1025 | 1025 | 'parent' => 'espresso-toolbar-events-view', |
1026 | - 'title' => __( 'All', 'event_espresso' ), |
|
1026 | + 'title' => __('All', 'event_espresso'), |
|
1027 | 1027 | 'href' => $events_admin_url, |
1028 | 1028 | 'meta' => array( |
1029 | 1029 | 'title' => __('All', 'event_espresso'), |
@@ -1034,13 +1034,13 @@ discard block |
||
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
1037 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1037 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1038 | 1038 | //Events View Today |
1039 | 1039 | $admin_bar->add_menu(array( |
1040 | 1040 | 'id' => 'espresso-toolbar-events-today', |
1041 | 1041 | 'parent' => 'espresso-toolbar-events-view', |
1042 | 1042 | 'title' => __('Today', 'event_espresso'), |
1043 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1043 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1044 | 1044 | 'meta' => array( |
1045 | 1045 | 'title' => __('Today', 'event_espresso'), |
1046 | 1046 | 'target' => '', |
@@ -1050,13 +1050,13 @@ discard block |
||
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | |
1053 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1053 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1054 | 1054 | //Events View This Month |
1055 | 1055 | $admin_bar->add_menu(array( |
1056 | 1056 | 'id' => 'espresso-toolbar-events-month', |
1057 | 1057 | 'parent' => 'espresso-toolbar-events-view', |
1058 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1059 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1058 | + 'title' => __('This Month', 'event_espresso'), |
|
1059 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1060 | 1060 | 'meta' => array( |
1061 | 1061 | 'title' => __('This Month', 'event_espresso'), |
1062 | 1062 | 'target' => '', |
@@ -1066,11 +1066,11 @@ discard block |
||
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | //Registration Overview |
1069 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1069 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1070 | 1070 | $admin_bar->add_menu(array( |
1071 | 1071 | 'id' => 'espresso-toolbar-registrations', |
1072 | 1072 | 'parent' => 'espresso-toolbar', |
1073 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1073 | + 'title' => __('Registrations', 'event_espresso'), |
|
1074 | 1074 | 'href' => $reg_admin_url, |
1075 | 1075 | 'meta' => array( |
1076 | 1076 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1081,12 +1081,12 @@ discard block |
||
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | //Registration Overview Today |
1084 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1084 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1085 | 1085 | $admin_bar->add_menu(array( |
1086 | 1086 | 'id' => 'espresso-toolbar-registrations-today', |
1087 | 1087 | 'parent' => 'espresso-toolbar-registrations', |
1088 | - 'title' => __( 'Today', 'event_espresso'), |
|
1089 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1088 | + 'title' => __('Today', 'event_espresso'), |
|
1089 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1090 | 1090 | 'meta' => array( |
1091 | 1091 | 'title' => __('Today', 'event_espresso'), |
1092 | 1092 | 'target' => '', |
@@ -1096,14 +1096,14 @@ discard block |
||
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | //Registration Overview Today Completed |
1099 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1099 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1100 | 1100 | $admin_bar->add_menu(array( |
1101 | 1101 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1102 | 1102 | 'parent' => 'espresso-toolbar-registrations-today', |
1103 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1104 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1103 | + 'title' => __('Approved', 'event_espresso'), |
|
1104 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1105 | 1105 | 'meta' => array( |
1106 | - 'title' => __('Approved', 'event_espresso' ), |
|
1106 | + 'title' => __('Approved', 'event_espresso'), |
|
1107 | 1107 | 'target' => '', |
1108 | 1108 | 'class' => $menu_class |
1109 | 1109 | ), |
@@ -1111,14 +1111,14 @@ discard block |
||
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | //Registration Overview Today Pending\ |
1114 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1114 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1115 | 1115 | $admin_bar->add_menu(array( |
1116 | 1116 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1117 | 1117 | 'parent' => 'espresso-toolbar-registrations-today', |
1118 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1119 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1118 | + 'title' => __('Pending', 'event_espresso'), |
|
1119 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1120 | 1120 | 'meta' => array( |
1121 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1121 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1122 | 1122 | 'target' => '', |
1123 | 1123 | 'class' => $menu_class |
1124 | 1124 | ), |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | //Registration Overview Today Incomplete |
1129 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1129 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1130 | 1130 | $admin_bar->add_menu(array( |
1131 | 1131 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1132 | 1132 | 'parent' => 'espresso-toolbar-registrations-today', |
1133 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1134 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1133 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1134 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1135 | 1135 | 'meta' => array( |
1136 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1136 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1137 | 1137 | 'target' => '', |
1138 | 1138 | 'class' => $menu_class |
1139 | 1139 | ), |
@@ -1141,12 +1141,12 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | //Registration Overview Today Incomplete |
1144 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1144 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1145 | 1145 | $admin_bar->add_menu(array( |
1146 | 1146 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1147 | 1147 | 'parent' => 'espresso-toolbar-registrations-today', |
1148 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1149 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1148 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1149 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1150 | 1150 | 'meta' => array( |
1151 | 1151 | 'title' => __('Cancelled', 'event_espresso'), |
1152 | 1152 | 'target' => '', |
@@ -1156,12 +1156,12 @@ discard block |
||
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | //Registration Overview This Month |
1159 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1159 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1160 | 1160 | $admin_bar->add_menu(array( |
1161 | 1161 | 'id' => 'espresso-toolbar-registrations-month', |
1162 | 1162 | 'parent' => 'espresso-toolbar-registrations', |
1163 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1164 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1163 | + 'title' => __('This Month', 'event_espresso'), |
|
1164 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1165 | 1165 | 'meta' => array( |
1166 | 1166 | 'title' => __('This Month', 'event_espresso'), |
1167 | 1167 | 'target' => '', |
@@ -1171,12 +1171,12 @@ discard block |
||
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | //Registration Overview This Month Approved |
1174 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1174 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1175 | 1175 | $admin_bar->add_menu(array( |
1176 | 1176 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1177 | 1177 | 'parent' => 'espresso-toolbar-registrations-month', |
1178 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1179 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1178 | + 'title' => __('Approved', 'event_espresso'), |
|
1179 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1180 | 1180 | 'meta' => array( |
1181 | 1181 | 'title' => __('Approved', 'event_espresso'), |
1182 | 1182 | 'target' => '', |
@@ -1186,12 +1186,12 @@ discard block |
||
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | //Registration Overview This Month Pending |
1189 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1189 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1190 | 1190 | $admin_bar->add_menu(array( |
1191 | 1191 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1192 | 1192 | 'parent' => 'espresso-toolbar-registrations-month', |
1193 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1194 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1193 | + 'title' => __('Pending', 'event_espresso'), |
|
1194 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1195 | 1195 | 'meta' => array( |
1196 | 1196 | 'title' => __('Pending', 'event_espresso'), |
1197 | 1197 | 'target' => '', |
@@ -1201,14 +1201,14 @@ discard block |
||
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | //Registration Overview This Month Not Approved |
1204 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1204 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1205 | 1205 | $admin_bar->add_menu(array( |
1206 | 1206 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1207 | 1207 | 'parent' => 'espresso-toolbar-registrations-month', |
1208 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1209 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1208 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1209 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1210 | 1210 | 'meta' => array( |
1211 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1211 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1212 | 1212 | 'target' => '', |
1213 | 1213 | 'class' => $menu_class |
1214 | 1214 | ), |
@@ -1217,12 +1217,12 @@ discard block |
||
1217 | 1217 | |
1218 | 1218 | |
1219 | 1219 | //Registration Overview This Month Cancelled |
1220 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1220 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1221 | 1221 | $admin_bar->add_menu(array( |
1222 | 1222 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1223 | 1223 | 'parent' => 'espresso-toolbar-registrations-month', |
1224 | 1224 | 'title' => __('Cancelled', 'event_espresso'), |
1225 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1225 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1226 | 1226 | 'meta' => array( |
1227 | 1227 | 'title' => __('Cancelled', 'event_espresso'), |
1228 | 1228 | 'target' => '', |
@@ -1232,11 +1232,11 @@ discard block |
||
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | //Extensions & Services |
1235 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1235 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1236 | 1236 | $admin_bar->add_menu(array( |
1237 | 1237 | 'id' => 'espresso-toolbar-extensions-and-services', |
1238 | 1238 | 'parent' => 'espresso-toolbar', |
1239 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1239 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1240 | 1240 | 'href' => $extensions_admin_url, |
1241 | 1241 | 'meta' => array( |
1242 | 1242 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1258,8 +1258,8 @@ discard block |
||
1258 | 1258 | * @param array $exclude_array any existing pages being excluded are in this array. |
1259 | 1259 | * @return array |
1260 | 1260 | */ |
1261 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1262 | - return array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() ); |
|
1261 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1262 | + return array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array()); |
|
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | |
@@ -1279,12 +1279,12 @@ discard block |
||
1279 | 1279 | */ |
1280 | 1280 | public function wp_enqueue_scripts() { |
1281 | 1281 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1282 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1282 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1283 | 1283 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1284 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1284 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1285 | 1285 | // register jQuery Validate and additional methods |
1286 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery' ), '1.15.0', TRUE ); |
|
1287 | - wp_register_script( 'jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', array( 'jquery', 'jquery-validate' ), '1.15.0', TRUE ); |
|
1286 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
1287 | + wp_register_script('jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', array('jquery', 'jquery-validate'), '1.15.0', TRUE); |
|
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | if ( is_array( $hooks_to_fire_at_time ) ) { |
207 | 207 | foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
208 | 208 | if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
209 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
209 | + && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
210 | 210 | ) { |
211 | 211 | unset( $crons[ $timestamp ][ $hook_name ] ); |
212 | 212 | } |
@@ -1120,14 +1120,14 @@ discard block |
||
1120 | 1120 | $QSG_ID = reset( $id_col ); |
1121 | 1121 | } else { |
1122 | 1122 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1123 | - EE_Log::instance()->log( |
|
1124 | - __FILE__, |
|
1125 | - __FUNCTION__, |
|
1126 | - sprintf( |
|
1127 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1128 | - $QST_ID ), |
|
1129 | - 'error' ); |
|
1130 | - continue; |
|
1123 | + EE_Log::instance()->log( |
|
1124 | + __FILE__, |
|
1125 | + __FUNCTION__, |
|
1126 | + sprintf( |
|
1127 | + __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1128 | + $QST_ID ), |
|
1129 | + 'error' ); |
|
1130 | + continue; |
|
1131 | 1131 | } |
1132 | 1132 | } |
1133 | 1133 | |
@@ -1657,8 +1657,8 @@ discard block |
||
1657 | 1657 | } |
1658 | 1658 | } |
1659 | 1659 | } |
1660 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1661 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1660 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1661 | + remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1662 | 1662 | |
1663 | 1663 | if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
1664 | 1664 | $db_update_sans_ee4 = array(); |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param $table_name |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
60 | + public static function ensure_table_name_has_prefix($table_name) { |
|
61 | 61 | global $wpdb; |
62 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
62 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * be called on plugin activation and reactivation |
86 | 86 | * @return boolean success, whether the database and folders are setup properly |
87 | 87 | */ |
88 | - public static function initialize_db_and_folders(){ |
|
88 | + public static function initialize_db_and_folders() { |
|
89 | 89 | $good_filesystem = EEH_Activation::create_upload_directories(); |
90 | 90 | $good_db = EEH_Activation::create_database_tables(); |
91 | 91 | return $good_filesystem && $good_db; |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * upon activation of a new plugin, reactivation, and at the end |
100 | 100 | * of running migration scripts |
101 | 101 | */ |
102 | - public static function initialize_db_content(){ |
|
102 | + public static function initialize_db_content() { |
|
103 | 103 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
104 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
104 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | EEH_Activation::remove_cron_tasks(); |
119 | 119 | EEH_Activation::create_cron_tasks(); |
120 | 120 | //also, check for CAF default db content |
121 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
121 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
122 | 122 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
123 | 123 | //which users really won't care about on initial activation |
124 | 124 | EE_Error::overwrite_success(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return array |
138 | 138 | * @throws \EE_Error |
139 | 139 | */ |
140 | - public static function get_cron_tasks( $which_to_include ) { |
|
140 | + public static function get_cron_tasks($which_to_include) { |
|
141 | 141 | $cron_tasks = apply_filters( |
142 | 142 | 'FHEE__EEH_Activation__get_cron_tasks', |
143 | 143 | array( |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
147 | 147 | ) |
148 | 148 | ); |
149 | - if( $which_to_include === 'all' ) { |
|
149 | + if ($which_to_include === 'all') { |
|
150 | 150 | //leave as-is |
151 | - }elseif( $which_to_include === 'old' ) { |
|
152 | - $cron_tasks = array_filter( $cron_tasks, function ( $value ) { |
|
151 | + }elseif ($which_to_include === 'old') { |
|
152 | + $cron_tasks = array_filter($cron_tasks, function($value) { |
|
153 | 153 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
154 | 154 | }); |
155 | - }elseif( $which_to_include === 'current' ) { |
|
156 | - $cron_tasks = array_filter( $cron_tasks ); |
|
157 | - }elseif( WP_DEBUG ) { |
|
158 | - throw new EE_Error( sprintf( __( 'Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso' ), $which_to_include ) ); |
|
159 | - }else{ |
|
155 | + }elseif ($which_to_include === 'current') { |
|
156 | + $cron_tasks = array_filter($cron_tasks); |
|
157 | + }elseif (WP_DEBUG) { |
|
158 | + throw new EE_Error(sprintf(__('Invalidate argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', 'event_espresso'), $which_to_include)); |
|
159 | + } else { |
|
160 | 160 | //leave as-is |
161 | 161 | } |
162 | 162 | return $cron_tasks; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public static function create_cron_tasks() { |
169 | 169 | |
170 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
171 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
172 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
170 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
171 | + if ( ! wp_next_scheduled($hook_name)) { |
|
172 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * Remove the currently-existing and now-removed cron tasks. |
180 | 180 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
181 | 181 | */ |
182 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
182 | + public static function remove_cron_tasks($remove_all = true) { |
|
183 | 183 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
184 | 184 | $crons = _get_cron_array(); |
185 | - $crons = is_array( $crons ) ? $crons : array(); |
|
185 | + $crons = is_array($crons) ? $crons : array(); |
|
186 | 186 | /* reminder of what $crons look like: |
187 | 187 | * Top-level keys are timestamps, and their values are arrays. |
188 | 188 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | * ... |
201 | 201 | * ... |
202 | 202 | */ |
203 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
204 | - foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
205 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
206 | - foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
207 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
208 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
203 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
204 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
205 | + if (is_array($hooks_to_fire_at_time)) { |
|
206 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
207 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
208 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
209 | 209 | ) { |
210 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
210 | + unset($crons[$timestamp][$hook_name]); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | //also take care of any empty cron timestamps. |
214 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
215 | - unset( $crons[ $timestamp ] ); |
|
214 | + if (empty($hooks_to_fire_at_time)) { |
|
215 | + unset($crons[$timestamp]); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
219 | - _set_cron_array( $crons ); |
|
219 | + _set_cron_array($crons); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public static function CPT_initialization() { |
233 | 233 | // register Custom Post Types |
234 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
234 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
235 | 235 | flush_rewrite_rules(); |
236 | 236 | } |
237 | 237 | |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | * @return void |
250 | 250 | */ |
251 | 251 | public static function reset_and_update_config() { |
252 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
253 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
252 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
253 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
254 | 254 | //EE_Config::reset(); |
255 | 255 | } |
256 | 256 | |
@@ -263,23 +263,23 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public static function load_calendar_config() { |
265 | 265 | // grab array of all plugin folders and loop thru it |
266 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
267 | - if ( empty( $plugins ) ) { |
|
266 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
267 | + if (empty($plugins)) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | - foreach ( $plugins as $plugin_path ) { |
|
270 | + foreach ($plugins as $plugin_path) { |
|
271 | 271 | // grab plugin folder name from path |
272 | - $plugin = basename( $plugin_path ); |
|
272 | + $plugin = basename($plugin_path); |
|
273 | 273 | // drill down to Espresso plugins |
274 | - if ( strpos( $plugin, 'espresso' ) !== FALSE || strpos( $plugin, 'Espresso' ) !== FALSE || strpos( $plugin, 'ee4' ) !== FALSE || strpos( $plugin, 'EE4' ) !== FALSE ) { |
|
274 | + if (strpos($plugin, 'espresso') !== FALSE || strpos($plugin, 'Espresso') !== FALSE || strpos($plugin, 'ee4') !== FALSE || strpos($plugin, 'EE4') !== FALSE) { |
|
275 | 275 | // then to calendar related plugins |
276 | - if ( strpos( $plugin, 'calendar' ) !== FALSE ) { |
|
276 | + if (strpos($plugin, 'calendar') !== FALSE) { |
|
277 | 277 | // this is what we are looking for |
278 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
278 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
279 | 279 | // does it exist in this folder ? |
280 | - if ( is_readable( $calendar_config )) { |
|
280 | + if (is_readable($calendar_config)) { |
|
281 | 281 | // YEAH! let's load it |
282 | - require_once( $calendar_config ); |
|
282 | + require_once($calendar_config); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -296,21 +296,21 @@ discard block |
||
296 | 296 | * @param \EE_Config $EE_Config |
297 | 297 | * @return \stdClass |
298 | 298 | */ |
299 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
300 | - $convert_from_array = array( 'addons' ); |
|
299 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
300 | + $convert_from_array = array('addons'); |
|
301 | 301 | // in case old settings were saved as an array |
302 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
302 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
303 | 303 | // convert existing settings to an object |
304 | 304 | $config_array = $settings; |
305 | 305 | $settings = new stdClass(); |
306 | - foreach ( $config_array as $key => $value ){ |
|
307 | - if ( $key == 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
308 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
306 | + foreach ($config_array as $key => $value) { |
|
307 | + if ($key == 'calendar' && class_exists('EE_Calendar_Config')) { |
|
308 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
309 | 309 | } else { |
310 | 310 | $settings->{$key} = $value; |
311 | 311 | } |
312 | 312 | } |
313 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
313 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
314 | 314 | } |
315 | 315 | return $settings; |
316 | 316 | } |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public static function deactivate_event_espresso() { |
328 | 328 | // check permissions |
329 | - if ( current_user_can( 'activate_plugins' )) { |
|
330 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
329 | + if (current_user_can('activate_plugins')) { |
|
330 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -349,25 +349,25 @@ discard block |
||
349 | 349 | $critical_pages = array( |
350 | 350 | array( |
351 | 351 | 'id' =>'reg_page_id', |
352 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
352 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
353 | 353 | 'post' => NULL, |
354 | 354 | 'code' => 'ESPRESSO_CHECKOUT' |
355 | 355 | ), |
356 | 356 | array( |
357 | 357 | 'id' => 'txn_page_id', |
358 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
358 | + 'name' => __('Transactions', 'event_espresso'), |
|
359 | 359 | 'post' => NULL, |
360 | 360 | 'code' => 'ESPRESSO_TXN_PAGE' |
361 | 361 | ), |
362 | 362 | array( |
363 | 363 | 'id' => 'thank_you_page_id', |
364 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
364 | + 'name' => __('Thank You', 'event_espresso'), |
|
365 | 365 | 'post' => NULL, |
366 | 366 | 'code' => 'ESPRESSO_THANK_YOU' |
367 | 367 | ), |
368 | 368 | array( |
369 | 369 | 'id' => 'cancel_page_id', |
370 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
370 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
371 | 371 | 'post' => NULL, |
372 | 372 | 'code' => 'ESPRESSO_CANCELLED' |
373 | 373 | ), |
@@ -375,62 +375,62 @@ discard block |
||
375 | 375 | |
376 | 376 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
377 | 377 | |
378 | - foreach ( $critical_pages as $critical_page ) { |
|
378 | + foreach ($critical_pages as $critical_page) { |
|
379 | 379 | // is critical page ID set in config ? |
380 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
380 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
381 | 381 | // attempt to find post by ID |
382 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
382 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
383 | 383 | } |
384 | 384 | // no dice? |
385 | - if ( $critical_page['post'] == NULL ) { |
|
385 | + if ($critical_page['post'] == NULL) { |
|
386 | 386 | // attempt to find post by title |
387 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
387 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
388 | 388 | // still nothing? |
389 | - if ( $critical_page['post'] == NULL ) { |
|
390 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
389 | + if ($critical_page['post'] == NULL) { |
|
390 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
391 | 391 | // REALLY? Still nothing ??!?!? |
392 | - if ( $critical_page['post'] == NULL ) { |
|
393 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
394 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
392 | + if ($critical_page['post'] == NULL) { |
|
393 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
394 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
395 | 395 | break; |
396 | 396 | } |
397 | 397 | } |
398 | 398 | } |
399 | 399 | // track post_shortcodes |
400 | - if ( $critical_page['post'] ) { |
|
401 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
400 | + if ($critical_page['post']) { |
|
401 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
402 | 402 | } |
403 | 403 | // check that Post ID matches critical page ID in config |
404 | 404 | if ( |
405 | - isset( $critical_page['post']->ID ) |
|
406 | - && $critical_page['post']->ID != $EE_Core_Config->{$critical_page[ 'id' ]} |
|
405 | + isset($critical_page['post']->ID) |
|
406 | + && $critical_page['post']->ID != $EE_Core_Config->{$critical_page['id']} |
|
407 | 407 | ) { |
408 | 408 | //update Config with post ID |
409 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
410 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
411 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
412 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
409 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
410 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
411 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
412 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | 416 | $critical_page_problem = |
417 | - ! isset( $critical_page['post']->post_status ) |
|
417 | + ! isset($critical_page['post']->post_status) |
|
418 | 418 | || $critical_page['post']->post_status != 'publish' |
419 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
419 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
420 | 420 | ? TRUE |
421 | 421 | : $critical_page_problem; |
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | - if ( $critical_page_problem ) { |
|
425 | + if ($critical_page_problem) { |
|
426 | 426 | $msg = sprintf( |
427 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
428 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
427 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
428 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
429 | 429 | ); |
430 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
430 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
431 | 431 | } |
432 | - if ( EE_Error::has_notices() ) { |
|
433 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
432 | + if (EE_Error::has_notices()) { |
|
433 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
@@ -442,13 +442,13 @@ discard block |
||
442 | 442 | * parameter to the shortcode |
443 | 443 | * @return WP_Post or NULl |
444 | 444 | */ |
445 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
445 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
446 | 446 | global $wpdb; |
447 | 447 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
448 | 448 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
449 | - if($post_id){ |
|
449 | + if ($post_id) { |
|
450 | 450 | return get_post($post_id); |
451 | - }else{ |
|
451 | + } else { |
|
452 | 452 | return NULL; |
453 | 453 | } |
454 | 454 | |
@@ -465,32 +465,32 @@ discard block |
||
465 | 465 | * @param array $critical_page |
466 | 466 | * @return array |
467 | 467 | */ |
468 | - public static function create_critical_page( $critical_page ) { |
|
468 | + public static function create_critical_page($critical_page) { |
|
469 | 469 | |
470 | 470 | $post_args = array( |
471 | 471 | 'post_title' => $critical_page['name'], |
472 | 472 | 'post_status' => 'publish', |
473 | 473 | 'post_type' => 'page', |
474 | 474 | 'comment_status' => 'closed', |
475 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
475 | + 'post_content' => '['.$critical_page['code'].']' |
|
476 | 476 | ); |
477 | 477 | |
478 | - $post_id = wp_insert_post( $post_args ); |
|
479 | - if ( ! $post_id ) { |
|
478 | + $post_id = wp_insert_post($post_args); |
|
479 | + if ( ! $post_id) { |
|
480 | 480 | $msg = sprintf( |
481 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
481 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
482 | 482 | $critical_page['name'] |
483 | 483 | ); |
484 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
484 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
485 | 485 | return $critical_page; |
486 | 486 | } |
487 | 487 | // get newly created post's details |
488 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
488 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
489 | 489 | $msg = sprintf( |
490 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
490 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
491 | 491 | $critical_page['name'] |
492 | 492 | ); |
493 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
493 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | return $critical_page; |
@@ -509,35 +509,35 @@ discard block |
||
509 | 509 | * @param array $critical_page |
510 | 510 | * @return void |
511 | 511 | */ |
512 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
512 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
513 | 513 | // check the goods |
514 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
514 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
515 | 515 | $msg = sprintf( |
516 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
516 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
517 | 517 | $critical_page['name'] |
518 | 518 | ); |
519 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
519 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
520 | 520 | return; |
521 | 521 | } |
522 | 522 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
523 | 523 | // map shortcode to post |
524 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
524 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
525 | 525 | // and make sure it's NOT added to the WP "Posts Page" |
526 | 526 | // name of the WP Posts Page |
527 | 527 | $posts_page = EE_Registry::instance()->CFG->get_page_for_posts(); |
528 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
529 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
528 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
529 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
530 | 530 | } |
531 | - if ( $posts_page != 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
532 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
531 | + if ($posts_page != 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
532 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
533 | 533 | } |
534 | 534 | // update post_shortcode CFG |
535 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
535 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
536 | 536 | $msg = sprintf( |
537 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
537 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
538 | 538 | $critical_page['name'] |
539 | 539 | ); |
540 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
540 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
@@ -555,24 +555,24 @@ discard block |
||
555 | 555 | public static function get_default_creator_id() { |
556 | 556 | global $wpdb; |
557 | 557 | |
558 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
558 | + if ( ! empty(self::$_default_creator_id)) { |
|
559 | 559 | return self::$_default_creator_id; |
560 | 560 | }/**/ |
561 | 561 | |
562 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
562 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
563 | 563 | |
564 | 564 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
565 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
566 | - if ( $pre_filtered_id !== false ) { |
|
565 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
566 | + if ($pre_filtered_id !== false) { |
|
567 | 567 | return (int) $pre_filtered_id; |
568 | 568 | } |
569 | 569 | |
570 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
571 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
572 | - $user_id = $wpdb->get_var( $query ); |
|
573 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
574 | - if ( $user_id && intval( $user_id ) ) { |
|
575 | - self::$_default_creator_id = intval( $user_id ); |
|
570 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
571 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
572 | + $user_id = $wpdb->get_var($query); |
|
573 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
574 | + if ($user_id && intval($user_id)) { |
|
575 | + self::$_default_creator_id = intval($user_id); |
|
576 | 576 | return self::$_default_creator_id; |
577 | 577 | } else { |
578 | 578 | return NULL; |
@@ -599,29 +599,29 @@ discard block |
||
599 | 599 | * @return void |
600 | 600 | * @throws EE_Error if there are database errors |
601 | 601 | */ |
602 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
603 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
602 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
603 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
604 | 604 | return; |
605 | 605 | } |
606 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
607 | - if ( ! function_exists( 'dbDelta' )) { |
|
608 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
606 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
607 | + if ( ! function_exists('dbDelta')) { |
|
608 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
609 | 609 | } |
610 | 610 | /** @var WPDB $wpdb */ |
611 | 611 | global $wpdb; |
612 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
612 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
613 | 613 | // do we need to first delete an existing version of this table ? |
614 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
614 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
615 | 615 | // ok, delete the table... but ONLY if it's empty |
616 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
616 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
617 | 617 | // table is NOT empty, are you SURE you want to delete this table ??? |
618 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
619 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
620 | - } else if ( ! $deleted_safely ) { |
|
618 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
619 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
620 | + } else if ( ! $deleted_safely) { |
|
621 | 621 | // so we should be more cautious rather than just dropping tables so easily |
622 | 622 | EE_Error::add_persistent_admin_notice( |
623 | - 'bad_table_' . $wp_table_name . '_detected', |
|
624 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
623 | + 'bad_table_'.$wp_table_name.'_detected', |
|
624 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
625 | 625 | $wp_table_name, |
626 | 626 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
627 | 627 | '<b>wp-config.php</b>', |
@@ -630,25 +630,25 @@ discard block |
||
630 | 630 | } |
631 | 631 | } |
632 | 632 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
633 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
633 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
634 | 634 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
635 | 635 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
636 | 636 | //happened. And then we can choose to tell the end user |
637 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
638 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
637 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
638 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
639 | 639 | ob_start(); |
640 | - dbDelta( $SQL ); |
|
640 | + dbDelta($SQL); |
|
641 | 641 | $output = ob_get_contents(); |
642 | 642 | ob_end_clean(); |
643 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
644 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
645 | - if( ! empty( $output ) ){ |
|
646 | - throw new EE_Error( $output ); |
|
643 | + $wpdb->show_errors($old_show_errors_policy); |
|
644 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
645 | + if ( ! empty($output)) { |
|
646 | + throw new EE_Error($output); |
|
647 | 647 | } |
648 | 648 | } else { |
649 | 649 | throw new EE_Error( |
650 | 650 | sprintf( |
651 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
651 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
652 | 652 | '<br />', |
653 | 653 | $sql |
654 | 654 | ) |
@@ -670,15 +670,15 @@ discard block |
||
670 | 670 | * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)' |
671 | 671 | * @return bool|int |
672 | 672 | */ |
673 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
674 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
673 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
674 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
675 | 675 | return FALSE; |
676 | 676 | } |
677 | 677 | global $wpdb; |
678 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
678 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
679 | 679 | $fields = self::get_fields_on_table($table_name); |
680 | - if (!in_array($column_name, $fields)){ |
|
681 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
680 | + if ( ! in_array($column_name, $fields)) { |
|
681 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
682 | 682 | //echo "alter query:$alter_query"; |
683 | 683 | return $wpdb->query($alter_query); |
684 | 684 | } |
@@ -697,15 +697,15 @@ discard block |
||
697 | 697 | * @param string $table_name, without prefixed $wpdb->prefix |
698 | 698 | * @return array of database column names |
699 | 699 | */ |
700 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
700 | + public static function get_fields_on_table($table_name = NULL) { |
|
701 | 701 | global $wpdb; |
702 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
703 | - if ( ! empty( $table_name )) { |
|
702 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
703 | + if ( ! empty($table_name)) { |
|
704 | 704 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
705 | 705 | if ($columns !== FALSE) { |
706 | 706 | $field_array = array(); |
707 | - foreach($columns as $column ){ |
|
708 | - $field_array[] = $column->Field;; |
|
707 | + foreach ($columns as $column) { |
|
708 | + $field_array[] = $column->Field; ; |
|
709 | 709 | } |
710 | 710 | return $field_array; |
711 | 711 | } |
@@ -723,12 +723,12 @@ discard block |
||
723 | 723 | * @param string $table_name |
724 | 724 | * @return bool |
725 | 725 | */ |
726 | - public static function db_table_is_empty( $table_name ) { |
|
726 | + public static function db_table_is_empty($table_name) { |
|
727 | 727 | global $wpdb; |
728 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
729 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
730 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
731 | - return absint( $count ) === 0 ? true : false; |
|
728 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
729 | + if (EEH_Activation::table_exists($table_name)) { |
|
730 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
731 | + return absint($count) === 0 ? true : false; |
|
732 | 732 | } |
733 | 733 | return false; |
734 | 734 | } |
@@ -743,9 +743,9 @@ discard block |
||
743 | 743 | * @param string $table_name |
744 | 744 | * @return bool | int |
745 | 745 | */ |
746 | - public static function delete_db_table_if_empty( $table_name ) { |
|
747 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
748 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
746 | + public static function delete_db_table_if_empty($table_name) { |
|
747 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
748 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
749 | 749 | } |
750 | 750 | return false; |
751 | 751 | } |
@@ -760,11 +760,11 @@ discard block |
||
760 | 760 | * @param string $table_name |
761 | 761 | * @return bool | int |
762 | 762 | */ |
763 | - public static function delete_unused_db_table( $table_name ) { |
|
763 | + public static function delete_unused_db_table($table_name) { |
|
764 | 764 | global $wpdb; |
765 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
766 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
767 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
765 | + if (EEH_Activation::table_exists($table_name)) { |
|
766 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
767 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
768 | 768 | } |
769 | 769 | return false; |
770 | 770 | } |
@@ -780,18 +780,18 @@ discard block |
||
780 | 780 | * @param string $index_name |
781 | 781 | * @return bool | int |
782 | 782 | */ |
783 | - public static function drop_index( $table_name, $index_name ) { |
|
784 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
783 | + public static function drop_index($table_name, $index_name) { |
|
784 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
785 | 785 | return FALSE; |
786 | 786 | } |
787 | 787 | global $wpdb; |
788 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
788 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
789 | 789 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
790 | 790 | if ( |
791 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) == $table_name |
|
792 | - && $wpdb->get_var( $index_exists_query ) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
791 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name |
|
792 | + && $wpdb->get_var($index_exists_query) == $table_name //using get_var with the $index_exists_query returns the table's name |
|
793 | 793 | ) { |
794 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
794 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
795 | 795 | } |
796 | 796 | return TRUE; |
797 | 797 | } |
@@ -807,27 +807,27 @@ discard block |
||
807 | 807 | * @return boolean success (whether database is setup properly or not) |
808 | 808 | */ |
809 | 809 | public static function create_database_tables() { |
810 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
810 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
811 | 811 | //find the migration script that sets the database to be compatible with the code |
812 | 812 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
813 | - if( $dms_name ){ |
|
814 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
815 | - $current_data_migration_script->set_migrating( false ); |
|
813 | + if ($dms_name) { |
|
814 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
815 | + $current_data_migration_script->set_migrating(false); |
|
816 | 816 | $current_data_migration_script->schema_changes_before_migration(); |
817 | 817 | $current_data_migration_script->schema_changes_after_migration(); |
818 | - if( $current_data_migration_script->get_errors() ){ |
|
819 | - if( WP_DEBUG ){ |
|
820 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
821 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
818 | + if ($current_data_migration_script->get_errors()) { |
|
819 | + if (WP_DEBUG) { |
|
820 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
821 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
822 | 822 | } |
823 | - }else{ |
|
824 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
823 | + } else { |
|
824 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
825 | 825 | } |
826 | 826 | return false; |
827 | 827 | } |
828 | 828 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
829 | - }else{ |
|
830 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
829 | + } else { |
|
830 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
831 | 831 | return false; |
832 | 832 | } |
833 | 833 | return true; |
@@ -847,27 +847,27 @@ discard block |
||
847 | 847 | public static function initialize_system_questions() { |
848 | 848 | // QUESTION GROUPS |
849 | 849 | global $wpdb; |
850 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
850 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
851 | 851 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
852 | 852 | // what we have |
853 | - $question_groups = $wpdb->get_col( $SQL ); |
|
853 | + $question_groups = $wpdb->get_col($SQL); |
|
854 | 854 | // check the response |
855 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
855 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
856 | 856 | // what we should have |
857 | - $QSG_systems = array( 1, 2 ); |
|
857 | + $QSG_systems = array(1, 2); |
|
858 | 858 | // loop thru what we should have and compare to what we have |
859 | - foreach ( $QSG_systems as $QSG_system ) { |
|
859 | + foreach ($QSG_systems as $QSG_system) { |
|
860 | 860 | // reset values array |
861 | 861 | $QSG_values = array(); |
862 | 862 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
863 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
863 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
864 | 864 | // add it |
865 | - switch ( $QSG_system ) { |
|
865 | + switch ($QSG_system) { |
|
866 | 866 | |
867 | 867 | case 1: |
868 | 868 | $QSG_values = array( |
869 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
870 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
869 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
870 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
871 | 871 | 'QSG_desc' => '', |
872 | 872 | 'QSG_order' => 1, |
873 | 873 | 'QSG_show_group_name' => 1, |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | |
880 | 880 | case 2: |
881 | 881 | $QSG_values = array( |
882 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
883 | - 'QSG_identifier' => 'address-information-' . time(), |
|
882 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
883 | + 'QSG_identifier' => 'address-information-'.time(), |
|
884 | 884 | 'QSG_desc' => '', |
885 | 885 | 'QSG_order' => 2, |
886 | 886 | 'QSG_show_group_name' => 1, |
@@ -892,14 +892,14 @@ discard block |
||
892 | 892 | |
893 | 893 | } |
894 | 894 | // make sure we have some values before inserting them |
895 | - if ( ! empty( $QSG_values )) { |
|
895 | + if ( ! empty($QSG_values)) { |
|
896 | 896 | // insert system question |
897 | 897 | $wpdb->insert( |
898 | 898 | $table_name, |
899 | 899 | $QSG_values, |
900 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
900 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
901 | 901 | ); |
902 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
902 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
903 | 903 | } |
904 | 904 | } |
905 | 905 | } |
@@ -908,10 +908,10 @@ discard block |
||
908 | 908 | |
909 | 909 | // QUESTIONS |
910 | 910 | global $wpdb; |
911 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
911 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
912 | 912 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
913 | 913 | // what we have |
914 | - $questions = $wpdb->get_col( $SQL ); |
|
914 | + $questions = $wpdb->get_col($SQL); |
|
915 | 915 | // what we should have |
916 | 916 | $QST_systems = array( |
917 | 917 | 'fname', |
@@ -928,25 +928,25 @@ discard block |
||
928 | 928 | $order_for_group_1 = 1; |
929 | 929 | $order_for_group_2 = 1; |
930 | 930 | // loop thru what we should have and compare to what we have |
931 | - foreach ( $QST_systems as $QST_system ) { |
|
931 | + foreach ($QST_systems as $QST_system) { |
|
932 | 932 | // reset values array |
933 | 933 | $QST_values = array(); |
934 | 934 | // if we don't have what we should have |
935 | - if ( ! in_array( $QST_system, $questions )) { |
|
935 | + if ( ! in_array($QST_system, $questions)) { |
|
936 | 936 | // add it |
937 | - switch ( $QST_system ) { |
|
937 | + switch ($QST_system) { |
|
938 | 938 | |
939 | 939 | case 'fname': |
940 | 940 | $QST_values = array( |
941 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
942 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
941 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
942 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
943 | 943 | 'QST_system' => 'fname', |
944 | 944 | 'QST_type' => 'TEXT', |
945 | 945 | 'QST_required' => 1, |
946 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
946 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
947 | 947 | 'QST_order' => 1, |
948 | 948 | 'QST_admin_only' => 0, |
949 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
949 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
950 | 950 | 'QST_wp_user' => self::get_default_creator_id(), |
951 | 951 | 'QST_deleted' => 0 |
952 | 952 | ); |
@@ -954,15 +954,15 @@ discard block |
||
954 | 954 | |
955 | 955 | case 'lname': |
956 | 956 | $QST_values = array( |
957 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
958 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
957 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
958 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
959 | 959 | 'QST_system' => 'lname', |
960 | 960 | 'QST_type' => 'TEXT', |
961 | 961 | 'QST_required' => 1, |
962 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
962 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
963 | 963 | 'QST_order' => 2, |
964 | 964 | 'QST_admin_only' => 0, |
965 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
965 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
966 | 966 | 'QST_wp_user' => self::get_default_creator_id(), |
967 | 967 | 'QST_deleted' => 0 |
968 | 968 | ); |
@@ -970,15 +970,15 @@ discard block |
||
970 | 970 | |
971 | 971 | case 'email': |
972 | 972 | $QST_values = array( |
973 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
974 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
973 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
974 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
975 | 975 | 'QST_system' => 'email', |
976 | 976 | 'QST_type' => 'TEXT', |
977 | 977 | 'QST_required' => 1, |
978 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
978 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
979 | 979 | 'QST_order' => 3, |
980 | 980 | 'QST_admin_only' => 0, |
981 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
981 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
982 | 982 | 'QST_wp_user' => self::get_default_creator_id(), |
983 | 983 | 'QST_deleted' => 0 |
984 | 984 | ); |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | |
987 | 987 | case 'address': |
988 | 988 | $QST_values = array( |
989 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
990 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
989 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
990 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
991 | 991 | 'QST_system' => 'address', |
992 | 992 | 'QST_type' => 'TEXT', |
993 | 993 | 'QST_required' => 0, |
994 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
994 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
995 | 995 | 'QST_order' => 4, |
996 | 996 | 'QST_admin_only' => 0, |
997 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
997 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
998 | 998 | 'QST_wp_user' => self::get_default_creator_id(), |
999 | 999 | 'QST_deleted' => 0 |
1000 | 1000 | ); |
@@ -1002,15 +1002,15 @@ discard block |
||
1002 | 1002 | |
1003 | 1003 | case 'address2': |
1004 | 1004 | $QST_values = array( |
1005 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
1006 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
1005 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1006 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1007 | 1007 | 'QST_system' => 'address2', |
1008 | 1008 | 'QST_type' => 'TEXT', |
1009 | 1009 | 'QST_required' => 0, |
1010 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1010 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1011 | 1011 | 'QST_order' => 5, |
1012 | 1012 | 'QST_admin_only' => 0, |
1013 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1013 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1014 | 1014 | 'QST_wp_user' => self::get_default_creator_id(), |
1015 | 1015 | 'QST_deleted' => 0 |
1016 | 1016 | ); |
@@ -1018,15 +1018,15 @@ discard block |
||
1018 | 1018 | |
1019 | 1019 | case 'city': |
1020 | 1020 | $QST_values = array( |
1021 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1022 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1021 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1022 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1023 | 1023 | 'QST_system' => 'city', |
1024 | 1024 | 'QST_type' => 'TEXT', |
1025 | 1025 | 'QST_required' => 0, |
1026 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1026 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1027 | 1027 | 'QST_order' => 6, |
1028 | 1028 | 'QST_admin_only' => 0, |
1029 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1029 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1030 | 1030 | 'QST_wp_user' => self::get_default_creator_id(), |
1031 | 1031 | 'QST_deleted' => 0 |
1032 | 1032 | ); |
@@ -1034,12 +1034,12 @@ discard block |
||
1034 | 1034 | |
1035 | 1035 | case 'state': |
1036 | 1036 | $QST_values = array( |
1037 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1038 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1037 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1038 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1039 | 1039 | 'QST_system' => 'state', |
1040 | 1040 | 'QST_type' => 'STATE', |
1041 | 1041 | 'QST_required' => 0, |
1042 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1042 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1043 | 1043 | 'QST_order' => 7, |
1044 | 1044 | 'QST_admin_only' => 0, |
1045 | 1045 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1049,12 +1049,12 @@ discard block |
||
1049 | 1049 | |
1050 | 1050 | case 'country' : |
1051 | 1051 | $QST_values = array( |
1052 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1053 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1052 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1053 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1054 | 1054 | 'QST_system' => 'country', |
1055 | 1055 | 'QST_type' => 'COUNTRY', |
1056 | 1056 | 'QST_required' => 0, |
1057 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1057 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1058 | 1058 | 'QST_order' => 8, |
1059 | 1059 | 'QST_admin_only' => 0, |
1060 | 1060 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1064,15 +1064,15 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | case 'zip': |
1066 | 1066 | $QST_values = array( |
1067 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1068 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1067 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1068 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1069 | 1069 | 'QST_system' => 'zip', |
1070 | 1070 | 'QST_type' => 'TEXT', |
1071 | 1071 | 'QST_required' => 0, |
1072 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1072 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1073 | 1073 | 'QST_order' => 9, |
1074 | 1074 | 'QST_admin_only' => 0, |
1075 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1075 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1076 | 1076 | 'QST_wp_user' => self::get_default_creator_id(), |
1077 | 1077 | 'QST_deleted' => 0 |
1078 | 1078 | ); |
@@ -1080,49 +1080,49 @@ discard block |
||
1080 | 1080 | |
1081 | 1081 | case 'phone': |
1082 | 1082 | $QST_values = array( |
1083 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1084 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1083 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1084 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1085 | 1085 | 'QST_system' => 'phone', |
1086 | 1086 | 'QST_type' => 'TEXT', |
1087 | 1087 | 'QST_required' => 0, |
1088 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1088 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1089 | 1089 | 'QST_order' => 10, |
1090 | 1090 | 'QST_admin_only' => 0, |
1091 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1091 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1092 | 1092 | 'QST_wp_user' => self::get_default_creator_id(), |
1093 | 1093 | 'QST_deleted' => 0 |
1094 | 1094 | ); |
1095 | 1095 | break; |
1096 | 1096 | |
1097 | 1097 | } |
1098 | - if ( ! empty( $QST_values )) { |
|
1098 | + if ( ! empty($QST_values)) { |
|
1099 | 1099 | // insert system question |
1100 | 1100 | $wpdb->insert( |
1101 | 1101 | $table_name, |
1102 | 1102 | $QST_values, |
1103 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1103 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1104 | 1104 | ); |
1105 | 1105 | $QST_ID = $wpdb->insert_id; |
1106 | 1106 | |
1107 | 1107 | // QUESTION GROUP QUESTIONS |
1108 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1108 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1109 | 1109 | $system_question_we_want = EEM_Question_Group::system_personal; |
1110 | 1110 | } else { |
1111 | 1111 | $system_question_we_want = EEM_Question_Group::system_address; |
1112 | 1112 | } |
1113 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1114 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1113 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1114 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1115 | 1115 | } else { |
1116 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1117 | - if( is_array( $id_col ) ) { |
|
1118 | - $QSG_ID = reset( $id_col ); |
|
1116 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1117 | + if (is_array($id_col)) { |
|
1118 | + $QSG_ID = reset($id_col); |
|
1119 | 1119 | } else { |
1120 | 1120 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1121 | 1121 | EE_Log::instance()->log( |
1122 | 1122 | __FILE__, |
1123 | 1123 | __FUNCTION__, |
1124 | 1124 | sprintf( |
1125 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1125 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1126 | 1126 | $QST_ID ), |
1127 | 1127 | 'error' ); |
1128 | 1128 | continue; |
@@ -1131,9 +1131,9 @@ discard block |
||
1131 | 1131 | |
1132 | 1132 | // add system questions to groups |
1133 | 1133 | $wpdb->insert( |
1134 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1135 | - array( 'QSG_ID' => $QSG_ID , 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID==1)? $order_for_group_1++ : $order_for_group_2++ ), |
|
1136 | - array( '%d', '%d','%d' ) |
|
1134 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1135 | + array('QSG_ID' => $QSG_ID, 'QST_ID' => $QST_ID, 'QGQ_order'=>($QSG_ID == 1) ? $order_for_group_1++ : $order_for_group_2++), |
|
1136 | + array('%d', '%d', '%d') |
|
1137 | 1137 | ); |
1138 | 1138 | } |
1139 | 1139 | } |
@@ -1145,11 +1145,11 @@ discard block |
||
1145 | 1145 | * Makes sure the default payment method (Invoice) is active. |
1146 | 1146 | * This used to be done automatically as part of constructing the old gateways config |
1147 | 1147 | */ |
1148 | - public static function insert_default_payment_methods(){ |
|
1149 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1150 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1151 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1152 | - }else{ |
|
1148 | + public static function insert_default_payment_methods() { |
|
1149 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1150 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1151 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1152 | + } else { |
|
1153 | 1153 | EEM_Payment_Method::instance()->verify_button_urls(); |
1154 | 1154 | } |
1155 | 1155 | } |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | |
1166 | 1166 | global $wpdb; |
1167 | 1167 | |
1168 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1168 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1169 | 1169 | |
1170 | 1170 | $table_name = EEM_Status::instance()->table(); |
1171 | 1171 | |
@@ -1231,38 +1231,38 @@ discard block |
||
1231 | 1231 | * @return boolean success of verifying upload directories exist |
1232 | 1232 | */ |
1233 | 1233 | public static function create_upload_directories() { |
1234 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1234 | + EE_Registry::instance()->load_helper('File'); |
|
1235 | 1235 | // Create the required folders |
1236 | 1236 | $folders = array( |
1237 | 1237 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1238 | 1238 | EVENT_ESPRESSO_GATEWAY_DIR, |
1239 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1240 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1241 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1239 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1240 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1241 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1242 | 1242 | ); |
1243 | - foreach ( $folders as $folder ) { |
|
1243 | + foreach ($folders as $folder) { |
|
1244 | 1244 | try { |
1245 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1246 | - @ chmod( $folder, 0755 ); |
|
1247 | - } catch( EE_Error $e ){ |
|
1245 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1246 | + @ chmod($folder, 0755); |
|
1247 | + } catch (EE_Error $e) { |
|
1248 | 1248 | EE_Error::add_error( |
1249 | 1249 | sprintf( |
1250 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1250 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1251 | 1251 | $folder, |
1252 | - '<br />' . $e->getMessage() |
|
1252 | + '<br />'.$e->getMessage() |
|
1253 | 1253 | ), |
1254 | 1254 | __FILE__, __FUNCTION__, __LINE__ |
1255 | 1255 | ); |
1256 | 1256 | //indicate we'll need to fix this later |
1257 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1257 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1258 | 1258 | return FALSE; |
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1262 | 1262 | //is disabled, there might be activation errors recorded in there |
1263 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1263 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1264 | 1264 | //remember EE's folders are all good |
1265 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1265 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1266 | 1266 | return TRUE; |
1267 | 1267 | } |
1268 | 1268 | |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | * @return boolean |
1276 | 1276 | */ |
1277 | 1277 | public static function upload_directories_incomplete() { |
1278 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1278 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | |
@@ -1294,16 +1294,16 @@ discard block |
||
1294 | 1294 | $installed_messengers = $default_messengers = array(); |
1295 | 1295 | |
1296 | 1296 | //include our helper |
1297 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1297 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1298 | 1298 | |
1299 | 1299 | //get all installed messenger objects |
1300 | 1300 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1301 | 1301 | |
1302 | 1302 | //let's setup the $installed messengers in an array AND the messengers that are set to be activated on install. |
1303 | - foreach ( $installed['messengers'] as $msgr ) { |
|
1304 | - if ( $msgr instanceof EE_messenger ) { |
|
1303 | + foreach ($installed['messengers'] as $msgr) { |
|
1304 | + if ($msgr instanceof EE_messenger) { |
|
1305 | 1305 | $installed_messengers[$msgr->name] = $msgr; |
1306 | - if ( $msgr->activate_on_install ) { |
|
1306 | + if ($msgr->activate_on_install) { |
|
1307 | 1307 | $default_messengers[] = $msgr->name; |
1308 | 1308 | } |
1309 | 1309 | } |
@@ -1313,36 +1313,36 @@ discard block |
||
1313 | 1313 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1314 | 1314 | |
1315 | 1315 | //things that have already been activated before |
1316 | - $has_activated = get_option( 'ee_has_activated_messenger' ); |
|
1316 | + $has_activated = get_option('ee_has_activated_messenger'); |
|
1317 | 1317 | |
1318 | 1318 | //do an initial loop to determine if we need to continue |
1319 | 1319 | $def_ms = array(); |
1320 | - foreach ( $default_messengers as $msgr ) { |
|
1321 | - if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) continue; |
|
1320 | + foreach ($default_messengers as $msgr) { |
|
1321 | + if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) continue; |
|
1322 | 1322 | $def_ms[] = $msgr; |
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | //setup the $installed_mts in an array |
1326 | - foreach ( $installed['message_types'] as $imt ) { |
|
1327 | - if ( $imt instanceof EE_message_type ) { |
|
1326 | + foreach ($installed['message_types'] as $imt) { |
|
1327 | + if ($imt instanceof EE_message_type) { |
|
1328 | 1328 | $installed_mts[$imt->name] = $imt; |
1329 | 1329 | } |
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | //loop through default array for default messengers (if present) |
1333 | - if ( ! empty( $def_ms ) ) { |
|
1334 | - foreach ( $def_ms as $messenger ) { |
|
1333 | + if ( ! empty($def_ms)) { |
|
1334 | + foreach ($def_ms as $messenger) { |
|
1335 | 1335 | //all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger. |
1336 | - if ( ! isset( $installed_messengers[$messenger] )) { |
|
1336 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1337 | 1337 | continue; |
1338 | 1338 | } |
1339 | 1339 | /** @var EE_messenger[] $installed_messengers */ |
1340 | 1340 | $default_mts = $installed_messengers[$messenger]->get_default_message_types(); |
1341 | 1341 | $active_messengers[$messenger]['obj'] = $installed_messengers[$messenger]; |
1342 | - foreach ( $default_mts as $index => $mt ) { |
|
1342 | + foreach ($default_mts as $index => $mt) { |
|
1343 | 1343 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1344 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1345 | - unset( $default_mts[$index] ); |
|
1344 | + if ( ! isset($installed_mts[$mt])) { |
|
1345 | + unset($default_mts[$index]); |
|
1346 | 1346 | continue; |
1347 | 1347 | } |
1348 | 1348 | |
@@ -1351,41 +1351,41 @@ discard block |
||
1351 | 1351 | /** @var EE_message_type[] $installed_mts */ |
1352 | 1352 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1353 | 1353 | $settings = array(); |
1354 | - if ( is_array( $settings_fields ) ) { |
|
1355 | - foreach ( $settings_fields as $field => $values ) { |
|
1356 | - if ( isset( $values['default'] ) ) { |
|
1354 | + if (is_array($settings_fields)) { |
|
1355 | + foreach ($settings_fields as $field => $values) { |
|
1356 | + if (isset($values['default'])) { |
|
1357 | 1357 | $settings[$field] = $values['default']; |
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1362 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1363 | 1363 | $has_activated[$messenger][] = $mt; |
1364 | 1364 | } |
1365 | 1365 | |
1366 | 1366 | //setup any initial settings for the messenger |
1367 | 1367 | $msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields(); |
1368 | 1368 | |
1369 | - if ( !empty( $msgr_settings ) ) { |
|
1370 | - foreach ( $msgr_settings as $field => $value ) { |
|
1369 | + if ( ! empty($msgr_settings)) { |
|
1370 | + foreach ($msgr_settings as $field => $value) { |
|
1371 | 1371 | $active_messengers[$messenger]['settings'][$field] = $value; |
1372 | 1372 | } |
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | //now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate. |
1376 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1376 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1377 | 1377 | |
1378 | 1378 | //let's generate all the templates but only if the messenger has default_mts (otherwise its just activated). |
1379 | - if ( !empty( $default_mts ) ) { |
|
1380 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE ); |
|
1379 | + if ( ! empty($default_mts)) { |
|
1380 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE); |
|
1381 | 1381 | } |
1382 | 1382 | } |
1383 | 1383 | } //end check for empty( $def_ms ) |
1384 | 1384 | |
1385 | 1385 | //still need to see if there are any message types to activate for active messengers |
1386 | - foreach ( $active_messengers as $messenger => $settings ) { |
|
1386 | + foreach ($active_messengers as $messenger => $settings) { |
|
1387 | 1387 | $msg_obj = $settings['obj']; |
1388 | - if ( ! $msg_obj instanceof EE_messenger ) { |
|
1388 | + if ( ! $msg_obj instanceof EE_messenger) { |
|
1389 | 1389 | continue; |
1390 | 1390 | } |
1391 | 1391 | |
@@ -1393,45 +1393,45 @@ discard block |
||
1393 | 1393 | $new_default_mts = array(); |
1394 | 1394 | |
1395 | 1395 | //loop through each default mt reported by the messenger and make sure its set in its active db entry. |
1396 | - foreach( $all_default_mts as $index => $mt ) { |
|
1396 | + foreach ($all_default_mts as $index => $mt) { |
|
1397 | 1397 | //already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated). |
1398 | - if ( ( isset( $has_activated[$messenger] ) && in_array($mt, $has_activated[$messenger]) ) || isset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) || EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE ) ) { |
|
1398 | + if ((isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger])) || isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) || EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)) { |
|
1399 | 1399 | continue; |
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | //is there an installed_mt matching the default string? If not then nothing to do here. |
1403 | - if ( ! isset( $installed_mts[$mt] ) ) { |
|
1404 | - unset( $all_default_mts[$mt] ); |
|
1403 | + if ( ! isset($installed_mts[$mt])) { |
|
1404 | + unset($all_default_mts[$mt]); |
|
1405 | 1405 | continue; |
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | $settings_fields = $installed_mts[$mt]->get_admin_settings_fields(); |
1409 | 1409 | $settings = array(); |
1410 | - if ( is_array( $settings_fields ) ) { |
|
1411 | - foreach ( $settings_fields as $field => $values ) { |
|
1412 | - if ( isset( $values['default'] ) ) { |
|
1410 | + if (is_array($settings_fields)) { |
|
1411 | + foreach ($settings_fields as $field => $values) { |
|
1412 | + if (isset($values['default'])) { |
|
1413 | 1413 | $settings[$field] = $values['default']; |
1414 | 1414 | } |
1415 | 1415 | } |
1416 | 1416 | } |
1417 | 1417 | |
1418 | - $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings; |
|
1418 | + $active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings; |
|
1419 | 1419 | $new_default_mts[] = $mt; |
1420 | 1420 | $has_activated[$messenger][] = $mt; |
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | |
1424 | - if ( ! empty( $new_default_mts ) ) { |
|
1425 | - $success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE ); |
|
1424 | + if ( ! empty($new_default_mts)) { |
|
1425 | + $success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE); |
|
1426 | 1426 | } |
1427 | 1427 | |
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | //now let's save the settings for this messenger! |
1431 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1431 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1432 | 1432 | |
1433 | 1433 | //update $has_activated record |
1434 | - update_option( 'ee_has_activated_messenger', $has_activated ); |
|
1434 | + update_option('ee_has_activated_messenger', $has_activated); |
|
1435 | 1435 | |
1436 | 1436 | //that's it! |
1437 | 1437 | return $success; |
@@ -1451,47 +1451,47 @@ discard block |
||
1451 | 1451 | */ |
1452 | 1452 | public static function validate_messages_system() { |
1453 | 1453 | //include our helper |
1454 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
1454 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
1455 | 1455 | |
1456 | 1456 | //get active and installed messengers/message types. |
1457 | 1457 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
1458 | 1458 | $installed = EEH_MSG_Template::get_installed_message_objects(); |
1459 | 1459 | $installed_messengers = $installed_mts = array(); |
1460 | 1460 | //set up the arrays so they can be handled easier. |
1461 | - foreach( $installed['messengers'] as $im ) { |
|
1462 | - if ( $im instanceof EE_messenger ) { |
|
1461 | + foreach ($installed['messengers'] as $im) { |
|
1462 | + if ($im instanceof EE_messenger) { |
|
1463 | 1463 | $installed_messengers[$im->name] = $im; |
1464 | 1464 | } |
1465 | 1465 | } |
1466 | - foreach( $installed['message_types'] as $imt ) { |
|
1467 | - if ( $imt instanceof EE_message_type ) { |
|
1466 | + foreach ($installed['message_types'] as $imt) { |
|
1467 | + if ($imt instanceof EE_message_type) { |
|
1468 | 1468 | $installed_mts[$imt->name] = $imt; |
1469 | 1469 | } |
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | //now let's loop through the active array and validate |
1473 | - foreach( $active_messengers as $messenger => $active_details ) { |
|
1473 | + foreach ($active_messengers as $messenger => $active_details) { |
|
1474 | 1474 | //first let's see if this messenger is installed. |
1475 | - if ( ! isset( $installed_messengers[$messenger] ) ) { |
|
1475 | + if ( ! isset($installed_messengers[$messenger])) { |
|
1476 | 1476 | //not set so let's just remove from actives and make sure templates are inactive. |
1477 | - unset( $active_messengers[$messenger] ); |
|
1478 | - EEH_MSG_Template::update_to_inactive( $messenger ); |
|
1477 | + unset($active_messengers[$messenger]); |
|
1478 | + EEH_MSG_Template::update_to_inactive($messenger); |
|
1479 | 1479 | continue; |
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | //messenger is active, so let's just make sure that any active message types not installed are deactivated. |
1483 | - $mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array(); |
|
1484 | - foreach ( $mts as $mt_name => $mt ) { |
|
1485 | - if ( ! isset( $installed_mts[$mt_name] ) ) { |
|
1486 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] ); |
|
1487 | - EEH_MSG_Template::update_to_inactive( $messenger, $mt_name ); |
|
1483 | + $mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array(); |
|
1484 | + foreach ($mts as $mt_name => $mt) { |
|
1485 | + if ( ! isset($installed_mts[$mt_name])) { |
|
1486 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]); |
|
1487 | + EEH_MSG_Template::update_to_inactive($messenger, $mt_name); |
|
1488 | 1488 | } |
1489 | 1489 | } |
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | //all done! let's update the active_messengers. |
1493 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
1494 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1493 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
1494 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1495 | 1495 | return; |
1496 | 1496 | } |
1497 | 1497 | |
@@ -1505,12 +1505,12 @@ discard block |
||
1505 | 1505 | * @static |
1506 | 1506 | * @return void |
1507 | 1507 | */ |
1508 | - public static function create_no_ticket_prices_array(){ |
|
1508 | + public static function create_no_ticket_prices_array() { |
|
1509 | 1509 | // this creates an array for tracking events that have no active ticket prices created |
1510 | 1510 | // this allows us to warn admins of the situation so that it can be corrected |
1511 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1512 | - if ( ! $espresso_no_ticket_prices ) { |
|
1513 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1511 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1512 | + if ( ! $espresso_no_ticket_prices) { |
|
1513 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1514 | 1514 | } |
1515 | 1515 | } |
1516 | 1516 | |
@@ -1532,24 +1532,24 @@ discard block |
||
1532 | 1532 | * Finds all our EE4 custom post types, and deletes them and their associated data (like post meta or term relations)/ |
1533 | 1533 | * @global wpdb $wpdb |
1534 | 1534 | */ |
1535 | - public static function delete_all_espresso_cpt_data(){ |
|
1535 | + public static function delete_all_espresso_cpt_data() { |
|
1536 | 1536 | global $wpdb; |
1537 | 1537 | //get all the CPT post_types |
1538 | 1538 | $ee_post_types = array(); |
1539 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1540 | - if ( method_exists( $model_name, 'instance' )) { |
|
1541 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1542 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1543 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1539 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1540 | + if (method_exists($model_name, 'instance')) { |
|
1541 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1542 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1543 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1544 | 1544 | } |
1545 | 1545 | } |
1546 | 1546 | } |
1547 | 1547 | //get all our CPTs |
1548 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1548 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1549 | 1549 | $cpt_ids = $wpdb->get_col($query); |
1550 | 1550 | //delete each post meta and term relations too |
1551 | - foreach($cpt_ids as $post_id){ |
|
1552 | - wp_delete_post($post_id,true); |
|
1551 | + foreach ($cpt_ids as $post_id) { |
|
1552 | + wp_delete_post($post_id, true); |
|
1553 | 1553 | } |
1554 | 1554 | } |
1555 | 1555 | |
@@ -1563,18 +1563,18 @@ discard block |
||
1563 | 1563 | * @param bool $remove_all |
1564 | 1564 | * @return void |
1565 | 1565 | */ |
1566 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1566 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1567 | 1567 | global $wpdb; |
1568 | 1568 | $undeleted_tables = array(); |
1569 | 1569 | |
1570 | 1570 | // load registry |
1571 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1572 | - if ( method_exists( $model_name, 'instance' )) { |
|
1573 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1574 | - if ( $model_obj instanceof EEM_Base ) { |
|
1575 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1576 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1577 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1571 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1572 | + if (method_exists($model_name, 'instance')) { |
|
1573 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1574 | + if ($model_obj instanceof EEM_Base) { |
|
1575 | + foreach ($model_obj->get_tables() as $table) { |
|
1576 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1577 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1578 | 1578 | case false : |
1579 | 1579 | $undeleted_tables[] = $table->get_table_name(); |
1580 | 1580 | break; |
@@ -1599,8 +1599,8 @@ discard block |
||
1599 | 1599 | 'esp_promotion_rule', |
1600 | 1600 | 'esp_rule' |
1601 | 1601 | ); |
1602 | - foreach( $tables_without_models as $table ){ |
|
1603 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1602 | + foreach ($tables_without_models as $table) { |
|
1603 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1604 | 1604 | } |
1605 | 1605 | |
1606 | 1606 | |
@@ -1638,58 +1638,58 @@ discard block |
||
1638 | 1638 | 'ee_job_parameters_' => false, |
1639 | 1639 | 'ee_upload_directories_incomplete' => true, |
1640 | 1640 | ); |
1641 | - if( is_main_site() ) { |
|
1642 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1641 | + if (is_main_site()) { |
|
1642 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1643 | 1643 | } |
1644 | 1644 | |
1645 | 1645 | $undeleted_options = array(); |
1646 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1646 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1647 | 1647 | |
1648 | - if( $no_wildcard ){ |
|
1649 | - if( ! delete_option( $option_name ) ){ |
|
1648 | + if ($no_wildcard) { |
|
1649 | + if ( ! delete_option($option_name)) { |
|
1650 | 1650 | $undeleted_options[] = $option_name; |
1651 | 1651 | } |
1652 | - }else{ |
|
1653 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1654 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1655 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1652 | + } else { |
|
1653 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1654 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1655 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1656 | 1656 | $undeleted_options[] = $option_name_from_wildcard; |
1657 | 1657 | } |
1658 | 1658 | } |
1659 | 1659 | } |
1660 | 1660 | } |
1661 | 1661 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1662 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1662 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1663 | 1663 | |
1664 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1664 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1665 | 1665 | $db_update_sans_ee4 = array(); |
1666 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1667 | - if( $version[0] =='3'){//if its NON EE4 |
|
1666 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1667 | + if ($version[0] == '3') {//if its NON EE4 |
|
1668 | 1668 | $db_update_sans_ee4[$version] = $times_activated; |
1669 | 1669 | } |
1670 | 1670 | } |
1671 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1671 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | $errors = ''; |
1675 | - if ( ! empty( $undeleted_tables )) { |
|
1675 | + if ( ! empty($undeleted_tables)) { |
|
1676 | 1676 | $errors .= sprintf( |
1677 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1677 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1678 | 1678 | '<br/>', |
1679 | - implode( ',<br/>', $undeleted_tables ) |
|
1679 | + implode(',<br/>', $undeleted_tables) |
|
1680 | 1680 | ); |
1681 | 1681 | } |
1682 | - if ( ! empty( $undeleted_options )) { |
|
1683 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1682 | + if ( ! empty($undeleted_options)) { |
|
1683 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1684 | 1684 | $errors .= sprintf( |
1685 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1685 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1686 | 1686 | '<br/>', |
1687 | - implode( ',<br/>', $undeleted_options ) |
|
1687 | + implode(',<br/>', $undeleted_options) |
|
1688 | 1688 | ); |
1689 | 1689 | |
1690 | 1690 | } |
1691 | - if ( $errors != '' ) { |
|
1692 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1691 | + if ($errors != '') { |
|
1692 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1693 | 1693 | } |
1694 | 1694 | } |
1695 | 1695 | |
@@ -1699,23 +1699,23 @@ discard block |
||
1699 | 1699 | * @param string $table_name with or without $wpdb->prefix |
1700 | 1700 | * @return boolean |
1701 | 1701 | */ |
1702 | - public static function table_exists( $table_name ){ |
|
1702 | + public static function table_exists($table_name) { |
|
1703 | 1703 | global $wpdb, $EZSQL_ERROR; |
1704 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1704 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1705 | 1705 | //ignore if this causes an sql error |
1706 | 1706 | $old_error = $wpdb->last_error; |
1707 | 1707 | $old_suppress_errors = $wpdb->suppress_errors(); |
1708 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1708 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1709 | 1709 | $ezsql_error_cache = $EZSQL_ERROR; |
1710 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1711 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1712 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1710 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1711 | + $wpdb->show_errors($old_show_errors_value); |
|
1712 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1713 | 1713 | $new_error = $wpdb->last_error; |
1714 | 1714 | $wpdb->last_error = $old_error; |
1715 | 1715 | $EZSQL_ERROR = $ezsql_error_cache; |
1716 | - if( empty( $new_error ) ){ |
|
1716 | + if (empty($new_error)) { |
|
1717 | 1717 | return TRUE; |
1718 | - }else{ |
|
1718 | + } else { |
|
1719 | 1719 | return FALSE; |
1720 | 1720 | } |
1721 | 1721 | } |
@@ -1723,7 +1723,7 @@ discard block |
||
1723 | 1723 | /** |
1724 | 1724 | * Resets the cache on EEH_Activation |
1725 | 1725 | */ |
1726 | - public static function reset(){ |
|
1726 | + public static function reset() { |
|
1727 | 1727 | self::$_default_creator_id = NULL; |
1728 | 1728 | self::$_initialized_db_content_already_in_this_request = false; |
1729 | 1729 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | * @since 4.8.30.rc.009 |
14 | 14 | * |
15 | 15 | */ |
16 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
17 | - exit( 'No direct script access allowed' ); |
|
16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | -class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper{ |
|
20 | +class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper { |
|
21 | 21 | /** |
22 | 22 | * |
23 | 23 | * @var EE_Registration |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @param EE_Registration $reg |
30 | 30 | * @param array $options |
31 | 31 | */ |
32 | - public function __construct( EE_Registration $reg, $options = array() ) { |
|
32 | + public function __construct(EE_Registration $reg, $options = array()) { |
|
33 | 33 | $this->_registration = $reg; |
34 | - if( ! isset( $options[ 'layout_strategy' ] ) ) { |
|
35 | - $options[ 'layout_strategy' ] = new EE_Admin_Two_Column_Layout(); |
|
34 | + if ( ! isset($options['layout_strategy'])) { |
|
35 | + $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
36 | 36 | } |
37 | - if( ! isset( $options[ 'html_id' ] ) ) { |
|
38 | - $options[ 'html_id' ] = 'reg-admin-attendee-questions-frm'; |
|
37 | + if ( ! isset($options['html_id'])) { |
|
38 | + $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
39 | 39 | } |
40 | 40 | $this->build_form_from_registration(); |
41 | - parent::__construct( $options ); |
|
41 | + parent::__construct($options); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | public function build_form_from_registration() { |
54 | 54 | $reg = $this->get_registration(); |
55 | - if( ! $reg instanceof EE_Registration ) { |
|
56 | - throw new EE_Error( __( 'We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso') ); |
|
55 | + if ( ! $reg instanceof EE_Registration) { |
|
56 | + throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
57 | 57 | } |
58 | 58 | //we want to get all their question groups |
59 | 59 | $question_groups = EEM_Question_Group::instance()->get_all( |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | 'Event_Question_Group.EQG_primary' => $reg->count() == 1 ? TRUE : FALSE, |
64 | 64 | 'Question.QST_system' => '' |
65 | 65 | ), |
66 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
66 | + 'order_by' => array('QSG_order' => 'ASC') |
|
67 | 67 | ) |
68 | 68 | ); |
69 | 69 | //get each question groups questions |
70 | - foreach( $question_groups as $question_group ) { |
|
71 | - if ( $question_group instanceof EE_Question_Group ) { |
|
72 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
70 | + foreach ($question_groups as $question_group) { |
|
71 | + if ($question_group instanceof EE_Question_Group) { |
|
72 | + $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group( |
|
73 | 73 | $question_group, |
74 | 74 | $reg |
75 | 75 | ); |
@@ -86,24 +86,24 @@ discard block |
||
86 | 86 | * @return \EE_Form_Section_Proper |
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | - public function build_subform_from_question_group( $question_group, $registration ) { |
|
90 | - if( ! $question_group instanceof EE_Question_Group || |
|
89 | + public function build_subform_from_question_group($question_group, $registration) { |
|
90 | + if ( ! $question_group instanceof EE_Question_Group || |
|
91 | 91 | ! $registration instanceof EE_Registration) { |
92 | - throw new EE_Error( __( 'A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso' ) ); |
|
92 | + throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
93 | 93 | } |
94 | 94 | $parts_of_subsection = array( |
95 | 95 | 'title' => new EE_Form_Section_HTML( |
96 | - EEH_HTML::h5( $question_group->name(), |
|
96 | + EEH_HTML::h5($question_group->name(), |
|
97 | 97 | $question_group->identifier(), |
98 | - 'espresso-question-group-title-h5 section-title' ) |
|
98 | + 'espresso-question-group-title-h5 section-title') |
|
99 | 99 | ) |
100 | 100 | ); |
101 | - foreach( $question_group->questions( array( array( 'QST_system' => '' ))) as $question ) { |
|
102 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input( $registration ); |
|
101 | + foreach ($question_group->questions(array(array('QST_system' => ''))) as $question) { |
|
102 | + $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration); |
|
103 | 103 | } |
104 | - $parts_of_subsection[ 'edit_link' ] = new EE_Form_Section_HTML( |
|
105 | - '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '"> |
|
106 | - <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span> |
|
104 | + $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
105 | + '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" title="'.esc_attr__('click to edit question', 'event_espresso').'"> |
|
106 | + <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span> |
|
107 | 107 | <div class="dashicons dashicons-edit"></div> |
108 | 108 | </a></td></tr>' |
109 | 109 | ); |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | protected function _normalize($req_data) { |
124 | 124 | $this->_received_submission = TRUE; |
125 | 125 | $this->_validation_errors = array(); |
126 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
127 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
128 | - try{ |
|
126 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
127 | + if ($subsection->form_data_present_in($req_data)) { |
|
128 | + try { |
|
129 | 129 | $subsection->_normalize($req_data); |
130 | - }catch( EE_Validation_Error $e ){ |
|
131 | - $subsection->add_validation_error( $e ); |
|
130 | + } catch (EE_Validation_Error $e) { |
|
131 | + $subsection->add_validation_error($e); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | * calling parent::_validate() first. |
144 | 144 | */ |
145 | 145 | protected function _validate() { |
146 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
147 | - if( $subsection->form_data_present_in( array_merge( $_GET, $_POST ) ) ) { |
|
148 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
149 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
146 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
147 | + if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
|
148 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
149 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
150 | 150 | } |
151 | 151 | $subsection->_validate(); |
152 | - } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
152 | + } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
153 | 153 | $subsection->_received_submission = true; |
154 | 154 | } |
155 | 155 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | /** |
263 | 263 | * Sets sensitive_data_removal_strategy |
264 | 264 | * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy |
265 | - * @return boolean |
|
265 | + * @return boolean|null |
|
266 | 266 | */ |
267 | 267 | public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) { |
268 | 268 | $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | /** |
357 | 357 | * returns true if input employs any of the validation strategy defined by the supplied array of classnames |
358 | 358 | * |
359 | - * @param array $validation_strategy_classnames |
|
359 | + * @param string[] $validation_strategy_classnames |
|
360 | 360 | * @return bool |
361 | 361 | */ |
362 | 362 | public function has_validation_strategy( $validation_strategy_classnames ) { |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * Returns whether or not any validation errors occurred |
480 | 480 | * |
481 | 481 | * @param array $req_data like $_POST |
482 | - * @return boolean whether or not there was an error |
|
482 | + * @return boolean|null whether or not there was an error |
|
483 | 483 | */ |
484 | 484 | protected function _normalize( $req_data ) { |
485 | 485 | //any existing validation errors don't apply so clear them |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -141,61 +141,61 @@ discard block |
||
141 | 141 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
142 | 142 | * } |
143 | 143 | */ |
144 | - public function __construct( $input_args = array() ){ |
|
145 | - $input_args = apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
144 | + public function __construct($input_args = array()) { |
|
145 | + $input_args = apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
146 | 146 | // the following properties must be cast as arrays |
147 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
148 | - foreach ( $input_args['validation_strategies'] as $validation_strategy ) { |
|
149 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
150 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
147 | + if (isset($input_args['validation_strategies'])) { |
|
148 | + foreach ($input_args['validation_strategies'] as $validation_strategy) { |
|
149 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
150 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
151 | 151 | } |
152 | 152 | } |
153 | - unset( $input_args['validation_strategies'] ); |
|
153 | + unset($input_args['validation_strategies']); |
|
154 | 154 | } |
155 | 155 | // loop thru incoming options |
156 | - foreach( $input_args as $key => $value ) { |
|
156 | + foreach ($input_args as $key => $value) { |
|
157 | 157 | // add underscore to $key to match property names |
158 | - $_key = '_' . $key; |
|
159 | - if ( property_exists( $this, $_key )) { |
|
158 | + $_key = '_'.$key; |
|
159 | + if (property_exists($this, $_key)) { |
|
160 | 160 | $this->{$_key} = $value; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | // ensure that "required" is set correctly |
164 | - $this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL ); |
|
164 | + $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); |
|
165 | 165 | |
166 | 166 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
167 | 167 | |
168 | 168 | $this->_display_strategy->_construct_finalize($this); |
169 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
169 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
170 | 170 | $validation_strategy->_construct_finalize($this); |
171 | 171 | } |
172 | 172 | |
173 | - if( ! $this->_normalization_strategy){ |
|
173 | + if ( ! $this->_normalization_strategy) { |
|
174 | 174 | $this->_normalization_strategy = new EE_Text_Normalization(); |
175 | 175 | } |
176 | 176 | $this->_normalization_strategy->_construct_finalize($this); |
177 | 177 | |
178 | 178 | //at least we can use the normalization strategy to populate the default |
179 | - if( isset( $input_args[ 'default' ] ) ) { |
|
180 | - $this->set_default( $input_args[ 'default' ] ); |
|
179 | + if (isset($input_args['default'])) { |
|
180 | + $this->set_default($input_args['default']); |
|
181 | 181 | } |
182 | 182 | |
183 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
183 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
184 | 184 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
185 | 185 | } |
186 | 186 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
187 | - parent::__construct( $input_args ); |
|
187 | + parent::__construct($input_args); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Sets the html_name to its default value, if none was specified in teh constructor. |
192 | 192 | * Calculation involves using the name and the parent's html_name |
193 | 193 | */ |
194 | - protected function _set_default_html_name_if_empty(){ |
|
195 | - if( ! $this->_html_name){ |
|
196 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
197 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
198 | - }else{ |
|
194 | + protected function _set_default_html_name_if_empty() { |
|
195 | + if ( ! $this->_html_name) { |
|
196 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
197 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
198 | + } else { |
|
199 | 199 | $this->_html_name = $this->name(); |
200 | 200 | } |
201 | 201 | } |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | function _construct_finalize($parent_form_section, $name) { |
211 | 211 | parent::_construct_finalize($parent_form_section, $name); |
212 | 212 | $this->_set_default_html_name_if_empty(); |
213 | - if( ! $this->_html_label ){ |
|
214 | - if( ! $this->_html_label_text){ |
|
215 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
213 | + if ( ! $this->_html_label) { |
|
214 | + if ( ! $this->_html_label_text) { |
|
215 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
216 | 216 | } |
217 | 217 | } |
218 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
218 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @return EE_Display_Strategy_Base |
224 | 224 | * @throws EE_Error |
225 | 225 | */ |
226 | - protected function _get_display_strategy(){ |
|
227 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
228 | - throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
|
229 | - }else{ |
|
226 | + protected function _get_display_strategy() { |
|
227 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
228 | + throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id())); |
|
229 | + } else { |
|
230 | 230 | return $this->_display_strategy; |
231 | 231 | } |
232 | 232 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * Sets the display strategy. |
235 | 235 | * @param EE_Display_Strategy_Base $strategy |
236 | 236 | */ |
237 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
237 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
238 | 238 | $this->_display_strategy = $strategy; |
239 | 239 | } |
240 | 240 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * Sets the sanitization strategy |
243 | 243 | * @param EE_Normalization_Strategy_Base $strategy |
244 | 244 | */ |
245 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
245 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
246 | 246 | $this->_normalization_strategy = $strategy; |
247 | 247 | } |
248 | 248 | |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | * Gets the display strategy for this input |
269 | 269 | * @return EE_Display_Strategy_Base |
270 | 270 | */ |
271 | - public function get_display_strategy(){ |
|
271 | + public function get_display_strategy() { |
|
272 | 272 | return $this->_display_strategy; |
273 | 273 | } |
274 | 274 | /** |
275 | 275 | * Overwrites the display strategy |
276 | 276 | * @param EE_Display_Strategy_Base $display_strategy |
277 | 277 | */ |
278 | - public function set_display_strategy($display_strategy){ |
|
278 | + public function set_display_strategy($display_strategy) { |
|
279 | 279 | $this->_display_strategy = $display_strategy; |
280 | 280 | $this->_display_strategy->_construct_finalize($this); |
281 | 281 | } |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | * Gets the normalization strategy set on this input |
284 | 284 | * @return EE_Normalization_Strategy_Base |
285 | 285 | */ |
286 | - public function get_normalization_strategy(){ |
|
286 | + public function get_normalization_strategy() { |
|
287 | 287 | return $this->_normalization_strategy; |
288 | 288 | } |
289 | 289 | /** |
290 | 290 | * Overwrites the normalization strategy |
291 | 291 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
292 | 292 | */ |
293 | - public function set_normalization_strategy($normalization_strategy){ |
|
293 | + public function set_normalization_strategy($normalization_strategy) { |
|
294 | 294 | $this->_normalization_strategy = $normalization_strategy; |
295 | 295 | $this->_normalization_strategy->_construct_finalize($this); |
296 | 296 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * Returns all teh validation strategies which apply to this field, numerically indexed |
300 | 300 | * @return EE_Validation_Strategy_Base[] |
301 | 301 | */ |
302 | - public function get_validation_strategies(){ |
|
302 | + public function get_validation_strategies() { |
|
303 | 303 | return $this->_validation_strategies; |
304 | 304 | } |
305 | 305 | |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | * @param EE_Validation_Strategy_Base $validation_strategy |
311 | 311 | * @return void |
312 | 312 | */ |
313 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
314 | - $validation_strategy->_construct_finalize( $this ); |
|
315 | - $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy; |
|
313 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
314 | + $validation_strategy->_construct_finalize($this); |
|
315 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | * @param EE_Validation_Strategy_Base $validation_strategy |
323 | 323 | * @return void |
324 | 324 | */ |
325 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
326 | - $this->_add_validation_strategy( $validation_strategy ); |
|
325 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
326 | + $this->_add_validation_strategy($validation_strategy); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -333,13 +333,13 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @param string $validation_strategy_classname |
335 | 335 | */ |
336 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
337 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
338 | - if( |
|
336 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
337 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
338 | + if ( |
|
339 | 339 | $validation_strategy instanceof $validation_strategy_classname |
340 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
340 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
341 | 341 | ) { |
342 | - unset( $this->_validation_strategies[ $key ] ); |
|
342 | + unset($this->_validation_strategies[$key]); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | * @param array $validation_strategy_classnames |
353 | 353 | * @return bool |
354 | 354 | */ |
355 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
356 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
355 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
356 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
357 | 357 | ? $validation_strategy_classnames |
358 | - : array( $validation_strategy_classnames ); |
|
359 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
360 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
358 | + : array($validation_strategy_classnames); |
|
359 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
360 | + if (in_array($key, $validation_strategy_classnames)) { |
|
361 | 361 | return true; |
362 | 362 | } |
363 | 363 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * to the parent form's layout strategy |
372 | 372 | * @return string |
373 | 373 | */ |
374 | - public function get_html_and_js(){ |
|
374 | + public function get_html_and_js() { |
|
375 | 375 | return $this->_parent_section->get_html_for_input($this); |
376 | 376 | } |
377 | 377 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * Makes sure the JS and CSS are enqueued for it |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - public function get_html_for_input(){ |
|
386 | + public function get_html_for_input() { |
|
387 | 387 | return $this->_get_display_strategy()->display(); |
388 | 388 | } |
389 | 389 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @return string |
394 | 394 | */ |
395 | 395 | public function html_other_attributes() { |
396 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
396 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | /** |
402 | 402 | * @param string $html_other_attributes |
403 | 403 | */ |
404 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
404 | + public function set_html_other_attributes($html_other_attributes) { |
|
405 | 405 | $this->_html_other_attributes = $html_other_attributes; |
406 | 406 | } |
407 | 407 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * according to the form section's layout strategy |
411 | 411 | * @return string |
412 | 412 | */ |
413 | - public function get_html_for_label(){ |
|
413 | + public function get_html_for_label() { |
|
414 | 414 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
415 | 415 | } |
416 | 416 | /** |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * according to the form section's layout strategy |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - public function get_html_for_errors(){ |
|
421 | + public function get_html_for_errors() { |
|
422 | 422 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
423 | 423 | } |
424 | 424 | /** |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * according to the form section's layout strategy |
427 | 427 | * @return string |
428 | 428 | */ |
429 | - public function get_html_for_help(){ |
|
429 | + public function get_html_for_help() { |
|
430 | 430 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
431 | 431 | } |
432 | 432 | /** |
@@ -435,18 +435,18 @@ discard block |
||
435 | 435 | * @return boolean |
436 | 436 | */ |
437 | 437 | protected function _validate() { |
438 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
439 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
440 | - try{ |
|
438 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
439 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
440 | + try { |
|
441 | 441 | $validation_strategy->validate($this->normalized_value()); |
442 | - }catch(EE_Validation_Error $e){ |
|
442 | + } catch (EE_Validation_Error $e) { |
|
443 | 443 | $this->add_validation_error($e); |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
447 | - if( $this->get_validation_errors()){ |
|
447 | + if ($this->get_validation_errors()) { |
|
448 | 448 | return false; |
449 | - }else{ |
|
449 | + } else { |
|
450 | 450 | return true; |
451 | 451 | } |
452 | 452 | } |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * @param string $value |
460 | 460 | * @return null|string |
461 | 461 | */ |
462 | - private function _sanitize($value){ |
|
463 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
462 | + private function _sanitize($value) { |
|
463 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | |
@@ -472,24 +472,24 @@ discard block |
||
472 | 472 | * @param array $req_data like $_POST |
473 | 473 | * @return boolean whether or not there was an error |
474 | 474 | */ |
475 | - protected function _normalize( $req_data ) { |
|
475 | + protected function _normalize($req_data) { |
|
476 | 476 | //any existing validation errors don't apply so clear them |
477 | 477 | $this->_validation_errors = array(); |
478 | 478 | try { |
479 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
479 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
480 | 480 | //super simple sanitization for now |
481 | - if ( is_array( $raw_input )) { |
|
481 | + if (is_array($raw_input)) { |
|
482 | 482 | $this->_raw_value = array(); |
483 | - foreach( $raw_input as $key => $value ) { |
|
484 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
483 | + foreach ($raw_input as $key => $value) { |
|
484 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
485 | 485 | } |
486 | 486 | } else { |
487 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
487 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
488 | 488 | } |
489 | 489 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
490 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
491 | - } catch ( EE_Validation_Error $e ) { |
|
492 | - $this->add_validation_error( $e ); |
|
490 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
491 | + } catch (EE_Validation_Error $e) { |
|
492 | + $this->add_validation_error($e); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | /** |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public function html_name(){ |
|
501 | + public function html_name() { |
|
502 | 502 | return $this->_html_name; |
503 | 503 | } |
504 | 504 | |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | /** |
508 | 508 | * @return string |
509 | 509 | */ |
510 | - function html_label_id(){ |
|
511 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
510 | + function html_label_id() { |
|
511 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | /** |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - function html_label_class(){ |
|
519 | + function html_label_class() { |
|
520 | 520 | return $this->_html_label_class; |
521 | 521 | } |
522 | 522 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | /** |
526 | 526 | * @return string |
527 | 527 | */ |
528 | - function html_label_style(){ |
|
528 | + function html_label_style() { |
|
529 | 529 | return $this->_html_label_style; |
530 | 530 | } |
531 | 531 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | /** |
535 | 535 | * @return string |
536 | 536 | */ |
537 | - function html_label_text(){ |
|
537 | + function html_label_text() { |
|
538 | 538 | return $this->_html_label_text; |
539 | 539 | } |
540 | 540 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | /** |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - function html_help_text(){ |
|
546 | + function html_help_text() { |
|
547 | 547 | return $this->_html_help_text; |
548 | 548 | } |
549 | 549 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | /** |
553 | 553 | * @return string |
554 | 554 | */ |
555 | - function html_help_class(){ |
|
555 | + function html_help_class() { |
|
556 | 556 | return $this->_html_help_class; |
557 | 557 | } |
558 | 558 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | /** |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - function html_help_style(){ |
|
564 | + function html_help_style() { |
|
565 | 565 | return $this->_html_style; |
566 | 566 | } |
567 | 567 | /** |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * in which case, we would have stored the malicious content to our database. |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - function raw_value(){ |
|
577 | + function raw_value() { |
|
578 | 578 | return $this->_raw_value; |
579 | 579 | } |
580 | 580 | /** |
@@ -582,15 +582,15 @@ discard block |
||
582 | 582 | * it escapes all html entities |
583 | 583 | * @return string |
584 | 584 | */ |
585 | - function raw_value_in_form(){ |
|
586 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
585 | + function raw_value_in_form() { |
|
586 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
587 | 587 | } |
588 | 588 | /** |
589 | 589 | * returns the value after it's been sanitized, and then converted into it's proper type |
590 | 590 | * in PHP. Eg, a string, an int, an array, |
591 | 591 | * @return mixed |
592 | 592 | */ |
593 | - function normalized_value(){ |
|
593 | + function normalized_value() { |
|
594 | 594 | return $this->_normalized_value; |
595 | 595 | } |
596 | 596 | |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * the best thing to display |
601 | 601 | * @return string |
602 | 602 | */ |
603 | - function pretty_value(){ |
|
603 | + function pretty_value() { |
|
604 | 604 | return $this->_normalized_value; |
605 | 605 | } |
606 | 606 | /** |
@@ -619,19 +619,19 @@ discard block |
||
619 | 619 | }</code> |
620 | 620 | * @return array |
621 | 621 | */ |
622 | - function get_jquery_validation_rules(){ |
|
622 | + function get_jquery_validation_rules() { |
|
623 | 623 | |
624 | 624 | $jquery_validation_rules = array(); |
625 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
625 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
626 | 626 | $jquery_validation_rules = array_replace_recursive( |
627 | 627 | $jquery_validation_rules, |
628 | 628 | $validation_strategy->get_jquery_validation_rule_array() |
629 | 629 | ); |
630 | 630 | } |
631 | 631 | |
632 | - if(! empty($jquery_validation_rules)){ |
|
633 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
634 | - }else{ |
|
632 | + if ( ! empty($jquery_validation_rules)) { |
|
633 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
634 | + } else { |
|
635 | 635 | return array(); |
636 | 636 | } |
637 | 637 | return $jquery_validation_js; |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @param mixed $value |
644 | 644 | * @return void |
645 | 645 | */ |
646 | - function set_default($value){ |
|
646 | + function set_default($value) { |
|
647 | 647 | $this->_normalized_value = $value; |
648 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
648 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @param string $label |
654 | 654 | * @return void |
655 | 655 | */ |
656 | - function set_html_label_text($label){ |
|
656 | + function set_html_label_text($label) { |
|
657 | 657 | $this->_html_label_text = $label; |
658 | 658 | } |
659 | 659 | |
@@ -665,12 +665,12 @@ discard block |
||
665 | 665 | * @param boolean $required |
666 | 666 | * @param null $required_text |
667 | 667 | */ |
668 | - function set_required($required = true, $required_text = NULL ){ |
|
669 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
670 | - if ( $required ) { |
|
671 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
668 | + function set_required($required = true, $required_text = NULL) { |
|
669 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
670 | + if ($required) { |
|
671 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
672 | 672 | } else { |
673 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
673 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
674 | 674 | } |
675 | 675 | $this->_required = $required; |
676 | 676 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * Returns whether or not this field is required |
679 | 679 | * @return boolean |
680 | 680 | */ |
681 | - public function required(){ |
|
681 | + public function required() { |
|
682 | 682 | return $this->_required; |
683 | 683 | } |
684 | 684 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | /** |
688 | 688 | * @param string $required_css_class |
689 | 689 | */ |
690 | - public function set_required_css_class( $required_css_class ) { |
|
690 | + public function set_required_css_class($required_css_class) { |
|
691 | 691 | $this->_required_css_class = $required_css_class; |
692 | 692 | } |
693 | 693 | |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * Sets the help text, in case |
707 | 707 | * @param string $text |
708 | 708 | */ |
709 | - public function set_html_help_text($text){ |
|
709 | + public function set_html_help_text($text) { |
|
710 | 710 | $this->_html_help_text = $text; |
711 | 711 | } |
712 | 712 | /** |
@@ -718,8 +718,8 @@ discard block |
||
718 | 718 | public function clean_sensitive_data() { |
719 | 719 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
720 | 720 | //if we need more logic than this we'll make a strategy for it |
721 | - if( $this->_sensitive_data_removal_strategy && |
|
722 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
721 | + if ($this->_sensitive_data_removal_strategy && |
|
722 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
723 | 723 | $this->_raw_value = NULL; |
724 | 724 | } |
725 | 725 | //and clean the normalized value according to the appropriate strategy |
@@ -733,10 +733,10 @@ discard block |
||
733 | 733 | * @param string $button_size |
734 | 734 | * @param string $other_attributes |
735 | 735 | */ |
736 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
736 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
737 | 737 | $button_css_attributes = 'button'; |
738 | 738 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
739 | - switch ( $button_size ) { |
|
739 | + switch ($button_size) { |
|
740 | 740 | case 'xs' : |
741 | 741 | case 'extra-small' : |
742 | 742 | $button_css_attributes .= ' button-xs'; |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | default : |
758 | 758 | $button_css_attributes .= ''; |
759 | 759 | } |
760 | - $this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes; |
|
760 | + $this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | * @return string |
767 | 767 | */ |
768 | 768 | public function button_css_attributes() { |
769 | - if ( empty( $this->_button_css_attributes )) { |
|
769 | + if (empty($this->_button_css_attributes)) { |
|
770 | 770 | $this->set_button_css_attributes(); |
771 | 771 | } |
772 | 772 | return $this->_button_css_attributes; |
@@ -786,27 +786,27 @@ discard block |
||
786 | 786 | * @param array $req_data |
787 | 787 | * @return mixed whatever the raw value of this form section is in the request data |
788 | 788 | */ |
789 | - public function find_form_data_for_this_section( $req_data ){ |
|
789 | + public function find_form_data_for_this_section($req_data) { |
|
790 | 790 | // break up the html name by "[]" |
791 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
792 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
791 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
792 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
793 | 793 | } else { |
794 | 794 | $before_any_brackets = $this->html_name(); |
795 | 795 | } |
796 | 796 | // grab all of the segments |
797 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
798 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
799 | - $name_parts = $matches[ 1 ]; |
|
797 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
798 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
799 | + $name_parts = $matches[1]; |
|
800 | 800 | array_unshift($name_parts, $before_any_brackets); |
801 | - }else{ |
|
802 | - $name_parts = array( $before_any_brackets ); |
|
801 | + } else { |
|
802 | + $name_parts = array($before_any_brackets); |
|
803 | 803 | } |
804 | 804 | // now get the value for the input |
805 | 805 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
806 | - if( $value === NULL ){ |
|
806 | + if ($value === NULL) { |
|
807 | 807 | //check if this thing's name is at the TOP level of the request data |
808 | - if( isset( $req_data[ $this->name() ] ) ){ |
|
809 | - $value = $req_data[ $this->name() ]; |
|
808 | + if (isset($req_data[$this->name()])) { |
|
809 | + $value = $req_data[$this->name()]; |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | return $value; |
@@ -820,15 +820,15 @@ discard block |
||
820 | 820 | * @param array $req_data |
821 | 821 | * @return array | NULL |
822 | 822 | */ |
823 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
824 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
825 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
826 | - if( empty($html_name_parts ) ){ |
|
827 | - return $req_data[ $first_part_to_consider ]; |
|
828 | - }else{ |
|
829 | - return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
|
823 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
824 | + $first_part_to_consider = array_shift($html_name_parts); |
|
825 | + if (isset($req_data[$first_part_to_consider])) { |
|
826 | + if (empty($html_name_parts)) { |
|
827 | + return $req_data[$first_part_to_consider]; |
|
828 | + } else { |
|
829 | + return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]); |
|
830 | 830 | } |
831 | - }else{ |
|
831 | + } else { |
|
832 | 832 | return NULL; |
833 | 833 | } |
834 | 834 | } |
@@ -840,14 +840,14 @@ discard block |
||
840 | 840 | * @param array $req_data like $_POST |
841 | 841 | * @return boolean |
842 | 842 | */ |
843 | - public function form_data_present_in($req_data = NULL){ |
|
844 | - if( $req_data === NULL ){ |
|
843 | + public function form_data_present_in($req_data = NULL) { |
|
844 | + if ($req_data === NULL) { |
|
845 | 845 | $req_data = $_POST; |
846 | 846 | } |
847 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
848 | - if( $checked_value !== null ){ |
|
847 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
848 | + if ($checked_value !== null) { |
|
849 | 849 | return TRUE; |
850 | - }else{ |
|
850 | + } else { |
|
851 | 851 | return FALSE; |
852 | 852 | } |
853 | 853 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if( ! $this->_html_name){ |
196 | 196 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
197 | 197 | $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
198 | - }else{ |
|
198 | + } else{ |
|
199 | 199 | $this->_html_name = $this->name(); |
200 | 200 | } |
201 | 201 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | protected function _get_display_strategy(){ |
227 | 227 | if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
228 | 228 | throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
229 | - }else{ |
|
229 | + } else{ |
|
230 | 230 | return $this->_display_strategy; |
231 | 231 | } |
232 | 232 | } |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
440 | 440 | try{ |
441 | 441 | $validation_strategy->validate($this->normalized_value()); |
442 | - }catch(EE_Validation_Error $e){ |
|
442 | + } catch(EE_Validation_Error $e){ |
|
443 | 443 | $this->add_validation_error($e); |
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
447 | 447 | if( $this->get_validation_errors()){ |
448 | 448 | return false; |
449 | - }else{ |
|
449 | + } else{ |
|
450 | 450 | return true; |
451 | 451 | } |
452 | 452 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | |
632 | 632 | if(! empty($jquery_validation_rules)){ |
633 | 633 | $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
634 | - }else{ |
|
634 | + } else{ |
|
635 | 635 | return array(); |
636 | 636 | } |
637 | 637 | return $jquery_validation_js; |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
799 | 799 | $name_parts = $matches[ 1 ]; |
800 | 800 | array_unshift($name_parts, $before_any_brackets); |
801 | - }else{ |
|
801 | + } else{ |
|
802 | 802 | $name_parts = array( $before_any_brackets ); |
803 | 803 | } |
804 | 804 | // now get the value for the input |
@@ -825,10 +825,10 @@ discard block |
||
825 | 825 | if( isset( $req_data[ $first_part_to_consider ] ) ){ |
826 | 826 | if( empty($html_name_parts ) ){ |
827 | 827 | return $req_data[ $first_part_to_consider ]; |
828 | - }else{ |
|
828 | + } else{ |
|
829 | 829 | return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
830 | 830 | } |
831 | - }else{ |
|
831 | + } else{ |
|
832 | 832 | return NULL; |
833 | 833 | } |
834 | 834 | } |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | $checked_value = $this->find_form_data_for_this_section( $req_data ); |
848 | 848 | if( $checked_value !== null ){ |
849 | 849 | return TRUE; |
850 | - }else{ |
|
850 | + } else{ |
|
851 | 851 | return FALSE; |
852 | 852 | } |
853 | 853 | } |
@@ -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 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
61 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
62 | 62 | |
63 | 63 | //if we were going to add our own metaboxes we'd use the below. |
64 | 64 | $this->_metaboxes = array( |
65 | 65 | 0 => array( |
66 | - 'page_route' => array('edit','create_new'), |
|
66 | + 'page_route' => array('edit', 'create_new'), |
|
67 | 67 | 'func' => 'pricing_metabox', |
68 | 68 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
69 | 69 | 'priority' => 'high', |
70 | 70 | 'context' => 'normal' |
71 | 71 | ), |
72 | 72 | |
73 | - );/**/ |
|
73 | + ); /**/ |
|
74 | 74 | |
75 | 75 | $this->_remove_metaboxes = array( |
76 | 76 | 0 => array( |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @var array Expected an array returned with 'date' and 'time' keys. |
91 | 91 | */ |
92 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
93 | 93 | 'date' => 'Y-m-d', |
94 | 94 | 'time' => 'h:i a' |
95 | 95 | )); |
96 | 96 | |
97 | 97 | //validate |
98 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
99 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
98 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
99 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
100 | 100 | |
101 | 101 | //validate format strings |
102 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
103 | - if ( is_array( $format_validation ) ) { |
|
104 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
105 | - foreach ( $format_validation as $error ) { |
|
106 | - $msg .= '<li>' . $error . '</li>'; |
|
102 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
103 | + if (is_array($format_validation)) { |
|
104 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
105 | + foreach ($format_validation as $error) { |
|
106 | + $msg .= '<li>'.$error.'</li>'; |
|
107 | 107 | } |
108 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
109 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
108 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
109 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | $this->_date_format_strings = array( |
111 | 111 | 'date' => 'Y-m-d', |
112 | 112 | 'time' => 'h:i a' |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | $this->_scripts_styles = array( |
118 | 118 | 'registers' => array( |
119 | 119 | 'ee-tickets-datetimes-css' => array( |
120 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
120 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
121 | 121 | 'type' => 'css' |
122 | 122 | ), |
123 | 123 | 'ee-dtt-ticket-metabox' => array( |
124 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
124 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
125 | 125 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
126 | 126 | ) |
127 | 127 | ), |
128 | 128 | 'deregisters' => array( |
129 | - 'event-editor-css' => array('type' => 'css' ), |
|
129 | + 'event-editor-css' => array('type' => 'css'), |
|
130 | 130 | 'event-datetime-metabox' => array('type' => 'js') |
131 | 131 | ), |
132 | 132 | 'enqueues' => array( |
133 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
134 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
133 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
134 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
135 | 135 | ), |
136 | 136 | 'localize' => array( |
137 | 137 | 'ee-dtt-ticket-metabox' => array( |
138 | 138 | 'DTT_TRASH_BLOCK' => array( |
139 | 139 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
140 | 140 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
141 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
141 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
142 | 142 | 'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
143 | 143 | 'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'), |
144 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
144 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
145 | 145 | ), |
146 | 146 | 'DTT_ERROR_MSG' => array( |
147 | 147 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
148 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
148 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
149 | 149 | ), |
150 | 150 | 'DTT_OVERSELL_WARNING' => array( |
151 | 151 | 'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'), |
152 | 152 | 'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso') |
153 | 153 | ), |
154 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
155 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
154 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
155 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
156 | 156 | ) |
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | 160 | |
161 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
162 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
161 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
162 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - public function caf_updates( $update_callbacks ) { |
|
168 | - foreach ( $update_callbacks as $key => $callback ) { |
|
169 | - if ( $callback[1] == '_default_tickets_update' ) |
|
170 | - unset( $update_callbacks[$key] ); |
|
167 | + public function caf_updates($update_callbacks) { |
|
168 | + foreach ($update_callbacks as $key => $callback) { |
|
169 | + if ($callback[1] == '_default_tickets_update') |
|
170 | + unset($update_callbacks[$key]); |
|
171 | 171 | } |
172 | 172 | |
173 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
173 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
174 | 174 | return $update_callbacks; |
175 | 175 | } |
176 | 176 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param array $data The request data from the form |
184 | 184 | * @return bool success or fail |
185 | 185 | */ |
186 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
186 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
187 | 187 | //first we need to start with datetimes cause they are the "root" items attached to events. |
188 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
188 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
189 | 189 | //next tackle the tickets (and prices?) |
190 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
190 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,41 +198,41 @@ discard block |
||
198 | 198 | * @param array $data the request data from the form |
199 | 199 | * @return EE_Datetime[] |
200 | 200 | */ |
201 | - protected function _update_dtts( $evt_obj, $data ) { |
|
202 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
201 | + protected function _update_dtts($evt_obj, $data) { |
|
202 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
203 | 203 | $saved_dtt_ids = array(); |
204 | 204 | $saved_dtt_objs = array(); |
205 | 205 | |
206 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
206 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
207 | 207 | //trim all values to ensure any excess whitespace is removed. |
208 | 208 | $dtt = array_map( |
209 | - function( $datetime_data ) { |
|
210 | - return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data ); |
|
209 | + function($datetime_data) { |
|
210 | + return is_array($datetime_data) ? $datetime_data : trim($datetime_data); |
|
211 | 211 | }, |
212 | 212 | $dtt |
213 | 213 | ); |
214 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
214 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
215 | 215 | $datetime_values = array( |
216 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
217 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
218 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
216 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
217 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
218 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
219 | 219 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
220 | 220 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
221 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
222 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
221 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
222 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | //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. |
226 | 226 | |
227 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
228 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
227 | + if ( ! empty($dtt['DTT_ID'])) { |
|
228 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
229 | 229 | |
230 | 230 | //set date and time format according to what is set in this class. |
231 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
232 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
231 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
232 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
233 | 233 | |
234 | - foreach ( $datetime_values as $field => $value ) { |
|
235 | - $DTM->set( $field, $value ); |
|
234 | + foreach ($datetime_values as $field => $value) { |
|
235 | + $DTM->set($field, $value); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
241 | 241 | |
242 | 242 | } else { |
243 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
243 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
244 | 244 | |
245 | 245 | //reset date and times to match the format |
246 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
247 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
248 | - foreach( $datetime_values as $field => $value ) { |
|
249 | - $DTM->set( $field, $value ); |
|
246 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
247 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
248 | + foreach ($datetime_values as $field => $value) { |
|
249 | + $DTM->set($field, $value); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | $DTM->save(); |
255 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
255 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
256 | 256 | $evt_obj->save(); |
257 | 257 | |
258 | 258 | //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. |
259 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
260 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
259 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
260 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
261 | 261 | EE_Registry::instance()->load_helper('DTT_Helper'); |
262 | 262 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
263 | 263 | $DTM->save(); |
@@ -273,25 +273,25 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
276 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
276 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
277 | 277 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
278 | 278 | |
279 | - if ( is_array( $old_datetimes ) ) { |
|
280 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
281 | - foreach ( $dtts_to_delete as $id ) { |
|
282 | - $id = absint( $id ); |
|
283 | - if ( empty( $id ) ) |
|
279 | + if (is_array($old_datetimes)) { |
|
280 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
281 | + foreach ($dtts_to_delete as $id) { |
|
282 | + $id = absint($id); |
|
283 | + if (empty($id)) |
|
284 | 284 | continue; |
285 | 285 | |
286 | 286 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
287 | 287 | |
288 | 288 | //remove tkt relationships. |
289 | 289 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
290 | - foreach ( $related_tickets as $tkt ) { |
|
290 | + foreach ($related_tickets as $tkt) { |
|
291 | 291 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
292 | 292 | } |
293 | 293 | |
294 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
294 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
295 | 295 | $dtt_to_remove->refresh_cache_of_related_objects(); |
296 | 296 | |
297 | 297 | } |
@@ -312,86 +312,86 @@ discard block |
||
312 | 312 | * @param array $data incoming request data |
313 | 313 | * @return EE_Ticket[] |
314 | 314 | */ |
315 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
315 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
316 | 316 | |
317 | 317 | $new_tkt = null; |
318 | 318 | $new_default = null; |
319 | 319 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
320 | 320 | $data = stripslashes_deep($data); |
321 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
321 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
322 | 322 | $saved_tickets = $dtts_on_existing = array(); |
323 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
323 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
324 | 324 | |
325 | 325 | //load money helper |
326 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
326 | + EE_Registry::instance()->load_helper('Money'); |
|
327 | 327 | |
328 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
328 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
329 | 329 | |
330 | 330 | $update_prices = $create_new_TKT = FALSE; |
331 | 331 | |
332 | 332 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
333 | 333 | |
334 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
335 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
334 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
335 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
336 | 336 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
337 | 337 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
338 | 338 | |
339 | 339 | // trim inputs to ensure any excess whitespace is removed. |
340 | 340 | $tkt = array_map( |
341 | - function( $ticket_data ) { |
|
342 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
341 | + function($ticket_data) { |
|
342 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
343 | 343 | }, |
344 | 344 | $tkt |
345 | 345 | ); |
346 | 346 | |
347 | 347 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
348 | 348 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
349 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
349 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
350 | 350 | |
351 | 351 | //note incoming base price needs converted from localized value. |
352 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
352 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
353 | 353 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
354 | 354 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
355 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
355 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
356 | 356 | |
357 | 357 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
358 | 358 | |
359 | 359 | $now = null; |
360 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
360 | + if (empty($tkt['TKT_start_date'])) { |
|
361 | 361 | //lets' use now in the set timezone. |
362 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
363 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
362 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
363 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
366 | + if (empty($tkt['TKT_end_date'])) { |
|
367 | 367 | /** |
368 | 368 | * set the TKT_end_date to the first datetime attached to the ticket. |
369 | 369 | */ |
370 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
371 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
370 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
371 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $TKT_values = array( |
375 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
376 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
377 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
378 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
375 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
376 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
377 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
378 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
379 | 379 | 'TKT_start_date' => $tkt['TKT_start_date'], |
380 | 380 | 'TKT_end_date' => $tkt['TKT_end_date'], |
381 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
382 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
384 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
381 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
382 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
384 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
385 | 385 | 'TKT_row' => $row, |
386 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
387 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
388 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
386 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
387 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
388 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
389 | 389 | 'TKT_price' => $ticket_price |
390 | 390 | ); |
391 | 391 | |
392 | 392 | |
393 | 393 | //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. |
394 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
394 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
395 | 395 | $TKT_values['TKT_ID'] = 0; |
396 | 396 | $TKT_values['TKT_is_default'] = 0; |
397 | 397 | $update_prices = TRUE; |
@@ -403,21 +403,21 @@ discard block |
||
403 | 403 | // but DID have it's items modified. |
404 | 404 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
405 | 405 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
406 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
407 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
408 | - if ( $TKT instanceof EE_Ticket ) { |
|
406 | + if (absint($TKT_values['TKT_ID'])) { |
|
407 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
408 | + if ($TKT instanceof EE_Ticket) { |
|
409 | 409 | |
410 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
410 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
411 | 411 | // are there any registrations using this ticket ? |
412 | 412 | $tickets_sold = $TKT->count_related( |
413 | 413 | 'Registration', |
414 | - array( array( |
|
415 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
416 | - ) ) |
|
414 | + array(array( |
|
415 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
416 | + )) |
|
417 | 417 | ); |
418 | 418 | //set ticket formats |
419 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
420 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
419 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
420 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
421 | 421 | |
422 | 422 | // let's just check the total price for the existing ticket |
423 | 423 | // and determine if it matches the new total price. |
@@ -427,17 +427,17 @@ discard block |
||
427 | 427 | ? TRUE : FALSE; |
428 | 428 | |
429 | 429 | //set new values |
430 | - foreach ( $TKT_values as $field => $value ) { |
|
431 | - if ( $field === 'TKT_qty' ) { |
|
432 | - $TKT->set_qty( $value ); |
|
430 | + foreach ($TKT_values as $field => $value) { |
|
431 | + if ($field === 'TKT_qty') { |
|
432 | + $TKT->set_qty($value); |
|
433 | 433 | } else { |
434 | - $TKT->set( $field, $value ); |
|
434 | + $TKT->set($field, $value); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
439 | - if ( $create_new_TKT ) { |
|
440 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
439 | + if ($create_new_TKT) { |
|
440 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $TKT = EE_Ticket::new_instance( |
447 | 447 | $TKT_values, |
448 | 448 | $timezone, |
449 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
449 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
450 | 450 | ); |
451 | - if ( $TKT instanceof EE_Ticket ) { |
|
451 | + if ($TKT instanceof EE_Ticket) { |
|
452 | 452 | // make sure ticket has an ID of setting relations won't work |
453 | 453 | $TKT->save(); |
454 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
454 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
455 | 455 | $update_prices = TRUE; |
456 | 456 | } |
457 | 457 | } |
@@ -459,38 +459,38 @@ discard block |
||
459 | 459 | //$TKT->save(); |
460 | 460 | |
461 | 461 | //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. |
462 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
463 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
462 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
463 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
464 | 464 | EE_Registry::instance()->load_helper('DTT_Helper'); |
465 | 465 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
466 | 466 | } |
467 | 467 | |
468 | 468 | //let's make sure the base price is handled |
469 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
469 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
470 | 470 | |
471 | 471 | //add/update price_modifiers |
472 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
472 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
473 | 473 | |
474 | 474 | //need to make sue that the TKT_price is accurate after saving the prices. |
475 | 475 | $TKT->ensure_TKT_Price_correct(); |
476 | 476 | |
477 | 477 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
478 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
479 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
478 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
479 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
480 | 480 | $update_prices = TRUE; |
481 | 481 | $new_default = clone $TKT; |
482 | - $new_default->set( 'TKT_ID', 0 ); |
|
483 | - $new_default->set( 'TKT_is_default', 1 ); |
|
484 | - $new_default->set( 'TKT_row', 1 ); |
|
485 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
482 | + $new_default->set('TKT_ID', 0); |
|
483 | + $new_default->set('TKT_is_default', 1); |
|
484 | + $new_default->set('TKT_row', 1); |
|
485 | + $new_default->set('TKT_price', $ticket_price); |
|
486 | 486 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
487 | 487 | $new_default->_remove_relations('Datetime'); |
488 | 488 | //todo we need to add the current attached prices as new prices to the new default ticket. |
489 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
489 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
490 | 490 | //don't forget the base price! |
491 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
491 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
492 | 492 | $new_default->save(); |
493 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
493 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | //let's assign any tickets that have been setup to the saved_tickets tracker |
502 | 502 | //save existing TKT |
503 | 503 | $TKT->save(); |
504 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
504 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
505 | 505 | //save new TKT |
506 | 506 | $new_tkt->save(); |
507 | 507 | //add new ticket to array |
508 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
508 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
509 | 509 | |
510 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
510 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
511 | 511 | |
512 | 512 | } else { |
513 | 513 | //add tkt to saved tkts |
514 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
514 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
515 | 515 | |
516 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
516 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | } |
@@ -523,22 +523,22 @@ discard block |
||
523 | 523 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
524 | 524 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
525 | 525 | // No sense in keeping all the related data in the db! |
526 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
526 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
528 | 528 | |
529 | - foreach ( $tickets_removed as $id ) { |
|
530 | - $id = absint( $id ); |
|
529 | + foreach ($tickets_removed as $id) { |
|
530 | + $id = absint($id); |
|
531 | 531 | |
532 | 532 | //get the ticket for this id |
533 | 533 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
534 | 534 | |
535 | 535 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
536 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
536 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
537 | 537 | continue; |
538 | 538 | |
539 | 539 | // if this tkt has any registrations attached so then we just ARCHIVE |
540 | 540 | // because we don't actually permanently delete these tickets. |
541 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
541 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
542 | 542 | $tkt_to_remove->delete(); |
543 | 543 | continue; |
544 | 544 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
548 | 548 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
549 | 549 | |
550 | - foreach( $dtts as $dtt ) { |
|
550 | + foreach ($dtts as $dtt) { |
|
551 | 551 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
552 | 552 | } |
553 | 553 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
556 | 556 | $tkt_to_remove->delete_related_permanently('Price'); |
557 | 557 | |
558 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
558 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
559 | 559 | |
560 | 560 | // finally let's delete this ticket |
561 | 561 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -587,39 +587,39 @@ discard block |
||
587 | 587 | // and removing the ticket from datetimes it got removed from. |
588 | 588 | |
589 | 589 | // first let's add datetimes |
590 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
591 | - foreach ( $added_datetimes as $row_id ) { |
|
590 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
591 | + foreach ($added_datetimes as $row_id) { |
|
592 | 592 | $row_id = (int) $row_id; |
593 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
594 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
593 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
594 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
595 | 595 | // Is this an existing ticket (has an ID) and does it have any sold? |
596 | 596 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
597 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
598 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
599 | - $saved_datetimes[ $row_id ]->save(); |
|
597 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
598 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
599 | + $saved_datetimes[$row_id]->save(); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
604 | 604 | // then remove datetimes |
605 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
606 | - foreach ( $removed_datetimes as $row_id ) { |
|
607 | - $row_id = (int)$row_id; |
|
605 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
606 | + foreach ($removed_datetimes as $row_id) { |
|
607 | + $row_id = (int) $row_id; |
|
608 | 608 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
609 | 609 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
610 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
611 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
610 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
611 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
612 | 612 | // Is this an existing ticket (has an ID) and does it have any sold? |
613 | 613 | // If so, then we need to remove it's sold from the DTT_sold. |
614 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
615 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
616 | - $saved_datetimes[ $row_id ]->save(); |
|
614 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
615 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
616 | + $saved_datetimes[$row_id]->save(); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
621 | 621 | // cap ticket qty by datetime reg limits |
622 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
622 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
623 | 623 | return $ticket; |
624 | 624 | } |
625 | 625 | |
@@ -640,39 +640,39 @@ discard block |
||
640 | 640 | EE_Ticket $ticket, |
641 | 641 | $price_rows = array(), |
642 | 642 | $ticket_price = 0, |
643 | - $base_price = 0 , |
|
643 | + $base_price = 0, |
|
644 | 644 | $base_price_id = 0 |
645 | 645 | ) { |
646 | 646 | |
647 | 647 | // create new ticket that's a copy of the existing |
648 | 648 | // except a new id of course (and not archived) |
649 | 649 | // AND has the new TKT_price associated with it. |
650 | - $new_ticket = clone( $ticket ); |
|
651 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
652 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
653 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
654 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
650 | + $new_ticket = clone($ticket); |
|
651 | + $new_ticket->set('TKT_ID', 0); |
|
652 | + $new_ticket->set('TKT_deleted', 0); |
|
653 | + $new_ticket->set('TKT_price', $ticket_price); |
|
654 | + $new_ticket->set('TKT_sold', 0); |
|
655 | 655 | // let's get a new ID for this ticket |
656 | 656 | $new_ticket->save(); |
657 | 657 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
658 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
658 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
659 | 659 | $new_ticket = $this->_update_ticket_datetimes( |
660 | 660 | $new_ticket, |
661 | 661 | $datetimes_on_existing, |
662 | - array_keys( $datetimes_on_existing ) |
|
662 | + array_keys($datetimes_on_existing) |
|
663 | 663 | ); |
664 | 664 | |
665 | 665 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
666 | 666 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
667 | 667 | // available. |
668 | - if ( $ticket->sold() > 0 ) { |
|
668 | + if ($ticket->sold() > 0) { |
|
669 | 669 | $new_qty = $ticket->qty() - $ticket->sold(); |
670 | - $new_ticket->set_qty( $new_qty ); |
|
670 | + $new_ticket->set_qty($new_qty); |
|
671 | 671 | } |
672 | 672 | //now we update the prices just for this ticket |
673 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
673 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
674 | 674 | //and we update the base price |
675 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
675 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
676 | 676 | return $new_ticket; |
677 | 677 | } |
678 | 678 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
693 | 693 | * @return EE_Ticket |
694 | 694 | */ |
695 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
695 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
696 | 696 | |
697 | 697 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
698 | 698 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $updated_prices = array(); |
701 | 701 | |
702 | 702 | // if $base_price ! FALSE then updating a base price. |
703 | - if ( $base_price !== FALSE ) { |
|
703 | + if ($base_price !== FALSE) { |
|
704 | 704 | $prices[1] = array( |
705 | 705 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
706 | 706 | 'PRT_ID' => 1, |
@@ -711,47 +711,47 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | //possibly need to save tkt |
714 | - if ( ! $ticket->ID() ) |
|
714 | + if ( ! $ticket->ID()) |
|
715 | 715 | $ticket->save(); |
716 | 716 | |
717 | - foreach ( $prices as $row => $prc ) { |
|
718 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
719 | - if ( empty($prt_id) ) |
|
717 | + foreach ($prices as $row => $prc) { |
|
718 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
719 | + if (empty($prt_id)) |
|
720 | 720 | continue; //prices MUST have a price type id. |
721 | 721 | $PRC_values = array( |
722 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
722 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
723 | 723 | 'PRT_ID' => $prt_id, |
724 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
725 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
726 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
724 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
725 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
726 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
727 | 727 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
728 | 728 | 'PRC_order' => $row |
729 | 729 | ); |
730 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
730 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
731 | 731 | $PRC_values['PRC_ID'] = 0; |
732 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
732 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
733 | 733 | } else { |
734 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
734 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
735 | 735 | //update this price with new values |
736 | - foreach ( $PRC_values as $field => $newprc ) { |
|
737 | - $PRC->set( $field, $newprc ); |
|
736 | + foreach ($PRC_values as $field => $newprc) { |
|
737 | + $PRC->set($field, $newprc); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | $PRC->save(); |
741 | 741 | $prcid = $PRC->ID(); |
742 | 742 | $updated_prices[$prcid] = $PRC; |
743 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
743 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | //now let's remove any prices that got removed from the ticket |
747 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
747 | + if ( ! empty ($current_prices_on_ticket)) { |
|
748 | 748 | $current = array_keys($current_prices_on_ticket); |
749 | 749 | $updated = array_keys($updated_prices); |
750 | 750 | $prices_to_remove = array_diff($current, $updated); |
751 | - if ( !empty( $prices_to_remove ) ) { |
|
752 | - foreach ( $prices_to_remove as $prc_id ) { |
|
751 | + if ( ! empty($prices_to_remove)) { |
|
752 | + foreach ($prices_to_remove as $prc_id) { |
|
753 | 753 | $p = $current_prices_on_ticket[$prc_id]; |
754 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
754 | + $ticket->_remove_relation_to($p, 'Price'); |
|
755 | 755 | |
756 | 756 | //delete permanently the price |
757 | 757 | $p->delete_permanently(); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | |
766 | 766 | |
767 | - public function autosave_handling( $event_admin_obj ) { |
|
767 | + public function autosave_handling($event_admin_obj) { |
|
768 | 768 | return $event_admin_obj; //doing nothing for the moment. |
769 | 769 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
770 | 770 | |
@@ -798,12 +798,12 @@ discard block |
||
798 | 798 | |
799 | 799 | //default main template args |
800 | 800 | $main_template_args = array( |
801 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
801 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
802 | 802 | 'existing_datetime_ids' => '', |
803 | 803 | 'total_dtt_rows' => 1, |
804 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
804 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
805 | 805 | 'datetime_rows' => '', |
806 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
806 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
807 | 807 | 'ticket_rows' => '', |
808 | 808 | 'existing_ticket_ids' => '', |
809 | 809 | 'total_ticket_rows' => 1, |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
815 | 815 | |
816 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
816 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
817 | 817 | |
818 | 818 | /** |
819 | 819 | * 1. Start with retrieving Datetimes |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | * 3. For each ticket get related prices |
822 | 822 | */ |
823 | 823 | |
824 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
825 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
824 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
825 | + $times = $DTM->get_all_event_dates($evtID); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | |
@@ -830,31 +830,31 @@ discard block |
||
830 | 830 | |
831 | 831 | /** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */ |
832 | 832 | $dttrow = 1; |
833 | - foreach ( $times as $time ) { |
|
833 | + foreach ($times as $time) { |
|
834 | 834 | $dttid = $time->get('DTT_ID'); |
835 | - $time->set( 'DTT_order', $dttrow ); |
|
835 | + $time->set('DTT_order', $dttrow); |
|
836 | 836 | $existing_datetime_ids[] = $dttid; |
837 | 837 | |
838 | 838 | //tickets attached |
839 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
839 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
840 | 840 | |
841 | 841 | //if there are no related tickets this is likely a new event OR autodraft |
842 | 842 | // event so we need to generate the default tickets because dtts |
843 | 843 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
844 | 844 | // datetime on the event. |
845 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
845 | + if (empty ($related_tickets) && count($times) < 2) { |
|
846 | 846 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
847 | 847 | |
848 | 848 | //this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save). |
849 | 849 | $default_prices = EEM_Price::instance()->get_all_default_prices(); |
850 | 850 | |
851 | - $main_default_ticket = reset( $related_tickets ); |
|
852 | - if ( $main_default_ticket instanceof EE_Ticket ) { |
|
853 | - foreach ( $default_prices as $default_price ) { |
|
854 | - if ( $default_price->is_base_price() ) { |
|
851 | + $main_default_ticket = reset($related_tickets); |
|
852 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
853 | + foreach ($default_prices as $default_price) { |
|
854 | + if ($default_price->is_base_price()) { |
|
855 | 855 | continue; |
856 | 856 | } |
857 | - $main_default_ticket->cache( 'Price', $default_price ); |
|
857 | + $main_default_ticket->cache('Price', $default_price); |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
@@ -863,11 +863,11 @@ discard block |
||
863 | 863 | //we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information. |
864 | 864 | |
865 | 865 | //loop through and setup the ticket rows and make sure the order is set. |
866 | - foreach ( $related_tickets as $ticket ) { |
|
866 | + foreach ($related_tickets as $ticket) { |
|
867 | 867 | $tktid = $ticket->get('TKT_ID'); |
868 | 868 | $tktrow = $ticket->get('TKT_row'); |
869 | 869 | //we only want unique tickets in our final display!! |
870 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
870 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
871 | 871 | $existing_ticket_ids[] = $tktid; |
872 | 872 | $all_tickets[] = $ticket; |
873 | 873 | } |
@@ -876,57 +876,57 @@ discard block |
||
876 | 876 | $datetime_tickets[$dttid][] = $tktrow; |
877 | 877 | |
878 | 878 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
879 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
879 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
880 | 880 | $ticket_datetimes[$tktid][] = $dttrow; |
881 | 881 | } |
882 | 882 | $dttrow++; |
883 | 883 | } |
884 | 884 | |
885 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
886 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
887 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
885 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
886 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
887 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
888 | 888 | |
889 | 889 | //sort $all_tickets by order |
890 | - usort( $all_tickets, function( $a, $b ) { |
|
890 | + usort($all_tickets, function($a, $b) { |
|
891 | 891 | $a_order = (int) $a->get('TKT_order'); |
892 | 892 | $b_order = (int) $b->get('TKT_order'); |
893 | - if ( $a_order == $b_order ) { |
|
893 | + if ($a_order == $b_order) { |
|
894 | 894 | return 0; |
895 | 895 | } |
896 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
896 | + return ($a_order < $b_order) ? -1 : 1; |
|
897 | 897 | }); |
898 | 898 | |
899 | 899 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
900 | 900 | $dttrow = 1; |
901 | - foreach ( $times as $time ) { |
|
902 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
901 | + foreach ($times as $time) { |
|
902 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
903 | 903 | $dttrow++; |
904 | 904 | } |
905 | 905 | |
906 | 906 | //then loop through all tickets for the ticket rows. |
907 | 907 | $tktrow = 1; |
908 | - foreach ( $all_tickets as $ticket ) { |
|
909 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
908 | + foreach ($all_tickets as $ticket) { |
|
909 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
910 | 910 | $tktrow++; |
911 | 911 | } |
912 | 912 | |
913 | 913 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
914 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
915 | - EEH_Template::display_template( $template, $main_template_args ); |
|
914 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
915 | + EEH_Template::display_template($template, $main_template_args); |
|
916 | 916 | return; |
917 | 917 | } |
918 | 918 | |
919 | 919 | |
920 | 920 | |
921 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
921 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
922 | 922 | |
923 | 923 | $dtt_display_template_args = array( |
924 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
925 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
924 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
925 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
926 | 926 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
927 | 927 | ); |
928 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
929 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
928 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
929 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | * |
945 | 945 | * @return string Generated edit row. |
946 | 946 | */ |
947 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
947 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
948 | 948 | |
949 | 949 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
950 | 950 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -952,30 +952,30 @@ discard block |
||
952 | 952 | $template_args = array( |
953 | 953 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
954 | 954 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
955 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
955 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
956 | 956 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
957 | 957 | 'DTT_name' => $default ? '' : $dtt->name(), |
958 | 958 | 'DTT_description' => $default ? '' : $dtt->description(), |
959 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
960 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
961 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
959 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
960 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
961 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
962 | 962 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
963 | 963 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
964 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
965 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
964 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
965 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
966 | 966 | ); |
967 | 967 | |
968 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
968 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
969 | 969 | |
970 | 970 | //allow filtering of template args at this point. |
971 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
971 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
972 | 972 | |
973 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
974 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
973 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
974 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | |
978 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
978 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
979 | 979 | |
980 | 980 | $template_args = array( |
981 | 981 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -983,47 +983,47 @@ discard block |
||
983 | 983 | 'DTT_description' => $default ? '' : $dtt->description(), |
984 | 984 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
985 | 985 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
986 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
986 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
987 | 987 | 'DTT_ID' => $default ? '' : $dtt->ID() |
988 | 988 | ); |
989 | 989 | |
990 | 990 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
991 | - if ( !$default ) { |
|
991 | + if ( ! $default) { |
|
992 | 992 | $tktrow = 1; |
993 | - foreach ( $all_tickets as $ticket ) { |
|
994 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
993 | + foreach ($all_tickets as $ticket) { |
|
994 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
995 | 995 | $tktrow++; |
996 | 996 | } |
997 | 997 | } |
998 | 998 | |
999 | 999 | //filter template args at this point |
1000 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
1000 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
1001 | 1001 | |
1002 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
1003 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1002 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
1003 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
1007 | 1007 | |
1008 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
1009 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
1010 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1008 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
1009 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
1010 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1011 | 1011 | |
1012 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
1012 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
1013 | 1013 | $template_args = array( |
1014 | 1014 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
1015 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
1015 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1016 | 1016 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1017 | 1017 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1018 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1019 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1018 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1019 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1020 | 1020 | ); |
1021 | 1021 | |
1022 | 1022 | //filter template args |
1023 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
1023 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
1024 | 1024 | |
1025 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1026 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1025 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1026 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | |
@@ -1045,37 +1045,37 @@ discard block |
||
1045 | 1045 | * |
1046 | 1046 | * @return [type] [description] |
1047 | 1047 | */ |
1048 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1048 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1049 | 1049 | |
1050 | 1050 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1051 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1051 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1052 | 1052 | |
1053 | - $prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1053 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1054 | 1054 | |
1055 | 1055 | //if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on |
1056 | 1056 | //the object. This is done by not including any query_params. |
1057 | - if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1 || empty( $prices ) ) ) { |
|
1058 | - $prices = $ticket->get_many_related( 'Price' ); |
|
1057 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
1058 | + $prices = $ticket->get_many_related('Price'); |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1062 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1062 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1063 | 1063 | |
1064 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1064 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1065 | 1065 | |
1066 | 1066 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1067 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1067 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1068 | 1068 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1069 | 1069 | |
1070 | 1070 | //breaking out complicated condition for ticket_status |
1071 | - if ( $default ) { |
|
1072 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1071 | + if ($default) { |
|
1072 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1073 | 1073 | } else { |
1074 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1074 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | //breaking out complicated condition for TKT_taxable |
1078 | - if ( $default ) { |
|
1078 | + if ($default) { |
|
1079 | 1079 | $TKT_taxable = ''; |
1080 | 1080 | } else { |
1081 | 1081 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1090,19 +1090,19 @@ discard block |
||
1090 | 1090 | 'edit_tkt_expanded' => '', |
1091 | 1091 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1092 | 1092 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1093 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1094 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1095 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1093 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1094 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1095 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1096 | 1096 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1097 | 1097 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1098 | 1098 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1099 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1100 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1101 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1102 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1103 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1099 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1100 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1101 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1102 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1103 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1104 | 1104 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1105 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1105 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1106 | 1106 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1107 | 1107 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1108 | 1108 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1111,99 +1111,99 @@ discard block |
||
1111 | 1111 | 'ticket_price_rows' => '', |
1112 | 1112 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1113 | 1113 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1114 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1115 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1114 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1115 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1116 | 1116 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1117 | 1117 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1118 | 1118 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1119 | 1119 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1120 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1120 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1121 | 1121 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1122 | 1122 | 'TKT_taxable' => $TKT_taxable, |
1123 | 1123 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1124 | 1124 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1125 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1125 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1126 | 1126 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1127 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1128 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1127 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1128 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1129 | 1129 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1130 | 1130 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1131 | 1131 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1132 | 1132 | ); |
1133 | 1133 | |
1134 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1134 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1135 | 1135 | |
1136 | 1136 | //handle rows that should NOT be empty |
1137 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1137 | + if (empty($template_args['TKT_start_date'])) { |
|
1138 | 1138 | //if empty then the start date will be now. |
1139 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1140 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1139 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1140 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1143 | + if (empty($template_args['TKT_end_date'])) { |
|
1144 | 1144 | |
1145 | 1145 | //get the earliest datetime (if present); |
1146 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1146 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1147 | 1147 | |
1148 | - if ( !empty( $earliest_dtt ) ) { |
|
1149 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1148 | + if ( ! empty($earliest_dtt)) { |
|
1149 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1150 | 1150 | } else { |
1151 | 1151 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1152 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1152 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1153 | 1153 | } |
1154 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1154 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | //generate ticket_datetime items |
1158 | - if ( ! $default ) { |
|
1158 | + if ( ! $default) { |
|
1159 | 1159 | $dttrow = 1; |
1160 | - foreach ( $all_dtts as $dtt ) { |
|
1161 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1160 | + foreach ($all_dtts as $dtt) { |
|
1161 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1162 | 1162 | $dttrow++; |
1163 | 1163 | } |
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | $prcrow = 1; |
1167 | - foreach ( $prices as $price ) { |
|
1168 | - if ( $price->is_base_price() ) { |
|
1167 | + foreach ($prices as $price) { |
|
1168 | + if ($price->is_base_price()) { |
|
1169 | 1169 | $prcrow++; |
1170 | 1170 | continue; |
1171 | 1171 | } |
1172 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1173 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1174 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1172 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1173 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1174 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1175 | 1175 | $prcrow++; |
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | //filter $template_args |
1179 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1179 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1180 | 1180 | |
1181 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1182 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1181 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1182 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | |
1186 | 1186 | |
1187 | 1187 | |
1188 | 1188 | |
1189 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1189 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1190 | 1190 | $tax_rows = ''; |
1191 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1191 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1192 | 1192 | $template_args = array(); |
1193 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1194 | - foreach ( $taxes as $tax ) { |
|
1195 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1193 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1194 | + foreach ($taxes as $tax) { |
|
1195 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1196 | 1196 | $template_args = array( |
1197 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1197 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1198 | 1198 | 'tax_id' => $tax->ID(), |
1199 | 1199 | 'tkt_row' => $tktrow, |
1200 | 1200 | 'tax_label' => $tax->get('PRC_name'), |
1201 | 1201 | 'tax_added' => $tax_added, |
1202 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1202 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1203 | 1203 | 'tax_amount' => $tax->get('PRC_amount') |
1204 | 1204 | ); |
1205 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1206 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1205 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1206 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
@@ -1211,81 +1211,81 @@ discard block |
||
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | |
1214 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1215 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1214 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1215 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1216 | 1216 | return $subtotal * $tax->get('PRC_amount') / 100; |
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | |
1220 | 1220 | |
1221 | 1221 | |
1222 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1223 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1222 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1223 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1224 | 1224 | $template_args = array( |
1225 | 1225 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1226 | 1226 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1227 | 1227 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1228 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1228 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1229 | 1229 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1230 | 1230 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1231 | 1231 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1232 | 1232 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1233 | 1233 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1234 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1235 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1236 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1237 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1238 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1234 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1235 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1236 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1237 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1238 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1239 | 1239 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1240 | 1240 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1241 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1242 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1241 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1242 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1243 | 1243 | ); |
1244 | 1244 | |
1245 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1245 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1246 | 1246 | |
1247 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1248 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1247 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1248 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | |
1252 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1253 | - if ( $price->is_base_price() ) { |
|
1254 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1252 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1253 | + if ($price->is_base_price()) { |
|
1254 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1255 | 1255 | } else { |
1256 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1256 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | |
1262 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1262 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1263 | 1263 | $template_args = array( |
1264 | 1264 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1265 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1266 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1265 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1266 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1267 | 1267 | 'PRT_name' => __('Price', 'event_espresso'), |
1268 | 1268 | 'price_selected_operator' => '+', |
1269 | 1269 | 'price_selected_is_percent' => 0 |
1270 | 1270 | ); |
1271 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1271 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1272 | 1272 | |
1273 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1273 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1274 | 1274 | |
1275 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1275 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | |
1279 | 1279 | |
1280 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1281 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1282 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1283 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1284 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1285 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1280 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1281 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1282 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1283 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1284 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1285 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1286 | 1286 | $price_option_spans = ''; |
1287 | 1287 | //setup pricetypes for selector |
1288 | - foreach ( $price_types as $price_type ) { |
|
1288 | + foreach ($price_types as $price_type) { |
|
1289 | 1289 | $all_price_types[] = array( |
1290 | 1290 | 'id' => $price_type->ID(), |
1291 | 1291 | 'text' => $price_type->get('PRT_name'), |
@@ -1297,50 +1297,50 @@ discard block |
||
1297 | 1297 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1298 | 1298 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1299 | 1299 | ); |
1300 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1300 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1303 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1304 | 1304 | $main_name = $select_name; |
1305 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1305 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1306 | 1306 | |
1307 | 1307 | $template_args = array( |
1308 | 1308 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1309 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1310 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1309 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1310 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1311 | 1311 | 'main_name' => $main_name, |
1312 | 1312 | 'selected_price_type_id' => $selected_price_type_id, |
1313 | 1313 | 'price_option_spans' => $price_option_spans, |
1314 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1315 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1314 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1315 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1316 | 1316 | 'disabled' => $disabled |
1317 | 1317 | ); |
1318 | 1318 | |
1319 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1319 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1320 | 1320 | |
1321 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1321 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1322 | 1322 | |
1323 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1323 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | |
1327 | 1327 | |
1328 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1329 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1330 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1331 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1328 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1329 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1330 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1331 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1332 | 1332 | $template_args = array( |
1333 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1333 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1334 | 1334 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1335 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1336 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1337 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1335 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1336 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1337 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1338 | 1338 | 'tkt_status_class' => '', |
1339 | 1339 | ); |
1340 | 1340 | |
1341 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1342 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1343 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1341 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1342 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1343 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | |
@@ -1348,53 +1348,53 @@ discard block |
||
1348 | 1348 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1349 | 1349 | $template_args = array( |
1350 | 1350 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1351 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1352 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1351 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1352 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1353 | 1353 | 'default_price_rows' => '', |
1354 | 1354 | 'default_base_price_amount' => 0, |
1355 | 1355 | 'default_base_price_name' => '', |
1356 | 1356 | 'default_base_price_description' => '', |
1357 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1358 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1357 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1358 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1359 | 1359 | 'existing_available_datetime_tickets_list' => '', |
1360 | 1360 | 'existing_available_ticket_datetimes_list' => '', |
1361 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1362 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1361 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1362 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1363 | 1363 | ); |
1364 | 1364 | |
1365 | 1365 | $tktrow = 1; |
1366 | - foreach ( $all_tickets as $ticket ) { |
|
1367 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1366 | + foreach ($all_tickets as $ticket) { |
|
1367 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1368 | 1368 | $tktrow++; |
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | |
1372 | 1372 | $dttrow = 1; |
1373 | - foreach ( $all_dtts as $dtt ) { |
|
1374 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1373 | + foreach ($all_dtts as $dtt) { |
|
1374 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1375 | 1375 | $dttrow++; |
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1379 | 1379 | $prcrow = 1; |
1380 | - foreach ( $default_prices as $price ) { |
|
1381 | - if ( $price->is_base_price() ) { |
|
1380 | + foreach ($default_prices as $price) { |
|
1381 | + if ($price->is_base_price()) { |
|
1382 | 1382 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1383 | 1383 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1384 | 1384 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1385 | 1385 | $prcrow++; |
1386 | 1386 | continue; |
1387 | 1387 | } |
1388 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1389 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1390 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1388 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1389 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1390 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1391 | 1391 | $prcrow++; |
1392 | 1392 | } |
1393 | 1393 | |
1394 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1394 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1395 | 1395 | |
1396 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1397 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1396 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1397 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -55,34 +55,34 @@ discard block |
||
55 | 55 | '[EVENT_NAME]' => __("This also can be used for the name of the event", 'event_espresso'), |
56 | 56 | '[EVENT_PHONE]' => __('The phone number for the event (usually an info number)', 'event_espresso'), |
57 | 57 | '[EVENT_DESCRIPTION]' => __('The description of the event', 'event_espresso'), |
58 | - '[EVENT_EXCERPT]' => __( 'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso' ), |
|
58 | + '[EVENT_EXCERPT]' => __('This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso'), |
|
59 | 59 | '[EVENT_LINK]' => __('A link associated with the event', 'event_espresso'), |
60 | 60 | '[EVENT_URL]' => __('A link to the event set up on the host site.', 'event_espresso'), |
61 | 61 | '[VIRTUAL_URL]' => __('What was used for the "URL of Event" field in the Venue settings', 'event_espresso'), |
62 | 62 | '[VIRTUAL_PHONE]' => __('An alternate phone number for the event. Typically used as a "call-in" number', 'event_espresso'), |
63 | 63 | '[EVENT_IMAGE]' => __('This will parse to the Feature image for the event.', 'event_espresso'), |
64 | 64 | '[EVENT_TOTAL_AVAILABLE_SPACES_*]' => sprintf( |
65 | - __( 'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso' ), |
|
65 | + __('This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso'), |
|
66 | 66 | '<code>', |
67 | 67 | '</code>' |
68 | 68 | ), |
69 | - '[EVENT_TOTAL_SPOTS_TAKEN]' => __( 'This shortcode will parse to the output the total approved registrations for this event', 'event_espresso' ), |
|
69 | + '[EVENT_TOTAL_SPOTS_TAKEN]' => __('This shortcode will parse to the output the total approved registrations for this event', 'event_espresso'), |
|
70 | 70 | '[EVENT_FACEBOOK_URL]' => __('This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.', 'event_espresso'), |
71 | 71 | '[EVENT_TWITTER_URL]' => __('This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url', 'event_espresso'), |
72 | 72 | '[EVENT_META_*]' => __('This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode.', 'event_espresso'), |
73 | - '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __( 'This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso' ), |
|
73 | + '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __('This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso'), |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | |
78 | - protected function _parser( $shortcode ) { |
|
78 | + protected function _parser($shortcode) { |
|
79 | 79 | |
80 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
80 | + EE_Registry::instance()->load_helper('Formatter'); |
|
81 | 81 | |
82 | 82 | $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
83 | 83 | |
84 | 84 | //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
85 | - if ( empty( $this->_event ) ) { |
|
85 | + if (empty($this->_event)) { |
|
86 | 86 | $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; |
87 | 87 | $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
88 | 88 | |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | |
92 | 92 | |
93 | 93 | //If there is no event objecdt by now then get out. |
94 | - if ( ! $this->_event instanceof EE_Event ) |
|
94 | + if ( ! $this->_event instanceof EE_Event) |
|
95 | 95 | return ''; |
96 | 96 | |
97 | - switch ( $shortcode ) { |
|
97 | + switch ($shortcode) { |
|
98 | 98 | |
99 | 99 | case '[EVENT_ID]' : |
100 | 100 | return $this->_event->ID(); |
@@ -127,71 +127,71 @@ discard block |
||
127 | 127 | |
128 | 128 | case '[VIRTUAL_URL]' : |
129 | 129 | $venue = $this->_event->get_first_related('Venue'); |
130 | - if ( empty( $venue ) ) |
|
130 | + if (empty($venue)) |
|
131 | 131 | return ''; |
132 | 132 | return $venue->get('VNU_virtual_url'); |
133 | 133 | |
134 | 134 | case '[VIRTUAL_PHONE]' : |
135 | 135 | $venue = $this->_event->get_first_related('Venue'); |
136 | - if ( empty( $venue ) ) |
|
136 | + if (empty($venue)) |
|
137 | 137 | return ''; |
138 | 138 | return $venue->get('VNU_virtual_phone'); |
139 | 139 | break; |
140 | 140 | |
141 | 141 | case '[EVENT_IMAGE]' : |
142 | - $image = $this->_event->feature_image_url(array(600,300) ); |
|
142 | + $image = $this->_event->feature_image_url(array(600, 300)); |
|
143 | 143 | // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. |
144 | - return !empty( $image ) ? '<img src="' . $image . '" alt="' . sprintf( esc_attr__( '%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name') ) . '" />' : ''; |
|
144 | + return ! empty($image) ? '<img src="'.$image.'" alt="'.sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')).'" />' : ''; |
|
145 | 145 | break; |
146 | 146 | |
147 | 147 | case '[EVENT_FACEBOOK_URL]' : |
148 | - $facebook_url = $this->_event->get_post_meta('event_facebook', true ); |
|
149 | - return empty( $facebook_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : $facebook_url; |
|
148 | + $facebook_url = $this->_event->get_post_meta('event_facebook', true); |
|
149 | + return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url; |
|
150 | 150 | break; |
151 | 151 | |
152 | 152 | case '[EVENT_TWITTER_URL]' : |
153 | 153 | $twitter_url = $this->_event->get_post_meta('event_twitter', true); |
154 | - return empty( $twitter_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : $twitter_url; |
|
154 | + return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url; |
|
155 | 155 | break; |
156 | 156 | |
157 | 157 | case '[EVENT_AUTHOR_EMAIL]' : |
158 | 158 | $author_id = $this->_event->get('EVT_wp_user'); |
159 | - $user_data = get_userdata( (int) $author_id ); |
|
159 | + $user_data = get_userdata((int) $author_id); |
|
160 | 160 | return $user_data->user_email; |
161 | 161 | break; |
162 | 162 | |
163 | 163 | case '[EVENT_TOTAL_SPOTS_TAKEN]' : |
164 | - return EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
164 | + return EEM_Registration::instance()->count(array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
165 | 165 | break; |
166 | 166 | |
167 | 167 | case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' : |
168 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
168 | + EE_Registry::instance()->load_helper('URL'); |
|
169 | 169 | return EEH_URL::add_query_args_and_nonce( |
170 | 170 | array( |
171 | 171 | 'event_id' => $this->_event->ID(), |
172 | 172 | 'page' => 'espresso_registrations', |
173 | 173 | 'action' => 'default' |
174 | 174 | ), |
175 | - admin_url( 'admin.php' ), |
|
175 | + admin_url('admin.php'), |
|
176 | 176 | true |
177 | 177 | ); |
178 | 178 | break; |
179 | 179 | } |
180 | 180 | |
181 | - if ( strpos( $shortcode, '[EVENT_META_*' ) !== false ) { |
|
182 | - $shortcode = str_replace( '[EVENT_META_*', '', $shortcode ); |
|
183 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
181 | + if (strpos($shortcode, '[EVENT_META_*') !== false) { |
|
182 | + $shortcode = str_replace('[EVENT_META_*', '', $shortcode); |
|
183 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
184 | 184 | |
185 | 185 | //pull the meta value from the event post |
186 | - $event_meta = $this->_event->get_post_meta( $shortcode, true ); |
|
186 | + $event_meta = $this->_event->get_post_meta($shortcode, true); |
|
187 | 187 | |
188 | - return !empty( $event_meta ) ? $this->_event->get_post_meta( $shortcode, true ) : ''; |
|
188 | + return ! empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : ''; |
|
189 | 189 | |
190 | 190 | } |
191 | 191 | |
192 | - if ( strpos( $shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*' ) !== false ) { |
|
193 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
194 | - $method = empty( $attrs['method'] ) ? 'current' : $attrs['method']; |
|
192 | + if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { |
|
193 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
194 | + $method = empty($attrs['method']) ? 'current' : $attrs['method']; |
|
195 | 195 | $method = $method === 'current'; |
196 | 196 | $available = $this->_event->total_available_spaces($method); |
197 | 197 | return $available === EE_INF ? '∞' : $available; |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | * @param boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event. Otherwise we just return the url of the event. |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - private function _get_event_link( $event, $full_link = TRUE ) { |
|
210 | + private function _get_event_link($event, $full_link = TRUE) { |
|
211 | 211 | $url = get_permalink($event->ID()); |
212 | 212 | |
213 | - return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url; |
|
213 | + return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url; |
|
214 | 214 | } |
215 | 215 | |
216 | 216 |