@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | * @param bool $routing |
| 57 | 57 | * @return Transactions_Admin_Page |
| 58 | 58 | */ |
| 59 | - public function __construct( $routing = TRUE ) { |
|
| 60 | - parent::__construct( $routing ); |
|
| 59 | + public function __construct($routing = TRUE) { |
|
| 60 | + parent::__construct($routing); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * @return void |
| 81 | 81 | */ |
| 82 | 82 | protected function _ajax_hooks() { |
| 83 | - add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds')); |
|
| 84 | - add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds')); |
|
| 85 | - add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment')); |
|
| 83 | + add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
| 84 | + add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
| 85 | + add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | 'buttons' => array( |
| 98 | 98 | 'add' => __('Add New Transaction', 'event_espresso'), |
| 99 | 99 | 'edit' => __('Edit Transaction', 'event_espresso'), |
| 100 | - 'delete' => __('Delete Transaction','event_espresso'), |
|
| 100 | + 'delete' => __('Delete Transaction', 'event_espresso'), |
|
| 101 | 101 | ) |
| 102 | 102 | ); |
| 103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $this->_set_transaction_status_array(); |
| 115 | 115 | |
| 116 | - $txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0; |
|
| 116 | + $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
| 117 | 117 | |
| 118 | 118 | $this->_page_routes = array( |
| 119 | 119 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | 'filename' => 'transactions_overview_views_filters_search' |
| 186 | 186 | ), |
| 187 | 187 | ), |
| 188 | - 'help_tour' => array( 'Transactions_Overview_Help_Tour' ), |
|
| 188 | + 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
| 189 | 189 | /** |
| 190 | 190 | * commented out because currently we are not displaying tips for transaction list table status but this |
| 191 | 191 | * may change in a later iteration so want to keep the code for then. |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | 'nav' => array( |
| 198 | 198 | 'label' => __('View Transaction', 'event_espresso'), |
| 199 | 199 | 'order' => 5, |
| 200 | - 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
|
| 200 | + 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url, |
|
| 201 | 201 | 'persistent' => FALSE |
| 202 | 202 | ), |
| 203 | 203 | 'help_tabs' => array( |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | 'filename' => 'transactions_view_transaction_primary_registrant_billing_information' |
| 219 | 219 | ), |
| 220 | 220 | ), |
| 221 | - 'qtips' => array( 'Transaction_Details_Tips' ), |
|
| 222 | - 'help_tour' => array( 'Transaction_Details_Help_Tour' ), |
|
| 221 | + 'qtips' => array('Transaction_Details_Tips'), |
|
| 222 | + 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
| 223 | 223 | 'metaboxes' => array('_transaction_details_metaboxes'), |
| 224 | 224 | |
| 225 | 225 | 'require_nonce' => FALSE |
@@ -237,21 +237,21 @@ discard block |
||
| 237 | 237 | // IF a registration was JUST added via the admin... |
| 238 | 238 | if ( |
| 239 | 239 | isset( |
| 240 | - $this->_req_data[ 'redirect_from' ], |
|
| 241 | - $this->_req_data[ 'EVT_ID' ], |
|
| 242 | - $this->_req_data[ 'event_name' ] |
|
| 240 | + $this->_req_data['redirect_from'], |
|
| 241 | + $this->_req_data['EVT_ID'], |
|
| 242 | + $this->_req_data['event_name'] |
|
| 243 | 243 | ) |
| 244 | 244 | ) { |
| 245 | 245 | // then set a cookie so that we can block any attempts to use |
| 246 | 246 | // the back button as a way to enter another registration. |
| 247 | - setcookie( 'ee_registration_added', $this->_req_data[ 'EVT_ID' ], time() + WEEK_IN_SECONDS, '/' ); |
|
| 247 | + setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
| 248 | 248 | // and update the global |
| 249 | - $_COOKIE[ 'ee_registration_added' ] = $this->_req_data[ 'EVT_ID' ]; |
|
| 249 | + $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
| 250 | 250 | } |
| 251 | - EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' ); |
|
| 252 | - EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' ); |
|
| 253 | - EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status; |
|
| 254 | - EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status; |
|
| 251 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso'); |
|
| 252 | + EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', 'event_espresso'); |
|
| 253 | + EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
| 254 | + EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
| 255 | 255 | } |
| 256 | 256 | public function admin_notices() {} |
| 257 | 257 | public function admin_footer_scripts() {} |
@@ -318,14 +318,14 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public function load_scripts_styles() { |
| 320 | 320 | //enqueue style |
| 321 | - wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 321 | + wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 322 | 322 | wp_enqueue_style('espresso_txn'); |
| 323 | 323 | |
| 324 | 324 | //scripts |
| 325 | 325 | add_filter('FHEE_load_accounting_js', '__return_true'); |
| 326 | 326 | |
| 327 | 327 | //scripts |
| 328 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 328 | + wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 329 | 329 | wp_enqueue_script('espresso_txn'); |
| 330 | 330 | |
| 331 | 331 | } |
@@ -365,8 +365,8 @@ discard block |
||
| 365 | 365 | * @return void |
| 366 | 366 | */ |
| 367 | 367 | protected function _set_list_table_views_default() { |
| 368 | - $this->_views = array ( |
|
| 369 | - 'all' => array ( |
|
| 368 | + $this->_views = array( |
|
| 369 | + 'all' => array( |
|
| 370 | 370 | 'slug' => 'all', |
| 371 | 371 | 'label' => __('View All Transactions', 'event_espresso'), |
| 372 | 372 | 'count' => 0 |
@@ -394,20 +394,20 @@ discard block |
||
| 394 | 394 | * @return void |
| 395 | 395 | */ |
| 396 | 396 | private function _set_transaction_object() { |
| 397 | - if ( is_object( $this->_transaction) ) |
|
| 397 | + if (is_object($this->_transaction)) |
|
| 398 | 398 | return; //get out we've already set the object |
| 399 | 399 | |
| 400 | 400 | $TXN = EEM_Transaction::instance(); |
| 401 | 401 | |
| 402 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
| 402 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
| 403 | 403 | |
| 404 | 404 | //get transaction object |
| 405 | 405 | $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
| 406 | - $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
| 406 | + $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
| 407 | 407 | |
| 408 | - if ( empty( $this->_transaction ) ) { |
|
| 409 | - $error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID . __(' could not be retrieved.', 'event_espresso'); |
|
| 410 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 408 | + if (empty($this->_transaction)) { |
|
| 409 | + $error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.__(' could not be retrieved.', 'event_espresso'); |
|
| 410 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | ), |
| 434 | 434 | 'view_receipt' => array( |
| 435 | 435 | 'class' => 'dashicons dashicons-media-default', |
| 436 | - 'desc' => __('View Transaction Receipt', 'event_espresso' ) |
|
| 436 | + 'desc' => __('View Transaction Receipt', 'event_espresso') |
|
| 437 | 437 | ), |
| 438 | 438 | 'view_registration' => array( |
| 439 | 439 | 'class' => 'dashicons dashicons-clipboard', |
@@ -442,10 +442,10 @@ discard block |
||
| 442 | 442 | ) |
| 443 | 443 | ); |
| 444 | 444 | |
| 445 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) { |
|
| 445 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) { |
|
| 446 | 446 | |
| 447 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 448 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
| 447 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 448 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
| 449 | 449 | $items['send_payment_reminder'] = array( |
| 450 | 450 | 'class' => 'dashicons dashicons-email-alt', |
| 451 | 451 | 'desc' => __('Send Payment Reminder', 'event_espresso') |
@@ -466,29 +466,29 @@ discard block |
||
| 466 | 466 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
| 467 | 467 | array( |
| 468 | 468 | 'overpaid' => array( |
| 469 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
| 470 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' ) |
|
| 469 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code, |
|
| 470 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence') |
|
| 471 | 471 | ), |
| 472 | 472 | 'complete' => array( |
| 473 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
| 474 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' ) |
|
| 473 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code, |
|
| 474 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence') |
|
| 475 | 475 | ), |
| 476 | 476 | 'incomplete' => array( |
| 477 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
| 478 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' ) |
|
| 477 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code, |
|
| 478 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence') |
|
| 479 | 479 | ), |
| 480 | 480 | 'abandoned' => array( |
| 481 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
| 482 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' ) |
|
| 481 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code, |
|
| 482 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence') |
|
| 483 | 483 | ), |
| 484 | 484 | 'failed' => array( |
| 485 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
| 486 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' ) |
|
| 485 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code, |
|
| 486 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence') |
|
| 487 | 487 | ) |
| 488 | 488 | ) |
| 489 | 489 | ); |
| 490 | 490 | |
| 491 | - return array_merge( $items, $more_items); |
|
| 491 | + return array_merge($items, $more_items); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | |
@@ -501,9 +501,9 @@ discard block |
||
| 501 | 501 | */ |
| 502 | 502 | protected function _transactions_overview_list_table() { |
| 503 | 503 | $this->_admin_page_title = __('Transactions', 'event_espresso'); |
| 504 | - $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL; |
|
| 505 | - $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : ''; |
|
| 506 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() ); |
|
| 504 | + $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL; |
|
| 505 | + $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : ''; |
|
| 506 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
| 507 | 507 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 508 | 508 | } |
| 509 | 509 | |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | * @return void |
| 518 | 518 | */ |
| 519 | 519 | protected function _transaction_details() { |
| 520 | - do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction ); |
|
| 521 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 520 | + do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
| 521 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 522 | 522 | |
| 523 | 523 | $this->_set_transaction_status_array(); |
| 524 | 524 | |
@@ -531,14 +531,14 @@ discard block |
||
| 531 | 531 | $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL; |
| 532 | 532 | |
| 533 | 533 | $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
| 534 | - $this->_template_args['txn_nmbr']['label'] = __( 'Transaction Number', 'event_espresso' ); |
|
| 534 | + $this->_template_args['txn_nmbr']['label'] = __('Transaction Number', 'event_espresso'); |
|
| 535 | 535 | |
| 536 | 536 | $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
| 537 | - $this->_template_args['txn_datetime']['label'] = __( 'Date', 'event_espresso' ); |
|
| 537 | + $this->_template_args['txn_datetime']['label'] = __('Date', 'event_espresso'); |
|
| 538 | 538 | |
| 539 | - $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ]; |
|
| 540 | - $this->_template_args['txn_status']['label'] = __( 'Transaction Status', 'event_espresso' ); |
|
| 541 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
| 539 | + $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
| 540 | + $this->_template_args['txn_status']['label'] = __('Transaction Status', 'event_espresso'); |
|
| 541 | + $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID'); |
|
| 542 | 542 | |
| 543 | 543 | $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
| 544 | 544 | $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
@@ -550,9 +550,9 @@ discard block |
||
| 550 | 550 | 'espresso_transactions_send_payment_reminder' |
| 551 | 551 | ) |
| 552 | 552 | ) { |
| 553 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 553 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 554 | 554 | $this->_template_args['send_payment_reminder_button'] = |
| 555 | - EEH_MSG_Template::is_mt_active( 'payment_reminder' ) |
|
| 555 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
| 556 | 556 | && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
| 557 | 557 | && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
| 558 | 558 | ? EEH_Template::get_button_or_link( |
@@ -574,40 +574,40 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
| 577 | - $this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE ); |
|
| 578 | - if ( EE_Registry::instance()->CFG->currency->sign_b4 ) { |
|
| 579 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
| 577 | + $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE); |
|
| 578 | + if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
| 579 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due']; |
|
| 580 | 580 | } else { |
| 581 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
| 581 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign; |
|
| 582 | 582 | } |
| 583 | - $this->_template_args['amount_due_class'] = ''; |
|
| 583 | + $this->_template_args['amount_due_class'] = ''; |
|
| 584 | 584 | |
| 585 | - if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) { |
|
| 585 | + if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
| 586 | 586 | // paid in full |
| 587 | - $this->_template_args['amount_due'] = FALSE; |
|
| 588 | - } elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) { |
|
| 587 | + $this->_template_args['amount_due'] = FALSE; |
|
| 588 | + } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
| 589 | 589 | // overpaid |
| 590 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 591 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) { |
|
| 590 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 591 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
| 592 | 592 | // monies owing |
| 593 | - $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
| 594 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) { |
|
| 593 | + $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
| 594 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
| 595 | 595 | // no payments made yet |
| 596 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 597 | - } elseif ( $this->_transaction->get('TXN_total') == 0 ) { |
|
| 596 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
| 597 | + } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
| 598 | 598 | // free event |
| 599 | - $this->_template_args['amount_due'] = FALSE; |
|
| 599 | + $this->_template_args['amount_due'] = FALSE; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | $payment_method = $this->_transaction->payment_method(); |
| 603 | 603 | |
| 604 | 604 | $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
| 605 | 605 | ? $payment_method->admin_name() |
| 606 | - : __( 'Unknown', 'event_espresso' ); |
|
| 606 | + : __('Unknown', 'event_espresso'); |
|
| 607 | 607 | |
| 608 | 608 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
| 609 | 609 | // link back to overview |
| 610 | - $this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] ) |
|
| 610 | + $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
| 611 | 611 | ? $_SERVER['HTTP_REFERER'] |
| 612 | 612 | : TXN_ADMIN_URL; |
| 613 | 613 | |
@@ -615,13 +615,13 @@ discard block |
||
| 615 | 615 | // next link |
| 616 | 616 | $next_txn = $this->_transaction->next( |
| 617 | 617 | null, |
| 618 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
| 618 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
| 619 | 619 | 'TXN_ID' |
| 620 | 620 | ); |
| 621 | 621 | $this->_template_args['next_transaction'] = $next_txn |
| 622 | 622 | ? $this->_next_link( |
| 623 | 623 | EE_Admin_Page::add_query_args_and_nonce( |
| 624 | - array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ), |
|
| 624 | + array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
| 625 | 625 | TXN_ADMIN_URL |
| 626 | 626 | ), |
| 627 | 627 | 'dashicons dashicons-arrow-right ee-icon-size-22' |
@@ -630,13 +630,13 @@ discard block |
||
| 630 | 630 | // previous link |
| 631 | 631 | $previous_txn = $this->_transaction->previous( |
| 632 | 632 | null, |
| 633 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
| 633 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
| 634 | 634 | 'TXN_ID' |
| 635 | 635 | ); |
| 636 | 636 | $this->_template_args['previous_transaction'] = $previous_txn |
| 637 | 637 | ? $this->_previous_link( |
| 638 | 638 | EE_Admin_Page::add_query_args_and_nonce( |
| 639 | - array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ), |
|
| 639 | + array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
| 640 | 640 | TXN_ADMIN_URL |
| 641 | 641 | ), |
| 642 | 642 | 'dashicons dashicons-arrow-left ee-icon-size-22' |
@@ -646,16 +646,16 @@ discard block |
||
| 646 | 646 | // were we just redirected here after adding a new registration ??? |
| 647 | 647 | if ( |
| 648 | 648 | isset( |
| 649 | - $this->_req_data[ 'redirect_from' ], |
|
| 650 | - $this->_req_data[ 'EVT_ID' ], |
|
| 651 | - $this->_req_data[ 'event_name' ] |
|
| 649 | + $this->_req_data['redirect_from'], |
|
| 650 | + $this->_req_data['EVT_ID'], |
|
| 651 | + $this->_req_data['event_name'] |
|
| 652 | 652 | ) |
| 653 | 653 | ) { |
| 654 | 654 | if ( |
| 655 | 655 | EE_Registry::instance()->CAP->current_user_can( |
| 656 | 656 | 'ee_edit_registrations', |
| 657 | 657 | 'espresso_registrations_new_registration', |
| 658 | - $this->_req_data[ 'EVT_ID' ] |
|
| 658 | + $this->_req_data['EVT_ID'] |
|
| 659 | 659 | ) |
| 660 | 660 | ) { |
| 661 | 661 | $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | 'action' => 'new_registration', |
| 666 | 666 | 'return' => 'default', |
| 667 | 667 | 'TXN_ID' => $this->_transaction->ID(), |
| 668 | - 'event_id' => $this->_req_data[ 'EVT_ID' ], |
|
| 668 | + 'event_id' => $this->_req_data['EVT_ID'], |
|
| 669 | 669 | ), |
| 670 | 670 | REG_ADMIN_URL |
| 671 | 671 | ); |
@@ -673,17 +673,17 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | $this->_admin_page_title .= sprintf( |
| 675 | 675 | __('Add Another New Registration to Event: "%1$s" ?'), |
| 676 | - htmlentities( urldecode( $this->_req_data[ 'event_name' ] ), ENT_QUOTES, 'UTF-8' ) |
|
| 676 | + htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
| 677 | 677 | ); |
| 678 | 678 | $this->_admin_page_title .= '</a>'; |
| 679 | 679 | } |
| 680 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
| 680 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
| 681 | 681 | } |
| 682 | 682 | // grab messages at the last second |
| 683 | 683 | $this->_template_args['notices'] = EE_Error::get_notices(); |
| 684 | 684 | // path to template |
| 685 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
| 686 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 685 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php'; |
|
| 686 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 687 | 687 | |
| 688 | 688 | // the details template wrapper |
| 689 | 689 | $this->display_admin_page_with_sidebar(); |
@@ -702,18 +702,18 @@ discard block |
||
| 702 | 702 | |
| 703 | 703 | $this->_set_transaction_object(); |
| 704 | 704 | |
| 705 | - add_meta_box( 'edit-txn-details-mbox', __( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' ); |
|
| 705 | + add_meta_box('edit-txn-details-mbox', __('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
| 706 | 706 | add_meta_box( |
| 707 | 707 | 'edit-txn-attendees-mbox', |
| 708 | - __( 'Attendees Registered in this Transaction', 'event_espresso' ), |
|
| 709 | - array( $this, 'txn_attendees_meta_box' ), |
|
| 708 | + __('Attendees Registered in this Transaction', 'event_espresso'), |
|
| 709 | + array($this, 'txn_attendees_meta_box'), |
|
| 710 | 710 | $this->_wp_page_slug, |
| 711 | 711 | 'normal', |
| 712 | 712 | 'high', |
| 713 | - array( 'TXN_ID' => $this->_transaction->ID() ) |
|
| 713 | + array('TXN_ID' => $this->_transaction->ID()) |
|
| 714 | 714 | ); |
| 715 | - add_meta_box( 'edit-txn-registrant-mbox', __( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
| 716 | - add_meta_box( 'edit-txn-billing-info-mbox', __( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
| 715 | + add_meta_box('edit-txn-registrant-mbox', __('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
| 716 | + add_meta_box('edit-txn-billing-info-mbox', __('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
| 717 | 717 | |
| 718 | 718 | } |
| 719 | 719 | |
@@ -734,15 +734,15 @@ discard block |
||
| 734 | 734 | |
| 735 | 735 | //get line table |
| 736 | 736 | EEH_Autoloader::register_line_item_display_autoloaders(); |
| 737 | - $Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' ); |
|
| 738 | - $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() ); |
|
| 737 | + $Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
| 738 | + $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
| 739 | 739 | $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
| 740 | 740 | |
| 741 | 741 | // process taxes |
| 742 | - $taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax ))); |
|
| 743 | - $this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE; |
|
| 742 | + $taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
| 743 | + $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE; |
|
| 744 | 744 | |
| 745 | - $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE ); |
|
| 745 | + $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE); |
|
| 746 | 746 | $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
| 747 | 747 | $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
| 748 | 748 | |
@@ -750,63 +750,63 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | // process payment details |
| 752 | 752 | $payments = $this->_transaction->get_many_related('Payment'); |
| 753 | - if( ! empty( $payments ) ) { |
|
| 754 | - $this->_template_args[ 'payments' ] = $payments; |
|
| 755 | - $this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments ); |
|
| 753 | + if ( ! empty($payments)) { |
|
| 754 | + $this->_template_args['payments'] = $payments; |
|
| 755 | + $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
| 756 | 756 | } else { |
| 757 | - $this->_template_args[ 'payments' ] = false; |
|
| 758 | - $this->_template_args[ 'existing_reg_payments' ] = array(); |
|
| 757 | + $this->_template_args['payments'] = false; |
|
| 758 | + $this->_template_args['existing_reg_payments'] = array(); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - $this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment' ), TXN_ADMIN_URL ); |
|
| 762 | - $this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL ); |
|
| 761 | + $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
| 762 | + $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL); |
|
| 763 | 763 | |
| 764 | - if ( isset( $txn_details['invoice_number'] )) { |
|
| 764 | + if (isset($txn_details['invoice_number'])) { |
|
| 765 | 765 | $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
| 766 | - $this->_template_args['txn_details']['invoice_number']['label'] = __( 'Invoice Number', 'event_espresso' ); |
|
| 766 | + $this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso'); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
| 770 | - $this->_template_args['txn_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' ); |
|
| 770 | + $this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso'); |
|
| 771 | 771 | |
| 772 | - $this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : ''; |
|
| 773 | - $this->_template_args['txn_details']['ip_address']['label'] = __( 'Transaction placed from IP', 'event_espresso' ); |
|
| 772 | + $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
| 773 | + $this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso'); |
|
| 774 | 774 | |
| 775 | - $this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : ''; |
|
| 776 | - $this->_template_args['txn_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' ); |
|
| 775 | + $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
| 776 | + $this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso'); |
|
| 777 | 777 | |
| 778 | 778 | $reg_steps = '<ul>'; |
| 779 | - foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) { |
|
| 780 | - if ( $reg_step_status === true ) { |
|
| 781 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf( __( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
| 782 | - } else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) { |
|
| 783 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
| 784 | - __( '%1$s : Initiated %2$s', 'event_espresso' ), |
|
| 785 | - ucwords( str_replace( '_', ' ', $reg_step ) ), |
|
| 786 | - gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ) |
|
| 787 | - ) . '</li>'; |
|
| 779 | + foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
| 780 | + if ($reg_step_status === true) { |
|
| 781 | + $reg_steps .= '<li style="color:#70cc50">'.sprintf(__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
| 782 | + } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
| 783 | + $reg_steps .= '<li style="color:#2EA2CC">'.sprintf( |
|
| 784 | + __('%1$s : Initiated %2$s', 'event_espresso'), |
|
| 785 | + ucwords(str_replace('_', ' ', $reg_step)), |
|
| 786 | + gmdate(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
| 787 | + ).'</li>'; |
|
| 788 | 788 | } else { |
| 789 | - $reg_steps .= '<li style="color:#E76700">' . sprintf( __( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
| 789 | + $reg_steps .= '<li style="color:#E76700">'.sprintf(__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | $reg_steps .= '</ul>'; |
| 793 | 793 | $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
| 794 | - $this->_template_args['txn_details']['reg_steps']['label'] = __( 'Registration Step Progress', 'event_espresso' ); |
|
| 794 | + $this->_template_args['txn_details']['reg_steps']['label'] = __('Registration Step Progress', 'event_espresso'); |
|
| 795 | 795 | |
| 796 | 796 | |
| 797 | 797 | $this->_get_registrations_to_apply_payment_to(); |
| 798 | - $this->_get_payment_methods( $payments ); |
|
| 798 | + $this->_get_payment_methods($payments); |
|
| 799 | 799 | $this->_get_payment_status_array(); |
| 800 | 800 | $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
| 801 | 801 | |
| 802 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction' ), TXN_ADMIN_URL ); |
|
| 803 | - $this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL ); |
|
| 804 | - $this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL ); |
|
| 802 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL); |
|
| 803 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL); |
|
| 804 | + $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL); |
|
| 805 | 805 | |
| 806 | 806 | // 'espresso_delete_payment_nonce' |
| 807 | 807 | |
| 808 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
| 809 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
| 808 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
| 809 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
| 810 | 810 | |
| 811 | 811 | } |
| 812 | 812 | |
@@ -821,27 +821,27 @@ discard block |
||
| 821 | 821 | * @param EE_Payment[] $payments |
| 822 | 822 | * @return array |
| 823 | 823 | */ |
| 824 | - protected function _get_registration_payment_IDs( $payments = array() ) { |
|
| 824 | + protected function _get_registration_payment_IDs($payments = array()) { |
|
| 825 | 825 | $existing_reg_payments = array(); |
| 826 | 826 | // get all reg payments for these payments |
| 827 | - $reg_payments = EEM_Registration_Payment::instance()->get_all( array( |
|
| 827 | + $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
| 828 | 828 | array( |
| 829 | 829 | 'PAY_ID' => array( |
| 830 | 830 | 'IN', |
| 831 | - array_keys( $payments ) |
|
| 831 | + array_keys($payments) |
|
| 832 | 832 | ) |
| 833 | 833 | ) |
| 834 | - ) ); |
|
| 835 | - if ( ! empty( $reg_payments ) ) { |
|
| 836 | - foreach ( $payments as $payment ) { |
|
| 837 | - if ( ! $payment instanceof EE_Payment ) { |
|
| 834 | + )); |
|
| 835 | + if ( ! empty($reg_payments)) { |
|
| 836 | + foreach ($payments as $payment) { |
|
| 837 | + if ( ! $payment instanceof EE_Payment) { |
|
| 838 | 838 | continue; |
| 839 | - } else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) { |
|
| 840 | - $existing_reg_payments[ $payment->ID() ] = array(); |
|
| 839 | + } else if ( ! isset($existing_reg_payments[$payment->ID()])) { |
|
| 840 | + $existing_reg_payments[$payment->ID()] = array(); |
|
| 841 | 841 | } |
| 842 | - foreach ( $reg_payments as $reg_payment ) { |
|
| 843 | - if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) { |
|
| 844 | - $existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID(); |
|
| 842 | + foreach ($reg_payments as $reg_payment) { |
|
| 843 | + if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
| 844 | + $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | } |
@@ -878,39 +878,39 @@ discard block |
||
| 878 | 878 | $registrations_to_apply_payment_to .= '<br /><div class="admin-primary-mbox-tbl-wrap">'; |
| 879 | 879 | $registrations_to_apply_payment_to .= '<table class="admin-primary-mbox-tbl">'; |
| 880 | 880 | $registrations_to_apply_payment_to .= '<thead><tr>'; |
| 881 | - $registrations_to_apply_payment_to .= '<td>' . __( 'ID', 'event_espresso' ) . '</td>'; |
|
| 882 | - $registrations_to_apply_payment_to .= '<td>' . __( 'Registrant', 'event_espresso' ) . '</td>'; |
|
| 883 | - $registrations_to_apply_payment_to .= '<td>' . __( 'Ticket', 'event_espresso' ) . '</td>'; |
|
| 884 | - $registrations_to_apply_payment_to .= '<td>' . __( 'Event', 'event_espresso' ) . '</td>'; |
|
| 885 | - $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">' . __( 'Paid', 'event_espresso' ) . '</td>'; |
|
| 886 | - $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">' . __( 'Owing', 'event_espresso' ) . '</td>'; |
|
| 887 | - $registrations_to_apply_payment_to .= '<td class="jst-cntr">' . __( 'Apply', 'event_espresso' ) . '</td>'; |
|
| 881 | + $registrations_to_apply_payment_to .= '<td>'.__('ID', 'event_espresso').'</td>'; |
|
| 882 | + $registrations_to_apply_payment_to .= '<td>'.__('Registrant', 'event_espresso').'</td>'; |
|
| 883 | + $registrations_to_apply_payment_to .= '<td>'.__('Ticket', 'event_espresso').'</td>'; |
|
| 884 | + $registrations_to_apply_payment_to .= '<td>'.__('Event', 'event_espresso').'</td>'; |
|
| 885 | + $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">'.__('Paid', 'event_espresso').'</td>'; |
|
| 886 | + $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">'.__('Owing', 'event_espresso').'</td>'; |
|
| 887 | + $registrations_to_apply_payment_to .= '<td class="jst-cntr">'.__('Apply', 'event_espresso').'</td>'; |
|
| 888 | 888 | $registrations_to_apply_payment_to .= '</tr></thead><tbody>'; |
| 889 | 889 | // get registrations for TXN |
| 890 | - $registrations = $this->_transaction->registrations( $query_params ); |
|
| 891 | - foreach ( $registrations as $registration ) { |
|
| 892 | - if ( $registration instanceof EE_Registration ) { |
|
| 890 | + $registrations = $this->_transaction->registrations($query_params); |
|
| 891 | + foreach ($registrations as $registration) { |
|
| 892 | + if ($registration instanceof EE_Registration) { |
|
| 893 | 893 | $owing = $registration->final_price() - $registration->paid(); |
| 894 | - $taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> ' . __( '+ tax', 'event_espresso' ) . '</span>' : ''; |
|
| 895 | - $checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments ) ? ' checked="checked"' : ''; |
|
| 896 | - $registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-' . $registration->ID() . '">'; |
|
| 894 | + $taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> '.__('+ tax', 'event_espresso').'</span>' : ''; |
|
| 895 | + $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) ? ' checked="checked"' : ''; |
|
| 896 | + $registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-'.$registration->ID().'">'; |
|
| 897 | 897 | // add html for checkbox input and label |
| 898 | - $registrations_to_apply_payment_to .= '<td>' . $registration->ID() . '</td>'; |
|
| 899 | - $registrations_to_apply_payment_to .= '<td>' . $registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ) . '</td>'; |
|
| 900 | - $registrations_to_apply_payment_to .= '<td>' . $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable . '</td>'; |
|
| 901 | - $registrations_to_apply_payment_to .= '<td>' . $registration->event_name() . '</td>'; |
|
| 902 | - $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">' . $registration->pretty_paid() . '</td>'; |
|
| 903 | - $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">' . EEH_Template::format_currency( $owing ) . '</td>'; |
|
| 898 | + $registrations_to_apply_payment_to .= '<td>'.$registration->ID().'</td>'; |
|
| 899 | + $registrations_to_apply_payment_to .= '<td>'.$registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __('Unknown Attendee', 'event_espresso').'</td>'; |
|
| 900 | + $registrations_to_apply_payment_to .= '<td>'.$registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable.'</td>'; |
|
| 901 | + $registrations_to_apply_payment_to .= '<td>'.$registration->event_name().'</td>'; |
|
| 902 | + $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">'.$registration->pretty_paid().'</td>'; |
|
| 903 | + $registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">'.EEH_Template::format_currency($owing).'</td>'; |
|
| 904 | 904 | $registrations_to_apply_payment_to .= '<td class="jst-cntr">'; |
| 905 | 905 | $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
| 906 | - $registrations_to_apply_payment_to .= '<input type="checkbox" value="' . $registration->ID() . '" name="txn_admin_payment[registrations]"' . $checked . $disabled . '>'; |
|
| 906 | + $registrations_to_apply_payment_to .= '<input type="checkbox" value="'.$registration->ID().'" name="txn_admin_payment[registrations]"'.$checked.$disabled.'>'; |
|
| 907 | 907 | $registrations_to_apply_payment_to .= '</td>'; |
| 908 | 908 | $registrations_to_apply_payment_to .= '</tr>'; |
| 909 | 909 | } |
| 910 | 910 | } |
| 911 | 911 | $registrations_to_apply_payment_to .= '</tbody></table></div>'; |
| 912 | - $registrations_to_apply_payment_to .= '<p class="clear description">' . __( 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso' ) . '</p></div>'; |
|
| 913 | - $this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to; |
|
| 912 | + $registrations_to_apply_payment_to .= '<p class="clear description">'.__('The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso').'</p></div>'; |
|
| 913 | + $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | |
@@ -927,9 +927,9 @@ discard block |
||
| 927 | 927 | $statuses = EEM_Registration::reg_status_array(array(), TRUE); |
| 928 | 928 | //let's add a "don't change" option. |
| 929 | 929 | $status_array['NAN'] = __('Leave the Same', 'event_espresso'); |
| 930 | - $status_array = array_merge( $status_array, $statuses ); |
|
| 931 | - $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' ); |
|
| 932 | - $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' ); |
|
| 930 | + $status_array = array_merge($status_array, $statuses); |
|
| 931 | + $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
| 932 | + $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
| 933 | 933 | |
| 934 | 934 | } |
| 935 | 935 | |
@@ -944,21 +944,21 @@ discard block |
||
| 944 | 944 | * @param EE_Payment[] to show on this page |
| 945 | 945 | * @return void |
| 946 | 946 | */ |
| 947 | - private function _get_payment_methods( $payments = array() ) { |
|
| 947 | + private function _get_payment_methods($payments = array()) { |
|
| 948 | 948 | $payment_methods_of_payments = array(); |
| 949 | - foreach( $payments as $payment ){ |
|
| 950 | - if( $payment instanceof EE_Payment ){ |
|
| 951 | - $payment_methods_of_payments[] = $payment->get( 'PMD_ID' ); |
|
| 949 | + foreach ($payments as $payment) { |
|
| 950 | + if ($payment instanceof EE_Payment) { |
|
| 951 | + $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
| 952 | 952 | } |
| 953 | 953 | } |
| 954 | - if( $payment_methods_of_payments ){ |
|
| 955 | - $query_args = array( array( 'OR*payment_method_for_payment' => array( |
|
| 956 | - 'PMD_ID' => array( 'IN', $payment_methods_of_payments ), |
|
| 957 | - 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) ); |
|
| 958 | - }else{ |
|
| 959 | - $query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ); |
|
| 954 | + if ($payment_methods_of_payments) { |
|
| 955 | + $query_args = array(array('OR*payment_method_for_payment' => array( |
|
| 956 | + 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
| 957 | + 'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') ))); |
|
| 958 | + } else { |
|
| 959 | + $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'))); |
|
| 960 | 960 | } |
| 961 | - $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args ); |
|
| 961 | + $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | |
@@ -972,46 +972,46 @@ discard block |
||
| 972 | 972 | * @param array $metabox |
| 973 | 973 | * @return void |
| 974 | 974 | */ |
| 975 | - public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) { |
|
| 975 | + public function txn_attendees_meta_box($post, $metabox = array('args' => array())) { |
|
| 976 | 976 | |
| 977 | - extract( $metabox['args'] ); |
|
| 977 | + extract($metabox['args']); |
|
| 978 | 978 | $this->_template_args['post'] = $post; |
| 979 | 979 | $this->_template_args['event_attendees'] = array(); |
| 980 | 980 | // process items in cart |
| 981 | - $line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) ); |
|
| 982 | - if ( ! empty( $line_items )) { |
|
| 983 | - foreach ( $line_items as $item ) { |
|
| 984 | - if ( $item instanceof EE_Line_Item ) { |
|
| 985 | - switch( $item->OBJ_type() ) { |
|
| 981 | + $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
| 982 | + if ( ! empty($line_items)) { |
|
| 983 | + foreach ($line_items as $item) { |
|
| 984 | + if ($item instanceof EE_Line_Item) { |
|
| 985 | + switch ($item->OBJ_type()) { |
|
| 986 | 986 | |
| 987 | 987 | case 'Event' : |
| 988 | 988 | break; |
| 989 | 989 | |
| 990 | 990 | case 'Ticket' : |
| 991 | 991 | $ticket = $item->ticket(); |
| 992 | - if ( empty( $ticket )) { |
|
| 992 | + if (empty($ticket)) { |
|
| 993 | 993 | continue; //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
| 994 | 994 | } |
| 995 | - $ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' )); |
|
| 995 | + $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
| 996 | 996 | $event = $ticket->get_first_related('Registration')->get_first_related('Event'); |
| 997 | - $event_name = $event instanceof EE_Event ? $event->get('EVT_name') . ' - ' . $item->get('LIN_name') : ''; |
|
| 997 | + $event_name = $event instanceof EE_Event ? $event->get('EVT_name').' - '.$item->get('LIN_name') : ''; |
|
| 998 | 998 | |
| 999 | - $registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() ))); |
|
| 1000 | - foreach( $registrations as $registration ) { |
|
| 1001 | - $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->get('REG_count'); |
|
| 1002 | - $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
| 1003 | - $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
| 999 | + $registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID()))); |
|
| 1000 | + foreach ($registrations as $registration) { |
|
| 1001 | + $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->get('REG_count'); |
|
| 1002 | + $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
| 1003 | + $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
| 1004 | 1004 | // attendee info |
| 1005 | 1005 | $attendee = $registration->get_first_related('Attendee'); |
| 1006 | - if ( $attendee instanceof EE_Attendee ) { |
|
| 1006 | + if ($attendee instanceof EE_Attendee) { |
|
| 1007 | 1007 | $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
| 1008 | 1008 | $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
| 1009 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event->get('EVT_name') . __(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
| 1010 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = implode(',<br>', $attendee->full_address_as_array() ); |
|
| 1009 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event->get('EVT_name').__(' Event', 'event_espresso').'">'.$attendee->email().'</a>'; |
|
| 1010 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = implode(',<br>', $attendee->full_address_as_array()); |
|
| 1011 | 1011 | } else { |
| 1012 | 1012 | $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
| 1013 | 1013 | $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
| 1014 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
|
| 1014 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
|
| 1015 | 1015 | $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
| 1016 | 1016 | } |
| 1017 | 1017 | } |
@@ -1021,12 +1021,12 @@ discard block |
||
| 1021 | 1021 | } |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees' ), TXN_ADMIN_URL ); |
|
| 1025 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE ); |
|
| 1024 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL); |
|
| 1025 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE); |
|
| 1026 | 1026 | |
| 1027 | 1027 | } else { |
| 1028 | 1028 | echo sprintf( |
| 1029 | - __( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ), |
|
| 1029 | + __('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'), |
|
| 1030 | 1030 | '<p class="important-notice">', |
| 1031 | 1031 | '</p>' |
| 1032 | 1032 | ); |
@@ -1045,20 +1045,20 @@ discard block |
||
| 1045 | 1045 | */ |
| 1046 | 1046 | public function txn_registrant_side_meta_box() { |
| 1047 | 1047 | $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
| 1048 | - if ( ! $primary_att instanceof EE_Attendee ) { |
|
| 1048 | + if ( ! $primary_att instanceof EE_Attendee) { |
|
| 1049 | 1049 | $this->_template_args['no_attendee_message'] = __('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', 'event_espresso'); |
| 1050 | 1050 | $primary_att = EEM_Attendee::instance()->create_default_object(); |
| 1051 | 1051 | } |
| 1052 | - $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
| 1052 | + $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
| 1053 | 1053 | $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
| 1054 | 1054 | $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
| 1055 | - $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
| 1055 | + $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
| 1056 | 1056 | $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
| 1057 | - $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID() ), REG_ADMIN_URL ); |
|
| 1057 | + $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL); |
|
| 1058 | 1058 | // get formatted address for registrant |
| 1059 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
| 1060 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att ); |
|
| 1061 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE ); |
|
| 1059 | + EE_Registry::instance()->load_helper('Formatter'); |
|
| 1060 | + $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
| 1061 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE); |
|
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | 1064 | |
@@ -1074,12 +1074,12 @@ discard block |
||
| 1074 | 1074 | |
| 1075 | 1075 | $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
| 1076 | 1076 | $this->_template_args['billing_form_url'] = add_query_arg( |
| 1077 | - array( 'action' => 'edit_transaction', 'process' => 'billing' ), |
|
| 1077 | + array('action' => 'edit_transaction', 'process' => 'billing'), |
|
| 1078 | 1078 | TXN_ADMIN_URL |
| 1079 | 1079 | ); |
| 1080 | 1080 | |
| 1081 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
| 1082 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/ |
|
| 1081 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
| 1082 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/ |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | |
@@ -1092,42 +1092,42 @@ discard block |
||
| 1092 | 1092 | * @return void |
| 1093 | 1093 | */ |
| 1094 | 1094 | public function apply_payments_or_refunds() { |
| 1095 | - $json_response_data = array( 'return_data' => FALSE ); |
|
| 1095 | + $json_response_data = array('return_data' => FALSE); |
|
| 1096 | 1096 | $valid_data = $this->_validate_payment_request_data(); |
| 1097 | - if ( ! empty( $valid_data ) ) { |
|
| 1098 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
| 1097 | + if ( ! empty($valid_data)) { |
|
| 1098 | + $PAY_ID = $valid_data['PAY_ID']; |
|
| 1099 | 1099 | //save the new payment |
| 1100 | - $payment = $this->_create_payment_from_request_data( $valid_data ); |
|
| 1100 | + $payment = $this->_create_payment_from_request_data($valid_data); |
|
| 1101 | 1101 | // get the TXN for this payment |
| 1102 | 1102 | $transaction = $payment->transaction(); |
| 1103 | 1103 | // verify transaction |
| 1104 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 1104 | + if ($transaction instanceof EE_Transaction) { |
|
| 1105 | 1105 | // calculate_total_payments_and_update_status |
| 1106 | - $this->_process_transaction_payments( $transaction ); |
|
| 1107 | - $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment ); |
|
| 1108 | - $this->_remove_existing_registration_payments( $payment, $PAY_ID ); |
|
| 1106 | + $this->_process_transaction_payments($transaction); |
|
| 1107 | + $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
| 1108 | + $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
| 1109 | 1109 | // apply payment to registrations (if applicable) |
| 1110 | - if ( ! empty( $REG_IDs ) ) { |
|
| 1111 | - $this->_update_registration_payments( $transaction, $payment, $REG_IDs ); |
|
| 1110 | + if ( ! empty($REG_IDs)) { |
|
| 1111 | + $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
| 1112 | 1112 | $this->_maybe_send_notifications(); |
| 1113 | 1113 | // now process status changes for the same registrations |
| 1114 | - $this->_process_registration_status_change( $transaction, $REG_IDs ); |
|
| 1114 | + $this->_process_registration_status_change($transaction, $REG_IDs); |
|
| 1115 | 1115 | } |
| 1116 | - $this->_maybe_send_notifications( $payment ); |
|
| 1116 | + $this->_maybe_send_notifications($payment); |
|
| 1117 | 1117 | //prepare to render page |
| 1118 | - $json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs ); |
|
| 1119 | - do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment ); |
|
| 1118 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
| 1119 | + do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment); |
|
| 1120 | 1120 | } else { |
| 1121 | 1121 | EE_Error::add_error( |
| 1122 | - __( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ), |
|
| 1122 | + __('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
| 1123 | 1123 | __FILE__, __FUNCTION__, __LINE__ |
| 1124 | 1124 | ); |
| 1125 | 1125 | } |
| 1126 | 1126 | } else { |
| 1127 | - EE_Error::add_error( __( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1127 | + EE_Error::add_error(__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | - $notices = EE_Error::get_notices( false, false, false ); |
|
| 1130 | + $notices = EE_Error::get_notices(false, false, false); |
|
| 1131 | 1131 | $this->_template_args = array( |
| 1132 | 1132 | 'data' => $json_response_data, |
| 1133 | 1133 | 'error' => $notices['errors'], |
@@ -1144,30 +1144,30 @@ discard block |
||
| 1144 | 1144 | * @return array |
| 1145 | 1145 | */ |
| 1146 | 1146 | protected function _validate_payment_request_data() { |
| 1147 | - if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) { |
|
| 1147 | + if ( ! isset($this->_req_data['txn_admin_payment'])) { |
|
| 1148 | 1148 | return false; |
| 1149 | 1149 | } |
| 1150 | 1150 | $payment_form = $this->_generate_payment_form_section(); |
| 1151 | 1151 | try { |
| 1152 | - if ( $payment_form->was_submitted() ) { |
|
| 1152 | + if ($payment_form->was_submitted()) { |
|
| 1153 | 1153 | $payment_form->receive_form_submission(); |
| 1154 | - if ( ! $payment_form->is_valid() ) { |
|
| 1154 | + if ( ! $payment_form->is_valid()) { |
|
| 1155 | 1155 | $submission_error_messages = array(); |
| 1156 | - foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) { |
|
| 1157 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
| 1156 | + foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
| 1157 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 1158 | 1158 | $submission_error_messages[] = sprintf( |
| 1159 | - _x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ), |
|
| 1159 | + _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
| 1160 | 1160 | $validation_error->get_form_section()->html_label_text(), |
| 1161 | 1161 | $validation_error->getMessage() |
| 1162 | 1162 | ); |
| 1163 | 1163 | } |
| 1164 | 1164 | } |
| 1165 | - EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1165 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
| 1166 | 1166 | return array(); |
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | - } catch ( EE_Error $e ) { |
|
| 1170 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1169 | + } catch (EE_Error $e) { |
|
| 1170 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1171 | 1171 | return array(); |
| 1172 | 1172 | } |
| 1173 | 1173 | return $payment_form->valid_data(); |
@@ -1189,63 +1189,63 @@ discard block |
||
| 1189 | 1189 | array( |
| 1190 | 1190 | 'default' => 0, |
| 1191 | 1191 | 'required' => false, |
| 1192 | - 'html_label_text' => __( 'Payment ID', 'event_espresso' ), |
|
| 1193 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
| 1192 | + 'html_label_text' => __('Payment ID', 'event_espresso'), |
|
| 1193 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
| 1194 | 1194 | ) |
| 1195 | 1195 | ), |
| 1196 | 1196 | 'TXN_ID' => new EE_Text_Input( |
| 1197 | 1197 | array( |
| 1198 | 1198 | 'default' => 0, |
| 1199 | 1199 | 'required' => true, |
| 1200 | - 'html_label_text' => __( 'Transaction ID', 'event_espresso' ), |
|
| 1201 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
| 1200 | + 'html_label_text' => __('Transaction ID', 'event_espresso'), |
|
| 1201 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
| 1202 | 1202 | ) |
| 1203 | 1203 | ), |
| 1204 | 1204 | 'type' => new EE_Text_Input( |
| 1205 | 1205 | array( |
| 1206 | 1206 | 'default' => 1, |
| 1207 | 1207 | 'required' => true, |
| 1208 | - 'html_label_text' => __( 'Payment or Refund', 'event_espresso' ), |
|
| 1209 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
| 1208 | + 'html_label_text' => __('Payment or Refund', 'event_espresso'), |
|
| 1209 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
| 1210 | 1210 | ) |
| 1211 | 1211 | ), |
| 1212 | 1212 | 'amount' => new EE_Text_Input( |
| 1213 | 1213 | array( |
| 1214 | 1214 | 'default' => 0, |
| 1215 | 1215 | 'required' => true, |
| 1216 | - 'html_label_text' => __( 'Payment amount', 'event_espresso' ), |
|
| 1217 | - 'validation_strategies' => array( new EE_Float_Normalization() ) |
|
| 1216 | + 'html_label_text' => __('Payment amount', 'event_espresso'), |
|
| 1217 | + 'validation_strategies' => array(new EE_Float_Normalization()) |
|
| 1218 | 1218 | ) |
| 1219 | 1219 | ), |
| 1220 | 1220 | 'status' => new EE_Text_Input( |
| 1221 | 1221 | array( |
| 1222 | 1222 | 'default' => EEM_Payment::status_id_approved, |
| 1223 | 1223 | 'required' => true, |
| 1224 | - 'html_label_text' => __( 'Payment status', 'event_espresso' ), |
|
| 1224 | + 'html_label_text' => __('Payment status', 'event_espresso'), |
|
| 1225 | 1225 | ) |
| 1226 | 1226 | ), |
| 1227 | 1227 | 'PMD_ID' => new EE_Text_Input( |
| 1228 | 1228 | array( |
| 1229 | 1229 | 'default' => 2, |
| 1230 | 1230 | 'required' => true, |
| 1231 | - 'html_label_text' => __( 'Payment Method', 'event_espresso' ), |
|
| 1232 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
| 1231 | + 'html_label_text' => __('Payment Method', 'event_espresso'), |
|
| 1232 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
| 1233 | 1233 | ) |
| 1234 | 1234 | ), |
| 1235 | 1235 | 'date' => new EE_Text_Input( |
| 1236 | 1236 | array( |
| 1237 | 1237 | 'default' => time(), |
| 1238 | 1238 | 'required' => true, |
| 1239 | - 'html_label_text' => __( 'Payment date', 'event_espresso' ), |
|
| 1239 | + 'html_label_text' => __('Payment date', 'event_espresso'), |
|
| 1240 | 1240 | ) |
| 1241 | 1241 | ), |
| 1242 | 1242 | 'txn_id_chq_nmbr' => new EE_Text_Input( |
| 1243 | 1243 | array( |
| 1244 | 1244 | 'default' => '', |
| 1245 | 1245 | 'required' => false, |
| 1246 | - 'html_label_text' => __( 'Transaction or Cheque Number', 'event_espresso' ), |
|
| 1246 | + 'html_label_text' => __('Transaction or Cheque Number', 'event_espresso'), |
|
| 1247 | 1247 | 'validation_strategies' => array( |
| 1248 | - new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ), |
|
| 1248 | + new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100), |
|
| 1249 | 1249 | ) |
| 1250 | 1250 | ) |
| 1251 | 1251 | ), |
@@ -1253,9 +1253,9 @@ discard block |
||
| 1253 | 1253 | array( |
| 1254 | 1254 | 'default' => '', |
| 1255 | 1255 | 'required' => false, |
| 1256 | - 'html_label_text' => __( 'Purchase Order Number', 'event_espresso' ), |
|
| 1256 | + 'html_label_text' => __('Purchase Order Number', 'event_espresso'), |
|
| 1257 | 1257 | 'validation_strategies' => array( |
| 1258 | - new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ), |
|
| 1258 | + new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100), |
|
| 1259 | 1259 | ) |
| 1260 | 1260 | ) |
| 1261 | 1261 | ), |
@@ -1263,9 +1263,9 @@ discard block |
||
| 1263 | 1263 | array( |
| 1264 | 1264 | 'default' => '', |
| 1265 | 1265 | 'required' => false, |
| 1266 | - 'html_label_text' => __( 'Extra Field for Accounting', 'event_espresso' ), |
|
| 1266 | + 'html_label_text' => __('Extra Field for Accounting', 'event_espresso'), |
|
| 1267 | 1267 | 'validation_strategies' => array( |
| 1268 | - new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ), |
|
| 1268 | + new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100), |
|
| 1269 | 1269 | ) |
| 1270 | 1270 | ) |
| 1271 | 1271 | ), |
@@ -1282,37 +1282,37 @@ discard block |
||
| 1282 | 1282 | * @param array $valid_data |
| 1283 | 1283 | * @return EE_Payment |
| 1284 | 1284 | */ |
| 1285 | - protected function _create_payment_from_request_data( $valid_data ) { |
|
| 1286 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
| 1285 | + protected function _create_payment_from_request_data($valid_data) { |
|
| 1286 | + $PAY_ID = $valid_data['PAY_ID']; |
|
| 1287 | 1287 | // get payment amount |
| 1288 | - $amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0; |
|
| 1288 | + $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
| 1289 | 1289 | // payments have a type value of 1 and refunds have a type value of -1 |
| 1290 | 1290 | // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
| 1291 | - $amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount; |
|
| 1291 | + $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
| 1292 | 1292 | // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
| 1293 | - $date = $valid_data['date'] ? preg_replace( '/\s+/', ' ', $valid_data['date'] ) : date( 'Y-m-d g:i a', current_time( 'timestamp' ) ); |
|
| 1293 | + $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', current_time('timestamp')); |
|
| 1294 | 1294 | $payment = EE_Payment::new_instance( |
| 1295 | 1295 | array( |
| 1296 | - 'TXN_ID' => $valid_data[ 'TXN_ID' ], |
|
| 1297 | - 'STS_ID' => $valid_data[ 'status' ], |
|
| 1296 | + 'TXN_ID' => $valid_data['TXN_ID'], |
|
| 1297 | + 'STS_ID' => $valid_data['status'], |
|
| 1298 | 1298 | 'PAY_timestamp' => $date, |
| 1299 | 1299 | 'PAY_source' => EEM_Payment_Method::scope_admin, |
| 1300 | - 'PMD_ID' => $valid_data[ 'PMD_ID' ], |
|
| 1300 | + 'PMD_ID' => $valid_data['PMD_ID'], |
|
| 1301 | 1301 | 'PAY_amount' => $amount, |
| 1302 | - 'PAY_txn_id_chq_nmbr' => $valid_data[ 'txn_id_chq_nmbr' ], |
|
| 1303 | - 'PAY_po_number' => $valid_data[ 'po_number' ], |
|
| 1304 | - 'PAY_extra_accntng' => $valid_data[ 'accounting' ], |
|
| 1302 | + 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
| 1303 | + 'PAY_po_number' => $valid_data['po_number'], |
|
| 1304 | + 'PAY_extra_accntng' => $valid_data['accounting'], |
|
| 1305 | 1305 | 'PAY_details' => $valid_data, |
| 1306 | 1306 | 'PAY_ID' => $PAY_ID |
| 1307 | 1307 | ), |
| 1308 | 1308 | '', |
| 1309 | - array( 'Y-m-d', 'g:i a' ) |
|
| 1309 | + array('Y-m-d', 'g:i a') |
|
| 1310 | 1310 | ); |
| 1311 | 1311 | |
| 1312 | - if ( ! $payment->save() ) { |
|
| 1312 | + if ( ! $payment->save()) { |
|
| 1313 | 1313 | EE_Error::add_error( |
| 1314 | 1314 | sprintf( |
| 1315 | - __( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ), |
|
| 1315 | + __('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
| 1316 | 1316 | $payment->ID() |
| 1317 | 1317 | ), |
| 1318 | 1318 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1329,15 +1329,15 @@ discard block |
||
| 1329 | 1329 | * @param \EE_Transaction $transaction |
| 1330 | 1330 | * @return array |
| 1331 | 1331 | */ |
| 1332 | - protected function _process_transaction_payments( EE_Transaction $transaction ) { |
|
| 1332 | + protected function _process_transaction_payments(EE_Transaction $transaction) { |
|
| 1333 | 1333 | /** @type EE_Transaction_Payments $transaction_payments */ |
| 1334 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
| 1334 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1335 | 1335 | //update the transaction with this payment |
| 1336 | - if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) { |
|
| 1337 | - EE_Error::add_success( __( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1336 | + if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
| 1337 | + EE_Error::add_success(__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1338 | 1338 | } else { |
| 1339 | 1339 | EE_Error::add_error( |
| 1340 | - __( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' ) |
|
| 1340 | + __('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso') |
|
| 1341 | 1341 | , __FILE__, __FUNCTION__, __LINE__ |
| 1342 | 1342 | ); |
| 1343 | 1343 | } |
@@ -1353,19 +1353,19 @@ discard block |
||
| 1353 | 1353 | * @param \EE_Payment $payment |
| 1354 | 1354 | * @return array |
| 1355 | 1355 | */ |
| 1356 | - protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) { |
|
| 1356 | + protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) { |
|
| 1357 | 1357 | $REG_IDs = array(); |
| 1358 | 1358 | // grab array of IDs for specific registrations to apply changes to |
| 1359 | - if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) { |
|
| 1360 | - $REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ]; |
|
| 1359 | + if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
| 1360 | + $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations']; |
|
| 1361 | 1361 | } |
| 1362 | 1362 | //nothing specified ? then get all reg IDs |
| 1363 | - if ( empty( $REG_IDs ) ) { |
|
| 1363 | + if (empty($REG_IDs)) { |
|
| 1364 | 1364 | $registrations = $payment->transaction()->registrations(); |
| 1365 | - $REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
| 1365 | + $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1366 | 1366 | } |
| 1367 | 1367 | // ensure that REG_IDs are integers and NOT strings |
| 1368 | - return array_map( 'intval', $REG_IDs ); |
|
| 1368 | + return array_map('intval', $REG_IDs); |
|
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | 1371 | |
@@ -1382,7 +1382,7 @@ discard block |
||
| 1382 | 1382 | /** |
| 1383 | 1383 | * @param array $existing_reg_payment_REG_IDs |
| 1384 | 1384 | */ |
| 1385 | - public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) { |
|
| 1385 | + public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) { |
|
| 1386 | 1386 | $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
| 1387 | 1387 | } |
| 1388 | 1388 | |
@@ -1397,13 +1397,13 @@ discard block |
||
| 1397 | 1397 | * @param \EE_Payment $payment |
| 1398 | 1398 | * @return array |
| 1399 | 1399 | */ |
| 1400 | - protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) { |
|
| 1401 | - if ( $this->existing_reg_payment_REG_IDs() === null ) { |
|
| 1400 | + protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) { |
|
| 1401 | + if ($this->existing_reg_payment_REG_IDs() === null) { |
|
| 1402 | 1402 | // let's get any existing reg payment records for this payment |
| 1403 | - $existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' ); |
|
| 1403 | + $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
| 1404 | 1404 | // but we only want the REG IDs, so grab the array keys |
| 1405 | - $existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array(); |
|
| 1406 | - $this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs ); |
|
| 1405 | + $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
| 1406 | + $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
| 1407 | 1407 | } |
| 1408 | 1408 | return $this->existing_reg_payment_REG_IDs(); |
| 1409 | 1409 | } |
@@ -1422,23 +1422,23 @@ discard block |
||
| 1422 | 1422 | * @param int $PAY_ID |
| 1423 | 1423 | * @return bool; |
| 1424 | 1424 | */ |
| 1425 | - protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) { |
|
| 1425 | + protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) { |
|
| 1426 | 1426 | // newly created payments will have nothing recorded for $PAY_ID |
| 1427 | - if ( $PAY_ID == 0 ) { |
|
| 1427 | + if ($PAY_ID == 0) { |
|
| 1428 | 1428 | return false; |
| 1429 | 1429 | } |
| 1430 | - $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
| 1431 | - if ( empty( $existing_reg_payment_REG_IDs )) { |
|
| 1430 | + $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1431 | + if (empty($existing_reg_payment_REG_IDs)) { |
|
| 1432 | 1432 | return false; |
| 1433 | 1433 | } |
| 1434 | 1434 | /** @type EE_Transaction_Payments $transaction_payments */ |
| 1435 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
| 1435 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1436 | 1436 | return $transaction_payments->delete_registration_payments_and_update_registrations( |
| 1437 | 1437 | $payment, |
| 1438 | 1438 | array( |
| 1439 | 1439 | array( |
| 1440 | 1440 | 'PAY_ID' => $payment->ID(), |
| 1441 | - 'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ), |
|
| 1441 | + 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
| 1442 | 1442 | ) |
| 1443 | 1443 | ) |
| 1444 | 1444 | ); |
@@ -1457,25 +1457,25 @@ discard block |
||
| 1457 | 1457 | * @param array $REG_IDs |
| 1458 | 1458 | * @return bool |
| 1459 | 1459 | */ |
| 1460 | - protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) { |
|
| 1460 | + protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) { |
|
| 1461 | 1461 | // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
| 1462 | 1462 | // so let's do that using our set of REG_IDs from the form |
| 1463 | 1463 | $registration_query_where_params = array( |
| 1464 | - 'REG_ID' => array( 'IN', $REG_IDs ) |
|
| 1464 | + 'REG_ID' => array('IN', $REG_IDs) |
|
| 1465 | 1465 | ); |
| 1466 | 1466 | // but add in some conditions regarding payment, |
| 1467 | 1467 | // so that we don't apply payments to registrations that are free or have already been paid for |
| 1468 | 1468 | // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
| 1469 | - if ( ! $payment->is_a_refund() ) { |
|
| 1470 | - $registration_query_where_params[ 'REG_final_price' ] = array( '!=', 0 ); |
|
| 1471 | - $registration_query_where_params[ 'REG_final_price*' ] = array( '!=', 'REG_paid', true ); |
|
| 1469 | + if ( ! $payment->is_a_refund()) { |
|
| 1470 | + $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
| 1471 | + $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
| 1474 | - $registrations = $transaction->registrations( array( $registration_query_where_params ) ); |
|
| 1475 | - if ( ! empty( $registrations ) ) { |
|
| 1474 | + $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
| 1475 | + if ( ! empty($registrations)) { |
|
| 1476 | 1476 | /** @type EE_Payment_Processor $payment_processor */ |
| 1477 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
| 1478 | - $payment_processor->process_registration_payments( $transaction, $payment, $registrations ); |
|
| 1477 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
| 1478 | + $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
| 1479 | 1479 | } |
| 1480 | 1480 | } |
| 1481 | 1481 | |
@@ -1491,22 +1491,22 @@ discard block |
||
| 1491 | 1491 | * @param array $REG_IDs |
| 1492 | 1492 | * @return bool |
| 1493 | 1493 | */ |
| 1494 | - protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) { |
|
| 1494 | + protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) { |
|
| 1495 | 1495 | // first if there is no change in status then we get out. |
| 1496 | 1496 | if ( |
| 1497 | - ! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ) |
|
| 1497 | + ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
| 1498 | 1498 | || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
| 1499 | 1499 | ) { |
| 1500 | 1500 | //no error message, no change requested, just nothing to do man. |
| 1501 | 1501 | return FALSE; |
| 1502 | 1502 | } |
| 1503 | 1503 | /** @type EE_Transaction_Processor $transaction_processor */ |
| 1504 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
| 1504 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 1505 | 1505 | // made it here dude? Oh WOW. K, let's take care of changing the statuses |
| 1506 | 1506 | return $transaction_processor->manually_update_registration_statuses( |
| 1507 | 1507 | $transaction, |
| 1508 | - sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ), |
|
| 1509 | - array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) |
|
| 1508 | + sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
| 1509 | + array(array('REG_ID' => array('IN', $REG_IDs))) |
|
| 1510 | 1510 | ); |
| 1511 | 1511 | } |
| 1512 | 1512 | |
@@ -1521,16 +1521,16 @@ discard block |
||
| 1521 | 1521 | * @param bool | null $delete_txn_reg_status_change |
| 1522 | 1522 | * @return array |
| 1523 | 1523 | */ |
| 1524 | - protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) { |
|
| 1524 | + protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) { |
|
| 1525 | 1525 | // was the payment deleted ? |
| 1526 | - if ( is_bool( $delete_txn_reg_status_change )) { |
|
| 1526 | + if (is_bool($delete_txn_reg_status_change)) { |
|
| 1527 | 1527 | return array( |
| 1528 | 1528 | 'PAY_ID' => $payment->ID(), |
| 1529 | 1529 | 'amount' => $payment->amount(), |
| 1530 | 1530 | 'total_paid' => $payment->transaction()->paid(), |
| 1531 | 1531 | 'txn_status' => $payment->transaction()->status_ID(), |
| 1532 | 1532 | 'pay_status' => $payment->STS_ID(), |
| 1533 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
| 1533 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
| 1534 | 1534 | 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
| 1535 | 1535 | ); |
| 1536 | 1536 | } else { |
@@ -1542,16 +1542,16 @@ discard block |
||
| 1542 | 1542 | 'pay_status' => $payment->STS_ID(), |
| 1543 | 1543 | 'PAY_ID' => $payment->ID(), |
| 1544 | 1544 | 'STS_ID' => $payment->STS_ID(), |
| 1545 | - 'status' => self::$_pay_status[ $payment->STS_ID() ], |
|
| 1546 | - 'date' => $payment->timestamp( 'Y-m-d', 'h:i a' ), |
|
| 1547 | - 'method' => strtoupper( $payment->source() ), |
|
| 1545 | + 'status' => self::$_pay_status[$payment->STS_ID()], |
|
| 1546 | + 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
| 1547 | + 'method' => strtoupper($payment->source()), |
|
| 1548 | 1548 | 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
| 1549 | - 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : __( "Unknown", 'event_espresso' ), |
|
| 1549 | + 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'), |
|
| 1550 | 1550 | 'gateway_response' => $payment->gateway_response(), |
| 1551 | 1551 | 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
| 1552 | 1552 | 'po_number' => $payment->po_number(), |
| 1553 | 1553 | 'extra_accntng' => $payment->extra_accntng(), |
| 1554 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
| 1554 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
| 1555 | 1555 | ); |
| 1556 | 1556 | } |
| 1557 | 1557 | } |
@@ -1566,39 +1566,39 @@ discard block |
||
| 1566 | 1566 | * @return void |
| 1567 | 1567 | */ |
| 1568 | 1568 | public function delete_payment() { |
| 1569 | - $json_response_data = array( 'return_data' => FALSE ); |
|
| 1570 | - $PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0; |
|
| 1571 | - if ( $PAY_ID ) { |
|
| 1572 | - $delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false; |
|
| 1573 | - $payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID ); |
|
| 1574 | - if ( $payment instanceof EE_Payment ) { |
|
| 1575 | - $REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
| 1569 | + $json_response_data = array('return_data' => FALSE); |
|
| 1570 | + $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
| 1571 | + if ($PAY_ID) { |
|
| 1572 | + $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
| 1573 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
| 1574 | + if ($payment instanceof EE_Payment) { |
|
| 1575 | + $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
| 1576 | 1576 | /** @type EE_Transaction_Payments $transaction_payments */ |
| 1577 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
| 1578 | - if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) { |
|
| 1579 | - $json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change ); |
|
| 1580 | - if ( $delete_txn_reg_status_change ) { |
|
| 1577 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 1578 | + if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
| 1579 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change); |
|
| 1580 | + if ($delete_txn_reg_status_change) { |
|
| 1581 | 1581 | $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
| 1582 | 1582 | //MAKE sure we also add the delete_txn_req_status_change to the |
| 1583 | 1583 | //$_REQUEST global because that's how messages will be looking for it. |
| 1584 | 1584 | $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
| 1585 | 1585 | $this->_maybe_send_notifications(); |
| 1586 | - $this->_process_registration_status_change( $payment->transaction(), $REG_IDs ); |
|
| 1586 | + $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
| 1587 | 1587 | } |
| 1588 | 1588 | } |
| 1589 | 1589 | } else { |
| 1590 | 1590 | EE_Error::add_error( |
| 1591 | - __( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ), |
|
| 1591 | + __('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
| 1592 | 1592 | __FILE__, __FUNCTION__, __LINE__ |
| 1593 | 1593 | ); |
| 1594 | 1594 | } |
| 1595 | 1595 | } else { |
| 1596 | 1596 | EE_Error::add_error( |
| 1597 | - __( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ), |
|
| 1597 | + __('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'), |
|
| 1598 | 1598 | __FILE__, __FUNCTION__, __LINE__ |
| 1599 | 1599 | ); |
| 1600 | 1600 | } |
| 1601 | - $notices = EE_Error::get_notices( false, false, false); |
|
| 1601 | + $notices = EE_Error::get_notices(false, false, false); |
|
| 1602 | 1602 | $this->_template_args = array( |
| 1603 | 1603 | 'data' => $json_response_data, |
| 1604 | 1604 | 'success' => $notices['success'], |
@@ -1618,17 +1618,17 @@ discard block |
||
| 1618 | 1618 | * @param array $REG_IDs |
| 1619 | 1619 | * @return array |
| 1620 | 1620 | */ |
| 1621 | - protected function _registration_payment_data_array( $REG_IDs ) { |
|
| 1621 | + protected function _registration_payment_data_array($REG_IDs) { |
|
| 1622 | 1622 | $registration_payment_data = array(); |
| 1623 | 1623 | //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
| 1624 | - if ( ! empty( $REG_IDs ) ) { |
|
| 1625 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
| 1626 | - $registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) ); |
|
| 1627 | - foreach ( $registrations as $registration ) { |
|
| 1628 | - if ( $registration instanceof EE_Registration ) { |
|
| 1629 | - $registration_payment_data[ $registration->ID() ] = array( |
|
| 1624 | + if ( ! empty($REG_IDs)) { |
|
| 1625 | + EE_Registry::instance()->load_helper('Template'); |
|
| 1626 | + $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
| 1627 | + foreach ($registrations as $registration) { |
|
| 1628 | + if ($registration instanceof EE_Registration) { |
|
| 1629 | + $registration_payment_data[$registration->ID()] = array( |
|
| 1630 | 1630 | 'paid' => $registration->pretty_paid(), |
| 1631 | - 'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ), |
|
| 1631 | + 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
| 1632 | 1632 | ); |
| 1633 | 1633 | } |
| 1634 | 1634 | } |
@@ -1648,30 +1648,30 @@ discard block |
||
| 1648 | 1648 | * @access protected |
| 1649 | 1649 | * @param \EE_Payment | null $payment |
| 1650 | 1650 | */ |
| 1651 | - protected function _maybe_send_notifications( $payment = null ) { |
|
| 1652 | - switch ( $payment instanceof EE_Payment ) { |
|
| 1651 | + protected function _maybe_send_notifications($payment = null) { |
|
| 1652 | + switch ($payment instanceof EE_Payment) { |
|
| 1653 | 1653 | // payment notifications |
| 1654 | 1654 | case true : |
| 1655 | 1655 | if ( |
| 1656 | 1656 | isset( |
| 1657 | - $this->_req_data[ 'txn_payments' ], |
|
| 1658 | - $this->_req_data[ 'txn_payments' ][ 'send_notifications' ] |
|
| 1657 | + $this->_req_data['txn_payments'], |
|
| 1658 | + $this->_req_data['txn_payments']['send_notifications'] |
|
| 1659 | 1659 | ) && |
| 1660 | - filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
| 1660 | + filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
| 1661 | 1661 | ) { |
| 1662 | - $this->_process_payment_notification( $payment ); |
|
| 1662 | + $this->_process_payment_notification($payment); |
|
| 1663 | 1663 | } |
| 1664 | 1664 | break; |
| 1665 | 1665 | // registration notifications |
| 1666 | 1666 | case false : |
| 1667 | 1667 | if ( |
| 1668 | 1668 | isset( |
| 1669 | - $this->_req_data[ 'txn_reg_status_change' ], |
|
| 1670 | - $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] |
|
| 1669 | + $this->_req_data['txn_reg_status_change'], |
|
| 1670 | + $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
| 1671 | 1671 | ) && |
| 1672 | - filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
| 1672 | + filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
| 1673 | 1673 | ) { |
| 1674 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
| 1674 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
| 1675 | 1675 | } |
| 1676 | 1676 | break; |
| 1677 | 1677 | } |
@@ -1687,11 +1687,11 @@ discard block |
||
| 1687 | 1687 | * @return void |
| 1688 | 1688 | */ |
| 1689 | 1689 | protected function _send_payment_reminder() { |
| 1690 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
| 1691 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
| 1692 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array(); |
|
| 1693 | - do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction ); |
|
| 1694 | - $this->_redirect_after_action( FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE ); |
|
| 1690 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
| 1691 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
| 1692 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array(); |
|
| 1693 | + do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction); |
|
| 1694 | + $this->_redirect_after_action(FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE); |
|
| 1695 | 1695 | } |
| 1696 | 1696 | |
| 1697 | 1697 | |
@@ -1705,36 +1705,36 @@ discard block |
||
| 1705 | 1705 | * @param string $view |
| 1706 | 1706 | * @return mixed int = count || array of transaction objects |
| 1707 | 1707 | */ |
| 1708 | - public function get_transactions( $perpage, $count = FALSE, $view = '' ) { |
|
| 1708 | + public function get_transactions($perpage, $count = FALSE, $view = '') { |
|
| 1709 | 1709 | |
| 1710 | 1710 | $TXN = EEM_Transaction::instance(); |
| 1711 | 1711 | |
| 1712 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
| 1713 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' ); |
|
| 1712 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
| 1713 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
| 1714 | 1714 | |
| 1715 | 1715 | //make sure our timestamps start and end right at the boundaries for each day |
| 1716 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
| 1717 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
| 1716 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
| 1717 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
| 1718 | 1718 | |
| 1719 | 1719 | |
| 1720 | 1720 | //convert to timestamps |
| 1721 | - $start_date = strtotime( $start_date ); |
|
| 1722 | - $end_date = strtotime( $end_date ); |
|
| 1721 | + $start_date = strtotime($start_date); |
|
| 1722 | + $end_date = strtotime($end_date); |
|
| 1723 | 1723 | |
| 1724 | 1724 | //makes sure start date is the lowest value and vice versa |
| 1725 | - $start_date = min( $start_date, $end_date ); |
|
| 1726 | - $end_date = max( $start_date, $end_date ); |
|
| 1725 | + $start_date = min($start_date, $end_date); |
|
| 1726 | + $end_date = max($start_date, $end_date); |
|
| 1727 | 1727 | |
| 1728 | 1728 | //convert to correct format for query |
| 1729 | - $start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
| 1730 | - $end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
| 1729 | + $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
| 1730 | + $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
| 1731 | 1731 | |
| 1732 | 1732 | |
| 1733 | 1733 | |
| 1734 | 1734 | //set orderby |
| 1735 | 1735 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
| 1736 | 1736 | |
| 1737 | - switch ( $this->_req_data['orderby'] ) { |
|
| 1737 | + switch ($this->_req_data['orderby']) { |
|
| 1738 | 1738 | case 'TXN_ID': |
| 1739 | 1739 | $orderby = 'TXN_ID'; |
| 1740 | 1740 | break; |
@@ -1748,66 +1748,66 @@ discard block |
||
| 1748 | 1748 | $orderby = 'TXN_timestamp'; |
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
| 1752 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
| 1753 | - $per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10; |
|
| 1754 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
| 1751 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
| 1752 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 1753 | + $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
| 1754 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 1755 | 1755 | |
| 1756 | - $offset = ($current_page-1)*$per_page; |
|
| 1757 | - $limit = array( $offset, $per_page ); |
|
| 1756 | + $offset = ($current_page - 1) * $per_page; |
|
| 1757 | + $limit = array($offset, $per_page); |
|
| 1758 | 1758 | |
| 1759 | 1759 | $_where = array( |
| 1760 | - 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ), |
|
| 1760 | + 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
| 1761 | 1761 | 'Registration.REG_count' => 1 |
| 1762 | 1762 | ); |
| 1763 | 1763 | |
| 1764 | - if ( isset( $this->_req_data['EVT_ID'] ) ) { |
|
| 1764 | + if (isset($this->_req_data['EVT_ID'])) { |
|
| 1765 | 1765 | $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | - if ( isset( $this->_req_data['s'] ) ) { |
|
| 1769 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1768 | + if (isset($this->_req_data['s'])) { |
|
| 1769 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
| 1770 | 1770 | $_where['OR'] = array( |
| 1771 | - 'Registration.Event.EVT_name' => array( 'LIKE', $search_string ), |
|
| 1772 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ), |
|
| 1773 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ), |
|
| 1774 | - 'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ), |
|
| 1775 | - 'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ), |
|
| 1776 | - 'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ), |
|
| 1777 | - 'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ), |
|
| 1778 | - 'Registration.Attendee.ATT_email' => array('LIKE', $search_string ), |
|
| 1779 | - 'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ), |
|
| 1780 | - 'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ), |
|
| 1781 | - 'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ), |
|
| 1782 | - 'Registration.REG_final_price' => array( 'LIKE', $search_string ), |
|
| 1783 | - 'Registration.REG_code' => array( 'LIKE', $search_string ), |
|
| 1784 | - 'Registration.REG_count' => array( 'LIKE' , $search_string ), |
|
| 1785 | - 'Registration.REG_group_size' => array( 'LIKE' , $search_string ), |
|
| 1786 | - 'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ), |
|
| 1787 | - 'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ), |
|
| 1788 | - 'Payment.PAY_source' => array('LIKE', $search_string ), |
|
| 1789 | - 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ), |
|
| 1790 | - 'TXN_session_data' => array( 'LIKE', $search_string ), |
|
| 1791 | - 'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string ) |
|
| 1771 | + 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
| 1772 | + 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
| 1773 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
| 1774 | + 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
| 1775 | + 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
| 1776 | + 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
| 1777 | + 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
| 1778 | + 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
| 1779 | + 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
| 1780 | + 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
| 1781 | + 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
| 1782 | + 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
| 1783 | + 'Registration.REG_code' => array('LIKE', $search_string), |
|
| 1784 | + 'Registration.REG_count' => array('LIKE', $search_string), |
|
| 1785 | + 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
| 1786 | + 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
| 1787 | + 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
| 1788 | + 'Payment.PAY_source' => array('LIKE', $search_string), |
|
| 1789 | + 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
| 1790 | + 'TXN_session_data' => array('LIKE', $search_string), |
|
| 1791 | + 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string) |
|
| 1792 | 1792 | ); |
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | 1795 | //failed transactions |
| 1796 | - $failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE; |
|
| 1797 | - $abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE; |
|
| 1796 | + $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE; |
|
| 1797 | + $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE; |
|
| 1798 | 1798 | |
| 1799 | - if ( $failed ) { |
|
| 1800 | - $_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code; |
|
| 1801 | - } else if ( $abandoned ) { |
|
| 1799 | + if ($failed) { |
|
| 1800 | + $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
| 1801 | + } else if ($abandoned) { |
|
| 1802 | 1802 | $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
| 1803 | 1803 | } else { |
| 1804 | - $_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code ); |
|
| 1805 | - $_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code ); |
|
| 1804 | + $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
| 1805 | + $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit ); |
|
| 1808 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit); |
|
| 1809 | 1809 | |
| 1810 | - $transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params); |
|
| 1810 | + $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params); |
|
| 1811 | 1811 | |
| 1812 | 1812 | |
| 1813 | 1813 | return $transactions; |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
| 2 | 2 | // if you're a dev and want to receive all errors via email add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
| 3 | -if ( defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE && defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS === TRUE ) { |
|
| 4 | - set_error_handler( array( 'EE_Error', 'error_handler' )); |
|
| 5 | - register_shutdown_function( array( 'EE_Error', 'fatal_error_handler' )); |
|
| 3 | +if (defined('WP_DEBUG') && WP_DEBUG === TRUE && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === TRUE) { |
|
| 4 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
| 5 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
| 6 | 6 | } |
| 7 | 7 | /** |
| 8 | 8 | * |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @access private |
| 65 | 65 | * @var boolean |
| 66 | 66 | */ |
| 67 | - private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE ); |
|
| 67 | + private static $_espresso_notices = array('success' => FALSE, 'errors' => FALSE, 'attention' => FALSE); |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | * @access public |
| 76 | 76 | * @echo string |
| 77 | 77 | */ |
| 78 | - function __construct( $message, $code = 0, Exception $previous = NULL ) { |
|
| 79 | - if ( version_compare( phpversion(), '5.3.0', '<' )) { |
|
| 80 | - parent::__construct( $message, $code ); |
|
| 78 | + function __construct($message, $code = 0, Exception $previous = NULL) { |
|
| 79 | + if (version_compare(phpversion(), '5.3.0', '<')) { |
|
| 80 | + parent::__construct($message, $code); |
|
| 81 | 81 | } else { |
| 82 | - parent::__construct( $message, $code, $previous ); |
|
| 82 | + parent::__construct($message, $code, $previous); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | * @param $line |
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | - public static function error_handler( $code, $message, $file, $line ) { |
|
| 98 | - $type = EE_Error::error_type( $code ); |
|
| 97 | + public static function error_handler($code, $message, $file, $line) { |
|
| 98 | + $type = EE_Error::error_type($code); |
|
| 99 | 99 | $site = site_url(); |
| 100 | - switch ( $site ) { |
|
| 100 | + switch ($site) { |
|
| 101 | 101 | case 'http://ee4.eventespresso.com/' : |
| 102 | 102 | case 'http://ee4decaf.eventespresso.com/' : |
| 103 | 103 | case 'http://ee4hf.eventespresso.com/' : |
@@ -110,16 +110,16 @@ discard block |
||
| 110 | 110 | $to = '[email protected]'; |
| 111 | 111 | break; |
| 112 | 112 | default : |
| 113 | - $to = get_option( 'admin_email' ); |
|
| 113 | + $to = get_option('admin_email'); |
|
| 114 | 114 | } |
| 115 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
| 116 | - $msg = EE_Error::_format_error( $type, $message, $file, $line ); |
|
| 117 | - if ( function_exists( 'wp_mail' )) { |
|
| 118 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
| 119 | - wp_mail( $to, $subject, $msg ); |
|
| 115 | + $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url(); |
|
| 116 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
| 117 | + if (function_exists('wp_mail')) { |
|
| 118 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
| 119 | + wp_mail($to, $subject, $msg); |
|
| 120 | 120 | } |
| 121 | 121 | echo '<div id="message" class="espresso-notices error"><p>'; |
| 122 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
| 122 | + echo $type.': '.$message.'<br />'.$file.' line '.$line; |
|
| 123 | 123 | echo '<br /></p></div>'; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | * @param $code |
| 133 | 133 | * @return string |
| 134 | 134 | */ |
| 135 | - public static function error_type( $code ) { |
|
| 136 | - switch( $code ) { |
|
| 135 | + public static function error_type($code) { |
|
| 136 | + switch ($code) { |
|
| 137 | 137 | case E_ERROR: // 1 // |
| 138 | 138 | return 'E_ERROR'; |
| 139 | 139 | case E_WARNING: // 2 // |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public static function fatal_error_handler() { |
| 181 | 181 | $last_error = error_get_last(); |
| 182 | - if ( $last_error['type'] === E_ERROR ) { |
|
| 183 | - EE_Error::error_handler( E_ERROR, $last_error['message'], $last_error['file'], $last_error['line'] ); |
|
| 182 | + if ($last_error['type'] === E_ERROR) { |
|
| 183 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param $line |
| 196 | 196 | * @return string |
| 197 | 197 | */ |
| 198 | - private static function _format_error( $code, $message, $file, $line ) { |
|
| 198 | + private static function _format_error($code, $message, $file, $line) { |
|
| 199 | 199 | $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
| 200 | 200 | $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
| 201 | 201 | $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @param $content_type |
| 214 | 214 | * @return string |
| 215 | 215 | */ |
| 216 | - public static function set_content_type( $content_type ) { |
|
| 216 | + public static function set_content_type($content_type) { |
|
| 217 | 217 | return 'text/html'; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public function get_error() { |
| 229 | 229 | |
| 230 | - if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){ |
|
| 230 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', FALSE)) { |
|
| 231 | 231 | throw $this; |
| 232 | 232 | } |
| 233 | 233 | // get separate user and developer messages if they exist |
| 234 | - $msg = explode( '||', $this->getMessage() ); |
|
| 234 | + $msg = explode('||', $this->getMessage()); |
|
| 235 | 235 | $user_msg = $msg[0]; |
| 236 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
| 236 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
| 237 | 237 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
| 238 | 238 | |
| 239 | 239 | // add details to _all_exceptions array |
| 240 | 240 | $x_time = time(); |
| 241 | - self::$_all_exceptions[ $x_time ]['name'] = get_class( $this ); |
|
| 242 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
| 243 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
| 244 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
| 245 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
| 246 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
| 247 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
| 241 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
| 242 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
| 243 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
| 244 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
| 245 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
| 246 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
| 247 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
| 248 | 248 | self::$_error_count++; |
| 249 | 249 | |
| 250 | 250 | //add_action( 'shutdown', array( $this, 'display_errors' )); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @access public |
| 260 | 260 | * @return boolean |
| 261 | 261 | */ |
| 262 | - public static function has_error(){ |
|
| 262 | + public static function has_error() { |
|
| 263 | 263 | return self::$_error_count ? TRUE : FALSE; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @access public |
| 271 | 271 | * @echo string |
| 272 | 272 | */ |
| 273 | - public function display_errors(){ |
|
| 273 | + public function display_errors() { |
|
| 274 | 274 | |
| 275 | 275 | $trace_details = ''; |
| 276 | 276 | |
@@ -331,18 +331,18 @@ discard block |
||
| 331 | 331 | </style> |
| 332 | 332 | <div id="ee-error-message" class="error">'; |
| 333 | 333 | |
| 334 | - if ( ! WP_DEBUG ) { |
|
| 334 | + if ( ! WP_DEBUG) { |
|
| 335 | 335 | $output .= ' |
| 336 | 336 | <p>'; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // cycle thru errors |
| 340 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
| 340 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
| 341 | 341 | |
| 342 | 342 | // process trace info |
| 343 | - if ( empty( $ex['trace'] )) { |
|
| 343 | + if (empty($ex['trace'])) { |
|
| 344 | 344 | |
| 345 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
| 345 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso'); |
|
| 346 | 346 | |
| 347 | 347 | } else { |
| 348 | 348 | |
@@ -357,50 +357,50 @@ discard block |
||
| 357 | 357 | <th scope="col" align="left">Method( arguments )</th> |
| 358 | 358 | </tr>'; |
| 359 | 359 | |
| 360 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
| 360 | + $last_on_stack = count($ex['trace']) - 1; |
|
| 361 | 361 | // reverse array so that stack is in proper chronological order |
| 362 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
| 362 | + $sorted_trace = array_reverse($ex['trace']); |
|
| 363 | 363 | |
| 364 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
| 364 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
| 365 | 365 | |
| 366 | - $file = isset( $trace['file'] ) ? $trace['file'] : '' ; |
|
| 367 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
| 368 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
| 369 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
| 370 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
| 371 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
| 366 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
| 367 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
| 368 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
| 369 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
| 370 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
| 371 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
| 372 | 372 | $zebra = $nmbr % 2 ? ' odd' : ''; |
| 373 | 373 | |
| 374 | - if ( empty( $file ) && ! empty( $class )) { |
|
| 375 | - $a = new ReflectionClass( $class ); |
|
| 374 | + if (empty($file) && ! empty($class)) { |
|
| 375 | + $a = new ReflectionClass($class); |
|
| 376 | 376 | $file = $a->getFileName(); |
| 377 | - if ( empty( $line ) && ! empty( $function )) { |
|
| 378 | - $b = new ReflectionMethod( $class, $function ); |
|
| 377 | + if (empty($line) && ! empty($function)) { |
|
| 378 | + $b = new ReflectionMethod($class, $function); |
|
| 379 | 379 | $line = $b->getStartLine(); |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ( $nmbr == $last_on_stack ) { |
|
| 383 | + if ($nmbr == $last_on_stack) { |
|
| 384 | 384 | $file = $ex['file'] != '' ? $ex['file'] : $file; |
| 385 | 385 | $line = $ex['line'] != '' ? $ex['line'] : $line; |
| 386 | - $error_code = self::generate_error_code ( $file, $trace['function'], $line ); |
|
| 386 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - $nmbr_dsply = ! empty( $nmbr ) ? $nmbr : ' '; |
|
| 390 | - $line_dsply = ! empty( $line ) ? $line : ' '; |
|
| 391 | - $file_dsply = ! empty( $file ) ? $file : ' '; |
|
| 392 | - $class_dsply = ! empty( $class ) ? $class : ' '; |
|
| 393 | - $type_dsply = ! empty( $type ) ? $type : ' '; |
|
| 394 | - $function_dsply = ! empty( $function ) ? $function : ' '; |
|
| 395 | - $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
|
| 389 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
| 390 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
| 391 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
| 392 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
| 393 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
| 394 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
| 395 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
| 396 | 396 | |
| 397 | 397 | $trace_details .= ' |
| 398 | 398 | <tr> |
| 399 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
| 400 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
| 401 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
| 402 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
| 403 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
| 399 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
| 400 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
| 401 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
| 402 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
| 403 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
| 404 | 404 | </tr>'; |
| 405 | 405 | |
| 406 | 406 | |
@@ -415,9 +415,9 @@ discard block |
||
| 415 | 415 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
| 416 | 416 | |
| 417 | 417 | // add generic non-identifying messages for non-privileged uesrs |
| 418 | - if ( ! WP_DEBUG ) { |
|
| 418 | + if ( ! WP_DEBUG) { |
|
| 419 | 419 | |
| 420 | - $output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] ) . '</span> <sup>' . $ex['code'] . '</sup><br />'; |
|
| 420 | + $output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> <sup>'.$ex['code'].'</sup><br />'; |
|
| 421 | 421 | |
| 422 | 422 | } else { |
| 423 | 423 | |
@@ -425,24 +425,24 @@ discard block |
||
| 425 | 425 | $output .= ' |
| 426 | 426 | <div class="ee-error-dev-msg-dv"> |
| 427 | 427 | <p class="ee-error-dev-msg-pg"> |
| 428 | - <strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong> <span>code: ' . $ex['code'] . '</span><br /> |
|
| 429 | - <span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/> |
|
| 430 | - <a id="display-ee-error-trace-' . self::$_error_count . $time . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' . self::$_error_count . $time . '"> |
|
| 431 | - ' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . ' |
|
| 428 | + <strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong> <span>code: '.$ex['code'].'</span><br /> |
|
| 429 | + <span class="big-text">"' . trim($ex['msg']).'"</span><br/> |
|
| 430 | + <a id="display-ee-error-trace-' . self::$_error_count.$time.'" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'.self::$_error_count.$time.'"> |
|
| 431 | + ' . __('click to view backtrace and class/method details', 'event_espresso').' |
|
| 432 | 432 | </a><br /> |
| 433 | 433 | <span class="small-text lt-grey-text">'.$ex['file'].' ( line no: '.$ex['line'].' )</span> |
| 434 | 434 | </p> |
| 435 | - <div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
| 435 | + <div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;"> |
|
| 436 | 436 | ' . $trace_details; |
| 437 | 437 | |
| 438 | - if ( ! empty( $class )) { |
|
| 438 | + if ( ! empty($class)) { |
|
| 439 | 439 | $output .= ' |
| 440 | 440 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
| 441 | 441 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
| 442 | 442 | <h3>Class Details</h3>'; |
| 443 | - $a = new ReflectionClass( $class ); |
|
| 443 | + $a = new ReflectionClass($class); |
|
| 444 | 444 | $output .= ' |
| 445 | - <pre>' . $a . '</pre> |
|
| 445 | + <pre>' . $a.'</pre> |
|
| 446 | 446 | </div> |
| 447 | 447 | </div>'; |
| 448 | 448 | } |
@@ -454,14 +454,14 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $this->write_to_error_log( $time, $ex ); |
|
| 457 | + $this->write_to_error_log($time, $ex); |
|
| 458 | 458 | |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // remove last linebreak |
| 462 | - $output = substr( $output, 0, ( count( $output ) - 7 )); |
|
| 462 | + $output = substr($output, 0, (count($output) - 7)); |
|
| 463 | 463 | |
| 464 | - if ( ! WP_DEBUG ) { |
|
| 464 | + if ( ! WP_DEBUG) { |
|
| 465 | 465 | $output .= ' |
| 466 | 466 | </p>'; |
| 467 | 467 | } |
@@ -469,10 +469,10 @@ discard block |
||
| 469 | 469 | $output .= ' |
| 470 | 470 | </div>'; |
| 471 | 471 | |
| 472 | - $output .= self::_print_scripts( TRUE ); |
|
| 472 | + $output .= self::_print_scripts(TRUE); |
|
| 473 | 473 | |
| 474 | - if ( defined( 'DOING_AJAX' )) { |
|
| 475 | - echo json_encode( array( 'error' => $output )); |
|
| 474 | + if (defined('DOING_AJAX')) { |
|
| 475 | + echo json_encode(array('error' => $output)); |
|
| 476 | 476 | exit(); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -492,29 +492,29 @@ discard block |
||
| 492 | 492 | * @ param array $arguments |
| 493 | 493 | * @ return string |
| 494 | 494 | */ |
| 495 | - private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
|
| 495 | + private function _convert_args_to_string($arguments = array(), $array = FALSE) { |
|
| 496 | 496 | |
| 497 | 497 | $arg_string = ''; |
| 498 | - if ( ! empty( $arguments )) { |
|
| 498 | + if ( ! empty($arguments)) { |
|
| 499 | 499 | |
| 500 | 500 | $args = array(); |
| 501 | 501 | |
| 502 | - foreach ( $arguments as $arg ) { |
|
| 502 | + foreach ($arguments as $arg) { |
|
| 503 | 503 | |
| 504 | - if ( ! empty( $arg )) { |
|
| 504 | + if ( ! empty($arg)) { |
|
| 505 | 505 | |
| 506 | - if ( is_string( $arg )) { |
|
| 507 | - $args[] = " '" . $arg . "'"; |
|
| 508 | - } elseif ( is_array( $arg )) { |
|
| 509 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE ); |
|
| 510 | - } elseif ( is_null( $arg )) { |
|
| 506 | + if (is_string($arg)) { |
|
| 507 | + $args[] = " '".$arg."'"; |
|
| 508 | + } elseif (is_array($arg)) { |
|
| 509 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE); |
|
| 510 | + } elseif (is_null($arg)) { |
|
| 511 | 511 | $args[] = ' NULL'; |
| 512 | - } elseif ( is_bool( $arg )) { |
|
| 513 | - $args[] = ( $arg ) ? ' TRUE' : ' FALSE'; |
|
| 514 | - } elseif ( is_object( $arg )) { |
|
| 515 | - $args[] = ' OBJECT ' . get_class( $arg ); |
|
| 516 | - } elseif ( is_resource( $arg )) { |
|
| 517 | - $args[] = get_resource_type( $arg ); |
|
| 512 | + } elseif (is_bool($arg)) { |
|
| 513 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
| 514 | + } elseif (is_object($arg)) { |
|
| 515 | + $args[] = ' OBJECT '.get_class($arg); |
|
| 516 | + } elseif (is_resource($arg)) { |
|
| 517 | + $args[] = get_resource_type($arg); |
|
| 518 | 518 | } else { |
| 519 | 519 | $args[] = $arg; |
| 520 | 520 | } |
@@ -522,9 +522,9 @@ discard block |
||
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | } |
| 525 | - $arg_string = implode( ', ', $args ); |
|
| 525 | + $arg_string = implode(', ', $args); |
|
| 526 | 526 | } |
| 527 | - if ( $array ) { |
|
| 527 | + if ($array) { |
|
| 528 | 528 | $arg_string .= ' )'; |
| 529 | 529 | } |
| 530 | 530 | return $arg_string; |
@@ -544,8 +544,8 @@ discard block |
||
| 544 | 544 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 545 | 545 | * @return void |
| 546 | 546 | */ |
| 547 | - public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 548 | - self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
|
| 547 | + public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 548 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
| 549 | 549 | self::$_error_count++; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -558,11 +558,11 @@ discard block |
||
| 558 | 558 | * @param string $line |
| 559 | 559 | * @throws EE_Error |
| 560 | 560 | */ |
| 561 | - public static function throw_exception_if_debugging( $msg = null, $file = null, $func = null, $line = null ) { |
|
| 562 | - if( WP_DEBUG ) { |
|
| 563 | - throw new EE_Error( $msg ); |
|
| 564 | - } else { |
|
| 565 | - EE_Error::add_error( $msg, $file, $func, $line ); |
|
| 561 | + public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) { |
|
| 562 | + if (WP_DEBUG) { |
|
| 563 | + throw new EE_Error($msg); |
|
| 564 | + } else { |
|
| 565 | + EE_Error::add_error($msg, $file, $func, $line); |
|
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | |
@@ -580,8 +580,8 @@ discard block |
||
| 580 | 580 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 581 | 581 | * @return void |
| 582 | 582 | */ |
| 583 | - public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 584 | - self::_add_notice ( 'success', $msg, $file, $func, $line ); |
|
| 583 | + public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 584 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | |
@@ -598,8 +598,8 @@ discard block |
||
| 598 | 598 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 599 | 599 | * @return void |
| 600 | 600 | */ |
| 601 | - public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 602 | - self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
|
| 601 | + public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 602 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | |
@@ -617,12 +617,12 @@ discard block |
||
| 617 | 617 | * @param string $line the line number where the error occurred - just use __LINE__ |
| 618 | 618 | * @return void |
| 619 | 619 | */ |
| 620 | - private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
| 621 | - if ( empty( $msg )) { |
|
| 620 | + private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
| 621 | + if (empty($msg)) { |
|
| 622 | 622 | EE_Error::doing_it_wrong( |
| 623 | - 'EE_Error::add_' . $type . '()', |
|
| 623 | + 'EE_Error::add_'.$type.'()', |
|
| 624 | 624 | sprintf( |
| 625 | - __( 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso' ), |
|
| 625 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), |
|
| 626 | 626 | $type, |
| 627 | 627 | $file, |
| 628 | 628 | $line |
@@ -630,32 +630,32 @@ discard block |
||
| 630 | 630 | EVENT_ESPRESSO_VERSION |
| 631 | 631 | ); |
| 632 | 632 | } |
| 633 | - if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { |
|
| 633 | + if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
| 634 | 634 | EE_Error::doing_it_wrong( |
| 635 | 635 | 'EE_Error::add_error()', |
| 636 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso' ), |
|
| 636 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), |
|
| 637 | 637 | EVENT_ESPRESSO_VERSION |
| 638 | 638 | ); |
| 639 | 639 | } |
| 640 | 640 | // get separate user and developer messages if they exist |
| 641 | - $msg = explode( '||', $msg ); |
|
| 641 | + $msg = explode('||', $msg); |
|
| 642 | 642 | $user_msg = $msg[0]; |
| 643 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
| 643 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
| 644 | 644 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
| 645 | 645 | // add notice if message exists |
| 646 | - if ( ! empty( $msg )) { |
|
| 646 | + if ( ! empty($msg)) { |
|
| 647 | 647 | // get error code |
| 648 | - $notice_code = EE_Error::generate_error_code( $file, $func, $line ); |
|
| 649 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
| 650 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
| 648 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
| 649 | + if (WP_DEBUG && $type == 'errors') { |
|
| 650 | + $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>'; |
|
| 651 | 651 | } |
| 652 | 652 | // add notice. Index by code if it's not blank |
| 653 | - if( $notice_code ) { |
|
| 654 | - self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
| 653 | + if ($notice_code) { |
|
| 654 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
| 655 | 655 | } else { |
| 656 | - self::$_espresso_notices[ $type ][] = $msg; |
|
| 656 | + self::$_espresso_notices[$type][] = $msg; |
|
| 657 | 657 | } |
| 658 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
| 658 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | } |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | * @access private |
| 710 | 710 | * @return void |
| 711 | 711 | */ |
| 712 | - public static function reset_notices(){ |
|
| 712 | + public static function reset_notices() { |
|
| 713 | 713 | self::$_espresso_notices['success'] = FALSE; |
| 714 | 714 | self::$_espresso_notices['attention'] = FALSE; |
| 715 | 715 | self::$_espresso_notices['errors'] = FALSE; |
@@ -722,14 +722,14 @@ discard block |
||
| 722 | 722 | * @access public |
| 723 | 723 | * @return int |
| 724 | 724 | */ |
| 725 | - public static function has_notices(){ |
|
| 725 | + public static function has_notices() { |
|
| 726 | 726 | $has_notices = 0; |
| 727 | 727 | // check for success messages |
| 728 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
| 728 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
| 729 | 729 | // check for attention messages |
| 730 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
| 730 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
| 731 | 731 | // check for error messages |
| 732 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
| 732 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
| 733 | 733 | return $has_notices; |
| 734 | 734 | } |
| 735 | 735 | |
@@ -745,8 +745,8 @@ discard block |
||
| 745 | 745 | * @param boolean $remove_empty whether or not to unset empty messages |
| 746 | 746 | * @return array |
| 747 | 747 | */ |
| 748 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
| 749 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 748 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
| 749 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 750 | 750 | |
| 751 | 751 | $success_messages = ''; |
| 752 | 752 | $attention_messages = ''; |
@@ -756,44 +756,44 @@ discard block |
||
| 756 | 756 | // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 757 | 757 | |
| 758 | 758 | // either save notices to the db |
| 759 | - if ( $save_to_transient ) { |
|
| 760 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
| 759 | + if ($save_to_transient) { |
|
| 760 | + update_option('ee_notices', self::$_espresso_notices); |
|
| 761 | 761 | return; |
| 762 | 762 | } |
| 763 | 763 | // grab any notices that have been previously saved |
| 764 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
| 765 | - foreach ( $notices as $type => $notice ) { |
|
| 766 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
| 764 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
| 765 | + foreach ($notices as $type => $notice) { |
|
| 766 | + if (is_array($notice) && ! empty($notice)) { |
|
| 767 | 767 | // make sure that existsing notice type is an array |
| 768 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
| 768 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
| 769 | 769 | // merge stored notices with any newly created ones |
| 770 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
| 770 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
| 771 | 771 | $print_scripts = TRUE; |
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | // now clear any stored notices |
| 775 | - update_option( 'ee_notices', FALSE ); |
|
| 775 | + update_option('ee_notices', FALSE); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | // check for success messages |
| 779 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
| 779 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
| 780 | 780 | // combine messages |
| 781 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
| 781 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
| 782 | 782 | $print_scripts = TRUE; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | // check for attention messages |
| 786 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
| 786 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
| 787 | 787 | // combine messages |
| 788 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
| 788 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
| 789 | 789 | $print_scripts = TRUE; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | // check for error messages |
| 793 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
| 794 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
| 793 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
| 794 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
| 795 | 795 | // combine messages |
| 796 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
| 796 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
| 797 | 797 | $print_scripts = TRUE; |
| 798 | 798 | } |
| 799 | 799 | |
@@ -807,21 +807,21 @@ discard block |
||
| 807 | 807 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
| 808 | 808 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
| 809 | 809 | //showMessage( $success_messages ); |
| 810 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
| 810 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | if ($attention_messages != '') { |
| 814 | 814 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
| 815 | 815 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
| 816 | 816 | //showMessage( $error_messages, TRUE ); |
| 817 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
| 817 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | if ($error_messages != '') { |
| 821 | 821 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
| 822 | 822 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
| 823 | 823 | //showMessage( $error_messages, TRUE ); |
| 824 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
| 824 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | $notices .= '</div>'; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | 'errors' => $error_messages |
| 835 | 835 | ); |
| 836 | 836 | |
| 837 | - if ( $remove_empty ) { |
|
| 837 | + if ($remove_empty) { |
|
| 838 | 838 | // remove empty notices |
| 839 | 839 | foreach ($notices as $type => $notice) { |
| 840 | 840 | if (empty($notice)) { |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - if ( $print_scripts ) { |
|
| 847 | + if ($print_scripts) { |
|
| 848 | 848 | self::_print_scripts(); |
| 849 | 849 | } |
| 850 | 850 | |
@@ -864,17 +864,17 @@ discard block |
||
| 864 | 864 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
| 865 | 865 | * @return void |
| 866 | 866 | */ |
| 867 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
| 868 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
| 869 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
| 867 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
| 868 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
| 869 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
| 870 | 870 | //maybe initialize persistent_admin_notices |
| 871 | - if ( empty( $persistent_admin_notices )) { |
|
| 872 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
| 871 | + if (empty($persistent_admin_notices)) { |
|
| 872 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
| 873 | 873 | } |
| 874 | - $pan_name = sanitize_key( $pan_name ); |
|
| 875 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
| 876 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
| 877 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
| 874 | + $pan_name = sanitize_key($pan_name); |
|
| 875 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
| 876 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
| 877 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
| 878 | 878 | } |
| 879 | 879 | } |
| 880 | 880 | } |
@@ -890,34 +890,34 @@ discard block |
||
| 890 | 890 | * @param bool $return_immediately |
| 891 | 891 | * @return void |
| 892 | 892 | */ |
| 893 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
| 894 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
| 895 | - if ( ! empty( $pan_name )) { |
|
| 896 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
| 893 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
| 894 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
| 895 | + if ( ! empty($pan_name)) { |
|
| 896 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
| 897 | 897 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
| 898 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
| 898 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
| 899 | 899 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
| 900 | - if ( $purge ) { |
|
| 901 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
| 900 | + if ($purge) { |
|
| 901 | + unset($persistent_admin_notices[$pan_name]); |
|
| 902 | 902 | } else { |
| 903 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
| 903 | + $persistent_admin_notices[$pan_name] = NULL; |
|
| 904 | 904 | } |
| 905 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
| 906 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 905 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
| 906 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
| 907 | 907 | } |
| 908 | 908 | } |
| 909 | 909 | } |
| 910 | - if ( $return_immediately ) { |
|
| 910 | + if ($return_immediately) { |
|
| 911 | 911 | return; |
| 912 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
| 912 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
| 913 | 913 | // grab any notices and concatenate into string |
| 914 | - echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
| 914 | + echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
| 915 | 915 | exit(); |
| 916 | 916 | } else { |
| 917 | 917 | // save errors to a transient to be displayed on next request (after redirect) |
| 918 | - EE_Error::get_notices( FALSE, TRUE ); |
|
| 919 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
| 920 | - wp_safe_redirect( urldecode( $return_url )); |
|
| 918 | + EE_Error::get_notices(FALSE, TRUE); |
|
| 919 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
| 920 | + wp_safe_redirect(urldecode($return_url)); |
|
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | |
@@ -932,20 +932,20 @@ discard block |
||
| 932 | 932 | * @param string $return_url URL to go back to aftger nag notice is dismissed |
| 933 | 933 | * @return string |
| 934 | 934 | */ |
| 935 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
| 936 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
| 935 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
| 936 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
| 937 | 937 | $args = array( |
| 938 | 938 | 'nag_notice' => $pan_name, |
| 939 | - 'return_url' => urlencode( $return_url ), |
|
| 939 | + 'return_url' => urlencode($return_url), |
|
| 940 | 940 | 'ajax_url' => WP_AJAX_URL, |
| 941 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
| 941 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
| 942 | 942 | ); |
| 943 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
| 943 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
| 944 | 944 | return ' |
| 945 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
| 946 | - <p>' . $pan_message . '</p> |
|
| 947 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
| 948 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
| 945 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
| 946 | + <p>' . $pan_message.'</p> |
|
| 947 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
| 948 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
| 949 | 949 | </a> |
| 950 | 950 | <div style="clear:both;"></div> |
| 951 | 951 | </div>'; |
@@ -961,24 +961,24 @@ discard block |
||
| 961 | 961 | * @param string $return_url |
| 962 | 962 | * @return array |
| 963 | 963 | */ |
| 964 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
| 964 | + public static function get_persistent_admin_notices($return_url = '') { |
|
| 965 | 965 | $notices = ''; |
| 966 | 966 | // check for persistent admin notices |
| 967 | 967 | //filter the list though so plugins can notify the admin in a different way if they want |
| 968 | 968 | $persistent_admin_notices = apply_filters( |
| 969 | 969 | 'FHEE__EE_Error__get_persistent_admin_notices', |
| 970 | - get_option( 'ee_pers_admin_notices', FALSE ), |
|
| 970 | + get_option('ee_pers_admin_notices', FALSE), |
|
| 971 | 971 | 'ee_pers_admin_notices', |
| 972 | 972 | $return_url |
| 973 | 973 | ); |
| 974 | - if ( $persistent_admin_notices ) { |
|
| 974 | + if ($persistent_admin_notices) { |
|
| 975 | 975 | // load scripts |
| 976 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 977 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 978 | - wp_enqueue_script( 'ee_error_js' ); |
|
| 976 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 977 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 978 | + wp_enqueue_script('ee_error_js'); |
|
| 979 | 979 | // and display notices |
| 980 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
| 981 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
| 980 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
| 981 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | return $notices; |
@@ -993,26 +993,26 @@ discard block |
||
| 993 | 993 | * @param bool $force_print |
| 994 | 994 | * @return void |
| 995 | 995 | */ |
| 996 | - private static function _print_scripts( $force_print = FALSE ) { |
|
| 997 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
| 998 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
| 996 | + private static function _print_scripts($force_print = FALSE) { |
|
| 997 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
| 998 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
| 999 | 999 | return; |
| 1000 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
| 1001 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
| 1002 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
| 1003 | - wp_enqueue_script( 'ee_error_js' ); |
|
| 1004 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
| 1000 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
| 1001 | + add_filter('FHEE_load_css', '__return_true'); |
|
| 1002 | + add_filter('FHEE_load_js', '__return_true'); |
|
| 1003 | + wp_enqueue_script('ee_error_js'); |
|
| 1004 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
| 1005 | 1005 | } |
| 1006 | 1006 | } else { |
| 1007 | 1007 | return ' |
| 1008 | 1008 | <script> |
| 1009 | 1009 | /* <![CDATA[ */ |
| 1010 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
| 1010 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
| 1011 | 1011 | /* ]]> */ |
| 1012 | 1012 | </script> |
| 1013 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
| 1014 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
| 1015 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
| 1013 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
| 1014 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
| 1015 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
| 1016 | 1016 | '; |
| 1017 | 1017 | |
| 1018 | 1018 | } |
@@ -1046,11 +1046,11 @@ discard block |
||
| 1046 | 1046 | * @ param string $line |
| 1047 | 1047 | * @ return string |
| 1048 | 1048 | */ |
| 1049 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
| 1050 | - $file = explode( '.', basename( $file )); |
|
| 1051 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
| 1052 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
| 1053 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
| 1049 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
| 1050 | + $file = explode('.', basename($file)); |
|
| 1051 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
| 1052 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
| 1053 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
| 1054 | 1054 | return $error_code; |
| 1055 | 1055 | } |
| 1056 | 1056 | |
@@ -1066,37 +1066,37 @@ discard block |
||
| 1066 | 1066 | * @ param object $ex |
| 1067 | 1067 | * @ return void |
| 1068 | 1068 | */ |
| 1069 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
| 1069 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
| 1070 | 1070 | |
| 1071 | - if ( ! $ex ) { |
|
| 1071 | + if ( ! $ex) { |
|
| 1072 | 1072 | return; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - if ( ! $time ) { |
|
| 1075 | + if ( ! $time) { |
|
| 1076 | 1076 | $time = time(); |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
| 1080 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
| 1081 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
| 1082 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
| 1083 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
| 1084 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
| 1085 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
| 1086 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
| 1087 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
| 1088 | - |
|
| 1089 | - EE_Registry::instance()->load_helper( 'File' ); |
|
| 1079 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
| 1080 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
| 1081 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
| 1082 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
| 1083 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
| 1084 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
| 1085 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
| 1086 | + $exception_log .= $ex['string'].PHP_EOL; |
|
| 1087 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
| 1088 | + |
|
| 1089 | + EE_Registry::instance()->load_helper('File'); |
|
| 1090 | 1090 | try { |
| 1091 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
| 1092 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); |
|
| 1093 | - if ( ! $clear ) { |
|
| 1091 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
| 1092 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); |
|
| 1093 | + if ( ! $clear) { |
|
| 1094 | 1094 | //get existing log file and append new log info |
| 1095 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
| 1095 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
| 1096 | 1096 | } |
| 1097 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
| 1098 | - } catch( EE_Error $e ){ |
|
| 1099 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
| 1097 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
| 1098 | + } catch (EE_Error $e) { |
|
| 1099 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
| 1100 | 1100 | return; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
@@ -1120,10 +1120,10 @@ discard block |
||
| 1120 | 1120 | * @param int $error_type |
| 1121 | 1121 | * @return void |
| 1122 | 1122 | */ |
| 1123 | - public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
| 1124 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
| 1123 | + public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
| 1124 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
| 1125 | 1125 | EE_Registry::instance()->load_helper('Debug_Tools'); |
| 1126 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type ); |
|
| 1126 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | 1129 | |
@@ -1155,13 +1155,13 @@ discard block |
||
| 1155 | 1155 | */ |
| 1156 | 1156 | function espresso_error_enqueue_scripts() { |
| 1157 | 1157 | // js for error handling |
| 1158 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
| 1159 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
| 1158 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
| 1159 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
| 1160 | 1160 | } |
| 1161 | -if ( is_admin() ) { |
|
| 1162 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
| 1161 | +if (is_admin()) { |
|
| 1162 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
| 1163 | 1163 | } else { |
| 1164 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
| 1164 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
| 2 | 2 | /** |
| 3 | 3 | * Class EE_Select_Input |
| 4 | 4 | * |
@@ -10,22 +10,22 @@ discard block |
||
| 10 | 10 | * @since 4.6 |
| 11 | 11 | * |
| 12 | 12 | */ |
| 13 | -class EE_Select_Input extends EE_Form_Input_With_Options_Base{ |
|
| 13 | +class EE_Select_Input extends EE_Form_Input_With_Options_Base { |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param array $answer_options |
| 17 | 17 | * @param array $input_settings |
| 18 | 18 | */ |
| 19 | - public function __construct( $answer_options, $input_settings = array() ) { |
|
| 20 | - $this->_set_display_strategy( new EE_Select_Display_Strategy( $answer_options ) ); |
|
| 19 | + public function __construct($answer_options, $input_settings = array()) { |
|
| 20 | + $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
| 21 | 21 | $this->_add_validation_strategy( |
| 22 | 22 | new EE_Enum_Validation_Strategy( |
| 23 | - isset( $input_settings['validation_error_message'] ) |
|
| 23 | + isset($input_settings['validation_error_message']) |
|
| 24 | 24 | ? $input_settings['validation_error_message'] |
| 25 | 25 | : null |
| 26 | 26 | ) |
| 27 | 27 | ); |
| 28 | - parent::__construct( $answer_options, $input_settings ); |
|
| 28 | + parent::__construct($answer_options, $input_settings); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -810,8 +810,7 @@ |
||
| 810 | 810 | * (If that doesn't exist, we also check for this subsection's name |
| 811 | 811 | * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].) |
| 812 | 812 | * This function finds its value in the form. |
| 813 | - |
|
| 814 | -* |
|
| 813 | + * |
|
| 815 | 814 | *@param array $req_data |
| 816 | 815 | * @return mixed whatever the raw value of this form section is in the request data |
| 817 | 816 | * @throws \EE_Error |
@@ -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 |
@@ -143,54 +143,54 @@ discard block |
||
| 143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
| 144 | 144 | * } |
| 145 | 145 | */ |
| 146 | - public function __construct( $input_args = array() ){ |
|
| 147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
| 146 | + public function __construct($input_args = array()) { |
|
| 147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
| 148 | 148 | // the following properties must be cast as arrays |
| 149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
| 150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
| 151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
| 149 | + if (isset($input_args['validation_strategies'])) { |
|
| 150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
| 151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | - unset( $input_args['validation_strategies'] ); |
|
| 155 | + unset($input_args['validation_strategies']); |
|
| 156 | 156 | } |
| 157 | 157 | // loop thru incoming options |
| 158 | - foreach( $input_args as $key => $value ) { |
|
| 158 | + foreach ($input_args as $key => $value) { |
|
| 159 | 159 | // add underscore to $key to match property names |
| 160 | - $_key = '_' . $key; |
|
| 161 | - if ( property_exists( $this, $_key )) { |
|
| 160 | + $_key = '_'.$key; |
|
| 161 | + if (property_exists($this, $_key)) { |
|
| 162 | 162 | $this->{$_key} = $value; |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | // ensure that "required" is set correctly |
| 166 | 166 | $this->set_required( |
| 167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
| 168 | - ? $input_args[ 'required_validation_error_message' ] |
|
| 167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
| 168 | + ? $input_args['required_validation_error_message'] |
|
| 169 | 169 | : null |
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
| 173 | 173 | |
| 174 | 174 | $this->_display_strategy->_construct_finalize($this); |
| 175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
| 175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 176 | 176 | $validation_strategy->_construct_finalize($this); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if( ! $this->_normalization_strategy){ |
|
| 179 | + if ( ! $this->_normalization_strategy) { |
|
| 180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
| 181 | 181 | } |
| 182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
| 183 | 183 | |
| 184 | 184 | //at least we can use the normalization strategy to populate the default |
| 185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
| 186 | - $this->set_default( $input_args[ 'default' ] ); |
|
| 185 | + if (isset($input_args['default'])) { |
|
| 186 | + $this->set_default($input_args['default']); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
| 189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
| 190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
| 191 | 191 | } |
| 192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
| 193 | - parent::__construct( $input_args ); |
|
| 193 | + parent::__construct($input_args); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @throws \EE_Error |
| 203 | 203 | */ |
| 204 | - protected function _set_default_html_name_if_empty(){ |
|
| 205 | - if( ! $this->_html_name){ |
|
| 204 | + protected function _set_default_html_name_if_empty() { |
|
| 205 | + if ( ! $this->_html_name) { |
|
| 206 | 206 | $this->_html_name = $this->name(); |
| 207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
| 208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
| 207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
| 208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | } |
@@ -220,10 +220,10 @@ discard block |
||
| 220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
| 221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
| 222 | 222 | $this->_set_default_html_name_if_empty(); |
| 223 | - if( ! $this->_html_label && ! $this->_html_label_text){ |
|
| 224 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
| 223 | + if ( ! $this->_html_label && ! $this->_html_label_text) { |
|
| 224 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
| 225 | 225 | } |
| 226 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
| 226 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | * @return EE_Display_Strategy_Base |
| 232 | 232 | * @throws EE_Error |
| 233 | 233 | */ |
| 234 | - protected function _get_display_strategy(){ |
|
| 235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
| 234 | + protected function _get_display_strategy() { |
|
| 235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
| 236 | 236 | throw new EE_Error( |
| 237 | 237 | sprintf( |
| 238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $this->html_id() |
| 244 | 244 | ) |
| 245 | 245 | ); |
| 246 | - }else{ |
|
| 246 | + } else { |
|
| 247 | 247 | return $this->_display_strategy; |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * Sets the display strategy. |
| 252 | 252 | * @param EE_Display_Strategy_Base $strategy |
| 253 | 253 | */ |
| 254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
| 254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
| 255 | 255 | $this->_display_strategy = $strategy; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * Sets the sanitization strategy |
| 260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
| 261 | 261 | */ |
| 262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
| 262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
| 263 | 263 | $this->_normalization_strategy = $strategy; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
| 285 | 285 | * Gets the display strategy for this input |
| 286 | 286 | * @return EE_Display_Strategy_Base |
| 287 | 287 | */ |
| 288 | - public function get_display_strategy(){ |
|
| 288 | + public function get_display_strategy() { |
|
| 289 | 289 | return $this->_display_strategy; |
| 290 | 290 | } |
| 291 | 291 | /** |
| 292 | 292 | * Overwrites the display strategy |
| 293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
| 294 | 294 | */ |
| 295 | - public function set_display_strategy($display_strategy){ |
|
| 295 | + public function set_display_strategy($display_strategy) { |
|
| 296 | 296 | $this->_display_strategy = $display_strategy; |
| 297 | 297 | $this->_display_strategy->_construct_finalize($this); |
| 298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
| 300 | 300 | * Gets the normalization strategy set on this input |
| 301 | 301 | * @return EE_Normalization_Strategy_Base |
| 302 | 302 | */ |
| 303 | - public function get_normalization_strategy(){ |
|
| 303 | + public function get_normalization_strategy() { |
|
| 304 | 304 | return $this->_normalization_strategy; |
| 305 | 305 | } |
| 306 | 306 | /** |
| 307 | 307 | * Overwrites the normalization strategy |
| 308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
| 309 | 309 | */ |
| 310 | - public function set_normalization_strategy($normalization_strategy){ |
|
| 310 | + public function set_normalization_strategy($normalization_strategy) { |
|
| 311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
| 312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
| 313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
| 317 | 317 | * @return EE_Validation_Strategy_Base[] |
| 318 | 318 | */ |
| 319 | - public function get_validation_strategies(){ |
|
| 319 | + public function get_validation_strategies() { |
|
| 320 | 320 | return $this->_validation_strategies; |
| 321 | 321 | } |
| 322 | 322 | |
@@ -327,9 +327,9 @@ discard block |
||
| 327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
| 328 | 328 | * @return void |
| 329 | 329 | */ |
| 330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
| 331 | - $validation_strategy->_construct_finalize( $this ); |
|
| 332 | - $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy; |
|
| 330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
| 331 | + $validation_strategy->_construct_finalize($this); |
|
| 332 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
| 340 | 340 | * @return void |
| 341 | 341 | */ |
| 342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
| 343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
| 342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
| 343 | + $this->_add_validation_strategy($validation_strategy); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @param string $validation_strategy_classname |
| 352 | 352 | */ |
| 353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
| 354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
| 355 | - if( |
|
| 353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
| 354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
| 355 | + if ( |
|
| 356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
| 357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
| 357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
| 358 | 358 | ) { |
| 359 | - unset( $this->_validation_strategies[ $key ] ); |
|
| 359 | + unset($this->_validation_strategies[$key]); |
|
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
| 369 | 369 | * @param array $validation_strategy_classnames |
| 370 | 370 | * @return bool |
| 371 | 371 | */ |
| 372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
| 373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
| 372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
| 373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
| 374 | 374 | ? $validation_strategy_classnames |
| 375 | - : array( $validation_strategy_classnames ); |
|
| 376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
| 377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
| 375 | + : array($validation_strategy_classnames); |
|
| 376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
| 377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
| 378 | 378 | return true; |
| 379 | 379 | } |
| 380 | 380 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * to the parent form's layout strategy |
| 389 | 389 | * @return string |
| 390 | 390 | */ |
| 391 | - public function get_html_and_js(){ |
|
| 391 | + public function get_html_and_js() { |
|
| 392 | 392 | return $this->_parent_section->get_html_for_input($this); |
| 393 | 393 | } |
| 394 | 394 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @return string |
| 403 | 403 | * @throws \EE_Error |
| 404 | 404 | */ |
| 405 | - public function get_html_for_input(){ |
|
| 405 | + public function get_html_for_input() { |
|
| 406 | 406 | return $this->_get_display_strategy()->display(); |
| 407 | 407 | } |
| 408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | * @return string |
| 413 | 413 | */ |
| 414 | 414 | public function html_other_attributes() { |
| 415 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
| 415 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | /** |
| 421 | 421 | * @param string $html_other_attributes |
| 422 | 422 | */ |
| 423 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
| 423 | + public function set_html_other_attributes($html_other_attributes) { |
|
| 424 | 424 | $this->_html_other_attributes = $html_other_attributes; |
| 425 | 425 | } |
| 426 | 426 | |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * according to the form section's layout strategy |
| 430 | 430 | * @return string |
| 431 | 431 | */ |
| 432 | - public function get_html_for_label(){ |
|
| 432 | + public function get_html_for_label() { |
|
| 433 | 433 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
| 434 | 434 | } |
| 435 | 435 | /** |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | * according to the form section's layout strategy |
| 438 | 438 | * @return string |
| 439 | 439 | */ |
| 440 | - public function get_html_for_errors(){ |
|
| 440 | + public function get_html_for_errors() { |
|
| 441 | 441 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
| 442 | 442 | } |
| 443 | 443 | /** |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | * according to the form section's layout strategy |
| 446 | 446 | * @return string |
| 447 | 447 | */ |
| 448 | - public function get_html_for_help(){ |
|
| 448 | + public function get_html_for_help() { |
|
| 449 | 449 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
| 450 | 450 | } |
| 451 | 451 | /** |
@@ -454,18 +454,18 @@ discard block |
||
| 454 | 454 | * @return boolean |
| 455 | 455 | */ |
| 456 | 456 | protected function _validate() { |
| 457 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
| 458 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
| 459 | - try{ |
|
| 457 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
| 458 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
| 459 | + try { |
|
| 460 | 460 | $validation_strategy->validate($this->normalized_value()); |
| 461 | - }catch(EE_Validation_Error $e){ |
|
| 461 | + } catch (EE_Validation_Error $e) { |
|
| 462 | 462 | $this->add_validation_error($e); |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | - if( $this->get_validation_errors()){ |
|
| 466 | + if ($this->get_validation_errors()) { |
|
| 467 | 467 | return false; |
| 468 | - }else{ |
|
| 468 | + } else { |
|
| 469 | 469 | return true; |
| 470 | 470 | } |
| 471 | 471 | } |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | * @param string $value |
| 479 | 479 | * @return null|string |
| 480 | 480 | */ |
| 481 | - private function _sanitize($value){ |
|
| 482 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
| 481 | + private function _sanitize($value) { |
|
| 482 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | |
@@ -493,24 +493,24 @@ discard block |
||
| 493 | 493 | * @return boolean whether or not there was an error |
| 494 | 494 | * @throws \EE_Error |
| 495 | 495 | */ |
| 496 | - protected function _normalize( $req_data ) { |
|
| 496 | + protected function _normalize($req_data) { |
|
| 497 | 497 | //any existing validation errors don't apply so clear them |
| 498 | 498 | $this->_validation_errors = array(); |
| 499 | 499 | try { |
| 500 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
| 500 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
| 501 | 501 | //super simple sanitization for now |
| 502 | - if ( is_array( $raw_input )) { |
|
| 502 | + if (is_array($raw_input)) { |
|
| 503 | 503 | $this->_raw_value = array(); |
| 504 | - foreach( $raw_input as $key => $value ) { |
|
| 505 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
| 504 | + foreach ($raw_input as $key => $value) { |
|
| 505 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
| 506 | 506 | } |
| 507 | 507 | } else { |
| 508 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
| 508 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
| 509 | 509 | } |
| 510 | 510 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
| 511 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
| 512 | - } catch ( EE_Validation_Error $e ) { |
|
| 513 | - $this->add_validation_error( $e ); |
|
| 511 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
| 512 | + } catch (EE_Validation_Error $e) { |
|
| 513 | + $this->add_validation_error($e); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | /** |
| 520 | 520 | * @return string |
| 521 | 521 | */ |
| 522 | - public function html_name(){ |
|
| 522 | + public function html_name() { |
|
| 523 | 523 | return $this->_html_name; |
| 524 | 524 | } |
| 525 | 525 | |
@@ -528,8 +528,8 @@ discard block |
||
| 528 | 528 | /** |
| 529 | 529 | * @return string |
| 530 | 530 | */ |
| 531 | - public function html_label_id(){ |
|
| 532 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
| 531 | + public function html_label_id() { |
|
| 532 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | /** |
| 538 | 538 | * @return string |
| 539 | 539 | */ |
| 540 | - public function html_label_class(){ |
|
| 540 | + public function html_label_class() { |
|
| 541 | 541 | return $this->_html_label_class; |
| 542 | 542 | } |
| 543 | 543 | |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | /** |
| 547 | 547 | * @return string |
| 548 | 548 | */ |
| 549 | - public function html_label_style(){ |
|
| 549 | + public function html_label_style() { |
|
| 550 | 550 | return $this->_html_label_style; |
| 551 | 551 | } |
| 552 | 552 | |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | /** |
| 556 | 556 | * @return string |
| 557 | 557 | */ |
| 558 | - public function html_label_text(){ |
|
| 558 | + public function html_label_text() { |
|
| 559 | 559 | return $this->_html_label_text; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | /** |
| 565 | 565 | * @return string |
| 566 | 566 | */ |
| 567 | - public function html_help_text(){ |
|
| 567 | + public function html_help_text() { |
|
| 568 | 568 | return $this->_html_help_text; |
| 569 | 569 | } |
| 570 | 570 | |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | /** |
| 574 | 574 | * @return string |
| 575 | 575 | */ |
| 576 | - public function html_help_class(){ |
|
| 576 | + public function html_help_class() { |
|
| 577 | 577 | return $this->_html_help_class; |
| 578 | 578 | } |
| 579 | 579 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | /** |
| 583 | 583 | * @return string |
| 584 | 584 | */ |
| 585 | - public function html_help_style(){ |
|
| 585 | + public function html_help_style() { |
|
| 586 | 586 | return $this->_html_style; |
| 587 | 587 | } |
| 588 | 588 | /** |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | * in which case, we would have stored the malicious content to our database. |
| 596 | 596 | * @return string |
| 597 | 597 | */ |
| 598 | - public function raw_value(){ |
|
| 598 | + public function raw_value() { |
|
| 599 | 599 | return $this->_raw_value; |
| 600 | 600 | } |
| 601 | 601 | /** |
@@ -603,15 +603,15 @@ discard block |
||
| 603 | 603 | * it escapes all html entities |
| 604 | 604 | * @return string |
| 605 | 605 | */ |
| 606 | - public function raw_value_in_form(){ |
|
| 607 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
| 606 | + public function raw_value_in_form() { |
|
| 607 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
| 608 | 608 | } |
| 609 | 609 | /** |
| 610 | 610 | * returns the value after it's been sanitized, and then converted into it's proper type |
| 611 | 611 | * in PHP. Eg, a string, an int, an array, |
| 612 | 612 | * @return mixed |
| 613 | 613 | */ |
| 614 | - public function normalized_value(){ |
|
| 614 | + public function normalized_value() { |
|
| 615 | 615 | return $this->_normalized_value; |
| 616 | 616 | } |
| 617 | 617 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * the best thing to display |
| 622 | 622 | * @return string |
| 623 | 623 | */ |
| 624 | - public function pretty_value(){ |
|
| 624 | + public function pretty_value() { |
|
| 625 | 625 | return $this->_normalized_value; |
| 626 | 626 | } |
| 627 | 627 | /** |
@@ -640,19 +640,19 @@ discard block |
||
| 640 | 640 | }</code> |
| 641 | 641 | * @return array |
| 642 | 642 | */ |
| 643 | - public function get_jquery_validation_rules(){ |
|
| 643 | + public function get_jquery_validation_rules() { |
|
| 644 | 644 | |
| 645 | 645 | $jquery_validation_rules = array(); |
| 646 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
| 646 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
| 647 | 647 | $jquery_validation_rules = array_replace_recursive( |
| 648 | 648 | $jquery_validation_rules, |
| 649 | 649 | $validation_strategy->get_jquery_validation_rule_array() |
| 650 | 650 | ); |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - if(! empty($jquery_validation_rules)){ |
|
| 654 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
| 655 | - }else{ |
|
| 653 | + if ( ! empty($jquery_validation_rules)) { |
|
| 654 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
| 655 | + } else { |
|
| 656 | 656 | return array(); |
| 657 | 657 | } |
| 658 | 658 | return $jquery_validation_js; |
@@ -664,9 +664,9 @@ discard block |
||
| 664 | 664 | * @param mixed $value |
| 665 | 665 | * @return void |
| 666 | 666 | */ |
| 667 | - public function set_default($value){ |
|
| 667 | + public function set_default($value) { |
|
| 668 | 668 | $this->_normalized_value = $value; |
| 669 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
| 669 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | /** |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | * @param string $label |
| 675 | 675 | * @return void |
| 676 | 676 | */ |
| 677 | - public function set_html_label_text($label){ |
|
| 677 | + public function set_html_label_text($label) { |
|
| 678 | 678 | $this->_html_label_text = $label; |
| 679 | 679 | } |
| 680 | 680 | |
@@ -688,13 +688,13 @@ discard block |
||
| 688 | 688 | * @param boolean $required boolean |
| 689 | 689 | * @param null $required_text |
| 690 | 690 | */ |
| 691 | - public function set_required($required = true, $required_text = NULL ){ |
|
| 692 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
| 691 | + public function set_required($required = true, $required_text = NULL) { |
|
| 692 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
| 693 | 693 | //whether $required is a string or a boolean, we want to add a required validation strategy |
| 694 | - if ( $required ) { |
|
| 695 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
| 694 | + if ($required) { |
|
| 695 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
| 696 | 696 | } else { |
| 697 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
| 697 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
| 698 | 698 | } |
| 699 | 699 | $this->_required = $required; |
| 700 | 700 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | * Returns whether or not this field is required |
| 703 | 703 | * @return boolean |
| 704 | 704 | */ |
| 705 | - public function required(){ |
|
| 705 | + public function required() { |
|
| 706 | 706 | return $this->_required; |
| 707 | 707 | } |
| 708 | 708 | |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | /** |
| 712 | 712 | * @param string $required_css_class |
| 713 | 713 | */ |
| 714 | - public function set_required_css_class( $required_css_class ) { |
|
| 714 | + public function set_required_css_class($required_css_class) { |
|
| 715 | 715 | $this->_required_css_class = $required_css_class; |
| 716 | 716 | } |
| 717 | 717 | |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | * Sets the help text, in case |
| 731 | 731 | * @param string $text |
| 732 | 732 | */ |
| 733 | - public function set_html_help_text($text){ |
|
| 733 | + public function set_html_help_text($text) { |
|
| 734 | 734 | $this->_html_help_text = $text; |
| 735 | 735 | } |
| 736 | 736 | /** |
@@ -742,8 +742,8 @@ discard block |
||
| 742 | 742 | public function clean_sensitive_data() { |
| 743 | 743 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
| 744 | 744 | //if we need more logic than this we'll make a strategy for it |
| 745 | - if( $this->_sensitive_data_removal_strategy && |
|
| 746 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
| 745 | + if ($this->_sensitive_data_removal_strategy && |
|
| 746 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
| 747 | 747 | $this->_raw_value = NULL; |
| 748 | 748 | } |
| 749 | 749 | //and clean the normalized value according to the appropriate strategy |
@@ -759,10 +759,10 @@ discard block |
||
| 759 | 759 | * @param string $button_size |
| 760 | 760 | * @param string $other_attributes |
| 761 | 761 | */ |
| 762 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
| 762 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
| 763 | 763 | $button_css_attributes = 'button'; |
| 764 | 764 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
| 765 | - switch ( $button_size ) { |
|
| 765 | + switch ($button_size) { |
|
| 766 | 766 | case 'xs' : |
| 767 | 767 | case 'extra-small' : |
| 768 | 768 | $button_css_attributes .= ' button-xs'; |
@@ -783,8 +783,8 @@ discard block |
||
| 783 | 783 | default : |
| 784 | 784 | $button_css_attributes .= ''; |
| 785 | 785 | } |
| 786 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
| 787 | - ? $button_css_attributes . ' ' . $other_attributes |
|
| 786 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
| 787 | + ? $button_css_attributes.' '.$other_attributes |
|
| 788 | 788 | : $button_css_attributes; |
| 789 | 789 | } |
| 790 | 790 | |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | * @return string |
| 795 | 795 | */ |
| 796 | 796 | public function button_css_attributes() { |
| 797 | - if ( empty( $this->_button_css_attributes )) { |
|
| 797 | + if (empty($this->_button_css_attributes)) { |
|
| 798 | 798 | $this->set_button_css_attributes(); |
| 799 | 799 | } |
| 800 | 800 | return $this->_button_css_attributes; |
@@ -816,26 +816,26 @@ discard block |
||
| 816 | 816 | * @return mixed whatever the raw value of this form section is in the request data |
| 817 | 817 | * @throws \EE_Error |
| 818 | 818 | */ |
| 819 | - public function find_form_data_for_this_section( $req_data ){ |
|
| 819 | + public function find_form_data_for_this_section($req_data) { |
|
| 820 | 820 | // break up the html name by "[]" |
| 821 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
| 822 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
| 821 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
| 822 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
| 823 | 823 | } else { |
| 824 | 824 | $before_any_brackets = $this->html_name(); |
| 825 | 825 | } |
| 826 | 826 | // grab all of the segments |
| 827 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
| 828 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
| 829 | - $name_parts = $matches[ 1 ]; |
|
| 827 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
| 828 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
| 829 | + $name_parts = $matches[1]; |
|
| 830 | 830 | array_unshift($name_parts, $before_any_brackets); |
| 831 | - }else{ |
|
| 832 | - $name_parts = array( $before_any_brackets ); |
|
| 831 | + } else { |
|
| 832 | + $name_parts = array($before_any_brackets); |
|
| 833 | 833 | } |
| 834 | 834 | // now get the value for the input |
| 835 | 835 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
| 836 | 836 | // check if this thing's name is at the TOP level of the request data |
| 837 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
| 838 | - $value = $req_data[ $this->name() ]; |
|
| 837 | + if ($value === null && isset($req_data[$this->name()])) { |
|
| 838 | + $value = $req_data[$this->name()]; |
|
| 839 | 839 | } |
| 840 | 840 | return $value; |
| 841 | 841 | } |
@@ -848,18 +848,18 @@ discard block |
||
| 848 | 848 | * @param array $req_data |
| 849 | 849 | * @return array | NULL |
| 850 | 850 | */ |
| 851 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
| 852 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
| 853 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
| 854 | - if( empty($html_name_parts ) ){ |
|
| 855 | - return $req_data[ $first_part_to_consider ]; |
|
| 856 | - }else{ |
|
| 851 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
| 852 | + $first_part_to_consider = array_shift($html_name_parts); |
|
| 853 | + if (isset($req_data[$first_part_to_consider])) { |
|
| 854 | + if (empty($html_name_parts)) { |
|
| 855 | + return $req_data[$first_part_to_consider]; |
|
| 856 | + } else { |
|
| 857 | 857 | return $this->_find_form_data_for_this_section_using_name_parts( |
| 858 | 858 | $html_name_parts, |
| 859 | - $req_data[ $first_part_to_consider ] |
|
| 859 | + $req_data[$first_part_to_consider] |
|
| 860 | 860 | ); |
| 861 | 861 | } |
| 862 | - }else{ |
|
| 862 | + } else { |
|
| 863 | 863 | return NULL; |
| 864 | 864 | } |
| 865 | 865 | } |
@@ -873,14 +873,14 @@ discard block |
||
| 873 | 873 | * @return boolean |
| 874 | 874 | * @throws \EE_Error |
| 875 | 875 | */ |
| 876 | - public function form_data_present_in($req_data = NULL){ |
|
| 877 | - if( $req_data === NULL ){ |
|
| 876 | + public function form_data_present_in($req_data = NULL) { |
|
| 877 | + if ($req_data === NULL) { |
|
| 878 | 878 | $req_data = $_POST; |
| 879 | 879 | } |
| 880 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
| 881 | - if( $checked_value !== null ){ |
|
| 880 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
| 881 | + if ($checked_value !== null) { |
|
| 882 | 882 | return TRUE; |
| 883 | - }else{ |
|
| 883 | + } else { |
|
| 884 | 884 | return FALSE; |
| 885 | 885 | } |
| 886 | 886 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $this->html_id() |
| 244 | 244 | ) |
| 245 | 245 | ); |
| 246 | - }else{ |
|
| 246 | + } else{ |
|
| 247 | 247 | return $this->_display_strategy; |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -458,14 +458,14 @@ discard block |
||
| 458 | 458 | if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
| 459 | 459 | try{ |
| 460 | 460 | $validation_strategy->validate($this->normalized_value()); |
| 461 | - }catch(EE_Validation_Error $e){ |
|
| 461 | + } catch(EE_Validation_Error $e){ |
|
| 462 | 462 | $this->add_validation_error($e); |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | if( $this->get_validation_errors()){ |
| 467 | 467 | return false; |
| 468 | - }else{ |
|
| 468 | + } else{ |
|
| 469 | 469 | return true; |
| 470 | 470 | } |
| 471 | 471 | } |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | if(! empty($jquery_validation_rules)){ |
| 654 | 654 | $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
| 655 | - }else{ |
|
| 655 | + } else{ |
|
| 656 | 656 | return array(); |
| 657 | 657 | } |
| 658 | 658 | return $jquery_validation_js; |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
| 829 | 829 | $name_parts = $matches[ 1 ]; |
| 830 | 830 | array_unshift($name_parts, $before_any_brackets); |
| 831 | - }else{ |
|
| 831 | + } else{ |
|
| 832 | 832 | $name_parts = array( $before_any_brackets ); |
| 833 | 833 | } |
| 834 | 834 | // now get the value for the input |
@@ -853,13 +853,13 @@ discard block |
||
| 853 | 853 | if( isset( $req_data[ $first_part_to_consider ] ) ){ |
| 854 | 854 | if( empty($html_name_parts ) ){ |
| 855 | 855 | return $req_data[ $first_part_to_consider ]; |
| 856 | - }else{ |
|
| 856 | + } else{ |
|
| 857 | 857 | return $this->_find_form_data_for_this_section_using_name_parts( |
| 858 | 858 | $html_name_parts, |
| 859 | 859 | $req_data[ $first_part_to_consider ] |
| 860 | 860 | ); |
| 861 | 861 | } |
| 862 | - }else{ |
|
| 862 | + } else{ |
|
| 863 | 863 | return NULL; |
| 864 | 864 | } |
| 865 | 865 | } |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | $checked_value = $this->find_form_data_for_this_section( $req_data ); |
| 881 | 881 | if( $checked_value !== null ){ |
| 882 | 882 | return TRUE; |
| 883 | - }else{ |
|
| 883 | + } else{ |
|
| 884 | 884 | return FALSE; |
| 885 | 885 | } |
| 886 | 886 | } |
@@ -8,18 +8,18 @@ discard block |
||
| 8 | 8 | * @since 4.6 |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EE_Required_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 11 | +class EE_Required_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param string $validation_error_message |
| 17 | 17 | */ |
| 18 | - public function __construct( $validation_error_message = null ) { |
|
| 19 | - if( ! $validation_error_message ){ |
|
| 18 | + public function __construct($validation_error_message = null) { |
|
| 19 | + if ( ! $validation_error_message) { |
|
| 20 | 20 | $validation_error_message = __("This field is required.", "event_espresso"); |
| 21 | 21 | } |
| 22 | - parent::__construct( $validation_error_message ); |
|
| 22 | + parent::__construct($validation_error_message); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | * @throws \EE_Validation_Error |
| 35 | 35 | */ |
| 36 | 36 | public function validate($normalized_value) { |
| 37 | - if( |
|
| 37 | + if ( |
|
| 38 | 38 | $normalized_value === '' |
| 39 | 39 | || $normalized_value === null |
| 40 | 40 | || $normalized_value === array() |
| 41 | 41 | ) { |
| 42 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
| 43 | - }else{ |
|
| 42 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
| 43 | + } else { |
|
| 44 | 44 | return true; |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @return array |
| 52 | 52 | * @throws \EE_Error |
| 53 | 53 | */ |
| 54 | - public function get_jquery_validation_rule_array(){ |
|
| 54 | + public function get_jquery_validation_rule_array() { |
|
| 55 | 55 | return array( |
| 56 | 56 | 'required'=> true, |
| 57 | 57 | 'messages' => array( |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @param null $validation_error_message |
| 24 | 24 | */ |
| 25 | - public function __construct( $validation_error_message = null ) { |
|
| 25 | + public function __construct($validation_error_message = null) { |
|
| 26 | 26 | $this->_validation_error_message = $validation_error_message === null |
| 27 | - ? __( 'Input invalid', 'event_espresso' ) |
|
| 27 | + ? __('Input invalid', 'event_espresso') |
|
| 28 | 28 | : $validation_error_message; |
| 29 | 29 | parent::__construct(); |
| 30 | 30 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * this validation strategy is the 'required' validation strategy, |
| 42 | 42 | * most should be OK with a null, empty string, etc) |
| 43 | 43 | */ |
| 44 | - public function validate( $normalized_value ) { |
|
| 44 | + public function validate($normalized_value) { |
|
| 45 | 45 | //by default, the validation strategy does no validation. this should be implemented |
| 46 | 46 | } |
| 47 | 47 | |
@@ -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 | /** |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | * @type $name string the name for this form section, if you want to explicitly define it |
| 80 | 80 | * } |
| 81 | 81 | */ |
| 82 | - public function __construct( $options_array = array() ) { |
|
| 82 | + public function __construct($options_array = array()) { |
|
| 83 | 83 | // used by display strategies |
| 84 | 84 | EE_Registry::instance()->load_helper('HTML'); |
| 85 | 85 | // assign incoming values to properties |
| 86 | - foreach( $options_array as $key => $value ) { |
|
| 87 | - $key = '_' . $key; |
|
| 88 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
| 86 | + foreach ($options_array as $key => $value) { |
|
| 87 | + $key = '_'.$key; |
|
| 88 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
| 89 | 89 | $this->{$key} = $value; |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param $name |
| 99 | 99 | * @throws \EE_Error |
| 100 | 100 | */ |
| 101 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
| 101 | + protected function _construct_finalize($parent_form_section, $name) { |
|
| 102 | 102 | $this->_construction_finalized = TRUE; |
| 103 | 103 | $this->_parent_section = $parent_form_section; |
| 104 | 104 | $this->_name = $name; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | /** |
| 120 | 120 | * @param string $action |
| 121 | 121 | */ |
| 122 | - public function set_action( $action ) { |
|
| 122 | + public function set_action($action) { |
|
| 123 | 123 | $this->_action = $action; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | 131 | public function method() { |
| 132 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
| 132 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | /** |
| 138 | 138 | * @param string $method |
| 139 | 139 | */ |
| 140 | - public function set_method( $method ) { |
|
| 141 | - switch ( $method ) { |
|
| 140 | + public function set_method($method) { |
|
| 141 | + switch ($method) { |
|
| 142 | 142 | case 'get' : |
| 143 | 143 | case 'GET' : |
| 144 | 144 | $this->_method = 'GET'; |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @throws \EE_Error |
| 159 | 159 | */ |
| 160 | - protected function _set_default_html_id_if_empty(){ |
|
| 161 | - if( ! $this->_html_id ){ |
|
| 162 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
| 163 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
| 164 | - }else{ |
|
| 165 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
| 160 | + protected function _set_default_html_id_if_empty() { |
|
| 161 | + if ( ! $this->_html_id) { |
|
| 162 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
| 163 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
| 164 | + } else { |
|
| 165 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | * @param $name |
| 175 | 175 | * @return string |
| 176 | 176 | */ |
| 177 | - private function _prep_name_for_html_id( $name ) { |
|
| 178 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
| 177 | + private function _prep_name_for_html_id($name) { |
|
| 178 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | * @param bool $add_pound_sign |
| 193 | 193 | * @return string |
| 194 | 194 | */ |
| 195 | - public function html_id( $add_pound_sign = FALSE ){ |
|
| 196 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
| 195 | + public function html_id($add_pound_sign = FALSE) { |
|
| 196 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | /** |
| 202 | 202 | * @return string |
| 203 | 203 | */ |
| 204 | - public function html_class(){ |
|
| 204 | + public function html_class() { |
|
| 205 | 205 | return $this->_html_class; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | /** |
| 211 | 211 | * @return string |
| 212 | 212 | */ |
| 213 | - public function html_style(){ |
|
| 213 | + public function html_style() { |
|
| 214 | 214 | return $this->_html_style; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | /** |
| 220 | 220 | * @param mixed $html_class |
| 221 | 221 | */ |
| 222 | - public function set_html_class( $html_class ) { |
|
| 222 | + public function set_html_class($html_class) { |
|
| 223 | 223 | $this->_html_class = $html_class; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | /** |
| 229 | 229 | * @param mixed $html_id |
| 230 | 230 | */ |
| 231 | - public function set_html_id( $html_id ) { |
|
| 231 | + public function set_html_id($html_id) { |
|
| 232 | 232 | $this->_html_id = $html_id; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | /** |
| 238 | 238 | * @param mixed $html_style |
| 239 | 239 | */ |
| 240 | - public function set_html_style( $html_style ) { |
|
| 240 | + public function set_html_style($html_style) { |
|
| 241 | 241 | $this->_html_style = $html_style; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | /** |
| 247 | 247 | * @param string $other_html_attributes |
| 248 | 248 | */ |
| 249 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
| 249 | + public function set_other_html_attributes($other_html_attributes) { |
|
| 250 | 250 | $this->_other_html_attributes = $other_html_attributes; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | * @throws EE_Error |
| 267 | 267 | * @return string |
| 268 | 268 | */ |
| 269 | - public function name(){ |
|
| 270 | - if( ! $this->_construction_finalized ){ |
|
| 271 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
| 269 | + public function name() { |
|
| 270 | + if ( ! $this->_construction_finalized) { |
|
| 271 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
| 272 | 272 | } |
| 273 | 273 | return $this->_name; |
| 274 | 274 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * Gets the parent section |
| 280 | 280 | * @return EE_Form_Section_Proper |
| 281 | 281 | */ |
| 282 | - public function parent_section(){ |
|
| 282 | + public function parent_section() { |
|
| 283 | 283 | return $this->_parent_section; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -292,18 +292,18 @@ discard block |
||
| 292 | 292 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
| 293 | 293 | * @return string |
| 294 | 294 | */ |
| 295 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
| 296 | - if ( ! empty( $action )) { |
|
| 297 | - $this->set_action( $action ); |
|
| 295 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
| 296 | + if ( ! empty($action)) { |
|
| 297 | + $this->set_action($action); |
|
| 298 | 298 | } |
| 299 | - if ( ! empty( $method )) { |
|
| 300 | - $this->set_method( $method ); |
|
| 299 | + if ( ! empty($method)) { |
|
| 300 | + $this->set_method($method); |
|
| 301 | 301 | } |
| 302 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
| 303 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
| 304 | - $html .= ' action="' . $this->action() . '"'; |
|
| 305 | - $html .= ' method="' . $this->method() . '"'; |
|
| 306 | - $html .= $other_attributes . '>'; |
|
| 302 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
| 303 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
| 304 | + $html .= ' action="'.$this->action().'"'; |
|
| 305 | + $html .= ' method="'.$this->method().'"'; |
|
| 306 | + $html .= $other_attributes.'>'; |
|
| 307 | 307 | return $html; |
| 308 | 308 | } |
| 309 | 309 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @return string |
| 315 | 315 | */ |
| 316 | 316 | public function form_close() { |
| 317 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
| 317 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @param array $form_other_js_data |
| 330 | 330 | * @return array |
| 331 | 331 | */ |
| 332 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
| 332 | + public function get_other_js_data($form_other_js_data = array()) { |
|
| 333 | 333 | return $form_other_js_data; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -347,20 +347,20 @@ discard block |
||
| 347 | 347 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
| 348 | 348 | * @return EE_Form_Section_Base |
| 349 | 349 | */ |
| 350 | - public function find_section_from_path( $form_section_path ) { |
|
| 351 | - if( strpos( $form_section_path, '/' ) === 0 ) { |
|
| 352 | - $form_section_path = substr( $form_section_path, strlen( '/' ) ); |
|
| 350 | + public function find_section_from_path($form_section_path) { |
|
| 351 | + if (strpos($form_section_path, '/') === 0) { |
|
| 352 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
| 353 | 353 | } |
| 354 | - if( empty( $form_section_path ) ) { |
|
| 354 | + if (empty($form_section_path)) { |
|
| 355 | 355 | return $this; |
| 356 | 356 | } |
| 357 | - if( strpos( $form_section_path, '../' ) === 0 ) { |
|
| 357 | + if (strpos($form_section_path, '../') === 0) { |
|
| 358 | 358 | $parent = $this->parent_section(); |
| 359 | 359 | |
| 360 | - $form_section_path = substr( $form_section_path, strlen( '../' ) ); |
|
| 361 | - if( $parent instanceof EE_Form_Section_Base ) { |
|
| 362 | - return $parent->find_section_from_path( $form_section_path ); |
|
| 363 | - } elseif( empty( $form_section_path ) ) { |
|
| 360 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
| 361 | + if ($parent instanceof EE_Form_Section_Base) { |
|
| 362 | + return $parent->find_section_from_path($form_section_path); |
|
| 363 | + } elseif (empty($form_section_path)) { |
|
| 364 | 364 | return $this; |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | if( $normalized_value ){ |
| 34 | 34 | if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false){ |
| 35 | 35 | throw new EE_Validation_Error( $this->get_validation_error_message(), 'invalid_url'); |
| 36 | - }else{ |
|
| 36 | + } else{ |
|
| 37 | 37 | EE_Registry::instance()->load_helper('URL'); |
| 38 | 38 | if( ! EEH_URL::remote_file_exists( |
| 39 | 39 | $normalized_value, |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | |
| 18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
| 18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * espresso_get_template_part |
| 21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
| 25 | 25 | * @param string $name The name of the specialised template. |
| 26 | 26 | * @return string the html output for the formatted money value |
| 27 | 27 | */ |
| 28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
| 29 | - EEH_Template::get_template_part( $slug, $name ); |
|
| 28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
| 29 | + EEH_Template::get_template_part($slug, $name); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
| 35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
| 36 | 36 | /** |
| 37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
| 38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @param string $suffix added to the end of the generated class |
| 43 | 43 | * @return string |
| 44 | 44 | */ |
| 45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
| 45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @return boolean |
| 71 | 71 | */ |
| 72 | 72 | public static function is_espresso_theme() { |
| 73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
| 73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | 81 | public static function load_espresso_theme_functions() { |
| 82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
| 83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
| 84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
| 82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
| 83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
| 84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
| 93 | 93 | * @return array |
| 94 | 94 | */ |
| 95 | 95 | public static function get_espresso_themes() { |
| 96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
| 97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
| 98 | - if ( empty( $espresso_themes ) ) { |
|
| 96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
| 97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
| 98 | + if (empty($espresso_themes)) { |
|
| 99 | 99 | return array(); |
| 100 | 100 | } |
| 101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
| 102 | - unset( $espresso_themes[ $key ] ); |
|
| 101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
| 102 | + unset($espresso_themes[$key]); |
|
| 103 | 103 | } |
| 104 | 104 | EEH_Template::$_espresso_themes = array(); |
| 105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
| 106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
| 105 | + foreach ($espresso_themes as $espresso_theme) { |
|
| 106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * @param bool $return_string |
| 123 | 123 | * @return string the html output for the formatted money value |
| 124 | 124 | */ |
| 125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
| 126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
| 125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
| 126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
| 127 | 127 | $templates = array(); |
| 128 | 128 | $name = (string) $name; |
| 129 | - if ( $name != '' ) { |
|
| 129 | + if ($name != '') { |
|
| 130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
| 131 | 131 | } |
| 132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
| 133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
| 134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
| 133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
| 134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -182,26 +182,26 @@ discard block |
||
| 182 | 182 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
| 183 | 183 | * @return mixed |
| 184 | 184 | */ |
| 185 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
| 185 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
| 186 | 186 | // first use WP locate_template to check for template in the current theme folder |
| 187 | - $template_path = locate_template( $templates ); |
|
| 187 | + $template_path = locate_template($templates); |
|
| 188 | 188 | |
| 189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
| 189 | + if ($check_if_custom && ! empty($template_path)) |
|
| 190 | 190 | return TRUE; |
| 191 | 191 | |
| 192 | 192 | // not in the theme |
| 193 | - if ( empty( $template_path )) { |
|
| 193 | + if (empty($template_path)) { |
|
| 194 | 194 | // not even a template to look for ? |
| 195 | - if ( empty( $templates )) { |
|
| 195 | + if (empty($templates)) { |
|
| 196 | 196 | // get post_type |
| 197 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
| 197 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
| 198 | 198 | // get array of EE Custom Post Types |
| 199 | 199 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
| 200 | 200 | // build template name based on request |
| 201 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
| 202 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 203 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 204 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
| 201 | + if (isset($EE_CPTs[$post_type])) { |
|
| 202 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
| 203 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
| 204 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | // currently active EE template theme |
@@ -210,82 +210,82 @@ discard block |
||
| 210 | 210 | // array of paths to folders that may contain templates |
| 211 | 211 | $template_folder_paths = array( |
| 212 | 212 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
| 213 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
| 213 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
| 214 | 214 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
| 215 | 215 | EVENT_ESPRESSO_TEMPLATE_DIR |
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | 218 | //add core plugin folders for checking only if we're not $check_if_custom |
| 219 | - if ( ! $check_if_custom ) { |
|
| 219 | + if ( ! $check_if_custom) { |
|
| 220 | 220 | $core_paths = array( |
| 221 | 221 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
| 222 | - EE_PUBLIC . $current_theme, |
|
| 222 | + EE_PUBLIC.$current_theme, |
|
| 223 | 223 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
| 224 | - EE_TEMPLATES . $current_theme, |
|
| 224 | + EE_TEMPLATES.$current_theme, |
|
| 225 | 225 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
| 226 | 226 | EE_PLUGIN_DIR_PATH |
| 227 | 227 | ); |
| 228 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
| 228 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // now filter that array |
| 232 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
| 233 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
| 234 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
| 232 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
| 233 | + $templates = is_array($templates) ? $templates : array($templates); |
|
| 234 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
| 235 | 235 | // array to hold all possible template paths |
| 236 | 236 | $full_template_paths = array(); |
| 237 | 237 | |
| 238 | 238 | EE_Registry::instance()->load_helper('File'); |
| 239 | 239 | // loop through $templates |
| 240 | - foreach ( $templates as $template ) { |
|
| 240 | + foreach ($templates as $template) { |
|
| 241 | 241 | // normalize directory separators |
| 242 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
| 243 | - $file_name = basename( $template ); |
|
| 244 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
| 242 | + $template = EEH_File::standardise_directory_separators($template); |
|
| 243 | + $file_name = basename($template); |
|
| 244 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
| 245 | 245 | // while looping through all template folder paths |
| 246 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
| 246 | + foreach ($template_folder_paths as $template_folder_path) { |
|
| 247 | 247 | // normalize directory separators |
| 248 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
| 248 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
| 249 | 249 | // determine if any common base path exists between the two paths |
| 250 | 250 | $common_base_path = EEH_Template::_find_common_base_path( |
| 251 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
| 251 | + array($template_folder_path, $template_path_minus_file_name) |
|
| 252 | 252 | ); |
| 253 | - if ( $common_base_path !== '' ) { |
|
| 253 | + if ($common_base_path !== '') { |
|
| 254 | 254 | // both paths have a common base, so just tack the filename onto our search path |
| 255 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
| 255 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
| 256 | 256 | } else { |
| 257 | 257 | // no common base path, so let's just concatenate |
| 258 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
| 258 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
| 259 | 259 | } |
| 260 | 260 | // build up our template locations array by adding our resolved paths |
| 261 | 261 | $full_template_paths[] = $resolved_path; |
| 262 | 262 | } |
| 263 | 263 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
| 264 | - array_unshift( $full_template_paths, $template ); |
|
| 264 | + array_unshift($full_template_paths, $template); |
|
| 265 | 265 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
| 266 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
| 266 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
| 267 | 267 | } |
| 268 | 268 | // filter final array of full template paths |
| 269 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
| 269 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
| 270 | 270 | // now loop through our final array of template location paths and check each location |
| 271 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
| 272 | - if ( is_readable( $full_template_path )) { |
|
| 273 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
| 271 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
| 272 | + if (is_readable($full_template_path)) { |
|
| 273 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
| 274 | 274 | // hook that can be used to display the full template path that will be used |
| 275 | - do_action( 'AHEE__EEH_Template__locate_template__full_template_path', $template_path ); |
|
| 275 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
| 276 | 276 | break; |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | // if we got it and you want to see it... |
| 281 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
| 282 | - if ( $return_string ) { |
|
| 283 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 281 | + if ($template_path && $load && ! $check_if_custom) { |
|
| 282 | + if ($return_string) { |
|
| 283 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 284 | 284 | } else { |
| 285 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
| 285 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
| 288 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -298,21 +298,21 @@ discard block |
||
| 298 | 298 | * @param array $paths |
| 299 | 299 | * @return string |
| 300 | 300 | */ |
| 301 | - protected static function _find_common_base_path( $paths ) { |
|
| 301 | + protected static function _find_common_base_path($paths) { |
|
| 302 | 302 | $last_offset = 0; |
| 303 | 303 | $common_base_path = ''; |
| 304 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
| 304 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
| 305 | 305 | $dir_length = $index - $last_offset + 1; |
| 306 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
| 307 | - foreach ( $paths as $path ) { |
|
| 308 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
| 306 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
| 307 | + foreach ($paths as $path) { |
|
| 308 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
| 309 | 309 | return $common_base_path; |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | $common_base_path .= $directory; |
| 313 | 313 | $last_offset = $index + 1; |
| 314 | 314 | } |
| 315 | - return substr( $common_base_path, 0, -1 ); |
|
| 315 | + return substr($common_base_path, 0, -1); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
| 325 | 325 | * @return mixed string |
| 326 | 326 | */ |
| 327 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
| 327 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
| 328 | 328 | //require the template validator for verifying variables are set according to how the template requires |
| 329 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
| 329 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | 332 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -337,26 +337,26 @@ discard block |
||
| 337 | 337 | * |
| 338 | 338 | * @since 4.6.0 |
| 339 | 339 | */ |
| 340 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
| 341 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
| 340 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
| 341 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
| 342 | 342 | |
| 343 | 343 | // you gimme nuttin - YOU GET NUTTIN !! |
| 344 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
| 344 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
| 345 | 345 | return ''; |
| 346 | 346 | } |
| 347 | 347 | // if $template_args are not in an array, then make it so |
| 348 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
| 349 | - $template_args = array( $template_args ); |
|
| 348 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
| 349 | + $template_args = array($template_args); |
|
| 350 | 350 | } |
| 351 | - extract( (array) $template_args); |
|
| 351 | + extract((array) $template_args); |
|
| 352 | 352 | |
| 353 | - if ( $return_string ) { |
|
| 353 | + if ($return_string) { |
|
| 354 | 354 | // because we want to return a string, we are going to capture the output |
| 355 | 355 | ob_start(); |
| 356 | - include( $template_path ); |
|
| 356 | + include($template_path); |
|
| 357 | 357 | return ob_get_clean(); |
| 358 | 358 | } else { |
| 359 | - include( $template_path ); |
|
| 359 | + include($template_path); |
|
| 360 | 360 | } |
| 361 | 361 | return ''; |
| 362 | 362 | } |
@@ -374,27 +374,27 @@ discard block |
||
| 374 | 374 | * @param string $suffix added to the end of the generated class |
| 375 | 375 | * @return string |
| 376 | 376 | */ |
| 377 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
| 377 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
| 378 | 378 | // in the beginning... |
| 379 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
| 379 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
| 380 | 380 | // da muddle |
| 381 | 381 | $class = ''; |
| 382 | 382 | // the end |
| 383 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
| 383 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
| 384 | 384 | // is the passed object an EE object ? |
| 385 | - if ( $object instanceof EE_Base_Class ) { |
|
| 385 | + if ($object instanceof EE_Base_Class) { |
|
| 386 | 386 | // grab the exact type of object |
| 387 | - $obj_class = get_class( $object ); |
|
| 387 | + $obj_class = get_class($object); |
|
| 388 | 388 | // depending on the type of object... |
| 389 | - switch ( $obj_class ) { |
|
| 389 | + switch ($obj_class) { |
|
| 390 | 390 | // no specifics just yet... |
| 391 | 391 | default : |
| 392 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
| 393 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
| 392 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
| 393 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
| 394 | 394 | |
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | - return $prefix . $class . $suffix; |
|
| 397 | + return $prefix.$class.$suffix; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | |
@@ -410,50 +410,50 @@ discard block |
||
| 410 | 410 | * @param string $cur_code_span_class |
| 411 | 411 | * @return string the html output for the formatted money value |
| 412 | 412 | */ |
| 413 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
| 413 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
| 414 | 414 | // ensure amount was received |
| 415 | - if ( is_null( $amount ) ) { |
|
| 416 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
| 417 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 415 | + if (is_null($amount)) { |
|
| 416 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
| 417 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 418 | 418 | return ''; |
| 419 | 419 | } |
| 420 | 420 | //ensure amount is float |
| 421 | 421 | $amount = (float) $amount; |
| 422 | 422 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
| 423 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
| 423 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
| 424 | 424 | // still a number or was amount converted to a string like "free" ? |
| 425 | - if ( is_float( $amount_formatted )) { |
|
| 425 | + if (is_float($amount_formatted)) { |
|
| 426 | 426 | // was a country ISO code passed ? if so generate currency config object for that country |
| 427 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
| 427 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
| 428 | 428 | // verify results |
| 429 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
| 429 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
| 430 | 430 | // set default config country currency settings |
| 431 | 431 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
| 432 | 432 | } |
| 433 | 433 | // format float |
| 434 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
| 434 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
| 435 | 435 | // add formatting ? |
| 436 | - if ( ! $return_raw ) { |
|
| 436 | + if ( ! $return_raw) { |
|
| 437 | 437 | // add currency sign |
| 438 | - if( $mny->sign_b4 ){ |
|
| 439 | - if( $amount >= 0 ){ |
|
| 440 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
| 441 | - }else{ |
|
| 442 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
| 438 | + if ($mny->sign_b4) { |
|
| 439 | + if ($amount >= 0) { |
|
| 440 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
| 441 | + } else { |
|
| 442 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - }else{ |
|
| 446 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
| 445 | + } else { |
|
| 446 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // add currency code ? |
| 450 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
| 450 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
| 451 | 451 | } |
| 452 | 452 | // filter results |
| 453 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
| 453 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
| 454 | 454 | } |
| 455 | 455 | // clean up vars |
| 456 | - unset( $mny ); |
|
| 456 | + unset($mny); |
|
| 457 | 457 | // return formatted currency amount |
| 458 | 458 | return $amount_formatted; |
| 459 | 459 | } |
@@ -468,11 +468,11 @@ discard block |
||
| 468 | 468 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
| 469 | 469 | * @return string The localized label for the status id. |
| 470 | 470 | */ |
| 471 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
| 471 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
| 472 | 472 | /** @type EEM_Status $EEM_Status */ |
| 473 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
| 474 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
| 475 | - return $status[ $status_id ]; |
|
| 473 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
| 474 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
| 475 | + return $status[$status_id]; |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -485,9 +485,9 @@ discard block |
||
| 485 | 485 | * @param string $icon |
| 486 | 486 | * @return string the html output for the button |
| 487 | 487 | */ |
| 488 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
| 489 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
| 490 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
| 488 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
| 489 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
| 490 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
| 491 | 491 | return $button; |
| 492 | 492 | } |
| 493 | 493 | |
@@ -504,21 +504,21 @@ discard block |
||
| 504 | 504 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
| 505 | 505 | * @return string generated link |
| 506 | 506 | */ |
| 507 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
| 507 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
| 508 | 508 | |
| 509 | - if ( ! $page ) |
|
| 510 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
| 509 | + if ( ! $page) |
|
| 510 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
| 511 | 511 | |
| 512 | - if ( ! $action ) |
|
| 513 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
| 512 | + if ( ! $action) |
|
| 513 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
| 514 | 514 | |
| 515 | 515 | $action = empty($action) ? 'default' : $action; |
| 516 | 516 | |
| 517 | 517 | |
| 518 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
| 519 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 520 | - $help_text = !$help_text ? '' : $help_text; |
|
| 521 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
| 518 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
| 519 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
| 520 | + $help_text = ! $help_text ? '' : $help_text; |
|
| 521 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | |
@@ -530,31 +530,31 @@ discard block |
||
| 530 | 530 | * @param EE_Help_Tour |
| 531 | 531 | * @return string html |
| 532 | 532 | */ |
| 533 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
| 533 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
| 534 | 534 | $id = $tour->get_slug(); |
| 535 | 535 | $stops = $tour->get_stops(); |
| 536 | 536 | |
| 537 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
| 537 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
| 538 | 538 | |
| 539 | - foreach ( $stops as $stop ) { |
|
| 540 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
| 541 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
| 539 | + foreach ($stops as $stop) { |
|
| 540 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
| 541 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
| 542 | 542 | |
| 543 | 543 | //if container is set to modal then let's make sure we set the options accordingly |
| 544 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
| 544 | + if (empty($data_id) && empty($data_class)) { |
|
| 545 | 545 | $stop['options']['modal'] = true; |
| 546 | 546 | $stop['options']['expose'] = true; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
| 550 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
| 549 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
| 550 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
| 551 | 551 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
| 552 | 552 | |
| 553 | 553 | //options |
| 554 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
| 554 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
| 555 | 555 | $options = ' data-options="'; |
| 556 | - foreach ( $stop['options'] as $option => $value ) { |
|
| 557 | - $options .= $option . ':' . $value . ';'; |
|
| 556 | + foreach ($stop['options'] as $option => $value) { |
|
| 557 | + $options .= $option.':'.$value.';'; |
|
| 558 | 558 | } |
| 559 | 559 | $options .= '"'; |
| 560 | 560 | } else { |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | //let's put all together |
| 565 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
| 565 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | $content .= '</ol>'; |
@@ -583,31 +583,31 @@ discard block |
||
| 583 | 583 | * @throws EE_Error |
| 584 | 584 | * @return string html structure for status. |
| 585 | 585 | */ |
| 586 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
| 587 | - if ( !is_array( $status_array ) ) |
|
| 588 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
| 586 | + public static function status_legend($status_array, $active_status = '') { |
|
| 587 | + if ( ! is_array($status_array)) |
|
| 588 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
| 589 | 589 | |
| 590 | 590 | $setup_array = array(); |
| 591 | - foreach ( $status_array as $item => $status ) { |
|
| 591 | + foreach ($status_array as $item => $status) { |
|
| 592 | 592 | $setup_array[$item] = array( |
| 593 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
| 594 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
| 593 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
| 594 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
| 595 | 595 | 'status' => $status |
| 596 | 596 | ); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
| 600 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
| 601 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
| 602 | - foreach ( $setup_array as $item => $details ) { |
|
| 599 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
| 600 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
| 601 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
| 602 | + foreach ($setup_array as $item => $details) { |
|
| 603 | 603 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
| 604 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
| 605 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
| 606 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
| 607 | - $content .= '</dt>' . "\n"; |
|
| 604 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
| 605 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
| 606 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
| 607 | + $content .= '</dt>'."\n"; |
|
| 608 | 608 | } |
| 609 | - $content .= '</dl>' . "\n"; |
|
| 610 | - $content .= '</div>' . "\n"; |
|
| 609 | + $content .= '</dl>'."\n"; |
|
| 610 | + $content .= '</div>'."\n"; |
|
| 611 | 611 | return $content; |
| 612 | 612 | } |
| 613 | 613 | |
@@ -620,8 +620,8 @@ discard block |
||
| 620 | 620 | * @return string |
| 621 | 621 | */ |
| 622 | 622 | public static function layout_array_as_table($data) { |
| 623 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
| 624 | - $data = (array)$data; |
|
| 623 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
| 624 | + $data = (array) $data; |
|
| 625 | 625 | } |
| 626 | 626 | EE_Registry::instance()->load_helper('Array'); |
| 627 | 627 | ob_start(); |
@@ -635,10 +635,10 @@ discard block |
||
| 635 | 635 | ?> |
| 636 | 636 | <tr> |
| 637 | 637 | <td> |
| 638 | - <?php echo $data_key;?> |
|
| 638 | + <?php echo $data_key; ?> |
|
| 639 | 639 | </td> |
| 640 | 640 | <td> |
| 641 | - <?php echo self::layout_array_as_table($data_values);?> |
|
| 641 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
| 642 | 642 | </td> |
| 643 | 643 | </tr> |
| 644 | 644 | <?php |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | <ul> |
| 653 | 653 | <?php |
| 654 | 654 | foreach ($data as $datum) { |
| 655 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
| 655 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
| 656 | 656 | }?> |
| 657 | 657 | </ul> |
| 658 | 658 | <?php |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | * |
| 683 | 683 | * @return string |
| 684 | 684 | */ |
| 685 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 686 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
| 685 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 686 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | |
@@ -707,13 +707,13 @@ discard block |
||
| 707 | 707 | * ) |
| 708 | 708 | * @return string |
| 709 | 709 | */ |
| 710 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
| 710 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
| 711 | 711 | $page_links = array(); |
| 712 | 712 | $disable_first = $disable_last = ''; |
| 713 | 713 | $total_items = (int) $total_items; |
| 714 | 714 | $per_page = (int) $per_page; |
| 715 | 715 | $current = (int) $current; |
| 716 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
| 716 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
| 717 | 717 | |
| 718 | 718 | //filter items_label |
| 719 | 719 | $items_label = apply_filters( |
@@ -721,68 +721,68 @@ discard block |
||
| 721 | 721 | $items_label |
| 722 | 722 | ); |
| 723 | 723 | |
| 724 | - if ( empty( $items_label ) |
|
| 725 | - || ! is_array( $items_label ) |
|
| 726 | - || ! isset( $items_label['single'] ) |
|
| 727 | - || ! isset( $items_label['plural'] ) ) { |
|
| 724 | + if (empty($items_label) |
|
| 725 | + || ! is_array($items_label) |
|
| 726 | + || ! isset($items_label['single']) |
|
| 727 | + || ! isset($items_label['plural'])) { |
|
| 728 | 728 | $items_label = array( |
| 729 | - 'single' => __( '1 item', 'event_espresso' ), |
|
| 730 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
| 729 | + 'single' => __('1 item', 'event_espresso'), |
|
| 730 | + 'plural' => __('%s items', 'event_espresso') |
|
| 731 | 731 | ); |
| 732 | 732 | } else { |
| 733 | 733 | $items_label = array( |
| 734 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
| 735 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
| 734 | + 'single' => '1 '.esc_html($items_label['single']), |
|
| 735 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
| 736 | 736 | ); |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 739 | + $total_pages = ceil($total_items / $per_page); |
|
| 740 | 740 | |
| 741 | - if ( $total_pages <= 1 ) |
|
| 741 | + if ($total_pages <= 1) |
|
| 742 | 742 | return ''; |
| 743 | 743 | |
| 744 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
| 744 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
| 745 | 745 | |
| 746 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
| 746 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
| 747 | 747 | |
| 748 | - if ( $current === 1 ) { |
|
| 748 | + if ($current === 1) { |
|
| 749 | 749 | $disable_first = ' disabled'; |
| 750 | 750 | } |
| 751 | - if ( $current == $total_pages ) { |
|
| 751 | + if ($current == $total_pages) { |
|
| 752 | 752 | $disable_last = ' disabled'; |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 756 | - 'first-page' . $disable_first, |
|
| 757 | - esc_attr__( 'Go to the first page' ), |
|
| 758 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
| 755 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
| 756 | + 'first-page'.$disable_first, |
|
| 757 | + esc_attr__('Go to the first page'), |
|
| 758 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
| 759 | 759 | '«' |
| 760 | 760 | ); |
| 761 | 761 | |
| 762 | 762 | $page_links[] = sprintf( |
| 763 | 763 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 764 | - 'prev-page' . $disable_first, |
|
| 765 | - esc_attr__( 'Go to the previous page' ), |
|
| 766 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
| 764 | + 'prev-page'.$disable_first, |
|
| 765 | + esc_attr__('Go to the previous page'), |
|
| 766 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
| 767 | 767 | '‹' |
| 768 | 768 | ); |
| 769 | 769 | |
| 770 | - if ( ! $show_num_field ) { |
|
| 770 | + if ( ! $show_num_field) { |
|
| 771 | 771 | $html_current_page = $current; |
| 772 | 772 | } else { |
| 773 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 774 | - esc_attr__( 'Current page' ), |
|
| 773 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
| 774 | + esc_attr__('Current page'), |
|
| 775 | 775 | $current, |
| 776 | - strlen( $total_pages ) |
|
| 776 | + strlen($total_pages) |
|
| 777 | 777 | ); |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | $html_total_pages = sprintf( |
| 781 | 781 | '<span class="total-pages">%s</span>', |
| 782 | - number_format_i18n( $total_pages ) |
|
| 782 | + number_format_i18n($total_pages) |
|
| 783 | 783 | ); |
| 784 | 784 | $page_links[] = sprintf( |
| 785 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
| 785 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
| 786 | 786 | $html_current_page, |
| 787 | 787 | $html_total_pages, |
| 788 | 788 | '<span class="paging-input">', |
@@ -791,29 +791,29 @@ discard block |
||
| 791 | 791 | |
| 792 | 792 | $page_links[] = sprintf( |
| 793 | 793 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 794 | - 'next-page' . $disable_last, |
|
| 795 | - esc_attr__( 'Go to the next page' ), |
|
| 796 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
| 794 | + 'next-page'.$disable_last, |
|
| 795 | + esc_attr__('Go to the next page'), |
|
| 796 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
| 797 | 797 | '›' |
| 798 | 798 | ); |
| 799 | 799 | |
| 800 | 800 | $page_links[] = sprintf( |
| 801 | 801 | '<a class="%s" title="%s" href="%s">%s</a>', |
| 802 | - 'last-page' . $disable_last, |
|
| 803 | - esc_attr__( 'Go to the last page' ), |
|
| 804 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
| 802 | + 'last-page'.$disable_last, |
|
| 803 | + esc_attr__('Go to the last page'), |
|
| 804 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
| 805 | 805 | '»' |
| 806 | 806 | ); |
| 807 | 807 | |
| 808 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
| 808 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
| 809 | 809 | // set page class |
| 810 | - if ( $total_pages ) { |
|
| 810 | + if ($total_pages) { |
|
| 811 | 811 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 812 | 812 | } else { |
| 813 | 813 | $page_class = ' no-pages'; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
| 816 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
| 830 | 830 | |
| 831 | 831 | |
| 832 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
| 832 | +if ( ! function_exists('espresso_pagination')) { |
|
| 833 | 833 | /** |
| 834 | 834 | * espresso_pagination |
| 835 | 835 | * |
@@ -841,21 +841,21 @@ discard block |
||
| 841 | 841 | $big = 999999999; // need an unlikely integer |
| 842 | 842 | $pagination = paginate_links( |
| 843 | 843 | array( |
| 844 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 844 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 845 | 845 | 'format' => '?paged=%#%', |
| 846 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
| 846 | + 'current' => max(1, get_query_var('paged')), |
|
| 847 | 847 | 'total' => $wp_query->max_num_pages, |
| 848 | 848 | 'show_all' => true, |
| 849 | 849 | 'end_size' => 10, |
| 850 | 850 | 'mid_size' => 6, |
| 851 | 851 | 'prev_next' => true, |
| 852 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
| 853 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
| 852 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
| 853 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
| 854 | 854 | 'type' => 'plain', |
| 855 | 855 | 'add_args' => false, |
| 856 | 856 | 'add_fragment' => '' |
| 857 | 857 | ) |
| 858 | 858 | ); |
| 859 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
| 859 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
| 860 | 860 | } |
| 861 | 861 | } |
| 862 | 862 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @since 4.6 |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EE_Conditionally_Required_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 11 | +class EE_Conditionally_Required_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Array describing conditions necessary to make the input required. |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | * @param string $validation_error_message |
| 25 | 25 | * @param array $requirement_conditions |
| 26 | 26 | */ |
| 27 | - public function __construct( $validation_error_message = null, $requirement_conditions = array() ) { |
|
| 28 | - if( ! $validation_error_message ){ |
|
| 27 | + public function __construct($validation_error_message = null, $requirement_conditions = array()) { |
|
| 28 | + if ( ! $validation_error_message) { |
|
| 29 | 29 | $validation_error_message = __("This field is required.", "event_espresso"); |
| 30 | 30 | } |
| 31 | - $this->set_requirement_conditions( $requirement_conditions ); |
|
| 32 | - parent::__construct( $validation_error_message ); |
|
| 31 | + $this->set_requirement_conditions($requirement_conditions); |
|
| 32 | + parent::__construct($validation_error_message); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @throws \EE_Validation_Error |
| 45 | 45 | */ |
| 46 | 46 | public function validate($normalized_value) { |
| 47 | - if( |
|
| 47 | + if ( |
|
| 48 | 48 | ( |
| 49 | 49 | $normalized_value === '' |
| 50 | 50 | || $normalized_value === null |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | ) |
| 53 | 53 | && $this->_input_is_required_server_side() |
| 54 | 54 | ) { |
| 55 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
| 56 | - }else{ |
|
| 55 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
| 56 | + } else { |
|
| 57 | 57 | return true; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @return array |
| 65 | 65 | * @throws \EE_Error |
| 66 | 66 | */ |
| 67 | - public function get_jquery_validation_rule_array(){ |
|
| 67 | + public function get_jquery_validation_rule_array() { |
|
| 68 | 68 | return array( |
| 69 | 69 | 'required'=> $this->_get_jquery_requirement_value(), |
| 70 | 70 | 'messages' => array( |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @param array $requirement_conditions |
| 84 | 84 | */ |
| 85 | - public function set_requirement_conditions( $requirement_conditions ) { |
|
| 85 | + public function set_requirement_conditions($requirement_conditions) { |
|
| 86 | 86 | $this->requirement_conditions = (array) $requirement_conditions; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | protected function _get_jquery_requirement_value() { |
| 109 | 109 | $requirement_value = ''; |
| 110 | 110 | $conditions = $this->get_requirement_conditions(); |
| 111 | - if( ! is_array( $conditions ) ){ |
|
| 111 | + if ( ! is_array($conditions)) { |
|
| 112 | 112 | EE_Error::throw_exception_if_debugging( |
| 113 | 113 | sprintf( |
| 114 | - __( 'Input requirement conditions must be an array. You provided %1$s', 'event_espresso' ), |
|
| 114 | + __('Input requirement conditions must be an array. You provided %1$s', 'event_espresso'), |
|
| 115 | 115 | $this->_input->name() |
| 116 | 116 | ), |
| 117 | 117 | __FILE__, |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | ); |
| 121 | 121 | return true; |
| 122 | 122 | } |
| 123 | - if( count( $conditions ) > 1 ) { |
|
| 123 | + if (count($conditions) > 1) { |
|
| 124 | 124 | EE_Error::throw_exception_if_debugging( |
| 125 | 125 | sprintf( |
| 126 | - __( 'Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso' ), |
|
| 126 | + __('Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso'), |
|
| 127 | 127 | $this->_input->name() |
| 128 | 128 | ), |
| 129 | 129 | __FILE__, |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | __LINE__ |
| 132 | 132 | ); |
| 133 | 133 | } |
| 134 | - foreach( $conditions as $input_path => $op_and_value ) { |
|
| 135 | - $input = $this->_input->find_section_from_path( $input_path ); |
|
| 136 | - if( ! $input instanceof EE_Form_Input_Base ) { |
|
| 134 | + foreach ($conditions as $input_path => $op_and_value) { |
|
| 135 | + $input = $this->_input->find_section_from_path($input_path); |
|
| 136 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
| 137 | 137 | EE_Error::throw_exception_if_debugging( |
| 138 | 138 | sprintf( |
| 139 | - __( 'Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
| 139 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
| 140 | 140 | $this->_input->name(), |
| 141 | 141 | $input_path |
| 142 | 142 | ), |
@@ -146,14 +146,14 @@ discard block |
||
| 146 | 146 | ); |
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | - list( $op, $value ) = $this->_validate_op_and_value( $op_and_value ); |
|
| 149 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
| 150 | 150 | //ok now the jquery dependency expression depends on the input's display strategy. |
| 151 | - if( ! $input->get_display_strategy() instanceof EE_Select_Display_Strategy ) { |
|
| 151 | + if ( ! $input->get_display_strategy() instanceof EE_Select_Display_Strategy) { |
|
| 152 | 152 | EE_Error::throw_exception_if_debugging( |
| 153 | 153 | sprintf( |
| 154 | - __( 'Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso' ), |
|
| 154 | + __('Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso'), |
|
| 155 | 155 | $input->name(), |
| 156 | - get_class( $input->get_display_strategy() ), |
|
| 156 | + get_class($input->get_display_strategy()), |
|
| 157 | 157 | $this->_input->name() |
| 158 | 158 | ), |
| 159 | 159 | __FILE__, |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | __LINE__ |
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | - $requirement_value = $input->html_id( true ) . ' option[value="' . $value . '"]:selected'; |
|
| 164 | + $requirement_value = $input->html_id(true).' option[value="'.$value.'"]:selected'; |
|
| 165 | 165 | } |
| 166 | 166 | return $requirement_value; |
| 167 | 167 | } |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | protected function _input_is_required_server_side() { |
| 180 | 180 | $meets_all_requirements = true; |
| 181 | 181 | $conditions = $this->get_requirement_conditions(); |
| 182 | - foreach( $conditions as $input_path => $op_and_value ) { |
|
| 183 | - $input = $this->_input->find_section_from_path( $input_path ); |
|
| 184 | - if( ! $input instanceof EE_Form_Input_Base ) { |
|
| 182 | + foreach ($conditions as $input_path => $op_and_value) { |
|
| 183 | + $input = $this->_input->find_section_from_path($input_path); |
|
| 184 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
| 185 | 185 | EE_Error::throw_exception_if_debugging( |
| 186 | 186 | sprintf( |
| 187 | - __( 'Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
| 187 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
| 188 | 188 | $this->_input->name(), |
| 189 | 189 | $input_path |
| 190 | 190 | ), |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | ); |
| 195 | 195 | return false; |
| 196 | 196 | } |
| 197 | - list( $op, $value ) = $this->_validate_op_and_value( $op_and_value ); |
|
| 198 | - switch( $op ) { |
|
| 197 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
| 198 | + switch ($op) { |
|
| 199 | 199 | case '=': |
| 200 | 200 | default: |
| 201 | 201 | $meets_all_requirements = $input->normalized_value() === $value; |
| 202 | 202 | } |
| 203 | - if( ! $meets_all_requirements ) { |
|
| 203 | + if ( ! $meets_all_requirements) { |
|
| 204 | 204 | break; |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | * @return array |
| 218 | 218 | * @throws \EE_Error |
| 219 | 219 | */ |
| 220 | - protected function _validate_op_and_value( $op_and_value ) { |
|
| 221 | - if( ! isset( $op_and_value[ 0 ], $op_and_value[ 1 ] ) ) { |
|
| 220 | + protected function _validate_op_and_value($op_and_value) { |
|
| 221 | + if ( ! isset($op_and_value[0], $op_and_value[1])) { |
|
| 222 | 222 | EE_Error::throw_exception_if_debugging( |
| 223 | 223 | sprintf( |
| 224 | - __( 'Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso' ), |
|
| 224 | + __('Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso'), |
|
| 225 | 225 | $this->_input->name() |
| 226 | 226 | ), |
| 227 | 227 | __FILE__, |
@@ -229,12 +229,12 @@ discard block |
||
| 229 | 229 | __LINE__ |
| 230 | 230 | ); |
| 231 | 231 | } |
| 232 | - $operator = $op_and_value[ 0 ]; |
|
| 233 | - $value = (string) $op_and_value[ 1 ]; |
|
| 234 | - if( $operator !== '=' ) { |
|
| 232 | + $operator = $op_and_value[0]; |
|
| 233 | + $value = (string) $op_and_value[1]; |
|
| 234 | + if ($operator !== '=') { |
|
| 235 | 235 | EE_Error::throw_exception_if_debugging( |
| 236 | 236 | sprintf( |
| 237 | - __( 'Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso' ), |
|
| 237 | + __('Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso'), |
|
| 238 | 238 | $this->_input->name() |
| 239 | 239 | ), |
| 240 | 240 | __FILE__, |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | __LINE__ |
| 243 | 243 | ); |
| 244 | 244 | } |
| 245 | - return array( $operator, $value ); |
|
| 245 | + return array($operator, $value); |
|
| 246 | 246 | |
| 247 | 247 | } |
| 248 | 248 | } |