@@ -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 | * Single Page Checkout (SPCO) |
| 4 | 4 | * |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | * @return EED_Single_Page_Checkout |
| 48 | 48 | */ |
| 49 | 49 | public static function instance() { |
| 50 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
| 51 | - return parent::get_instance( __CLASS__ ); |
|
| 50 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
| 51 | + return parent::get_instance(__CLASS__); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -93,22 +93,22 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public static function set_hooks_admin() { |
| 95 | 95 | EED_Single_Page_Checkout::set_definitions(); |
| 96 | - if ( defined( 'DOING_AJAX' )) { |
|
| 96 | + if (defined('DOING_AJAX')) { |
|
| 97 | 97 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
| 98 | 98 | ob_start(); |
| 99 | 99 | EED_Single_Page_Checkout::load_request_handler(); |
| 100 | 100 | EED_Single_Page_Checkout::load_reg_steps(); |
| 101 | 101 | } else { |
| 102 | 102 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
| 103 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
| 103 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
| 104 | 104 | } |
| 105 | 105 | // set ajax hooks |
| 106 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
| 107 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
| 108 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
| 109 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
| 110 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
| 111 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
| 106 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 107 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
| 108 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 109 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
| 110 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 111 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @param string $ajax_action |
| 120 | 120 | * @throws \EE_Error |
| 121 | 121 | */ |
| 122 | - public static function process_ajax_request( $ajax_action ) { |
|
| 123 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
| 122 | + public static function process_ajax_request($ajax_action) { |
|
| 123 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
| 124 | 124 | EED_Single_Page_Checkout::instance()->_initialize(); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @throws \EE_Error |
| 133 | 133 | */ |
| 134 | 134 | public static function display_reg_step() { |
| 135 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
| 135 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @throws \EE_Error |
| 144 | 144 | */ |
| 145 | 145 | public static function process_reg_step() { |
| 146 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
| 146 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @throws \EE_Error |
| 155 | 155 | */ |
| 156 | 156 | public static function update_reg_step() { |
| 157 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
| 157 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @throws \EE_Error |
| 168 | 168 | */ |
| 169 | 169 | public static function update_checkout() { |
| 170 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
| 170 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public static function load_request_handler() { |
| 182 | 182 | // load core Request_Handler class |
| 183 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
| 184 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
| 183 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
| 184 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | * @throws \EE_Error |
| 196 | 196 | */ |
| 197 | 197 | public static function set_definitions() { |
| 198 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
| 199 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
| 200 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
| 201 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
| 202 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
| 203 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
| 204 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
| 205 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
| 198 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
| 199 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
| 200 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
| 201 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
| 202 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
| 203 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
| 204 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
| 205 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public static function load_reg_steps() { |
| 219 | 219 | static $reg_steps_loaded = FALSE; |
| 220 | - if ( $reg_steps_loaded ) { |
|
| 220 | + if ($reg_steps_loaded) { |
|
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | 223 | // filter list of reg_steps |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | EED_Single_Page_Checkout::get_reg_steps() |
| 227 | 227 | ); |
| 228 | 228 | // sort by key (order) |
| 229 | - ksort( $reg_steps_to_load ); |
|
| 229 | + ksort($reg_steps_to_load); |
|
| 230 | 230 | // loop through folders |
| 231 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
| 231 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
| 232 | 232 | // we need a |
| 233 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
| 233 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 234 | 234 | // copy over to the reg_steps_array |
| 235 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
| 235 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
| 236 | 236 | // register custom key route for each reg step |
| 237 | 237 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
| 238 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
| 238 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
| 239 | 239 | // add AJAX or other hooks |
| 240 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
| 240 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
| 241 | 241 | // setup autoloaders if necessary |
| 242 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
| 243 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
| 242 | + if ( ! class_exists($reg_step['class_name'])) { |
|
| 243 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
| 244 | 244 | } |
| 245 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
| 246 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
| 245 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
| 246 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
@@ -262,28 +262,28 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | public static function get_reg_steps() { |
| 264 | 264 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
| 265 | - if ( empty( $reg_steps )) { |
|
| 265 | + if (empty($reg_steps)) { |
|
| 266 | 266 | $reg_steps = array( |
| 267 | 267 | 10 => array( |
| 268 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
| 268 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
| 269 | 269 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
| 270 | 270 | 'slug' => 'attendee_information', |
| 271 | 271 | 'has_hooks' => FALSE |
| 272 | 272 | ), |
| 273 | 273 | 20 => array( |
| 274 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
| 274 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
| 275 | 275 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
| 276 | 276 | 'slug' => 'registration_confirmation', |
| 277 | 277 | 'has_hooks' => FALSE |
| 278 | 278 | ), |
| 279 | 279 | 30 => array( |
| 280 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
| 280 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
| 281 | 281 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
| 282 | 282 | 'slug' => 'payment_options', |
| 283 | 283 | 'has_hooks' => TRUE |
| 284 | 284 | ), |
| 285 | 285 | 999 => array( |
| 286 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
| 286 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
| 287 | 287 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
| 288 | 288 | 'slug' => 'finalize_registration', |
| 289 | 289 | 'has_hooks' => FALSE |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public static function registration_checkout_for_admin() { |
| 306 | 306 | EED_Single_Page_Checkout::load_reg_steps(); |
| 307 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
| 308 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
| 309 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
| 307 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 308 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
| 309 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
| 310 | 310 | EED_Single_Page_Checkout::instance()->_initialize(); |
| 311 | 311 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
| 312 | 312 | return EE_Registry::instance()->REQ->get_output(); |
@@ -323,15 +323,15 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | public static function process_registration_from_admin() { |
| 325 | 325 | EED_Single_Page_Checkout::load_reg_steps(); |
| 326 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
| 327 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
| 328 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
| 326 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
| 327 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
| 328 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
| 329 | 329 | EED_Single_Page_Checkout::instance()->_initialize(); |
| 330 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
| 331 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
| 332 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
| 333 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
| 334 | - if ( $final_reg_step->process_reg_step() ) { |
|
| 330 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
| 331 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
| 332 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
| 333 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
| 334 | + if ($final_reg_step->process_reg_step()) { |
|
| 335 | 335 | $final_reg_step->set_completed(); |
| 336 | 336 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
| 337 | 337 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | * @return void |
| 352 | 352 | * @throws \EE_Error |
| 353 | 353 | */ |
| 354 | - public function run( $WP_Query ) { |
|
| 354 | + public function run($WP_Query) { |
|
| 355 | 355 | if ( |
| 356 | 356 | $WP_Query instanceof WP_Query |
| 357 | 357 | && $WP_Query->is_main_query() |
| 358 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
| 358 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
| 359 | 359 | ) { |
| 360 | 360 | $this->_initialize(); |
| 361 | 361 | } |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | * @return void |
| 372 | 372 | * @throws \EE_Error |
| 373 | 373 | */ |
| 374 | - public static function init( $WP_Query ) { |
|
| 375 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
| 374 | + public static function init($WP_Query) { |
|
| 375 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
@@ -386,34 +386,34 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | private function _initialize() { |
| 388 | 388 | // ensure SPCO doesn't run twice |
| 389 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
| 389 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
| 390 | 390 | return; |
| 391 | 391 | } |
| 392 | 392 | try { |
| 393 | 393 | // setup the EE_Checkout object |
| 394 | 394 | $this->checkout = $this->_initialize_checkout(); |
| 395 | 395 | // filter checkout |
| 396 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
| 396 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
| 397 | 397 | // get the $_GET |
| 398 | 398 | $this->_get_request_vars(); |
| 399 | 399 | // filter continue_reg |
| 400 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
| 400 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
| 401 | 401 | // load the reg steps array |
| 402 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
| 402 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
| 403 | 403 | EED_Single_Page_Checkout::$_initialized = true; |
| 404 | 404 | return; |
| 405 | 405 | } |
| 406 | 406 | // set the current step |
| 407 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
| 407 | + $this->checkout->set_current_step($this->checkout->step); |
|
| 408 | 408 | // and the next step |
| 409 | 409 | $this->checkout->set_next_step(); |
| 410 | 410 | // was there already a valid transaction in the checkout from the session ? |
| 411 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
| 411 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 412 | 412 | // get transaction from db or session |
| 413 | 413 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
| 414 | 414 | ? $this->_get_transaction_and_cart_for_previous_visit() |
| 415 | 415 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
| 416 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
| 416 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
| 417 | 417 | // add some style and make it dance |
| 418 | 418 | $this->checkout->transaction = EE_Transaction::new_instance(); |
| 419 | 419 | $this->add_styles_and_scripts(); |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | return; |
| 422 | 422 | } |
| 423 | 423 | // and the registrations for the transaction |
| 424 | - $this->_get_registrations( $this->checkout->transaction ); |
|
| 424 | + $this->_get_registrations($this->checkout->transaction); |
|
| 425 | 425 | } |
| 426 | 426 | // verify that everything has been setup correctly |
| 427 | - if ( ! $this->_final_verifications() ) { |
|
| 427 | + if ( ! $this->_final_verifications()) { |
|
| 428 | 428 | EED_Single_Page_Checkout::$_initialized = true; |
| 429 | 429 | return; |
| 430 | 430 | } |
@@ -449,9 +449,9 @@ discard block |
||
| 449 | 449 | // set no cache headers and constants |
| 450 | 450 | EE_System::do_not_cache(); |
| 451 | 451 | // add anchor |
| 452 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
| 453 | - } catch ( Exception $e ) { |
|
| 454 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 452 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
| 453 | + } catch (Exception $e) { |
|
| 454 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
@@ -469,20 +469,20 @@ discard block |
||
| 469 | 469 | // look in session for existing checkout |
| 470 | 470 | $checkout = EE_Registry::instance()->SSN->checkout(); |
| 471 | 471 | // verify |
| 472 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
| 472 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 473 | 473 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
| 474 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
| 474 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
| 475 | 475 | } else { |
| 476 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
| 476 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
| 477 | 477 | $this->unlock_transaction(); |
| 478 | - wp_safe_redirect( $checkout->redirect_url ); |
|
| 478 | + wp_safe_redirect($checkout->redirect_url); |
|
| 479 | 479 | exit(); |
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
| 482 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
| 483 | 483 | // verify again |
| 484 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
| 485 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
| 484 | + if ( ! $checkout instanceof EE_Checkout) { |
|
| 485 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
| 486 | 486 | } |
| 487 | 487 | // reset anything that needs a clean slate for each request |
| 488 | 488 | $checkout->reset_for_current_request(); |
@@ -502,24 +502,24 @@ discard block |
||
| 502 | 502 | // load classes |
| 503 | 503 | EED_Single_Page_Checkout::load_request_handler(); |
| 504 | 504 | //make sure this request is marked as belonging to EE |
| 505 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
| 505 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
| 506 | 506 | // which step is being requested ? |
| 507 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
| 507 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
| 508 | 508 | // which step is being edited ? |
| 509 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
| 509 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
| 510 | 510 | // and what we're doing on the current step |
| 511 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
| 511 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
| 512 | 512 | // returning to edit ? |
| 513 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
| 513 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
| 514 | 514 | // or some other kind of revisit ? |
| 515 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
| 515 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
| 516 | 516 | // and whether or not to generate a reg form for this request |
| 517 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
| 517 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
| 518 | 518 | // and whether or not to process a reg form submission for this request |
| 519 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
| 519 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
| 520 | 520 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
| 521 | 521 | ? $this->checkout->process_form_submission |
| 522 | - : FALSE; // TRUE FALSE |
|
| 522 | + : FALSE; // TRUE FALSE |
|
| 523 | 523 | // $this->_display_request_vars(); |
| 524 | 524 | } |
| 525 | 525 | |
@@ -532,17 +532,17 @@ discard block |
||
| 532 | 532 | * @return void |
| 533 | 533 | */ |
| 534 | 534 | protected function _display_request_vars() { |
| 535 | - if ( ! WP_DEBUG ) { |
|
| 535 | + if ( ! WP_DEBUG) { |
|
| 536 | 536 | return; |
| 537 | 537 | } |
| 538 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
| 539 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
| 540 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
| 541 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
| 542 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
| 543 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
| 544 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
| 545 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
| 538 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
| 539 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
| 540 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
| 541 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
| 542 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
| 543 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
| 544 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
| 545 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | |
@@ -556,8 +556,8 @@ discard block |
||
| 556 | 556 | * @return array |
| 557 | 557 | */ |
| 558 | 558 | private function _get_first_step() { |
| 559 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
| 560 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
| 559 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
| 560 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | |
@@ -573,27 +573,27 @@ discard block |
||
| 573 | 573 | private function _load_and_instantiate_reg_steps() { |
| 574 | 574 | // have reg_steps already been instantiated ? |
| 575 | 575 | if ( |
| 576 | - empty( $this->checkout->reg_steps ) || |
|
| 577 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
| 576 | + empty($this->checkout->reg_steps) || |
|
| 577 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
| 578 | 578 | ) { |
| 579 | 579 | // if not, then loop through raw reg steps array |
| 580 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
| 581 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
| 580 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
| 581 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
| 582 | 582 | return false; |
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
| 586 | 586 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
| 587 | 587 | // skip the registration_confirmation page ? |
| 588 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
| 588 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
| 589 | 589 | // just remove it from the reg steps array |
| 590 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
| 590 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
| 591 | 591 | } else if ( |
| 592 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
| 592 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
| 593 | 593 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
| 594 | 594 | ) { |
| 595 | 595 | // set the order to something big like 100 |
| 596 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
| 596 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
| 597 | 597 | } |
| 598 | 598 | // filter the array for good luck |
| 599 | 599 | $this->checkout->reg_steps = apply_filters( |
@@ -603,13 +603,13 @@ discard block |
||
| 603 | 603 | // finally re-sort based on the reg step class order properties |
| 604 | 604 | $this->checkout->sort_reg_steps(); |
| 605 | 605 | } else { |
| 606 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
| 606 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 607 | 607 | // set all current step stati to FALSE |
| 608 | - $reg_step->set_is_current_step( FALSE ); |
|
| 608 | + $reg_step->set_is_current_step(FALSE); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | - if ( empty( $this->checkout->reg_steps )) { |
|
| 612 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
| 611 | + if (empty($this->checkout->reg_steps)) { |
|
| 612 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 613 | 613 | return false; |
| 614 | 614 | } |
| 615 | 615 | // make reg step details available to JS |
@@ -627,10 +627,10 @@ discard block |
||
| 627 | 627 | * @param int $order |
| 628 | 628 | * @return bool |
| 629 | 629 | */ |
| 630 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
| 630 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
| 631 | 631 | |
| 632 | 632 | // we need a file_path, class_name, and slug to add a reg step |
| 633 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
| 633 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
| 634 | 634 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
| 635 | 635 | if ( |
| 636 | 636 | $this->checkout->reg_url_link |
@@ -648,26 +648,26 @@ discard block |
||
| 648 | 648 | FALSE |
| 649 | 649 | ); |
| 650 | 650 | // did we gets the goods ? |
| 651 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
| 651 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
| 652 | 652 | // set reg step order based on config |
| 653 | - $reg_step_obj->set_order( $order ); |
|
| 653 | + $reg_step_obj->set_order($order); |
|
| 654 | 654 | // add instantiated reg step object to the master reg steps array |
| 655 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
| 655 | + $this->checkout->add_reg_step($reg_step_obj); |
|
| 656 | 656 | } else { |
| 657 | 657 | EE_Error::add_error( |
| 658 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
| 658 | + __('The current step could not be set.', 'event_espresso'), |
|
| 659 | 659 | __FILE__, __FUNCTION__, __LINE__ |
| 660 | 660 | ); |
| 661 | 661 | return false; |
| 662 | 662 | } |
| 663 | 663 | } else { |
| 664 | - if ( WP_DEBUG ) { |
|
| 664 | + if (WP_DEBUG) { |
|
| 665 | 665 | EE_Error::add_error( |
| 666 | 666 | sprintf( |
| 667 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
| 668 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
| 669 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
| 670 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
| 667 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
| 668 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
| 669 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
| 670 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
| 671 | 671 | '<ul>', |
| 672 | 672 | '<li>', |
| 673 | 673 | '</li>', |
@@ -691,16 +691,16 @@ discard block |
||
| 691 | 691 | */ |
| 692 | 692 | private function _get_transaction_and_cart_for_previous_visit() { |
| 693 | 693 | /** @var $TXN_model EEM_Transaction */ |
| 694 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
| 694 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
| 695 | 695 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
| 696 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
| 696 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
| 697 | 697 | // verify transaction |
| 698 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 698 | + if ($transaction instanceof EE_Transaction) { |
|
| 699 | 699 | // and get the cart that was used for that transaction |
| 700 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
| 700 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
| 701 | 701 | return $transaction; |
| 702 | 702 | } else { |
| 703 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
| 703 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 704 | 704 | return NULL; |
| 705 | 705 | } |
| 706 | 706 | } |
@@ -714,8 +714,8 @@ discard block |
||
| 714 | 714 | * @param EE_Transaction $transaction |
| 715 | 715 | * @return EE_Cart |
| 716 | 716 | */ |
| 717 | - private function _get_cart_for_transaction( $transaction ) { |
|
| 718 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
| 717 | + private function _get_cart_for_transaction($transaction) { |
|
| 718 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | |
@@ -727,8 +727,8 @@ discard block |
||
| 727 | 727 | * @param EE_Transaction $transaction |
| 728 | 728 | * @return EE_Cart |
| 729 | 729 | */ |
| 730 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
| 731 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
| 730 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
| 731 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
| 732 | 732 | } |
| 733 | 733 | |
| 734 | 734 | |
@@ -744,17 +744,17 @@ discard block |
||
| 744 | 744 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
| 745 | 745 | // if there's no transaction, then this is the FIRST visit to SPCO |
| 746 | 746 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
| 747 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
| 747 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
| 748 | 748 | // and then create a new transaction |
| 749 | 749 | $transaction = $this->_initialize_transaction(); |
| 750 | 750 | // verify transaction |
| 751 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 751 | + if ($transaction instanceof EE_Transaction) { |
|
| 752 | 752 | // save it so that we have an ID for other objects to use |
| 753 | 753 | $transaction->save(); |
| 754 | 754 | // and save TXN data to the cart |
| 755 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
| 755 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
| 756 | 756 | } else { |
| 757 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 757 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 758 | 758 | } |
| 759 | 759 | return $transaction; |
| 760 | 760 | } |
@@ -774,15 +774,15 @@ discard block |
||
| 774 | 774 | // grab the cart grand total |
| 775 | 775 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
| 776 | 776 | // create new TXN |
| 777 | - return EE_Transaction::new_instance( array( |
|
| 777 | + return EE_Transaction::new_instance(array( |
|
| 778 | 778 | 'TXN_timestamp' => time(), |
| 779 | 779 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
| 780 | 780 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
| 781 | 781 | 'TXN_paid' => 0, |
| 782 | 782 | 'STS_ID' => EEM_Transaction::failed_status_code, |
| 783 | 783 | )); |
| 784 | - } catch( Exception $e ) { |
|
| 785 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 784 | + } catch (Exception $e) { |
|
| 785 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 786 | 786 | } |
| 787 | 787 | return NULL; |
| 788 | 788 | } |
@@ -797,38 +797,38 @@ discard block |
||
| 797 | 797 | * @return EE_Cart |
| 798 | 798 | * @throws \EE_Error |
| 799 | 799 | */ |
| 800 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
| 800 | + private function _get_registrations(EE_Transaction $transaction) { |
|
| 801 | 801 | // first step: grab the registrants { : o |
| 802 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
| 802 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
| 803 | 803 | // verify registrations have been set |
| 804 | - if ( empty( $registrations )) { |
|
| 804 | + if (empty($registrations)) { |
|
| 805 | 805 | // if no cached registrations, then check the db |
| 806 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
| 806 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
| 807 | 807 | // still nothing ? well as long as this isn't a revisit |
| 808 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
| 808 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
| 809 | 809 | // generate new registrations from scratch |
| 810 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
| 810 | + $registrations = $this->_initialize_registrations($transaction); |
|
| 811 | 811 | } |
| 812 | 812 | } |
| 813 | 813 | // sort by their original registration order |
| 814 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
| 814 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
| 815 | 815 | // then loop thru the array |
| 816 | - foreach ( $registrations as $registration ) { |
|
| 816 | + foreach ($registrations as $registration) { |
|
| 817 | 817 | // verify each registration |
| 818 | - if ( $registration instanceof EE_Registration ) { |
|
| 818 | + if ($registration instanceof EE_Registration) { |
|
| 819 | 819 | // we display all attendee info for the primary registrant |
| 820 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 820 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
| 821 | 821 | && $registration->is_primary_registrant() |
| 822 | 822 | ) { |
| 823 | 823 | $this->checkout->primary_revisit = true; |
| 824 | 824 | break; |
| 825 | - } else if ( $this->checkout->revisit |
|
| 825 | + } else if ($this->checkout->revisit |
|
| 826 | 826 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
| 827 | 827 | ) { |
| 828 | 828 | // but hide info if it doesn't belong to you |
| 829 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
| 829 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
| 830 | 830 | } |
| 831 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
| 831 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | 834 | } |
@@ -843,17 +843,17 @@ discard block |
||
| 843 | 843 | * @return array |
| 844 | 844 | * @throws \EE_Error |
| 845 | 845 | */ |
| 846 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
| 846 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
| 847 | 847 | $att_nmbr = 0; |
| 848 | 848 | $registrations = array(); |
| 849 | - if ( $transaction instanceof EE_Transaction ) { |
|
| 849 | + if ($transaction instanceof EE_Transaction) { |
|
| 850 | 850 | /** @type EE_Registration_Processor $registration_processor */ |
| 851 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
| 851 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 852 | 852 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
| 853 | 853 | // now let's add the cart items to the $transaction |
| 854 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
| 854 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
| 855 | 855 | //do the following for each ticket of this type they selected |
| 856 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
| 856 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
| 857 | 857 | $att_nmbr++; |
| 858 | 858 | $registration = $registration_processor->generate_ONE_registration_from_line_item( |
| 859 | 859 | $line_item, |
@@ -861,12 +861,12 @@ discard block |
||
| 861 | 861 | $att_nmbr, |
| 862 | 862 | $this->checkout->total_ticket_count |
| 863 | 863 | ); |
| 864 | - if ( $registration instanceof EE_Registration ) { |
|
| 865 | - $registrations[ $registration->ID() ] = $registration; |
|
| 864 | + if ($registration instanceof EE_Registration) { |
|
| 865 | + $registrations[$registration->ID()] = $registration; |
|
| 866 | 866 | } |
| 867 | 867 | } |
| 868 | 868 | } |
| 869 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
| 869 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
| 870 | 870 | } |
| 871 | 871 | return $registrations; |
| 872 | 872 | } |
@@ -881,12 +881,12 @@ discard block |
||
| 881 | 881 | * @param EE_Registration $reg_B |
| 882 | 882 | * @return array() |
| 883 | 883 | */ |
| 884 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
| 884 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
| 885 | 885 | // this shouldn't ever happen within the same TXN, but oh well |
| 886 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
| 886 | + if ($reg_A->count() === $reg_B->count()) { |
|
| 887 | 887 | return 0; |
| 888 | 888 | } |
| 889 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
| 889 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | |
@@ -901,21 +901,21 @@ discard block |
||
| 901 | 901 | */ |
| 902 | 902 | private function _final_verifications() { |
| 903 | 903 | // filter checkout |
| 904 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
| 904 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
| 905 | 905 | //verify that current step is still set correctly |
| 906 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
| 907 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 906 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
| 907 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 908 | 908 | return false; |
| 909 | 909 | } |
| 910 | 910 | // if returning to SPCO, then verify that primary registrant is set |
| 911 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
| 911 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
| 912 | 912 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
| 913 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
| 914 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 913 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 914 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 915 | 915 | return false; |
| 916 | 916 | } |
| 917 | 917 | $valid_registrant = null; |
| 918 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
| 918 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
| 919 | 919 | if ( |
| 920 | 920 | $registration instanceof EE_Registration |
| 921 | 921 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -923,9 +923,9 @@ discard block |
||
| 923 | 923 | $valid_registrant = $registration; |
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
| 926 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
| 927 | 927 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
| 928 | - if ( EED_Single_Page_Checkout::$_checkout_verified ) { |
|
| 928 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
| 929 | 929 | // clear the session, mark the checkout as unverified, and try again |
| 930 | 930 | EE_Registry::instance()->SSN->clear_session(); |
| 931 | 931 | EED_Single_Page_Checkout::$_initialized = false; |
@@ -934,13 +934,13 @@ discard block |
||
| 934 | 934 | EE_Error::reset_notices(); |
| 935 | 935 | return false; |
| 936 | 936 | } |
| 937 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 937 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 938 | 938 | return false; |
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 941 | // now that things have been kinda sufficiently verified, |
| 942 | 942 | // let's add the checkout to the session so that's available other systems |
| 943 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
| 943 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
| 944 | 944 | return true; |
| 945 | 945 | } |
| 946 | 946 | |
@@ -955,28 +955,28 @@ discard block |
||
| 955 | 955 | * @param bool $reinitializing |
| 956 | 956 | * @throws \EE_Error |
| 957 | 957 | */ |
| 958 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
| 959 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
| 958 | + private function _initialize_reg_steps($reinitializing = false) { |
|
| 959 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
| 960 | 960 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
| 961 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
| 962 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
| 961 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
| 962 | + if ( ! $reg_step->initialize_reg_step()) { |
|
| 963 | 963 | // if not initialized then maybe this step is being removed... |
| 964 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
| 964 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
| 965 | 965 | // if it was the current step, then we need to start over here |
| 966 | - $this->_initialize_reg_steps( true ); |
|
| 966 | + $this->_initialize_reg_steps(true); |
|
| 967 | 967 | return; |
| 968 | 968 | } |
| 969 | 969 | continue; |
| 970 | 970 | } |
| 971 | 971 | // i18n |
| 972 | 972 | $reg_step->translate_js_strings(); |
| 973 | - if ( $reg_step->is_current_step() ) { |
|
| 973 | + if ($reg_step->is_current_step()) { |
|
| 974 | 974 | // the text that appears on the reg step form submit button |
| 975 | 975 | $reg_step->set_submit_button_text(); |
| 976 | 976 | } |
| 977 | 977 | } |
| 978 | 978 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
| 979 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
| 979 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | |
@@ -989,43 +989,43 @@ discard block |
||
| 989 | 989 | */ |
| 990 | 990 | private function _check_form_submission() { |
| 991 | 991 | //does this request require the reg form to be generated ? |
| 992 | - if ( $this->checkout->generate_reg_form ) { |
|
| 992 | + if ($this->checkout->generate_reg_form) { |
|
| 993 | 993 | // ever heard that song by Blue Rodeo ? |
| 994 | 994 | try { |
| 995 | 995 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
| 996 | 996 | // if not displaying a form, then check for form submission |
| 997 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
| 997 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
| 998 | 998 | // clear out any old data in case this step is being run again |
| 999 | - $this->checkout->current_step->set_valid_data( array() ); |
|
| 999 | + $this->checkout->current_step->set_valid_data(array()); |
|
| 1000 | 1000 | // capture submitted form data |
| 1001 | 1001 | $this->checkout->current_step->reg_form->receive_form_submission( |
| 1002 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
| 1002 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
| 1003 | 1003 | ); |
| 1004 | 1004 | // validate submitted form data |
| 1005 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
| 1005 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
| 1006 | 1006 | // thou shall not pass !!! |
| 1007 | 1007 | $this->checkout->continue_reg = FALSE; |
| 1008 | 1008 | // any form validation errors? |
| 1009 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
| 1009 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
| 1010 | 1010 | $submission_error_messages = array(); |
| 1011 | 1011 | // bad, bad, bad registrant |
| 1012 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
| 1013 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
| 1012 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
| 1013 | + if ($validation_error instanceof EE_Validation_Error) { |
|
| 1014 | 1014 | $submission_error_messages[] = sprintf( |
| 1015 | - __( '%s : %s', 'event_espresso' ), |
|
| 1015 | + __('%s : %s', 'event_espresso'), |
|
| 1016 | 1016 | $validation_error->get_form_section()->html_label_text(), |
| 1017 | 1017 | $validation_error->getMessage() |
| 1018 | 1018 | ); |
| 1019 | 1019 | } |
| 1020 | 1020 | } |
| 1021 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1021 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
| 1022 | 1022 | } |
| 1023 | 1023 | // well not really... what will happen is we'll just get redirected back to redo the current step |
| 1024 | 1024 | $this->go_to_next_step(); |
| 1025 | 1025 | return; |
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | - } catch( EE_Error $e ) { |
|
| 1028 | + } catch (EE_Error $e) { |
|
| 1029 | 1029 | $e->get_error(); |
| 1030 | 1030 | } |
| 1031 | 1031 | } |
@@ -1042,22 +1042,22 @@ discard block |
||
| 1042 | 1042 | */ |
| 1043 | 1043 | private function _process_form_action() { |
| 1044 | 1044 | // what cha wanna do? |
| 1045 | - switch( $this->checkout->action ) { |
|
| 1045 | + switch ($this->checkout->action) { |
|
| 1046 | 1046 | // AJAX next step reg form |
| 1047 | 1047 | case 'display_spco_reg_step' : |
| 1048 | 1048 | $this->checkout->redirect = FALSE; |
| 1049 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
| 1050 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
| 1049 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1050 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | break; |
| 1053 | 1053 | |
| 1054 | 1054 | default : |
| 1055 | 1055 | // meh... do one of those other steps first |
| 1056 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
| 1056 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1057 | 1057 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
| 1058 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
| 1058 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
| 1059 | 1059 | // call action on current step |
| 1060 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
| 1060 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
| 1061 | 1061 | // good registrant, you get to proceed |
| 1062 | 1062 | if ( |
| 1063 | 1063 | $this->checkout->current_step->success_message() !== '' |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | ) { |
| 1069 | 1069 | EE_Error::add_success( |
| 1070 | 1070 | $this->checkout->current_step->success_message() |
| 1071 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
| 1071 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
| 1072 | 1072 | ); |
| 1073 | 1073 | |
| 1074 | 1074 | } |
@@ -1076,12 +1076,12 @@ discard block |
||
| 1076 | 1076 | $this->_setup_redirect(); |
| 1077 | 1077 | } |
| 1078 | 1078 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
| 1079 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
| 1079 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
| 1080 | 1080 | |
| 1081 | 1081 | } else { |
| 1082 | 1082 | EE_Error::add_error( |
| 1083 | 1083 | sprintf( |
| 1084 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
| 1084 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
| 1085 | 1085 | $this->checkout->action, |
| 1086 | 1086 | $this->checkout->current_step->name() |
| 1087 | 1087 | ), |
@@ -1107,10 +1107,10 @@ discard block |
||
| 1107 | 1107 | public function add_styles_and_scripts() { |
| 1108 | 1108 | // i18n |
| 1109 | 1109 | $this->translate_js_strings(); |
| 1110 | - if ( $this->checkout->admin_request ) { |
|
| 1111 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
| 1110 | + if ($this->checkout->admin_request) { |
|
| 1111 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1112 | 1112 | } else { |
| 1113 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
| 1113 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | } |
| 1116 | 1116 | |
@@ -1126,42 +1126,42 @@ discard block |
||
| 1126 | 1126 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
| 1127 | 1127 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
| 1128 | 1128 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
| 1129 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
| 1130 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
| 1131 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
| 1129 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1130 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
| 1131 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
| 1132 | 1132 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
| 1133 | 1133 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
| 1134 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' ); |
|
| 1135 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
| 1134 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>'); |
|
| 1135 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
| 1136 | 1136 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
| 1137 | 1137 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
| 1138 | 1138 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
| 1139 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
| 1140 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
| 1141 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
| 1142 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
| 1143 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
| 1144 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
| 1145 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
| 1146 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
| 1147 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
| 1148 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
| 1149 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
| 1150 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
| 1151 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
| 1152 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
| 1139 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
| 1140 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
| 1141 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
| 1142 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
| 1143 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
| 1144 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
| 1145 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
| 1146 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
| 1147 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
| 1148 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
| 1149 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
| 1150 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
| 1151 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
| 1152 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
| 1153 | 1153 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
| 1154 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
| 1154 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
| 1155 | 1155 | '<h4 class="important-notice">', |
| 1156 | 1156 | '</h4>', |
| 1157 | 1157 | '<br />', |
| 1158 | 1158 | '<p>', |
| 1159 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
| 1159 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
| 1160 | 1160 | '">', |
| 1161 | 1161 | '</a>', |
| 1162 | 1162 | '</p>' |
| 1163 | 1163 | ); |
| 1164 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
| 1164 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | |
@@ -1174,25 +1174,25 @@ discard block |
||
| 1174 | 1174 | */ |
| 1175 | 1175 | public function enqueue_styles_and_scripts() { |
| 1176 | 1176 | // load css |
| 1177 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 1178 | - wp_enqueue_style( 'single_page_checkout' ); |
|
| 1177 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1178 | + wp_enqueue_style('single_page_checkout'); |
|
| 1179 | 1179 | // load JS |
| 1180 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
| 1181 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
| 1182 | - wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 1183 | - wp_enqueue_script( 'single_page_checkout' ); |
|
| 1180 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
| 1181 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
| 1182 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 1183 | + wp_enqueue_script('single_page_checkout'); |
|
| 1184 | 1184 | |
| 1185 | 1185 | /** |
| 1186 | 1186 | * global action hook for enqueueing styles and scripts with |
| 1187 | 1187 | * spco calls. |
| 1188 | 1188 | */ |
| 1189 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
| 1189 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
| 1190 | 1190 | |
| 1191 | 1191 | /** |
| 1192 | 1192 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
| 1193 | 1193 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
| 1194 | 1194 | */ |
| 1195 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
| 1195 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
| 1196 | 1196 | |
| 1197 | 1197 | // add css and JS for current step |
| 1198 | 1198 | $this->checkout->current_step->enqueue_styles_and_scripts(); |
@@ -1209,19 +1209,19 @@ discard block |
||
| 1209 | 1209 | */ |
| 1210 | 1210 | private function _display_spco_reg_form() { |
| 1211 | 1211 | // if registering via the admin, just display the reg form for the current step |
| 1212 | - if ( $this->checkout->admin_request ) { |
|
| 1213 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
| 1212 | + if ($this->checkout->admin_request) { |
|
| 1213 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
| 1214 | 1214 | } else { |
| 1215 | 1215 | // add powered by EE msg |
| 1216 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
| 1216 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
| 1217 | 1217 | |
| 1218 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
| 1218 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
| 1219 | 1219 | $cookies_not_set_msg = ''; |
| 1220 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
| 1220 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
| 1221 | 1221 | $cookies_not_set_msg = apply_filters( |
| 1222 | 1222 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
| 1223 | 1223 | sprintf( |
| 1224 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
| 1224 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
| 1225 | 1225 | '<div class="ee-attention">', |
| 1226 | 1226 | '</div>', |
| 1227 | 1227 | '<h6 class="important-notice">', |
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | 'layout_strategy' => |
| 1242 | 1242 | new EE_Template_Layout( |
| 1243 | 1243 | array( |
| 1244 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
| 1244 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
| 1245 | 1245 | 'template_args' => array( |
| 1246 | 1246 | 'empty_cart' => $empty_cart, |
| 1247 | 1247 | 'revisit' => $this->checkout->revisit, |
@@ -1250,8 +1250,8 @@ discard block |
||
| 1250 | 1250 | 'empty_msg' => apply_filters( |
| 1251 | 1251 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
| 1252 | 1252 | sprintf( |
| 1253 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
| 1254 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
| 1253 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
| 1254 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
| 1255 | 1255 | '">', |
| 1256 | 1256 | '</a>' |
| 1257 | 1257 | ) |
@@ -1259,14 +1259,14 @@ discard block |
||
| 1259 | 1259 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
| 1260 | 1260 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
| 1261 | 1261 | 'session_expiration' => |
| 1262 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
| 1262 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
| 1263 | 1263 | ) |
| 1264 | 1264 | ) |
| 1265 | 1265 | ) |
| 1266 | 1266 | ) |
| 1267 | 1267 | ); |
| 1268 | 1268 | // load template and add to output sent that gets filtered into the_content() |
| 1269 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
| 1269 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
| 1270 | 1270 | } |
| 1271 | 1271 | } |
| 1272 | 1272 | |
@@ -1280,8 +1280,8 @@ discard block |
||
| 1280 | 1280 | * @internal param string $label |
| 1281 | 1281 | * @return string |
| 1282 | 1282 | */ |
| 1283 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
| 1284 | - if ( $next_step === 'finalize_registration' ) { |
|
| 1283 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
| 1284 | + if ($next_step === 'finalize_registration') { |
|
| 1285 | 1285 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
| 1286 | 1286 | } |
| 1287 | 1287 | } |
@@ -1295,18 +1295,18 @@ discard block |
||
| 1295 | 1295 | * @return string |
| 1296 | 1296 | */ |
| 1297 | 1297 | public static function display_registration_footer() { |
| 1298 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
| 1299 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
| 1300 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
| 1301 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
| 1298 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
| 1299 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
| 1300 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
| 1301 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
| 1302 | 1302 | echo apply_filters( |
| 1303 | 1303 | 'FHEE__EE_Front_Controller__display_registration_footer', |
| 1304 | 1304 | sprintf( |
| 1305 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
| 1306 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
| 1305 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
| 1306 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
| 1307 | 1307 | '" target="_blank">', |
| 1308 | 1308 | '</a>', |
| 1309 | - '<a href="' . $url . '" title="', |
|
| 1309 | + '<a href="'.$url.'" title="', |
|
| 1310 | 1310 | '" target="_blank">', |
| 1311 | 1311 | '</a></div>' |
| 1312 | 1312 | ) |
@@ -1337,12 +1337,12 @@ discard block |
||
| 1337 | 1337 | * @return array |
| 1338 | 1338 | */ |
| 1339 | 1339 | private function _setup_redirect() { |
| 1340 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
| 1340 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 1341 | 1341 | $this->checkout->redirect = TRUE; |
| 1342 | - if ( empty( $this->checkout->redirect_url )) { |
|
| 1342 | + if (empty($this->checkout->redirect_url)) { |
|
| 1343 | 1343 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
| 1344 | 1344 | } |
| 1345 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
| 1345 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
| 1346 | 1346 | } |
| 1347 | 1347 | } |
| 1348 | 1348 | |
@@ -1356,9 +1356,9 @@ discard block |
||
| 1356 | 1356 | * @throws \EE_Error |
| 1357 | 1357 | */ |
| 1358 | 1358 | public function go_to_next_step() { |
| 1359 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
| 1359 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1360 | 1360 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
| 1361 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
| 1361 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
| 1362 | 1362 | } |
| 1363 | 1363 | $this->unlock_transaction(); |
| 1364 | 1364 | // just return for these conditions |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | */ |
| 1388 | 1388 | protected function _handle_json_response() { |
| 1389 | 1389 | // if this is an ajax request |
| 1390 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
| 1390 | + if (EE_Registry::instance()->REQ->ajax) { |
|
| 1391 | 1391 | // DEBUG LOG |
| 1392 | 1392 | //$this->checkout->log( |
| 1393 | 1393 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1400,7 +1400,7 @@ discard block |
||
| 1400 | 1400 | $this->checkout->json_response->set_registration_time_limit( |
| 1401 | 1401 | $this->checkout->get_registration_time_limit() |
| 1402 | 1402 | ); |
| 1403 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
| 1403 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
| 1404 | 1404 | // just send the ajax ( |
| 1405 | 1405 | $json_response = apply_filters( |
| 1406 | 1406 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1421,9 +1421,9 @@ discard block |
||
| 1421 | 1421 | */ |
| 1422 | 1422 | protected function _handle_html_redirects() { |
| 1423 | 1423 | // going somewhere ? |
| 1424 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
| 1424 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
| 1425 | 1425 | // store notices in a transient |
| 1426 | - EE_Error::get_notices( false, true, true ); |
|
| 1426 | + EE_Error::get_notices(false, true, true); |
|
| 1427 | 1427 | // DEBUG LOG |
| 1428 | 1428 | //$this->checkout->log( |
| 1429 | 1429 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1433,7 +1433,7 @@ discard block |
||
| 1433 | 1433 | // 'headers_list' => headers_list(), |
| 1434 | 1434 | // ) |
| 1435 | 1435 | //); |
| 1436 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
| 1436 | + wp_safe_redirect($this->checkout->redirect_url); |
|
| 1437 | 1437 | exit(); |
| 1438 | 1438 | } |
| 1439 | 1439 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -26,20 +26,20 @@ discard block |
||
| 26 | 26 | * @param EE_Response $response |
| 27 | 27 | * @return EE_Response |
| 28 | 28 | */ |
| 29 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 29 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
| 30 | 30 | $this->_request = $request; |
| 31 | 31 | $this->_response = $response; |
| 32 | 32 | global $pagenow; |
| 33 | 33 | if ( |
| 34 | 34 | in_array( |
| 35 | 35 | $pagenow, |
| 36 | - array( 'wp-login.php', 'wp-register.php' ) |
|
| 36 | + array('wp-login.php', 'wp-register.php') |
|
| 37 | 37 | ) |
| 38 | - && ! $request->get( 'ee_load_on_login' ) |
|
| 38 | + && ! $request->get('ee_load_on_login') |
|
| 39 | 39 | ) { |
| 40 | 40 | $this->_response->terminate_request(); |
| 41 | 41 | } |
| 42 | - $this->_response = $this->process_request_stack( $this->_request, $this->_response ); |
|
| 42 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
| 43 | 43 | return $this->_response; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * Loads the class file for a given class name. |
| 133 | 133 | * |
| 134 | 134 | * @param string $class The fully-qualified class name. |
| 135 | - * @return mixed The mapped file name on success, or boolean false on |
|
| 135 | + * @return string|false The mapped file name on success, or boolean false on |
|
| 136 | 136 | * failure. |
| 137 | 137 | */ |
| 138 | 138 | public function loadClass( $class ) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @param string $prefix The namespace prefix. |
| 167 | 167 | * @param string $relative_class The relative class name. |
| 168 | - * @return mixed Boolean false if no mapped file can be loaded, or the |
|
| 168 | + * @return string|false Boolean false if no mapped file can be loaded, or the |
|
| 169 | 169 | * name of the mapped file that was loaded. |
| 170 | 170 | */ |
| 171 | 171 | protected function loadMappedFile( $prefix, $relative_class ) { |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | * @param string $prefix |
| 78 | 78 | * @return array |
| 79 | 79 | */ |
| 80 | - public function prefixes( $prefix = '' ) { |
|
| 81 | - if ( ! empty( $prefix ) ) { |
|
| 80 | + public function prefixes($prefix = '') { |
|
| 81 | + if ( ! empty($prefix)) { |
|
| 82 | 82 | // are there any base directories for this namespace prefix? |
| 83 | - return isset( $this->prefixes[ $prefix ] ) ? $this->prefixes[ $prefix ] : array(); |
|
| 83 | + return isset($this->prefixes[$prefix]) ? $this->prefixes[$prefix] : array(); |
|
| 84 | 84 | } |
| 85 | 85 | return $this->prefixes; |
| 86 | 86 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | 95 | public function register() { |
| 96 | - spl_autoload_register( array( $this, 'loadClass' ) ); |
|
| 96 | + spl_autoload_register(array($this, 'loadClass')); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
@@ -109,20 +109,20 @@ discard block |
||
| 109 | 109 | * than last. |
| 110 | 110 | * @return void |
| 111 | 111 | */ |
| 112 | - public function addNamespace( $prefix, $base_dir, $prepend = false ) { |
|
| 112 | + public function addNamespace($prefix, $base_dir, $prepend = false) { |
|
| 113 | 113 | // normalize namespace prefix |
| 114 | - $prefix = trim( $prefix, Psr4Autoloader::NS ) . Psr4Autoloader::NS; |
|
| 114 | + $prefix = trim($prefix, Psr4Autoloader::NS).Psr4Autoloader::NS; |
|
| 115 | 115 | // normalize the base directory with a trailing separator |
| 116 | - $base_dir = \EEH_File::standardise_and_end_with_directory_separator( $base_dir ); |
|
| 116 | + $base_dir = \EEH_File::standardise_and_end_with_directory_separator($base_dir); |
|
| 117 | 117 | // initialize the namespace prefix array |
| 118 | - if ( isset( $this->prefixes[ $prefix ] ) === false ) { |
|
| 119 | - $this->prefixes[ $prefix ] = array(); |
|
| 118 | + if (isset($this->prefixes[$prefix]) === false) { |
|
| 119 | + $this->prefixes[$prefix] = array(); |
|
| 120 | 120 | } |
| 121 | 121 | // retain the base directory for the namespace prefix |
| 122 | - if ( $prepend ) { |
|
| 123 | - array_unshift( $this->prefixes[ $prefix ], $base_dir ); |
|
| 122 | + if ($prepend) { |
|
| 123 | + array_unshift($this->prefixes[$prefix], $base_dir); |
|
| 124 | 124 | } else { |
| 125 | - $this->prefixes[ $prefix ][] = $base_dir; |
|
| 125 | + $this->prefixes[$prefix][] = $base_dir; |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
@@ -135,24 +135,24 @@ discard block |
||
| 135 | 135 | * @return mixed The mapped file name on success, or boolean false on |
| 136 | 136 | * failure. |
| 137 | 137 | */ |
| 138 | - public function loadClass( $class ) { |
|
| 138 | + public function loadClass($class) { |
|
| 139 | 139 | // the current namespace prefix |
| 140 | 140 | $prefix = $class; |
| 141 | 141 | // work backwards through the namespace names of the fully-qualified |
| 142 | 142 | // class name to find a mapped file name |
| 143 | - while ( false !== $pos = strrpos( $prefix, Psr4Autoloader::NS ) ) { |
|
| 143 | + while (false !== $pos = strrpos($prefix, Psr4Autoloader::NS)) { |
|
| 144 | 144 | // retain the trailing namespace separator in the prefix |
| 145 | - $prefix = substr( $class, 0, $pos + 1 ); |
|
| 145 | + $prefix = substr($class, 0, $pos + 1); |
|
| 146 | 146 | // the rest is the relative class name |
| 147 | - $relative_class = substr( $class, $pos + 1 ); |
|
| 147 | + $relative_class = substr($class, $pos + 1); |
|
| 148 | 148 | // try to load a mapped file for the prefix and relative class |
| 149 | - $mapped_file = $this->loadMappedFile( $prefix, $relative_class ); |
|
| 150 | - if ( $mapped_file ) { |
|
| 149 | + $mapped_file = $this->loadMappedFile($prefix, $relative_class); |
|
| 150 | + if ($mapped_file) { |
|
| 151 | 151 | return $mapped_file; |
| 152 | 152 | } |
| 153 | 153 | // remove the trailing namespace separator for the next iteration |
| 154 | 154 | // of strrpos() |
| 155 | - $prefix = rtrim( $prefix, Psr4Autoloader::NS ); |
|
| 155 | + $prefix = rtrim($prefix, Psr4Autoloader::NS); |
|
| 156 | 156 | } |
| 157 | 157 | // never found a mapped file |
| 158 | 158 | return false; |
@@ -168,17 +168,17 @@ discard block |
||
| 168 | 168 | * @return mixed Boolean false if no mapped file can be loaded, or the |
| 169 | 169 | * name of the mapped file that was loaded. |
| 170 | 170 | */ |
| 171 | - protected function loadMappedFile( $prefix, $relative_class ) { |
|
| 171 | + protected function loadMappedFile($prefix, $relative_class) { |
|
| 172 | 172 | // look through base directories for this namespace prefix |
| 173 | - foreach ( $this->prefixes( $prefix ) as $base_dir ) { |
|
| 173 | + foreach ($this->prefixes($prefix) as $base_dir) { |
|
| 174 | 174 | // replace the namespace prefix with the base directory, |
| 175 | 175 | // replace namespace separators with directory separators |
| 176 | 176 | // in the relative class name, append with .php |
| 177 | 177 | $file = $base_dir |
| 178 | - . str_replace( Psr4Autoloader::NS, DS, $relative_class ) |
|
| 178 | + . str_replace(Psr4Autoloader::NS, DS, $relative_class) |
|
| 179 | 179 | . '.php'; |
| 180 | 180 | // if the mapped file exists, require it |
| 181 | - if ( $this->requireFile( $file ) ) { |
|
| 181 | + if ($this->requireFile($file)) { |
|
| 182 | 182 | // yes, we're done |
| 183 | 183 | return $file; |
| 184 | 184 | } |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | * @param string $file The file to require. |
| 196 | 196 | * @return bool True if the file exists, false if not. |
| 197 | 197 | */ |
| 198 | - protected function requireFile( $file ) { |
|
| 199 | - if ( file_exists( $file ) ) { |
|
| 198 | + protected function requireFile($file) { |
|
| 199 | + if (file_exists($file)) { |
|
| 200 | 200 | require $file; |
| 201 | 201 | return true; |
| 202 | 202 | } |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | * given a valid namespace, will find all files that match the provided mask |
| 78 | 78 | * |
| 79 | 79 | * @access public |
| 80 | - * @param string|array $namespaces |
|
| 80 | + * @param string $namespaces |
|
| 81 | 81 | * @return FilesystemIterator |
| 82 | 82 | * @throws \EventEspresso\Core\Exceptions\InvalidClassException |
| 83 | 83 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | use EventEspresso\Core\Psr4Autoloader; |
| 7 | 7 | use FilesystemIterator; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 10 | - exit( 'No direct script access allowed' ); |
|
| 9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 10 | + exit('No direct script access allowed'); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | * @param string $namespace_base_dir |
| 41 | 41 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 42 | 42 | */ |
| 43 | - protected function setNamespace( $namespace, $namespace_base_dir ) { |
|
| 44 | - if ( ! is_string( $namespace ) ) { |
|
| 45 | - throw new InvalidDataTypeException( '$namespace', $namespace, 'string' ); |
|
| 43 | + protected function setNamespace($namespace, $namespace_base_dir) { |
|
| 44 | + if ( ! is_string($namespace)) { |
|
| 45 | + throw new InvalidDataTypeException('$namespace', $namespace, 'string'); |
|
| 46 | 46 | } |
| 47 | - if ( ! is_string( $namespace_base_dir ) ) { |
|
| 48 | - throw new InvalidDataTypeException( '$namespace_base_dir', $namespace_base_dir, 'string' ); |
|
| 47 | + if ( ! is_string($namespace_base_dir)) { |
|
| 48 | + throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string'); |
|
| 49 | 49 | } |
| 50 | - $this->namespaces[ $namespace ] = $namespace_base_dir; |
|
| 50 | + $this->namespaces[$namespace] = $namespace_base_dir; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @return int |
| 68 | 68 | */ |
| 69 | 69 | public function count() { |
| 70 | - return count( $this->FQCNs ); |
|
| 70 | + return count($this->FQCNs); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | * @throws \EventEspresso\Core\Exceptions\InvalidClassException |
| 83 | 83 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 84 | 84 | */ |
| 85 | - public function locate( $namespaces ) { |
|
| 86 | - if ( ! ( is_string( $namespaces ) || is_array( $namespaces ) ) ) { |
|
| 87 | - throw new InvalidDataTypeException( '$namespaces', $namespaces, 'string or array' ); |
|
| 85 | + public function locate($namespaces) { |
|
| 86 | + if ( ! (is_string($namespaces) || is_array($namespaces))) { |
|
| 87 | + throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array'); |
|
| 88 | 88 | } |
| 89 | - foreach ( (array) $namespaces as $namespace ) { |
|
| 90 | - foreach ( $this->FindFQCNsByNamespace( $namespace ) as $key => $file ) { |
|
| 91 | - $this->FQCNs[ $key ] = $file; |
|
| 89 | + foreach ((array) $namespaces as $namespace) { |
|
| 90 | + foreach ($this->FindFQCNsByNamespace($namespace) as $key => $file) { |
|
| 91 | + $this->FQCNs[$key] = $file; |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | return $this->FQCNs; |
@@ -107,24 +107,24 @@ discard block |
||
| 107 | 107 | * @throws \EventEspresso\Core\Exceptions\InvalidClassException |
| 108 | 108 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 109 | 109 | */ |
| 110 | - protected function FindFQCNsByNamespace( $partial_namespace ) { |
|
| 110 | + protected function FindFQCNsByNamespace($partial_namespace) { |
|
| 111 | 111 | $iterator = new FilesystemIterator( |
| 112 | - $this->getDirectoryFromPartialNamespace( $partial_namespace ) |
|
| 112 | + $this->getDirectoryFromPartialNamespace($partial_namespace) |
|
| 113 | 113 | ); |
| 114 | - foreach ( $this->flags as $flag ) { |
|
| 115 | - $iterator->setFlags( $flag ); |
|
| 114 | + foreach ($this->flags as $flag) { |
|
| 115 | + $iterator->setFlags($flag); |
|
| 116 | 116 | } |
| 117 | - if ( iterator_count( $iterator ) === 0 ) { |
|
| 117 | + if (iterator_count($iterator) === 0) { |
|
| 118 | 118 | return array(); |
| 119 | 119 | } |
| 120 | - foreach ( $iterator as $file ) { |
|
| 121 | - $file = \EEH_File::standardise_directory_separators( $file ); |
|
| 122 | - foreach ( $this->namespaces as $namespace => $base_dir ) { |
|
| 120 | + foreach ($iterator as $file) { |
|
| 121 | + $file = \EEH_File::standardise_directory_separators($file); |
|
| 122 | + foreach ($this->namespaces as $namespace => $base_dir) { |
|
| 123 | 123 | $namespace .= Psr4Autoloader::NS; |
| 124 | - if ( strpos( $file, $base_dir ) === 0 ) { |
|
| 125 | - $this->FQCNs[] = Psr4Autoloader::NS . str_replace( |
|
| 126 | - array( $base_dir, DS, '.php' ), |
|
| 127 | - array( $namespace, Psr4Autoloader::NS, '' ), |
|
| 124 | + if (strpos($file, $base_dir) === 0) { |
|
| 125 | + $this->FQCNs[] = Psr4Autoloader::NS.str_replace( |
|
| 126 | + array($base_dir, DS, '.php'), |
|
| 127 | + array($namespace, Psr4Autoloader::NS, ''), |
|
| 128 | 128 | $file |
| 129 | 129 | ); |
| 130 | 130 | } |
@@ -144,25 +144,25 @@ discard block |
||
| 144 | 144 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 145 | 145 | * @throws \EventEspresso\Core\Exceptions\InvalidClassException |
| 146 | 146 | */ |
| 147 | - protected function getDirectoryFromPartialNamespace( $partial_namespace ) { |
|
| 148 | - if ( empty( $partial_namespace ) ) { |
|
| 149 | - throw new InvalidClassException( $partial_namespace ); |
|
| 147 | + protected function getDirectoryFromPartialNamespace($partial_namespace) { |
|
| 148 | + if (empty($partial_namespace)) { |
|
| 149 | + throw new InvalidClassException($partial_namespace); |
|
| 150 | 150 | } |
| 151 | 151 | // load our PSR-4 Autoloader so we can get the list of registered namespaces from it |
| 152 | 152 | $psr4_loader = \EE_Psr4AutoloaderInit::psr4_loader(); |
| 153 | 153 | // breakup the incoming namespace into segments then loop thru them |
| 154 | - $namespace_segments = explode( Psr4Autoloader::NS, trim( $partial_namespace, Psr4Autoloader::NS ) ); |
|
| 154 | + $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS)); |
|
| 155 | 155 | // we're only interested in the first element, so pull that from the array |
| 156 | - $namespace = array_shift( $namespace_segments ); |
|
| 156 | + $namespace = array_shift($namespace_segments); |
|
| 157 | 157 | // check if there's a base directory registered for that namespace |
| 158 | - $prefix = $psr4_loader->prefixes( $namespace . Psr4Autoloader::NS ); |
|
| 158 | + $prefix = $psr4_loader->prefixes($namespace.Psr4Autoloader::NS); |
|
| 159 | 159 | // nope? then the incoming namespace is invalid |
| 160 | - if ( empty( $prefix ) || empty( $prefix[0] ) ) { |
|
| 161 | - throw new InvalidClassException( $partial_namespace ); |
|
| 160 | + if (empty($prefix) || empty($prefix[0])) { |
|
| 161 | + throw new InvalidClassException($partial_namespace); |
|
| 162 | 162 | } |
| 163 | - $this->setNamespace( $namespace, $prefix[0] ); |
|
| 163 | + $this->setNamespace($namespace, $prefix[0]); |
|
| 164 | 164 | // but if it's good, add that base directory to the rest of the path, and return it |
| 165 | - return $prefix[0] . implode( DS, $namespace_segments ) . DS; |
|
| 165 | + return $prefix[0].implode(DS, $namespace_segments).DS; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | |
@@ -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 EEH_Debug_Tools |
| 4 | 4 | * |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @since 4.0 |
| 9 | 9 | * |
| 10 | 10 | */ |
| 11 | -class EEH_Debug_Tools{ |
|
| 11 | +class EEH_Debug_Tools { |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public static function instance() { |
| 43 | 43 | // check if class object is instantiated, and instantiated properly |
| 44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
| 44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
| 45 | 45 | self::$_instance = new self(); |
| 46 | 46 | } |
| 47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | private function __construct() { |
| 59 | 59 | // load Kint PHP debugging library |
| 60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
| 60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
| 61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
| 62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
| 63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
| 64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
| 65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
| 66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
| 66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
| 67 | 67 | } |
| 68 | 68 | // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) { |
| 69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
| 70 | 70 | // } |
| 71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
| 72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
| 73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
| 74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
| 71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
| 72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
| 74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | 84 | public static function show_db_name() { |
| 85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
| 86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
| 85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
| 86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
| 87 | 87 | } |
| 88 | - if ( EE_DEBUG ) { |
|
| 88 | + if (EE_DEBUG) { |
|
| 89 | 89 | EEH_Debug_Tools::instance()->show_times(); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function espresso_session_footer_dump() { |
| 101 | 101 | if ( |
| 102 | - ( defined( 'WP_DEBUG' ) && WP_DEBUG ) |
|
| 103 | - && ! defined( 'DOING_AJAX' ) |
|
| 104 | - && class_exists( 'Kint' ) |
|
| 105 | - && function_exists( 'wp_get_current_user' ) |
|
| 106 | - && current_user_can( 'update_core' ) |
|
| 107 | - && class_exists( 'EE_Registry' ) |
|
| 102 | + (defined('WP_DEBUG') && WP_DEBUG) |
|
| 103 | + && ! defined('DOING_AJAX') |
|
| 104 | + && class_exists('Kint') |
|
| 105 | + && function_exists('wp_get_current_user') |
|
| 106 | + && current_user_can('update_core') |
|
| 107 | + && class_exists('EE_Registry') |
|
| 108 | 108 | ) { |
| 109 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
| 110 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
| 109 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
| 110 | + Kint::dump(EE_Registry::instance()->SSN); |
|
| 111 | 111 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
| 112 | 112 | $this->espresso_list_hooked_functions(); |
| 113 | 113 | $this->show_times(); |
@@ -124,27 +124,27 @@ discard block |
||
| 124 | 124 | * @param string $tag |
| 125 | 125 | * @return void |
| 126 | 126 | */ |
| 127 | - public function espresso_list_hooked_functions( $tag='' ){ |
|
| 127 | + public function espresso_list_hooked_functions($tag = '') { |
|
| 128 | 128 | global $wp_filter; |
| 129 | 129 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
| 130 | - if ( $tag ) { |
|
| 131 | - $hook[$tag]=$wp_filter[$tag]; |
|
| 132 | - if ( ! is_array( $hook[$tag] )) { |
|
| 133 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
| 130 | + if ($tag) { |
|
| 131 | + $hook[$tag] = $wp_filter[$tag]; |
|
| 132 | + if ( ! is_array($hook[$tag])) { |
|
| 133 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
| 136 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
| 137 | 137 | } |
| 138 | 138 | else { |
| 139 | - $hook=$wp_filter; |
|
| 140 | - ksort( $hook ); |
|
| 139 | + $hook = $wp_filter; |
|
| 140 | + ksort($hook); |
|
| 141 | 141 | } |
| 142 | - foreach( $hook as $tag_name => $priorities ) { |
|
| 142 | + foreach ($hook as $tag_name => $priorities) { |
|
| 143 | 143 | echo "<br />>>>>>\t<strong>$tag_name</strong><br />"; |
| 144 | - ksort( $priorities ); |
|
| 145 | - foreach( $priorities as $priority => $function ){ |
|
| 144 | + ksort($priorities); |
|
| 145 | + foreach ($priorities as $priority => $function) { |
|
| 146 | 146 | echo $priority; |
| 147 | - foreach( $function as $name => $properties ) { |
|
| 147 | + foreach ($function as $name => $properties) { |
|
| 148 | 148 | echo "\t$name<br />"; |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -159,15 +159,15 @@ discard block |
||
| 159 | 159 | * @param string $hook_name |
| 160 | 160 | * @return array |
| 161 | 161 | */ |
| 162 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
| 162 | + public static function registered_filter_callbacks($hook_name = '') { |
|
| 163 | 163 | $filters = array(); |
| 164 | 164 | global $wp_filter; |
| 165 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
| 166 | - $filters[ $hook_name ] = array(); |
|
| 167 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
| 168 | - $filters[ $hook_name ][ $priority ] = array(); |
|
| 169 | - foreach ( $callbacks as $callback ) { |
|
| 170 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
| 165 | + if (isset($wp_filter[$hook_name])) { |
|
| 166 | + $filters[$hook_name] = array(); |
|
| 167 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
| 168 | + $filters[$hook_name][$priority] = array(); |
|
| 169 | + foreach ($callbacks as $callback) { |
|
| 170 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | /** |
| 180 | 180 | * reset_times |
| 181 | 181 | */ |
| 182 | - public function reset_times(){ |
|
| 182 | + public function reset_times() { |
|
| 183 | 183 | $this->_times = array(); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | * start_timer |
| 190 | 190 | * @param null $timer_name |
| 191 | 191 | */ |
| 192 | - public function start_timer( $timer_name = NULL ){ |
|
| 193 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
| 192 | + public function start_timer($timer_name = NULL) { |
|
| 193 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -199,15 +199,15 @@ discard block |
||
| 199 | 199 | * stop_timer |
| 200 | 200 | * @param string $timer_name |
| 201 | 201 | */ |
| 202 | - public function stop_timer( $timer_name = '' ){ |
|
| 202 | + public function stop_timer($timer_name = '') { |
|
| 203 | 203 | $timer_name = $timer_name !== '' ? $timer_name : get_called_class(); |
| 204 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
| 205 | - $start_time = $this->_start_times[ $timer_name ]; |
|
| 206 | - unset( $this->_start_times[ $timer_name ] ); |
|
| 207 | - }else{ |
|
| 208 | - $start_time = array_pop( $this->_start_times ); |
|
| 204 | + if (isset($this->_start_times[$timer_name])) { |
|
| 205 | + $start_time = $this->_start_times[$timer_name]; |
|
| 206 | + unset($this->_start_times[$timer_name]); |
|
| 207 | + } else { |
|
| 208 | + $start_time = array_pop($this->_start_times); |
|
| 209 | 209 | } |
| 210 | - $this->_times[ $timer_name ] = number_format( microtime( true ) - $start_time, 8 ); |
|
| 210 | + $this->_times[$timer_name] = number_format(microtime(true) - $start_time, 8); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
| 218 | 218 | * @return void |
| 219 | 219 | */ |
| 220 | - public function measure_memory( $label, $output_now = false ) { |
|
| 221 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
| 222 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
| 223 | - if( $output_now ) { |
|
| 220 | + public function measure_memory($label, $output_now = false) { |
|
| 221 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
| 222 | + $this->_memory_usage_points[$label] = $memory_used; |
|
| 223 | + if ($output_now) { |
|
| 224 | 224 | echo "\r\n<br>$label : $memory_used"; |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | * @param int $size |
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | - public function convert( $size ) { |
|
| 234 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
| 235 | - return @round( $size / pow( 1024, $i = floor( log( $size, 1024 ) ) ), 2 ) . ' ' . $unit[ absint( $i ) ]; |
|
| 233 | + public function convert($size) { |
|
| 234 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
| 235 | + return @round($size / pow(1024, $i = floor(log($size, 1024))), 2).' '.$unit[absint($i)]; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -242,25 +242,25 @@ discard block |
||
| 242 | 242 | * @param bool $output_now |
| 243 | 243 | * @return string |
| 244 | 244 | */ |
| 245 | - public function show_times($output_now=true){ |
|
| 245 | + public function show_times($output_now = true) { |
|
| 246 | 246 | $output = ''; |
| 247 | - if ( ! empty( $this->_times )) { |
|
| 247 | + if ( ! empty($this->_times)) { |
|
| 248 | 248 | $total = 0; |
| 249 | 249 | $output .= '<h2 style="margin:1em .5em 0;">Times:</h2>'; |
| 250 | 250 | $output .= '<span style="color:#9999CC; font-size:.8em; margin:0 1.5em 0;">( in milliseconds )</span><br />'; |
| 251 | - foreach( $this->_times as $timer_name => $total_time ) { |
|
| 252 | - $output .= $this->format_time( $timer_name, $total_time ); |
|
| 251 | + foreach ($this->_times as $timer_name => $total_time) { |
|
| 252 | + $output .= $this->format_time($timer_name, $total_time); |
|
| 253 | 253 | $total += $total_time; |
| 254 | 254 | } |
| 255 | 255 | $output .= '<br />'; |
| 256 | 256 | $output .= '<h4 style="margin:1em .5em 0;">TOTAL TIME</h4>'; |
| 257 | - $output .= $this->format_time( '', $total ); |
|
| 257 | + $output .= $this->format_time('', $total); |
|
| 258 | 258 | $output .= '<br />'; |
| 259 | 259 | } |
| 260 | - if ( ! empty( $this->_memory_usage_points )) { |
|
| 261 | - $output .= '<h2 style="margin:1em .5em 0;">Memory</h2>' . implode( '<br />', $this->_memory_usage_points ); |
|
| 260 | + if ( ! empty($this->_memory_usage_points)) { |
|
| 261 | + $output .= '<h2 style="margin:1em .5em 0;">Memory</h2>'.implode('<br />', $this->_memory_usage_points); |
|
| 262 | 262 | } |
| 263 | - if( $output_now ){ |
|
| 263 | + if ($output_now) { |
|
| 264 | 264 | echo $output; |
| 265 | 265 | return ''; |
| 266 | 266 | } |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | * @param float $total_time |
| 275 | 275 | * @return string |
| 276 | 276 | */ |
| 277 | - public function format_time( $timer_name, $total_time ) { |
|
| 277 | + public function format_time($timer_name, $total_time) { |
|
| 278 | 278 | $total_time = $total_time * 1000; |
| 279 | - switch ( $total_time ) { |
|
| 279 | + switch ($total_time) { |
|
| 280 | 280 | case $total_time < 0.01 : |
| 281 | 281 | $color = '#8A549A'; |
| 282 | 282 | $bold = 'normal'; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | . '; font-weight:' |
| 308 | 308 | . $bold |
| 309 | 309 | . '; font-size:1.2em;">' |
| 310 | - . str_pad( number_format( $total_time, 5 ), 11, '0', STR_PAD_LEFT ) |
|
| 310 | + . str_pad(number_format($total_time, 5), 11, '0', STR_PAD_LEFT) |
|
| 311 | 311 | . '</span> ' |
| 312 | 312 | . $timer_name |
| 313 | 313 | . '<br />'; |
@@ -321,25 +321,25 @@ discard block |
||
| 321 | 321 | * @return void |
| 322 | 322 | */ |
| 323 | 323 | public static function ee_plugin_activation_errors() { |
| 324 | - if ( WP_DEBUG ) { |
|
| 324 | + if (WP_DEBUG) { |
|
| 325 | 325 | $activation_errors = ob_get_contents(); |
| 326 | - if ( ! empty( $activation_errors ) ) { |
|
| 327 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
| 326 | + if ( ! empty($activation_errors)) { |
|
| 327 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
| 328 | 328 | } |
| 329 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
| 330 | - if ( class_exists( 'EEH_File' )) { |
|
| 329 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
| 330 | + if (class_exists('EEH_File')) { |
|
| 331 | 331 | try { |
| 332 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
| 333 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
| 334 | - } catch( EE_Error $e ){ |
|
| 335 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 332 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
| 333 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
| 334 | + } catch (EE_Error $e) { |
|
| 335 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
| 336 | 336 | } |
| 337 | 337 | } else { |
| 338 | 338 | // old school attempt |
| 339 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
| 339 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
| 340 | 340 | } |
| 341 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
| 342 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
| 341 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
| 342 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
@@ -355,22 +355,22 @@ discard block |
||
| 355 | 355 | * @param int $error_type |
| 356 | 356 | * @uses trigger_error() |
| 357 | 357 | */ |
| 358 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
| 359 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
| 360 | - $version = $version === null ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
| 361 | - $error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version ); |
|
| 358 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
| 359 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
| 360 | + $version = $version === null ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
| 361 | + $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version); |
|
| 362 | 362 | |
| 363 | 363 | //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request. |
| 364 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 365 | - $error_message .= ' ' . esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso' ); |
|
| 364 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 365 | + $error_message .= ' '.esc_html__('This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso'); |
|
| 366 | 366 | $error_message .= '<ul><li>'; |
| 367 | - $error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() ); |
|
| 367 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
| 368 | 368 | $error_message .= '</ul>'; |
| 369 | - EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' ); |
|
| 369 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
| 370 | 370 | //now we set this on the transient so it shows up on the next request. |
| 371 | - EE_Error::get_notices( false, true ); |
|
| 371 | + EE_Error::get_notices(false, true); |
|
| 372 | 372 | } else { |
| 373 | - trigger_error( $error_message, $error_type ); |
|
| 373 | + trigger_error($error_message, $error_type); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -392,22 +392,22 @@ discard block |
||
| 392 | 392 | * @param string $debug_index |
| 393 | 393 | * @param string $debug_key |
| 394 | 394 | */ |
| 395 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
| 396 | - if ( WP_DEBUG && false ) { |
|
| 397 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
| 398 | - $debug_data = get_option( $debug_key, array() ); |
|
| 395 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
| 396 | + if (WP_DEBUG && false) { |
|
| 397 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
| 398 | + $debug_data = get_option($debug_key, array()); |
|
| 399 | 399 | $default_data = array( |
| 400 | - $class => $func . '() : ' . $line, |
|
| 400 | + $class => $func.'() : '.$line, |
|
| 401 | 401 | 'REQ' => $display_request ? $_REQUEST : '', |
| 402 | 402 | ); |
| 403 | 403 | // don't serialize objects |
| 404 | - $info = self::strip_objects( $info ); |
|
| 405 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
| 406 | - if ( ! isset( $debug_data[$index] ) ) { |
|
| 404 | + $info = self::strip_objects($info); |
|
| 405 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
| 406 | + if ( ! isset($debug_data[$index])) { |
|
| 407 | 407 | $debug_data[$index] = array(); |
| 408 | 408 | } |
| 409 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
| 410 | - update_option( $debug_key, $debug_data ); |
|
| 409 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
| 410 | + update_option($debug_key, $debug_data); |
|
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | |
@@ -419,26 +419,26 @@ discard block |
||
| 419 | 419 | * @param array $info |
| 420 | 420 | * @return array |
| 421 | 421 | */ |
| 422 | - public static function strip_objects( $info = array() ) { |
|
| 423 | - foreach ( $info as $key => $value ) { |
|
| 424 | - if ( is_array( $value ) ) { |
|
| 425 | - $info[ $key ] = self::strip_objects( $value ); |
|
| 426 | - } else if ( is_object( $value ) ) { |
|
| 427 | - $object_class = get_class( $value ); |
|
| 428 | - $info[ $object_class ] = array(); |
|
| 429 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
| 430 | - if ( method_exists( $value, 'ID' ) ) { |
|
| 431 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
| 422 | + public static function strip_objects($info = array()) { |
|
| 423 | + foreach ($info as $key => $value) { |
|
| 424 | + if (is_array($value)) { |
|
| 425 | + $info[$key] = self::strip_objects($value); |
|
| 426 | + } else if (is_object($value)) { |
|
| 427 | + $object_class = get_class($value); |
|
| 428 | + $info[$object_class] = array(); |
|
| 429 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
| 430 | + if (method_exists($value, 'ID')) { |
|
| 431 | + $info[$object_class]['ID'] = $value->ID(); |
|
| 432 | 432 | } |
| 433 | - if ( method_exists( $value, 'status' ) ) { |
|
| 434 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
| 435 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
| 436 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
| 433 | + if (method_exists($value, 'status')) { |
|
| 434 | + $info[$object_class]['status'] = $value->status(); |
|
| 435 | + } else if (method_exists($value, 'status_ID')) { |
|
| 436 | + $info[$object_class]['status'] = $value->status_ID(); |
|
| 437 | 437 | } |
| 438 | - unset( $info[ $key ] ); |
|
| 438 | + unset($info[$key]); |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | - return (array)$info; |
|
| 441 | + return (array) $info; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | |
@@ -451,23 +451,23 @@ discard block |
||
| 451 | 451 | * @param int $header |
| 452 | 452 | * @param bool $die |
| 453 | 453 | */ |
| 454 | - public static function printv( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
| 454 | + public static function printv($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
| 455 | 455 | $var_name = ! $var_name ? 'string' : $var_name; |
| 456 | 456 | $heading_tag = 'h'; |
| 457 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
| 458 | - $var_name = ucwords( str_replace( '$', '', $var_name ) ); |
|
| 459 | - $is_method = method_exists( $var_name, $var ); |
|
| 460 | - $var_name = ucwords( str_replace( '_', ' ', $var_name ) ); |
|
| 457 | + $heading_tag .= is_int($header) ? $header : 5; |
|
| 458 | + $var_name = ucwords(str_replace('$', '', $var_name)); |
|
| 459 | + $is_method = method_exists($var_name, $var); |
|
| 460 | + $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
| 461 | 461 | $margin = is_admin() ? ' 180px' : '0'; |
| 462 | - $result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0' . $margin . ';"><b>' . $var_name . '</b>'; |
|
| 462 | + $result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>'.$var_name.'</b>'; |
|
| 463 | 463 | $result .= $is_method |
| 464 | - ? '<span style="color:#999">::</span><span style="color:#E76700">' . $var . '()</span><br />' |
|
| 465 | - : '<span style="color:#999"> : </span><span style="color:#E76700">' . $var . '</span><br />'; |
|
| 466 | - $result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file; |
|
| 467 | - $result .= '<br />line no: ' . $line . '</span>'; |
|
| 468 | - $result .= '</' . $heading_tag . '>'; |
|
| 469 | - if ( $die ) { |
|
| 470 | - die( $result ); |
|
| 464 | + ? '<span style="color:#999">::</span><span style="color:#E76700">'.$var.'()</span><br />' |
|
| 465 | + : '<span style="color:#999"> : </span><span style="color:#E76700">'.$var.'</span><br />'; |
|
| 466 | + $result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file; |
|
| 467 | + $result .= '<br />line no: '.$line.'</span>'; |
|
| 468 | + $result .= '</'.$heading_tag.'>'; |
|
| 469 | + if ($die) { |
|
| 470 | + die($result); |
|
| 471 | 471 | } else { |
| 472 | 472 | echo $result; |
| 473 | 473 | } |
@@ -482,38 +482,38 @@ discard block |
||
| 482 | 482 | * @param int $header |
| 483 | 483 | * @param bool $die |
| 484 | 484 | */ |
| 485 | - public static function printr( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
| 485 | + public static function printr($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
| 486 | 486 | // return; |
| 487 | - $file = str_replace( rtrim( ABSPATH, '\\/' ), '', $file ); |
|
| 487 | + $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
| 488 | 488 | //$print_r = false; |
| 489 | - if ( is_string( $var ) ) { |
|
| 490 | - EEH_Debug_Tools::printv( $var, $var_name, $file, $line, $header, $die ); |
|
| 489 | + if (is_string($var)) { |
|
| 490 | + EEH_Debug_Tools::printv($var, $var_name, $file, $line, $header, $die); |
|
| 491 | 491 | return; |
| 492 | - } else if ( is_object( $var ) ) { |
|
| 492 | + } else if (is_object($var)) { |
|
| 493 | 493 | $var_name = ! $var_name ? 'object' : $var_name; |
| 494 | 494 | //$print_r = true; |
| 495 | - } else if ( is_array( $var ) ) { |
|
| 495 | + } else if (is_array($var)) { |
|
| 496 | 496 | $var_name = ! $var_name ? 'array' : $var_name; |
| 497 | 497 | //$print_r = true; |
| 498 | - } else if ( is_numeric( $var ) ) { |
|
| 498 | + } else if (is_numeric($var)) { |
|
| 499 | 499 | $var_name = ! $var_name ? 'numeric' : $var_name; |
| 500 | - } else if ( is_null( $var ) ) { |
|
| 500 | + } else if (is_null($var)) { |
|
| 501 | 501 | $var_name = ! $var_name ? 'null' : $var_name; |
| 502 | 502 | } |
| 503 | 503 | $heading_tag = 'h'; |
| 504 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
| 505 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
| 504 | + $heading_tag .= is_int($header) ? $header : 5; |
|
| 505 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
| 506 | 506 | $margin = is_admin() ? ' 180px' : '0'; |
| 507 | - $result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>' . $var_name . '</b>'; |
|
| 507 | + $result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>'.$var_name.'</b>'; |
|
| 508 | 508 | $result .= '<span style="color:#999;"> : </span><span style="color:#E76700;">'; |
| 509 | 509 | $result .= '<pre style="color:#999; padding:1em; background: #fff">'; |
| 510 | 510 | ob_start(); |
| 511 | - var_dump( $var ); |
|
| 511 | + var_dump($var); |
|
| 512 | 512 | $result .= ob_get_clean(); |
| 513 | - $result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;'.$margin.'">' . $file; |
|
| 514 | - $result .= '<br />line no: ' . $line . '</span></' . $heading_tag . '>'; |
|
| 515 | - if ( $die ) { |
|
| 516 | - die( $result ); |
|
| 513 | + $result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;'.$margin.'">'.$file; |
|
| 514 | + $result .= '<br />line no: '.$line.'</span></'.$heading_tag.'>'; |
|
| 515 | + if ($die) { |
|
| 516 | + die($result); |
|
| 517 | 517 | } else { |
| 518 | 518 | echo $result; |
| 519 | 519 | } |
@@ -530,8 +530,8 @@ discard block |
||
| 530 | 530 | * borrowed from Kint Debugger |
| 531 | 531 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 532 | 532 | */ |
| 533 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
| 534 | - function dump_wp_query(){ |
|
| 533 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
| 534 | + function dump_wp_query() { |
|
| 535 | 535 | global $wp_query; |
| 536 | 536 | d($wp_query); |
| 537 | 537 | } |
@@ -541,8 +541,8 @@ discard block |
||
| 541 | 541 | * borrowed from Kint Debugger |
| 542 | 542 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 543 | 543 | */ |
| 544 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
| 545 | - function dump_wp(){ |
|
| 544 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
| 545 | + function dump_wp() { |
|
| 546 | 546 | global $wp; |
| 547 | 547 | d($wp); |
| 548 | 548 | } |
@@ -552,8 +552,8 @@ discard block |
||
| 552 | 552 | * borrowed from Kint Debugger |
| 553 | 553 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
| 554 | 554 | */ |
| 555 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
| 556 | - function dump_post(){ |
|
| 555 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
| 556 | + function dump_post() { |
|
| 557 | 557 | global $post; |
| 558 | 558 | d($post); |
| 559 | 559 | } |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | // add generic non-identifying messages for non-privileged users |
| 171 | 171 | if ( ! WP_DEBUG ) { |
| 172 | 172 | $output .= '<span class="ee-error-user-msg-spn">' |
| 173 | - . trim( $ex['msg'] ) |
|
| 174 | - . '</span> <sup>' |
|
| 175 | - . $ex['code'] |
|
| 176 | - . '</sup><br />'; |
|
| 173 | + . trim( $ex['msg'] ) |
|
| 174 | + . '</span> <sup>' |
|
| 175 | + . $ex['code'] |
|
| 176 | + . '</sup><br />'; |
|
| 177 | 177 | } else { |
| 178 | 178 | // or helpful developer messages if debugging is on |
| 179 | 179 | $output .= ' |
@@ -182,42 +182,42 @@ discard block |
||
| 182 | 182 | ' |
| 183 | 183 | . sprintf( |
| 184 | 184 | __( '%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso' ), |
| 185 | - '<strong class="ee-error-dev-msg-str">', |
|
| 185 | + '<strong class="ee-error-dev-msg-str">', |
|
| 186 | 186 | $ex['name'], |
| 187 | 187 | '</strong> <span>', |
| 188 | 188 | $ex['code'] . '</span>' |
| 189 | 189 | ) |
| 190 | 190 | . '<br /> |
| 191 | 191 | <span class="big-text">"' |
| 192 | - . trim( $ex['msg'] ) |
|
| 193 | - . '"</span><br/> |
|
| 192 | + . trim( $ex['msg'] ) |
|
| 193 | + . '"</span><br/> |
|
| 194 | 194 | <a id="display-ee-error-trace-' |
| 195 | - . self::$_error_count |
|
| 196 | - . $time |
|
| 197 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
| 198 | - . self::$_error_count |
|
| 199 | - . $time |
|
| 200 | - . '"> |
|
| 195 | + . self::$_error_count |
|
| 196 | + . $time |
|
| 197 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
| 198 | + . self::$_error_count |
|
| 199 | + . $time |
|
| 200 | + . '"> |
|
| 201 | 201 | ' |
| 202 | - . __( 'click to view backtrace and class/method details', 'event_espresso' ) |
|
| 203 | - . ' |
|
| 202 | + . __( 'click to view backtrace and class/method details', 'event_espresso' ) |
|
| 203 | + . ' |
|
| 204 | 204 | </a><br /> |
| 205 | 205 | ' |
| 206 | - . $ex['file'] |
|
| 207 | - . sprintf( |
|
| 208 | - __( '%1$s( line no: %2$s )%3$s', 'event_espresso' ), |
|
| 209 | - ' <span class="small-text lt-grey-text">', |
|
| 210 | - $ex['line'], |
|
| 211 | - '</span>' |
|
| 212 | - ) |
|
| 213 | - . ' |
|
| 206 | + . $ex['file'] |
|
| 207 | + . sprintf( |
|
| 208 | + __( '%1$s( line no: %2$s )%3$s', 'event_espresso' ), |
|
| 209 | + ' <span class="small-text lt-grey-text">', |
|
| 210 | + $ex['line'], |
|
| 211 | + '</span>' |
|
| 212 | + ) |
|
| 213 | + . ' |
|
| 214 | 214 | </p> |
| 215 | 215 | <div id="ee-error-trace-' |
| 216 | - . self::$_error_count |
|
| 217 | - . $time |
|
| 218 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
| 216 | + . self::$_error_count |
|
| 217 | + . $time |
|
| 218 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
| 219 | 219 | ' |
| 220 | - . $trace_details; |
|
| 220 | + . $trace_details; |
|
| 221 | 221 | if ( ! empty( $class ) ) { |
| 222 | 222 | $output .= ' |
| 223 | 223 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $time = time(); |
| 361 | 361 | } |
| 362 | 362 | $exception_log = '----------------------------------------------------------------------------------------' |
| 363 | - . PHP_EOL; |
|
| 363 | + . PHP_EOL; |
|
| 364 | 364 | $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
| 365 | 365 | $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
| 366 | 366 | $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $exception_log .= 'Stack trace: ' . PHP_EOL; |
| 370 | 370 | $exception_log .= $ex['string'] . PHP_EOL; |
| 371 | 371 | $exception_log .= '----------------------------------------------------------------------------------------' |
| 372 | - . PHP_EOL; |
|
| 372 | + . PHP_EOL; |
|
| 373 | 373 | try { |
| 374 | 374 | \EEH_File::ensure_file_exists_and_is_writable( |
| 375 | 375 | EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . BaseException::$_exception_log_file |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\Core\Exceptions; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 5 | - exit( 'No direct script access allowed' ); |
|
| 4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | * @param \Exception $previous |
| 51 | 51 | * @throws \EventEspresso\Core\Exceptions\BaseException |
| 52 | 52 | */ |
| 53 | - public function __construct( $message, $code = 0, \Exception $previous = null ) { |
|
| 54 | - parent::__construct( $message, $code, $previous ); |
|
| 55 | - if ( WP_DEBUG ) { |
|
| 53 | + public function __construct($message, $code = 0, \Exception $previous = null) { |
|
| 54 | + parent::__construct($message, $code, $previous); |
|
| 55 | + if (WP_DEBUG) { |
|
| 56 | 56 | $this->get_error(); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -64,23 +64,23 @@ discard block |
||
| 64 | 64 | * @throws \EventEspresso\Core\Exceptions\BaseException |
| 65 | 65 | */ |
| 66 | 66 | public function get_error() { |
| 67 | - if ( apply_filters( 'FHEE__BaseException__get_error__show_normal_exceptions', false ) ) { |
|
| 67 | + if (apply_filters('FHEE__BaseException__get_error__show_normal_exceptions', false)) { |
|
| 68 | 68 | throw $this; |
| 69 | 69 | } |
| 70 | 70 | // get separate user and developer messages if they exist |
| 71 | - $msg = explode( '||', $this->getMessage() ); |
|
| 71 | + $msg = explode('||', $this->getMessage()); |
|
| 72 | 72 | $user_msg = $msg[0]; |
| 73 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
| 73 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
| 74 | 74 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
| 75 | 75 | // add details to _all_exceptions array |
| 76 | 76 | $x_time = time(); |
| 77 | - self::$_all_exceptions[ $x_time ]['name'] = get_class( $this ); |
|
| 78 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
| 79 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
| 80 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
| 81 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
| 82 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
| 83 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
| 77 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
| 78 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
| 79 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
| 80 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
| 81 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
| 82 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
| 83 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
| 84 | 84 | self::$_error_count++; |
| 85 | 85 | $this->display_errors(); |
| 86 | 86 | } |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | $output = BaseException::_exception_styles(); |
| 100 | 100 | $output .= ' |
| 101 | 101 | <div id="ee-error-message" class="error">'; |
| 102 | - if ( ! WP_DEBUG ) { |
|
| 102 | + if ( ! WP_DEBUG) { |
|
| 103 | 103 | $output .= ' |
| 104 | 104 | <p>'; |
| 105 | 105 | } |
| 106 | 106 | // cycle thru errors |
| 107 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
| 107 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
| 108 | 108 | // process trace info |
| 109 | - if ( empty( $ex['trace'] ) ) { |
|
| 109 | + if (empty($ex['trace'])) { |
|
| 110 | 110 | $trace_details .= __( |
| 111 | 111 | 'Sorry, but no trace information was available for this exception.', |
| 112 | 112 | 'event_espresso' |
@@ -119,47 +119,47 @@ discard block |
||
| 119 | 119 | <th scope="col" align="right" style="width:2.5%;">#</th> |
| 120 | 120 | <th scope="col" align="right" style="width:3.5%;">Line</th> |
| 121 | 121 | <th scope="col" align="left" style="width:40%;">File</th> |
| 122 | - <th scope="col" align="left">' . __( 'Class', 'event_espresso' ) . '->' . __( 'Method( arguments )', 'event_espresso' ) . '</th> |
|
| 122 | + <th scope="col" align="left">' . __('Class', 'event_espresso').'->'.__('Method( arguments )', 'event_espresso').'</th> |
|
| 123 | 123 | </tr>'; |
| 124 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
| 124 | + $last_on_stack = count($ex['trace']) - 1; |
|
| 125 | 125 | // reverse array so that stack is in proper chronological order |
| 126 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
| 127 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
| 128 | - $file = isset( $trace['file'] ) ? $trace['file'] : ''; |
|
| 129 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
| 130 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
| 131 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
| 132 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
| 133 | - $args = isset( $trace['args'] ) && count( $trace['args'] ) > 4 ? ' <br />' . $args . '<br />' : $args; |
|
| 134 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
| 126 | + $sorted_trace = array_reverse($ex['trace']); |
|
| 127 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
| 128 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
| 129 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
| 130 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
| 131 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
| 132 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
| 133 | + $args = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args; |
|
| 134 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
| 135 | 135 | $zebra = $nmbr % 2 !== 0 ? ' odd' : ''; |
| 136 | - if ( empty( $file ) && ! empty( $class ) ) { |
|
| 137 | - $a = new \ReflectionClass( $class ); |
|
| 136 | + if (empty($file) && ! empty($class)) { |
|
| 137 | + $a = new \ReflectionClass($class); |
|
| 138 | 138 | $file = $a->getFileName(); |
| 139 | - if ( empty( $line ) && ! empty( $function ) ) { |
|
| 140 | - $b = new \ReflectionMethod( $class, $function ); |
|
| 139 | + if (empty($line) && ! empty($function)) { |
|
| 140 | + $b = new \ReflectionMethod($class, $function); |
|
| 141 | 141 | $line = $b->getStartLine(); |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | - if ( $nmbr === $last_on_stack ) { |
|
| 144 | + if ($nmbr === $last_on_stack) { |
|
| 145 | 145 | $file = $ex['file'] !== '' ? $ex['file'] : $file; |
| 146 | 146 | $line = $ex['line'] !== '' ? $ex['line'] : $line; |
| 147 | - $error_code = self::generate_error_code( $file, $trace['function'], $line ); |
|
| 147 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
| 148 | 148 | } |
| 149 | - $file = \EEH_File::standardise_directory_separators( $file ); |
|
| 150 | - $nmbr = ! empty( $nmbr ) ? $nmbr : ' '; |
|
| 151 | - $line = ! empty( $line ) ? $line : ' '; |
|
| 152 | - $file = ! empty( $file ) ? $file : ' '; |
|
| 153 | - $class_display = ! empty( $class ) ? $class : ''; |
|
| 154 | - $type = ! empty( $type ) ? $type : ''; |
|
| 155 | - $function = ! empty( $function ) ? $function : ''; |
|
| 156 | - $args = ! empty( $args ) ? '( ' . $args . ' )' : '()'; |
|
| 149 | + $file = \EEH_File::standardise_directory_separators($file); |
|
| 150 | + $nmbr = ! empty($nmbr) ? $nmbr : ' '; |
|
| 151 | + $line = ! empty($line) ? $line : ' '; |
|
| 152 | + $file = ! empty($file) ? $file : ' '; |
|
| 153 | + $class_display = ! empty($class) ? $class : ''; |
|
| 154 | + $type = ! empty($type) ? $type : ''; |
|
| 155 | + $function = ! empty($function) ? $function : ''; |
|
| 156 | + $args = ! empty($args) ? '( '.$args.' )' : '()'; |
|
| 157 | 157 | $trace_details .= ' |
| 158 | 158 | <tr> |
| 159 | - <td align="right" valign="top" class="' . $zebra . '">' . $nmbr . '</td> |
|
| 160 | - <td align="right" valign="top" class="' . $zebra . '">' . $line . '</td> |
|
| 161 | - <td align="left" valign="top" class="' . $zebra . '">' . $file . '</td> |
|
| 162 | - <td align="left" valign="top" class="' . $zebra . '">' . $class_display . $type . $function . $args . '</td> |
|
| 159 | + <td align="right" valign="top" class="' . $zebra.'">'.$nmbr.'</td> |
|
| 160 | + <td align="right" valign="top" class="' . $zebra.'">'.$line.'</td> |
|
| 161 | + <td align="left" valign="top" class="' . $zebra.'">'.$file.'</td> |
|
| 162 | + <td align="left" valign="top" class="' . $zebra.'">'.$class_display.$type.$function.$args.'</td> |
|
| 163 | 163 | </tr>'; |
| 164 | 164 | } |
| 165 | 165 | $trace_details .= ' |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | } |
| 169 | 169 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
| 170 | 170 | // add generic non-identifying messages for non-privileged users |
| 171 | - if ( ! WP_DEBUG ) { |
|
| 171 | + if ( ! WP_DEBUG) { |
|
| 172 | 172 | $output .= '<span class="ee-error-user-msg-spn">' |
| 173 | - . trim( $ex['msg'] ) |
|
| 173 | + . trim($ex['msg']) |
|
| 174 | 174 | . '</span> <sup>' |
| 175 | 175 | . $ex['code'] |
| 176 | 176 | . '</sup><br />'; |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | <p class="ee-error-dev-msg-pg"> |
| 182 | 182 | ' |
| 183 | 183 | . sprintf( |
| 184 | - __( '%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso' ), |
|
| 184 | + __('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'), |
|
| 185 | 185 | '<strong class="ee-error-dev-msg-str">', |
| 186 | 186 | $ex['name'], |
| 187 | 187 | '</strong> <span>', |
| 188 | - $ex['code'] . '</span>' |
|
| 188 | + $ex['code'].'</span>' |
|
| 189 | 189 | ) |
| 190 | 190 | . '<br /> |
| 191 | 191 | <span class="big-text">"' |
| 192 | - . trim( $ex['msg'] ) |
|
| 192 | + . trim($ex['msg']) |
|
| 193 | 193 | . '"</span><br/> |
| 194 | 194 | <a id="display-ee-error-trace-' |
| 195 | 195 | . self::$_error_count |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | . $time |
| 200 | 200 | . '"> |
| 201 | 201 | ' |
| 202 | - . __( 'click to view backtrace and class/method details', 'event_espresso' ) |
|
| 202 | + . __('click to view backtrace and class/method details', 'event_espresso') |
|
| 203 | 203 | . ' |
| 204 | 204 | </a><br /> |
| 205 | 205 | ' |
| 206 | 206 | . $ex['file'] |
| 207 | 207 | . sprintf( |
| 208 | - __( '%1$s( line no: %2$s )%3$s', 'event_espresso' ), |
|
| 208 | + __('%1$s( line no: %2$s )%3$s', 'event_espresso'), |
|
| 209 | 209 | ' <span class="small-text lt-grey-text">', |
| 210 | 210 | $ex['line'], |
| 211 | 211 | '</span>' |
@@ -218,14 +218,14 @@ discard block |
||
| 218 | 218 | . '-dv" class="ee-error-trace-dv" style="display: none;"> |
| 219 | 219 | ' |
| 220 | 220 | . $trace_details; |
| 221 | - if ( ! empty( $class ) ) { |
|
| 221 | + if ( ! empty($class)) { |
|
| 222 | 222 | $output .= ' |
| 223 | 223 | <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;"> |
| 224 | 224 | <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;"> |
| 225 | - <h3>' . __( 'Class Details', 'event_espresso' ) . '</h3>'; |
|
| 226 | - $a = new \ReflectionClass( $class ); |
|
| 225 | + <h3>' . __('Class Details', 'event_espresso').'</h3>'; |
|
| 226 | + $a = new \ReflectionClass($class); |
|
| 227 | 227 | $output .= ' |
| 228 | - <pre>' . $a . '</pre> |
|
| 228 | + <pre>' . $a.'</pre> |
|
| 229 | 229 | </div> |
| 230 | 230 | </div>'; |
| 231 | 231 | } |
@@ -234,19 +234,19 @@ discard block |
||
| 234 | 234 | </div> |
| 235 | 235 | <br />'; |
| 236 | 236 | } |
| 237 | - $this->write_to_error_log( $time, $ex ); |
|
| 237 | + $this->write_to_error_log($time, $ex); |
|
| 238 | 238 | } |
| 239 | 239 | // remove last linebreak |
| 240 | - $output = substr( $output, 0, count( $output ) - 7 ); |
|
| 241 | - if ( ! WP_DEBUG ) { |
|
| 240 | + $output = substr($output, 0, count($output) - 7); |
|
| 241 | + if ( ! WP_DEBUG) { |
|
| 242 | 242 | $output .= ' |
| 243 | 243 | </p>'; |
| 244 | 244 | } |
| 245 | 245 | $output .= ' |
| 246 | 246 | </div>'; |
| 247 | - $output .= self::_print_scripts( true ); |
|
| 248 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 249 | - echo json_encode( array( 'error' => $output ) ); |
|
| 247 | + $output .= self::_print_scripts(true); |
|
| 248 | + if (defined('DOING_AJAX')) { |
|
| 249 | + echo json_encode(array('error' => $output)); |
|
| 250 | 250 | exit(); |
| 251 | 251 | } |
| 252 | 252 | echo $output; |
@@ -263,56 +263,56 @@ discard block |
||
| 263 | 263 | * @param bool $array |
| 264 | 264 | * @return string |
| 265 | 265 | */ |
| 266 | - private function _convert_args_to_string( $arguments = array(), $indent = 0, $array = false ) { |
|
| 266 | + private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false) { |
|
| 267 | 267 | $args = array(); |
| 268 | - $args_count = count( $arguments ); |
|
| 269 | - if ( $args_count > 2 ) { |
|
| 268 | + $args_count = count($arguments); |
|
| 269 | + if ($args_count > 2) { |
|
| 270 | 270 | $indent++; |
| 271 | 271 | $args[] = '<br />'; |
| 272 | 272 | } |
| 273 | 273 | $x = 0; |
| 274 | - foreach ( $arguments as $arg ) { |
|
| 274 | + foreach ($arguments as $arg) { |
|
| 275 | 275 | $x++; |
| 276 | - for( $i = 0; $i < $indent; $i++ ) { |
|
| 276 | + for ($i = 0; $i < $indent; $i++) { |
|
| 277 | 277 | $args[] = ' '; |
| 278 | 278 | } |
| 279 | - if ( is_string( $arg ) ) { |
|
| 280 | - if ( ! $array && strlen( $arg ) > 75 ) { |
|
| 279 | + if (is_string($arg)) { |
|
| 280 | + if ( ! $array && strlen($arg) > 75) { |
|
| 281 | 281 | $args[] = "<br />"; |
| 282 | - for ( $i = 0; $i <= $indent; $i++ ) { |
|
| 282 | + for ($i = 0; $i <= $indent; $i++) { |
|
| 283 | 283 | $args[] = ' '; |
| 284 | 284 | } |
| 285 | - $args[] = "'" . $arg . "'<br />"; |
|
| 285 | + $args[] = "'".$arg."'<br />"; |
|
| 286 | 286 | } else { |
| 287 | - $args[] = " '" . $arg . "'"; |
|
| 287 | + $args[] = " '".$arg."'"; |
|
| 288 | 288 | } |
| 289 | - } elseif ( is_array( $arg ) ) { |
|
| 290 | - $arg_count = count( $arg ); |
|
| 291 | - if ( $arg_count > 2 ) { |
|
| 289 | + } elseif (is_array($arg)) { |
|
| 290 | + $arg_count = count($arg); |
|
| 291 | + if ($arg_count > 2) { |
|
| 292 | 292 | $indent++; |
| 293 | - $args[] = " array(" . $this->_convert_args_to_string( $arg, $indent, true ) . ")"; |
|
| 293 | + $args[] = " array(".$this->_convert_args_to_string($arg, $indent, true).")"; |
|
| 294 | 294 | $indent--; |
| 295 | - } else if ( $arg_count === 0 ) { |
|
| 295 | + } else if ($arg_count === 0) { |
|
| 296 | 296 | $args[] = " array()"; |
| 297 | 297 | } else { |
| 298 | - $args[] = " array( " . $this->_convert_args_to_string( $arg ) . " )"; |
|
| 298 | + $args[] = " array( ".$this->_convert_args_to_string($arg)." )"; |
|
| 299 | 299 | } |
| 300 | - } elseif ( $arg === null ) { |
|
| 300 | + } elseif ($arg === null) { |
|
| 301 | 301 | $args[] = ' null'; |
| 302 | - } elseif ( is_bool( $arg ) ) { |
|
| 302 | + } elseif (is_bool($arg)) { |
|
| 303 | 303 | $args[] = $arg ? ' true' : ' false'; |
| 304 | - } elseif ( is_object( $arg ) ) { |
|
| 305 | - $args[] = get_class( $arg ); |
|
| 306 | - } elseif ( is_resource( $arg ) ) { |
|
| 307 | - $args[] = get_resource_type( $arg ); |
|
| 304 | + } elseif (is_object($arg)) { |
|
| 305 | + $args[] = get_class($arg); |
|
| 306 | + } elseif (is_resource($arg)) { |
|
| 307 | + $args[] = get_resource_type($arg); |
|
| 308 | 308 | } else { |
| 309 | 309 | $args[] = $arg; |
| 310 | 310 | } |
| 311 | - if ( $x === $args_count ) { |
|
| 312 | - if ( $args_count > 2 ) { |
|
| 311 | + if ($x === $args_count) { |
|
| 312 | + if ($args_count > 2) { |
|
| 313 | 313 | $args[] = "<br />"; |
| 314 | 314 | $indent--; |
| 315 | - for ( $i = 1; $i < $indent; $i++ ) { |
|
| 315 | + for ($i = 1; $i < $indent; $i++) { |
|
| 316 | 316 | $args[] = ' '; |
| 317 | 317 | } |
| 318 | 318 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $args[] = $args_count > 2 ? ",<br />" : ', '; |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | - return implode( '', $args ); |
|
| 323 | + return implode('', $args); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | * @param string $line |
| 336 | 336 | * @return string |
| 337 | 337 | */ |
| 338 | - public static function generate_error_code( $file = '', $func = '', $line = '' ) { |
|
| 339 | - $file_bits = explode( '.', basename( $file ) ); |
|
| 340 | - $error_code = ! empty( $file_bits[0] ) ? $file_bits[0] : ''; |
|
| 341 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
| 342 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
| 338 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
| 339 | + $file_bits = explode('.', basename($file)); |
|
| 340 | + $error_code = ! empty($file_bits[0]) ? $file_bits[0] : ''; |
|
| 341 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
| 342 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
| 343 | 343 | return $error_code; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -352,43 +352,43 @@ discard block |
||
| 352 | 352 | * @param array $ex |
| 353 | 353 | * @param bool $clear |
| 354 | 354 | */ |
| 355 | - public function write_to_error_log( $time = 0, $ex = array(), $clear = false ) { |
|
| 356 | - if ( empty( $ex ) ) { |
|
| 355 | + public function write_to_error_log($time = 0, $ex = array(), $clear = false) { |
|
| 356 | + if (empty($ex)) { |
|
| 357 | 357 | return; |
| 358 | 358 | } |
| 359 | - if ( ! $time ) { |
|
| 359 | + if ( ! $time) { |
|
| 360 | 360 | $time = time(); |
| 361 | 361 | } |
| 362 | 362 | $exception_log = '----------------------------------------------------------------------------------------' |
| 363 | 363 | . PHP_EOL; |
| 364 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
| 365 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
| 366 | - $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
| 367 | - $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
| 368 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
| 369 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
| 370 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
| 364 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
| 365 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
| 366 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
| 367 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
| 368 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
| 369 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
| 370 | + $exception_log .= $ex['string'].PHP_EOL; |
|
| 371 | 371 | $exception_log .= '----------------------------------------------------------------------------------------' |
| 372 | 372 | . PHP_EOL; |
| 373 | 373 | try { |
| 374 | 374 | \EEH_File::ensure_file_exists_and_is_writable( |
| 375 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . BaseException::$_exception_log_file |
|
| 375 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.BaseException::$_exception_log_file |
|
| 376 | 376 | ); |
| 377 | - \EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); |
|
| 378 | - if ( ! $clear ) { |
|
| 377 | + \EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); |
|
| 378 | + if ( ! $clear) { |
|
| 379 | 379 | //get existing log file and append new log info |
| 380 | 380 | $exception_log = \EEH_File::get_file_contents( |
| 381 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . BaseException::$_exception_log_file |
|
| 382 | - ) . $exception_log; |
|
| 381 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.BaseException::$_exception_log_file |
|
| 382 | + ).$exception_log; |
|
| 383 | 383 | } |
| 384 | 384 | \EEH_File::write_to_file( |
| 385 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . BaseException::$_exception_log_file, |
|
| 385 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.BaseException::$_exception_log_file, |
|
| 386 | 386 | $exception_log |
| 387 | 387 | ); |
| 388 | - } catch ( \Exception $e ) { |
|
| 388 | + } catch (\Exception $e) { |
|
| 389 | 389 | \EE_Error::add_error( |
| 390 | 390 | sprintf( |
| 391 | - __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), |
|
| 391 | + __('Event Espresso error logging could not be setup because: %s', 'event_espresso'), |
|
| 392 | 392 | $e->getMessage() |
| 393 | 393 | ) |
| 394 | 394 | ); |
@@ -472,26 +472,26 @@ discard block |
||
| 472 | 472 | * @param bool $force_print |
| 473 | 473 | * @return string|void |
| 474 | 474 | */ |
| 475 | - private static function _print_scripts( $force_print = false ) { |
|
| 476 | - if ( ! $force_print && ( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' ) ) ) { |
|
| 477 | - if ( wp_script_is( 'ee_error_js', 'enqueued' ) ) { |
|
| 475 | + private static function _print_scripts($force_print = false) { |
|
| 476 | + if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
| 477 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
| 478 | 478 | return ''; |
| 479 | - } else if ( wp_script_is( 'ee_error_js', 'registered' ) ) { |
|
| 480 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
| 481 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
| 482 | - wp_enqueue_script( 'ee_error_js' ); |
|
| 483 | - wp_localize_script( 'ee_error_js', 'ee_settings', array( 'wp_debug' => WP_DEBUG ) ); |
|
| 479 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
| 480 | + add_filter('FHEE_load_css', '__return_true'); |
|
| 481 | + add_filter('FHEE_load_js', '__return_true'); |
|
| 482 | + wp_enqueue_script('ee_error_js'); |
|
| 483 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
| 484 | 484 | } |
| 485 | 485 | } else { |
| 486 | 486 | return ' |
| 487 | 487 | <script> |
| 488 | 488 | /* <![CDATA[ */ |
| 489 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
| 489 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
| 490 | 490 | /* ]]> */ |
| 491 | 491 | </script> |
| 492 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
| 493 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
| 494 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
| 492 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
| 493 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
| 494 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
| 495 | 495 | '; |
| 496 | 496 | } |
| 497 | 497 | return ''; |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | use EventEspresso\Core\Exceptions\InvalidDataTypeException; |
| 6 | 6 | use FilesystemIterator; |
| 7 | 7 | |
| 8 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 9 | - exit( 'No direct script access allowed' ); |
|
| 8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 9 | + exit('No direct script access allowed'); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | * @param array $flags controls how files are found and/or file data is returned |
| 36 | 36 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 37 | 37 | */ |
| 38 | - public function __construct( $flags = array() ) { |
|
| 39 | - if ( empty( $flags ) ) { |
|
| 38 | + public function __construct($flags = array()) { |
|
| 39 | + if (empty($flags)) { |
|
| 40 | 40 | $flags = array( |
| 41 | 41 | FilesystemIterator::SKIP_DOTS, |
| 42 | 42 | FilesystemIterator::UNIX_PATHS, |
| 43 | 43 | FilesystemIterator::CURRENT_AS_PATHNAME |
| 44 | 44 | ); |
| 45 | 45 | } |
| 46 | - $this->setFlags( $flags ); |
|
| 46 | + $this->setFlags($flags); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * @param array $flags |
| 55 | 55 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 56 | 56 | */ |
| 57 | - public function setFlags( $flags ) { |
|
| 58 | - if ( ! is_array( $flags ) ) { |
|
| 59 | - throw new InvalidDataTypeException( '$flags', $flags, 'array' ); |
|
| 57 | + public function setFlags($flags) { |
|
| 58 | + if ( ! is_array($flags)) { |
|
| 59 | + throw new InvalidDataTypeException('$flags', $flags, 'array'); |
|
| 60 | 60 | } |
| 61 | 61 | $this->flags = $flags; |
| 62 | 62 | } |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | use FilesystemIterator; |
| 6 | 6 | use GlobIterator; |
| 7 | 7 | |
| 8 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 9 | - exit( 'No direct script access allowed' ); |
|
| 8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 9 | + exit('No direct script access allowed'); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | * @param string $file_mask |
| 39 | 39 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 40 | 40 | */ |
| 41 | - public function setFileMask( $file_mask ) { |
|
| 42 | - if ( ! is_string( $file_mask ) ) { |
|
| 43 | - throw new InvalidDataTypeException( '$file_mask', $file_mask, 'string' ); |
|
| 41 | + public function setFileMask($file_mask) { |
|
| 42 | + if ( ! is_string($file_mask)) { |
|
| 43 | + throw new InvalidDataTypeException('$file_mask', $file_mask, 'string'); |
|
| 44 | 44 | } |
| 45 | 45 | $this->file_mask = $file_mask; |
| 46 | 46 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @return int |
| 64 | 64 | */ |
| 65 | 65 | public function count() { |
| 66 | - return count( $this->filepaths ); |
|
| 66 | + return count($this->filepaths); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | * @return \FilesystemIterator |
| 78 | 78 | * @throws \EventEspresso\Core\Exceptions\InvalidDataTypeException |
| 79 | 79 | */ |
| 80 | - public function locate( $directory_paths ) { |
|
| 81 | - if ( ! ( is_string( $directory_paths ) || is_array( $directory_paths ) ) ) { |
|
| 82 | - throw new InvalidDataTypeException( '$directory_paths', $directory_paths, 'string or array' ); |
|
| 80 | + public function locate($directory_paths) { |
|
| 81 | + if ( ! (is_string($directory_paths) || is_array($directory_paths))) { |
|
| 82 | + throw new InvalidDataTypeException('$directory_paths', $directory_paths, 'string or array'); |
|
| 83 | 83 | } |
| 84 | - foreach ( (array) $directory_paths as $directory_path ) { |
|
| 85 | - foreach ( $this->findFilesByPath( $directory_path ) as $key => $file ) { |
|
| 86 | - $this->filepaths[ $key ] = \EEH_File::standardise_directory_separators( $file ); |
|
| 84 | + foreach ((array) $directory_paths as $directory_path) { |
|
| 85 | + foreach ($this->findFilesByPath($directory_path) as $key => $file) { |
|
| 86 | + $this->filepaths[$key] = \EEH_File::standardise_directory_separators($file); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | return $this->filepaths; |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | * @param string $directory_path |
| 99 | 99 | * @return \FilesystemIterator |
| 100 | 100 | */ |
| 101 | - protected function findFilesByPath( $directory_path = '' ) { |
|
| 102 | - $iterator = new GlobIterator ( |
|
| 103 | - \EEH_File::end_with_directory_separator( $directory_path ) . $this->file_mask |
|
| 101 | + protected function findFilesByPath($directory_path = '') { |
|
| 102 | + $iterator = new GlobIterator( |
|
| 103 | + \EEH_File::end_with_directory_separator($directory_path).$this->file_mask |
|
| 104 | 104 | ); |
| 105 | - foreach ( $this->flags as $flag ) { |
|
| 106 | - $iterator->setFlags( $flag ); |
|
| 105 | + foreach ($this->flags as $flag) { |
|
| 106 | + $iterator->setFlags($flag); |
|
| 107 | 107 | } |
| 108 | 108 | return $iterator; |
| 109 | 109 | } |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\core\services\locators; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 5 | - exit( 'No direct script access allowed' ); |
|
| 4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param array|string $location |
| 23 | 23 | * @return \FilesystemIterator |
| 24 | 24 | */ |
| 25 | - public function locate( $location ); |
|
| 25 | + public function locate($location); |
|
| 26 | 26 | |
| 27 | 27 | } |
| 28 | 28 | // End of file LocatorInterface.php |