@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
| 217 | 217 | if ( ! EE_Processor_Base::$IPN ) { |
| 218 | - // otherwise, send out notifications |
|
| 218 | + // otherwise, send out notifications |
|
| 219 | 219 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
| 220 | 220 | } |
| 221 | 221 | // DEBUG LOG |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
| 264 | 264 | if ( ! EE_Processor_Base::$IPN ) { |
| 265 | - // otherwise, send out notifications |
|
| 265 | + // otherwise, send out notifications |
|
| 266 | 266 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
| 267 | 267 | } |
| 268 | 268 | // DEBUG LOG |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
| 351 | 351 | if ( ! EE_Processor_Base::$IPN ) { |
| 352 | - // otherwise, send out notifications |
|
| 352 | + // otherwise, send out notifications |
|
| 353 | 353 | add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
| 354 | 354 | } |
| 355 | 355 | // DEBUG LOG |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | // false, |
| 391 | 391 | // 'EE_Transaction: ' . $registration->transaction()->ID() |
| 392 | 392 | // ); |
| 393 | - if ( ! $registration->is_primary_registrant()) { |
|
| 394 | - return; |
|
| 395 | - } |
|
| 396 | - do_action( |
|
| 393 | + if ( ! $registration->is_primary_registrant()) { |
|
| 394 | + return; |
|
| 395 | + } |
|
| 396 | + do_action( |
|
| 397 | 397 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
| 398 | 398 | $registration, |
| 399 | 399 | $additional_details |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | // set new REG_Status |
| 429 | 429 | $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
| 430 | 430 | return $this->reg_status_updated( $registration->ID() ) |
| 431 | - && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
| 431 | + && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
| 432 | 432 | ? true |
| 433 | 433 | : false; |
| 434 | 434 | } |
@@ -508,15 +508,15 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | |
| 510 | 510 | |
| 511 | - /** |
|
| 512 | - * update_registration_after_being_canceled_or_declined |
|
| 513 | - * |
|
| 514 | - * @param \EE_Registration $registration |
|
| 515 | - * @param array $closed_reg_statuses |
|
| 516 | - * @param bool $update_reg |
|
| 517 | - * @return bool |
|
| 518 | - * @throws \EE_Error |
|
| 519 | - */ |
|
| 511 | + /** |
|
| 512 | + * update_registration_after_being_canceled_or_declined |
|
| 513 | + * |
|
| 514 | + * @param \EE_Registration $registration |
|
| 515 | + * @param array $closed_reg_statuses |
|
| 516 | + * @param bool $update_reg |
|
| 517 | + * @return bool |
|
| 518 | + * @throws \EE_Error |
|
| 519 | + */ |
|
| 520 | 520 | public function update_registration_after_being_canceled_or_declined( |
| 521 | 521 | EE_Registration $registration, |
| 522 | 522 | $closed_reg_statuses = array(), |
@@ -524,14 +524,14 @@ discard block |
||
| 524 | 524 | ) { |
| 525 | 525 | // these reg statuses should not be considered in any calculations involving monies owing |
| 526 | 526 | $closed_reg_statuses = ! empty( $closed_reg_statuses ) |
| 527 | - ? $closed_reg_statuses |
|
| 527 | + ? $closed_reg_statuses |
|
| 528 | 528 | : EEM_Registration::closed_reg_statuses(); |
| 529 | 529 | if ( ! in_array( $registration->status_ID(), $closed_reg_statuses, true ) ) { |
| 530 | 530 | return false; |
| 531 | 531 | } |
| 532 | - // release a reserved ticket by decrementing ticket and datetime reserved values |
|
| 533 | - $registration->release_reserved_ticket(true); |
|
| 534 | - $registration->set_final_price(0); |
|
| 532 | + // release a reserved ticket by decrementing ticket and datetime reserved values |
|
| 533 | + $registration->release_reserved_ticket(true); |
|
| 534 | + $registration->set_final_price(0); |
|
| 535 | 535 | if ( $update_reg ) { |
| 536 | 536 | $registration->save(); |
| 537 | 537 | } |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | use EventEspresso\core\domain\entities\RegUrlLink; |
| 4 | 4 | use EventEspresso\core\domain\services\registration\CreateRegistrationService; |
| 5 | 5 | |
| 6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
| 7 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
| 6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
| 7 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Class EE_Registration_Processor |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public static function instance() { |
| 68 | 68 | // check if class object is instantiated |
| 69 | - if ( ! self::$_instance instanceof EE_Registration_Processor ) { |
|
| 69 | + if ( ! self::$_instance instanceof EE_Registration_Processor) { |
|
| 70 | 70 | self::$_instance = new self(); |
| 71 | 71 | } |
| 72 | 72 | return self::$_instance; |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * @param int $REG_ID |
| 87 | 87 | * @return string |
| 88 | 88 | */ |
| 89 | - public function old_reg_status( $REG_ID ) { |
|
| 90 | - return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null; |
|
| 89 | + public function old_reg_status($REG_ID) { |
|
| 90 | + return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | * @param int $REG_ID |
| 97 | 97 | * @param string $old_reg_status |
| 98 | 98 | */ |
| 99 | - public function set_old_reg_status( $REG_ID, $old_reg_status ) { |
|
| 99 | + public function set_old_reg_status($REG_ID, $old_reg_status) { |
|
| 100 | 100 | // only set the first time |
| 101 | - if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) { |
|
| 102 | - $this->_old_reg_status[ $REG_ID ] = $old_reg_status; |
|
| 101 | + if ( ! isset($this->_old_reg_status[$REG_ID])) { |
|
| 102 | + $this->_old_reg_status[$REG_ID] = $old_reg_status; |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | * @param int $REG_ID |
| 110 | 110 | * @return string |
| 111 | 111 | */ |
| 112 | - public function new_reg_status( $REG_ID ) { |
|
| 113 | - return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null; |
|
| 112 | + public function new_reg_status($REG_ID) { |
|
| 113 | + return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @param int $REG_ID |
| 120 | 120 | * @param string $new_reg_status |
| 121 | 121 | */ |
| 122 | - public function set_new_reg_status( $REG_ID, $new_reg_status ) { |
|
| 123 | - $this->_new_reg_status[ $REG_ID ] = $new_reg_status; |
|
| 122 | + public function set_new_reg_status($REG_ID, $new_reg_status) { |
|
| 123 | + $this->_new_reg_status[$REG_ID] = $new_reg_status; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @param int $REG_ID |
| 132 | 132 | * @return bool |
| 133 | 133 | */ |
| 134 | - public function reg_status_updated( $REG_ID ) { |
|
| 135 | - return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false; |
|
| 134 | + public function reg_status_updated($REG_ID) { |
|
| 135 | + return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | * @param \EE_Registration $registration |
| 142 | 142 | * @throws \EE_Error |
| 143 | 143 | */ |
| 144 | - public function update_registration_status_and_trigger_notifications( \EE_Registration $registration ) { |
|
| 145 | - $this->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
| 146 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ); |
|
| 147 | - $this->toggle_registration_status_if_no_monies_owing( $registration, false ); |
|
| 144 | + public function update_registration_status_and_trigger_notifications(\EE_Registration $registration) { |
|
| 145 | + $this->toggle_incomplete_registration_status_to_default($registration, false); |
|
| 146 | + $this->toggle_registration_status_for_default_approved_events($registration, false); |
|
| 147 | + $this->toggle_registration_status_if_no_monies_owing($registration, false); |
|
| 148 | 148 | $registration->save(); |
| 149 | 149 | // trigger notifications |
| 150 | - $this->trigger_registration_update_notifications( $registration ); |
|
| 150 | + $this->trigger_registration_update_notifications($registration); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -162,18 +162,18 @@ discard block |
||
| 162 | 162 | * @return boolean |
| 163 | 163 | * @throws \EE_Error |
| 164 | 164 | */ |
| 165 | - public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) { |
|
| 165 | + public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) { |
|
| 166 | 166 | // set initial REG_Status |
| 167 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
| 167 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
| 168 | 168 | // set incoming REG_Status |
| 169 | - $this->set_new_reg_status( $registration->ID(), $new_reg_status ); |
|
| 169 | + $this->set_new_reg_status($registration->ID(), $new_reg_status); |
|
| 170 | 170 | // toggle reg status but only if it has changed and the user can do so |
| 171 | 171 | if ( |
| 172 | - $this->reg_status_updated( $registration->ID() ) && |
|
| 173 | - EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() ) |
|
| 172 | + $this->reg_status_updated($registration->ID()) && |
|
| 173 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID()) |
|
| 174 | 174 | ) { |
| 175 | 175 | // change status to new value |
| 176 | - if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) ) && $save ) { |
|
| 176 | + if ($registration->set_status($this->new_reg_status($registration->ID())) && $save) { |
|
| 177 | 177 | $registration->save(); |
| 178 | 178 | } |
| 179 | 179 | return TRUE; |
@@ -193,30 +193,30 @@ discard block |
||
| 193 | 193 | * @return void |
| 194 | 194 | * @throws \EE_Error |
| 195 | 195 | */ |
| 196 | - public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) { |
|
| 196 | + public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) { |
|
| 197 | 197 | $existing_reg_status = $registration->status_ID(); |
| 198 | 198 | // set initial REG_Status |
| 199 | - $this->set_old_reg_status( $registration->ID(), $existing_reg_status ); |
|
| 199 | + $this->set_old_reg_status($registration->ID(), $existing_reg_status); |
|
| 200 | 200 | // is the registration currently incomplete ? |
| 201 | - if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) { |
|
| 201 | + if ($registration->status_ID() === EEM_Registration::status_id_incomplete) { |
|
| 202 | 202 | // grab default reg status for the event, if set |
| 203 | 203 | $event_default_registration_status = $registration->event()->default_registration_status(); |
| 204 | 204 | // if no default reg status is set for the event, then use the global value |
| 205 | - $STS_ID = ! empty( $event_default_registration_status ) |
|
| 205 | + $STS_ID = ! empty($event_default_registration_status) |
|
| 206 | 206 | ? $event_default_registration_status |
| 207 | 207 | : EE_Registry::instance()->CFG->registration->default_STS_ID; |
| 208 | 208 | // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered |
| 209 | 209 | $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID; |
| 210 | 210 | // set incoming REG_Status |
| 211 | - $this->set_new_reg_status( $registration->ID(), $STS_ID ); |
|
| 212 | - $registration->set_status( $STS_ID ); |
|
| 213 | - if ( $save ) { |
|
| 211 | + $this->set_new_reg_status($registration->ID(), $STS_ID); |
|
| 212 | + $registration->set_status($STS_ID); |
|
| 213 | + if ($save) { |
|
| 214 | 214 | $registration->save(); |
| 215 | 215 | } |
| 216 | 216 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
| 217 | - if ( ! EE_Processor_Base::$IPN ) { |
|
| 217 | + if ( ! EE_Processor_Base::$IPN) { |
|
| 218 | 218 | // otherwise, send out notifications |
| 219 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
| 219 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
| 220 | 220 | } |
| 221 | 221 | // DEBUG LOG |
| 222 | 222 | //$this->log( |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | * @return boolean |
| 242 | 242 | * @throws \EE_Error |
| 243 | 243 | */ |
| 244 | - public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) { |
|
| 244 | + public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) { |
|
| 245 | 245 | $reg_status = $registration->status_ID(); |
| 246 | 246 | // set initial REG_Status |
| 247 | - $this->set_old_reg_status( $registration->ID(), $reg_status ); |
|
| 247 | + $this->set_old_reg_status($registration->ID(), $reg_status); |
|
| 248 | 248 | // if not already, toggle reg status to approved IF the event default reg status is approved |
| 249 | 249 | // ( as long as the registration wasn't cancelled or declined at some point ) |
| 250 | 250 | if ( |
@@ -254,16 +254,16 @@ discard block |
||
| 254 | 254 | $registration->event()->default_registration_status() === EEM_Registration::status_id_approved |
| 255 | 255 | ) { |
| 256 | 256 | // set incoming REG_Status |
| 257 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
| 257 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
| 258 | 258 | // toggle status to approved |
| 259 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
| 260 | - if ( $save ) { |
|
| 259 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
| 260 | + if ($save) { |
|
| 261 | 261 | $registration->save(); |
| 262 | 262 | } |
| 263 | 263 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
| 264 | - if ( ! EE_Processor_Base::$IPN ) { |
|
| 264 | + if ( ! EE_Processor_Base::$IPN) { |
|
| 265 | 265 | // otherwise, send out notifications |
| 266 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
| 266 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
| 267 | 267 | } |
| 268 | 268 | // DEBUG LOG |
| 269 | 269 | //$this->log( |
@@ -291,19 +291,19 @@ discard block |
||
| 291 | 291 | * @return bool |
| 292 | 292 | * @throws \EE_Error |
| 293 | 293 | */ |
| 294 | - public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) { |
|
| 294 | + public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) { |
|
| 295 | 295 | // set initial REG_Status |
| 296 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
| 296 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
| 297 | 297 | //EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ ); |
| 298 | 298 | // was a payment just made ? |
| 299 | 299 | if ( |
| 300 | - isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) && |
|
| 301 | - $additional_details[ 'payment_updates' ] && |
|
| 302 | - $additional_details[ 'last_payment' ] instanceof EE_Payment |
|
| 300 | + isset($additional_details['payment_updates'], $additional_details['last_payment']) && |
|
| 301 | + $additional_details['payment_updates'] && |
|
| 302 | + $additional_details['last_payment'] instanceof EE_Payment |
|
| 303 | 303 | ) { |
| 304 | - $payment = $additional_details[ 'last_payment' ]; |
|
| 304 | + $payment = $additional_details['last_payment']; |
|
| 305 | 305 | $total_paid = 0; |
| 306 | - foreach ( self::$_amount_paid as $reg => $amount_paid ) { |
|
| 306 | + foreach (self::$_amount_paid as $reg => $amount_paid) { |
|
| 307 | 307 | $total_paid += $amount_paid; |
| 308 | 308 | } |
| 309 | 309 | } else { |
@@ -327,30 +327,30 @@ discard block |
||
| 327 | 327 | $registration->transaction()->is_completed() || |
| 328 | 328 | $registration->transaction()->is_overpaid() || |
| 329 | 329 | $registration->transaction()->is_free() || |
| 330 | - apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration ) |
|
| 330 | + apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration) |
|
| 331 | 331 | ) || ( |
| 332 | 332 | $payment instanceof EE_Payment && |
| 333 | 333 | $payment->is_approved() && |
| 334 | 334 | // this specific registration has not yet been paid for |
| 335 | - ! isset( self::$_amount_paid[ $registration->ID() ] ) && |
|
| 335 | + ! isset(self::$_amount_paid[$registration->ID()]) && |
|
| 336 | 336 | // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price |
| 337 | 337 | $payment->amount() - $total_paid >= $registration->final_price() |
| 338 | 338 | ) |
| 339 | 339 | ) |
| 340 | 340 | ) { |
| 341 | 341 | // mark as paid |
| 342 | - self::$_amount_paid[ $registration->ID() ] = $registration->final_price(); |
|
| 342 | + self::$_amount_paid[$registration->ID()] = $registration->final_price(); |
|
| 343 | 343 | // track new REG_Status |
| 344 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
| 344 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
| 345 | 345 | // toggle status to approved |
| 346 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
| 347 | - if ( $save ) { |
|
| 346 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
| 347 | + if ($save) { |
|
| 348 | 348 | $registration->save(); |
| 349 | 349 | } |
| 350 | 350 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
| 351 | - if ( ! EE_Processor_Base::$IPN ) { |
|
| 351 | + if ( ! EE_Processor_Base::$IPN) { |
|
| 352 | 352 | // otherwise, send out notifications |
| 353 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
| 353 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
| 354 | 354 | } |
| 355 | 355 | // DEBUG LOG |
| 356 | 356 | //$this->log( |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | * @param array $additional_details |
| 377 | 377 | * @return void |
| 378 | 378 | */ |
| 379 | - public function trigger_registration_update_notifications( $registration, $additional_details = array() ) { |
|
| 379 | + public function trigger_registration_update_notifications($registration, $additional_details = array()) { |
|
| 380 | 380 | try { |
| 381 | - if ( ! $registration instanceof EE_Registration ) { |
|
| 382 | - throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) ); |
|
| 381 | + if ( ! $registration instanceof EE_Registration) { |
|
| 382 | + throw new EE_Error(__('An invalid registration was received.', 'event_espresso')); |
|
| 383 | 383 | } |
| 384 | 384 | // EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
| 385 | 385 | // EEH_Debug_Tools::log( |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | $registration, |
| 399 | 399 | $additional_details |
| 400 | 400 | ); |
| 401 | - } catch( Exception $e ) { |
|
| 402 | - EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() ); |
|
| 401 | + } catch (Exception $e) { |
|
| 402 | + EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine()); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
@@ -413,22 +413,22 @@ discard block |
||
| 413 | 413 | * @return bool |
| 414 | 414 | * @throws \EE_Error |
| 415 | 415 | */ |
| 416 | - public function update_registration_after_checkout_or_payment( EE_Registration $registration, $additional_details = array() ) { |
|
| 416 | + public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) { |
|
| 417 | 417 | // set initial REG_Status |
| 418 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
| 418 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
| 419 | 419 | |
| 420 | 420 | // if the registration status gets updated, then save the registration |
| 421 | 421 | if ( |
| 422 | - $this->toggle_registration_status_for_default_approved_events( $registration, false ) |
|
| 423 | - || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details ) |
|
| 422 | + $this->toggle_registration_status_for_default_approved_events($registration, false) |
|
| 423 | + || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details) |
|
| 424 | 424 | ) { |
| 425 | 425 | $registration->save(); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | // set new REG_Status |
| 429 | - $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
|
| 430 | - return $this->reg_status_updated( $registration->ID() ) |
|
| 431 | - && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved |
|
| 429 | + $this->set_new_reg_status($registration->ID(), $registration->status_ID()); |
|
| 430 | + return $this->reg_status_updated($registration->ID()) |
|
| 431 | + && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved |
|
| 432 | 432 | ? true |
| 433 | 433 | : false; |
| 434 | 434 | } |
@@ -444,20 +444,20 @@ discard block |
||
| 444 | 444 | * @return void |
| 445 | 445 | * @throws \EE_Error |
| 446 | 446 | */ |
| 447 | - public function update_registration_final_prices( $transaction, $save_regs = true ) { |
|
| 448 | - $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
| 449 | - foreach( $transaction->registrations() as $registration ) { |
|
| 447 | + public function update_registration_final_prices($transaction, $save_regs = true) { |
|
| 448 | + $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
| 449 | + foreach ($transaction->registrations() as $registration) { |
|
| 450 | 450 | /** @var EE_Line_Item $line_item */ |
| 451 | - $line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration ); |
|
| 452 | - if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) { |
|
| 453 | - $registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ); |
|
| 454 | - if( $save_regs ) { |
|
| 451 | + $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration); |
|
| 452 | + if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) { |
|
| 453 | + $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]); |
|
| 454 | + if ($save_regs) { |
|
| 455 | 455 | $registration->save(); |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | //and make sure there's no rounding problem |
| 460 | - $this->fix_reg_final_price_rounding_issue( $transaction ); |
|
| 460 | + $this->fix_reg_final_price_rounding_issue($transaction); |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @return boolean success verifying that there is NO difference after this method is done |
| 478 | 478 | * @throws \EE_Error |
| 479 | 479 | */ |
| 480 | - public function fix_reg_final_price_rounding_issue( $transaction ) { |
|
| 480 | + public function fix_reg_final_price_rounding_issue($transaction) { |
|
| 481 | 481 | $reg_final_price_sum = EEM_Registration::instance()->sum( |
| 482 | 482 | array( |
| 483 | 483 | array( |
@@ -486,9 +486,9 @@ discard block |
||
| 486 | 486 | ), |
| 487 | 487 | 'REG_final_price' |
| 488 | 488 | ); |
| 489 | - $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
| 489 | + $diff = $transaction->total() - (float) $reg_final_price_sum; |
|
| 490 | 490 | //ok then, just grab one of the registrations |
| 491 | - if( $diff !== 0 ) { |
|
| 491 | + if ($diff !== 0) { |
|
| 492 | 492 | $a_reg = EEM_Registration::instance()->get_one( |
| 493 | 493 | array( |
| 494 | 494 | array( |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | )); |
| 498 | 498 | $success = $a_reg instanceof EE_Registration |
| 499 | 499 | ? $a_reg->save( |
| 500 | - array( 'REG_final_price' => $a_reg->final_price() + $diff ) |
|
| 500 | + array('REG_final_price' => $a_reg->final_price() + $diff) |
|
| 501 | 501 | ) |
| 502 | 502 | : false; |
| 503 | 503 | return $success ? true : false; |
@@ -523,16 +523,16 @@ discard block |
||
| 523 | 523 | $update_reg = true |
| 524 | 524 | ) { |
| 525 | 525 | // these reg statuses should not be considered in any calculations involving monies owing |
| 526 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) |
|
| 526 | + $closed_reg_statuses = ! empty($closed_reg_statuses) |
|
| 527 | 527 | ? $closed_reg_statuses |
| 528 | 528 | : EEM_Registration::closed_reg_statuses(); |
| 529 | - if ( ! in_array( $registration->status_ID(), $closed_reg_statuses, true ) ) { |
|
| 529 | + if ( ! in_array($registration->status_ID(), $closed_reg_statuses, true)) { |
|
| 530 | 530 | return false; |
| 531 | 531 | } |
| 532 | 532 | // release a reserved ticket by decrementing ticket and datetime reserved values |
| 533 | 533 | $registration->release_reserved_ticket(true); |
| 534 | 534 | $registration->set_final_price(0); |
| 535 | - if ( $update_reg ) { |
|
| 535 | + if ($update_reg) { |
|
| 536 | 536 | $registration->save(); |
| 537 | 537 | } |
| 538 | 538 | return true; |
@@ -555,23 +555,23 @@ discard block |
||
| 555 | 555 | $update_reg = true |
| 556 | 556 | ) { |
| 557 | 557 | // these reg statuses should not be considered in any calculations involving monies owing |
| 558 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses |
|
| 558 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses |
|
| 559 | 559 | : EEM_Registration::closed_reg_statuses(); |
| 560 | - if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) { |
|
| 560 | + if (in_array($registration->status_ID(), $closed_reg_statuses)) { |
|
| 561 | 561 | return false; |
| 562 | 562 | } |
| 563 | 563 | $ticket = $registration->ticket(); |
| 564 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
| 564 | + if ( ! $ticket instanceof EE_Ticket) { |
|
| 565 | 565 | throw new EE_Error( |
| 566 | 566 | sprintf( |
| 567 | - __( 'The Ticket for Registration %1$d was not found or is invalid.', |
|
| 568 | - 'event_espresso' ), |
|
| 567 | + __('The Ticket for Registration %1$d was not found or is invalid.', |
|
| 568 | + 'event_espresso'), |
|
| 569 | 569 | $registration->ticket_ID() |
| 570 | 570 | ) |
| 571 | 571 | ); |
| 572 | 572 | } |
| 573 | - $registration->set_final_price( $ticket->price() ); |
|
| 574 | - if ( $update_reg ) { |
|
| 573 | + $registration->set_final_price($ticket->price()); |
|
| 574 | + if ($update_reg) { |
|
| 575 | 575 | $registration->save(); |
| 576 | 576 | } |
| 577 | 577 | return true; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | $total_ticket_count = 1 |
| 610 | 610 | ) { |
| 611 | 611 | EE_Error::doing_it_wrong( |
| 612 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 612 | + __CLASS__.'::'.__FUNCTION__, |
|
| 613 | 613 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
| 614 | 614 | '\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'), |
| 615 | 615 | '4.9.1', |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | public function generate_reg_url_link($att_nmbr, $item) |
| 653 | 653 | { |
| 654 | 654 | EE_Error::doing_it_wrong( |
| 655 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 655 | + __CLASS__.'::'.__FUNCTION__, |
|
| 656 | 656 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
| 657 | 657 | 'EventEspresso\core\domain\entities\RegUrlLink'), |
| 658 | 658 | '4.9.1', |
@@ -672,11 +672,11 @@ discard block |
||
| 672 | 672 | * @return string |
| 673 | 673 | * @throws \EE_Error |
| 674 | 674 | */ |
| 675 | - public function generate_reg_code( EE_Registration $registration ) { |
|
| 675 | + public function generate_reg_code(EE_Registration $registration) { |
|
| 676 | 676 | EE_Error::doing_it_wrong( |
| 677 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 677 | + __CLASS__.'::'.__FUNCTION__, |
|
| 678 | 678 | sprintf( |
| 679 | - __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), |
|
| 679 | + __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
| 680 | 680 | 'EventEspresso\core\domain\entities\RegCode' |
| 681 | 681 | ), |
| 682 | 682 | '4.9.1', |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | return apply_filters( |
| 686 | 686 | 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', |
| 687 | 687 | new RegCode( |
| 688 | - RegUrlLink::fromRegistration( $registration ), |
|
| 688 | + RegUrlLink::fromRegistration($registration), |
|
| 689 | 689 | $registration->transaction(), |
| 690 | 690 | $registration->ticket() |
| 691 | 691 | ), |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
| 8 | 8 | |
| 9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 10 | - exit('No direct script access allowed'); |
|
| 10 | + exit('No direct script access allowed'); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | |
@@ -24,101 +24,101 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param \EE_Event $event |
|
| 29 | - * @param \EE_Transaction $transaction |
|
| 30 | - * @param \EE_Ticket $ticket |
|
| 31 | - * @param \EE_Line_Item $ticket_line_item |
|
| 32 | - * @param $reg_count |
|
| 33 | - * @param $reg_group_size |
|
| 34 | - * @return \EE_Registration |
|
| 35 | - * @throws \EE_Error |
|
| 36 | - * @throws UnexpectedEntityException |
|
| 37 | - */ |
|
| 38 | - public function create( |
|
| 39 | - \EE_Event $event, |
|
| 40 | - \EE_Transaction $transaction, |
|
| 41 | - \EE_Ticket $ticket, |
|
| 42 | - \EE_Line_Item $ticket_line_item, |
|
| 43 | - $reg_count, |
|
| 44 | - $reg_group_size |
|
| 45 | - ) { |
|
| 46 | - $registrations = $transaction->registrations(); |
|
| 47 | - $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
| 48 | - $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
| 49 | - $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
| 50 | - // generate new EE_Registration |
|
| 51 | - $registration = \EE_Registration::new_instance( |
|
| 52 | - array( |
|
| 53 | - 'EVT_ID' => $event->ID(), |
|
| 54 | - 'TXN_ID' => $transaction->ID(), |
|
| 55 | - 'TKT_ID' => $ticket->ID(), |
|
| 56 | - 'STS_ID' => \EEM_Registration::status_id_incomplete, |
|
| 57 | - 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
| 58 | - 'REG_session' => \EE_Registry::instance()->SSN->id(), |
|
| 59 | - 'REG_count' => $reg_count, |
|
| 60 | - 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
| 61 | - 'REG_url_link' => $reg_url_link, |
|
| 62 | - 'REG_code' => $reg_code, |
|
| 63 | - ) |
|
| 64 | - ); |
|
| 65 | - if ( ! $registration instanceof \EE_Registration) { |
|
| 66 | - throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
| 67 | - } |
|
| 68 | - // save registration so that we have an ID |
|
| 69 | - $registration->save(); |
|
| 70 | - // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
| 71 | - // because that is done as soon as the tickets are added/removed from the cart |
|
| 72 | - $registration->reserve_ticket(); |
|
| 73 | - $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
| 74 | - $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
| 75 | - $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
| 76 | - $registration->save(); |
|
| 77 | - return $registration; |
|
| 78 | - } |
|
| 27 | + /** |
|
| 28 | + * @param \EE_Event $event |
|
| 29 | + * @param \EE_Transaction $transaction |
|
| 30 | + * @param \EE_Ticket $ticket |
|
| 31 | + * @param \EE_Line_Item $ticket_line_item |
|
| 32 | + * @param $reg_count |
|
| 33 | + * @param $reg_group_size |
|
| 34 | + * @return \EE_Registration |
|
| 35 | + * @throws \EE_Error |
|
| 36 | + * @throws UnexpectedEntityException |
|
| 37 | + */ |
|
| 38 | + public function create( |
|
| 39 | + \EE_Event $event, |
|
| 40 | + \EE_Transaction $transaction, |
|
| 41 | + \EE_Ticket $ticket, |
|
| 42 | + \EE_Line_Item $ticket_line_item, |
|
| 43 | + $reg_count, |
|
| 44 | + $reg_group_size |
|
| 45 | + ) { |
|
| 46 | + $registrations = $transaction->registrations(); |
|
| 47 | + $reg_count = $reg_count ? $reg_count : count($registrations) + 1; |
|
| 48 | + $reg_url_link = new RegUrlLink($reg_count, $ticket_line_item); |
|
| 49 | + $reg_code = new RegCode($reg_url_link, $transaction, $ticket); |
|
| 50 | + // generate new EE_Registration |
|
| 51 | + $registration = \EE_Registration::new_instance( |
|
| 52 | + array( |
|
| 53 | + 'EVT_ID' => $event->ID(), |
|
| 54 | + 'TXN_ID' => $transaction->ID(), |
|
| 55 | + 'TKT_ID' => $ticket->ID(), |
|
| 56 | + 'STS_ID' => \EEM_Registration::status_id_incomplete, |
|
| 57 | + 'REG_final_price' => $this->resolveFinalPrice($transaction, $ticket, $ticket_line_item), |
|
| 58 | + 'REG_session' => \EE_Registry::instance()->SSN->id(), |
|
| 59 | + 'REG_count' => $reg_count, |
|
| 60 | + 'REG_group_size' => $reg_group_size ? $reg_group_size : $this->incrementRegCount($registrations), |
|
| 61 | + 'REG_url_link' => $reg_url_link, |
|
| 62 | + 'REG_code' => $reg_code, |
|
| 63 | + ) |
|
| 64 | + ); |
|
| 65 | + if ( ! $registration instanceof \EE_Registration) { |
|
| 66 | + throw new UnexpectedEntityException($registration, 'EE_Registration'); |
|
| 67 | + } |
|
| 68 | + // save registration so that we have an ID |
|
| 69 | + $registration->save(); |
|
| 70 | + // track reservation on reg but don't adjust ticket and datetime reserved counts |
|
| 71 | + // because that is done as soon as the tickets are added/removed from the cart |
|
| 72 | + $registration->reserve_ticket(); |
|
| 73 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
| 74 | + $registration->_add_relation_to($ticket, 'Ticket', array(), $ticket->ID()); |
|
| 75 | + $transaction->_add_relation_to($registration, 'Registration', array(), $registration->ID()); |
|
| 76 | + $registration->save(); |
|
| 77 | + return $registration; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @param \EE_Transaction $transaction |
|
| 84 | - * @param \EE_Ticket $ticket |
|
| 85 | - * @param \EE_Line_Item $ticket_line_item |
|
| 86 | - * @return float |
|
| 87 | - */ |
|
| 88 | - protected function resolveFinalPrice( |
|
| 89 | - \EE_Transaction $transaction, |
|
| 90 | - \EE_Ticket $ticket, |
|
| 91 | - \EE_Line_Item $ticket_line_item |
|
| 92 | - ) { |
|
| 93 | - $final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
| 94 | - $transaction->total_line_item(), |
|
| 95 | - $ticket_line_item |
|
| 96 | - ); |
|
| 97 | - $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
| 98 | - return (float)$final_price; |
|
| 99 | - } |
|
| 82 | + /** |
|
| 83 | + * @param \EE_Transaction $transaction |
|
| 84 | + * @param \EE_Ticket $ticket |
|
| 85 | + * @param \EE_Line_Item $ticket_line_item |
|
| 86 | + * @return float |
|
| 87 | + */ |
|
| 88 | + protected function resolveFinalPrice( |
|
| 89 | + \EE_Transaction $transaction, |
|
| 90 | + \EE_Ticket $ticket, |
|
| 91 | + \EE_Line_Item $ticket_line_item |
|
| 92 | + ) { |
|
| 93 | + $final_price = \EEH_Line_Item::calculate_final_price_for_ticket_line_item( |
|
| 94 | + $transaction->total_line_item(), |
|
| 95 | + $ticket_line_item |
|
| 96 | + ); |
|
| 97 | + $final_price = $final_price !== null ? $final_price : $ticket->get_ticket_total_with_taxes(); |
|
| 98 | + return (float)$final_price; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param \EE_Registration[] $registrations |
|
| 105 | - * @param boolean $update_existing_registrations |
|
| 106 | - * @return int |
|
| 107 | - * @throws \EE_Error |
|
| 108 | - */ |
|
| 109 | - protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
| 110 | - { |
|
| 111 | - $new_reg_count = count($registrations) + 1; |
|
| 112 | - if ($update_existing_registrations) { |
|
| 113 | - foreach ($registrations as $registration) { |
|
| 114 | - if ($registration instanceof \EE_Registration) { |
|
| 115 | - $registration->set_count($new_reg_count); |
|
| 116 | - $registration->save(); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - return $new_reg_count; |
|
| 121 | - } |
|
| 103 | + /** |
|
| 104 | + * @param \EE_Registration[] $registrations |
|
| 105 | + * @param boolean $update_existing_registrations |
|
| 106 | + * @return int |
|
| 107 | + * @throws \EE_Error |
|
| 108 | + */ |
|
| 109 | + protected function incrementRegCount(array $registrations, $update_existing_registrations = true) |
|
| 110 | + { |
|
| 111 | + $new_reg_count = count($registrations) + 1; |
|
| 112 | + if ($update_existing_registrations) { |
|
| 113 | + foreach ($registrations as $registration) { |
|
| 114 | + if ($registration instanceof \EE_Registration) { |
|
| 115 | + $registration->set_count($new_reg_count); |
|
| 116 | + $registration->save(); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + return $new_reg_count; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | } |
@@ -21,639 +21,638 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | abstract class EE_Model_Field_Base implements HasSchemaInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * The alias for the table the column belongs to. |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - protected $_table_alias; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * The actual db column name for the table |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - protected $_table_column; |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * The authoritative name for the table column (used by client code to reference the field). |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - protected $_name; |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * A description for the field. |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 48 | - protected $_nicename; |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Whether the field is nullable or not |
|
| 53 | - * @var bool |
|
| 54 | - */ |
|
| 55 | - protected $_nullable; |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * What the default value for the field should be. |
|
| 60 | - * @var mixed |
|
| 61 | - */ |
|
| 62 | - protected $_default_value; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Other configuration for the field |
|
| 67 | - * @var mixed |
|
| 68 | - */ |
|
| 69 | - protected $_other_config; |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * The name of the model this field is instantiated for. |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - protected $_model_name; |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * This should be a json-schema valid data type for the field. |
|
| 81 | - * @link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
| 82 | - * @var string |
|
| 83 | - */ |
|
| 84 | - private $_schema_type = 'string'; |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * If the schema has a defined format then it should be defined via this property. |
|
| 89 | - * @link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
| 90 | - * @var string |
|
| 91 | - */ |
|
| 92 | - private $_schema_format = ''; |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Indicates that the value of the field is managed exclusively by the server/model and not something |
|
| 97 | - * settable by client code. |
|
| 98 | - * @link http://json-schema.org/latest/json-schema-hypermedia.html#rfc.section.4.4 |
|
| 99 | - * @var bool |
|
| 100 | - */ |
|
| 101 | - private $_schema_readonly = false; |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @param string $table_column |
|
| 106 | - * @param string $nicename |
|
| 107 | - * @param bool $nullable |
|
| 108 | - * @param null $default_value |
|
| 109 | - */ |
|
| 110 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
| 111 | - { |
|
| 112 | - $this->_table_column = $table_column; |
|
| 113 | - $this->_nicename = $nicename; |
|
| 114 | - $this->_nullable = $nullable; |
|
| 115 | - $this->_default_value = $default_value; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @param $table_alias |
|
| 121 | - * @param $name |
|
| 122 | - * @param $model_name |
|
| 123 | - */ |
|
| 124 | - public function _construct_finalize($table_alias, $name, $model_name) |
|
| 125 | - { |
|
| 126 | - $this->_table_alias = $table_alias; |
|
| 127 | - $this->_name = $name; |
|
| 128 | - $this->_model_name = $model_name; |
|
| 129 | - /** |
|
| 130 | - * allow for changing the defaults |
|
| 131 | - */ |
|
| 132 | - $this->_nicename = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___nicename', |
|
| 133 | - $this->_nicename, $this); |
|
| 134 | - $this->_default_value = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___default_value', |
|
| 135 | - $this->_default_value, $this); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - public function get_table_alias() |
|
| 139 | - { |
|
| 140 | - return $this->_table_alias; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - public function get_table_column() |
|
| 144 | - { |
|
| 145 | - return $this->_table_column; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Returns the name of the model this field is on. Eg 'Event' or 'Ticket_Datetime' |
|
| 150 | - * |
|
| 151 | - * @return string |
|
| 152 | - */ |
|
| 153 | - public function get_model_name() |
|
| 154 | - { |
|
| 155 | - return $this->_model_name; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @throws \EE_Error |
|
| 160 | - * @return string |
|
| 161 | - */ |
|
| 162 | - public function get_name() |
|
| 163 | - { |
|
| 164 | - if ($this->_name) { |
|
| 165 | - return $this->_name; |
|
| 166 | - } else { |
|
| 167 | - throw new EE_Error(sprintf(__("Model field '%s' has no name set. Did you make a model and forget to call the parent model constructor?", |
|
| 168 | - "event_espresso"), get_class($this))); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - public function get_nicename() |
|
| 173 | - { |
|
| 174 | - return $this->_nicename; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - public function is_nullable() |
|
| 178 | - { |
|
| 179 | - return $this->_nullable; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * returns whether this field is an auto-increment field or not. If it is, then |
|
| 184 | - * on insertion it can be null. However, on updates it must be present. |
|
| 185 | - * |
|
| 186 | - * @return boolean |
|
| 187 | - */ |
|
| 188 | - public function is_auto_increment() |
|
| 189 | - { |
|
| 190 | - return false; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * The default value in the model object's value domain. See lengthy comment about |
|
| 195 | - * value domains at the top of EEM_Base |
|
| 196 | - * |
|
| 197 | - * @return mixed |
|
| 198 | - */ |
|
| 199 | - public function get_default_value() |
|
| 200 | - { |
|
| 201 | - return $this->_default_value; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Returns the table alias joined to the table column, however this isn't the right |
|
| 206 | - * table alias if the aliased table is being joined to. In that case, you can use |
|
| 207 | - * EE_Model_Parser::extract_table_alias_model_relation_chain_prefix() to find the table's current alias |
|
| 208 | - * in the current query |
|
| 209 | - * |
|
| 210 | - * @return string |
|
| 211 | - */ |
|
| 212 | - public function get_qualified_column() |
|
| 213 | - { |
|
| 214 | - return $this->get_table_alias() . "." . $this->get_table_column(); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * When get() is called on a model object (eg EE_Event), before returning its value, |
|
| 219 | - * call this function on it, allowing us to customize the returned value based on |
|
| 220 | - * the field's type. Eg, we may want ot serialize it, strip tags, etc. By default, |
|
| 221 | - * we simply return it. |
|
| 222 | - * |
|
| 223 | - * @param mixed $value_of_field_on_model_object |
|
| 224 | - * @return mixed |
|
| 225 | - */ |
|
| 226 | - public function prepare_for_get($value_of_field_on_model_object) |
|
| 227 | - { |
|
| 228 | - return $value_of_field_on_model_object; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * When inserting or updating a field on a model object, run this function on each |
|
| 233 | - * value to prepare it for insertion into the db. We may want to add slashes, serialize it, etc. |
|
| 234 | - * By default, we do nothing. |
|
| 235 | - * |
|
| 236 | - * @param mixed $value_of_field_on_model_object |
|
| 237 | - * @return mixed |
|
| 238 | - */ |
|
| 239 | - public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
| 240 | - { |
|
| 241 | - return $value_of_field_on_model_object; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * When creating a brand-new model object, or setting a particular value for one of its fields, this function |
|
| 246 | - * is called before setting it on the model object. We may want to strip slashes, unserialize the value, etc. |
|
| 247 | - * By default, we do nothing. |
|
| 248 | - * |
|
| 249 | - * @param mixed $value_inputted_for_field_on_model_object |
|
| 250 | - * @return mixed |
|
| 251 | - */ |
|
| 252 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 253 | - { |
|
| 254 | - return $value_inputted_for_field_on_model_object; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * When instantiating a model object from DB results, this function is called before setting each field. |
|
| 260 | - * We may want to serialize the value, etc. By default, we return the value using prepare_for_set() method as that |
|
| 261 | - * is the one child classes will most often define. |
|
| 262 | - * |
|
| 263 | - * @param mixed $value_found_in_db_for_model_object |
|
| 264 | - * @return mixed |
|
| 265 | - */ |
|
| 266 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
| 267 | - { |
|
| 268 | - return $this->prepare_for_set($value_found_in_db_for_model_object); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * When echoing a field's value on a model object, this function is run to prepare the value for presentation in a |
|
| 273 | - * webpage. For example, we may want to output floats with 2 decimal places by default, dates as "Monday Jan 12, |
|
| 274 | - * 2013, at 3:23pm" instead of |
|
| 275 | - * "8765678632", or any other modifications to how the value should be displayed, but not modified itself. |
|
| 276 | - * |
|
| 277 | - * @param mixed $value_on_field_to_be_outputted |
|
| 278 | - * @return mixed |
|
| 279 | - */ |
|
| 280 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted) |
|
| 281 | - { |
|
| 282 | - return $value_on_field_to_be_outputted; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * Returns whatever is set as the nicename for the object. |
|
| 288 | - * @return string |
|
| 289 | - */ |
|
| 290 | - public function getSchemaDescription() |
|
| 291 | - { |
|
| 292 | - return $this->get_nicename(); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Returns whatever is set as the $_schema_type property for the object. |
|
| 298 | - * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
| 299 | - * @return string|array |
|
| 300 | - */ |
|
| 301 | - public function getSchemaType() |
|
| 302 | - { |
|
| 303 | - if ($this->is_nullable()) { |
|
| 304 | - $this->_schema_type = (array) $this->_schema_type; |
|
| 305 | - if (! in_array('null', $this->_schema_type)) { |
|
| 306 | - $this->_schema_type[] = 'null'; |
|
| 307 | - }; |
|
| 308 | - } |
|
| 309 | - return $this->_schema_type; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * Sets the _schema_type property. Child classes should call this in their constructors to override the default state |
|
| 315 | - * for this property. |
|
| 316 | - * @param string|array $type |
|
| 317 | - * @throws InvalidArgumentException |
|
| 318 | - */ |
|
| 319 | - protected function setSchemaType($type) |
|
| 320 | - { |
|
| 321 | - $this->validateSchemaType($type); |
|
| 322 | - $this->_schema_type = $type; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
| 328 | - * this method and return the properties for the schema. |
|
| 329 | - * |
|
| 330 | - * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
| 331 | - * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
| 332 | - * |
|
| 333 | - * @return array |
|
| 334 | - */ |
|
| 335 | - public function getSchemaProperties() |
|
| 336 | - { |
|
| 337 | - return array(); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - /** |
|
| 343 | - * By default this returns the scalar default value that was sent in on the class prepped according to the class type |
|
| 344 | - * as the default. However, when there are schema properties, then the default property is setup to mirror the |
|
| 345 | - * property keys and correctly prepare the default according to that expected property value. |
|
| 346 | - * The getSchema method validates whether the schema for default is setup correctly or not according to the schema type |
|
| 347 | - * |
|
| 348 | - * @return mixed |
|
| 349 | - */ |
|
| 350 | - public function getSchemaDefault() |
|
| 351 | - { |
|
| 352 | - $default_value = $this->prepare_for_use_in_db($this->prepare_for_set($this->get_default_value())); |
|
| 353 | - $schema_properties = $this->getSchemaProperties(); |
|
| 354 | - |
|
| 355 | - //if this schema has properties than shape the default value to match the properties shape. |
|
| 356 | - if ($schema_properties) { |
|
| 357 | - $value_to_return = array(); |
|
| 358 | - foreach ($schema_properties as $property_key => $property_schema) { |
|
| 359 | - switch ($property_key) { |
|
| 360 | - case 'pretty': |
|
| 361 | - case 'rendered': |
|
| 362 | - $value_to_return[$property_key] = $this->prepare_for_pretty_echoing($this->prepare_for_set($default_value)); |
|
| 363 | - break; |
|
| 364 | - default: |
|
| 365 | - $value_to_return[$property_key] = $default_value; |
|
| 366 | - break; |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - $default_value = $value_to_return; |
|
| 370 | - } |
|
| 371 | - return $default_value; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * If a child class has enum values, they should override this method and provide a simple array |
|
| 379 | - * of the enum values. |
|
| 380 | - |
|
| 381 | - * The reason this is not a property on the class is because there may be filterable enum values that |
|
| 382 | - * are set on the instantiated object that could be filtered after construct. |
|
| 383 | - * |
|
| 384 | - * @return array |
|
| 385 | - */ |
|
| 386 | - public function getSchemaEnum() |
|
| 387 | - { |
|
| 388 | - return array(); |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * This returns the value of the $_schema_format property on the object. |
|
| 394 | - * @return string |
|
| 395 | - */ |
|
| 396 | - public function getSchemaFormat() |
|
| 397 | - { |
|
| 398 | - return $this->_schema_format; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - |
|
| 402 | - /** |
|
| 403 | - * Sets the schema format property. |
|
| 404 | - * @throws InvalidArgumentException |
|
| 405 | - * @param string $format |
|
| 406 | - */ |
|
| 407 | - protected function setSchemaFormat($format) |
|
| 408 | - { |
|
| 409 | - $this->validateSchemaFormat($format); |
|
| 410 | - $this->_schema_format = $format; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * This returns the value of the $_schema_readonly property on the object. |
|
| 416 | - * @return bool |
|
| 417 | - */ |
|
| 418 | - public function getSchemaReadonly() |
|
| 419 | - { |
|
| 420 | - return $this->_schema_readonly; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * This sets the value for the $_schema_readonly property. |
|
| 426 | - * @param bool $readonly (only explicit boolean values are accepted) |
|
| 427 | - */ |
|
| 428 | - protected function setSchemaReadOnly($readonly) |
|
| 429 | - { |
|
| 430 | - if (! is_bool($readonly)) { |
|
| 431 | - throw new InvalidArgumentException( |
|
| 432 | - sprintf( |
|
| 433 | - esc_html__('The incoming argument (%s) must be a boolean.', 'event_espresso'), |
|
| 434 | - print_r($readonly, true) |
|
| 435 | - ) |
|
| 436 | - ); |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - $this->_schema_readonly = $readonly; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - |
|
| 443 | - |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * Return `%d`, `%s` or `%f` to indicate the data type for the field. |
|
| 447 | - * @uses _get_wpdb_data_type() |
|
| 448 | - * |
|
| 449 | - * @return string |
|
| 450 | - */ |
|
| 451 | - public function get_wpdb_data_type() |
|
| 452 | - { |
|
| 453 | - return $this->_get_wpdb_data_type(); |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * Return `%d`, `%s` or `%f` to indicate the data type for the field that should be indicated in wpdb queries. |
|
| 459 | - * @param string $type Included if a specific type is requested. |
|
| 460 | - * @uses get_schema_type() |
|
| 461 | - * @return string |
|
| 462 | - */ |
|
| 463 | - protected function _get_wpdb_data_type($type='') |
|
| 464 | - { |
|
| 465 | - $type = empty($type) ? $this->getSchemaType() : $type; |
|
| 466 | - |
|
| 467 | - //if type is an array, then different parsing is required. |
|
| 468 | - if (is_array($type)) { |
|
| 469 | - return $this->_get_wpdb_data_type_for_type_array($type); |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - $wpdb_type = '%s'; |
|
| 473 | - switch ($type) { |
|
| 474 | - case 'number': |
|
| 475 | - $wpdb_type = '%f'; |
|
| 476 | - break; |
|
| 477 | - case 'integer': |
|
| 478 | - case 'boolean': |
|
| 479 | - $wpdb_type = '%d'; |
|
| 480 | - break; |
|
| 481 | - case 'object': |
|
| 482 | - $properties = $this->getSchemaProperties(); |
|
| 483 | - if (isset($properties['raw'], $properties['raw']['type'])) { |
|
| 484 | - $wpdb_type = $this->_get_wpdb_data_type($properties['raw']['type']); |
|
| 485 | - } |
|
| 486 | - break; //leave at default |
|
| 487 | - } |
|
| 488 | - return $wpdb_type; |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - |
|
| 492 | - |
|
| 493 | - protected function _get_wpdb_data_type_for_type_array($type) |
|
| 494 | - { |
|
| 495 | - $type = (array) $type; |
|
| 496 | - //first let's flip because then we can do a faster key check |
|
| 497 | - $type = array_flip($type); |
|
| 498 | - |
|
| 499 | - //check for things that mean '%s' |
|
| 500 | - if (isset($type['string'],$type['object'],$type['array'])) { |
|
| 501 | - return '%s'; |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - //if makes it past the above condition and there's float in the array |
|
| 505 | - //then the type is %f |
|
| 506 | - if (isset($type['number'])) { |
|
| 507 | - return '%f'; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - //if it makes it above the above conditions and there is an integer in the array |
|
| 511 | - //then the type is %d |
|
| 512 | - if (isset($type['integer'])) { |
|
| 513 | - return '%d'; |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - //anything else is a string |
|
| 517 | - return '%s'; |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - |
|
| 521 | - /** |
|
| 522 | - * This returns elements used to represent this field in the json schema. |
|
| 523 | - * |
|
| 524 | - * @link http://json-schema.org/ |
|
| 525 | - * @return array |
|
| 526 | - */ |
|
| 527 | - public function getSchema() |
|
| 528 | - { |
|
| 529 | - $schema = array( |
|
| 530 | - 'description' => $this->getSchemaDescription(), |
|
| 531 | - 'type' => $this->getSchemaType(), |
|
| 532 | - 'readonly' => $this->getSchemaReadonly(), |
|
| 533 | - 'default' => $this->getSchemaDefault() |
|
| 534 | - ); |
|
| 535 | - |
|
| 536 | - //optional properties of the schema |
|
| 537 | - $enum = $this->getSchemaEnum(); |
|
| 538 | - $properties = $this->getSchemaProperties(); |
|
| 539 | - $format = $this->getSchemaFormat(); |
|
| 540 | - if ($enum) { |
|
| 541 | - $schema['enum'] = $enum; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - if ($properties) { |
|
| 545 | - $schema['properties'] = $properties; |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - if ($format) { |
|
| 549 | - $schema['format'] = $format; |
|
| 550 | - } |
|
| 551 | - return $schema; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * Some fields are in the database-only, (ie, used in queries etc), but shouldn't necessarily be part |
|
| 556 | - * of the model objects (ie, client code shouldn't care to ever see their value... if client code does |
|
| 557 | - * want to see their value, then they shouldn't be db-only fields!) |
|
| 558 | - * Eg, when doing events as custom post types, querying the post_type is essential, but |
|
| 559 | - * post_type is irrelevant for EE_Event objects (because they will ALL be of post_type 'esp_event'). |
|
| 560 | - * By default, all fields aren't db-only. |
|
| 561 | - * |
|
| 562 | - * @return boolean |
|
| 563 | - */ |
|
| 564 | - public function is_db_only_field() |
|
| 565 | - { |
|
| 566 | - return false; |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - |
|
| 570 | - /** |
|
| 571 | - * Validates the incoming string|array to ensure its an allowable type. |
|
| 572 | - * @throws InvalidArgumentException |
|
| 573 | - * @param string|array $type |
|
| 574 | - */ |
|
| 575 | - private function validateSchemaType($type) |
|
| 576 | - { |
|
| 577 | - if (! (is_string($type) || is_array($type))) { |
|
| 578 | - throw new InvalidArgumentException( |
|
| 579 | - sprintf( |
|
| 580 | - esc_html__('The incoming argument (%s) must be a string or an array.', 'event_espresso'), |
|
| 581 | - print_r($type, true) |
|
| 582 | - ) |
|
| 583 | - ); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - //validate allowable types. |
|
| 587 | - //@link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
| 588 | - $allowable_types = array_flip( |
|
| 589 | - array( |
|
| 590 | - 'string', |
|
| 591 | - 'number', |
|
| 592 | - 'null', |
|
| 593 | - 'object', |
|
| 594 | - 'array', |
|
| 595 | - 'boolean', |
|
| 596 | - 'integer' |
|
| 597 | - ) |
|
| 598 | - ); |
|
| 599 | - |
|
| 600 | - if (is_array($type)) { |
|
| 601 | - foreach ($type as $item_in_type) { |
|
| 602 | - $this->validateSchemaType($item_in_type); |
|
| 603 | - } |
|
| 604 | - return; |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - if (! isset($allowable_types[$type])) { |
|
| 608 | - throw new InvalidArgumentException( |
|
| 609 | - sprintf( |
|
| 610 | - esc_html__('The incoming argument (%1$s) must be one of the allowable types: %2$s', 'event_espresso'), |
|
| 611 | - $type, |
|
| 612 | - implode(',', array_flip($allowable_types)) |
|
| 613 | - ) |
|
| 614 | - ); |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - |
|
| 619 | - /** |
|
| 620 | - * Validates that the incoming format is an allowable string to use for the _schema_format property |
|
| 621 | - * @throws InvalidArgumentException |
|
| 622 | - * @param $format |
|
| 623 | - */ |
|
| 624 | - private function validateSchemaFormat($format) |
|
| 625 | - { |
|
| 626 | - if (! is_string($format)) { |
|
| 627 | - throw new InvalidArgumentException( |
|
| 628 | - sprintf( |
|
| 629 | - esc_html__('The incoming argument (%s) must be a string.', 'event_espresso'), |
|
| 630 | - print_r($format, true) |
|
| 631 | - ) |
|
| 632 | - ); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - //validate allowable format values |
|
| 636 | - //@link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
| 637 | - $allowable_formats = array_flip( |
|
| 638 | - array( |
|
| 639 | - 'date-time', |
|
| 640 | - 'email', |
|
| 641 | - 'hostname', |
|
| 642 | - 'ipv4', |
|
| 643 | - 'ipv6', |
|
| 644 | - 'uri', |
|
| 645 | - 'uriref' |
|
| 646 | - ) |
|
| 647 | - ); |
|
| 648 | - |
|
| 649 | - if (! isset($allowable_formats[$format])) { |
|
| 650 | - throw new InvalidArgumentException( |
|
| 651 | - sprintf( |
|
| 652 | - esc_html__('The incoming argument (%1$s) must be one of the allowable formats: %2$s', 'event_espresso'), |
|
| 653 | - $format, |
|
| 654 | - implode(',', array_flip($allowable_formats)) |
|
| 655 | - ) |
|
| 656 | - ); |
|
| 657 | - } |
|
| 658 | - } |
|
| 24 | + /** |
|
| 25 | + * The alias for the table the column belongs to. |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + protected $_table_alias; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * The actual db column name for the table |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + protected $_table_column; |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * The authoritative name for the table column (used by client code to reference the field). |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + protected $_name; |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * A description for the field. |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | + protected $_nicename; |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Whether the field is nullable or not |
|
| 53 | + * @var bool |
|
| 54 | + */ |
|
| 55 | + protected $_nullable; |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * What the default value for the field should be. |
|
| 60 | + * @var mixed |
|
| 61 | + */ |
|
| 62 | + protected $_default_value; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Other configuration for the field |
|
| 67 | + * @var mixed |
|
| 68 | + */ |
|
| 69 | + protected $_other_config; |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * The name of the model this field is instantiated for. |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + protected $_model_name; |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * This should be a json-schema valid data type for the field. |
|
| 81 | + * @link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
| 82 | + * @var string |
|
| 83 | + */ |
|
| 84 | + private $_schema_type = 'string'; |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * If the schema has a defined format then it should be defined via this property. |
|
| 89 | + * @link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
| 90 | + * @var string |
|
| 91 | + */ |
|
| 92 | + private $_schema_format = ''; |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Indicates that the value of the field is managed exclusively by the server/model and not something |
|
| 97 | + * settable by client code. |
|
| 98 | + * @link http://json-schema.org/latest/json-schema-hypermedia.html#rfc.section.4.4 |
|
| 99 | + * @var bool |
|
| 100 | + */ |
|
| 101 | + private $_schema_readonly = false; |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @param string $table_column |
|
| 106 | + * @param string $nicename |
|
| 107 | + * @param bool $nullable |
|
| 108 | + * @param null $default_value |
|
| 109 | + */ |
|
| 110 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
| 111 | + { |
|
| 112 | + $this->_table_column = $table_column; |
|
| 113 | + $this->_nicename = $nicename; |
|
| 114 | + $this->_nullable = $nullable; |
|
| 115 | + $this->_default_value = $default_value; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @param $table_alias |
|
| 121 | + * @param $name |
|
| 122 | + * @param $model_name |
|
| 123 | + */ |
|
| 124 | + public function _construct_finalize($table_alias, $name, $model_name) |
|
| 125 | + { |
|
| 126 | + $this->_table_alias = $table_alias; |
|
| 127 | + $this->_name = $name; |
|
| 128 | + $this->_model_name = $model_name; |
|
| 129 | + /** |
|
| 130 | + * allow for changing the defaults |
|
| 131 | + */ |
|
| 132 | + $this->_nicename = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___nicename', |
|
| 133 | + $this->_nicename, $this); |
|
| 134 | + $this->_default_value = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___default_value', |
|
| 135 | + $this->_default_value, $this); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + public function get_table_alias() |
|
| 139 | + { |
|
| 140 | + return $this->_table_alias; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + public function get_table_column() |
|
| 144 | + { |
|
| 145 | + return $this->_table_column; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Returns the name of the model this field is on. Eg 'Event' or 'Ticket_Datetime' |
|
| 150 | + * |
|
| 151 | + * @return string |
|
| 152 | + */ |
|
| 153 | + public function get_model_name() |
|
| 154 | + { |
|
| 155 | + return $this->_model_name; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @throws \EE_Error |
|
| 160 | + * @return string |
|
| 161 | + */ |
|
| 162 | + public function get_name() |
|
| 163 | + { |
|
| 164 | + if ($this->_name) { |
|
| 165 | + return $this->_name; |
|
| 166 | + } else { |
|
| 167 | + throw new EE_Error(sprintf(__("Model field '%s' has no name set. Did you make a model and forget to call the parent model constructor?", |
|
| 168 | + "event_espresso"), get_class($this))); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + public function get_nicename() |
|
| 173 | + { |
|
| 174 | + return $this->_nicename; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + public function is_nullable() |
|
| 178 | + { |
|
| 179 | + return $this->_nullable; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * returns whether this field is an auto-increment field or not. If it is, then |
|
| 184 | + * on insertion it can be null. However, on updates it must be present. |
|
| 185 | + * |
|
| 186 | + * @return boolean |
|
| 187 | + */ |
|
| 188 | + public function is_auto_increment() |
|
| 189 | + { |
|
| 190 | + return false; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * The default value in the model object's value domain. See lengthy comment about |
|
| 195 | + * value domains at the top of EEM_Base |
|
| 196 | + * |
|
| 197 | + * @return mixed |
|
| 198 | + */ |
|
| 199 | + public function get_default_value() |
|
| 200 | + { |
|
| 201 | + return $this->_default_value; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Returns the table alias joined to the table column, however this isn't the right |
|
| 206 | + * table alias if the aliased table is being joined to. In that case, you can use |
|
| 207 | + * EE_Model_Parser::extract_table_alias_model_relation_chain_prefix() to find the table's current alias |
|
| 208 | + * in the current query |
|
| 209 | + * |
|
| 210 | + * @return string |
|
| 211 | + */ |
|
| 212 | + public function get_qualified_column() |
|
| 213 | + { |
|
| 214 | + return $this->get_table_alias() . "." . $this->get_table_column(); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * When get() is called on a model object (eg EE_Event), before returning its value, |
|
| 219 | + * call this function on it, allowing us to customize the returned value based on |
|
| 220 | + * the field's type. Eg, we may want ot serialize it, strip tags, etc. By default, |
|
| 221 | + * we simply return it. |
|
| 222 | + * |
|
| 223 | + * @param mixed $value_of_field_on_model_object |
|
| 224 | + * @return mixed |
|
| 225 | + */ |
|
| 226 | + public function prepare_for_get($value_of_field_on_model_object) |
|
| 227 | + { |
|
| 228 | + return $value_of_field_on_model_object; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * When inserting or updating a field on a model object, run this function on each |
|
| 233 | + * value to prepare it for insertion into the db. We may want to add slashes, serialize it, etc. |
|
| 234 | + * By default, we do nothing. |
|
| 235 | + * |
|
| 236 | + * @param mixed $value_of_field_on_model_object |
|
| 237 | + * @return mixed |
|
| 238 | + */ |
|
| 239 | + public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
| 240 | + { |
|
| 241 | + return $value_of_field_on_model_object; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * When creating a brand-new model object, or setting a particular value for one of its fields, this function |
|
| 246 | + * is called before setting it on the model object. We may want to strip slashes, unserialize the value, etc. |
|
| 247 | + * By default, we do nothing. |
|
| 248 | + * |
|
| 249 | + * @param mixed $value_inputted_for_field_on_model_object |
|
| 250 | + * @return mixed |
|
| 251 | + */ |
|
| 252 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 253 | + { |
|
| 254 | + return $value_inputted_for_field_on_model_object; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * When instantiating a model object from DB results, this function is called before setting each field. |
|
| 260 | + * We may want to serialize the value, etc. By default, we return the value using prepare_for_set() method as that |
|
| 261 | + * is the one child classes will most often define. |
|
| 262 | + * |
|
| 263 | + * @param mixed $value_found_in_db_for_model_object |
|
| 264 | + * @return mixed |
|
| 265 | + */ |
|
| 266 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
| 267 | + { |
|
| 268 | + return $this->prepare_for_set($value_found_in_db_for_model_object); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * When echoing a field's value on a model object, this function is run to prepare the value for presentation in a |
|
| 273 | + * webpage. For example, we may want to output floats with 2 decimal places by default, dates as "Monday Jan 12, |
|
| 274 | + * 2013, at 3:23pm" instead of |
|
| 275 | + * "8765678632", or any other modifications to how the value should be displayed, but not modified itself. |
|
| 276 | + * |
|
| 277 | + * @param mixed $value_on_field_to_be_outputted |
|
| 278 | + * @return mixed |
|
| 279 | + */ |
|
| 280 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted) |
|
| 281 | + { |
|
| 282 | + return $value_on_field_to_be_outputted; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * Returns whatever is set as the nicename for the object. |
|
| 288 | + * @return string |
|
| 289 | + */ |
|
| 290 | + public function getSchemaDescription() |
|
| 291 | + { |
|
| 292 | + return $this->get_nicename(); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Returns whatever is set as the $_schema_type property for the object. |
|
| 298 | + * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
| 299 | + * @return string|array |
|
| 300 | + */ |
|
| 301 | + public function getSchemaType() |
|
| 302 | + { |
|
| 303 | + if ($this->is_nullable()) { |
|
| 304 | + $this->_schema_type = (array) $this->_schema_type; |
|
| 305 | + if (! in_array('null', $this->_schema_type)) { |
|
| 306 | + $this->_schema_type[] = 'null'; |
|
| 307 | + }; |
|
| 308 | + } |
|
| 309 | + return $this->_schema_type; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * Sets the _schema_type property. Child classes should call this in their constructors to override the default state |
|
| 315 | + * for this property. |
|
| 316 | + * @param string|array $type |
|
| 317 | + * @throws InvalidArgumentException |
|
| 318 | + */ |
|
| 319 | + protected function setSchemaType($type) |
|
| 320 | + { |
|
| 321 | + $this->validateSchemaType($type); |
|
| 322 | + $this->_schema_type = $type; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
| 328 | + * this method and return the properties for the schema. |
|
| 329 | + * |
|
| 330 | + * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
| 331 | + * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
| 332 | + * |
|
| 333 | + * @return array |
|
| 334 | + */ |
|
| 335 | + public function getSchemaProperties() |
|
| 336 | + { |
|
| 337 | + return array(); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + /** |
|
| 343 | + * By default this returns the scalar default value that was sent in on the class prepped according to the class type |
|
| 344 | + * as the default. However, when there are schema properties, then the default property is setup to mirror the |
|
| 345 | + * property keys and correctly prepare the default according to that expected property value. |
|
| 346 | + * The getSchema method validates whether the schema for default is setup correctly or not according to the schema type |
|
| 347 | + * |
|
| 348 | + * @return mixed |
|
| 349 | + */ |
|
| 350 | + public function getSchemaDefault() |
|
| 351 | + { |
|
| 352 | + $default_value = $this->prepare_for_use_in_db($this->prepare_for_set($this->get_default_value())); |
|
| 353 | + $schema_properties = $this->getSchemaProperties(); |
|
| 354 | + |
|
| 355 | + //if this schema has properties than shape the default value to match the properties shape. |
|
| 356 | + if ($schema_properties) { |
|
| 357 | + $value_to_return = array(); |
|
| 358 | + foreach ($schema_properties as $property_key => $property_schema) { |
|
| 359 | + switch ($property_key) { |
|
| 360 | + case 'pretty': |
|
| 361 | + case 'rendered': |
|
| 362 | + $value_to_return[$property_key] = $this->prepare_for_pretty_echoing($this->prepare_for_set($default_value)); |
|
| 363 | + break; |
|
| 364 | + default: |
|
| 365 | + $value_to_return[$property_key] = $default_value; |
|
| 366 | + break; |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + $default_value = $value_to_return; |
|
| 370 | + } |
|
| 371 | + return $default_value; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * If a child class has enum values, they should override this method and provide a simple array |
|
| 379 | + * of the enum values. |
|
| 380 | + * The reason this is not a property on the class is because there may be filterable enum values that |
|
| 381 | + * are set on the instantiated object that could be filtered after construct. |
|
| 382 | + * |
|
| 383 | + * @return array |
|
| 384 | + */ |
|
| 385 | + public function getSchemaEnum() |
|
| 386 | + { |
|
| 387 | + return array(); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * This returns the value of the $_schema_format property on the object. |
|
| 393 | + * @return string |
|
| 394 | + */ |
|
| 395 | + public function getSchemaFormat() |
|
| 396 | + { |
|
| 397 | + return $this->_schema_format; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + /** |
|
| 402 | + * Sets the schema format property. |
|
| 403 | + * @throws InvalidArgumentException |
|
| 404 | + * @param string $format |
|
| 405 | + */ |
|
| 406 | + protected function setSchemaFormat($format) |
|
| 407 | + { |
|
| 408 | + $this->validateSchemaFormat($format); |
|
| 409 | + $this->_schema_format = $format; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * This returns the value of the $_schema_readonly property on the object. |
|
| 415 | + * @return bool |
|
| 416 | + */ |
|
| 417 | + public function getSchemaReadonly() |
|
| 418 | + { |
|
| 419 | + return $this->_schema_readonly; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * This sets the value for the $_schema_readonly property. |
|
| 425 | + * @param bool $readonly (only explicit boolean values are accepted) |
|
| 426 | + */ |
|
| 427 | + protected function setSchemaReadOnly($readonly) |
|
| 428 | + { |
|
| 429 | + if (! is_bool($readonly)) { |
|
| 430 | + throw new InvalidArgumentException( |
|
| 431 | + sprintf( |
|
| 432 | + esc_html__('The incoming argument (%s) must be a boolean.', 'event_espresso'), |
|
| 433 | + print_r($readonly, true) |
|
| 434 | + ) |
|
| 435 | + ); |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + $this->_schema_readonly = $readonly; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + |
|
| 442 | + |
|
| 443 | + |
|
| 444 | + /** |
|
| 445 | + * Return `%d`, `%s` or `%f` to indicate the data type for the field. |
|
| 446 | + * @uses _get_wpdb_data_type() |
|
| 447 | + * |
|
| 448 | + * @return string |
|
| 449 | + */ |
|
| 450 | + public function get_wpdb_data_type() |
|
| 451 | + { |
|
| 452 | + return $this->_get_wpdb_data_type(); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * Return `%d`, `%s` or `%f` to indicate the data type for the field that should be indicated in wpdb queries. |
|
| 458 | + * @param string $type Included if a specific type is requested. |
|
| 459 | + * @uses get_schema_type() |
|
| 460 | + * @return string |
|
| 461 | + */ |
|
| 462 | + protected function _get_wpdb_data_type($type='') |
|
| 463 | + { |
|
| 464 | + $type = empty($type) ? $this->getSchemaType() : $type; |
|
| 465 | + |
|
| 466 | + //if type is an array, then different parsing is required. |
|
| 467 | + if (is_array($type)) { |
|
| 468 | + return $this->_get_wpdb_data_type_for_type_array($type); |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + $wpdb_type = '%s'; |
|
| 472 | + switch ($type) { |
|
| 473 | + case 'number': |
|
| 474 | + $wpdb_type = '%f'; |
|
| 475 | + break; |
|
| 476 | + case 'integer': |
|
| 477 | + case 'boolean': |
|
| 478 | + $wpdb_type = '%d'; |
|
| 479 | + break; |
|
| 480 | + case 'object': |
|
| 481 | + $properties = $this->getSchemaProperties(); |
|
| 482 | + if (isset($properties['raw'], $properties['raw']['type'])) { |
|
| 483 | + $wpdb_type = $this->_get_wpdb_data_type($properties['raw']['type']); |
|
| 484 | + } |
|
| 485 | + break; //leave at default |
|
| 486 | + } |
|
| 487 | + return $wpdb_type; |
|
| 488 | + } |
|
| 489 | + |
|
| 490 | + |
|
| 491 | + |
|
| 492 | + protected function _get_wpdb_data_type_for_type_array($type) |
|
| 493 | + { |
|
| 494 | + $type = (array) $type; |
|
| 495 | + //first let's flip because then we can do a faster key check |
|
| 496 | + $type = array_flip($type); |
|
| 497 | + |
|
| 498 | + //check for things that mean '%s' |
|
| 499 | + if (isset($type['string'],$type['object'],$type['array'])) { |
|
| 500 | + return '%s'; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + //if makes it past the above condition and there's float in the array |
|
| 504 | + //then the type is %f |
|
| 505 | + if (isset($type['number'])) { |
|
| 506 | + return '%f'; |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + //if it makes it above the above conditions and there is an integer in the array |
|
| 510 | + //then the type is %d |
|
| 511 | + if (isset($type['integer'])) { |
|
| 512 | + return '%d'; |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + //anything else is a string |
|
| 516 | + return '%s'; |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * This returns elements used to represent this field in the json schema. |
|
| 522 | + * |
|
| 523 | + * @link http://json-schema.org/ |
|
| 524 | + * @return array |
|
| 525 | + */ |
|
| 526 | + public function getSchema() |
|
| 527 | + { |
|
| 528 | + $schema = array( |
|
| 529 | + 'description' => $this->getSchemaDescription(), |
|
| 530 | + 'type' => $this->getSchemaType(), |
|
| 531 | + 'readonly' => $this->getSchemaReadonly(), |
|
| 532 | + 'default' => $this->getSchemaDefault() |
|
| 533 | + ); |
|
| 534 | + |
|
| 535 | + //optional properties of the schema |
|
| 536 | + $enum = $this->getSchemaEnum(); |
|
| 537 | + $properties = $this->getSchemaProperties(); |
|
| 538 | + $format = $this->getSchemaFormat(); |
|
| 539 | + if ($enum) { |
|
| 540 | + $schema['enum'] = $enum; |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + if ($properties) { |
|
| 544 | + $schema['properties'] = $properties; |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + if ($format) { |
|
| 548 | + $schema['format'] = $format; |
|
| 549 | + } |
|
| 550 | + return $schema; |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + /** |
|
| 554 | + * Some fields are in the database-only, (ie, used in queries etc), but shouldn't necessarily be part |
|
| 555 | + * of the model objects (ie, client code shouldn't care to ever see their value... if client code does |
|
| 556 | + * want to see their value, then they shouldn't be db-only fields!) |
|
| 557 | + * Eg, when doing events as custom post types, querying the post_type is essential, but |
|
| 558 | + * post_type is irrelevant for EE_Event objects (because they will ALL be of post_type 'esp_event'). |
|
| 559 | + * By default, all fields aren't db-only. |
|
| 560 | + * |
|
| 561 | + * @return boolean |
|
| 562 | + */ |
|
| 563 | + public function is_db_only_field() |
|
| 564 | + { |
|
| 565 | + return false; |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * Validates the incoming string|array to ensure its an allowable type. |
|
| 571 | + * @throws InvalidArgumentException |
|
| 572 | + * @param string|array $type |
|
| 573 | + */ |
|
| 574 | + private function validateSchemaType($type) |
|
| 575 | + { |
|
| 576 | + if (! (is_string($type) || is_array($type))) { |
|
| 577 | + throw new InvalidArgumentException( |
|
| 578 | + sprintf( |
|
| 579 | + esc_html__('The incoming argument (%s) must be a string or an array.', 'event_espresso'), |
|
| 580 | + print_r($type, true) |
|
| 581 | + ) |
|
| 582 | + ); |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + //validate allowable types. |
|
| 586 | + //@link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
| 587 | + $allowable_types = array_flip( |
|
| 588 | + array( |
|
| 589 | + 'string', |
|
| 590 | + 'number', |
|
| 591 | + 'null', |
|
| 592 | + 'object', |
|
| 593 | + 'array', |
|
| 594 | + 'boolean', |
|
| 595 | + 'integer' |
|
| 596 | + ) |
|
| 597 | + ); |
|
| 598 | + |
|
| 599 | + if (is_array($type)) { |
|
| 600 | + foreach ($type as $item_in_type) { |
|
| 601 | + $this->validateSchemaType($item_in_type); |
|
| 602 | + } |
|
| 603 | + return; |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + if (! isset($allowable_types[$type])) { |
|
| 607 | + throw new InvalidArgumentException( |
|
| 608 | + sprintf( |
|
| 609 | + esc_html__('The incoming argument (%1$s) must be one of the allowable types: %2$s', 'event_espresso'), |
|
| 610 | + $type, |
|
| 611 | + implode(',', array_flip($allowable_types)) |
|
| 612 | + ) |
|
| 613 | + ); |
|
| 614 | + } |
|
| 615 | + } |
|
| 616 | + |
|
| 617 | + |
|
| 618 | + /** |
|
| 619 | + * Validates that the incoming format is an allowable string to use for the _schema_format property |
|
| 620 | + * @throws InvalidArgumentException |
|
| 621 | + * @param $format |
|
| 622 | + */ |
|
| 623 | + private function validateSchemaFormat($format) |
|
| 624 | + { |
|
| 625 | + if (! is_string($format)) { |
|
| 626 | + throw new InvalidArgumentException( |
|
| 627 | + sprintf( |
|
| 628 | + esc_html__('The incoming argument (%s) must be a string.', 'event_espresso'), |
|
| 629 | + print_r($format, true) |
|
| 630 | + ) |
|
| 631 | + ); |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + //validate allowable format values |
|
| 635 | + //@link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
| 636 | + $allowable_formats = array_flip( |
|
| 637 | + array( |
|
| 638 | + 'date-time', |
|
| 639 | + 'email', |
|
| 640 | + 'hostname', |
|
| 641 | + 'ipv4', |
|
| 642 | + 'ipv6', |
|
| 643 | + 'uri', |
|
| 644 | + 'uriref' |
|
| 645 | + ) |
|
| 646 | + ); |
|
| 647 | + |
|
| 648 | + if (! isset($allowable_formats[$format])) { |
|
| 649 | + throw new InvalidArgumentException( |
|
| 650 | + sprintf( |
|
| 651 | + esc_html__('The incoming argument (%1$s) must be one of the allowable formats: %2$s', 'event_espresso'), |
|
| 652 | + $format, |
|
| 653 | + implode(',', array_flip($allowable_formats)) |
|
| 654 | + ) |
|
| 655 | + ); |
|
| 656 | + } |
|
| 657 | + } |
|
| 659 | 658 | } |
| 660 | 659 | \ No newline at end of file |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | public function __construct($pm_instance = NULL) { |
| 23 | 23 | $this->_setup_properties(); |
| 24 | 24 | parent::__construct($pm_instance); |
| 25 | - $this->_gateway->set_unsupported_character_remover(new \EventEspresso\core\services\formatters\Windows1252()); |
|
| 25 | + $this->_gateway->set_unsupported_character_remover(new \EventEspresso\core\services\formatters\Windows1252()); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | $this->_gateway->set_template_helper( new EEH_Template() ); |
| 107 | 107 | $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
| 108 | 108 | $this->_gateway->set_money_helper( new EEH_Money() ); |
| 109 | - $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
| 110 | - $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
| 111 | - do_action( 'AHEE__EE_PMT_Base___construct__done_initializing_gateway_class',$this,$this->_gateway); |
|
| 109 | + $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
| 110 | + $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
| 111 | + do_action( 'AHEE__EE_PMT_Base___construct__done_initializing_gateway_class',$this,$this->_gateway); |
|
| 112 | 112 | } |
| 113 | 113 | if ( ! isset( $this->_has_billing_form ) ) { |
| 114 | 114 | // by default, On Site gateways have a billing form |
@@ -282,17 +282,17 @@ discard block |
||
| 282 | 282 | //if we know who the attendee is, and this is a billing form |
| 283 | 283 | //that uses attendee info, populate it |
| 284 | 284 | if ( |
| 285 | - apply_filters( |
|
| 286 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
| 287 | - ( |
|
| 288 | - $this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 289 | - && $transaction instanceof EE_Transaction |
|
| 290 | - && $transaction->primary_registration() instanceof EE_Registration |
|
| 291 | - && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
| 292 | - ), |
|
| 293 | - $this->_billing_form, |
|
| 294 | - $transaction |
|
| 295 | - ) |
|
| 285 | + apply_filters( |
|
| 286 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
| 287 | + ( |
|
| 288 | + $this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
| 289 | + && $transaction instanceof EE_Transaction |
|
| 290 | + && $transaction->primary_registration() instanceof EE_Registration |
|
| 291 | + && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
| 292 | + ), |
|
| 293 | + $this->_billing_form, |
|
| 294 | + $transaction |
|
| 295 | + ) |
|
| 296 | 296 | ){ |
| 297 | 297 | $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
| 298 | 298 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @since $VID:$ |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | -abstract class EE_PMT_Base{ |
|
| 19 | +abstract class EE_PMT_Base { |
|
| 20 | 20 | |
| 21 | 21 | const onsite = 'on-site'; |
| 22 | 22 | const offsite = 'off-site'; |
@@ -97,34 +97,34 @@ discard block |
||
| 97 | 97 | * @return EE_PMT_Base |
| 98 | 98 | */ |
| 99 | 99 | function __construct($pm_instance = NULL) { |
| 100 | - if ( $pm_instance instanceof EE_Payment_Method ){ |
|
| 100 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
| 101 | 101 | $this->set_instance($pm_instance); |
| 102 | 102 | } |
| 103 | - if($this->_gateway){ |
|
| 104 | - $this->_gateway->set_payment_model( EEM_Payment::instance() ); |
|
| 105 | - $this->_gateway->set_payment_log( EEM_Change_Log::instance() ); |
|
| 106 | - $this->_gateway->set_template_helper( new EEH_Template() ); |
|
| 107 | - $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
|
| 108 | - $this->_gateway->set_money_helper( new EEH_Money() ); |
|
| 103 | + if ($this->_gateway) { |
|
| 104 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
| 105 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
| 106 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
| 107 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
| 108 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
| 109 | 109 | $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
| 110 | 110 | $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
| 111 | - do_action( 'AHEE__EE_PMT_Base___construct__done_initializing_gateway_class',$this,$this->_gateway); |
|
| 111 | + do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
| 112 | 112 | } |
| 113 | - if ( ! isset( $this->_has_billing_form ) ) { |
|
| 113 | + if ( ! isset($this->_has_billing_form)) { |
|
| 114 | 114 | // by default, On Site gateways have a billing form |
| 115 | - if ( $this->payment_occurs() == EE_PMT_Base::onsite ) { |
|
| 116 | - $this->set_has_billing_form( true ); |
|
| 115 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
| 116 | + $this->set_has_billing_form(true); |
|
| 117 | 117 | } else { |
| 118 | - $this->set_has_billing_form( false ); |
|
| 118 | + $this->set_has_billing_form(false); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if( ! $this->_pretty_name){ |
|
| 122 | + if ( ! $this->_pretty_name) { |
|
| 123 | 123 | throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso"))); |
| 124 | 124 | } |
| 125 | 125 | //if the child didn't specify a default button, use the credit card one |
| 126 | - if( $this->_default_button_url === NULL){ |
|
| 127 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
| 126 | + if ($this->_default_button_url === NULL) { |
|
| 127 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | /** |
| 134 | 134 | * @param boolean $has_billing_form |
| 135 | 135 | */ |
| 136 | - public function set_has_billing_form( $has_billing_form ) { |
|
| 137 | - $this->_has_billing_form = filter_var( $has_billing_form, FILTER_VALIDATE_BOOLEAN ); |
|
| 136 | + public function set_has_billing_form($has_billing_form) { |
|
| 137 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | /** |
| 143 | 143 | * sets the file_folder property |
| 144 | 144 | */ |
| 145 | - protected function _set_file_folder(){ |
|
| 145 | + protected function _set_file_folder() { |
|
| 146 | 146 | $reflector = new ReflectionClass(get_class($this)); |
| 147 | 147 | $fn = $reflector->getFileName(); |
| 148 | - $this->_file_folder = dirname($fn).DS; |
|
| 148 | + $this->_file_folder = dirname($fn).DS; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | /** |
| 154 | 154 | * sets the file URL with a trailing slash for this PMT |
| 155 | 155 | */ |
| 156 | - protected function _set_file_url(){ |
|
| 157 | - $plugins_dir_fixed = str_replace('\\',DS,WP_PLUGIN_DIR); |
|
| 158 | - $file_folder_fixed = str_replace('\\',DS,$this->file_folder()); |
|
| 159 | - $file_path = str_replace($plugins_dir_fixed,WP_PLUGIN_URL,$file_folder_fixed); |
|
| 156 | + protected function _set_file_url() { |
|
| 157 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
| 158 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
| 159 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
| 160 | 160 | $this->_file_url = $file_path; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * Gets the default description on all payment methods of this type |
| 165 | 165 | * @return string |
| 166 | 166 | */ |
| 167 | - public function default_description(){ |
|
| 167 | + public function default_description() { |
|
| 168 | 168 | return $this->_default_description; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | * Returns the folder containing the PMT child class, with a trailing slash |
| 175 | 175 | * @return string |
| 176 | 176 | */ |
| 177 | - public function file_folder(){ |
|
| 178 | - if( ! $this->_file_folder ) { |
|
| 177 | + public function file_folder() { |
|
| 178 | + if ( ! $this->_file_folder) { |
|
| 179 | 179 | $this->_set_file_folder(); |
| 180 | 180 | } |
| 181 | 181 | return $this->_file_folder; |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | /** |
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | - public function file_url(){ |
|
| 190 | - if( ! $this->_file_url ) { |
|
| 189 | + public function file_url() { |
|
| 190 | + if ( ! $this->_file_url) { |
|
| 191 | 191 | $this->_set_file_url(); |
| 192 | 192 | } |
| 193 | 193 | return $this->_file_url; |
@@ -200,14 +200,14 @@ discard block |
||
| 200 | 200 | * Its important teh payment method instance is set before |
| 201 | 201 | * @param EE_Payment_Method $payment_method_instance |
| 202 | 202 | */ |
| 203 | - function set_instance($payment_method_instance){ |
|
| 203 | + function set_instance($payment_method_instance) { |
|
| 204 | 204 | $this->_pm_instance = $payment_method_instance; |
| 205 | 205 | //if they have already requested the settings form, make sure its |
| 206 | 206 | //data matches this model object |
| 207 | - if($this->_settings_form){ |
|
| 207 | + if ($this->_settings_form) { |
|
| 208 | 208 | $this->settings_form()->populate_model_obj($payment_method_instance); |
| 209 | 209 | } |
| 210 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
| 210 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 211 | 211 | $this->_gateway->set_settings($payment_method_instance->settings_array()); |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -218,13 +218,13 @@ discard block |
||
| 218 | 218 | * Gets teh form for displaying to admins where they setup the payment method |
| 219 | 219 | * @return EE_Payment_Method_Form |
| 220 | 220 | */ |
| 221 | - function settings_form(){ |
|
| 222 | - if( ! $this->_settings_form){ |
|
| 221 | + function settings_form() { |
|
| 222 | + if ( ! $this->_settings_form) { |
|
| 223 | 223 | $this->_settings_form = $this->generate_new_settings_form(); |
| 224 | - $this->_settings_form->set_payment_method_type( $this ); |
|
| 224 | + $this->_settings_form->set_payment_method_type($this); |
|
| 225 | 225 | //if we have already assigned a model object to this pmt, make |
| 226 | 226 | //sure its reflected in teh form we just generated |
| 227 | - if($this->_pm_instance){ |
|
| 227 | + if ($this->_pm_instance) { |
|
| 228 | 228 | $this->_settings_form->populate_model_obj($this->_pm_instance); |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * this payment method type's settings form later in the request |
| 251 | 251 | * @param EE_Payment_Method_Form $form |
| 252 | 252 | */ |
| 253 | - public function set_settings_form($form){ |
|
| 253 | + public function set_settings_form($form) { |
|
| 254 | 254 | $this->_settings_form = $form; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | * @param array $extra_args |
| 274 | 274 | * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
| 275 | 275 | */ |
| 276 | - public function billing_form( EE_Transaction $transaction = NULL, $extra_args = array() ){ |
|
| 276 | + public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array()) { |
|
| 277 | 277 | // has billing form already been regenerated ? or overwrite cache? |
| 278 | - if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form ){ |
|
| 279 | - $this->_billing_form = $this->generate_new_billing_form( $transaction, $extra_args ); |
|
| 278 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
| 279 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
| 280 | 280 | } |
| 281 | 281 | //if we know who the attendee is, and this is a billing form |
| 282 | 282 | //that uses attendee info, populate it |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | $this->_billing_form, |
| 293 | 293 | $transaction |
| 294 | 294 | ) |
| 295 | - ){ |
|
| 296 | - $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
|
| 295 | + ) { |
|
| 296 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
| 297 | 297 | } |
| 298 | 298 | return $this->_billing_form; |
| 299 | 299 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @param \EE_Transaction $transaction |
| 305 | 305 | * @return \EE_Billing_Info_Form |
| 306 | 306 | */ |
| 307 | - abstract function generate_new_billing_form( EE_Transaction $transaction = NULL ); |
|
| 307 | + abstract function generate_new_billing_form(EE_Transaction $transaction = NULL); |
|
| 308 | 308 | |
| 309 | 309 | |
| 310 | 310 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @param \EE_Billing_Info_Form $billing_form |
| 316 | 316 | * @return \EE_Billing_Info_Form |
| 317 | 317 | */ |
| 318 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
| 318 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
| 319 | 319 | return $billing_form; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * if you have form |
| 327 | 327 | * @param EE_Payment_Method $form |
| 328 | 328 | */ |
| 329 | - public function set_billing_form($form){ |
|
| 329 | + public function set_billing_form($form) { |
|
| 330 | 330 | $this->_billing_form = $form; |
| 331 | 331 | } |
| 332 | 332 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * Returns whether or not this payment method requires HTTPS to be used |
| 337 | 337 | * @return boolean |
| 338 | 338 | */ |
| 339 | - function requires_https(){ |
|
| 339 | + function requires_https() { |
|
| 340 | 340 | return $this->_requires_https; |
| 341 | 341 | } |
| 342 | 342 | |
@@ -354,9 +354,9 @@ discard block |
||
| 354 | 354 | * @return EE_Payment |
| 355 | 355 | * @throws EE_Error |
| 356 | 356 | */ |
| 357 | - function process_payment( EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null,$fail_url = '', $method = 'CART', $by_admin = false ){ |
|
| 357 | + function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { |
|
| 358 | 358 | // @todo: add surcharge for the payment method, if any |
| 359 | - if ( $this->_gateway ) { |
|
| 359 | + if ($this->_gateway) { |
|
| 360 | 360 | //there is a gateway, so we're going to make a payment object |
| 361 | 361 | //but wait! do they already have a payment in progress that we thought was failed? |
| 362 | 362 | $duplicate_properties = array( |
@@ -367,10 +367,10 @@ discard block |
||
| 367 | 367 | 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
| 368 | 368 | 'PAY_gateway_response' => null, |
| 369 | 369 | ); |
| 370 | - $payment = EEM_Payment::instance()->get_one( array( $duplicate_properties )); |
|
| 370 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
| 371 | 371 | //if we didn't already have a payment in progress for the same thing, |
| 372 | 372 | //then we actually want to make a new payment |
| 373 | - if ( ! $payment instanceof EE_Payment ){ |
|
| 373 | + if ( ! $payment instanceof EE_Payment) { |
|
| 374 | 374 | $payment = EE_Payment::new_instance( |
| 375 | 375 | array_merge( |
| 376 | 376 | $duplicate_properties, |
@@ -386,10 +386,10 @@ discard block |
||
| 386 | 386 | } |
| 387 | 387 | //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
| 388 | 388 | $payment->save(); |
| 389 | - $billing_values = $this->_get_billing_values_from_form( $billing_info ); |
|
| 389 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
| 390 | 390 | |
| 391 | 391 | // Offsite Gateway |
| 392 | - if( $this->_gateway instanceof EE_Offsite_Gateway ){ |
|
| 392 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 393 | 393 | |
| 394 | 394 | $payment = $this->_gateway->set_redirection_info( |
| 395 | 395 | $payment, |
@@ -405,17 +405,17 @@ discard block |
||
| 405 | 405 | ); |
| 406 | 406 | $payment->save(); |
| 407 | 407 | // Onsite Gateway |
| 408 | - } elseif ( $this->_gateway instanceof EE_Onsite_Gateway ) { |
|
| 408 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
| 409 | 409 | |
| 410 | - $payment = $this->_gateway->do_direct_payment($payment,$billing_values); |
|
| 410 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
| 411 | 411 | $payment->save(); |
| 412 | 412 | |
| 413 | 413 | } else { |
| 414 | 414 | throw new EE_Error( |
| 415 | 415 | sprintf( |
| 416 | - __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso' ), |
|
| 416 | + __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), |
|
| 417 | 417 | get_class($this), |
| 418 | - gettype( $this->_gateway ) |
|
| 418 | + gettype($this->_gateway) |
|
| 419 | 419 | ) |
| 420 | 420 | ); |
| 421 | 421 | } |
@@ -437,8 +437,8 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | // if there is billing info, clean it and save it now |
| 440 | - if( $billing_info instanceof EE_Billing_Attendee_Info_Form ){ |
|
| 441 | - $this->_save_billing_info_to_attendee( $billing_info, $transaction ); |
|
| 440 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
| 441 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | return $payment; |
@@ -451,10 +451,10 @@ discard block |
||
| 451 | 451 | * @param EE_Billing_Info_Form $billing_form |
| 452 | 452 | * @return array |
| 453 | 453 | */ |
| 454 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
| 455 | - if($billing_form instanceof EE_Form_Section_Proper ){ |
|
| 456 | - return $billing_form->input_pretty_values( true ); |
|
| 457 | - }else{ |
|
| 454 | + protected function _get_billing_values_from_form($billing_form) { |
|
| 455 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
| 456 | + return $billing_form->input_pretty_values(true); |
|
| 457 | + } else { |
|
| 458 | 458 | return NULL; |
| 459 | 459 | } |
| 460 | 460 | } |
@@ -468,13 +468,13 @@ discard block |
||
| 468 | 468 | * @return EE_Payment |
| 469 | 469 | * @throws EE_Error |
| 470 | 470 | */ |
| 471 | - public function handle_ipn($req_data,$transaction){ |
|
| 471 | + public function handle_ipn($req_data, $transaction) { |
|
| 472 | 472 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
| 473 | - if( ! $this->_gateway instanceof EE_Offsite_Gateway){ |
|
| 474 | - throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r( $this->_gateway, TRUE ))); |
|
| 473 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 474 | + throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE))); |
|
| 475 | 475 | |
| 476 | 476 | } |
| 477 | - $payment = $this->_gateway->handle_payment_update( $req_data, $transaction ); |
|
| 477 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
| 478 | 478 | return $payment; |
| 479 | 479 | } |
| 480 | 480 | |
@@ -487,22 +487,22 @@ discard block |
||
| 487 | 487 | * @param EE_Transaction $transaction |
| 488 | 488 | * @return boolean success |
| 489 | 489 | */ |
| 490 | - protected function _save_billing_info_to_attendee($billing_form, $transaction){ |
|
| 491 | - if( ! $transaction || ! $transaction instanceof EE_Transaction){ |
|
| 490 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) { |
|
| 491 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
| 492 | 492 | EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
| 493 | 493 | return false; |
| 494 | 494 | } |
| 495 | 495 | $primary_reg = $transaction->primary_registration(); |
| 496 | - if( ! $primary_reg ){ |
|
| 496 | + if ( ! $primary_reg) { |
|
| 497 | 497 | EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
| 498 | 498 | return false; |
| 499 | 499 | } |
| 500 | 500 | $attendee = $primary_reg->attendee(); |
| 501 | - if( ! $attendee ){ |
|
| 501 | + if ( ! $attendee) { |
|
| 502 | 502 | EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
| 503 | 503 | return false; |
| 504 | 504 | } |
| 505 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method() ); |
|
| 505 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
| 506 | 506 | |
| 507 | 507 | } |
| 508 | 508 | |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | * @param array $req_data |
| 516 | 516 | * @return EE_Payment |
| 517 | 517 | */ |
| 518 | - protected function find_payment_for_ipn( EE_Transaction $transaction, $req_data = array() ){ |
|
| 518 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) { |
|
| 519 | 519 | return $transaction->last_payment(); |
| 520 | 520 | } |
| 521 | 521 | |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
| 533 | 533 | * @throws EE_Error |
| 534 | 534 | */ |
| 535 | - public function handle_unclaimed_ipn( $req_data = array() ){ |
|
| 536 | - throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this) )); |
|
| 535 | + public function handle_unclaimed_ipn($req_data = array()) { |
|
| 536 | + throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | * @param EE_Transaction $transaction |
| 550 | 550 | * @return EE_Payment |
| 551 | 551 | */ |
| 552 | - public function finalize_payment_for($transaction){ |
|
| 552 | + public function finalize_payment_for($transaction) { |
|
| 553 | 553 | return $transaction->last_payment(); |
| 554 | 554 | } |
| 555 | 555 | |
@@ -559,10 +559,10 @@ discard block |
||
| 559 | 559 | * Whether or not this payment method's gateway supports sending refund requests |
| 560 | 560 | * @return boolean |
| 561 | 561 | */ |
| 562 | - public function supports_sending_refunds(){ |
|
| 563 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
| 562 | + public function supports_sending_refunds() { |
|
| 563 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 564 | 564 | return $this->_gateway->supports_sending_refunds(); |
| 565 | - }else{ |
|
| 565 | + } else { |
|
| 566 | 566 | return false; |
| 567 | 567 | } |
| 568 | 568 | } |
@@ -576,14 +576,14 @@ discard block |
||
| 576 | 576 | * @throws EE_Error |
| 577 | 577 | * @return EE_Payment |
| 578 | 578 | */ |
| 579 | - public function process_refund( EE_Payment $payment, $refund_info = array()){ |
|
| 580 | - if ( $this->_gateway && $this->_gateway instanceof EE_Gateway ) { |
|
| 581 | - return $this->_gateway->do_direct_refund( $payment, $refund_info ); |
|
| 579 | + public function process_refund(EE_Payment $payment, $refund_info = array()) { |
|
| 580 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
| 581 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
| 582 | 582 | } else { |
| 583 | 583 | throw new EE_Error( |
| 584 | 584 | sprintf( |
| 585 | - __( 'Payment Method Type "%s" does not support sending refund requests', 'event_espresso' ), |
|
| 586 | - get_class( $this ) |
|
| 585 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
| 586 | + get_class($this) |
|
| 587 | 587 | ) |
| 588 | 588 | ); |
| 589 | 589 | } |
@@ -597,15 +597,15 @@ discard block |
||
| 597 | 597 | * @return string |
| 598 | 598 | * @throws EE_Error |
| 599 | 599 | */ |
| 600 | - public function payment_occurs(){ |
|
| 601 | - if( ! $this->_gateway){ |
|
| 600 | + public function payment_occurs() { |
|
| 601 | + if ( ! $this->_gateway) { |
|
| 602 | 602 | return EE_PMT_Base::offline; |
| 603 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
| 603 | + }elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
| 604 | 604 | return EE_PMT_Base::onsite; |
| 605 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
| 605 | + }elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
| 606 | 606 | return EE_PMT_Base::offsite; |
| 607 | - }else{ |
|
| 608 | - throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
|
| 607 | + } else { |
|
| 608 | + throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this))); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | |
@@ -618,8 +618,8 @@ discard block |
||
| 618 | 618 | * @param EE_Payment $payment |
| 619 | 619 | * @return string |
| 620 | 620 | */ |
| 621 | - public function payment_overview_content(EE_Payment $payment){ |
|
| 622 | - return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance,'payment'=>$payment) , true); |
|
| 621 | + public function payment_overview_content(EE_Payment $payment) { |
|
| 622 | + return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance, 'payment'=>$payment), true); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | * @type array $template_args any arguments you want passed to the template file while rendering. |
| 633 | 633 | * Keys will be variable names and values with be their values. |
| 634 | 634 | */ |
| 635 | - public function help_tabs_config(){ |
|
| 635 | + public function help_tabs_config() { |
|
| 636 | 636 | return array(); |
| 637 | 637 | } |
| 638 | 638 | |
@@ -643,9 +643,9 @@ discard block |
||
| 643 | 643 | * the payment method's table's PMT_type column) |
| 644 | 644 | * @return string |
| 645 | 645 | */ |
| 646 | - public function system_name(){ |
|
| 646 | + public function system_name() { |
|
| 647 | 647 | $classname = get_class($this); |
| 648 | - return str_replace("EE_PMT_",'',$classname); |
|
| 648 | + return str_replace("EE_PMT_", '', $classname); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | * A pretty i18n version of the PMT name |
| 655 | 655 | * @return string |
| 656 | 656 | */ |
| 657 | - public function pretty_name(){ |
|
| 657 | + public function pretty_name() { |
|
| 658 | 658 | return $this->_pretty_name; |
| 659 | 659 | } |
| 660 | 660 | |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | * Gets the default absolute URL to the payment method type's button |
| 665 | 665 | * @return string |
| 666 | 666 | */ |
| 667 | - public function default_button_url(){ |
|
| 667 | + public function default_button_url() { |
|
| 668 | 668 | return $this->_default_button_url; |
| 669 | 669 | } |
| 670 | 670 | |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | * Gets the gateway used by this payment method (if any) |
| 675 | 675 | * @return EE_Gateway |
| 676 | 676 | */ |
| 677 | - public function get_gateway(){ |
|
| 677 | + public function get_gateway() { |
|
| 678 | 678 | return $this->_gateway; |
| 679 | 679 | } |
| 680 | 680 | |
@@ -683,8 +683,8 @@ discard block |
||
| 683 | 683 | /** |
| 684 | 684 | * @return string html for the link to a help tab |
| 685 | 685 | */ |
| 686 | - public function get_help_tab_link(){ |
|
| 687 | - return EEH_Template::get_help_tab_link( $this->get_help_tab_name() ); |
|
| 686 | + public function get_help_tab_link() { |
|
| 687 | + return EEH_Template::get_help_tab_link($this->get_help_tab_name()); |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | |
@@ -693,8 +693,8 @@ discard block |
||
| 693 | 693 | * Returns the name of the help tab for this PMT |
| 694 | 694 | * @return string |
| 695 | 695 | */ |
| 696 | - public function get_help_tab_name(){ |
|
| 697 | - return 'ee_' . strtolower( $this->system_name() ) . '_help_tab'; |
|
| 696 | + public function get_help_tab_name() { |
|
| 697 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | /** |
@@ -702,8 +702,8 @@ discard block |
||
| 702 | 702 | * this PMT by an admin |
| 703 | 703 | * @return string |
| 704 | 704 | */ |
| 705 | - public function cap_name(){ |
|
| 706 | - return 'ee_payment_method_' . strtolower( $this->system_name() ); |
|
| 705 | + public function cap_name() { |
|
| 706 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
@@ -715,9 +715,9 @@ discard block |
||
| 715 | 715 | * @param EE_Payment $payment |
| 716 | 716 | * @return void |
| 717 | 717 | */ |
| 718 | - public function update_txn_based_on_payment( $payment ){ |
|
| 719 | - if( $this->_gateway instanceof EE_Gateway ){ |
|
| 720 | - $this->_gateway->update_txn_based_on_payment( $payment ); |
|
| 718 | + public function update_txn_based_on_payment($payment) { |
|
| 719 | + if ($this->_gateway instanceof EE_Gateway) { |
|
| 720 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
| 721 | 721 | } |
| 722 | 722 | } |
| 723 | 723 | |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | * @return string |
| 733 | 733 | */ |
| 734 | 734 | public function introductory_html() { |
| 735 | - return EEH_Template::locate_template( $this->file_folder() . 'templates' . DS . strtolower( $this->system_name() ) . '_intro.template.php', array( 'pmt_obj' => $this, 'pm_instance' => $this->_pm_instance ) ); |
|
| 735 | + return EEH_Template::locate_template($this->file_folder().'templates'.DS.strtolower($this->system_name()).'_intro.template.php', array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | |
@@ -18,54 +18,54 @@ |
||
| 18 | 18 | class TicketSelectorSimple extends TicketSelector |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var \EE_Ticket $ticket |
|
| 23 | - */ |
|
| 24 | - protected $ticket; |
|
| 21 | + /** |
|
| 22 | + * @var \EE_Ticket $ticket |
|
| 23 | + */ |
|
| 24 | + protected $ticket; |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * TicketSelectorSimple constructor. |
|
| 30 | - * |
|
| 31 | - * @param \EE_Event $event |
|
| 32 | - * @param \EE_Ticket $ticket |
|
| 33 | - * @param int $max_attendees |
|
| 34 | - * @param array $template_args |
|
| 35 | - */ |
|
| 36 | - public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args) |
|
| 37 | - { |
|
| 38 | - $this->ticket = $ticket; |
|
| 39 | - parent::__construct($event, array($this->ticket), $max_attendees, $template_args); |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * TicketSelectorSimple constructor. |
|
| 30 | + * |
|
| 31 | + * @param \EE_Event $event |
|
| 32 | + * @param \EE_Ticket $ticket |
|
| 33 | + * @param int $max_attendees |
|
| 34 | + * @param array $template_args |
|
| 35 | + */ |
|
| 36 | + public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args) |
|
| 37 | + { |
|
| 38 | + $this->ticket = $ticket; |
|
| 39 | + parent::__construct($event, array($this->ticket), $max_attendees, $template_args); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * sets any and all template args that are required for this Ticket Selector |
|
| 46 | - * |
|
| 47 | - * @return void |
|
| 48 | - * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
| 49 | - * @throws \EE_Error |
|
| 50 | - */ |
|
| 51 | - protected function addTemplateArgs() |
|
| 52 | - { |
|
| 53 | - unset($this->template_args['tickets']); |
|
| 54 | - $this->template_args['ticket'] = $this->ticket; |
|
| 55 | - $ticket_selector_row = new TicketSelectorRowSimple( |
|
| 56 | - $this->ticket, |
|
| 57 | - $this->max_attendees, |
|
| 58 | - $this->template_args['date_format'], |
|
| 59 | - $this->template_args['event_status'] |
|
| 60 | - ); |
|
| 61 | - $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
| 62 | - $ticket_selector_row->setupTicketStatusDisplay(); |
|
| 63 | - $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
| 64 | - if (empty($this->template_args['ticket_status_display'])) { |
|
| 65 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 66 | - } |
|
| 67 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
| 68 | - } |
|
| 44 | + /** |
|
| 45 | + * sets any and all template args that are required for this Ticket Selector |
|
| 46 | + * |
|
| 47 | + * @return void |
|
| 48 | + * @throws \EventEspresso\core\exceptions\UnexpectedEntityException |
|
| 49 | + * @throws \EE_Error |
|
| 50 | + */ |
|
| 51 | + protected function addTemplateArgs() |
|
| 52 | + { |
|
| 53 | + unset($this->template_args['tickets']); |
|
| 54 | + $this->template_args['ticket'] = $this->ticket; |
|
| 55 | + $ticket_selector_row = new TicketSelectorRowSimple( |
|
| 56 | + $this->ticket, |
|
| 57 | + $this->max_attendees, |
|
| 58 | + $this->template_args['date_format'], |
|
| 59 | + $this->template_args['event_status'] |
|
| 60 | + ); |
|
| 61 | + $this->template_args['TKT_ID'] = $this->ticket->ID(); |
|
| 62 | + $ticket_selector_row->setupTicketStatusDisplay(); |
|
| 63 | + $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay(); |
|
| 64 | + if (empty($this->template_args['ticket_status_display'])) { |
|
| 65 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
| 66 | + } |
|
| 67 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | } |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | if (empty($this->template_args['ticket_status_display'])) { |
| 65 | 65 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
| 66 | 66 | } |
| 67 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php'; |
|
| 67 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php'; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -18,15 +18,15 @@ |
||
| 18 | 18 | class TicketSelectorRowSimple extends TicketSelectorRow |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @throws EE_Error |
|
| 23 | - */ |
|
| 24 | - public function setupTicketStatusDisplay() |
|
| 25 | - { |
|
| 26 | - $remaining = $this->ticket->remaining(); |
|
| 27 | - list($tkt_status, $ticket_status) = $this->getTicketStatusClasses($remaining); |
|
| 28 | - $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
| 29 | - } |
|
| 21 | + /** |
|
| 22 | + * @throws EE_Error |
|
| 23 | + */ |
|
| 24 | + public function setupTicketStatusDisplay() |
|
| 25 | + { |
|
| 26 | + $remaining = $this->ticket->remaining(); |
|
| 27 | + list($tkt_status, $ticket_status) = $this->getTicketStatusClasses($remaining); |
|
| 28 | + $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
@@ -19,249 +19,249 @@ |
||
| 19 | 19 | abstract class TicketSelectorRow |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var \EE_Ticket $ticket |
|
| 24 | - */ |
|
| 25 | - protected $ticket; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var int $total_tickets |
|
| 29 | - */ |
|
| 30 | - protected $total_tickets; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var int $max_atndz |
|
| 34 | - */ |
|
| 35 | - protected $max_atndz; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var string $date_format |
|
| 39 | - */ |
|
| 40 | - protected $date_format; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var int $EVT_ID |
|
| 44 | - */ |
|
| 45 | - protected $EVT_ID; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var string $event_status |
|
| 49 | - */ |
|
| 50 | - protected $event_status; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var boolean $required_ticket_sold_out |
|
| 54 | - */ |
|
| 55 | - protected $required_ticket_sold_out; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var string $ticket_status_display |
|
| 59 | - */ |
|
| 60 | - protected $ticket_status_display; |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @param \EE_Ticket $ticket |
|
| 66 | - * @param int $max_atndz |
|
| 67 | - * @param string $date_format |
|
| 68 | - * @param string $event_status |
|
| 69 | - * @param bool $required_ticket_sold_out |
|
| 70 | - * @throws EE_Error |
|
| 71 | - * @throws UnexpectedEntityException |
|
| 72 | - */ |
|
| 73 | - public function __construct( |
|
| 74 | - \EE_Ticket $ticket, |
|
| 75 | - $max_atndz, |
|
| 76 | - $date_format, |
|
| 77 | - $event_status, |
|
| 78 | - $required_ticket_sold_out = false |
|
| 79 | - ) { |
|
| 80 | - $this->ticket = $ticket; |
|
| 81 | - $this->max_atndz = $max_atndz; |
|
| 82 | - $this->date_format = $date_format; |
|
| 83 | - $this->EVT_ID = $this->ticket->get_event_ID(); |
|
| 84 | - $this->event_status = $event_status; |
|
| 85 | - $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * getTicketStatusClasses |
|
| 92 | - * |
|
| 93 | - * @param int $remaining |
|
| 94 | - * @return array |
|
| 95 | - * @throws EE_Error |
|
| 96 | - */ |
|
| 97 | - protected function getTicketStatusClasses($remaining = 0) |
|
| 98 | - { |
|
| 99 | - // if a previous required ticket with the same sale start date is sold out, |
|
| 100 | - // then mark this ticket as sold out as well. |
|
| 101 | - // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
| 102 | - $tkt_status = $this->required_ticket_sold_out !== false |
|
| 103 | - && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
| 104 | - ? \EE_Ticket::sold_out |
|
| 105 | - : $this->ticket->ticket_status(); |
|
| 106 | - $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
| 107 | - ? \EE_Ticket::sold_out |
|
| 108 | - : $tkt_status; |
|
| 109 | - // check ticket status |
|
| 110 | - switch ($tkt_status) { |
|
| 111 | - // sold_out |
|
| 112 | - case \EE_Ticket::sold_out : |
|
| 113 | - $ticket_status = 'ticket-sales-sold-out'; |
|
| 114 | - $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
| 115 | - break; |
|
| 116 | - // expired |
|
| 117 | - case \EE_Ticket::expired : |
|
| 118 | - $ticket_status = 'ticket-sales-expired'; |
|
| 119 | - $status_class = 'ticket-sales-expired lt-grey-text'; |
|
| 120 | - break; |
|
| 121 | - // archived |
|
| 122 | - case \EE_Ticket::archived : |
|
| 123 | - $ticket_status = 'archived-ticket'; |
|
| 124 | - $status_class = 'archived-ticket hidden'; |
|
| 125 | - break; |
|
| 126 | - // pending |
|
| 127 | - case \EE_Ticket::pending : |
|
| 128 | - $ticket_status = 'ticket-pending'; |
|
| 129 | - $status_class = 'ticket-pending'; |
|
| 130 | - break; |
|
| 131 | - // onsale |
|
| 132 | - case \EE_Ticket::onsale : |
|
| 133 | - default : |
|
| 134 | - $ticket_status = 'ticket-on-sale'; |
|
| 135 | - $status_class = 'ticket-on-sale'; |
|
| 136 | - break; |
|
| 137 | - } |
|
| 138 | - $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
| 139 | - return array($tkt_status, $ticket_status, $status_class); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * @return string |
|
| 145 | - */ |
|
| 146 | - public function getTicketStatusDisplay() |
|
| 147 | - { |
|
| 148 | - return $this->ticket_status_display; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * setTicketStatusDisplay |
|
| 155 | - * |
|
| 156 | - * @param string $tkt_status |
|
| 157 | - * @param string $ticket_status |
|
| 158 | - * @param int $remaining |
|
| 159 | - * @throws EE_Error |
|
| 160 | - */ |
|
| 161 | - protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
| 162 | - $this->ticket_status_display = ''; |
|
| 163 | - // now depending on the ticket and other circumstances... |
|
| 164 | - if ($this->max_atndz === 0) { |
|
| 165 | - // registration is CLOSED because admin set max attendees to ZERO |
|
| 166 | - $this->ticket_status_display = $this->registrationClosed(); |
|
| 167 | - } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
| 168 | - // SOLD OUT - no tickets remaining |
|
| 169 | - $this->ticket_status_display = $this->ticketsSoldOut(); |
|
| 170 | - } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
| 171 | - // expired or archived ticket |
|
| 172 | - $this->ticket_status_display = $ticket_status; |
|
| 173 | - } else if ($tkt_status === \EE_Ticket::pending) { |
|
| 174 | - // ticket not on sale yet |
|
| 175 | - $this->ticket_status_display = $this->ticketsSalesPending(); |
|
| 176 | - } else if ($this->ticket->min() > $remaining) { |
|
| 177 | - // min qty purchasable is less than tickets available |
|
| 178 | - $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * registrationClosed |
|
| 186 | - */ |
|
| 187 | - protected function registrationClosed() |
|
| 188 | - { |
|
| 189 | - return \EEH_HTML::span( |
|
| 190 | - apply_filters( |
|
| 191 | - 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
| 192 | - __('Closed', 'event_espresso') |
|
| 193 | - ), |
|
| 194 | - '', 'sold-out' |
|
| 195 | - ); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * ticketsSoldOut |
|
| 202 | - */ |
|
| 203 | - protected function ticketsSoldOut() |
|
| 204 | - { |
|
| 205 | - return \EEH_HTML::span( |
|
| 206 | - apply_filters( |
|
| 207 | - 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
| 208 | - __('Sold Out', 'event_espresso') |
|
| 209 | - ), |
|
| 210 | - '', 'sold-out' |
|
| 211 | - ); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * ticketsSalesPending |
|
| 218 | - * |
|
| 219 | - * @throws EE_Error |
|
| 220 | - */ |
|
| 221 | - protected function ticketsSalesPending() |
|
| 222 | - { |
|
| 223 | - return \EEH_HTML::span( |
|
| 224 | - \EEH_HTML::span( |
|
| 225 | - apply_filters( |
|
| 226 | - 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
| 227 | - __('Goes On Sale', 'event_espresso') |
|
| 228 | - ), |
|
| 229 | - '', 'ticket-pending' |
|
| 230 | - ) |
|
| 231 | - . \EEH_HTML::br() |
|
| 232 | - . \EEH_HTML::span( |
|
| 233 | - $this->ticket->get_i18n_datetime( |
|
| 234 | - 'TKT_start_date', |
|
| 235 | - apply_filters( |
|
| 236 | - 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
| 237 | - $this->date_format |
|
| 238 | - ) |
|
| 239 | - ), |
|
| 240 | - '', 'small-text' |
|
| 241 | - ), |
|
| 242 | - '', 'ticket-pending-pg' |
|
| 243 | - ); |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * notEnoughTicketsAvailable |
|
| 250 | - */ |
|
| 251 | - protected function notEnoughTicketsAvailable() |
|
| 252 | - { |
|
| 253 | - return \EEH_HTML::div( |
|
| 254 | - \EEH_HTML::span( |
|
| 255 | - apply_filters( |
|
| 256 | - 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
| 257 | - __('Not Available', 'event_espresso') |
|
| 258 | - ), |
|
| 259 | - '', 'archived-ticket small-text' |
|
| 260 | - ) |
|
| 261 | - . \EEH_HTML::br(), |
|
| 262 | - '', 'archived-ticket-pg' |
|
| 263 | - ); |
|
| 264 | - } |
|
| 22 | + /** |
|
| 23 | + * @var \EE_Ticket $ticket |
|
| 24 | + */ |
|
| 25 | + protected $ticket; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var int $total_tickets |
|
| 29 | + */ |
|
| 30 | + protected $total_tickets; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var int $max_atndz |
|
| 34 | + */ |
|
| 35 | + protected $max_atndz; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var string $date_format |
|
| 39 | + */ |
|
| 40 | + protected $date_format; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var int $EVT_ID |
|
| 44 | + */ |
|
| 45 | + protected $EVT_ID; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var string $event_status |
|
| 49 | + */ |
|
| 50 | + protected $event_status; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var boolean $required_ticket_sold_out |
|
| 54 | + */ |
|
| 55 | + protected $required_ticket_sold_out; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var string $ticket_status_display |
|
| 59 | + */ |
|
| 60 | + protected $ticket_status_display; |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @param \EE_Ticket $ticket |
|
| 66 | + * @param int $max_atndz |
|
| 67 | + * @param string $date_format |
|
| 68 | + * @param string $event_status |
|
| 69 | + * @param bool $required_ticket_sold_out |
|
| 70 | + * @throws EE_Error |
|
| 71 | + * @throws UnexpectedEntityException |
|
| 72 | + */ |
|
| 73 | + public function __construct( |
|
| 74 | + \EE_Ticket $ticket, |
|
| 75 | + $max_atndz, |
|
| 76 | + $date_format, |
|
| 77 | + $event_status, |
|
| 78 | + $required_ticket_sold_out = false |
|
| 79 | + ) { |
|
| 80 | + $this->ticket = $ticket; |
|
| 81 | + $this->max_atndz = $max_atndz; |
|
| 82 | + $this->date_format = $date_format; |
|
| 83 | + $this->EVT_ID = $this->ticket->get_event_ID(); |
|
| 84 | + $this->event_status = $event_status; |
|
| 85 | + $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * getTicketStatusClasses |
|
| 92 | + * |
|
| 93 | + * @param int $remaining |
|
| 94 | + * @return array |
|
| 95 | + * @throws EE_Error |
|
| 96 | + */ |
|
| 97 | + protected function getTicketStatusClasses($remaining = 0) |
|
| 98 | + { |
|
| 99 | + // if a previous required ticket with the same sale start date is sold out, |
|
| 100 | + // then mark this ticket as sold out as well. |
|
| 101 | + // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
| 102 | + $tkt_status = $this->required_ticket_sold_out !== false |
|
| 103 | + && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
| 104 | + ? \EE_Ticket::sold_out |
|
| 105 | + : $this->ticket->ticket_status(); |
|
| 106 | + $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
| 107 | + ? \EE_Ticket::sold_out |
|
| 108 | + : $tkt_status; |
|
| 109 | + // check ticket status |
|
| 110 | + switch ($tkt_status) { |
|
| 111 | + // sold_out |
|
| 112 | + case \EE_Ticket::sold_out : |
|
| 113 | + $ticket_status = 'ticket-sales-sold-out'; |
|
| 114 | + $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
| 115 | + break; |
|
| 116 | + // expired |
|
| 117 | + case \EE_Ticket::expired : |
|
| 118 | + $ticket_status = 'ticket-sales-expired'; |
|
| 119 | + $status_class = 'ticket-sales-expired lt-grey-text'; |
|
| 120 | + break; |
|
| 121 | + // archived |
|
| 122 | + case \EE_Ticket::archived : |
|
| 123 | + $ticket_status = 'archived-ticket'; |
|
| 124 | + $status_class = 'archived-ticket hidden'; |
|
| 125 | + break; |
|
| 126 | + // pending |
|
| 127 | + case \EE_Ticket::pending : |
|
| 128 | + $ticket_status = 'ticket-pending'; |
|
| 129 | + $status_class = 'ticket-pending'; |
|
| 130 | + break; |
|
| 131 | + // onsale |
|
| 132 | + case \EE_Ticket::onsale : |
|
| 133 | + default : |
|
| 134 | + $ticket_status = 'ticket-on-sale'; |
|
| 135 | + $status_class = 'ticket-on-sale'; |
|
| 136 | + break; |
|
| 137 | + } |
|
| 138 | + $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
| 139 | + return array($tkt_status, $ticket_status, $status_class); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @return string |
|
| 145 | + */ |
|
| 146 | + public function getTicketStatusDisplay() |
|
| 147 | + { |
|
| 148 | + return $this->ticket_status_display; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * setTicketStatusDisplay |
|
| 155 | + * |
|
| 156 | + * @param string $tkt_status |
|
| 157 | + * @param string $ticket_status |
|
| 158 | + * @param int $remaining |
|
| 159 | + * @throws EE_Error |
|
| 160 | + */ |
|
| 161 | + protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
| 162 | + $this->ticket_status_display = ''; |
|
| 163 | + // now depending on the ticket and other circumstances... |
|
| 164 | + if ($this->max_atndz === 0) { |
|
| 165 | + // registration is CLOSED because admin set max attendees to ZERO |
|
| 166 | + $this->ticket_status_display = $this->registrationClosed(); |
|
| 167 | + } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
| 168 | + // SOLD OUT - no tickets remaining |
|
| 169 | + $this->ticket_status_display = $this->ticketsSoldOut(); |
|
| 170 | + } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
| 171 | + // expired or archived ticket |
|
| 172 | + $this->ticket_status_display = $ticket_status; |
|
| 173 | + } else if ($tkt_status === \EE_Ticket::pending) { |
|
| 174 | + // ticket not on sale yet |
|
| 175 | + $this->ticket_status_display = $this->ticketsSalesPending(); |
|
| 176 | + } else if ($this->ticket->min() > $remaining) { |
|
| 177 | + // min qty purchasable is less than tickets available |
|
| 178 | + $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * registrationClosed |
|
| 186 | + */ |
|
| 187 | + protected function registrationClosed() |
|
| 188 | + { |
|
| 189 | + return \EEH_HTML::span( |
|
| 190 | + apply_filters( |
|
| 191 | + 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
| 192 | + __('Closed', 'event_espresso') |
|
| 193 | + ), |
|
| 194 | + '', 'sold-out' |
|
| 195 | + ); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * ticketsSoldOut |
|
| 202 | + */ |
|
| 203 | + protected function ticketsSoldOut() |
|
| 204 | + { |
|
| 205 | + return \EEH_HTML::span( |
|
| 206 | + apply_filters( |
|
| 207 | + 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
| 208 | + __('Sold Out', 'event_espresso') |
|
| 209 | + ), |
|
| 210 | + '', 'sold-out' |
|
| 211 | + ); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * ticketsSalesPending |
|
| 218 | + * |
|
| 219 | + * @throws EE_Error |
|
| 220 | + */ |
|
| 221 | + protected function ticketsSalesPending() |
|
| 222 | + { |
|
| 223 | + return \EEH_HTML::span( |
|
| 224 | + \EEH_HTML::span( |
|
| 225 | + apply_filters( |
|
| 226 | + 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
| 227 | + __('Goes On Sale', 'event_espresso') |
|
| 228 | + ), |
|
| 229 | + '', 'ticket-pending' |
|
| 230 | + ) |
|
| 231 | + . \EEH_HTML::br() |
|
| 232 | + . \EEH_HTML::span( |
|
| 233 | + $this->ticket->get_i18n_datetime( |
|
| 234 | + 'TKT_start_date', |
|
| 235 | + apply_filters( |
|
| 236 | + 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
| 237 | + $this->date_format |
|
| 238 | + ) |
|
| 239 | + ), |
|
| 240 | + '', 'small-text' |
|
| 241 | + ), |
|
| 242 | + '', 'ticket-pending-pg' |
|
| 243 | + ); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * notEnoughTicketsAvailable |
|
| 250 | + */ |
|
| 251 | + protected function notEnoughTicketsAvailable() |
|
| 252 | + { |
|
| 253 | + return \EEH_HTML::div( |
|
| 254 | + \EEH_HTML::span( |
|
| 255 | + apply_filters( |
|
| 256 | + 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
| 257 | + __('Not Available', 'event_espresso') |
|
| 258 | + ), |
|
| 259 | + '', 'archived-ticket small-text' |
|
| 260 | + ) |
|
| 261 | + . \EEH_HTML::br(), |
|
| 262 | + '', 'archived-ticket-pg' |
|
| 263 | + ); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | |
| 267 | 267 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | public static function instance() |
| 151 | 151 | { |
| 152 | 152 | // check if class object is instantiated, and instantiated properly |
| 153 | - if (! self::$_instance instanceof EE_Config) { |
|
| 153 | + if ( ! self::$_instance instanceof EE_Config) { |
|
| 154 | 154 | self::$_instance = new self(); |
| 155 | 155 | } |
| 156 | 156 | return self::$_instance; |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | $this |
| 294 | 294 | ); |
| 295 | 295 | if (is_object($settings) && property_exists($this, $config)) { |
| 296 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 296 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
| 297 | 297 | //call configs populate method to ensure any defaults are set for empty values. |
| 298 | 298 | if (method_exists($settings, 'populate')) { |
| 299 | 299 | $this->{$config}->populate(); |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | break; |
| 562 | 562 | // TEST #2 : check that settings section exists |
| 563 | 563 | case 2 : |
| 564 | - if (! isset($this->{$section})) { |
|
| 564 | + if ( ! isset($this->{$section})) { |
|
| 565 | 565 | if ($display_errors) { |
| 566 | 566 | throw new EE_Error( |
| 567 | 567 | sprintf( |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | break; |
| 623 | 623 | // TEST #6 : verify config class is accessible |
| 624 | 624 | case 6 : |
| 625 | - if (! class_exists($config_class)) { |
|
| 625 | + if ( ! class_exists($config_class)) { |
|
| 626 | 626 | if ($display_errors) { |
| 627 | 627 | throw new EE_Error( |
| 628 | 628 | sprintf( |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | break; |
| 640 | 640 | // TEST #7 : check that config has even been set |
| 641 | 641 | case 7 : |
| 642 | - if (! isset($this->{$section}->{$name})) { |
|
| 642 | + if ( ! isset($this->{$section}->{$name})) { |
|
| 643 | 643 | if ($display_errors) { |
| 644 | 644 | throw new EE_Error( |
| 645 | 645 | sprintf( |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | break; |
| 658 | 658 | // TEST #8 : check that config is the requested type |
| 659 | 659 | case 8 : |
| 660 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
| 660 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
| 661 | 661 | if ($display_errors) { |
| 662 | 662 | throw new EE_Error( |
| 663 | 663 | sprintf( |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | break; |
| 677 | 677 | // TEST #9 : verify config object |
| 678 | 678 | case 9 : |
| 679 | - if (! $config_obj instanceof EE_Config_Base) { |
|
| 679 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
| 680 | 680 | if ($display_errors) { |
| 681 | 681 | throw new EE_Error( |
| 682 | 682 | sprintf( |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | */ |
| 710 | 710 | private function _generate_config_option_name($section = '', $name = '') |
| 711 | 711 | { |
| 712 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 712 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | { |
| 728 | 728 | return ! empty($config_class) |
| 729 | 729 | ? $config_class |
| 730 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 730 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | |
@@ -747,17 +747,17 @@ discard block |
||
| 747 | 747 | // ensure config class is set to something |
| 748 | 748 | $config_class = $this->_set_config_class($config_class, $name); |
| 749 | 749 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
| 750 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 750 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 751 | 751 | return null; |
| 752 | 752 | } |
| 753 | 753 | $config_option_name = $this->_generate_config_option_name($section, $name); |
| 754 | 754 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
| 755 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 755 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
| 756 | 756 | $this->_addon_option_names[$config_option_name] = $config_class; |
| 757 | 757 | $this->update_addon_option_names(); |
| 758 | 758 | } |
| 759 | 759 | // verify the incoming config object but suppress errors |
| 760 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 760 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 761 | 761 | $config_obj = new $config_class(); |
| 762 | 762 | } |
| 763 | 763 | if (get_option($config_option_name)) { |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | // get class name of the incoming object |
| 806 | 806 | $config_class = get_class($config_obj); |
| 807 | 807 | // run tests 1-5 and 9 to verify config |
| 808 | - if (! $this->_verify_config_params( |
|
| 808 | + if ( ! $this->_verify_config_params( |
|
| 809 | 809 | $section, |
| 810 | 810 | $name, |
| 811 | 811 | $config_class, |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | } |
| 818 | 818 | $config_option_name = $this->_generate_config_option_name($section, $name); |
| 819 | 819 | // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
| 820 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 820 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
| 821 | 821 | // save new config to db |
| 822 | 822 | if ($this->set_config($section, $name, $config_class, $config_obj)) { |
| 823 | 823 | return true; |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | 'event_espresso' |
| 844 | 844 | ), |
| 845 | 845 | $config_class, |
| 846 | - 'EE_Config->' . $section . '->' . $name |
|
| 846 | + 'EE_Config->'.$section.'->'.$name |
|
| 847 | 847 | ), |
| 848 | 848 | __FILE__, |
| 849 | 849 | __FUNCTION__, |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | // ensure config class is set to something |
| 871 | 871 | $config_class = $this->_set_config_class($config_class, $name); |
| 872 | 872 | // run tests 1-4, 6 and 7 to verify that all params have been set |
| 873 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 873 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 874 | 874 | return null; |
| 875 | 875 | } |
| 876 | 876 | // now test if the requested config object exists, but suppress errors |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | // retrieve the wp-option for this config class. |
| 917 | 917 | $config_option = maybe_unserialize(get_option($config_option_name, array())); |
| 918 | 918 | if (empty($config_option)) { |
| 919 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 919 | + EE_Config::log($config_option_name.'-NOT-FOUND'); |
|
| 920 | 920 | } |
| 921 | 921 | return $config_option; |
| 922 | 922 | } |
@@ -935,7 +935,7 @@ discard block |
||
| 935 | 935 | //copy incoming $_REQUEST and sanitize it so we can save it |
| 936 | 936 | $_request = $_REQUEST; |
| 937 | 937 | array_walk_recursive($_request, 'sanitize_text_field'); |
| 938 | - $config_log[(string)microtime(true)] = array( |
|
| 938 | + $config_log[(string) microtime(true)] = array( |
|
| 939 | 939 | 'config_name' => $config_option_name, |
| 940 | 940 | 'request' => $_request, |
| 941 | 941 | ); |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | */ |
| 952 | 952 | public static function trim_log() |
| 953 | 953 | { |
| 954 | - if (! EE_Config::logging_enabled()) { |
|
| 954 | + if ( ! EE_Config::logging_enabled()) { |
|
| 955 | 955 | return; |
| 956 | 956 | } |
| 957 | 957 | $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | public static function get_page_for_posts() |
| 977 | 977 | { |
| 978 | 978 | $page_for_posts = get_option('page_for_posts'); |
| 979 | - if (! $page_for_posts) { |
|
| 979 | + if ( ! $page_for_posts) { |
|
| 980 | 980 | return 'posts'; |
| 981 | 981 | } |
| 982 | 982 | /** @type WPDB $wpdb */ |
@@ -1037,13 +1037,13 @@ discard block |
||
| 1037 | 1037 | ) |
| 1038 | 1038 | ) { |
| 1039 | 1039 | // grab list of installed widgets |
| 1040 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1040 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
| 1041 | 1041 | // filter list of modules to register |
| 1042 | 1042 | $widgets_to_register = apply_filters( |
| 1043 | 1043 | 'FHEE__EE_Config__register_widgets__widgets_to_register', |
| 1044 | 1044 | $widgets_to_register |
| 1045 | 1045 | ); |
| 1046 | - if (! empty($widgets_to_register)) { |
|
| 1046 | + if ( ! empty($widgets_to_register)) { |
|
| 1047 | 1047 | // cycle thru widget folders |
| 1048 | 1048 | foreach ($widgets_to_register as $widget_path) { |
| 1049 | 1049 | // add to list of installed widget modules |
@@ -1094,31 +1094,31 @@ discard block |
||
| 1094 | 1094 | // create classname from widget directory name |
| 1095 | 1095 | $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
| 1096 | 1096 | // add class prefix |
| 1097 | - $widget_class = 'EEW_' . $widget; |
|
| 1097 | + $widget_class = 'EEW_'.$widget; |
|
| 1098 | 1098 | // does the widget exist ? |
| 1099 | - if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1099 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
| 1100 | 1100 | $msg = sprintf( |
| 1101 | 1101 | __( |
| 1102 | 1102 | 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
| 1103 | 1103 | 'event_espresso' |
| 1104 | 1104 | ), |
| 1105 | 1105 | $widget_class, |
| 1106 | - $widget_path . DS . $widget_class . $widget_ext |
|
| 1106 | + $widget_path.DS.$widget_class.$widget_ext |
|
| 1107 | 1107 | ); |
| 1108 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1108 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1109 | 1109 | return; |
| 1110 | 1110 | } |
| 1111 | 1111 | // load the widget class file |
| 1112 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1112 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
| 1113 | 1113 | // verify that class exists |
| 1114 | - if (! class_exists($widget_class)) { |
|
| 1114 | + if ( ! class_exists($widget_class)) { |
|
| 1115 | 1115 | $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
| 1116 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1116 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1117 | 1117 | return; |
| 1118 | 1118 | } |
| 1119 | 1119 | register_widget($widget_class); |
| 1120 | 1120 | // add to array of registered widgets |
| 1121 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1121 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | |
@@ -1132,19 +1132,19 @@ discard block |
||
| 1132 | 1132 | private function _register_modules() |
| 1133 | 1133 | { |
| 1134 | 1134 | // grab list of installed modules |
| 1135 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1135 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
| 1136 | 1136 | // filter list of modules to register |
| 1137 | 1137 | $modules_to_register = apply_filters( |
| 1138 | 1138 | 'FHEE__EE_Config__register_modules__modules_to_register', |
| 1139 | 1139 | $modules_to_register |
| 1140 | 1140 | ); |
| 1141 | - if (! empty($modules_to_register)) { |
|
| 1141 | + if ( ! empty($modules_to_register)) { |
|
| 1142 | 1142 | // loop through folders |
| 1143 | 1143 | foreach ($modules_to_register as $module_path) { |
| 1144 | 1144 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
| 1145 | 1145 | if ( |
| 1146 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1147 | - && $module_path !== EE_MODULES . 'gateways' |
|
| 1146 | + $module_path !== EE_MODULES.'zzz-copy-this-module-template' |
|
| 1147 | + && $module_path !== EE_MODULES.'gateways' |
|
| 1148 | 1148 | ) { |
| 1149 | 1149 | // add to list of installed modules |
| 1150 | 1150 | EE_Config::register_module($module_path); |
@@ -1182,25 +1182,25 @@ discard block |
||
| 1182 | 1182 | // remove last segment |
| 1183 | 1183 | array_pop($module_path); |
| 1184 | 1184 | // glue it back together |
| 1185 | - $module_path = implode(DS, $module_path) . DS; |
|
| 1185 | + $module_path = implode(DS, $module_path).DS; |
|
| 1186 | 1186 | // take first segment from file name pieces and sanitize it |
| 1187 | 1187 | $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
| 1188 | 1188 | // ensure class prefix is added |
| 1189 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1189 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
| 1190 | 1190 | } else { |
| 1191 | 1191 | // we need to generate the filename based off of the folder name |
| 1192 | 1192 | // grab and sanitize module name |
| 1193 | 1193 | $module = strtolower(basename($module_path)); |
| 1194 | 1194 | $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
| 1195 | 1195 | // like trailingslashit() |
| 1196 | - $module_path = rtrim($module_path, DS) . DS; |
|
| 1196 | + $module_path = rtrim($module_path, DS).DS; |
|
| 1197 | 1197 | // create classname from module directory name |
| 1198 | 1198 | $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
| 1199 | 1199 | // add class prefix |
| 1200 | - $module_class = 'EED_' . $module; |
|
| 1200 | + $module_class = 'EED_'.$module; |
|
| 1201 | 1201 | } |
| 1202 | 1202 | // does the module exist ? |
| 1203 | - if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1203 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
| 1204 | 1204 | $msg = sprintf( |
| 1205 | 1205 | __( |
| 1206 | 1206 | 'The requested %s module file could not be found or is not readable due to file permissions.', |
@@ -1208,19 +1208,19 @@ discard block |
||
| 1208 | 1208 | ), |
| 1209 | 1209 | $module |
| 1210 | 1210 | ); |
| 1211 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1211 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1212 | 1212 | return false; |
| 1213 | 1213 | } |
| 1214 | 1214 | // load the module class file |
| 1215 | - require_once($module_path . $module_class . $module_ext); |
|
| 1215 | + require_once($module_path.$module_class.$module_ext); |
|
| 1216 | 1216 | // verify that class exists |
| 1217 | - if (! class_exists($module_class)) { |
|
| 1217 | + if ( ! class_exists($module_class)) { |
|
| 1218 | 1218 | $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
| 1219 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1219 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1220 | 1220 | return false; |
| 1221 | 1221 | } |
| 1222 | 1222 | // add to array of registered modules |
| 1223 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1223 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
| 1224 | 1224 | do_action( |
| 1225 | 1225 | 'AHEE__EE_Config__register_module__complete', |
| 1226 | 1226 | $module_class, |
@@ -1273,26 +1273,26 @@ discard block |
||
| 1273 | 1273 | { |
| 1274 | 1274 | do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
| 1275 | 1275 | $module = str_replace('EED_', '', $module); |
| 1276 | - $module_class = 'EED_' . $module; |
|
| 1277 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1276 | + $module_class = 'EED_'.$module; |
|
| 1277 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1278 | 1278 | $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
| 1279 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1279 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1280 | 1280 | return false; |
| 1281 | 1281 | } |
| 1282 | 1282 | if (empty($route)) { |
| 1283 | 1283 | $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
| 1284 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1284 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1285 | 1285 | return false; |
| 1286 | 1286 | } |
| 1287 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
| 1287 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
| 1288 | 1288 | $msg = sprintf( |
| 1289 | 1289 | __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
| 1290 | 1290 | $route |
| 1291 | 1291 | ); |
| 1292 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1292 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1293 | 1293 | return false; |
| 1294 | 1294 | } |
| 1295 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1295 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
| 1296 | 1296 | return true; |
| 1297 | 1297 | } |
| 1298 | 1298 | |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | public static function get_route($route = null, $key = 'ee') |
| 1310 | 1310 | { |
| 1311 | 1311 | do_action('AHEE__EE_Config__get_route__begin', $route); |
| 1312 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1312 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1313 | 1313 | if (isset(EE_Config::$_module_route_map[$key][$route])) { |
| 1314 | 1314 | return EE_Config::$_module_route_map[$key][$route]; |
| 1315 | 1315 | } |
@@ -1345,44 +1345,44 @@ discard block |
||
| 1345 | 1345 | public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
| 1346 | 1346 | { |
| 1347 | 1347 | do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
| 1348 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1348 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1349 | 1349 | $msg = sprintf( |
| 1350 | 1350 | __('The module route %s for this forward has not been registered.', 'event_espresso'), |
| 1351 | 1351 | $route |
| 1352 | 1352 | ); |
| 1353 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1353 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1354 | 1354 | return false; |
| 1355 | 1355 | } |
| 1356 | 1356 | if (empty($forward)) { |
| 1357 | 1357 | $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
| 1358 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1358 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1359 | 1359 | return false; |
| 1360 | 1360 | } |
| 1361 | 1361 | if (is_array($forward)) { |
| 1362 | - if (! isset($forward[1])) { |
|
| 1362 | + if ( ! isset($forward[1])) { |
|
| 1363 | 1363 | $msg = sprintf( |
| 1364 | 1364 | __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
| 1365 | 1365 | $route |
| 1366 | 1366 | ); |
| 1367 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1367 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1368 | 1368 | return false; |
| 1369 | 1369 | } |
| 1370 | - if (! method_exists($forward[0], $forward[1])) { |
|
| 1370 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
| 1371 | 1371 | $msg = sprintf( |
| 1372 | 1372 | __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
| 1373 | 1373 | $forward[1], |
| 1374 | 1374 | $route |
| 1375 | 1375 | ); |
| 1376 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1376 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1377 | 1377 | return false; |
| 1378 | 1378 | } |
| 1379 | - } else if (! function_exists($forward)) { |
|
| 1379 | + } else if ( ! function_exists($forward)) { |
|
| 1380 | 1380 | $msg = sprintf( |
| 1381 | 1381 | __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
| 1382 | 1382 | $forward, |
| 1383 | 1383 | $route |
| 1384 | 1384 | ); |
| 1385 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1385 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1386 | 1386 | return false; |
| 1387 | 1387 | } |
| 1388 | 1388 | EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
@@ -1432,15 +1432,15 @@ discard block |
||
| 1432 | 1432 | public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
| 1433 | 1433 | { |
| 1434 | 1434 | do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
| 1435 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1435 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1436 | 1436 | $msg = sprintf( |
| 1437 | 1437 | __('The module route %s for this view has not been registered.', 'event_espresso'), |
| 1438 | 1438 | $route |
| 1439 | 1439 | ); |
| 1440 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1440 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1441 | 1441 | return false; |
| 1442 | 1442 | } |
| 1443 | - if (! is_readable($view)) { |
|
| 1443 | + if ( ! is_readable($view)) { |
|
| 1444 | 1444 | $msg = sprintf( |
| 1445 | 1445 | __( |
| 1446 | 1446 | 'The %s view file could not be found or is not readable due to file permissions.', |
@@ -1448,7 +1448,7 @@ discard block |
||
| 1448 | 1448 | ), |
| 1449 | 1449 | $view |
| 1450 | 1450 | ); |
| 1451 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1451 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1452 | 1452 | return false; |
| 1453 | 1453 | } |
| 1454 | 1454 | EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
@@ -1555,7 +1555,7 @@ discard block |
||
| 1555 | 1555 | */ |
| 1556 | 1556 | public function get_pretty($property) |
| 1557 | 1557 | { |
| 1558 | - if (! property_exists($this, $property)) { |
|
| 1558 | + if ( ! property_exists($this, $property)) { |
|
| 1559 | 1559 | throw new EE_Error( |
| 1560 | 1560 | sprintf( |
| 1561 | 1561 | __( |
@@ -1794,11 +1794,11 @@ discard block |
||
| 1794 | 1794 | */ |
| 1795 | 1795 | public function reg_page_url() |
| 1796 | 1796 | { |
| 1797 | - if (! $this->reg_page_url) { |
|
| 1797 | + if ( ! $this->reg_page_url) { |
|
| 1798 | 1798 | $this->reg_page_url = add_query_arg( |
| 1799 | 1799 | array('uts' => time()), |
| 1800 | 1800 | get_permalink($this->reg_page_id) |
| 1801 | - ) . '#checkout'; |
|
| 1801 | + ).'#checkout'; |
|
| 1802 | 1802 | } |
| 1803 | 1803 | return $this->reg_page_url; |
| 1804 | 1804 | } |
@@ -1815,7 +1815,7 @@ discard block |
||
| 1815 | 1815 | */ |
| 1816 | 1816 | public function txn_page_url($query_args = array()) |
| 1817 | 1817 | { |
| 1818 | - if (! $this->txn_page_url) { |
|
| 1818 | + if ( ! $this->txn_page_url) { |
|
| 1819 | 1819 | $this->txn_page_url = get_permalink($this->txn_page_id); |
| 1820 | 1820 | } |
| 1821 | 1821 | if ($query_args) { |
@@ -1837,7 +1837,7 @@ discard block |
||
| 1837 | 1837 | */ |
| 1838 | 1838 | public function thank_you_page_url($query_args = array()) |
| 1839 | 1839 | { |
| 1840 | - if (! $this->thank_you_page_url) { |
|
| 1840 | + if ( ! $this->thank_you_page_url) { |
|
| 1841 | 1841 | $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
| 1842 | 1842 | } |
| 1843 | 1843 | if ($query_args) { |
@@ -1857,7 +1857,7 @@ discard block |
||
| 1857 | 1857 | */ |
| 1858 | 1858 | public function cancel_page_url() |
| 1859 | 1859 | { |
| 1860 | - if (! $this->cancel_page_url) { |
|
| 1860 | + if ( ! $this->cancel_page_url) { |
|
| 1861 | 1861 | $this->cancel_page_url = get_permalink($this->cancel_page_id); |
| 1862 | 1862 | } |
| 1863 | 1863 | return $this->cancel_page_url; |
@@ -1902,13 +1902,13 @@ discard block |
||
| 1902 | 1902 | $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
| 1903 | 1903 | $option = 'ee_ueip_optin'; |
| 1904 | 1904 | //set correct table for query |
| 1905 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1905 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options'; |
|
| 1906 | 1906 | //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
| 1907 | 1907 | //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
| 1908 | 1908 | //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
| 1909 | 1909 | //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
| 1910 | 1910 | //for the purpose of caching. |
| 1911 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1911 | + $pre = apply_filters('pre_option_'.$option, false, $option); |
|
| 1912 | 1912 | if (false !== $pre) { |
| 1913 | 1913 | EE_Core_Config::$ee_ueip_option = $pre; |
| 1914 | 1914 | return EE_Core_Config::$ee_ueip_option; |
@@ -1918,9 +1918,9 @@ discard block |
||
| 1918 | 1918 | if (is_object($row)) { |
| 1919 | 1919 | $value = $row->option_value; |
| 1920 | 1920 | } else { //option does not exist so use default. |
| 1921 | - return apply_filters('default_option_' . $option, false, $option); |
|
| 1921 | + return apply_filters('default_option_'.$option, false, $option); |
|
| 1922 | 1922 | } |
| 1923 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 1923 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option); |
|
| 1924 | 1924 | return EE_Core_Config::$ee_ueip_option; |
| 1925 | 1925 | } |
| 1926 | 1926 | |
@@ -2197,27 +2197,27 @@ discard block |
||
| 2197 | 2197 | // retrieve the country settings from the db, just in case they have been customized |
| 2198 | 2198 | $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
| 2199 | 2199 | if ($country instanceof EE_Country) { |
| 2200 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2201 | - $this->name = $country->currency_name_single(); // Dollar |
|
| 2202 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2203 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2204 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2205 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2206 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2207 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2200 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2201 | + $this->name = $country->currency_name_single(); // Dollar |
|
| 2202 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2203 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2204 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2205 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2206 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2207 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2208 | 2208 | } |
| 2209 | 2209 | } |
| 2210 | 2210 | // fallback to hardcoded defaults, in case the above failed |
| 2211 | 2211 | if (empty($this->code)) { |
| 2212 | 2212 | // set default currency settings |
| 2213 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2214 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2215 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2216 | - $this->sign = '$'; // currency sign: $ |
|
| 2217 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2218 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2219 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2220 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2213 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2214 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2215 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2216 | + $this->sign = '$'; // currency sign: $ |
|
| 2217 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2218 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2219 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2220 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2221 | 2221 | } |
| 2222 | 2222 | } |
| 2223 | 2223 | } |
@@ -2541,7 +2541,7 @@ discard block |
||
| 2541 | 2541 | public function log_file_name($reset = false) |
| 2542 | 2542 | { |
| 2543 | 2543 | if (empty($this->log_file_name) || $reset) { |
| 2544 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2544 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt'; |
|
| 2545 | 2545 | EE_Config::instance()->update_espresso_config(false, false); |
| 2546 | 2546 | } |
| 2547 | 2547 | return $this->log_file_name; |
@@ -2556,7 +2556,7 @@ discard block |
||
| 2556 | 2556 | public function debug_file_name($reset = false) |
| 2557 | 2557 | { |
| 2558 | 2558 | if (empty($this->debug_file_name) || $reset) { |
| 2559 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2559 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt'; |
|
| 2560 | 2560 | EE_Config::instance()->update_espresso_config(false, false); |
| 2561 | 2561 | } |
| 2562 | 2562 | return $this->debug_file_name; |
@@ -2773,21 +2773,21 @@ discard block |
||
| 2773 | 2773 | $this->use_google_maps = true; |
| 2774 | 2774 | $this->google_map_api_key = ''; |
| 2775 | 2775 | // for event details pages (reg page) |
| 2776 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2777 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2778 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2779 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2780 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2781 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2782 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2776 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2777 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2778 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2779 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2780 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2781 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2782 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2783 | 2783 | // for event list pages |
| 2784 | - $this->event_list_map_width = 300; // ee_map_width |
|
| 2785 | - $this->event_list_map_height = 185; // ee_map_height |
|
| 2786 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2787 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2788 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2789 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2790 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2784 | + $this->event_list_map_width = 300; // ee_map_width |
|
| 2785 | + $this->event_list_map_height = 185; // ee_map_height |
|
| 2786 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2787 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2788 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2789 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2790 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2791 | 2791 | } |
| 2792 | 2792 | |
| 2793 | 2793 | } |
@@ -3102,7 +3102,7 @@ discard block |
||
| 3102 | 3102 | */ |
| 3103 | 3103 | public function max_input_vars_limit_check($input_count = 0) |
| 3104 | 3104 | { |
| 3105 | - if (! empty($this->php->max_input_vars) |
|
| 3105 | + if ( ! empty($this->php->max_input_vars) |
|
| 3106 | 3106 | && ($input_count >= $this->php->max_input_vars) |
| 3107 | 3107 | && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
| 3108 | 3108 | ) { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\services\shortcodes\LegacyShortcodesManager; |
| 2 | 2 | |
| 3 | 3 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('No direct script access allowed'); |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -16,2443 +16,2443 @@ discard block |
||
| 16 | 16 | final class EE_Config |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - const OPTION_NAME = 'ee_config'; |
|
| 19 | + const OPTION_NAME = 'ee_config'; |
|
| 20 | + |
|
| 21 | + const LOG_NAME = 'ee_config_log'; |
|
| 22 | + |
|
| 23 | + const LOG_LENGTH = 100; |
|
| 24 | + |
|
| 25 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * instance of the EE_Config object |
|
| 30 | + * |
|
| 31 | + * @var EE_Config $_instance |
|
| 32 | + * @access private |
|
| 33 | + */ |
|
| 34 | + private static $_instance; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var boolean $_logging_enabled |
|
| 38 | + */ |
|
| 39 | + private static $_logging_enabled = false; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 43 | + */ |
|
| 44 | + private $legacy_shortcodes_manager; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * An StdClass whose property names are addon slugs, |
|
| 48 | + * and values are their config classes |
|
| 49 | + * |
|
| 50 | + * @var StdClass |
|
| 51 | + */ |
|
| 52 | + public $addons; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var EE_Admin_Config |
|
| 56 | + */ |
|
| 57 | + public $admin; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var EE_Core_Config |
|
| 61 | + */ |
|
| 62 | + public $core; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @var EE_Currency_Config |
|
| 66 | + */ |
|
| 67 | + public $currency; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @var EE_Organization_Config |
|
| 71 | + */ |
|
| 72 | + public $organization; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @var EE_Registration_Config |
|
| 76 | + */ |
|
| 77 | + public $registration; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @var EE_Template_Config |
|
| 81 | + */ |
|
| 82 | + public $template_settings; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Holds EE environment values. |
|
| 86 | + * |
|
| 87 | + * @var EE_Environment_Config |
|
| 88 | + */ |
|
| 89 | + public $environment; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * settings pertaining to Google maps |
|
| 93 | + * |
|
| 94 | + * @var EE_Map_Config |
|
| 95 | + */ |
|
| 96 | + public $map_settings; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * settings pertaining to Taxes |
|
| 100 | + * |
|
| 101 | + * @var EE_Tax_Config |
|
| 102 | + */ |
|
| 103 | + public $tax_settings; |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Settings pertaining to global messages settings. |
|
| 108 | + * |
|
| 109 | + * @var EE_Messages_Config |
|
| 110 | + */ |
|
| 111 | + public $messages; |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @deprecated |
|
| 115 | + * @var EE_Gateway_Config |
|
| 116 | + */ |
|
| 117 | + public $gateway; |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @var array $_addon_option_names |
|
| 121 | + * @access private |
|
| 122 | + */ |
|
| 123 | + private $_addon_option_names = array(); |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @var array $_module_route_map |
|
| 127 | + * @access private |
|
| 128 | + */ |
|
| 129 | + private static $_module_route_map = array(); |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @var array $_module_forward_map |
|
| 133 | + * @access private |
|
| 134 | + */ |
|
| 135 | + private static $_module_forward_map = array(); |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @var array $_module_view_map |
|
| 139 | + * @access private |
|
| 140 | + */ |
|
| 141 | + private static $_module_view_map = array(); |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * @singleton method used to instantiate class object |
|
| 147 | + * @access public |
|
| 148 | + * @return EE_Config instance |
|
| 149 | + */ |
|
| 150 | + public static function instance() |
|
| 151 | + { |
|
| 152 | + // check if class object is instantiated, and instantiated properly |
|
| 153 | + if (! self::$_instance instanceof EE_Config) { |
|
| 154 | + self::$_instance = new self(); |
|
| 155 | + } |
|
| 156 | + return self::$_instance; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Resets the config |
|
| 163 | + * |
|
| 164 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 165 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 166 | + * reflect its state in the database |
|
| 167 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 168 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 169 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 170 | + * site was put into maintenance mode) |
|
| 171 | + * @return EE_Config |
|
| 172 | + */ |
|
| 173 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 174 | + { |
|
| 175 | + if (self::$_instance instanceof EE_Config) { |
|
| 176 | + if ($hard_reset) { |
|
| 177 | + self::$_instance->legacy_shortcodes_manager = null; |
|
| 178 | + self::$_instance->_addon_option_names = array(); |
|
| 179 | + self::$_instance->_initialize_config(); |
|
| 180 | + self::$_instance->update_espresso_config(); |
|
| 181 | + } |
|
| 182 | + self::$_instance->update_addon_option_names(); |
|
| 183 | + } |
|
| 184 | + self::$_instance = null; |
|
| 185 | + //we don't need to reset the static properties imo because those should |
|
| 186 | + //only change when a module is added or removed. Currently we don't |
|
| 187 | + //support removing a module during a request when it previously existed |
|
| 188 | + if ($reinstantiate) { |
|
| 189 | + return self::instance(); |
|
| 190 | + } else { |
|
| 191 | + return null; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * class constructor |
|
| 199 | + * |
|
| 200 | + * @access private |
|
| 201 | + */ |
|
| 202 | + private function __construct() |
|
| 203 | + { |
|
| 204 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 205 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 206 | + // setup empty config classes |
|
| 207 | + $this->_initialize_config(); |
|
| 208 | + // load existing EE site settings |
|
| 209 | + $this->_load_core_config(); |
|
| 210 | + // confirm everything loaded correctly and set filtered defaults if not |
|
| 211 | + $this->_verify_config(); |
|
| 212 | + // register shortcodes and modules |
|
| 213 | + add_action( |
|
| 214 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 215 | + array($this, 'register_shortcodes_and_modules'), |
|
| 216 | + 999 |
|
| 217 | + ); |
|
| 218 | + // initialize shortcodes and modules |
|
| 219 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 220 | + // register widgets |
|
| 221 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 222 | + // shutdown |
|
| 223 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 224 | + // construct__end hook |
|
| 225 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
| 226 | + // hardcoded hack |
|
| 227 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * @return boolean |
|
| 234 | + */ |
|
| 235 | + public static function logging_enabled() |
|
| 236 | + { |
|
| 237 | + return self::$_logging_enabled; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * use to get the current theme if needed from static context |
|
| 244 | + * |
|
| 245 | + * @return string current theme set. |
|
| 246 | + */ |
|
| 247 | + public static function get_current_theme() |
|
| 248 | + { |
|
| 249 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 250 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * _initialize_config |
|
| 257 | + * |
|
| 258 | + * @access private |
|
| 259 | + * @return void |
|
| 260 | + */ |
|
| 261 | + private function _initialize_config() |
|
| 262 | + { |
|
| 263 | + EE_Config::trim_log(); |
|
| 264 | + //set defaults |
|
| 265 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 266 | + $this->addons = new stdClass(); |
|
| 267 | + // set _module_route_map |
|
| 268 | + EE_Config::$_module_route_map = array(); |
|
| 269 | + // set _module_forward_map |
|
| 270 | + EE_Config::$_module_forward_map = array(); |
|
| 271 | + // set _module_view_map |
|
| 272 | + EE_Config::$_module_view_map = array(); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * load core plugin configuration |
|
| 279 | + * |
|
| 280 | + * @access private |
|
| 281 | + * @return void |
|
| 282 | + */ |
|
| 283 | + private function _load_core_config() |
|
| 284 | + { |
|
| 285 | + // load_core_config__start hook |
|
| 286 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 287 | + $espresso_config = $this->get_espresso_config(); |
|
| 288 | + foreach ($espresso_config as $config => $settings) { |
|
| 289 | + // load_core_config__start hook |
|
| 290 | + $settings = apply_filters( |
|
| 291 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 292 | + $settings, |
|
| 293 | + $config, |
|
| 294 | + $this |
|
| 295 | + ); |
|
| 296 | + if (is_object($settings) && property_exists($this, $config)) { |
|
| 297 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 298 | + //call configs populate method to ensure any defaults are set for empty values. |
|
| 299 | + if (method_exists($settings, 'populate')) { |
|
| 300 | + $this->{$config}->populate(); |
|
| 301 | + } |
|
| 302 | + if (method_exists($settings, 'do_hooks')) { |
|
| 303 | + $this->{$config}->do_hooks(); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 308 | + $this->update_espresso_config(); |
|
| 309 | + } |
|
| 310 | + // load_core_config__end hook |
|
| 311 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + |
|
| 316 | + /** |
|
| 317 | + * _verify_config |
|
| 318 | + * |
|
| 319 | + * @access protected |
|
| 320 | + * @return void |
|
| 321 | + */ |
|
| 322 | + protected function _verify_config() |
|
| 323 | + { |
|
| 324 | + $this->core = $this->core instanceof EE_Core_Config |
|
| 325 | + ? $this->core |
|
| 326 | + : new EE_Core_Config(); |
|
| 327 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 328 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 329 | + ? $this->organization |
|
| 330 | + : new EE_Organization_Config(); |
|
| 331 | + $this->organization = apply_filters( |
|
| 332 | + 'FHEE__EE_Config___initialize_config__organization', |
|
| 333 | + $this->organization |
|
| 334 | + ); |
|
| 335 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 336 | + ? $this->currency |
|
| 337 | + : new EE_Currency_Config(); |
|
| 338 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 339 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 340 | + ? $this->registration |
|
| 341 | + : new EE_Registration_Config(); |
|
| 342 | + $this->registration = apply_filters( |
|
| 343 | + 'FHEE__EE_Config___initialize_config__registration', |
|
| 344 | + $this->registration |
|
| 345 | + ); |
|
| 346 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 347 | + ? $this->admin |
|
| 348 | + : new EE_Admin_Config(); |
|
| 349 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 350 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 351 | + ? $this->template_settings |
|
| 352 | + : new EE_Template_Config(); |
|
| 353 | + $this->template_settings = apply_filters( |
|
| 354 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 355 | + $this->template_settings |
|
| 356 | + ); |
|
| 357 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 358 | + ? $this->map_settings |
|
| 359 | + : new EE_Map_Config(); |
|
| 360 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
| 361 | + $this->map_settings); |
|
| 362 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 363 | + ? $this->environment |
|
| 364 | + : new EE_Environment_Config(); |
|
| 365 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
| 366 | + $this->environment); |
|
| 367 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 368 | + ? $this->tax_settings |
|
| 369 | + : new EE_Tax_Config(); |
|
| 370 | + $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
| 371 | + $this->tax_settings); |
|
| 372 | + $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
| 373 | + $this->messages = $this->messages instanceof EE_Messages_Config |
|
| 374 | + ? $this->messages |
|
| 375 | + : new EE_Messages_Config(); |
|
| 376 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 377 | + ? $this->gateway |
|
| 378 | + : new EE_Gateway_Config(); |
|
| 379 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 380 | + $this->legacy_shortcodes_manager = null; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + |
|
| 384 | + /** |
|
| 385 | + * get_espresso_config |
|
| 386 | + * |
|
| 387 | + * @access public |
|
| 388 | + * @return array of espresso config stuff |
|
| 389 | + */ |
|
| 390 | + public function get_espresso_config() |
|
| 391 | + { |
|
| 392 | + // grab espresso configuration |
|
| 393 | + return apply_filters( |
|
| 394 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 395 | + get_option(EE_Config::OPTION_NAME, array()) |
|
| 396 | + ); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + /** |
|
| 402 | + * double_check_config_comparison |
|
| 403 | + * |
|
| 404 | + * @access public |
|
| 405 | + * @param string $option |
|
| 406 | + * @param $old_value |
|
| 407 | + * @param $value |
|
| 408 | + */ |
|
| 409 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 410 | + { |
|
| 411 | + // make sure we're checking the ee config |
|
| 412 | + if ($option === EE_Config::OPTION_NAME) { |
|
| 413 | + // run a loose comparison of the old value against the new value for type and properties, |
|
| 414 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 415 | + if ($value != $old_value) { |
|
| 416 | + // if they are NOT the same, then remove the hook, |
|
| 417 | + // which means the subsequent update results will be based solely on the update query results |
|
| 418 | + // the reason we do this is because, as stated above, |
|
| 419 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 420 | + // this happens PRIOR to serialization and any subsequent update. |
|
| 421 | + // If values are found to match their previous old value, |
|
| 422 | + // then WP bails before performing any update. |
|
| 423 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 424 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 425 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 426 | + // MySQL MAY ALSO NOT perform the update because |
|
| 427 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 428 | + // This results in the query returning an "affected rows" value of ZERO, |
|
| 429 | + // which gets returned immediately by WP update_option and looks like an error. |
|
| 430 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * update_espresso_config |
|
| 439 | + * |
|
| 440 | + * @access public |
|
| 441 | + */ |
|
| 442 | + protected function _reset_espresso_addon_config() |
|
| 443 | + { |
|
| 444 | + $this->_addon_option_names = array(); |
|
| 445 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 446 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 447 | + $config_class = get_class($addon_config_obj); |
|
| 448 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
| 449 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 450 | + } |
|
| 451 | + $this->addons->{$addon_name} = null; |
|
| 452 | + } |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * update_espresso_config |
|
| 459 | + * |
|
| 460 | + * @access public |
|
| 461 | + * @param bool $add_success |
|
| 462 | + * @param bool $add_error |
|
| 463 | + * @return bool |
|
| 464 | + */ |
|
| 465 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
| 466 | + { |
|
| 467 | + // don't allow config updates during WP heartbeats |
|
| 468 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 469 | + return false; |
|
| 470 | + } |
|
| 471 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 472 | + //$clone = clone( self::$_instance ); |
|
| 473 | + //self::$_instance = NULL; |
|
| 474 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 475 | + $this->_reset_espresso_addon_config(); |
|
| 476 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 477 | + // but BEFORE the actual update occurs |
|
| 478 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 479 | + // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
| 480 | + $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
| 481 | + $this->legacy_shortcodes_manager = null; |
|
| 482 | + // now update "ee_config" |
|
| 483 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 484 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 485 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
| 486 | + // if not saved... check if the hook we just added still exists; |
|
| 487 | + // if it does, it means one of two things: |
|
| 488 | + // that update_option bailed at the ( $value === $old_value ) conditional, |
|
| 489 | + // or... |
|
| 490 | + // the db update query returned 0 rows affected |
|
| 491 | + // (probably because the data value was the same from it's perspective) |
|
| 492 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 493 | + // but just means no update occurred, so don't display an error to the user. |
|
| 494 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 495 | + // then it means that something truly went wrong |
|
| 496 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 497 | + // remove our action since we don't want it in the system anymore |
|
| 498 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 499 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 500 | + //self::$_instance = $clone; |
|
| 501 | + //unset( $clone ); |
|
| 502 | + // if config remains the same or was updated successfully |
|
| 503 | + if ($saved) { |
|
| 504 | + if ($add_success) { |
|
| 505 | + EE_Error::add_success( |
|
| 506 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 507 | + __FILE__, |
|
| 508 | + __FUNCTION__, |
|
| 509 | + __LINE__ |
|
| 510 | + ); |
|
| 511 | + } |
|
| 512 | + return true; |
|
| 513 | + } else { |
|
| 514 | + if ($add_error) { |
|
| 515 | + EE_Error::add_error( |
|
| 516 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 517 | + __FILE__, |
|
| 518 | + __FUNCTION__, |
|
| 519 | + __LINE__ |
|
| 520 | + ); |
|
| 521 | + } |
|
| 522 | + return false; |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * _verify_config_params |
|
| 530 | + * |
|
| 531 | + * @access private |
|
| 532 | + * @param string $section |
|
| 533 | + * @param string $name |
|
| 534 | + * @param string $config_class |
|
| 535 | + * @param EE_Config_Base $config_obj |
|
| 536 | + * @param array $tests_to_run |
|
| 537 | + * @param bool $display_errors |
|
| 538 | + * @return bool TRUE on success, FALSE on fail |
|
| 539 | + */ |
|
| 540 | + private function _verify_config_params( |
|
| 541 | + $section = '', |
|
| 542 | + $name = '', |
|
| 543 | + $config_class = '', |
|
| 544 | + $config_obj = null, |
|
| 545 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 546 | + $display_errors = true |
|
| 547 | + ) { |
|
| 548 | + try { |
|
| 549 | + foreach ($tests_to_run as $test) { |
|
| 550 | + switch ($test) { |
|
| 551 | + // TEST #1 : check that section was set |
|
| 552 | + case 1 : |
|
| 553 | + if (empty($section)) { |
|
| 554 | + if ($display_errors) { |
|
| 555 | + throw new EE_Error( |
|
| 556 | + sprintf( |
|
| 557 | + __( |
|
| 558 | + 'No configuration section has been provided while attempting to save "%s".', |
|
| 559 | + 'event_espresso' |
|
| 560 | + ), |
|
| 561 | + $config_class |
|
| 562 | + ) |
|
| 563 | + ); |
|
| 564 | + } |
|
| 565 | + return false; |
|
| 566 | + } |
|
| 567 | + break; |
|
| 568 | + // TEST #2 : check that settings section exists |
|
| 569 | + case 2 : |
|
| 570 | + if (! isset($this->{$section})) { |
|
| 571 | + if ($display_errors) { |
|
| 572 | + throw new EE_Error( |
|
| 573 | + sprintf( |
|
| 574 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 575 | + $section |
|
| 576 | + ) |
|
| 577 | + ); |
|
| 578 | + } |
|
| 579 | + return false; |
|
| 580 | + } |
|
| 581 | + break; |
|
| 582 | + // TEST #3 : check that section is the proper format |
|
| 583 | + case 3 : |
|
| 584 | + if ( |
|
| 585 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 586 | + ) { |
|
| 587 | + if ($display_errors) { |
|
| 588 | + throw new EE_Error( |
|
| 589 | + sprintf( |
|
| 590 | + __( |
|
| 591 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
| 592 | + 'event_espresso' |
|
| 593 | + ), |
|
| 594 | + $section |
|
| 595 | + ) |
|
| 596 | + ); |
|
| 597 | + } |
|
| 598 | + return false; |
|
| 599 | + } |
|
| 600 | + break; |
|
| 601 | + // TEST #4 : check that config section name has been set |
|
| 602 | + case 4 : |
|
| 603 | + if (empty($name)) { |
|
| 604 | + if ($display_errors) { |
|
| 605 | + throw new EE_Error( |
|
| 606 | + __( |
|
| 607 | + 'No name has been provided for the specific configuration section.', |
|
| 608 | + 'event_espresso' |
|
| 609 | + ) |
|
| 610 | + ); |
|
| 611 | + } |
|
| 612 | + return false; |
|
| 613 | + } |
|
| 614 | + break; |
|
| 615 | + // TEST #5 : check that a config class name has been set |
|
| 616 | + case 5 : |
|
| 617 | + if (empty($config_class)) { |
|
| 618 | + if ($display_errors) { |
|
| 619 | + throw new EE_Error( |
|
| 620 | + __( |
|
| 621 | + 'No class name has been provided for the specific configuration section.', |
|
| 622 | + 'event_espresso' |
|
| 623 | + ) |
|
| 624 | + ); |
|
| 625 | + } |
|
| 626 | + return false; |
|
| 627 | + } |
|
| 628 | + break; |
|
| 629 | + // TEST #6 : verify config class is accessible |
|
| 630 | + case 6 : |
|
| 631 | + if (! class_exists($config_class)) { |
|
| 632 | + if ($display_errors) { |
|
| 633 | + throw new EE_Error( |
|
| 634 | + sprintf( |
|
| 635 | + __( |
|
| 636 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 637 | + 'event_espresso' |
|
| 638 | + ), |
|
| 639 | + $config_class |
|
| 640 | + ) |
|
| 641 | + ); |
|
| 642 | + } |
|
| 643 | + return false; |
|
| 644 | + } |
|
| 645 | + break; |
|
| 646 | + // TEST #7 : check that config has even been set |
|
| 647 | + case 7 : |
|
| 648 | + if (! isset($this->{$section}->{$name})) { |
|
| 649 | + if ($display_errors) { |
|
| 650 | + throw new EE_Error( |
|
| 651 | + sprintf( |
|
| 652 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 653 | + $section, |
|
| 654 | + $name |
|
| 655 | + ) |
|
| 656 | + ); |
|
| 657 | + } |
|
| 658 | + return false; |
|
| 659 | + } else { |
|
| 660 | + // and make sure it's not serialized |
|
| 661 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 662 | + } |
|
| 663 | + break; |
|
| 664 | + // TEST #8 : check that config is the requested type |
|
| 665 | + case 8 : |
|
| 666 | + if (! $this->{$section}->{$name} instanceof $config_class) { |
|
| 667 | + if ($display_errors) { |
|
| 668 | + throw new EE_Error( |
|
| 669 | + sprintf( |
|
| 670 | + __( |
|
| 671 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 672 | + 'event_espresso' |
|
| 673 | + ), |
|
| 674 | + $section, |
|
| 675 | + $name, |
|
| 676 | + $config_class |
|
| 677 | + ) |
|
| 678 | + ); |
|
| 679 | + } |
|
| 680 | + return false; |
|
| 681 | + } |
|
| 682 | + break; |
|
| 683 | + // TEST #9 : verify config object |
|
| 684 | + case 9 : |
|
| 685 | + if (! $config_obj instanceof EE_Config_Base) { |
|
| 686 | + if ($display_errors) { |
|
| 687 | + throw new EE_Error( |
|
| 688 | + sprintf( |
|
| 689 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 690 | + print_r($config_obj, true) |
|
| 691 | + ) |
|
| 692 | + ); |
|
| 693 | + } |
|
| 694 | + return false; |
|
| 695 | + } |
|
| 696 | + break; |
|
| 697 | + } |
|
| 698 | + } |
|
| 699 | + } catch (EE_Error $e) { |
|
| 700 | + $e->get_error(); |
|
| 701 | + } |
|
| 702 | + // you have successfully run the gauntlet |
|
| 703 | + return true; |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + |
|
| 707 | + |
|
| 708 | + /** |
|
| 709 | + * _generate_config_option_name |
|
| 710 | + * |
|
| 711 | + * @access protected |
|
| 712 | + * @param string $section |
|
| 713 | + * @param string $name |
|
| 714 | + * @return string |
|
| 715 | + */ |
|
| 716 | + private function _generate_config_option_name($section = '', $name = '') |
|
| 717 | + { |
|
| 718 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 719 | + } |
|
| 720 | + |
|
| 721 | + |
|
| 722 | + |
|
| 723 | + /** |
|
| 724 | + * _set_config_class |
|
| 725 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 726 | + * |
|
| 727 | + * @access private |
|
| 728 | + * @param string $config_class |
|
| 729 | + * @param string $name |
|
| 730 | + * @return string |
|
| 731 | + */ |
|
| 732 | + private function _set_config_class($config_class = '', $name = '') |
|
| 733 | + { |
|
| 734 | + return ! empty($config_class) |
|
| 735 | + ? $config_class |
|
| 736 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + |
|
| 740 | + |
|
| 741 | + /** |
|
| 742 | + * set_config |
|
| 743 | + * |
|
| 744 | + * @access protected |
|
| 745 | + * @param string $section |
|
| 746 | + * @param string $name |
|
| 747 | + * @param string $config_class |
|
| 748 | + * @param EE_Config_Base $config_obj |
|
| 749 | + * @return EE_Config_Base |
|
| 750 | + */ |
|
| 751 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 752 | + { |
|
| 753 | + // ensure config class is set to something |
|
| 754 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 755 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 756 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 757 | + return null; |
|
| 758 | + } |
|
| 759 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 760 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 761 | + if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 762 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
| 763 | + $this->update_addon_option_names(); |
|
| 764 | + } |
|
| 765 | + // verify the incoming config object but suppress errors |
|
| 766 | + if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 767 | + $config_obj = new $config_class(); |
|
| 768 | + } |
|
| 769 | + if (get_option($config_option_name)) { |
|
| 770 | + EE_Config::log($config_option_name); |
|
| 771 | + update_option($config_option_name, $config_obj); |
|
| 772 | + $this->{$section}->{$name} = $config_obj; |
|
| 773 | + return $this->{$section}->{$name}; |
|
| 774 | + } else { |
|
| 775 | + // create a wp-option for this config |
|
| 776 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 777 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 778 | + return $this->{$section}->{$name}; |
|
| 779 | + } else { |
|
| 780 | + EE_Error::add_error( |
|
| 781 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 782 | + __FILE__, |
|
| 783 | + __FUNCTION__, |
|
| 784 | + __LINE__ |
|
| 785 | + ); |
|
| 786 | + return null; |
|
| 787 | + } |
|
| 788 | + } |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + |
|
| 792 | + |
|
| 793 | + /** |
|
| 794 | + * update_config |
|
| 795 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 796 | + * |
|
| 797 | + * @access public |
|
| 798 | + * @param string $section |
|
| 799 | + * @param string $name |
|
| 800 | + * @param EE_Config_Base|string $config_obj |
|
| 801 | + * @param bool $throw_errors |
|
| 802 | + * @return bool |
|
| 803 | + */ |
|
| 804 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 805 | + { |
|
| 806 | + // don't allow config updates during WP heartbeats |
|
| 807 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 808 | + return false; |
|
| 809 | + } |
|
| 810 | + $config_obj = maybe_unserialize($config_obj); |
|
| 811 | + // get class name of the incoming object |
|
| 812 | + $config_class = get_class($config_obj); |
|
| 813 | + // run tests 1-5 and 9 to verify config |
|
| 814 | + if (! $this->_verify_config_params( |
|
| 815 | + $section, |
|
| 816 | + $name, |
|
| 817 | + $config_class, |
|
| 818 | + $config_obj, |
|
| 819 | + array(1, 2, 3, 4, 7, 9) |
|
| 820 | + ) |
|
| 821 | + ) { |
|
| 822 | + return false; |
|
| 823 | + } |
|
| 824 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 825 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 826 | + if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 827 | + // save new config to db |
|
| 828 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 829 | + return true; |
|
| 830 | + } |
|
| 831 | + } else { |
|
| 832 | + // first check if the record already exists |
|
| 833 | + $existing_config = get_option($config_option_name); |
|
| 834 | + $config_obj = serialize($config_obj); |
|
| 835 | + // just return if db record is already up to date (NOT type safe comparison) |
|
| 836 | + if ($existing_config == $config_obj) { |
|
| 837 | + $this->{$section}->{$name} = $config_obj; |
|
| 838 | + return true; |
|
| 839 | + } else if (update_option($config_option_name, $config_obj)) { |
|
| 840 | + EE_Config::log($config_option_name); |
|
| 841 | + // update wp-option for this config class |
|
| 842 | + $this->{$section}->{$name} = $config_obj; |
|
| 843 | + return true; |
|
| 844 | + } elseif ($throw_errors) { |
|
| 845 | + EE_Error::add_error( |
|
| 846 | + sprintf( |
|
| 847 | + __( |
|
| 848 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 849 | + 'event_espresso' |
|
| 850 | + ), |
|
| 851 | + $config_class, |
|
| 852 | + 'EE_Config->' . $section . '->' . $name |
|
| 853 | + ), |
|
| 854 | + __FILE__, |
|
| 855 | + __FUNCTION__, |
|
| 856 | + __LINE__ |
|
| 857 | + ); |
|
| 858 | + } |
|
| 859 | + } |
|
| 860 | + return false; |
|
| 861 | + } |
|
| 862 | + |
|
| 863 | + |
|
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * get_config |
|
| 867 | + * |
|
| 868 | + * @access public |
|
| 869 | + * @param string $section |
|
| 870 | + * @param string $name |
|
| 871 | + * @param string $config_class |
|
| 872 | + * @return mixed EE_Config_Base | NULL |
|
| 873 | + */ |
|
| 874 | + public function get_config($section = '', $name = '', $config_class = '') |
|
| 875 | + { |
|
| 876 | + // ensure config class is set to something |
|
| 877 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 878 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 879 | + if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 880 | + return null; |
|
| 881 | + } |
|
| 882 | + // now test if the requested config object exists, but suppress errors |
|
| 883 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 884 | + // config already exists, so pass it back |
|
| 885 | + return $this->{$section}->{$name}; |
|
| 886 | + } |
|
| 887 | + // load config option from db if it exists |
|
| 888 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 889 | + // verify the newly retrieved config object, but suppress errors |
|
| 890 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 891 | + // config is good, so set it and pass it back |
|
| 892 | + $this->{$section}->{$name} = $config_obj; |
|
| 893 | + return $this->{$section}->{$name}; |
|
| 894 | + } |
|
| 895 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 896 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
| 897 | + // verify the newly created config object |
|
| 898 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 899 | + return $this->{$section}->{$name}; |
|
| 900 | + } else { |
|
| 901 | + EE_Error::add_error( |
|
| 902 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 903 | + __FILE__, |
|
| 904 | + __FUNCTION__, |
|
| 905 | + __LINE__ |
|
| 906 | + ); |
|
| 907 | + } |
|
| 908 | + return null; |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + |
|
| 912 | + |
|
| 913 | + /** |
|
| 914 | + * get_config_option |
|
| 915 | + * |
|
| 916 | + * @access public |
|
| 917 | + * @param string $config_option_name |
|
| 918 | + * @return mixed EE_Config_Base | FALSE |
|
| 919 | + */ |
|
| 920 | + public function get_config_option($config_option_name = '') |
|
| 921 | + { |
|
| 922 | + // retrieve the wp-option for this config class. |
|
| 923 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 924 | + if (empty($config_option)) { |
|
| 925 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 926 | + } |
|
| 927 | + return $config_option; |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + |
|
| 931 | + |
|
| 932 | + /** |
|
| 933 | + * log |
|
| 934 | + * |
|
| 935 | + * @param string $config_option_name |
|
| 936 | + */ |
|
| 937 | + public static function log($config_option_name = '') |
|
| 938 | + { |
|
| 939 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 940 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 941 | + //copy incoming $_REQUEST and sanitize it so we can save it |
|
| 942 | + $_request = $_REQUEST; |
|
| 943 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 944 | + $config_log[(string)microtime(true)] = array( |
|
| 945 | + 'config_name' => $config_option_name, |
|
| 946 | + 'request' => $_request, |
|
| 947 | + ); |
|
| 948 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 949 | + } |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + |
|
| 953 | + |
|
| 954 | + /** |
|
| 955 | + * trim_log |
|
| 956 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 957 | + */ |
|
| 958 | + public static function trim_log() |
|
| 959 | + { |
|
| 960 | + if (! EE_Config::logging_enabled()) { |
|
| 961 | + return; |
|
| 962 | + } |
|
| 963 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 964 | + $log_length = count($config_log); |
|
| 965 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 966 | + ksort($config_log); |
|
| 967 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 968 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 969 | + } |
|
| 970 | + } |
|
| 971 | + |
|
| 972 | + |
|
| 973 | + |
|
| 974 | + /** |
|
| 975 | + * get_page_for_posts |
|
| 976 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 977 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 978 | + * |
|
| 979 | + * @access public |
|
| 980 | + * @return string |
|
| 981 | + */ |
|
| 982 | + public static function get_page_for_posts() |
|
| 983 | + { |
|
| 984 | + $page_for_posts = get_option('page_for_posts'); |
|
| 985 | + if (! $page_for_posts) { |
|
| 986 | + return 'posts'; |
|
| 987 | + } |
|
| 988 | + /** @type WPDB $wpdb */ |
|
| 989 | + global $wpdb; |
|
| 990 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 991 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 992 | + } |
|
| 993 | + |
|
| 994 | + |
|
| 995 | + |
|
| 996 | + /** |
|
| 997 | + * register_shortcodes_and_modules. |
|
| 998 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 999 | + * In fact, this is where we give modules a chance to let core know they exist |
|
| 1000 | + * so they can help trigger maintenance mode if it's needed |
|
| 1001 | + * |
|
| 1002 | + * @access public |
|
| 1003 | + * @return void |
|
| 1004 | + */ |
|
| 1005 | + public function register_shortcodes_and_modules() |
|
| 1006 | + { |
|
| 1007 | + // allow modules to set hooks for the rest of the system |
|
| 1008 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + |
|
| 1012 | + |
|
| 1013 | + /** |
|
| 1014 | + * initialize_shortcodes_and_modules |
|
| 1015 | + * meaning they can start adding their hooks to get stuff done |
|
| 1016 | + * |
|
| 1017 | + * @access public |
|
| 1018 | + * @return void |
|
| 1019 | + */ |
|
| 1020 | + public function initialize_shortcodes_and_modules() |
|
| 1021 | + { |
|
| 1022 | + // allow modules to set hooks for the rest of the system |
|
| 1023 | + $this->_initialize_modules(); |
|
| 1024 | + } |
|
| 1025 | + |
|
| 1026 | + |
|
| 1027 | + |
|
| 1028 | + /** |
|
| 1029 | + * widgets_init |
|
| 1030 | + * |
|
| 1031 | + * @access private |
|
| 1032 | + * @return void |
|
| 1033 | + */ |
|
| 1034 | + public function widgets_init() |
|
| 1035 | + { |
|
| 1036 | + //only init widgets on admin pages when not in complete maintenance, and |
|
| 1037 | + //on frontend when not in any maintenance mode |
|
| 1038 | + if ( |
|
| 1039 | + ! EE_Maintenance_Mode::instance()->level() |
|
| 1040 | + || ( |
|
| 1041 | + is_admin() |
|
| 1042 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1043 | + ) |
|
| 1044 | + ) { |
|
| 1045 | + // grab list of installed widgets |
|
| 1046 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1047 | + // filter list of modules to register |
|
| 1048 | + $widgets_to_register = apply_filters( |
|
| 1049 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1050 | + $widgets_to_register |
|
| 1051 | + ); |
|
| 1052 | + if (! empty($widgets_to_register)) { |
|
| 1053 | + // cycle thru widget folders |
|
| 1054 | + foreach ($widgets_to_register as $widget_path) { |
|
| 1055 | + // add to list of installed widget modules |
|
| 1056 | + EE_Config::register_ee_widget($widget_path); |
|
| 1057 | + } |
|
| 1058 | + } |
|
| 1059 | + // filter list of installed modules |
|
| 1060 | + EE_Registry::instance()->widgets = apply_filters( |
|
| 1061 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1062 | + EE_Registry::instance()->widgets |
|
| 1063 | + ); |
|
| 1064 | + } |
|
| 1065 | + } |
|
| 1066 | + |
|
| 1067 | + |
|
| 1068 | + |
|
| 1069 | + /** |
|
| 1070 | + * register_ee_widget - makes core aware of this widget |
|
| 1071 | + * |
|
| 1072 | + * @access public |
|
| 1073 | + * @param string $widget_path - full path up to and including widget folder |
|
| 1074 | + * @return void |
|
| 1075 | + */ |
|
| 1076 | + public static function register_ee_widget($widget_path = null) |
|
| 1077 | + { |
|
| 1078 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1079 | + $widget_ext = '.widget.php'; |
|
| 1080 | + // make all separators match |
|
| 1081 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
| 1082 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1083 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1084 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1085 | + $file_name = explode('.', basename($widget_path)); |
|
| 1086 | + // take first segment from file name pieces and remove class prefix if it exists |
|
| 1087 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1088 | + // sanitize shortcode directory name |
|
| 1089 | + $widget = sanitize_key($widget); |
|
| 1090 | + // now we need to rebuild the shortcode path |
|
| 1091 | + $widget_path = explode(DS, $widget_path); |
|
| 1092 | + // remove last segment |
|
| 1093 | + array_pop($widget_path); |
|
| 1094 | + // glue it back together |
|
| 1095 | + $widget_path = implode(DS, $widget_path); |
|
| 1096 | + } else { |
|
| 1097 | + // grab and sanitize widget directory name |
|
| 1098 | + $widget = sanitize_key(basename($widget_path)); |
|
| 1099 | + } |
|
| 1100 | + // create classname from widget directory name |
|
| 1101 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1102 | + // add class prefix |
|
| 1103 | + $widget_class = 'EEW_' . $widget; |
|
| 1104 | + // does the widget exist ? |
|
| 1105 | + if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1106 | + $msg = sprintf( |
|
| 1107 | + __( |
|
| 1108 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1109 | + 'event_espresso' |
|
| 1110 | + ), |
|
| 1111 | + $widget_class, |
|
| 1112 | + $widget_path . DS . $widget_class . $widget_ext |
|
| 1113 | + ); |
|
| 1114 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1115 | + return; |
|
| 1116 | + } |
|
| 1117 | + // load the widget class file |
|
| 1118 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1119 | + // verify that class exists |
|
| 1120 | + if (! class_exists($widget_class)) { |
|
| 1121 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1122 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1123 | + return; |
|
| 1124 | + } |
|
| 1125 | + register_widget($widget_class); |
|
| 1126 | + // add to array of registered widgets |
|
| 1127 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1128 | + } |
|
| 1129 | + |
|
| 1130 | + |
|
| 1131 | + |
|
| 1132 | + /** |
|
| 1133 | + * _register_modules |
|
| 1134 | + * |
|
| 1135 | + * @access private |
|
| 1136 | + * @return array |
|
| 1137 | + */ |
|
| 1138 | + private function _register_modules() |
|
| 1139 | + { |
|
| 1140 | + // grab list of installed modules |
|
| 1141 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1142 | + // filter list of modules to register |
|
| 1143 | + $modules_to_register = apply_filters( |
|
| 1144 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1145 | + $modules_to_register |
|
| 1146 | + ); |
|
| 1147 | + if (! empty($modules_to_register)) { |
|
| 1148 | + // loop through folders |
|
| 1149 | + foreach ($modules_to_register as $module_path) { |
|
| 1150 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1151 | + if ( |
|
| 1152 | + $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1153 | + && $module_path !== EE_MODULES . 'gateways' |
|
| 1154 | + ) { |
|
| 1155 | + // add to list of installed modules |
|
| 1156 | + EE_Config::register_module($module_path); |
|
| 1157 | + } |
|
| 1158 | + } |
|
| 1159 | + } |
|
| 1160 | + // filter list of installed modules |
|
| 1161 | + return apply_filters( |
|
| 1162 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1163 | + EE_Registry::instance()->modules |
|
| 1164 | + ); |
|
| 1165 | + } |
|
| 1166 | + |
|
| 1167 | + |
|
| 1168 | + |
|
| 1169 | + /** |
|
| 1170 | + * register_module - makes core aware of this module |
|
| 1171 | + * |
|
| 1172 | + * @access public |
|
| 1173 | + * @param string $module_path - full path up to and including module folder |
|
| 1174 | + * @return bool |
|
| 1175 | + */ |
|
| 1176 | + public static function register_module($module_path = null) |
|
| 1177 | + { |
|
| 1178 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1179 | + $module_ext = '.module.php'; |
|
| 1180 | + // make all separators match |
|
| 1181 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
| 1182 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1183 | + if (strpos($module_path, $module_ext) !== false) { |
|
| 1184 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1185 | + $module_file = explode('.', basename($module_path)); |
|
| 1186 | + // now we need to rebuild the shortcode path |
|
| 1187 | + $module_path = explode(DS, $module_path); |
|
| 1188 | + // remove last segment |
|
| 1189 | + array_pop($module_path); |
|
| 1190 | + // glue it back together |
|
| 1191 | + $module_path = implode(DS, $module_path) . DS; |
|
| 1192 | + // take first segment from file name pieces and sanitize it |
|
| 1193 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1194 | + // ensure class prefix is added |
|
| 1195 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1196 | + } else { |
|
| 1197 | + // we need to generate the filename based off of the folder name |
|
| 1198 | + // grab and sanitize module name |
|
| 1199 | + $module = strtolower(basename($module_path)); |
|
| 1200 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1201 | + // like trailingslashit() |
|
| 1202 | + $module_path = rtrim($module_path, DS) . DS; |
|
| 1203 | + // create classname from module directory name |
|
| 1204 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1205 | + // add class prefix |
|
| 1206 | + $module_class = 'EED_' . $module; |
|
| 1207 | + } |
|
| 1208 | + // does the module exist ? |
|
| 1209 | + if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1210 | + $msg = sprintf( |
|
| 1211 | + __( |
|
| 1212 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1213 | + 'event_espresso' |
|
| 1214 | + ), |
|
| 1215 | + $module |
|
| 1216 | + ); |
|
| 1217 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1218 | + return false; |
|
| 1219 | + } |
|
| 1220 | + // load the module class file |
|
| 1221 | + require_once($module_path . $module_class . $module_ext); |
|
| 1222 | + // verify that class exists |
|
| 1223 | + if (! class_exists($module_class)) { |
|
| 1224 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1225 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1226 | + return false; |
|
| 1227 | + } |
|
| 1228 | + // add to array of registered modules |
|
| 1229 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1230 | + do_action( |
|
| 1231 | + 'AHEE__EE_Config__register_module__complete', |
|
| 1232 | + $module_class, |
|
| 1233 | + EE_Registry::instance()->modules->{$module_class} |
|
| 1234 | + ); |
|
| 1235 | + return true; |
|
| 1236 | + } |
|
| 1237 | + |
|
| 1238 | + |
|
| 1239 | + |
|
| 1240 | + /** |
|
| 1241 | + * _initialize_modules |
|
| 1242 | + * allow modules to set hooks for the rest of the system |
|
| 1243 | + * |
|
| 1244 | + * @access private |
|
| 1245 | + * @return void |
|
| 1246 | + */ |
|
| 1247 | + private function _initialize_modules() |
|
| 1248 | + { |
|
| 1249 | + // cycle thru shortcode folders |
|
| 1250 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1251 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1252 | + // which set hooks ? |
|
| 1253 | + if (is_admin()) { |
|
| 1254 | + // fire immediately |
|
| 1255 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1256 | + } else { |
|
| 1257 | + // delay until other systems are online |
|
| 1258 | + add_action( |
|
| 1259 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1260 | + array($module_class, 'set_hooks') |
|
| 1261 | + ); |
|
| 1262 | + } |
|
| 1263 | + } |
|
| 1264 | + } |
|
| 1265 | + |
|
| 1266 | + |
|
| 1267 | + |
|
| 1268 | + /** |
|
| 1269 | + * register_route - adds module method routes to route_map |
|
| 1270 | + * |
|
| 1271 | + * @access public |
|
| 1272 | + * @param string $route - "pretty" public alias for module method |
|
| 1273 | + * @param string $module - module name (classname without EED_ prefix) |
|
| 1274 | + * @param string $method_name - the actual module method to be routed to |
|
| 1275 | + * @param string $key - url param key indicating a route is being called |
|
| 1276 | + * @return bool |
|
| 1277 | + */ |
|
| 1278 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1279 | + { |
|
| 1280 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1281 | + $module = str_replace('EED_', '', $module); |
|
| 1282 | + $module_class = 'EED_' . $module; |
|
| 1283 | + if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1284 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1285 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1286 | + return false; |
|
| 1287 | + } |
|
| 1288 | + if (empty($route)) { |
|
| 1289 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1290 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1291 | + return false; |
|
| 1292 | + } |
|
| 1293 | + if (! method_exists('EED_' . $module, $method_name)) { |
|
| 1294 | + $msg = sprintf( |
|
| 1295 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1296 | + $route |
|
| 1297 | + ); |
|
| 1298 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1299 | + return false; |
|
| 1300 | + } |
|
| 1301 | + EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1302 | + return true; |
|
| 1303 | + } |
|
| 1304 | + |
|
| 1305 | + |
|
| 1306 | + |
|
| 1307 | + /** |
|
| 1308 | + * get_route - get module method route |
|
| 1309 | + * |
|
| 1310 | + * @access public |
|
| 1311 | + * @param string $route - "pretty" public alias for module method |
|
| 1312 | + * @param string $key - url param key indicating a route is being called |
|
| 1313 | + * @return string |
|
| 1314 | + */ |
|
| 1315 | + public static function get_route($route = null, $key = 'ee') |
|
| 1316 | + { |
|
| 1317 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1318 | + $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1319 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
| 1320 | + return EE_Config::$_module_route_map[$key][$route]; |
|
| 1321 | + } |
|
| 1322 | + return null; |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + |
|
| 1326 | + |
|
| 1327 | + /** |
|
| 1328 | + * get_routes - get ALL module method routes |
|
| 1329 | + * |
|
| 1330 | + * @access public |
|
| 1331 | + * @return array |
|
| 1332 | + */ |
|
| 1333 | + public static function get_routes() |
|
| 1334 | + { |
|
| 1335 | + return EE_Config::$_module_route_map; |
|
| 1336 | + } |
|
| 1337 | + |
|
| 1338 | + |
|
| 1339 | + |
|
| 1340 | + /** |
|
| 1341 | + * register_forward - allows modules to forward request to another module for further processing |
|
| 1342 | + * |
|
| 1343 | + * @access public |
|
| 1344 | + * @param string $route - "pretty" public alias for module method |
|
| 1345 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1346 | + * class, allows different forwards to be served based on status |
|
| 1347 | + * @param array|string $forward - function name or array( class, method ) |
|
| 1348 | + * @param string $key - url param key indicating a route is being called |
|
| 1349 | + * @return bool |
|
| 1350 | + */ |
|
| 1351 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1352 | + { |
|
| 1353 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1354 | + if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1355 | + $msg = sprintf( |
|
| 1356 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1357 | + $route |
|
| 1358 | + ); |
|
| 1359 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1360 | + return false; |
|
| 1361 | + } |
|
| 1362 | + if (empty($forward)) { |
|
| 1363 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1364 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1365 | + return false; |
|
| 1366 | + } |
|
| 1367 | + if (is_array($forward)) { |
|
| 1368 | + if (! isset($forward[1])) { |
|
| 1369 | + $msg = sprintf( |
|
| 1370 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1371 | + $route |
|
| 1372 | + ); |
|
| 1373 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1374 | + return false; |
|
| 1375 | + } |
|
| 1376 | + if (! method_exists($forward[0], $forward[1])) { |
|
| 1377 | + $msg = sprintf( |
|
| 1378 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1379 | + $forward[1], |
|
| 1380 | + $route |
|
| 1381 | + ); |
|
| 1382 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1383 | + return false; |
|
| 1384 | + } |
|
| 1385 | + } else if (! function_exists($forward)) { |
|
| 1386 | + $msg = sprintf( |
|
| 1387 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1388 | + $forward, |
|
| 1389 | + $route |
|
| 1390 | + ); |
|
| 1391 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1392 | + return false; |
|
| 1393 | + } |
|
| 1394 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
| 1395 | + return true; |
|
| 1396 | + } |
|
| 1397 | + |
|
| 1398 | + |
|
| 1399 | + |
|
| 1400 | + /** |
|
| 1401 | + * get_forward - get forwarding route |
|
| 1402 | + * |
|
| 1403 | + * @access public |
|
| 1404 | + * @param string $route - "pretty" public alias for module method |
|
| 1405 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1406 | + * allows different forwards to be served based on status |
|
| 1407 | + * @param string $key - url param key indicating a route is being called |
|
| 1408 | + * @return string |
|
| 1409 | + */ |
|
| 1410 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1411 | + { |
|
| 1412 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1413 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
| 1414 | + return apply_filters( |
|
| 1415 | + 'FHEE__EE_Config__get_forward', |
|
| 1416 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
| 1417 | + $route, |
|
| 1418 | + $status |
|
| 1419 | + ); |
|
| 1420 | + } |
|
| 1421 | + return null; |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + |
|
| 1425 | + |
|
| 1426 | + /** |
|
| 1427 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1428 | + * results |
|
| 1429 | + * |
|
| 1430 | + * @access public |
|
| 1431 | + * @param string $route - "pretty" public alias for module method |
|
| 1432 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1433 | + * allows different views to be served based on status |
|
| 1434 | + * @param string $view |
|
| 1435 | + * @param string $key - url param key indicating a route is being called |
|
| 1436 | + * @return bool |
|
| 1437 | + */ |
|
| 1438 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1439 | + { |
|
| 1440 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1441 | + if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1442 | + $msg = sprintf( |
|
| 1443 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1444 | + $route |
|
| 1445 | + ); |
|
| 1446 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1447 | + return false; |
|
| 1448 | + } |
|
| 1449 | + if (! is_readable($view)) { |
|
| 1450 | + $msg = sprintf( |
|
| 1451 | + __( |
|
| 1452 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1453 | + 'event_espresso' |
|
| 1454 | + ), |
|
| 1455 | + $view |
|
| 1456 | + ); |
|
| 1457 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1458 | + return false; |
|
| 1459 | + } |
|
| 1460 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
| 1461 | + return true; |
|
| 1462 | + } |
|
| 1463 | + |
|
| 1464 | + |
|
| 1465 | + |
|
| 1466 | + /** |
|
| 1467 | + * get_view - get view for route and status |
|
| 1468 | + * |
|
| 1469 | + * @access public |
|
| 1470 | + * @param string $route - "pretty" public alias for module method |
|
| 1471 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1472 | + * allows different views to be served based on status |
|
| 1473 | + * @param string $key - url param key indicating a route is being called |
|
| 1474 | + * @return string |
|
| 1475 | + */ |
|
| 1476 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1477 | + { |
|
| 1478 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1479 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
| 1480 | + return apply_filters( |
|
| 1481 | + 'FHEE__EE_Config__get_view', |
|
| 1482 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
| 1483 | + $route, |
|
| 1484 | + $status |
|
| 1485 | + ); |
|
| 1486 | + } |
|
| 1487 | + return null; |
|
| 1488 | + } |
|
| 1489 | + |
|
| 1490 | + |
|
| 1491 | + |
|
| 1492 | + public function update_addon_option_names() |
|
| 1493 | + { |
|
| 1494 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1495 | + } |
|
| 1496 | + |
|
| 1497 | + |
|
| 1498 | + |
|
| 1499 | + public function shutdown() |
|
| 1500 | + { |
|
| 1501 | + $this->update_addon_option_names(); |
|
| 1502 | + } |
|
| 1503 | + |
|
| 1504 | + |
|
| 1505 | + |
|
| 1506 | + /** |
|
| 1507 | + * @return LegacyShortcodesManager |
|
| 1508 | + */ |
|
| 1509 | + public static function getLegacyShortcodesManager() |
|
| 1510 | + { |
|
| 1511 | + |
|
| 1512 | + if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
| 1513 | + EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
| 1514 | + EE_Registry::instance() |
|
| 1515 | + ); |
|
| 1516 | + } |
|
| 1517 | + return EE_Config::instance()->legacy_shortcodes_manager; |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + |
|
| 1521 | + |
|
| 1522 | + /** |
|
| 1523 | + * register_shortcode - makes core aware of this shortcode |
|
| 1524 | + * |
|
| 1525 | + * @deprecated 4.9.26 |
|
| 1526 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1527 | + * @return bool |
|
| 1528 | + */ |
|
| 1529 | + public static function register_shortcode($shortcode_path = null) |
|
| 1530 | + { |
|
| 1531 | + EE_Error::doing_it_wrong( |
|
| 1532 | + __METHOD__, |
|
| 1533 | + __( |
|
| 1534 | + 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
| 1535 | + 'event_espresso' |
|
| 1536 | + ), |
|
| 1537 | + '4.9.26' |
|
| 1538 | + ); |
|
| 1539 | + return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
| 1540 | + } |
|
| 20 | 1541 | |
| 21 | - const LOG_NAME = 'ee_config_log'; |
|
| 22 | 1542 | |
| 23 | - const LOG_LENGTH = 100; |
|
| 24 | 1543 | |
| 25 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * instance of the EE_Config object |
|
| 30 | - * |
|
| 31 | - * @var EE_Config $_instance |
|
| 32 | - * @access private |
|
| 33 | - */ |
|
| 34 | - private static $_instance; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var boolean $_logging_enabled |
|
| 38 | - */ |
|
| 39 | - private static $_logging_enabled = false; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 43 | - */ |
|
| 44 | - private $legacy_shortcodes_manager; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * An StdClass whose property names are addon slugs, |
|
| 48 | - * and values are their config classes |
|
| 49 | - * |
|
| 50 | - * @var StdClass |
|
| 51 | - */ |
|
| 52 | - public $addons; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var EE_Admin_Config |
|
| 56 | - */ |
|
| 57 | - public $admin; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var EE_Core_Config |
|
| 61 | - */ |
|
| 62 | - public $core; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @var EE_Currency_Config |
|
| 66 | - */ |
|
| 67 | - public $currency; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @var EE_Organization_Config |
|
| 71 | - */ |
|
| 72 | - public $organization; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @var EE_Registration_Config |
|
| 76 | - */ |
|
| 77 | - public $registration; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @var EE_Template_Config |
|
| 81 | - */ |
|
| 82 | - public $template_settings; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Holds EE environment values. |
|
| 86 | - * |
|
| 87 | - * @var EE_Environment_Config |
|
| 88 | - */ |
|
| 89 | - public $environment; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * settings pertaining to Google maps |
|
| 93 | - * |
|
| 94 | - * @var EE_Map_Config |
|
| 95 | - */ |
|
| 96 | - public $map_settings; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * settings pertaining to Taxes |
|
| 100 | - * |
|
| 101 | - * @var EE_Tax_Config |
|
| 102 | - */ |
|
| 103 | - public $tax_settings; |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Settings pertaining to global messages settings. |
|
| 108 | - * |
|
| 109 | - * @var EE_Messages_Config |
|
| 110 | - */ |
|
| 111 | - public $messages; |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @deprecated |
|
| 115 | - * @var EE_Gateway_Config |
|
| 116 | - */ |
|
| 117 | - public $gateway; |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @var array $_addon_option_names |
|
| 121 | - * @access private |
|
| 122 | - */ |
|
| 123 | - private $_addon_option_names = array(); |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @var array $_module_route_map |
|
| 127 | - * @access private |
|
| 128 | - */ |
|
| 129 | - private static $_module_route_map = array(); |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @var array $_module_forward_map |
|
| 133 | - * @access private |
|
| 134 | - */ |
|
| 135 | - private static $_module_forward_map = array(); |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @var array $_module_view_map |
|
| 139 | - * @access private |
|
| 140 | - */ |
|
| 141 | - private static $_module_view_map = array(); |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * @singleton method used to instantiate class object |
|
| 147 | - * @access public |
|
| 148 | - * @return EE_Config instance |
|
| 149 | - */ |
|
| 150 | - public static function instance() |
|
| 151 | - { |
|
| 152 | - // check if class object is instantiated, and instantiated properly |
|
| 153 | - if (! self::$_instance instanceof EE_Config) { |
|
| 154 | - self::$_instance = new self(); |
|
| 155 | - } |
|
| 156 | - return self::$_instance; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Resets the config |
|
| 163 | - * |
|
| 164 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 165 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 166 | - * reflect its state in the database |
|
| 167 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 168 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 169 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 170 | - * site was put into maintenance mode) |
|
| 171 | - * @return EE_Config |
|
| 172 | - */ |
|
| 173 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 174 | - { |
|
| 175 | - if (self::$_instance instanceof EE_Config) { |
|
| 176 | - if ($hard_reset) { |
|
| 177 | - self::$_instance->legacy_shortcodes_manager = null; |
|
| 178 | - self::$_instance->_addon_option_names = array(); |
|
| 179 | - self::$_instance->_initialize_config(); |
|
| 180 | - self::$_instance->update_espresso_config(); |
|
| 181 | - } |
|
| 182 | - self::$_instance->update_addon_option_names(); |
|
| 183 | - } |
|
| 184 | - self::$_instance = null; |
|
| 185 | - //we don't need to reset the static properties imo because those should |
|
| 186 | - //only change when a module is added or removed. Currently we don't |
|
| 187 | - //support removing a module during a request when it previously existed |
|
| 188 | - if ($reinstantiate) { |
|
| 189 | - return self::instance(); |
|
| 190 | - } else { |
|
| 191 | - return null; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * class constructor |
|
| 199 | - * |
|
| 200 | - * @access private |
|
| 201 | - */ |
|
| 202 | - private function __construct() |
|
| 203 | - { |
|
| 204 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 205 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 206 | - // setup empty config classes |
|
| 207 | - $this->_initialize_config(); |
|
| 208 | - // load existing EE site settings |
|
| 209 | - $this->_load_core_config(); |
|
| 210 | - // confirm everything loaded correctly and set filtered defaults if not |
|
| 211 | - $this->_verify_config(); |
|
| 212 | - // register shortcodes and modules |
|
| 213 | - add_action( |
|
| 214 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 215 | - array($this, 'register_shortcodes_and_modules'), |
|
| 216 | - 999 |
|
| 217 | - ); |
|
| 218 | - // initialize shortcodes and modules |
|
| 219 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 220 | - // register widgets |
|
| 221 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 222 | - // shutdown |
|
| 223 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 224 | - // construct__end hook |
|
| 225 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
| 226 | - // hardcoded hack |
|
| 227 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * @return boolean |
|
| 234 | - */ |
|
| 235 | - public static function logging_enabled() |
|
| 236 | - { |
|
| 237 | - return self::$_logging_enabled; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * use to get the current theme if needed from static context |
|
| 244 | - * |
|
| 245 | - * @return string current theme set. |
|
| 246 | - */ |
|
| 247 | - public static function get_current_theme() |
|
| 248 | - { |
|
| 249 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 250 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * _initialize_config |
|
| 257 | - * |
|
| 258 | - * @access private |
|
| 259 | - * @return void |
|
| 260 | - */ |
|
| 261 | - private function _initialize_config() |
|
| 262 | - { |
|
| 263 | - EE_Config::trim_log(); |
|
| 264 | - //set defaults |
|
| 265 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 266 | - $this->addons = new stdClass(); |
|
| 267 | - // set _module_route_map |
|
| 268 | - EE_Config::$_module_route_map = array(); |
|
| 269 | - // set _module_forward_map |
|
| 270 | - EE_Config::$_module_forward_map = array(); |
|
| 271 | - // set _module_view_map |
|
| 272 | - EE_Config::$_module_view_map = array(); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * load core plugin configuration |
|
| 279 | - * |
|
| 280 | - * @access private |
|
| 281 | - * @return void |
|
| 282 | - */ |
|
| 283 | - private function _load_core_config() |
|
| 284 | - { |
|
| 285 | - // load_core_config__start hook |
|
| 286 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 287 | - $espresso_config = $this->get_espresso_config(); |
|
| 288 | - foreach ($espresso_config as $config => $settings) { |
|
| 289 | - // load_core_config__start hook |
|
| 290 | - $settings = apply_filters( |
|
| 291 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 292 | - $settings, |
|
| 293 | - $config, |
|
| 294 | - $this |
|
| 295 | - ); |
|
| 296 | - if (is_object($settings) && property_exists($this, $config)) { |
|
| 297 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 298 | - //call configs populate method to ensure any defaults are set for empty values. |
|
| 299 | - if (method_exists($settings, 'populate')) { |
|
| 300 | - $this->{$config}->populate(); |
|
| 301 | - } |
|
| 302 | - if (method_exists($settings, 'do_hooks')) { |
|
| 303 | - $this->{$config}->do_hooks(); |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 308 | - $this->update_espresso_config(); |
|
| 309 | - } |
|
| 310 | - // load_core_config__end hook |
|
| 311 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * _verify_config |
|
| 318 | - * |
|
| 319 | - * @access protected |
|
| 320 | - * @return void |
|
| 321 | - */ |
|
| 322 | - protected function _verify_config() |
|
| 323 | - { |
|
| 324 | - $this->core = $this->core instanceof EE_Core_Config |
|
| 325 | - ? $this->core |
|
| 326 | - : new EE_Core_Config(); |
|
| 327 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 328 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 329 | - ? $this->organization |
|
| 330 | - : new EE_Organization_Config(); |
|
| 331 | - $this->organization = apply_filters( |
|
| 332 | - 'FHEE__EE_Config___initialize_config__organization', |
|
| 333 | - $this->organization |
|
| 334 | - ); |
|
| 335 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 336 | - ? $this->currency |
|
| 337 | - : new EE_Currency_Config(); |
|
| 338 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 339 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 340 | - ? $this->registration |
|
| 341 | - : new EE_Registration_Config(); |
|
| 342 | - $this->registration = apply_filters( |
|
| 343 | - 'FHEE__EE_Config___initialize_config__registration', |
|
| 344 | - $this->registration |
|
| 345 | - ); |
|
| 346 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 347 | - ? $this->admin |
|
| 348 | - : new EE_Admin_Config(); |
|
| 349 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 350 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 351 | - ? $this->template_settings |
|
| 352 | - : new EE_Template_Config(); |
|
| 353 | - $this->template_settings = apply_filters( |
|
| 354 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 355 | - $this->template_settings |
|
| 356 | - ); |
|
| 357 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 358 | - ? $this->map_settings |
|
| 359 | - : new EE_Map_Config(); |
|
| 360 | - $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
| 361 | - $this->map_settings); |
|
| 362 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 363 | - ? $this->environment |
|
| 364 | - : new EE_Environment_Config(); |
|
| 365 | - $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
| 366 | - $this->environment); |
|
| 367 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 368 | - ? $this->tax_settings |
|
| 369 | - : new EE_Tax_Config(); |
|
| 370 | - $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
| 371 | - $this->tax_settings); |
|
| 372 | - $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages); |
|
| 373 | - $this->messages = $this->messages instanceof EE_Messages_Config |
|
| 374 | - ? $this->messages |
|
| 375 | - : new EE_Messages_Config(); |
|
| 376 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 377 | - ? $this->gateway |
|
| 378 | - : new EE_Gateway_Config(); |
|
| 379 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 380 | - $this->legacy_shortcodes_manager = null; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - |
|
| 384 | - /** |
|
| 385 | - * get_espresso_config |
|
| 386 | - * |
|
| 387 | - * @access public |
|
| 388 | - * @return array of espresso config stuff |
|
| 389 | - */ |
|
| 390 | - public function get_espresso_config() |
|
| 391 | - { |
|
| 392 | - // grab espresso configuration |
|
| 393 | - return apply_filters( |
|
| 394 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 395 | - get_option(EE_Config::OPTION_NAME, array()) |
|
| 396 | - ); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - |
|
| 401 | - /** |
|
| 402 | - * double_check_config_comparison |
|
| 403 | - * |
|
| 404 | - * @access public |
|
| 405 | - * @param string $option |
|
| 406 | - * @param $old_value |
|
| 407 | - * @param $value |
|
| 408 | - */ |
|
| 409 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 410 | - { |
|
| 411 | - // make sure we're checking the ee config |
|
| 412 | - if ($option === EE_Config::OPTION_NAME) { |
|
| 413 | - // run a loose comparison of the old value against the new value for type and properties, |
|
| 414 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 415 | - if ($value != $old_value) { |
|
| 416 | - // if they are NOT the same, then remove the hook, |
|
| 417 | - // which means the subsequent update results will be based solely on the update query results |
|
| 418 | - // the reason we do this is because, as stated above, |
|
| 419 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 420 | - // this happens PRIOR to serialization and any subsequent update. |
|
| 421 | - // If values are found to match their previous old value, |
|
| 422 | - // then WP bails before performing any update. |
|
| 423 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 424 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 425 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 426 | - // MySQL MAY ALSO NOT perform the update because |
|
| 427 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 428 | - // This results in the query returning an "affected rows" value of ZERO, |
|
| 429 | - // which gets returned immediately by WP update_option and looks like an error. |
|
| 430 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - /** |
|
| 438 | - * update_espresso_config |
|
| 439 | - * |
|
| 440 | - * @access public |
|
| 441 | - */ |
|
| 442 | - protected function _reset_espresso_addon_config() |
|
| 443 | - { |
|
| 444 | - $this->_addon_option_names = array(); |
|
| 445 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 446 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 447 | - $config_class = get_class($addon_config_obj); |
|
| 448 | - if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
| 449 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 450 | - } |
|
| 451 | - $this->addons->{$addon_name} = null; |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - |
|
| 457 | - /** |
|
| 458 | - * update_espresso_config |
|
| 459 | - * |
|
| 460 | - * @access public |
|
| 461 | - * @param bool $add_success |
|
| 462 | - * @param bool $add_error |
|
| 463 | - * @return bool |
|
| 464 | - */ |
|
| 465 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
| 466 | - { |
|
| 467 | - // don't allow config updates during WP heartbeats |
|
| 468 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 469 | - return false; |
|
| 470 | - } |
|
| 471 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 472 | - //$clone = clone( self::$_instance ); |
|
| 473 | - //self::$_instance = NULL; |
|
| 474 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 475 | - $this->_reset_espresso_addon_config(); |
|
| 476 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 477 | - // but BEFORE the actual update occurs |
|
| 478 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 479 | - // don't want to persist legacy_shortcodes_manager, but don't want to lose it either |
|
| 480 | - $legacy_shortcodes_manager = $this->legacy_shortcodes_manager; |
|
| 481 | - $this->legacy_shortcodes_manager = null; |
|
| 482 | - // now update "ee_config" |
|
| 483 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 484 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 485 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
| 486 | - // if not saved... check if the hook we just added still exists; |
|
| 487 | - // if it does, it means one of two things: |
|
| 488 | - // that update_option bailed at the ( $value === $old_value ) conditional, |
|
| 489 | - // or... |
|
| 490 | - // the db update query returned 0 rows affected |
|
| 491 | - // (probably because the data value was the same from it's perspective) |
|
| 492 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 493 | - // but just means no update occurred, so don't display an error to the user. |
|
| 494 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 495 | - // then it means that something truly went wrong |
|
| 496 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 497 | - // remove our action since we don't want it in the system anymore |
|
| 498 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 499 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 500 | - //self::$_instance = $clone; |
|
| 501 | - //unset( $clone ); |
|
| 502 | - // if config remains the same or was updated successfully |
|
| 503 | - if ($saved) { |
|
| 504 | - if ($add_success) { |
|
| 505 | - EE_Error::add_success( |
|
| 506 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 507 | - __FILE__, |
|
| 508 | - __FUNCTION__, |
|
| 509 | - __LINE__ |
|
| 510 | - ); |
|
| 511 | - } |
|
| 512 | - return true; |
|
| 513 | - } else { |
|
| 514 | - if ($add_error) { |
|
| 515 | - EE_Error::add_error( |
|
| 516 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 517 | - __FILE__, |
|
| 518 | - __FUNCTION__, |
|
| 519 | - __LINE__ |
|
| 520 | - ); |
|
| 521 | - } |
|
| 522 | - return false; |
|
| 523 | - } |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * _verify_config_params |
|
| 530 | - * |
|
| 531 | - * @access private |
|
| 532 | - * @param string $section |
|
| 533 | - * @param string $name |
|
| 534 | - * @param string $config_class |
|
| 535 | - * @param EE_Config_Base $config_obj |
|
| 536 | - * @param array $tests_to_run |
|
| 537 | - * @param bool $display_errors |
|
| 538 | - * @return bool TRUE on success, FALSE on fail |
|
| 539 | - */ |
|
| 540 | - private function _verify_config_params( |
|
| 541 | - $section = '', |
|
| 542 | - $name = '', |
|
| 543 | - $config_class = '', |
|
| 544 | - $config_obj = null, |
|
| 545 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 546 | - $display_errors = true |
|
| 547 | - ) { |
|
| 548 | - try { |
|
| 549 | - foreach ($tests_to_run as $test) { |
|
| 550 | - switch ($test) { |
|
| 551 | - // TEST #1 : check that section was set |
|
| 552 | - case 1 : |
|
| 553 | - if (empty($section)) { |
|
| 554 | - if ($display_errors) { |
|
| 555 | - throw new EE_Error( |
|
| 556 | - sprintf( |
|
| 557 | - __( |
|
| 558 | - 'No configuration section has been provided while attempting to save "%s".', |
|
| 559 | - 'event_espresso' |
|
| 560 | - ), |
|
| 561 | - $config_class |
|
| 562 | - ) |
|
| 563 | - ); |
|
| 564 | - } |
|
| 565 | - return false; |
|
| 566 | - } |
|
| 567 | - break; |
|
| 568 | - // TEST #2 : check that settings section exists |
|
| 569 | - case 2 : |
|
| 570 | - if (! isset($this->{$section})) { |
|
| 571 | - if ($display_errors) { |
|
| 572 | - throw new EE_Error( |
|
| 573 | - sprintf( |
|
| 574 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 575 | - $section |
|
| 576 | - ) |
|
| 577 | - ); |
|
| 578 | - } |
|
| 579 | - return false; |
|
| 580 | - } |
|
| 581 | - break; |
|
| 582 | - // TEST #3 : check that section is the proper format |
|
| 583 | - case 3 : |
|
| 584 | - if ( |
|
| 585 | - ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 586 | - ) { |
|
| 587 | - if ($display_errors) { |
|
| 588 | - throw new EE_Error( |
|
| 589 | - sprintf( |
|
| 590 | - __( |
|
| 591 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
| 592 | - 'event_espresso' |
|
| 593 | - ), |
|
| 594 | - $section |
|
| 595 | - ) |
|
| 596 | - ); |
|
| 597 | - } |
|
| 598 | - return false; |
|
| 599 | - } |
|
| 600 | - break; |
|
| 601 | - // TEST #4 : check that config section name has been set |
|
| 602 | - case 4 : |
|
| 603 | - if (empty($name)) { |
|
| 604 | - if ($display_errors) { |
|
| 605 | - throw new EE_Error( |
|
| 606 | - __( |
|
| 607 | - 'No name has been provided for the specific configuration section.', |
|
| 608 | - 'event_espresso' |
|
| 609 | - ) |
|
| 610 | - ); |
|
| 611 | - } |
|
| 612 | - return false; |
|
| 613 | - } |
|
| 614 | - break; |
|
| 615 | - // TEST #5 : check that a config class name has been set |
|
| 616 | - case 5 : |
|
| 617 | - if (empty($config_class)) { |
|
| 618 | - if ($display_errors) { |
|
| 619 | - throw new EE_Error( |
|
| 620 | - __( |
|
| 621 | - 'No class name has been provided for the specific configuration section.', |
|
| 622 | - 'event_espresso' |
|
| 623 | - ) |
|
| 624 | - ); |
|
| 625 | - } |
|
| 626 | - return false; |
|
| 627 | - } |
|
| 628 | - break; |
|
| 629 | - // TEST #6 : verify config class is accessible |
|
| 630 | - case 6 : |
|
| 631 | - if (! class_exists($config_class)) { |
|
| 632 | - if ($display_errors) { |
|
| 633 | - throw new EE_Error( |
|
| 634 | - sprintf( |
|
| 635 | - __( |
|
| 636 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 637 | - 'event_espresso' |
|
| 638 | - ), |
|
| 639 | - $config_class |
|
| 640 | - ) |
|
| 641 | - ); |
|
| 642 | - } |
|
| 643 | - return false; |
|
| 644 | - } |
|
| 645 | - break; |
|
| 646 | - // TEST #7 : check that config has even been set |
|
| 647 | - case 7 : |
|
| 648 | - if (! isset($this->{$section}->{$name})) { |
|
| 649 | - if ($display_errors) { |
|
| 650 | - throw new EE_Error( |
|
| 651 | - sprintf( |
|
| 652 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 653 | - $section, |
|
| 654 | - $name |
|
| 655 | - ) |
|
| 656 | - ); |
|
| 657 | - } |
|
| 658 | - return false; |
|
| 659 | - } else { |
|
| 660 | - // and make sure it's not serialized |
|
| 661 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 662 | - } |
|
| 663 | - break; |
|
| 664 | - // TEST #8 : check that config is the requested type |
|
| 665 | - case 8 : |
|
| 666 | - if (! $this->{$section}->{$name} instanceof $config_class) { |
|
| 667 | - if ($display_errors) { |
|
| 668 | - throw new EE_Error( |
|
| 669 | - sprintf( |
|
| 670 | - __( |
|
| 671 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 672 | - 'event_espresso' |
|
| 673 | - ), |
|
| 674 | - $section, |
|
| 675 | - $name, |
|
| 676 | - $config_class |
|
| 677 | - ) |
|
| 678 | - ); |
|
| 679 | - } |
|
| 680 | - return false; |
|
| 681 | - } |
|
| 682 | - break; |
|
| 683 | - // TEST #9 : verify config object |
|
| 684 | - case 9 : |
|
| 685 | - if (! $config_obj instanceof EE_Config_Base) { |
|
| 686 | - if ($display_errors) { |
|
| 687 | - throw new EE_Error( |
|
| 688 | - sprintf( |
|
| 689 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 690 | - print_r($config_obj, true) |
|
| 691 | - ) |
|
| 692 | - ); |
|
| 693 | - } |
|
| 694 | - return false; |
|
| 695 | - } |
|
| 696 | - break; |
|
| 697 | - } |
|
| 698 | - } |
|
| 699 | - } catch (EE_Error $e) { |
|
| 700 | - $e->get_error(); |
|
| 701 | - } |
|
| 702 | - // you have successfully run the gauntlet |
|
| 703 | - return true; |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - |
|
| 707 | - |
|
| 708 | - /** |
|
| 709 | - * _generate_config_option_name |
|
| 710 | - * |
|
| 711 | - * @access protected |
|
| 712 | - * @param string $section |
|
| 713 | - * @param string $name |
|
| 714 | - * @return string |
|
| 715 | - */ |
|
| 716 | - private function _generate_config_option_name($section = '', $name = '') |
|
| 717 | - { |
|
| 718 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 719 | - } |
|
| 720 | - |
|
| 721 | - |
|
| 722 | - |
|
| 723 | - /** |
|
| 724 | - * _set_config_class |
|
| 725 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 726 | - * |
|
| 727 | - * @access private |
|
| 728 | - * @param string $config_class |
|
| 729 | - * @param string $name |
|
| 730 | - * @return string |
|
| 731 | - */ |
|
| 732 | - private function _set_config_class($config_class = '', $name = '') |
|
| 733 | - { |
|
| 734 | - return ! empty($config_class) |
|
| 735 | - ? $config_class |
|
| 736 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - |
|
| 740 | - |
|
| 741 | - /** |
|
| 742 | - * set_config |
|
| 743 | - * |
|
| 744 | - * @access protected |
|
| 745 | - * @param string $section |
|
| 746 | - * @param string $name |
|
| 747 | - * @param string $config_class |
|
| 748 | - * @param EE_Config_Base $config_obj |
|
| 749 | - * @return EE_Config_Base |
|
| 750 | - */ |
|
| 751 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 752 | - { |
|
| 753 | - // ensure config class is set to something |
|
| 754 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 755 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 756 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 757 | - return null; |
|
| 758 | - } |
|
| 759 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 760 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 761 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 762 | - $this->_addon_option_names[$config_option_name] = $config_class; |
|
| 763 | - $this->update_addon_option_names(); |
|
| 764 | - } |
|
| 765 | - // verify the incoming config object but suppress errors |
|
| 766 | - if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 767 | - $config_obj = new $config_class(); |
|
| 768 | - } |
|
| 769 | - if (get_option($config_option_name)) { |
|
| 770 | - EE_Config::log($config_option_name); |
|
| 771 | - update_option($config_option_name, $config_obj); |
|
| 772 | - $this->{$section}->{$name} = $config_obj; |
|
| 773 | - return $this->{$section}->{$name}; |
|
| 774 | - } else { |
|
| 775 | - // create a wp-option for this config |
|
| 776 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 777 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 778 | - return $this->{$section}->{$name}; |
|
| 779 | - } else { |
|
| 780 | - EE_Error::add_error( |
|
| 781 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 782 | - __FILE__, |
|
| 783 | - __FUNCTION__, |
|
| 784 | - __LINE__ |
|
| 785 | - ); |
|
| 786 | - return null; |
|
| 787 | - } |
|
| 788 | - } |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - |
|
| 792 | - |
|
| 793 | - /** |
|
| 794 | - * update_config |
|
| 795 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 796 | - * |
|
| 797 | - * @access public |
|
| 798 | - * @param string $section |
|
| 799 | - * @param string $name |
|
| 800 | - * @param EE_Config_Base|string $config_obj |
|
| 801 | - * @param bool $throw_errors |
|
| 802 | - * @return bool |
|
| 803 | - */ |
|
| 804 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 805 | - { |
|
| 806 | - // don't allow config updates during WP heartbeats |
|
| 807 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 808 | - return false; |
|
| 809 | - } |
|
| 810 | - $config_obj = maybe_unserialize($config_obj); |
|
| 811 | - // get class name of the incoming object |
|
| 812 | - $config_class = get_class($config_obj); |
|
| 813 | - // run tests 1-5 and 9 to verify config |
|
| 814 | - if (! $this->_verify_config_params( |
|
| 815 | - $section, |
|
| 816 | - $name, |
|
| 817 | - $config_class, |
|
| 818 | - $config_obj, |
|
| 819 | - array(1, 2, 3, 4, 7, 9) |
|
| 820 | - ) |
|
| 821 | - ) { |
|
| 822 | - return false; |
|
| 823 | - } |
|
| 824 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 825 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 826 | - if (! isset($this->_addon_option_names[$config_option_name])) { |
|
| 827 | - // save new config to db |
|
| 828 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 829 | - return true; |
|
| 830 | - } |
|
| 831 | - } else { |
|
| 832 | - // first check if the record already exists |
|
| 833 | - $existing_config = get_option($config_option_name); |
|
| 834 | - $config_obj = serialize($config_obj); |
|
| 835 | - // just return if db record is already up to date (NOT type safe comparison) |
|
| 836 | - if ($existing_config == $config_obj) { |
|
| 837 | - $this->{$section}->{$name} = $config_obj; |
|
| 838 | - return true; |
|
| 839 | - } else if (update_option($config_option_name, $config_obj)) { |
|
| 840 | - EE_Config::log($config_option_name); |
|
| 841 | - // update wp-option for this config class |
|
| 842 | - $this->{$section}->{$name} = $config_obj; |
|
| 843 | - return true; |
|
| 844 | - } elseif ($throw_errors) { |
|
| 845 | - EE_Error::add_error( |
|
| 846 | - sprintf( |
|
| 847 | - __( |
|
| 848 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 849 | - 'event_espresso' |
|
| 850 | - ), |
|
| 851 | - $config_class, |
|
| 852 | - 'EE_Config->' . $section . '->' . $name |
|
| 853 | - ), |
|
| 854 | - __FILE__, |
|
| 855 | - __FUNCTION__, |
|
| 856 | - __LINE__ |
|
| 857 | - ); |
|
| 858 | - } |
|
| 859 | - } |
|
| 860 | - return false; |
|
| 861 | - } |
|
| 862 | - |
|
| 863 | - |
|
| 864 | - |
|
| 865 | - /** |
|
| 866 | - * get_config |
|
| 867 | - * |
|
| 868 | - * @access public |
|
| 869 | - * @param string $section |
|
| 870 | - * @param string $name |
|
| 871 | - * @param string $config_class |
|
| 872 | - * @return mixed EE_Config_Base | NULL |
|
| 873 | - */ |
|
| 874 | - public function get_config($section = '', $name = '', $config_class = '') |
|
| 875 | - { |
|
| 876 | - // ensure config class is set to something |
|
| 877 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 878 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 879 | - if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 880 | - return null; |
|
| 881 | - } |
|
| 882 | - // now test if the requested config object exists, but suppress errors |
|
| 883 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 884 | - // config already exists, so pass it back |
|
| 885 | - return $this->{$section}->{$name}; |
|
| 886 | - } |
|
| 887 | - // load config option from db if it exists |
|
| 888 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 889 | - // verify the newly retrieved config object, but suppress errors |
|
| 890 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 891 | - // config is good, so set it and pass it back |
|
| 892 | - $this->{$section}->{$name} = $config_obj; |
|
| 893 | - return $this->{$section}->{$name}; |
|
| 894 | - } |
|
| 895 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 896 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
| 897 | - // verify the newly created config object |
|
| 898 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 899 | - return $this->{$section}->{$name}; |
|
| 900 | - } else { |
|
| 901 | - EE_Error::add_error( |
|
| 902 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 903 | - __FILE__, |
|
| 904 | - __FUNCTION__, |
|
| 905 | - __LINE__ |
|
| 906 | - ); |
|
| 907 | - } |
|
| 908 | - return null; |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - |
|
| 912 | - |
|
| 913 | - /** |
|
| 914 | - * get_config_option |
|
| 915 | - * |
|
| 916 | - * @access public |
|
| 917 | - * @param string $config_option_name |
|
| 918 | - * @return mixed EE_Config_Base | FALSE |
|
| 919 | - */ |
|
| 920 | - public function get_config_option($config_option_name = '') |
|
| 921 | - { |
|
| 922 | - // retrieve the wp-option for this config class. |
|
| 923 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 924 | - if (empty($config_option)) { |
|
| 925 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 926 | - } |
|
| 927 | - return $config_option; |
|
| 928 | - } |
|
| 929 | - |
|
| 930 | - |
|
| 931 | - |
|
| 932 | - /** |
|
| 933 | - * log |
|
| 934 | - * |
|
| 935 | - * @param string $config_option_name |
|
| 936 | - */ |
|
| 937 | - public static function log($config_option_name = '') |
|
| 938 | - { |
|
| 939 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 940 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 941 | - //copy incoming $_REQUEST and sanitize it so we can save it |
|
| 942 | - $_request = $_REQUEST; |
|
| 943 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 944 | - $config_log[(string)microtime(true)] = array( |
|
| 945 | - 'config_name' => $config_option_name, |
|
| 946 | - 'request' => $_request, |
|
| 947 | - ); |
|
| 948 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 949 | - } |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - |
|
| 953 | - |
|
| 954 | - /** |
|
| 955 | - * trim_log |
|
| 956 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 957 | - */ |
|
| 958 | - public static function trim_log() |
|
| 959 | - { |
|
| 960 | - if (! EE_Config::logging_enabled()) { |
|
| 961 | - return; |
|
| 962 | - } |
|
| 963 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 964 | - $log_length = count($config_log); |
|
| 965 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 966 | - ksort($config_log); |
|
| 967 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 968 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 969 | - } |
|
| 970 | - } |
|
| 971 | - |
|
| 972 | - |
|
| 973 | - |
|
| 974 | - /** |
|
| 975 | - * get_page_for_posts |
|
| 976 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 977 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 978 | - * |
|
| 979 | - * @access public |
|
| 980 | - * @return string |
|
| 981 | - */ |
|
| 982 | - public static function get_page_for_posts() |
|
| 983 | - { |
|
| 984 | - $page_for_posts = get_option('page_for_posts'); |
|
| 985 | - if (! $page_for_posts) { |
|
| 986 | - return 'posts'; |
|
| 987 | - } |
|
| 988 | - /** @type WPDB $wpdb */ |
|
| 989 | - global $wpdb; |
|
| 990 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 991 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 992 | - } |
|
| 993 | - |
|
| 994 | - |
|
| 995 | - |
|
| 996 | - /** |
|
| 997 | - * register_shortcodes_and_modules. |
|
| 998 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 999 | - * In fact, this is where we give modules a chance to let core know they exist |
|
| 1000 | - * so they can help trigger maintenance mode if it's needed |
|
| 1001 | - * |
|
| 1002 | - * @access public |
|
| 1003 | - * @return void |
|
| 1004 | - */ |
|
| 1005 | - public function register_shortcodes_and_modules() |
|
| 1006 | - { |
|
| 1007 | - // allow modules to set hooks for the rest of the system |
|
| 1008 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - |
|
| 1012 | - |
|
| 1013 | - /** |
|
| 1014 | - * initialize_shortcodes_and_modules |
|
| 1015 | - * meaning they can start adding their hooks to get stuff done |
|
| 1016 | - * |
|
| 1017 | - * @access public |
|
| 1018 | - * @return void |
|
| 1019 | - */ |
|
| 1020 | - public function initialize_shortcodes_and_modules() |
|
| 1021 | - { |
|
| 1022 | - // allow modules to set hooks for the rest of the system |
|
| 1023 | - $this->_initialize_modules(); |
|
| 1024 | - } |
|
| 1025 | - |
|
| 1026 | - |
|
| 1027 | - |
|
| 1028 | - /** |
|
| 1029 | - * widgets_init |
|
| 1030 | - * |
|
| 1031 | - * @access private |
|
| 1032 | - * @return void |
|
| 1033 | - */ |
|
| 1034 | - public function widgets_init() |
|
| 1035 | - { |
|
| 1036 | - //only init widgets on admin pages when not in complete maintenance, and |
|
| 1037 | - //on frontend when not in any maintenance mode |
|
| 1038 | - if ( |
|
| 1039 | - ! EE_Maintenance_Mode::instance()->level() |
|
| 1040 | - || ( |
|
| 1041 | - is_admin() |
|
| 1042 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1043 | - ) |
|
| 1044 | - ) { |
|
| 1045 | - // grab list of installed widgets |
|
| 1046 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1047 | - // filter list of modules to register |
|
| 1048 | - $widgets_to_register = apply_filters( |
|
| 1049 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1050 | - $widgets_to_register |
|
| 1051 | - ); |
|
| 1052 | - if (! empty($widgets_to_register)) { |
|
| 1053 | - // cycle thru widget folders |
|
| 1054 | - foreach ($widgets_to_register as $widget_path) { |
|
| 1055 | - // add to list of installed widget modules |
|
| 1056 | - EE_Config::register_ee_widget($widget_path); |
|
| 1057 | - } |
|
| 1058 | - } |
|
| 1059 | - // filter list of installed modules |
|
| 1060 | - EE_Registry::instance()->widgets = apply_filters( |
|
| 1061 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1062 | - EE_Registry::instance()->widgets |
|
| 1063 | - ); |
|
| 1064 | - } |
|
| 1065 | - } |
|
| 1066 | - |
|
| 1067 | - |
|
| 1068 | - |
|
| 1069 | - /** |
|
| 1070 | - * register_ee_widget - makes core aware of this widget |
|
| 1071 | - * |
|
| 1072 | - * @access public |
|
| 1073 | - * @param string $widget_path - full path up to and including widget folder |
|
| 1074 | - * @return void |
|
| 1075 | - */ |
|
| 1076 | - public static function register_ee_widget($widget_path = null) |
|
| 1077 | - { |
|
| 1078 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1079 | - $widget_ext = '.widget.php'; |
|
| 1080 | - // make all separators match |
|
| 1081 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
| 1082 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1083 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1084 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1085 | - $file_name = explode('.', basename($widget_path)); |
|
| 1086 | - // take first segment from file name pieces and remove class prefix if it exists |
|
| 1087 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1088 | - // sanitize shortcode directory name |
|
| 1089 | - $widget = sanitize_key($widget); |
|
| 1090 | - // now we need to rebuild the shortcode path |
|
| 1091 | - $widget_path = explode(DS, $widget_path); |
|
| 1092 | - // remove last segment |
|
| 1093 | - array_pop($widget_path); |
|
| 1094 | - // glue it back together |
|
| 1095 | - $widget_path = implode(DS, $widget_path); |
|
| 1096 | - } else { |
|
| 1097 | - // grab and sanitize widget directory name |
|
| 1098 | - $widget = sanitize_key(basename($widget_path)); |
|
| 1099 | - } |
|
| 1100 | - // create classname from widget directory name |
|
| 1101 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1102 | - // add class prefix |
|
| 1103 | - $widget_class = 'EEW_' . $widget; |
|
| 1104 | - // does the widget exist ? |
|
| 1105 | - if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1106 | - $msg = sprintf( |
|
| 1107 | - __( |
|
| 1108 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1109 | - 'event_espresso' |
|
| 1110 | - ), |
|
| 1111 | - $widget_class, |
|
| 1112 | - $widget_path . DS . $widget_class . $widget_ext |
|
| 1113 | - ); |
|
| 1114 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1115 | - return; |
|
| 1116 | - } |
|
| 1117 | - // load the widget class file |
|
| 1118 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1119 | - // verify that class exists |
|
| 1120 | - if (! class_exists($widget_class)) { |
|
| 1121 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1122 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1123 | - return; |
|
| 1124 | - } |
|
| 1125 | - register_widget($widget_class); |
|
| 1126 | - // add to array of registered widgets |
|
| 1127 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1128 | - } |
|
| 1129 | - |
|
| 1130 | - |
|
| 1131 | - |
|
| 1132 | - /** |
|
| 1133 | - * _register_modules |
|
| 1134 | - * |
|
| 1135 | - * @access private |
|
| 1136 | - * @return array |
|
| 1137 | - */ |
|
| 1138 | - private function _register_modules() |
|
| 1139 | - { |
|
| 1140 | - // grab list of installed modules |
|
| 1141 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1142 | - // filter list of modules to register |
|
| 1143 | - $modules_to_register = apply_filters( |
|
| 1144 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1145 | - $modules_to_register |
|
| 1146 | - ); |
|
| 1147 | - if (! empty($modules_to_register)) { |
|
| 1148 | - // loop through folders |
|
| 1149 | - foreach ($modules_to_register as $module_path) { |
|
| 1150 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1151 | - if ( |
|
| 1152 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1153 | - && $module_path !== EE_MODULES . 'gateways' |
|
| 1154 | - ) { |
|
| 1155 | - // add to list of installed modules |
|
| 1156 | - EE_Config::register_module($module_path); |
|
| 1157 | - } |
|
| 1158 | - } |
|
| 1159 | - } |
|
| 1160 | - // filter list of installed modules |
|
| 1161 | - return apply_filters( |
|
| 1162 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1163 | - EE_Registry::instance()->modules |
|
| 1164 | - ); |
|
| 1165 | - } |
|
| 1166 | - |
|
| 1167 | - |
|
| 1168 | - |
|
| 1169 | - /** |
|
| 1170 | - * register_module - makes core aware of this module |
|
| 1171 | - * |
|
| 1172 | - * @access public |
|
| 1173 | - * @param string $module_path - full path up to and including module folder |
|
| 1174 | - * @return bool |
|
| 1175 | - */ |
|
| 1176 | - public static function register_module($module_path = null) |
|
| 1177 | - { |
|
| 1178 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1179 | - $module_ext = '.module.php'; |
|
| 1180 | - // make all separators match |
|
| 1181 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
| 1182 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1183 | - if (strpos($module_path, $module_ext) !== false) { |
|
| 1184 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1185 | - $module_file = explode('.', basename($module_path)); |
|
| 1186 | - // now we need to rebuild the shortcode path |
|
| 1187 | - $module_path = explode(DS, $module_path); |
|
| 1188 | - // remove last segment |
|
| 1189 | - array_pop($module_path); |
|
| 1190 | - // glue it back together |
|
| 1191 | - $module_path = implode(DS, $module_path) . DS; |
|
| 1192 | - // take first segment from file name pieces and sanitize it |
|
| 1193 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1194 | - // ensure class prefix is added |
|
| 1195 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1196 | - } else { |
|
| 1197 | - // we need to generate the filename based off of the folder name |
|
| 1198 | - // grab and sanitize module name |
|
| 1199 | - $module = strtolower(basename($module_path)); |
|
| 1200 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1201 | - // like trailingslashit() |
|
| 1202 | - $module_path = rtrim($module_path, DS) . DS; |
|
| 1203 | - // create classname from module directory name |
|
| 1204 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1205 | - // add class prefix |
|
| 1206 | - $module_class = 'EED_' . $module; |
|
| 1207 | - } |
|
| 1208 | - // does the module exist ? |
|
| 1209 | - if (! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1210 | - $msg = sprintf( |
|
| 1211 | - __( |
|
| 1212 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1213 | - 'event_espresso' |
|
| 1214 | - ), |
|
| 1215 | - $module |
|
| 1216 | - ); |
|
| 1217 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1218 | - return false; |
|
| 1219 | - } |
|
| 1220 | - // load the module class file |
|
| 1221 | - require_once($module_path . $module_class . $module_ext); |
|
| 1222 | - // verify that class exists |
|
| 1223 | - if (! class_exists($module_class)) { |
|
| 1224 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1225 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1226 | - return false; |
|
| 1227 | - } |
|
| 1228 | - // add to array of registered modules |
|
| 1229 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1230 | - do_action( |
|
| 1231 | - 'AHEE__EE_Config__register_module__complete', |
|
| 1232 | - $module_class, |
|
| 1233 | - EE_Registry::instance()->modules->{$module_class} |
|
| 1234 | - ); |
|
| 1235 | - return true; |
|
| 1236 | - } |
|
| 1237 | - |
|
| 1238 | - |
|
| 1239 | - |
|
| 1240 | - /** |
|
| 1241 | - * _initialize_modules |
|
| 1242 | - * allow modules to set hooks for the rest of the system |
|
| 1243 | - * |
|
| 1244 | - * @access private |
|
| 1245 | - * @return void |
|
| 1246 | - */ |
|
| 1247 | - private function _initialize_modules() |
|
| 1248 | - { |
|
| 1249 | - // cycle thru shortcode folders |
|
| 1250 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1251 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1252 | - // which set hooks ? |
|
| 1253 | - if (is_admin()) { |
|
| 1254 | - // fire immediately |
|
| 1255 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1256 | - } else { |
|
| 1257 | - // delay until other systems are online |
|
| 1258 | - add_action( |
|
| 1259 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1260 | - array($module_class, 'set_hooks') |
|
| 1261 | - ); |
|
| 1262 | - } |
|
| 1263 | - } |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - |
|
| 1267 | - |
|
| 1268 | - /** |
|
| 1269 | - * register_route - adds module method routes to route_map |
|
| 1270 | - * |
|
| 1271 | - * @access public |
|
| 1272 | - * @param string $route - "pretty" public alias for module method |
|
| 1273 | - * @param string $module - module name (classname without EED_ prefix) |
|
| 1274 | - * @param string $method_name - the actual module method to be routed to |
|
| 1275 | - * @param string $key - url param key indicating a route is being called |
|
| 1276 | - * @return bool |
|
| 1277 | - */ |
|
| 1278 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1279 | - { |
|
| 1280 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1281 | - $module = str_replace('EED_', '', $module); |
|
| 1282 | - $module_class = 'EED_' . $module; |
|
| 1283 | - if (! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1284 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1285 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1286 | - return false; |
|
| 1287 | - } |
|
| 1288 | - if (empty($route)) { |
|
| 1289 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1290 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1291 | - return false; |
|
| 1292 | - } |
|
| 1293 | - if (! method_exists('EED_' . $module, $method_name)) { |
|
| 1294 | - $msg = sprintf( |
|
| 1295 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1296 | - $route |
|
| 1297 | - ); |
|
| 1298 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1299 | - return false; |
|
| 1300 | - } |
|
| 1301 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1302 | - return true; |
|
| 1303 | - } |
|
| 1304 | - |
|
| 1305 | - |
|
| 1306 | - |
|
| 1307 | - /** |
|
| 1308 | - * get_route - get module method route |
|
| 1309 | - * |
|
| 1310 | - * @access public |
|
| 1311 | - * @param string $route - "pretty" public alias for module method |
|
| 1312 | - * @param string $key - url param key indicating a route is being called |
|
| 1313 | - * @return string |
|
| 1314 | - */ |
|
| 1315 | - public static function get_route($route = null, $key = 'ee') |
|
| 1316 | - { |
|
| 1317 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1318 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1319 | - if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
| 1320 | - return EE_Config::$_module_route_map[$key][$route]; |
|
| 1321 | - } |
|
| 1322 | - return null; |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - |
|
| 1326 | - |
|
| 1327 | - /** |
|
| 1328 | - * get_routes - get ALL module method routes |
|
| 1329 | - * |
|
| 1330 | - * @access public |
|
| 1331 | - * @return array |
|
| 1332 | - */ |
|
| 1333 | - public static function get_routes() |
|
| 1334 | - { |
|
| 1335 | - return EE_Config::$_module_route_map; |
|
| 1336 | - } |
|
| 1337 | - |
|
| 1338 | - |
|
| 1339 | - |
|
| 1340 | - /** |
|
| 1341 | - * register_forward - allows modules to forward request to another module for further processing |
|
| 1342 | - * |
|
| 1343 | - * @access public |
|
| 1344 | - * @param string $route - "pretty" public alias for module method |
|
| 1345 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1346 | - * class, allows different forwards to be served based on status |
|
| 1347 | - * @param array|string $forward - function name or array( class, method ) |
|
| 1348 | - * @param string $key - url param key indicating a route is being called |
|
| 1349 | - * @return bool |
|
| 1350 | - */ |
|
| 1351 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1352 | - { |
|
| 1353 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1354 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1355 | - $msg = sprintf( |
|
| 1356 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1357 | - $route |
|
| 1358 | - ); |
|
| 1359 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1360 | - return false; |
|
| 1361 | - } |
|
| 1362 | - if (empty($forward)) { |
|
| 1363 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1364 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1365 | - return false; |
|
| 1366 | - } |
|
| 1367 | - if (is_array($forward)) { |
|
| 1368 | - if (! isset($forward[1])) { |
|
| 1369 | - $msg = sprintf( |
|
| 1370 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1371 | - $route |
|
| 1372 | - ); |
|
| 1373 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1374 | - return false; |
|
| 1375 | - } |
|
| 1376 | - if (! method_exists($forward[0], $forward[1])) { |
|
| 1377 | - $msg = sprintf( |
|
| 1378 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1379 | - $forward[1], |
|
| 1380 | - $route |
|
| 1381 | - ); |
|
| 1382 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1383 | - return false; |
|
| 1384 | - } |
|
| 1385 | - } else if (! function_exists($forward)) { |
|
| 1386 | - $msg = sprintf( |
|
| 1387 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1388 | - $forward, |
|
| 1389 | - $route |
|
| 1390 | - ); |
|
| 1391 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1392 | - return false; |
|
| 1393 | - } |
|
| 1394 | - EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
| 1395 | - return true; |
|
| 1396 | - } |
|
| 1397 | - |
|
| 1398 | - |
|
| 1399 | - |
|
| 1400 | - /** |
|
| 1401 | - * get_forward - get forwarding route |
|
| 1402 | - * |
|
| 1403 | - * @access public |
|
| 1404 | - * @param string $route - "pretty" public alias for module method |
|
| 1405 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1406 | - * allows different forwards to be served based on status |
|
| 1407 | - * @param string $key - url param key indicating a route is being called |
|
| 1408 | - * @return string |
|
| 1409 | - */ |
|
| 1410 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1411 | - { |
|
| 1412 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1413 | - if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
| 1414 | - return apply_filters( |
|
| 1415 | - 'FHEE__EE_Config__get_forward', |
|
| 1416 | - EE_Config::$_module_forward_map[$key][$route][$status], |
|
| 1417 | - $route, |
|
| 1418 | - $status |
|
| 1419 | - ); |
|
| 1420 | - } |
|
| 1421 | - return null; |
|
| 1422 | - } |
|
| 1423 | - |
|
| 1424 | - |
|
| 1425 | - |
|
| 1426 | - /** |
|
| 1427 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1428 | - * results |
|
| 1429 | - * |
|
| 1430 | - * @access public |
|
| 1431 | - * @param string $route - "pretty" public alias for module method |
|
| 1432 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1433 | - * allows different views to be served based on status |
|
| 1434 | - * @param string $view |
|
| 1435 | - * @param string $key - url param key indicating a route is being called |
|
| 1436 | - * @return bool |
|
| 1437 | - */ |
|
| 1438 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1439 | - { |
|
| 1440 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1441 | - if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1442 | - $msg = sprintf( |
|
| 1443 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1444 | - $route |
|
| 1445 | - ); |
|
| 1446 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1447 | - return false; |
|
| 1448 | - } |
|
| 1449 | - if (! is_readable($view)) { |
|
| 1450 | - $msg = sprintf( |
|
| 1451 | - __( |
|
| 1452 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1453 | - 'event_espresso' |
|
| 1454 | - ), |
|
| 1455 | - $view |
|
| 1456 | - ); |
|
| 1457 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1458 | - return false; |
|
| 1459 | - } |
|
| 1460 | - EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
| 1461 | - return true; |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - |
|
| 1465 | - |
|
| 1466 | - /** |
|
| 1467 | - * get_view - get view for route and status |
|
| 1468 | - * |
|
| 1469 | - * @access public |
|
| 1470 | - * @param string $route - "pretty" public alias for module method |
|
| 1471 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1472 | - * allows different views to be served based on status |
|
| 1473 | - * @param string $key - url param key indicating a route is being called |
|
| 1474 | - * @return string |
|
| 1475 | - */ |
|
| 1476 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1477 | - { |
|
| 1478 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1479 | - if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
| 1480 | - return apply_filters( |
|
| 1481 | - 'FHEE__EE_Config__get_view', |
|
| 1482 | - EE_Config::$_module_view_map[$key][$route][$status], |
|
| 1483 | - $route, |
|
| 1484 | - $status |
|
| 1485 | - ); |
|
| 1486 | - } |
|
| 1487 | - return null; |
|
| 1488 | - } |
|
| 1489 | - |
|
| 1490 | - |
|
| 1491 | - |
|
| 1492 | - public function update_addon_option_names() |
|
| 1493 | - { |
|
| 1494 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1495 | - } |
|
| 1496 | - |
|
| 1497 | - |
|
| 1498 | - |
|
| 1499 | - public function shutdown() |
|
| 1500 | - { |
|
| 1501 | - $this->update_addon_option_names(); |
|
| 1502 | - } |
|
| 1503 | - |
|
| 1504 | - |
|
| 1505 | - |
|
| 1506 | - /** |
|
| 1507 | - * @return LegacyShortcodesManager |
|
| 1508 | - */ |
|
| 1509 | - public static function getLegacyShortcodesManager() |
|
| 1510 | - { |
|
| 1511 | - |
|
| 1512 | - if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) { |
|
| 1513 | - EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager( |
|
| 1514 | - EE_Registry::instance() |
|
| 1515 | - ); |
|
| 1516 | - } |
|
| 1517 | - return EE_Config::instance()->legacy_shortcodes_manager; |
|
| 1518 | - } |
|
| 1519 | - |
|
| 1520 | - |
|
| 1521 | - |
|
| 1522 | - /** |
|
| 1523 | - * register_shortcode - makes core aware of this shortcode |
|
| 1524 | - * |
|
| 1525 | - * @deprecated 4.9.26 |
|
| 1526 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1527 | - * @return bool |
|
| 1528 | - */ |
|
| 1529 | - public static function register_shortcode($shortcode_path = null) |
|
| 1530 | - { |
|
| 1531 | - EE_Error::doing_it_wrong( |
|
| 1532 | - __METHOD__, |
|
| 1533 | - __( |
|
| 1534 | - 'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.', |
|
| 1535 | - 'event_espresso' |
|
| 1536 | - ), |
|
| 1537 | - '4.9.26' |
|
| 1538 | - ); |
|
| 1539 | - return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path); |
|
| 1540 | - } |
|
| 1541 | - |
|
| 1542 | - |
|
| 1543 | - |
|
| 1544 | -} |
|
| 1545 | - |
|
| 1546 | - |
|
| 1547 | - |
|
| 1548 | -/** |
|
| 1549 | - * Base class used for config classes. These classes should generally not have |
|
| 1550 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1551 | - * basically, they should just be well-defined stdClasses |
|
| 1552 | - */ |
|
| 1553 | -class EE_Config_Base |
|
| 1554 | -{ |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * Utility function for escaping the value of a property and returning. |
|
| 1558 | - * |
|
| 1559 | - * @param string $property property name (checks to see if exists). |
|
| 1560 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1561 | - * @throws \EE_Error |
|
| 1562 | - */ |
|
| 1563 | - public function get_pretty($property) |
|
| 1564 | - { |
|
| 1565 | - if (! property_exists($this, $property)) { |
|
| 1566 | - throw new EE_Error( |
|
| 1567 | - sprintf( |
|
| 1568 | - __( |
|
| 1569 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1570 | - 'event_espresso' |
|
| 1571 | - ), |
|
| 1572 | - get_class($this), |
|
| 1573 | - $property |
|
| 1574 | - ) |
|
| 1575 | - ); |
|
| 1576 | - } |
|
| 1577 | - //just handling escaping of strings for now. |
|
| 1578 | - if (is_string($this->{$property})) { |
|
| 1579 | - return stripslashes($this->{$property}); |
|
| 1580 | - } |
|
| 1581 | - return $this->{$property}; |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - |
|
| 1585 | - |
|
| 1586 | - public function populate() |
|
| 1587 | - { |
|
| 1588 | - //grab defaults via a new instance of this class. |
|
| 1589 | - $class_name = get_class($this); |
|
| 1590 | - $defaults = new $class_name; |
|
| 1591 | - //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1592 | - //default from our $defaults object. |
|
| 1593 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1594 | - if ($this->{$property} === null) { |
|
| 1595 | - $this->{$property} = $value; |
|
| 1596 | - } |
|
| 1597 | - } |
|
| 1598 | - //cleanup |
|
| 1599 | - unset($defaults); |
|
| 1600 | - } |
|
| 1601 | - |
|
| 1602 | - |
|
| 1603 | - |
|
| 1604 | - /** |
|
| 1605 | - * __isset |
|
| 1606 | - * |
|
| 1607 | - * @param $a |
|
| 1608 | - * @return bool |
|
| 1609 | - */ |
|
| 1610 | - public function __isset($a) |
|
| 1611 | - { |
|
| 1612 | - return false; |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - |
|
| 1616 | - |
|
| 1617 | - /** |
|
| 1618 | - * __unset |
|
| 1619 | - * |
|
| 1620 | - * @param $a |
|
| 1621 | - * @return bool |
|
| 1622 | - */ |
|
| 1623 | - public function __unset($a) |
|
| 1624 | - { |
|
| 1625 | - return false; |
|
| 1626 | - } |
|
| 1627 | - |
|
| 1628 | - |
|
| 1629 | - |
|
| 1630 | - /** |
|
| 1631 | - * __clone |
|
| 1632 | - */ |
|
| 1633 | - public function __clone() |
|
| 1634 | - { |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - |
|
| 1638 | - |
|
| 1639 | - /** |
|
| 1640 | - * __wakeup |
|
| 1641 | - */ |
|
| 1642 | - public function __wakeup() |
|
| 1643 | - { |
|
| 1644 | - } |
|
| 1645 | - |
|
| 1646 | - |
|
| 1647 | - |
|
| 1648 | - /** |
|
| 1649 | - * __destruct |
|
| 1650 | - */ |
|
| 1651 | - public function __destruct() |
|
| 1652 | - { |
|
| 1653 | - } |
|
| 1654 | -} |
|
| 1655 | - |
|
| 1656 | - |
|
| 1657 | - |
|
| 1658 | -/** |
|
| 1659 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 1660 | - */ |
|
| 1661 | -class EE_Core_Config extends EE_Config_Base |
|
| 1662 | -{ |
|
| 1663 | - |
|
| 1664 | - public $current_blog_id; |
|
| 1665 | - |
|
| 1666 | - public $ee_ueip_optin; |
|
| 1667 | - |
|
| 1668 | - public $ee_ueip_has_notified; |
|
| 1669 | - |
|
| 1670 | - /** |
|
| 1671 | - * Not to be confused with the 4 critical page variables (See |
|
| 1672 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1673 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1674 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1675 | - * |
|
| 1676 | - * @var array |
|
| 1677 | - */ |
|
| 1678 | - public $post_shortcodes; |
|
| 1679 | - |
|
| 1680 | - public $module_route_map; |
|
| 1681 | - |
|
| 1682 | - public $module_forward_map; |
|
| 1683 | - |
|
| 1684 | - public $module_view_map; |
|
| 1685 | - |
|
| 1686 | - /** |
|
| 1687 | - * The next 4 vars are the IDs of critical EE pages. |
|
| 1688 | - * |
|
| 1689 | - * @var int |
|
| 1690 | - */ |
|
| 1691 | - public $reg_page_id; |
|
| 1692 | - |
|
| 1693 | - public $txn_page_id; |
|
| 1694 | - |
|
| 1695 | - public $thank_you_page_id; |
|
| 1696 | - |
|
| 1697 | - public $cancel_page_id; |
|
| 1698 | - |
|
| 1699 | - /** |
|
| 1700 | - * The next 4 vars are the URLs of critical EE pages. |
|
| 1701 | - * |
|
| 1702 | - * @var int |
|
| 1703 | - */ |
|
| 1704 | - public $reg_page_url; |
|
| 1705 | - |
|
| 1706 | - public $txn_page_url; |
|
| 1707 | - |
|
| 1708 | - public $thank_you_page_url; |
|
| 1709 | - |
|
| 1710 | - public $cancel_page_url; |
|
| 1711 | - |
|
| 1712 | - /** |
|
| 1713 | - * The next vars relate to the custom slugs for EE CPT routes |
|
| 1714 | - */ |
|
| 1715 | - public $event_cpt_slug; |
|
| 1716 | - |
|
| 1717 | - |
|
| 1718 | - /** |
|
| 1719 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1720 | - * request across blog switches in a multisite context. |
|
| 1721 | - * Avoids extra queries to the db for this option. |
|
| 1722 | - * |
|
| 1723 | - * @var bool |
|
| 1724 | - */ |
|
| 1725 | - public static $ee_ueip_option; |
|
| 1726 | - |
|
| 1727 | - |
|
| 1728 | - |
|
| 1729 | - /** |
|
| 1730 | - * class constructor |
|
| 1731 | - * |
|
| 1732 | - * @access public |
|
| 1733 | - */ |
|
| 1734 | - public function __construct() |
|
| 1735 | - { |
|
| 1736 | - // set default organization settings |
|
| 1737 | - $this->current_blog_id = get_current_blog_id(); |
|
| 1738 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1739 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1740 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1741 | - $this->post_shortcodes = array(); |
|
| 1742 | - $this->module_route_map = array(); |
|
| 1743 | - $this->module_forward_map = array(); |
|
| 1744 | - $this->module_view_map = array(); |
|
| 1745 | - // critical EE page IDs |
|
| 1746 | - $this->reg_page_id = 0; |
|
| 1747 | - $this->txn_page_id = 0; |
|
| 1748 | - $this->thank_you_page_id = 0; |
|
| 1749 | - $this->cancel_page_id = 0; |
|
| 1750 | - // critical EE page URLs |
|
| 1751 | - $this->reg_page_url = ''; |
|
| 1752 | - $this->txn_page_url = ''; |
|
| 1753 | - $this->thank_you_page_url = ''; |
|
| 1754 | - $this->cancel_page_url = ''; |
|
| 1755 | - //cpt slugs |
|
| 1756 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1757 | - //ueip constant check |
|
| 1758 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1759 | - $this->ee_ueip_optin = false; |
|
| 1760 | - $this->ee_ueip_has_notified = true; |
|
| 1761 | - } |
|
| 1762 | - } |
|
| 1763 | - |
|
| 1764 | - |
|
| 1765 | - |
|
| 1766 | - /** |
|
| 1767 | - * @return array |
|
| 1768 | - */ |
|
| 1769 | - public function get_critical_pages_array() |
|
| 1770 | - { |
|
| 1771 | - return array( |
|
| 1772 | - $this->reg_page_id, |
|
| 1773 | - $this->txn_page_id, |
|
| 1774 | - $this->thank_you_page_id, |
|
| 1775 | - $this->cancel_page_id, |
|
| 1776 | - ); |
|
| 1777 | - } |
|
| 1778 | - |
|
| 1779 | - |
|
| 1780 | - |
|
| 1781 | - /** |
|
| 1782 | - * @return array |
|
| 1783 | - */ |
|
| 1784 | - public function get_critical_pages_shortcodes_array() |
|
| 1785 | - { |
|
| 1786 | - return array( |
|
| 1787 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1788 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1789 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1790 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1791 | - ); |
|
| 1792 | - } |
|
| 1793 | - |
|
| 1794 | - |
|
| 1795 | - |
|
| 1796 | - /** |
|
| 1797 | - * gets/returns URL for EE reg_page |
|
| 1798 | - * |
|
| 1799 | - * @access public |
|
| 1800 | - * @return string |
|
| 1801 | - */ |
|
| 1802 | - public function reg_page_url() |
|
| 1803 | - { |
|
| 1804 | - if (! $this->reg_page_url) { |
|
| 1805 | - $this->reg_page_url = add_query_arg( |
|
| 1806 | - array('uts' => time()), |
|
| 1807 | - get_permalink($this->reg_page_id) |
|
| 1808 | - ) . '#checkout'; |
|
| 1809 | - } |
|
| 1810 | - return $this->reg_page_url; |
|
| 1811 | - } |
|
| 1812 | - |
|
| 1813 | - |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * gets/returns URL for EE txn_page |
|
| 1817 | - * |
|
| 1818 | - * @param array $query_args like what gets passed to |
|
| 1819 | - * add_query_arg() as the first argument |
|
| 1820 | - * @access public |
|
| 1821 | - * @return string |
|
| 1822 | - */ |
|
| 1823 | - public function txn_page_url($query_args = array()) |
|
| 1824 | - { |
|
| 1825 | - if (! $this->txn_page_url) { |
|
| 1826 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1827 | - } |
|
| 1828 | - if ($query_args) { |
|
| 1829 | - return add_query_arg($query_args, $this->txn_page_url); |
|
| 1830 | - } else { |
|
| 1831 | - return $this->txn_page_url; |
|
| 1832 | - } |
|
| 1833 | - } |
|
| 1834 | - |
|
| 1835 | - |
|
| 1836 | - |
|
| 1837 | - /** |
|
| 1838 | - * gets/returns URL for EE thank_you_page |
|
| 1839 | - * |
|
| 1840 | - * @param array $query_args like what gets passed to |
|
| 1841 | - * add_query_arg() as the first argument |
|
| 1842 | - * @access public |
|
| 1843 | - * @return string |
|
| 1844 | - */ |
|
| 1845 | - public function thank_you_page_url($query_args = array()) |
|
| 1846 | - { |
|
| 1847 | - if (! $this->thank_you_page_url) { |
|
| 1848 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1849 | - } |
|
| 1850 | - if ($query_args) { |
|
| 1851 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1852 | - } else { |
|
| 1853 | - return $this->thank_you_page_url; |
|
| 1854 | - } |
|
| 1855 | - } |
|
| 1856 | - |
|
| 1857 | - |
|
| 1858 | - |
|
| 1859 | - /** |
|
| 1860 | - * gets/returns URL for EE cancel_page |
|
| 1861 | - * |
|
| 1862 | - * @access public |
|
| 1863 | - * @return string |
|
| 1864 | - */ |
|
| 1865 | - public function cancel_page_url() |
|
| 1866 | - { |
|
| 1867 | - if (! $this->cancel_page_url) { |
|
| 1868 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1869 | - } |
|
| 1870 | - return $this->cancel_page_url; |
|
| 1871 | - } |
|
| 1872 | - |
|
| 1873 | - |
|
| 1874 | - |
|
| 1875 | - /** |
|
| 1876 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1877 | - * |
|
| 1878 | - * @since 4.7.5 |
|
| 1879 | - */ |
|
| 1880 | - protected function _reset_urls() |
|
| 1881 | - { |
|
| 1882 | - $this->reg_page_url = ''; |
|
| 1883 | - $this->txn_page_url = ''; |
|
| 1884 | - $this->cancel_page_url = ''; |
|
| 1885 | - $this->thank_you_page_url = ''; |
|
| 1886 | - } |
|
| 1887 | - |
|
| 1888 | - |
|
| 1889 | - |
|
| 1890 | - /** |
|
| 1891 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1892 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1893 | - * on the main site only. |
|
| 1894 | - * |
|
| 1895 | - * @return mixed|void |
|
| 1896 | - */ |
|
| 1897 | - protected function _get_main_ee_ueip_optin() |
|
| 1898 | - { |
|
| 1899 | - //if this is the main site then we can just bypass our direct query. |
|
| 1900 | - if (is_main_site()) { |
|
| 1901 | - return get_option('ee_ueip_optin', false); |
|
| 1902 | - } |
|
| 1903 | - //is this already cached for this request? If so use it. |
|
| 1904 | - if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
| 1905 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1906 | - } |
|
| 1907 | - global $wpdb; |
|
| 1908 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1909 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1910 | - $option = 'ee_ueip_optin'; |
|
| 1911 | - //set correct table for query |
|
| 1912 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1913 | - //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1914 | - //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1915 | - //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1916 | - //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1917 | - //for the purpose of caching. |
|
| 1918 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1919 | - if (false !== $pre) { |
|
| 1920 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
| 1921 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1922 | - } |
|
| 1923 | - $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 1924 | - $option)); |
|
| 1925 | - if (is_object($row)) { |
|
| 1926 | - $value = $row->option_value; |
|
| 1927 | - } else { //option does not exist so use default. |
|
| 1928 | - return apply_filters('default_option_' . $option, false, $option); |
|
| 1929 | - } |
|
| 1930 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 1931 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1932 | - } |
|
| 1933 | - |
|
| 1934 | - |
|
| 1935 | - |
|
| 1936 | - /** |
|
| 1937 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 1938 | - * on the object. |
|
| 1939 | - * |
|
| 1940 | - * @return array |
|
| 1941 | - */ |
|
| 1942 | - public function __sleep() |
|
| 1943 | - { |
|
| 1944 | - //reset all url properties |
|
| 1945 | - $this->_reset_urls(); |
|
| 1946 | - //return what to save to db |
|
| 1947 | - return array_keys(get_object_vars($this)); |
|
| 1948 | - } |
|
| 1949 | - |
|
| 1950 | -} |
|
| 1951 | - |
|
| 1952 | - |
|
| 1953 | - |
|
| 1954 | -/** |
|
| 1955 | - * Config class for storing info on the Organization |
|
| 1956 | - */ |
|
| 1957 | -class EE_Organization_Config extends EE_Config_Base |
|
| 1958 | -{ |
|
| 1959 | - |
|
| 1960 | - /** |
|
| 1961 | - * @var string $name |
|
| 1962 | - * eg EE4.1 |
|
| 1963 | - */ |
|
| 1964 | - public $name; |
|
| 1965 | - |
|
| 1966 | - /** |
|
| 1967 | - * @var string $address_1 |
|
| 1968 | - * eg 123 Onna Road |
|
| 1969 | - */ |
|
| 1970 | - public $address_1; |
|
| 1971 | - |
|
| 1972 | - /** |
|
| 1973 | - * @var string $address_2 |
|
| 1974 | - * eg PO Box 123 |
|
| 1975 | - */ |
|
| 1976 | - public $address_2; |
|
| 1977 | - |
|
| 1978 | - /** |
|
| 1979 | - * @var string $city |
|
| 1980 | - * eg Inna City |
|
| 1981 | - */ |
|
| 1982 | - public $city; |
|
| 1983 | - |
|
| 1984 | - /** |
|
| 1985 | - * @var int $STA_ID |
|
| 1986 | - * eg 4 |
|
| 1987 | - */ |
|
| 1988 | - public $STA_ID; |
|
| 1989 | - |
|
| 1990 | - /** |
|
| 1991 | - * @var string $CNT_ISO |
|
| 1992 | - * eg US |
|
| 1993 | - */ |
|
| 1994 | - public $CNT_ISO; |
|
| 1995 | - |
|
| 1996 | - /** |
|
| 1997 | - * @var string $zip |
|
| 1998 | - * eg 12345 or V1A 2B3 |
|
| 1999 | - */ |
|
| 2000 | - public $zip; |
|
| 2001 | - |
|
| 2002 | - /** |
|
| 2003 | - * @var string $email |
|
| 2004 | - * eg [email protected] |
|
| 2005 | - */ |
|
| 2006 | - public $email; |
|
| 2007 | - |
|
| 2008 | - |
|
| 2009 | - /** |
|
| 2010 | - * @var string $phone |
|
| 2011 | - * eg. 111-111-1111 |
|
| 2012 | - */ |
|
| 2013 | - public $phone; |
|
| 2014 | - |
|
| 2015 | - |
|
| 2016 | - /** |
|
| 2017 | - * @var string $vat |
|
| 2018 | - * VAT/Tax Number |
|
| 2019 | - */ |
|
| 2020 | - public $vat; |
|
| 2021 | - |
|
| 2022 | - /** |
|
| 2023 | - * @var string $logo_url |
|
| 2024 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 2025 | - */ |
|
| 2026 | - public $logo_url; |
|
| 2027 | - |
|
| 2028 | - |
|
| 2029 | - /** |
|
| 2030 | - * The below are all various properties for holding links to organization social network profiles |
|
| 2031 | - * |
|
| 2032 | - * @var string |
|
| 2033 | - */ |
|
| 2034 | - /** |
|
| 2035 | - * facebook (facebook.com/profile.name) |
|
| 2036 | - * |
|
| 2037 | - * @var string |
|
| 2038 | - */ |
|
| 2039 | - public $facebook; |
|
| 2040 | - |
|
| 2041 | - |
|
| 2042 | - /** |
|
| 2043 | - * twitter (twitter.com/twitter_handle) |
|
| 2044 | - * |
|
| 2045 | - * @var string |
|
| 2046 | - */ |
|
| 2047 | - public $twitter; |
|
| 2048 | - |
|
| 2049 | - |
|
| 2050 | - /** |
|
| 2051 | - * linkedin (linkedin.com/in/profile_name) |
|
| 2052 | - * |
|
| 2053 | - * @var string |
|
| 2054 | - */ |
|
| 2055 | - public $linkedin; |
|
| 2056 | - |
|
| 2057 | - |
|
| 2058 | - /** |
|
| 2059 | - * pinterest (www.pinterest.com/profile_name) |
|
| 2060 | - * |
|
| 2061 | - * @var string |
|
| 2062 | - */ |
|
| 2063 | - public $pinterest; |
|
| 2064 | - |
|
| 2065 | - |
|
| 2066 | - /** |
|
| 2067 | - * google+ (google.com/+profileName) |
|
| 2068 | - * |
|
| 2069 | - * @var string |
|
| 2070 | - */ |
|
| 2071 | - public $google; |
|
| 2072 | - |
|
| 2073 | - |
|
| 2074 | - /** |
|
| 2075 | - * instagram (instagram.com/handle) |
|
| 2076 | - * |
|
| 2077 | - * @var string |
|
| 2078 | - */ |
|
| 2079 | - public $instagram; |
|
| 2080 | - |
|
| 2081 | - |
|
| 2082 | - |
|
| 2083 | - /** |
|
| 2084 | - * class constructor |
|
| 2085 | - * |
|
| 2086 | - * @access public |
|
| 2087 | - */ |
|
| 2088 | - public function __construct() |
|
| 2089 | - { |
|
| 2090 | - // set default organization settings |
|
| 2091 | - $this->name = get_bloginfo('name'); |
|
| 2092 | - $this->address_1 = '123 Onna Road'; |
|
| 2093 | - $this->address_2 = 'PO Box 123'; |
|
| 2094 | - $this->city = 'Inna City'; |
|
| 2095 | - $this->STA_ID = 4; |
|
| 2096 | - $this->CNT_ISO = 'US'; |
|
| 2097 | - $this->zip = '12345'; |
|
| 2098 | - $this->email = get_bloginfo('admin_email'); |
|
| 2099 | - $this->phone = ''; |
|
| 2100 | - $this->vat = '123456789'; |
|
| 2101 | - $this->logo_url = ''; |
|
| 2102 | - $this->facebook = ''; |
|
| 2103 | - $this->twitter = ''; |
|
| 2104 | - $this->linkedin = ''; |
|
| 2105 | - $this->pinterest = ''; |
|
| 2106 | - $this->google = ''; |
|
| 2107 | - $this->instagram = ''; |
|
| 2108 | - } |
|
| 2109 | - |
|
| 2110 | -} |
|
| 2111 | - |
|
| 2112 | - |
|
| 2113 | - |
|
| 2114 | -/** |
|
| 2115 | - * Class for defining what's in the EE_Config relating to currency |
|
| 2116 | - */ |
|
| 2117 | -class EE_Currency_Config extends EE_Config_Base |
|
| 2118 | -{ |
|
| 2119 | - |
|
| 2120 | - /** |
|
| 2121 | - * @var string $code |
|
| 2122 | - * eg 'US' |
|
| 2123 | - */ |
|
| 2124 | - public $code; |
|
| 2125 | - |
|
| 2126 | - /** |
|
| 2127 | - * @var string $name |
|
| 2128 | - * eg 'Dollar' |
|
| 2129 | - */ |
|
| 2130 | - public $name; |
|
| 2131 | - |
|
| 2132 | - /** |
|
| 2133 | - * plural name |
|
| 2134 | - * |
|
| 2135 | - * @var string $plural |
|
| 2136 | - * eg 'Dollars' |
|
| 2137 | - */ |
|
| 2138 | - public $plural; |
|
| 2139 | - |
|
| 2140 | - /** |
|
| 2141 | - * currency sign |
|
| 2142 | - * |
|
| 2143 | - * @var string $sign |
|
| 2144 | - * eg '$' |
|
| 2145 | - */ |
|
| 2146 | - public $sign; |
|
| 2147 | - |
|
| 2148 | - /** |
|
| 2149 | - * Whether the currency sign should come before the number or not |
|
| 2150 | - * |
|
| 2151 | - * @var boolean $sign_b4 |
|
| 2152 | - */ |
|
| 2153 | - public $sign_b4; |
|
| 2154 | - |
|
| 2155 | - /** |
|
| 2156 | - * How many digits should come after the decimal place |
|
| 2157 | - * |
|
| 2158 | - * @var int $dec_plc |
|
| 2159 | - */ |
|
| 2160 | - public $dec_plc; |
|
| 2161 | - |
|
| 2162 | - /** |
|
| 2163 | - * Symbol to use for decimal mark |
|
| 2164 | - * |
|
| 2165 | - * @var string $dec_mrk |
|
| 2166 | - * eg '.' |
|
| 2167 | - */ |
|
| 2168 | - public $dec_mrk; |
|
| 2169 | - |
|
| 2170 | - /** |
|
| 2171 | - * Symbol to use for thousands |
|
| 2172 | - * |
|
| 2173 | - * @var string $thsnds |
|
| 2174 | - * eg ',' |
|
| 2175 | - */ |
|
| 2176 | - public $thsnds; |
|
| 2177 | - |
|
| 2178 | - |
|
| 2179 | - |
|
| 2180 | - /** |
|
| 2181 | - * class constructor |
|
| 2182 | - * |
|
| 2183 | - * @access public |
|
| 2184 | - * @param string $CNT_ISO |
|
| 2185 | - * @throws \EE_Error |
|
| 2186 | - */ |
|
| 2187 | - public function __construct($CNT_ISO = '') |
|
| 2188 | - { |
|
| 2189 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2190 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2191 | - // get country code from organization settings or use default |
|
| 2192 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2193 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2194 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2195 | - : ''; |
|
| 2196 | - // but override if requested |
|
| 2197 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2198 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2199 | - if ( |
|
| 2200 | - ! empty($CNT_ISO) |
|
| 2201 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2202 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2203 | - ) { |
|
| 2204 | - // retrieve the country settings from the db, just in case they have been customized |
|
| 2205 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2206 | - if ($country instanceof EE_Country) { |
|
| 2207 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2208 | - $this->name = $country->currency_name_single(); // Dollar |
|
| 2209 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2210 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2211 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2212 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2213 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2214 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2215 | - } |
|
| 2216 | - } |
|
| 2217 | - // fallback to hardcoded defaults, in case the above failed |
|
| 2218 | - if (empty($this->code)) { |
|
| 2219 | - // set default currency settings |
|
| 2220 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2221 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2222 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2223 | - $this->sign = '$'; // currency sign: $ |
|
| 2224 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2225 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2226 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2227 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2228 | - } |
|
| 2229 | - } |
|
| 2230 | -} |
|
| 2231 | - |
|
| 2232 | - |
|
| 2233 | - |
|
| 2234 | -/** |
|
| 2235 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 2236 | - */ |
|
| 2237 | -class EE_Registration_Config extends EE_Config_Base |
|
| 2238 | -{ |
|
| 2239 | - |
|
| 2240 | - /** |
|
| 2241 | - * Default registration status |
|
| 2242 | - * |
|
| 2243 | - * @var string $default_STS_ID |
|
| 2244 | - * eg 'RPP' |
|
| 2245 | - */ |
|
| 2246 | - public $default_STS_ID; |
|
| 2247 | - |
|
| 2248 | - |
|
| 2249 | - /** |
|
| 2250 | - * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
| 2251 | - * registrations) |
|
| 2252 | - * @var int |
|
| 2253 | - */ |
|
| 2254 | - public $default_maximum_number_of_tickets; |
|
| 2255 | - |
|
| 2256 | - |
|
| 2257 | - /** |
|
| 2258 | - * level of validation to apply to email addresses |
|
| 2259 | - * |
|
| 2260 | - * @var string $email_validation_level |
|
| 2261 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2262 | - */ |
|
| 2263 | - public $email_validation_level; |
|
| 2264 | - |
|
| 2265 | - /** |
|
| 2266 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2267 | - * |
|
| 2268 | - * @var boolean $show_pending_payment_options |
|
| 2269 | - */ |
|
| 2270 | - public $show_pending_payment_options; |
|
| 2271 | - |
|
| 2272 | - /** |
|
| 2273 | - * Whether to skip the registration confirmation page |
|
| 2274 | - * |
|
| 2275 | - * @var boolean $skip_reg_confirmation |
|
| 2276 | - */ |
|
| 2277 | - public $skip_reg_confirmation; |
|
| 2278 | - |
|
| 2279 | - /** |
|
| 2280 | - * an array of SPCO reg steps where: |
|
| 2281 | - * the keys denotes the reg step order |
|
| 2282 | - * each element consists of an array with the following elements: |
|
| 2283 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2284 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2285 | - * "slug" => the URL param used to trigger the reg step |
|
| 2286 | - * |
|
| 2287 | - * @var array $reg_steps |
|
| 2288 | - */ |
|
| 2289 | - public $reg_steps; |
|
| 2290 | - |
|
| 2291 | - /** |
|
| 2292 | - * Whether registration confirmation should be the last page of SPCO |
|
| 2293 | - * |
|
| 2294 | - * @var boolean $reg_confirmation_last |
|
| 2295 | - */ |
|
| 2296 | - public $reg_confirmation_last; |
|
| 2297 | - |
|
| 2298 | - /** |
|
| 2299 | - * Whether or not to enable the EE Bot Trap |
|
| 2300 | - * |
|
| 2301 | - * @var boolean $use_bot_trap |
|
| 2302 | - */ |
|
| 2303 | - public $use_bot_trap; |
|
| 2304 | - |
|
| 2305 | - /** |
|
| 2306 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2307 | - * |
|
| 2308 | - * @var boolean $use_encryption |
|
| 2309 | - */ |
|
| 2310 | - public $use_encryption; |
|
| 1544 | +} |
|
| 2311 | 1545 | |
| 2312 | - /** |
|
| 2313 | - * Whether or not to use ReCaptcha |
|
| 2314 | - * |
|
| 2315 | - * @var boolean $use_captcha |
|
| 2316 | - */ |
|
| 2317 | - public $use_captcha; |
|
| 2318 | 1546 | |
| 2319 | - /** |
|
| 2320 | - * ReCaptcha Theme |
|
| 2321 | - * |
|
| 2322 | - * @var string $recaptcha_theme |
|
| 2323 | - * options: 'dark ', 'light' |
|
| 2324 | - */ |
|
| 2325 | - public $recaptcha_theme; |
|
| 2326 | 1547 | |
| 2327 | - /** |
|
| 2328 | - * ReCaptcha Type |
|
| 2329 | - * |
|
| 2330 | - * @var string $recaptcha_type |
|
| 2331 | - * options: 'audio', 'image' |
|
| 2332 | - */ |
|
| 2333 | - public $recaptcha_type; |
|
| 1548 | +/** |
|
| 1549 | + * Base class used for config classes. These classes should generally not have |
|
| 1550 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1551 | + * basically, they should just be well-defined stdClasses |
|
| 1552 | + */ |
|
| 1553 | +class EE_Config_Base |
|
| 1554 | +{ |
|
| 2334 | 1555 | |
| 2335 | - /** |
|
| 2336 | - * ReCaptcha language |
|
| 2337 | - * |
|
| 2338 | - * @var string $recaptcha_language |
|
| 2339 | - * eg 'en' |
|
| 2340 | - */ |
|
| 2341 | - public $recaptcha_language; |
|
| 1556 | + /** |
|
| 1557 | + * Utility function for escaping the value of a property and returning. |
|
| 1558 | + * |
|
| 1559 | + * @param string $property property name (checks to see if exists). |
|
| 1560 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1561 | + * @throws \EE_Error |
|
| 1562 | + */ |
|
| 1563 | + public function get_pretty($property) |
|
| 1564 | + { |
|
| 1565 | + if (! property_exists($this, $property)) { |
|
| 1566 | + throw new EE_Error( |
|
| 1567 | + sprintf( |
|
| 1568 | + __( |
|
| 1569 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1570 | + 'event_espresso' |
|
| 1571 | + ), |
|
| 1572 | + get_class($this), |
|
| 1573 | + $property |
|
| 1574 | + ) |
|
| 1575 | + ); |
|
| 1576 | + } |
|
| 1577 | + //just handling escaping of strings for now. |
|
| 1578 | + if (is_string($this->{$property})) { |
|
| 1579 | + return stripslashes($this->{$property}); |
|
| 1580 | + } |
|
| 1581 | + return $this->{$property}; |
|
| 1582 | + } |
|
| 1583 | + |
|
| 1584 | + |
|
| 1585 | + |
|
| 1586 | + public function populate() |
|
| 1587 | + { |
|
| 1588 | + //grab defaults via a new instance of this class. |
|
| 1589 | + $class_name = get_class($this); |
|
| 1590 | + $defaults = new $class_name; |
|
| 1591 | + //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1592 | + //default from our $defaults object. |
|
| 1593 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1594 | + if ($this->{$property} === null) { |
|
| 1595 | + $this->{$property} = $value; |
|
| 1596 | + } |
|
| 1597 | + } |
|
| 1598 | + //cleanup |
|
| 1599 | + unset($defaults); |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + |
|
| 1603 | + |
|
| 1604 | + /** |
|
| 1605 | + * __isset |
|
| 1606 | + * |
|
| 1607 | + * @param $a |
|
| 1608 | + * @return bool |
|
| 1609 | + */ |
|
| 1610 | + public function __isset($a) |
|
| 1611 | + { |
|
| 1612 | + return false; |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + |
|
| 1616 | + |
|
| 1617 | + /** |
|
| 1618 | + * __unset |
|
| 1619 | + * |
|
| 1620 | + * @param $a |
|
| 1621 | + * @return bool |
|
| 1622 | + */ |
|
| 1623 | + public function __unset($a) |
|
| 1624 | + { |
|
| 1625 | + return false; |
|
| 1626 | + } |
|
| 1627 | + |
|
| 1628 | + |
|
| 1629 | + |
|
| 1630 | + /** |
|
| 1631 | + * __clone |
|
| 1632 | + */ |
|
| 1633 | + public function __clone() |
|
| 1634 | + { |
|
| 1635 | + } |
|
| 1636 | + |
|
| 1637 | + |
|
| 1638 | + |
|
| 1639 | + /** |
|
| 1640 | + * __wakeup |
|
| 1641 | + */ |
|
| 1642 | + public function __wakeup() |
|
| 1643 | + { |
|
| 1644 | + } |
|
| 1645 | + |
|
| 1646 | + |
|
| 1647 | + |
|
| 1648 | + /** |
|
| 1649 | + * __destruct |
|
| 1650 | + */ |
|
| 1651 | + public function __destruct() |
|
| 1652 | + { |
|
| 1653 | + } |
|
| 1654 | +} |
|
| 2342 | 1655 | |
| 2343 | - /** |
|
| 2344 | - * ReCaptcha public key |
|
| 2345 | - * |
|
| 2346 | - * @var string $recaptcha_publickey |
|
| 2347 | - */ |
|
| 2348 | - public $recaptcha_publickey; |
|
| 2349 | 1656 | |
| 2350 | - /** |
|
| 2351 | - * ReCaptcha private key |
|
| 2352 | - * |
|
| 2353 | - * @var string $recaptcha_privatekey |
|
| 2354 | - */ |
|
| 2355 | - public $recaptcha_privatekey; |
|
| 2356 | 1657 | |
| 2357 | - /** |
|
| 2358 | - * ReCaptcha width |
|
| 2359 | - * |
|
| 2360 | - * @var int $recaptcha_width |
|
| 2361 | - * @deprecated |
|
| 2362 | - */ |
|
| 2363 | - public $recaptcha_width; |
|
| 1658 | +/** |
|
| 1659 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 1660 | + */ |
|
| 1661 | +class EE_Core_Config extends EE_Config_Base |
|
| 1662 | +{ |
|
| 2364 | 1663 | |
| 2365 | - /** |
|
| 2366 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2367 | - * |
|
| 2368 | - * @var boolean $track_invalid_checkout_access |
|
| 2369 | - */ |
|
| 2370 | - protected $track_invalid_checkout_access = true; |
|
| 1664 | + public $current_blog_id; |
|
| 1665 | + |
|
| 1666 | + public $ee_ueip_optin; |
|
| 1667 | + |
|
| 1668 | + public $ee_ueip_has_notified; |
|
| 1669 | + |
|
| 1670 | + /** |
|
| 1671 | + * Not to be confused with the 4 critical page variables (See |
|
| 1672 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1673 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1674 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1675 | + * |
|
| 1676 | + * @var array |
|
| 1677 | + */ |
|
| 1678 | + public $post_shortcodes; |
|
| 1679 | + |
|
| 1680 | + public $module_route_map; |
|
| 1681 | + |
|
| 1682 | + public $module_forward_map; |
|
| 1683 | + |
|
| 1684 | + public $module_view_map; |
|
| 1685 | + |
|
| 1686 | + /** |
|
| 1687 | + * The next 4 vars are the IDs of critical EE pages. |
|
| 1688 | + * |
|
| 1689 | + * @var int |
|
| 1690 | + */ |
|
| 1691 | + public $reg_page_id; |
|
| 1692 | + |
|
| 1693 | + public $txn_page_id; |
|
| 1694 | + |
|
| 1695 | + public $thank_you_page_id; |
|
| 1696 | + |
|
| 1697 | + public $cancel_page_id; |
|
| 1698 | + |
|
| 1699 | + /** |
|
| 1700 | + * The next 4 vars are the URLs of critical EE pages. |
|
| 1701 | + * |
|
| 1702 | + * @var int |
|
| 1703 | + */ |
|
| 1704 | + public $reg_page_url; |
|
| 1705 | + |
|
| 1706 | + public $txn_page_url; |
|
| 1707 | + |
|
| 1708 | + public $thank_you_page_url; |
|
| 1709 | + |
|
| 1710 | + public $cancel_page_url; |
|
| 1711 | + |
|
| 1712 | + /** |
|
| 1713 | + * The next vars relate to the custom slugs for EE CPT routes |
|
| 1714 | + */ |
|
| 1715 | + public $event_cpt_slug; |
|
| 1716 | + |
|
| 1717 | + |
|
| 1718 | + /** |
|
| 1719 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1720 | + * request across blog switches in a multisite context. |
|
| 1721 | + * Avoids extra queries to the db for this option. |
|
| 1722 | + * |
|
| 1723 | + * @var bool |
|
| 1724 | + */ |
|
| 1725 | + public static $ee_ueip_option; |
|
| 1726 | + |
|
| 1727 | + |
|
| 1728 | + |
|
| 1729 | + /** |
|
| 1730 | + * class constructor |
|
| 1731 | + * |
|
| 1732 | + * @access public |
|
| 1733 | + */ |
|
| 1734 | + public function __construct() |
|
| 1735 | + { |
|
| 1736 | + // set default organization settings |
|
| 1737 | + $this->current_blog_id = get_current_blog_id(); |
|
| 1738 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1739 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1740 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1741 | + $this->post_shortcodes = array(); |
|
| 1742 | + $this->module_route_map = array(); |
|
| 1743 | + $this->module_forward_map = array(); |
|
| 1744 | + $this->module_view_map = array(); |
|
| 1745 | + // critical EE page IDs |
|
| 1746 | + $this->reg_page_id = 0; |
|
| 1747 | + $this->txn_page_id = 0; |
|
| 1748 | + $this->thank_you_page_id = 0; |
|
| 1749 | + $this->cancel_page_id = 0; |
|
| 1750 | + // critical EE page URLs |
|
| 1751 | + $this->reg_page_url = ''; |
|
| 1752 | + $this->txn_page_url = ''; |
|
| 1753 | + $this->thank_you_page_url = ''; |
|
| 1754 | + $this->cancel_page_url = ''; |
|
| 1755 | + //cpt slugs |
|
| 1756 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1757 | + //ueip constant check |
|
| 1758 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1759 | + $this->ee_ueip_optin = false; |
|
| 1760 | + $this->ee_ueip_has_notified = true; |
|
| 1761 | + } |
|
| 1762 | + } |
|
| 1763 | + |
|
| 1764 | + |
|
| 1765 | + |
|
| 1766 | + /** |
|
| 1767 | + * @return array |
|
| 1768 | + */ |
|
| 1769 | + public function get_critical_pages_array() |
|
| 1770 | + { |
|
| 1771 | + return array( |
|
| 1772 | + $this->reg_page_id, |
|
| 1773 | + $this->txn_page_id, |
|
| 1774 | + $this->thank_you_page_id, |
|
| 1775 | + $this->cancel_page_id, |
|
| 1776 | + ); |
|
| 1777 | + } |
|
| 1778 | + |
|
| 1779 | + |
|
| 1780 | + |
|
| 1781 | + /** |
|
| 1782 | + * @return array |
|
| 1783 | + */ |
|
| 1784 | + public function get_critical_pages_shortcodes_array() |
|
| 1785 | + { |
|
| 1786 | + return array( |
|
| 1787 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1788 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1789 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1790 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1791 | + ); |
|
| 1792 | + } |
|
| 1793 | + |
|
| 1794 | + |
|
| 1795 | + |
|
| 1796 | + /** |
|
| 1797 | + * gets/returns URL for EE reg_page |
|
| 1798 | + * |
|
| 1799 | + * @access public |
|
| 1800 | + * @return string |
|
| 1801 | + */ |
|
| 1802 | + public function reg_page_url() |
|
| 1803 | + { |
|
| 1804 | + if (! $this->reg_page_url) { |
|
| 1805 | + $this->reg_page_url = add_query_arg( |
|
| 1806 | + array('uts' => time()), |
|
| 1807 | + get_permalink($this->reg_page_id) |
|
| 1808 | + ) . '#checkout'; |
|
| 1809 | + } |
|
| 1810 | + return $this->reg_page_url; |
|
| 1811 | + } |
|
| 1812 | + |
|
| 1813 | + |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * gets/returns URL for EE txn_page |
|
| 1817 | + * |
|
| 1818 | + * @param array $query_args like what gets passed to |
|
| 1819 | + * add_query_arg() as the first argument |
|
| 1820 | + * @access public |
|
| 1821 | + * @return string |
|
| 1822 | + */ |
|
| 1823 | + public function txn_page_url($query_args = array()) |
|
| 1824 | + { |
|
| 1825 | + if (! $this->txn_page_url) { |
|
| 1826 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1827 | + } |
|
| 1828 | + if ($query_args) { |
|
| 1829 | + return add_query_arg($query_args, $this->txn_page_url); |
|
| 1830 | + } else { |
|
| 1831 | + return $this->txn_page_url; |
|
| 1832 | + } |
|
| 1833 | + } |
|
| 1834 | + |
|
| 1835 | + |
|
| 1836 | + |
|
| 1837 | + /** |
|
| 1838 | + * gets/returns URL for EE thank_you_page |
|
| 1839 | + * |
|
| 1840 | + * @param array $query_args like what gets passed to |
|
| 1841 | + * add_query_arg() as the first argument |
|
| 1842 | + * @access public |
|
| 1843 | + * @return string |
|
| 1844 | + */ |
|
| 1845 | + public function thank_you_page_url($query_args = array()) |
|
| 1846 | + { |
|
| 1847 | + if (! $this->thank_you_page_url) { |
|
| 1848 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1849 | + } |
|
| 1850 | + if ($query_args) { |
|
| 1851 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1852 | + } else { |
|
| 1853 | + return $this->thank_you_page_url; |
|
| 1854 | + } |
|
| 1855 | + } |
|
| 1856 | + |
|
| 1857 | + |
|
| 1858 | + |
|
| 1859 | + /** |
|
| 1860 | + * gets/returns URL for EE cancel_page |
|
| 1861 | + * |
|
| 1862 | + * @access public |
|
| 1863 | + * @return string |
|
| 1864 | + */ |
|
| 1865 | + public function cancel_page_url() |
|
| 1866 | + { |
|
| 1867 | + if (! $this->cancel_page_url) { |
|
| 1868 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1869 | + } |
|
| 1870 | + return $this->cancel_page_url; |
|
| 1871 | + } |
|
| 1872 | + |
|
| 1873 | + |
|
| 1874 | + |
|
| 1875 | + /** |
|
| 1876 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1877 | + * |
|
| 1878 | + * @since 4.7.5 |
|
| 1879 | + */ |
|
| 1880 | + protected function _reset_urls() |
|
| 1881 | + { |
|
| 1882 | + $this->reg_page_url = ''; |
|
| 1883 | + $this->txn_page_url = ''; |
|
| 1884 | + $this->cancel_page_url = ''; |
|
| 1885 | + $this->thank_you_page_url = ''; |
|
| 1886 | + } |
|
| 1887 | + |
|
| 1888 | + |
|
| 1889 | + |
|
| 1890 | + /** |
|
| 1891 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1892 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1893 | + * on the main site only. |
|
| 1894 | + * |
|
| 1895 | + * @return mixed|void |
|
| 1896 | + */ |
|
| 1897 | + protected function _get_main_ee_ueip_optin() |
|
| 1898 | + { |
|
| 1899 | + //if this is the main site then we can just bypass our direct query. |
|
| 1900 | + if (is_main_site()) { |
|
| 1901 | + return get_option('ee_ueip_optin', false); |
|
| 1902 | + } |
|
| 1903 | + //is this already cached for this request? If so use it. |
|
| 1904 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
| 1905 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1906 | + } |
|
| 1907 | + global $wpdb; |
|
| 1908 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1909 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1910 | + $option = 'ee_ueip_optin'; |
|
| 1911 | + //set correct table for query |
|
| 1912 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1913 | + //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1914 | + //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1915 | + //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1916 | + //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1917 | + //for the purpose of caching. |
|
| 1918 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1919 | + if (false !== $pre) { |
|
| 1920 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
| 1921 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1922 | + } |
|
| 1923 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 1924 | + $option)); |
|
| 1925 | + if (is_object($row)) { |
|
| 1926 | + $value = $row->option_value; |
|
| 1927 | + } else { //option does not exist so use default. |
|
| 1928 | + return apply_filters('default_option_' . $option, false, $option); |
|
| 1929 | + } |
|
| 1930 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 1931 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1932 | + } |
|
| 1933 | + |
|
| 1934 | + |
|
| 1935 | + |
|
| 1936 | + /** |
|
| 1937 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 1938 | + * on the object. |
|
| 1939 | + * |
|
| 1940 | + * @return array |
|
| 1941 | + */ |
|
| 1942 | + public function __sleep() |
|
| 1943 | + { |
|
| 1944 | + //reset all url properties |
|
| 1945 | + $this->_reset_urls(); |
|
| 1946 | + //return what to save to db |
|
| 1947 | + return array_keys(get_object_vars($this)); |
|
| 1948 | + } |
|
| 2371 | 1949 | |
| 1950 | +} |
|
| 2372 | 1951 | |
| 2373 | 1952 | |
| 2374 | - /** |
|
| 2375 | - * class constructor |
|
| 2376 | - * |
|
| 2377 | - * @access public |
|
| 2378 | - */ |
|
| 2379 | - public function __construct() |
|
| 2380 | - { |
|
| 2381 | - // set default registration settings |
|
| 2382 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2383 | - $this->email_validation_level = 'wp_default'; |
|
| 2384 | - $this->show_pending_payment_options = true; |
|
| 2385 | - $this->skip_reg_confirmation = false; |
|
| 2386 | - $this->reg_steps = array(); |
|
| 2387 | - $this->reg_confirmation_last = false; |
|
| 2388 | - $this->use_bot_trap = true; |
|
| 2389 | - $this->use_encryption = true; |
|
| 2390 | - $this->use_captcha = false; |
|
| 2391 | - $this->recaptcha_theme = 'light'; |
|
| 2392 | - $this->recaptcha_type = 'image'; |
|
| 2393 | - $this->recaptcha_language = 'en'; |
|
| 2394 | - $this->recaptcha_publickey = null; |
|
| 2395 | - $this->recaptcha_privatekey = null; |
|
| 2396 | - $this->recaptcha_width = 500; |
|
| 2397 | - $this->default_maximum_number_of_tickets = 10; |
|
| 2398 | - } |
|
| 2399 | - |
|
| 2400 | - |
|
| 2401 | - |
|
| 2402 | - /** |
|
| 2403 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2404 | - * |
|
| 2405 | - * @since 4.8.8.rc.019 |
|
| 2406 | - */ |
|
| 2407 | - public function do_hooks() |
|
| 2408 | - { |
|
| 2409 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2410 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
| 2411 | - } |
|
| 2412 | 1953 | |
| 1954 | +/** |
|
| 1955 | + * Config class for storing info on the Organization |
|
| 1956 | + */ |
|
| 1957 | +class EE_Organization_Config extends EE_Config_Base |
|
| 1958 | +{ |
|
| 2413 | 1959 | |
| 1960 | + /** |
|
| 1961 | + * @var string $name |
|
| 1962 | + * eg EE4.1 |
|
| 1963 | + */ |
|
| 1964 | + public $name; |
|
| 1965 | + |
|
| 1966 | + /** |
|
| 1967 | + * @var string $address_1 |
|
| 1968 | + * eg 123 Onna Road |
|
| 1969 | + */ |
|
| 1970 | + public $address_1; |
|
| 1971 | + |
|
| 1972 | + /** |
|
| 1973 | + * @var string $address_2 |
|
| 1974 | + * eg PO Box 123 |
|
| 1975 | + */ |
|
| 1976 | + public $address_2; |
|
| 1977 | + |
|
| 1978 | + /** |
|
| 1979 | + * @var string $city |
|
| 1980 | + * eg Inna City |
|
| 1981 | + */ |
|
| 1982 | + public $city; |
|
| 1983 | + |
|
| 1984 | + /** |
|
| 1985 | + * @var int $STA_ID |
|
| 1986 | + * eg 4 |
|
| 1987 | + */ |
|
| 1988 | + public $STA_ID; |
|
| 1989 | + |
|
| 1990 | + /** |
|
| 1991 | + * @var string $CNT_ISO |
|
| 1992 | + * eg US |
|
| 1993 | + */ |
|
| 1994 | + public $CNT_ISO; |
|
| 1995 | + |
|
| 1996 | + /** |
|
| 1997 | + * @var string $zip |
|
| 1998 | + * eg 12345 or V1A 2B3 |
|
| 1999 | + */ |
|
| 2000 | + public $zip; |
|
| 2001 | + |
|
| 2002 | + /** |
|
| 2003 | + * @var string $email |
|
| 2004 | + * eg [email protected] |
|
| 2005 | + */ |
|
| 2006 | + public $email; |
|
| 2007 | + |
|
| 2008 | + |
|
| 2009 | + /** |
|
| 2010 | + * @var string $phone |
|
| 2011 | + * eg. 111-111-1111 |
|
| 2012 | + */ |
|
| 2013 | + public $phone; |
|
| 2014 | + |
|
| 2015 | + |
|
| 2016 | + /** |
|
| 2017 | + * @var string $vat |
|
| 2018 | + * VAT/Tax Number |
|
| 2019 | + */ |
|
| 2020 | + public $vat; |
|
| 2021 | + |
|
| 2022 | + /** |
|
| 2023 | + * @var string $logo_url |
|
| 2024 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 2025 | + */ |
|
| 2026 | + public $logo_url; |
|
| 2027 | + |
|
| 2028 | + |
|
| 2029 | + /** |
|
| 2030 | + * The below are all various properties for holding links to organization social network profiles |
|
| 2031 | + * |
|
| 2032 | + * @var string |
|
| 2033 | + */ |
|
| 2034 | + /** |
|
| 2035 | + * facebook (facebook.com/profile.name) |
|
| 2036 | + * |
|
| 2037 | + * @var string |
|
| 2038 | + */ |
|
| 2039 | + public $facebook; |
|
| 2040 | + |
|
| 2041 | + |
|
| 2042 | + /** |
|
| 2043 | + * twitter (twitter.com/twitter_handle) |
|
| 2044 | + * |
|
| 2045 | + * @var string |
|
| 2046 | + */ |
|
| 2047 | + public $twitter; |
|
| 2048 | + |
|
| 2049 | + |
|
| 2050 | + /** |
|
| 2051 | + * linkedin (linkedin.com/in/profile_name) |
|
| 2052 | + * |
|
| 2053 | + * @var string |
|
| 2054 | + */ |
|
| 2055 | + public $linkedin; |
|
| 2056 | + |
|
| 2057 | + |
|
| 2058 | + /** |
|
| 2059 | + * pinterest (www.pinterest.com/profile_name) |
|
| 2060 | + * |
|
| 2061 | + * @var string |
|
| 2062 | + */ |
|
| 2063 | + public $pinterest; |
|
| 2064 | + |
|
| 2065 | + |
|
| 2066 | + /** |
|
| 2067 | + * google+ (google.com/+profileName) |
|
| 2068 | + * |
|
| 2069 | + * @var string |
|
| 2070 | + */ |
|
| 2071 | + public $google; |
|
| 2072 | + |
|
| 2073 | + |
|
| 2074 | + /** |
|
| 2075 | + * instagram (instagram.com/handle) |
|
| 2076 | + * |
|
| 2077 | + * @var string |
|
| 2078 | + */ |
|
| 2079 | + public $instagram; |
|
| 2080 | + |
|
| 2081 | + |
|
| 2082 | + |
|
| 2083 | + /** |
|
| 2084 | + * class constructor |
|
| 2085 | + * |
|
| 2086 | + * @access public |
|
| 2087 | + */ |
|
| 2088 | + public function __construct() |
|
| 2089 | + { |
|
| 2090 | + // set default organization settings |
|
| 2091 | + $this->name = get_bloginfo('name'); |
|
| 2092 | + $this->address_1 = '123 Onna Road'; |
|
| 2093 | + $this->address_2 = 'PO Box 123'; |
|
| 2094 | + $this->city = 'Inna City'; |
|
| 2095 | + $this->STA_ID = 4; |
|
| 2096 | + $this->CNT_ISO = 'US'; |
|
| 2097 | + $this->zip = '12345'; |
|
| 2098 | + $this->email = get_bloginfo('admin_email'); |
|
| 2099 | + $this->phone = ''; |
|
| 2100 | + $this->vat = '123456789'; |
|
| 2101 | + $this->logo_url = ''; |
|
| 2102 | + $this->facebook = ''; |
|
| 2103 | + $this->twitter = ''; |
|
| 2104 | + $this->linkedin = ''; |
|
| 2105 | + $this->pinterest = ''; |
|
| 2106 | + $this->google = ''; |
|
| 2107 | + $this->instagram = ''; |
|
| 2108 | + } |
|
| 2414 | 2109 | |
| 2415 | - /** |
|
| 2416 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status |
|
| 2417 | - * field matches the config setting for default_STS_ID. |
|
| 2418 | - */ |
|
| 2419 | - public function set_default_reg_status_on_EEM_Event() |
|
| 2420 | - { |
|
| 2421 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2422 | - } |
|
| 2110 | +} |
|
| 2423 | 2111 | |
| 2424 | 2112 | |
| 2425 | - /** |
|
| 2426 | - * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
| 2427 | - * for Events matches the config setting for default_maximum_number_of_tickets |
|
| 2428 | - */ |
|
| 2429 | - public function set_default_max_ticket_on_EEM_Event() |
|
| 2430 | - { |
|
| 2431 | - EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
| 2432 | - } |
|
| 2433 | 2113 | |
| 2114 | +/** |
|
| 2115 | + * Class for defining what's in the EE_Config relating to currency |
|
| 2116 | + */ |
|
| 2117 | +class EE_Currency_Config extends EE_Config_Base |
|
| 2118 | +{ |
|
| 2434 | 2119 | |
| 2120 | + /** |
|
| 2121 | + * @var string $code |
|
| 2122 | + * eg 'US' |
|
| 2123 | + */ |
|
| 2124 | + public $code; |
|
| 2125 | + |
|
| 2126 | + /** |
|
| 2127 | + * @var string $name |
|
| 2128 | + * eg 'Dollar' |
|
| 2129 | + */ |
|
| 2130 | + public $name; |
|
| 2131 | + |
|
| 2132 | + /** |
|
| 2133 | + * plural name |
|
| 2134 | + * |
|
| 2135 | + * @var string $plural |
|
| 2136 | + * eg 'Dollars' |
|
| 2137 | + */ |
|
| 2138 | + public $plural; |
|
| 2139 | + |
|
| 2140 | + /** |
|
| 2141 | + * currency sign |
|
| 2142 | + * |
|
| 2143 | + * @var string $sign |
|
| 2144 | + * eg '$' |
|
| 2145 | + */ |
|
| 2146 | + public $sign; |
|
| 2147 | + |
|
| 2148 | + /** |
|
| 2149 | + * Whether the currency sign should come before the number or not |
|
| 2150 | + * |
|
| 2151 | + * @var boolean $sign_b4 |
|
| 2152 | + */ |
|
| 2153 | + public $sign_b4; |
|
| 2154 | + |
|
| 2155 | + /** |
|
| 2156 | + * How many digits should come after the decimal place |
|
| 2157 | + * |
|
| 2158 | + * @var int $dec_plc |
|
| 2159 | + */ |
|
| 2160 | + public $dec_plc; |
|
| 2161 | + |
|
| 2162 | + /** |
|
| 2163 | + * Symbol to use for decimal mark |
|
| 2164 | + * |
|
| 2165 | + * @var string $dec_mrk |
|
| 2166 | + * eg '.' |
|
| 2167 | + */ |
|
| 2168 | + public $dec_mrk; |
|
| 2169 | + |
|
| 2170 | + /** |
|
| 2171 | + * Symbol to use for thousands |
|
| 2172 | + * |
|
| 2173 | + * @var string $thsnds |
|
| 2174 | + * eg ',' |
|
| 2175 | + */ |
|
| 2176 | + public $thsnds; |
|
| 2177 | + |
|
| 2178 | + |
|
| 2179 | + |
|
| 2180 | + /** |
|
| 2181 | + * class constructor |
|
| 2182 | + * |
|
| 2183 | + * @access public |
|
| 2184 | + * @param string $CNT_ISO |
|
| 2185 | + * @throws \EE_Error |
|
| 2186 | + */ |
|
| 2187 | + public function __construct($CNT_ISO = '') |
|
| 2188 | + { |
|
| 2189 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2190 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2191 | + // get country code from organization settings or use default |
|
| 2192 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2193 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2194 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2195 | + : ''; |
|
| 2196 | + // but override if requested |
|
| 2197 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2198 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2199 | + if ( |
|
| 2200 | + ! empty($CNT_ISO) |
|
| 2201 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2202 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2203 | + ) { |
|
| 2204 | + // retrieve the country settings from the db, just in case they have been customized |
|
| 2205 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2206 | + if ($country instanceof EE_Country) { |
|
| 2207 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2208 | + $this->name = $country->currency_name_single(); // Dollar |
|
| 2209 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2210 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2211 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2212 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2213 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2214 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2215 | + } |
|
| 2216 | + } |
|
| 2217 | + // fallback to hardcoded defaults, in case the above failed |
|
| 2218 | + if (empty($this->code)) { |
|
| 2219 | + // set default currency settings |
|
| 2220 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2221 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2222 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2223 | + $this->sign = '$'; // currency sign: $ |
|
| 2224 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2225 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2226 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2227 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2228 | + } |
|
| 2229 | + } |
|
| 2230 | +} |
|
| 2435 | 2231 | |
| 2436 | - /** |
|
| 2437 | - * @return boolean |
|
| 2438 | - */ |
|
| 2439 | - public function track_invalid_checkout_access() |
|
| 2440 | - { |
|
| 2441 | - return $this->track_invalid_checkout_access; |
|
| 2442 | - } |
|
| 2443 | 2232 | |
| 2444 | 2233 | |
| 2234 | +/** |
|
| 2235 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 2236 | + */ |
|
| 2237 | +class EE_Registration_Config extends EE_Config_Base |
|
| 2238 | +{ |
|
| 2445 | 2239 | |
| 2446 | - /** |
|
| 2447 | - * @param boolean $track_invalid_checkout_access |
|
| 2448 | - */ |
|
| 2449 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2450 | - { |
|
| 2451 | - $this->track_invalid_checkout_access = filter_var( |
|
| 2452 | - $track_invalid_checkout_access, |
|
| 2453 | - FILTER_VALIDATE_BOOLEAN |
|
| 2454 | - ); |
|
| 2455 | - } |
|
| 2240 | + /** |
|
| 2241 | + * Default registration status |
|
| 2242 | + * |
|
| 2243 | + * @var string $default_STS_ID |
|
| 2244 | + * eg 'RPP' |
|
| 2245 | + */ |
|
| 2246 | + public $default_STS_ID; |
|
| 2247 | + |
|
| 2248 | + |
|
| 2249 | + /** |
|
| 2250 | + * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of |
|
| 2251 | + * registrations) |
|
| 2252 | + * @var int |
|
| 2253 | + */ |
|
| 2254 | + public $default_maximum_number_of_tickets; |
|
| 2255 | + |
|
| 2256 | + |
|
| 2257 | + /** |
|
| 2258 | + * level of validation to apply to email addresses |
|
| 2259 | + * |
|
| 2260 | + * @var string $email_validation_level |
|
| 2261 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2262 | + */ |
|
| 2263 | + public $email_validation_level; |
|
| 2264 | + |
|
| 2265 | + /** |
|
| 2266 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2267 | + * |
|
| 2268 | + * @var boolean $show_pending_payment_options |
|
| 2269 | + */ |
|
| 2270 | + public $show_pending_payment_options; |
|
| 2271 | + |
|
| 2272 | + /** |
|
| 2273 | + * Whether to skip the registration confirmation page |
|
| 2274 | + * |
|
| 2275 | + * @var boolean $skip_reg_confirmation |
|
| 2276 | + */ |
|
| 2277 | + public $skip_reg_confirmation; |
|
| 2278 | + |
|
| 2279 | + /** |
|
| 2280 | + * an array of SPCO reg steps where: |
|
| 2281 | + * the keys denotes the reg step order |
|
| 2282 | + * each element consists of an array with the following elements: |
|
| 2283 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2284 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2285 | + * "slug" => the URL param used to trigger the reg step |
|
| 2286 | + * |
|
| 2287 | + * @var array $reg_steps |
|
| 2288 | + */ |
|
| 2289 | + public $reg_steps; |
|
| 2290 | + |
|
| 2291 | + /** |
|
| 2292 | + * Whether registration confirmation should be the last page of SPCO |
|
| 2293 | + * |
|
| 2294 | + * @var boolean $reg_confirmation_last |
|
| 2295 | + */ |
|
| 2296 | + public $reg_confirmation_last; |
|
| 2297 | + |
|
| 2298 | + /** |
|
| 2299 | + * Whether or not to enable the EE Bot Trap |
|
| 2300 | + * |
|
| 2301 | + * @var boolean $use_bot_trap |
|
| 2302 | + */ |
|
| 2303 | + public $use_bot_trap; |
|
| 2304 | + |
|
| 2305 | + /** |
|
| 2306 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2307 | + * |
|
| 2308 | + * @var boolean $use_encryption |
|
| 2309 | + */ |
|
| 2310 | + public $use_encryption; |
|
| 2311 | + |
|
| 2312 | + /** |
|
| 2313 | + * Whether or not to use ReCaptcha |
|
| 2314 | + * |
|
| 2315 | + * @var boolean $use_captcha |
|
| 2316 | + */ |
|
| 2317 | + public $use_captcha; |
|
| 2318 | + |
|
| 2319 | + /** |
|
| 2320 | + * ReCaptcha Theme |
|
| 2321 | + * |
|
| 2322 | + * @var string $recaptcha_theme |
|
| 2323 | + * options: 'dark ', 'light' |
|
| 2324 | + */ |
|
| 2325 | + public $recaptcha_theme; |
|
| 2326 | + |
|
| 2327 | + /** |
|
| 2328 | + * ReCaptcha Type |
|
| 2329 | + * |
|
| 2330 | + * @var string $recaptcha_type |
|
| 2331 | + * options: 'audio', 'image' |
|
| 2332 | + */ |
|
| 2333 | + public $recaptcha_type; |
|
| 2334 | + |
|
| 2335 | + /** |
|
| 2336 | + * ReCaptcha language |
|
| 2337 | + * |
|
| 2338 | + * @var string $recaptcha_language |
|
| 2339 | + * eg 'en' |
|
| 2340 | + */ |
|
| 2341 | + public $recaptcha_language; |
|
| 2342 | + |
|
| 2343 | + /** |
|
| 2344 | + * ReCaptcha public key |
|
| 2345 | + * |
|
| 2346 | + * @var string $recaptcha_publickey |
|
| 2347 | + */ |
|
| 2348 | + public $recaptcha_publickey; |
|
| 2349 | + |
|
| 2350 | + /** |
|
| 2351 | + * ReCaptcha private key |
|
| 2352 | + * |
|
| 2353 | + * @var string $recaptcha_privatekey |
|
| 2354 | + */ |
|
| 2355 | + public $recaptcha_privatekey; |
|
| 2356 | + |
|
| 2357 | + /** |
|
| 2358 | + * ReCaptcha width |
|
| 2359 | + * |
|
| 2360 | + * @var int $recaptcha_width |
|
| 2361 | + * @deprecated |
|
| 2362 | + */ |
|
| 2363 | + public $recaptcha_width; |
|
| 2364 | + |
|
| 2365 | + /** |
|
| 2366 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2367 | + * |
|
| 2368 | + * @var boolean $track_invalid_checkout_access |
|
| 2369 | + */ |
|
| 2370 | + protected $track_invalid_checkout_access = true; |
|
| 2371 | + |
|
| 2372 | + |
|
| 2373 | + |
|
| 2374 | + /** |
|
| 2375 | + * class constructor |
|
| 2376 | + * |
|
| 2377 | + * @access public |
|
| 2378 | + */ |
|
| 2379 | + public function __construct() |
|
| 2380 | + { |
|
| 2381 | + // set default registration settings |
|
| 2382 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2383 | + $this->email_validation_level = 'wp_default'; |
|
| 2384 | + $this->show_pending_payment_options = true; |
|
| 2385 | + $this->skip_reg_confirmation = false; |
|
| 2386 | + $this->reg_steps = array(); |
|
| 2387 | + $this->reg_confirmation_last = false; |
|
| 2388 | + $this->use_bot_trap = true; |
|
| 2389 | + $this->use_encryption = true; |
|
| 2390 | + $this->use_captcha = false; |
|
| 2391 | + $this->recaptcha_theme = 'light'; |
|
| 2392 | + $this->recaptcha_type = 'image'; |
|
| 2393 | + $this->recaptcha_language = 'en'; |
|
| 2394 | + $this->recaptcha_publickey = null; |
|
| 2395 | + $this->recaptcha_privatekey = null; |
|
| 2396 | + $this->recaptcha_width = 500; |
|
| 2397 | + $this->default_maximum_number_of_tickets = 10; |
|
| 2398 | + } |
|
| 2399 | + |
|
| 2400 | + |
|
| 2401 | + |
|
| 2402 | + /** |
|
| 2403 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2404 | + * |
|
| 2405 | + * @since 4.8.8.rc.019 |
|
| 2406 | + */ |
|
| 2407 | + public function do_hooks() |
|
| 2408 | + { |
|
| 2409 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2410 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event')); |
|
| 2411 | + } |
|
| 2412 | + |
|
| 2413 | + |
|
| 2414 | + |
|
| 2415 | + /** |
|
| 2416 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status |
|
| 2417 | + * field matches the config setting for default_STS_ID. |
|
| 2418 | + */ |
|
| 2419 | + public function set_default_reg_status_on_EEM_Event() |
|
| 2420 | + { |
|
| 2421 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2422 | + } |
|
| 2423 | + |
|
| 2424 | + |
|
| 2425 | + /** |
|
| 2426 | + * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field |
|
| 2427 | + * for Events matches the config setting for default_maximum_number_of_tickets |
|
| 2428 | + */ |
|
| 2429 | + public function set_default_max_ticket_on_EEM_Event() |
|
| 2430 | + { |
|
| 2431 | + EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets); |
|
| 2432 | + } |
|
| 2433 | + |
|
| 2434 | + |
|
| 2435 | + |
|
| 2436 | + /** |
|
| 2437 | + * @return boolean |
|
| 2438 | + */ |
|
| 2439 | + public function track_invalid_checkout_access() |
|
| 2440 | + { |
|
| 2441 | + return $this->track_invalid_checkout_access; |
|
| 2442 | + } |
|
| 2443 | + |
|
| 2444 | + |
|
| 2445 | + |
|
| 2446 | + /** |
|
| 2447 | + * @param boolean $track_invalid_checkout_access |
|
| 2448 | + */ |
|
| 2449 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2450 | + { |
|
| 2451 | + $this->track_invalid_checkout_access = filter_var( |
|
| 2452 | + $track_invalid_checkout_access, |
|
| 2453 | + FILTER_VALIDATE_BOOLEAN |
|
| 2454 | + ); |
|
| 2455 | + } |
|
| 2456 | 2456 | |
| 2457 | 2457 | |
| 2458 | 2458 | |
@@ -2466,160 +2466,160 @@ discard block |
||
| 2466 | 2466 | class EE_Admin_Config extends EE_Config_Base |
| 2467 | 2467 | { |
| 2468 | 2468 | |
| 2469 | - /** |
|
| 2470 | - * @var boolean $use_personnel_manager |
|
| 2471 | - */ |
|
| 2472 | - public $use_personnel_manager; |
|
| 2473 | - |
|
| 2474 | - /** |
|
| 2475 | - * @var boolean $use_dashboard_widget |
|
| 2476 | - */ |
|
| 2477 | - public $use_dashboard_widget; |
|
| 2478 | - |
|
| 2479 | - /** |
|
| 2480 | - * @var int $events_in_dashboard |
|
| 2481 | - */ |
|
| 2482 | - public $events_in_dashboard; |
|
| 2483 | - |
|
| 2484 | - /** |
|
| 2485 | - * @var boolean $use_event_timezones |
|
| 2486 | - */ |
|
| 2487 | - public $use_event_timezones; |
|
| 2488 | - |
|
| 2489 | - /** |
|
| 2490 | - * @var boolean $use_full_logging |
|
| 2491 | - */ |
|
| 2492 | - public $use_full_logging; |
|
| 2493 | - |
|
| 2494 | - /** |
|
| 2495 | - * @var string $log_file_name |
|
| 2496 | - */ |
|
| 2497 | - public $log_file_name; |
|
| 2498 | - |
|
| 2499 | - /** |
|
| 2500 | - * @var string $debug_file_name |
|
| 2501 | - */ |
|
| 2502 | - public $debug_file_name; |
|
| 2503 | - |
|
| 2504 | - /** |
|
| 2505 | - * @var boolean $use_remote_logging |
|
| 2506 | - */ |
|
| 2507 | - public $use_remote_logging; |
|
| 2508 | - |
|
| 2509 | - /** |
|
| 2510 | - * @var string $remote_logging_url |
|
| 2511 | - */ |
|
| 2512 | - public $remote_logging_url; |
|
| 2513 | - |
|
| 2514 | - /** |
|
| 2515 | - * @var boolean $show_reg_footer |
|
| 2516 | - */ |
|
| 2517 | - public $show_reg_footer; |
|
| 2518 | - |
|
| 2519 | - /** |
|
| 2520 | - * @var string $affiliate_id |
|
| 2521 | - */ |
|
| 2522 | - public $affiliate_id; |
|
| 2523 | - |
|
| 2524 | - /** |
|
| 2525 | - * help tours on or off (global setting) |
|
| 2526 | - * |
|
| 2527 | - * @var boolean |
|
| 2528 | - */ |
|
| 2529 | - public $help_tour_activation; |
|
| 2530 | - |
|
| 2531 | - /** |
|
| 2532 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2533 | - * but is incompatible with some server configuration errors |
|
| 2534 | - * if you get "500 internal server errors" during registration, try turning this on |
|
| 2535 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2536 | - * |
|
| 2537 | - * @var boolean $encode_session_data |
|
| 2538 | - */ |
|
| 2539 | - private $encode_session_data = false; |
|
| 2540 | - |
|
| 2541 | - |
|
| 2542 | - |
|
| 2543 | - /** |
|
| 2544 | - * class constructor |
|
| 2545 | - * |
|
| 2546 | - * @access public |
|
| 2547 | - */ |
|
| 2548 | - public function __construct() |
|
| 2549 | - { |
|
| 2550 | - // set default general admin settings |
|
| 2551 | - $this->use_personnel_manager = true; |
|
| 2552 | - $this->use_dashboard_widget = true; |
|
| 2553 | - $this->events_in_dashboard = 30; |
|
| 2554 | - $this->use_event_timezones = false; |
|
| 2555 | - $this->use_full_logging = false; |
|
| 2556 | - $this->use_remote_logging = false; |
|
| 2557 | - $this->remote_logging_url = null; |
|
| 2558 | - $this->show_reg_footer = true; |
|
| 2559 | - $this->affiliate_id = 'default'; |
|
| 2560 | - $this->help_tour_activation = true; |
|
| 2561 | - $this->encode_session_data = false; |
|
| 2562 | - } |
|
| 2563 | - |
|
| 2564 | - |
|
| 2565 | - |
|
| 2566 | - /** |
|
| 2567 | - * @param bool $reset |
|
| 2568 | - * @return string |
|
| 2569 | - */ |
|
| 2570 | - public function log_file_name($reset = false) |
|
| 2571 | - { |
|
| 2572 | - if (empty($this->log_file_name) || $reset) { |
|
| 2573 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2574 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2575 | - } |
|
| 2576 | - return $this->log_file_name; |
|
| 2577 | - } |
|
| 2578 | - |
|
| 2579 | - |
|
| 2580 | - |
|
| 2581 | - /** |
|
| 2582 | - * @param bool $reset |
|
| 2583 | - * @return string |
|
| 2584 | - */ |
|
| 2585 | - public function debug_file_name($reset = false) |
|
| 2586 | - { |
|
| 2587 | - if (empty($this->debug_file_name) || $reset) { |
|
| 2588 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2589 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2590 | - } |
|
| 2591 | - return $this->debug_file_name; |
|
| 2592 | - } |
|
| 2593 | - |
|
| 2594 | - |
|
| 2595 | - |
|
| 2596 | - /** |
|
| 2597 | - * @return string |
|
| 2598 | - */ |
|
| 2599 | - public function affiliate_id() |
|
| 2600 | - { |
|
| 2601 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2602 | - } |
|
| 2603 | - |
|
| 2604 | - |
|
| 2605 | - |
|
| 2606 | - /** |
|
| 2607 | - * @return boolean |
|
| 2608 | - */ |
|
| 2609 | - public function encode_session_data() |
|
| 2610 | - { |
|
| 2611 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2612 | - } |
|
| 2613 | - |
|
| 2614 | - |
|
| 2615 | - |
|
| 2616 | - /** |
|
| 2617 | - * @param boolean $encode_session_data |
|
| 2618 | - */ |
|
| 2619 | - public function set_encode_session_data($encode_session_data) |
|
| 2620 | - { |
|
| 2621 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2622 | - } |
|
| 2469 | + /** |
|
| 2470 | + * @var boolean $use_personnel_manager |
|
| 2471 | + */ |
|
| 2472 | + public $use_personnel_manager; |
|
| 2473 | + |
|
| 2474 | + /** |
|
| 2475 | + * @var boolean $use_dashboard_widget |
|
| 2476 | + */ |
|
| 2477 | + public $use_dashboard_widget; |
|
| 2478 | + |
|
| 2479 | + /** |
|
| 2480 | + * @var int $events_in_dashboard |
|
| 2481 | + */ |
|
| 2482 | + public $events_in_dashboard; |
|
| 2483 | + |
|
| 2484 | + /** |
|
| 2485 | + * @var boolean $use_event_timezones |
|
| 2486 | + */ |
|
| 2487 | + public $use_event_timezones; |
|
| 2488 | + |
|
| 2489 | + /** |
|
| 2490 | + * @var boolean $use_full_logging |
|
| 2491 | + */ |
|
| 2492 | + public $use_full_logging; |
|
| 2493 | + |
|
| 2494 | + /** |
|
| 2495 | + * @var string $log_file_name |
|
| 2496 | + */ |
|
| 2497 | + public $log_file_name; |
|
| 2498 | + |
|
| 2499 | + /** |
|
| 2500 | + * @var string $debug_file_name |
|
| 2501 | + */ |
|
| 2502 | + public $debug_file_name; |
|
| 2503 | + |
|
| 2504 | + /** |
|
| 2505 | + * @var boolean $use_remote_logging |
|
| 2506 | + */ |
|
| 2507 | + public $use_remote_logging; |
|
| 2508 | + |
|
| 2509 | + /** |
|
| 2510 | + * @var string $remote_logging_url |
|
| 2511 | + */ |
|
| 2512 | + public $remote_logging_url; |
|
| 2513 | + |
|
| 2514 | + /** |
|
| 2515 | + * @var boolean $show_reg_footer |
|
| 2516 | + */ |
|
| 2517 | + public $show_reg_footer; |
|
| 2518 | + |
|
| 2519 | + /** |
|
| 2520 | + * @var string $affiliate_id |
|
| 2521 | + */ |
|
| 2522 | + public $affiliate_id; |
|
| 2523 | + |
|
| 2524 | + /** |
|
| 2525 | + * help tours on or off (global setting) |
|
| 2526 | + * |
|
| 2527 | + * @var boolean |
|
| 2528 | + */ |
|
| 2529 | + public $help_tour_activation; |
|
| 2530 | + |
|
| 2531 | + /** |
|
| 2532 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2533 | + * but is incompatible with some server configuration errors |
|
| 2534 | + * if you get "500 internal server errors" during registration, try turning this on |
|
| 2535 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2536 | + * |
|
| 2537 | + * @var boolean $encode_session_data |
|
| 2538 | + */ |
|
| 2539 | + private $encode_session_data = false; |
|
| 2540 | + |
|
| 2541 | + |
|
| 2542 | + |
|
| 2543 | + /** |
|
| 2544 | + * class constructor |
|
| 2545 | + * |
|
| 2546 | + * @access public |
|
| 2547 | + */ |
|
| 2548 | + public function __construct() |
|
| 2549 | + { |
|
| 2550 | + // set default general admin settings |
|
| 2551 | + $this->use_personnel_manager = true; |
|
| 2552 | + $this->use_dashboard_widget = true; |
|
| 2553 | + $this->events_in_dashboard = 30; |
|
| 2554 | + $this->use_event_timezones = false; |
|
| 2555 | + $this->use_full_logging = false; |
|
| 2556 | + $this->use_remote_logging = false; |
|
| 2557 | + $this->remote_logging_url = null; |
|
| 2558 | + $this->show_reg_footer = true; |
|
| 2559 | + $this->affiliate_id = 'default'; |
|
| 2560 | + $this->help_tour_activation = true; |
|
| 2561 | + $this->encode_session_data = false; |
|
| 2562 | + } |
|
| 2563 | + |
|
| 2564 | + |
|
| 2565 | + |
|
| 2566 | + /** |
|
| 2567 | + * @param bool $reset |
|
| 2568 | + * @return string |
|
| 2569 | + */ |
|
| 2570 | + public function log_file_name($reset = false) |
|
| 2571 | + { |
|
| 2572 | + if (empty($this->log_file_name) || $reset) { |
|
| 2573 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2574 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2575 | + } |
|
| 2576 | + return $this->log_file_name; |
|
| 2577 | + } |
|
| 2578 | + |
|
| 2579 | + |
|
| 2580 | + |
|
| 2581 | + /** |
|
| 2582 | + * @param bool $reset |
|
| 2583 | + * @return string |
|
| 2584 | + */ |
|
| 2585 | + public function debug_file_name($reset = false) |
|
| 2586 | + { |
|
| 2587 | + if (empty($this->debug_file_name) || $reset) { |
|
| 2588 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2589 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2590 | + } |
|
| 2591 | + return $this->debug_file_name; |
|
| 2592 | + } |
|
| 2593 | + |
|
| 2594 | + |
|
| 2595 | + |
|
| 2596 | + /** |
|
| 2597 | + * @return string |
|
| 2598 | + */ |
|
| 2599 | + public function affiliate_id() |
|
| 2600 | + { |
|
| 2601 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2602 | + } |
|
| 2603 | + |
|
| 2604 | + |
|
| 2605 | + |
|
| 2606 | + /** |
|
| 2607 | + * @return boolean |
|
| 2608 | + */ |
|
| 2609 | + public function encode_session_data() |
|
| 2610 | + { |
|
| 2611 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2612 | + } |
|
| 2613 | + |
|
| 2614 | + |
|
| 2615 | + |
|
| 2616 | + /** |
|
| 2617 | + * @param boolean $encode_session_data |
|
| 2618 | + */ |
|
| 2619 | + public function set_encode_session_data($encode_session_data) |
|
| 2620 | + { |
|
| 2621 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2622 | + } |
|
| 2623 | 2623 | |
| 2624 | 2624 | |
| 2625 | 2625 | |
@@ -2633,71 +2633,71 @@ discard block |
||
| 2633 | 2633 | class EE_Template_Config extends EE_Config_Base |
| 2634 | 2634 | { |
| 2635 | 2635 | |
| 2636 | - /** |
|
| 2637 | - * @var boolean $enable_default_style |
|
| 2638 | - */ |
|
| 2639 | - public $enable_default_style; |
|
| 2640 | - |
|
| 2641 | - /** |
|
| 2642 | - * @var string $custom_style_sheet |
|
| 2643 | - */ |
|
| 2644 | - public $custom_style_sheet; |
|
| 2645 | - |
|
| 2646 | - /** |
|
| 2647 | - * @var boolean $display_address_in_regform |
|
| 2648 | - */ |
|
| 2649 | - public $display_address_in_regform; |
|
| 2650 | - |
|
| 2651 | - /** |
|
| 2652 | - * @var int $display_description_on_multi_reg_page |
|
| 2653 | - */ |
|
| 2654 | - public $display_description_on_multi_reg_page; |
|
| 2655 | - |
|
| 2656 | - /** |
|
| 2657 | - * @var boolean $use_custom_templates |
|
| 2658 | - */ |
|
| 2659 | - public $use_custom_templates; |
|
| 2660 | - |
|
| 2661 | - /** |
|
| 2662 | - * @var string $current_espresso_theme |
|
| 2663 | - */ |
|
| 2664 | - public $current_espresso_theme; |
|
| 2665 | - |
|
| 2666 | - /** |
|
| 2667 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2668 | - */ |
|
| 2669 | - public $EED_Ticket_Selector; |
|
| 2670 | - |
|
| 2671 | - /** |
|
| 2672 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2673 | - */ |
|
| 2674 | - public $EED_Event_Single; |
|
| 2675 | - |
|
| 2676 | - /** |
|
| 2677 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2678 | - */ |
|
| 2679 | - public $EED_Events_Archive; |
|
| 2680 | - |
|
| 2681 | - |
|
| 2682 | - |
|
| 2683 | - /** |
|
| 2684 | - * class constructor |
|
| 2685 | - * |
|
| 2686 | - * @access public |
|
| 2687 | - */ |
|
| 2688 | - public function __construct() |
|
| 2689 | - { |
|
| 2690 | - // set default template settings |
|
| 2691 | - $this->enable_default_style = true; |
|
| 2692 | - $this->custom_style_sheet = null; |
|
| 2693 | - $this->display_address_in_regform = true; |
|
| 2694 | - $this->display_description_on_multi_reg_page = false; |
|
| 2695 | - $this->use_custom_templates = false; |
|
| 2696 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2697 | - $this->EED_Event_Single = null; |
|
| 2698 | - $this->EED_Events_Archive = null; |
|
| 2699 | - $this->EED_Ticket_Selector = null; |
|
| 2700 | - } |
|
| 2636 | + /** |
|
| 2637 | + * @var boolean $enable_default_style |
|
| 2638 | + */ |
|
| 2639 | + public $enable_default_style; |
|
| 2640 | + |
|
| 2641 | + /** |
|
| 2642 | + * @var string $custom_style_sheet |
|
| 2643 | + */ |
|
| 2644 | + public $custom_style_sheet; |
|
| 2645 | + |
|
| 2646 | + /** |
|
| 2647 | + * @var boolean $display_address_in_regform |
|
| 2648 | + */ |
|
| 2649 | + public $display_address_in_regform; |
|
| 2650 | + |
|
| 2651 | + /** |
|
| 2652 | + * @var int $display_description_on_multi_reg_page |
|
| 2653 | + */ |
|
| 2654 | + public $display_description_on_multi_reg_page; |
|
| 2655 | + |
|
| 2656 | + /** |
|
| 2657 | + * @var boolean $use_custom_templates |
|
| 2658 | + */ |
|
| 2659 | + public $use_custom_templates; |
|
| 2660 | + |
|
| 2661 | + /** |
|
| 2662 | + * @var string $current_espresso_theme |
|
| 2663 | + */ |
|
| 2664 | + public $current_espresso_theme; |
|
| 2665 | + |
|
| 2666 | + /** |
|
| 2667 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2668 | + */ |
|
| 2669 | + public $EED_Ticket_Selector; |
|
| 2670 | + |
|
| 2671 | + /** |
|
| 2672 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2673 | + */ |
|
| 2674 | + public $EED_Event_Single; |
|
| 2675 | + |
|
| 2676 | + /** |
|
| 2677 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2678 | + */ |
|
| 2679 | + public $EED_Events_Archive; |
|
| 2680 | + |
|
| 2681 | + |
|
| 2682 | + |
|
| 2683 | + /** |
|
| 2684 | + * class constructor |
|
| 2685 | + * |
|
| 2686 | + * @access public |
|
| 2687 | + */ |
|
| 2688 | + public function __construct() |
|
| 2689 | + { |
|
| 2690 | + // set default template settings |
|
| 2691 | + $this->enable_default_style = true; |
|
| 2692 | + $this->custom_style_sheet = null; |
|
| 2693 | + $this->display_address_in_regform = true; |
|
| 2694 | + $this->display_description_on_multi_reg_page = false; |
|
| 2695 | + $this->use_custom_templates = false; |
|
| 2696 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2697 | + $this->EED_Event_Single = null; |
|
| 2698 | + $this->EED_Events_Archive = null; |
|
| 2699 | + $this->EED_Ticket_Selector = null; |
|
| 2700 | + } |
|
| 2701 | 2701 | |
| 2702 | 2702 | } |
| 2703 | 2703 | |
@@ -2709,115 +2709,115 @@ discard block |
||
| 2709 | 2709 | class EE_Map_Config extends EE_Config_Base |
| 2710 | 2710 | { |
| 2711 | 2711 | |
| 2712 | - /** |
|
| 2713 | - * @var boolean $use_google_maps |
|
| 2714 | - */ |
|
| 2715 | - public $use_google_maps; |
|
| 2716 | - |
|
| 2717 | - /** |
|
| 2718 | - * @var string $api_key |
|
| 2719 | - */ |
|
| 2720 | - public $google_map_api_key; |
|
| 2721 | - |
|
| 2722 | - /** |
|
| 2723 | - * @var int $event_details_map_width |
|
| 2724 | - */ |
|
| 2725 | - public $event_details_map_width; |
|
| 2726 | - |
|
| 2727 | - /** |
|
| 2728 | - * @var int $event_details_map_height |
|
| 2729 | - */ |
|
| 2730 | - public $event_details_map_height; |
|
| 2731 | - |
|
| 2732 | - /** |
|
| 2733 | - * @var int $event_details_map_zoom |
|
| 2734 | - */ |
|
| 2735 | - public $event_details_map_zoom; |
|
| 2736 | - |
|
| 2737 | - /** |
|
| 2738 | - * @var boolean $event_details_display_nav |
|
| 2739 | - */ |
|
| 2740 | - public $event_details_display_nav; |
|
| 2741 | - |
|
| 2742 | - /** |
|
| 2743 | - * @var boolean $event_details_nav_size |
|
| 2744 | - */ |
|
| 2745 | - public $event_details_nav_size; |
|
| 2746 | - |
|
| 2747 | - /** |
|
| 2748 | - * @var string $event_details_control_type |
|
| 2749 | - */ |
|
| 2750 | - public $event_details_control_type; |
|
| 2751 | - |
|
| 2752 | - /** |
|
| 2753 | - * @var string $event_details_map_align |
|
| 2754 | - */ |
|
| 2755 | - public $event_details_map_align; |
|
| 2756 | - |
|
| 2757 | - /** |
|
| 2758 | - * @var int $event_list_map_width |
|
| 2759 | - */ |
|
| 2760 | - public $event_list_map_width; |
|
| 2761 | - |
|
| 2762 | - /** |
|
| 2763 | - * @var int $event_list_map_height |
|
| 2764 | - */ |
|
| 2765 | - public $event_list_map_height; |
|
| 2766 | - |
|
| 2767 | - /** |
|
| 2768 | - * @var int $event_list_map_zoom |
|
| 2769 | - */ |
|
| 2770 | - public $event_list_map_zoom; |
|
| 2771 | - |
|
| 2772 | - /** |
|
| 2773 | - * @var boolean $event_list_display_nav |
|
| 2774 | - */ |
|
| 2775 | - public $event_list_display_nav; |
|
| 2776 | - |
|
| 2777 | - /** |
|
| 2778 | - * @var boolean $event_list_nav_size |
|
| 2779 | - */ |
|
| 2780 | - public $event_list_nav_size; |
|
| 2781 | - |
|
| 2782 | - /** |
|
| 2783 | - * @var string $event_list_control_type |
|
| 2784 | - */ |
|
| 2785 | - public $event_list_control_type; |
|
| 2786 | - |
|
| 2787 | - /** |
|
| 2788 | - * @var string $event_list_map_align |
|
| 2789 | - */ |
|
| 2790 | - public $event_list_map_align; |
|
| 2791 | - |
|
| 2792 | - |
|
| 2793 | - |
|
| 2794 | - /** |
|
| 2795 | - * class constructor |
|
| 2796 | - * |
|
| 2797 | - * @access public |
|
| 2798 | - */ |
|
| 2799 | - public function __construct() |
|
| 2800 | - { |
|
| 2801 | - // set default map settings |
|
| 2802 | - $this->use_google_maps = true; |
|
| 2803 | - $this->google_map_api_key = ''; |
|
| 2804 | - // for event details pages (reg page) |
|
| 2805 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2806 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2807 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2808 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2809 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2810 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2811 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2812 | - // for event list pages |
|
| 2813 | - $this->event_list_map_width = 300; // ee_map_width |
|
| 2814 | - $this->event_list_map_height = 185; // ee_map_height |
|
| 2815 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2816 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2817 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2818 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2819 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2820 | - } |
|
| 2712 | + /** |
|
| 2713 | + * @var boolean $use_google_maps |
|
| 2714 | + */ |
|
| 2715 | + public $use_google_maps; |
|
| 2716 | + |
|
| 2717 | + /** |
|
| 2718 | + * @var string $api_key |
|
| 2719 | + */ |
|
| 2720 | + public $google_map_api_key; |
|
| 2721 | + |
|
| 2722 | + /** |
|
| 2723 | + * @var int $event_details_map_width |
|
| 2724 | + */ |
|
| 2725 | + public $event_details_map_width; |
|
| 2726 | + |
|
| 2727 | + /** |
|
| 2728 | + * @var int $event_details_map_height |
|
| 2729 | + */ |
|
| 2730 | + public $event_details_map_height; |
|
| 2731 | + |
|
| 2732 | + /** |
|
| 2733 | + * @var int $event_details_map_zoom |
|
| 2734 | + */ |
|
| 2735 | + public $event_details_map_zoom; |
|
| 2736 | + |
|
| 2737 | + /** |
|
| 2738 | + * @var boolean $event_details_display_nav |
|
| 2739 | + */ |
|
| 2740 | + public $event_details_display_nav; |
|
| 2741 | + |
|
| 2742 | + /** |
|
| 2743 | + * @var boolean $event_details_nav_size |
|
| 2744 | + */ |
|
| 2745 | + public $event_details_nav_size; |
|
| 2746 | + |
|
| 2747 | + /** |
|
| 2748 | + * @var string $event_details_control_type |
|
| 2749 | + */ |
|
| 2750 | + public $event_details_control_type; |
|
| 2751 | + |
|
| 2752 | + /** |
|
| 2753 | + * @var string $event_details_map_align |
|
| 2754 | + */ |
|
| 2755 | + public $event_details_map_align; |
|
| 2756 | + |
|
| 2757 | + /** |
|
| 2758 | + * @var int $event_list_map_width |
|
| 2759 | + */ |
|
| 2760 | + public $event_list_map_width; |
|
| 2761 | + |
|
| 2762 | + /** |
|
| 2763 | + * @var int $event_list_map_height |
|
| 2764 | + */ |
|
| 2765 | + public $event_list_map_height; |
|
| 2766 | + |
|
| 2767 | + /** |
|
| 2768 | + * @var int $event_list_map_zoom |
|
| 2769 | + */ |
|
| 2770 | + public $event_list_map_zoom; |
|
| 2771 | + |
|
| 2772 | + /** |
|
| 2773 | + * @var boolean $event_list_display_nav |
|
| 2774 | + */ |
|
| 2775 | + public $event_list_display_nav; |
|
| 2776 | + |
|
| 2777 | + /** |
|
| 2778 | + * @var boolean $event_list_nav_size |
|
| 2779 | + */ |
|
| 2780 | + public $event_list_nav_size; |
|
| 2781 | + |
|
| 2782 | + /** |
|
| 2783 | + * @var string $event_list_control_type |
|
| 2784 | + */ |
|
| 2785 | + public $event_list_control_type; |
|
| 2786 | + |
|
| 2787 | + /** |
|
| 2788 | + * @var string $event_list_map_align |
|
| 2789 | + */ |
|
| 2790 | + public $event_list_map_align; |
|
| 2791 | + |
|
| 2792 | + |
|
| 2793 | + |
|
| 2794 | + /** |
|
| 2795 | + * class constructor |
|
| 2796 | + * |
|
| 2797 | + * @access public |
|
| 2798 | + */ |
|
| 2799 | + public function __construct() |
|
| 2800 | + { |
|
| 2801 | + // set default map settings |
|
| 2802 | + $this->use_google_maps = true; |
|
| 2803 | + $this->google_map_api_key = ''; |
|
| 2804 | + // for event details pages (reg page) |
|
| 2805 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2806 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2807 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2808 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2809 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2810 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2811 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2812 | + // for event list pages |
|
| 2813 | + $this->event_list_map_width = 300; // ee_map_width |
|
| 2814 | + $this->event_list_map_height = 185; // ee_map_height |
|
| 2815 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2816 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2817 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2818 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2819 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2820 | + } |
|
| 2821 | 2821 | |
| 2822 | 2822 | } |
| 2823 | 2823 | |
@@ -2829,47 +2829,47 @@ discard block |
||
| 2829 | 2829 | class EE_Events_Archive_Config extends EE_Config_Base |
| 2830 | 2830 | { |
| 2831 | 2831 | |
| 2832 | - public $display_status_banner; |
|
| 2832 | + public $display_status_banner; |
|
| 2833 | 2833 | |
| 2834 | - public $display_description; |
|
| 2834 | + public $display_description; |
|
| 2835 | 2835 | |
| 2836 | - public $display_ticket_selector; |
|
| 2836 | + public $display_ticket_selector; |
|
| 2837 | 2837 | |
| 2838 | - public $display_datetimes; |
|
| 2838 | + public $display_datetimes; |
|
| 2839 | 2839 | |
| 2840 | - public $display_venue; |
|
| 2840 | + public $display_venue; |
|
| 2841 | 2841 | |
| 2842 | - public $display_expired_events; |
|
| 2842 | + public $display_expired_events; |
|
| 2843 | 2843 | |
| 2844 | - public $use_sortable_display_order; |
|
| 2844 | + public $use_sortable_display_order; |
|
| 2845 | 2845 | |
| 2846 | - public $display_order_tickets; |
|
| 2846 | + public $display_order_tickets; |
|
| 2847 | 2847 | |
| 2848 | - public $display_order_datetimes; |
|
| 2848 | + public $display_order_datetimes; |
|
| 2849 | 2849 | |
| 2850 | - public $display_order_event; |
|
| 2850 | + public $display_order_event; |
|
| 2851 | 2851 | |
| 2852 | - public $display_order_venue; |
|
| 2852 | + public $display_order_venue; |
|
| 2853 | 2853 | |
| 2854 | 2854 | |
| 2855 | 2855 | |
| 2856 | - /** |
|
| 2857 | - * class constructor |
|
| 2858 | - */ |
|
| 2859 | - public function __construct() |
|
| 2860 | - { |
|
| 2861 | - $this->display_status_banner = 0; |
|
| 2862 | - $this->display_description = 1; |
|
| 2863 | - $this->display_ticket_selector = 0; |
|
| 2864 | - $this->display_datetimes = 1; |
|
| 2865 | - $this->display_venue = 0; |
|
| 2866 | - $this->display_expired_events = 0; |
|
| 2867 | - $this->use_sortable_display_order = false; |
|
| 2868 | - $this->display_order_tickets = 100; |
|
| 2869 | - $this->display_order_datetimes = 110; |
|
| 2870 | - $this->display_order_event = 120; |
|
| 2871 | - $this->display_order_venue = 130; |
|
| 2872 | - } |
|
| 2856 | + /** |
|
| 2857 | + * class constructor |
|
| 2858 | + */ |
|
| 2859 | + public function __construct() |
|
| 2860 | + { |
|
| 2861 | + $this->display_status_banner = 0; |
|
| 2862 | + $this->display_description = 1; |
|
| 2863 | + $this->display_ticket_selector = 0; |
|
| 2864 | + $this->display_datetimes = 1; |
|
| 2865 | + $this->display_venue = 0; |
|
| 2866 | + $this->display_expired_events = 0; |
|
| 2867 | + $this->use_sortable_display_order = false; |
|
| 2868 | + $this->display_order_tickets = 100; |
|
| 2869 | + $this->display_order_datetimes = 110; |
|
| 2870 | + $this->display_order_event = 120; |
|
| 2871 | + $this->display_order_venue = 130; |
|
| 2872 | + } |
|
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | 2875 | |
@@ -2880,35 +2880,35 @@ discard block |
||
| 2880 | 2880 | class EE_Event_Single_Config extends EE_Config_Base |
| 2881 | 2881 | { |
| 2882 | 2882 | |
| 2883 | - public $display_status_banner_single; |
|
| 2883 | + public $display_status_banner_single; |
|
| 2884 | 2884 | |
| 2885 | - public $display_venue; |
|
| 2885 | + public $display_venue; |
|
| 2886 | 2886 | |
| 2887 | - public $use_sortable_display_order; |
|
| 2887 | + public $use_sortable_display_order; |
|
| 2888 | 2888 | |
| 2889 | - public $display_order_tickets; |
|
| 2889 | + public $display_order_tickets; |
|
| 2890 | 2890 | |
| 2891 | - public $display_order_datetimes; |
|
| 2891 | + public $display_order_datetimes; |
|
| 2892 | 2892 | |
| 2893 | - public $display_order_event; |
|
| 2893 | + public $display_order_event; |
|
| 2894 | 2894 | |
| 2895 | - public $display_order_venue; |
|
| 2895 | + public $display_order_venue; |
|
| 2896 | 2896 | |
| 2897 | 2897 | |
| 2898 | 2898 | |
| 2899 | - /** |
|
| 2900 | - * class constructor |
|
| 2901 | - */ |
|
| 2902 | - public function __construct() |
|
| 2903 | - { |
|
| 2904 | - $this->display_status_banner_single = 0; |
|
| 2905 | - $this->display_venue = 1; |
|
| 2906 | - $this->use_sortable_display_order = false; |
|
| 2907 | - $this->display_order_tickets = 100; |
|
| 2908 | - $this->display_order_datetimes = 110; |
|
| 2909 | - $this->display_order_event = 120; |
|
| 2910 | - $this->display_order_venue = 130; |
|
| 2911 | - } |
|
| 2899 | + /** |
|
| 2900 | + * class constructor |
|
| 2901 | + */ |
|
| 2902 | + public function __construct() |
|
| 2903 | + { |
|
| 2904 | + $this->display_status_banner_single = 0; |
|
| 2905 | + $this->display_venue = 1; |
|
| 2906 | + $this->use_sortable_display_order = false; |
|
| 2907 | + $this->display_order_tickets = 100; |
|
| 2908 | + $this->display_order_datetimes = 110; |
|
| 2909 | + $this->display_order_event = 120; |
|
| 2910 | + $this->display_order_venue = 130; |
|
| 2911 | + } |
|
| 2912 | 2912 | } |
| 2913 | 2913 | |
| 2914 | 2914 | |
@@ -2919,152 +2919,152 @@ discard block |
||
| 2919 | 2919 | class EE_Ticket_Selector_Config extends EE_Config_Base |
| 2920 | 2920 | { |
| 2921 | 2921 | |
| 2922 | - /** |
|
| 2923 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2924 | - */ |
|
| 2925 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2926 | - |
|
| 2927 | - /** |
|
| 2928 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2929 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2930 | - */ |
|
| 2931 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2932 | - |
|
| 2933 | - /** |
|
| 2934 | - * @var boolean $show_ticket_sale_columns |
|
| 2935 | - */ |
|
| 2936 | - public $show_ticket_sale_columns; |
|
| 2937 | - |
|
| 2938 | - /** |
|
| 2939 | - * @var boolean $show_ticket_details |
|
| 2940 | - */ |
|
| 2941 | - public $show_ticket_details; |
|
| 2942 | - |
|
| 2943 | - /** |
|
| 2944 | - * @var boolean $show_expired_tickets |
|
| 2945 | - */ |
|
| 2946 | - public $show_expired_tickets; |
|
| 2947 | - |
|
| 2948 | - /** |
|
| 2949 | - * whether or not to display a dropdown box populated with event datetimes |
|
| 2950 | - * that toggles which tickets are displayed for a ticket selector. |
|
| 2951 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 2952 | - * |
|
| 2953 | - * @var string $show_datetime_selector |
|
| 2954 | - */ |
|
| 2955 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
| 2956 | - |
|
| 2957 | - /** |
|
| 2958 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 2959 | - * |
|
| 2960 | - * @var int $datetime_selector_threshold |
|
| 2961 | - */ |
|
| 2962 | - private $datetime_selector_threshold = 3; |
|
| 2963 | - |
|
| 2964 | - |
|
| 2965 | - |
|
| 2966 | - /** |
|
| 2967 | - * class constructor |
|
| 2968 | - */ |
|
| 2969 | - public function __construct() |
|
| 2970 | - { |
|
| 2971 | - $this->show_ticket_sale_columns = true; |
|
| 2972 | - $this->show_ticket_details = true; |
|
| 2973 | - $this->show_expired_tickets = true; |
|
| 2974 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 2975 | - $this->datetime_selector_threshold = 3; |
|
| 2976 | - } |
|
| 2977 | - |
|
| 2978 | - |
|
| 2979 | - |
|
| 2980 | - /** |
|
| 2981 | - * returns true if a datetime selector should be displayed |
|
| 2982 | - * |
|
| 2983 | - * @param array $datetimes |
|
| 2984 | - * @return bool |
|
| 2985 | - */ |
|
| 2986 | - public function showDatetimeSelector(array $datetimes) |
|
| 2987 | - { |
|
| 2988 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 2989 | - return ! ( |
|
| 2990 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 2991 | - || ( |
|
| 2992 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 2993 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 2994 | - ) |
|
| 2995 | - ); |
|
| 2996 | - } |
|
| 2997 | - |
|
| 2998 | - |
|
| 2999 | - |
|
| 3000 | - /** |
|
| 3001 | - * @return string |
|
| 3002 | - */ |
|
| 3003 | - public function getShowDatetimeSelector() |
|
| 3004 | - { |
|
| 3005 | - return $this->show_datetime_selector; |
|
| 3006 | - } |
|
| 3007 | - |
|
| 3008 | - |
|
| 3009 | - |
|
| 3010 | - /** |
|
| 3011 | - * @param bool $keys_only |
|
| 3012 | - * @return array |
|
| 3013 | - */ |
|
| 3014 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3015 | - { |
|
| 3016 | - return $keys_only |
|
| 3017 | - ? array( |
|
| 3018 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3019 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3020 | - ) |
|
| 3021 | - : array( |
|
| 3022 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3023 | - 'Do not show date & time filter', 'event_espresso' |
|
| 3024 | - ), |
|
| 3025 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3026 | - 'Maybe show date & time filter', 'event_espresso' |
|
| 3027 | - ), |
|
| 3028 | - ); |
|
| 3029 | - } |
|
| 3030 | - |
|
| 3031 | - |
|
| 3032 | - |
|
| 3033 | - /** |
|
| 3034 | - * @param string $show_datetime_selector |
|
| 3035 | - */ |
|
| 3036 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3037 | - { |
|
| 3038 | - $this->show_datetime_selector = in_array( |
|
| 3039 | - $show_datetime_selector, |
|
| 3040 | - $this->getShowDatetimeSelectorOptions(), |
|
| 3041 | - true |
|
| 3042 | - ) |
|
| 3043 | - ? $show_datetime_selector |
|
| 3044 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3045 | - } |
|
| 3046 | - |
|
| 3047 | - |
|
| 3048 | - |
|
| 3049 | - /** |
|
| 3050 | - * @return int |
|
| 3051 | - */ |
|
| 3052 | - public function getDatetimeSelectorThreshold() |
|
| 3053 | - { |
|
| 3054 | - return $this->datetime_selector_threshold; |
|
| 3055 | - } |
|
| 3056 | - |
|
| 3057 | - |
|
| 3058 | - |
|
| 3059 | - |
|
| 3060 | - /** |
|
| 3061 | - * @param int $datetime_selector_threshold |
|
| 3062 | - */ |
|
| 3063 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3064 | - { |
|
| 3065 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3066 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3067 | - } |
|
| 2922 | + /** |
|
| 2923 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2924 | + */ |
|
| 2925 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2926 | + |
|
| 2927 | + /** |
|
| 2928 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2929 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2930 | + */ |
|
| 2931 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2932 | + |
|
| 2933 | + /** |
|
| 2934 | + * @var boolean $show_ticket_sale_columns |
|
| 2935 | + */ |
|
| 2936 | + public $show_ticket_sale_columns; |
|
| 2937 | + |
|
| 2938 | + /** |
|
| 2939 | + * @var boolean $show_ticket_details |
|
| 2940 | + */ |
|
| 2941 | + public $show_ticket_details; |
|
| 2942 | + |
|
| 2943 | + /** |
|
| 2944 | + * @var boolean $show_expired_tickets |
|
| 2945 | + */ |
|
| 2946 | + public $show_expired_tickets; |
|
| 2947 | + |
|
| 2948 | + /** |
|
| 2949 | + * whether or not to display a dropdown box populated with event datetimes |
|
| 2950 | + * that toggles which tickets are displayed for a ticket selector. |
|
| 2951 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 2952 | + * |
|
| 2953 | + * @var string $show_datetime_selector |
|
| 2954 | + */ |
|
| 2955 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
| 2956 | + |
|
| 2957 | + /** |
|
| 2958 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 2959 | + * |
|
| 2960 | + * @var int $datetime_selector_threshold |
|
| 2961 | + */ |
|
| 2962 | + private $datetime_selector_threshold = 3; |
|
| 2963 | + |
|
| 2964 | + |
|
| 2965 | + |
|
| 2966 | + /** |
|
| 2967 | + * class constructor |
|
| 2968 | + */ |
|
| 2969 | + public function __construct() |
|
| 2970 | + { |
|
| 2971 | + $this->show_ticket_sale_columns = true; |
|
| 2972 | + $this->show_ticket_details = true; |
|
| 2973 | + $this->show_expired_tickets = true; |
|
| 2974 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 2975 | + $this->datetime_selector_threshold = 3; |
|
| 2976 | + } |
|
| 2977 | + |
|
| 2978 | + |
|
| 2979 | + |
|
| 2980 | + /** |
|
| 2981 | + * returns true if a datetime selector should be displayed |
|
| 2982 | + * |
|
| 2983 | + * @param array $datetimes |
|
| 2984 | + * @return bool |
|
| 2985 | + */ |
|
| 2986 | + public function showDatetimeSelector(array $datetimes) |
|
| 2987 | + { |
|
| 2988 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 2989 | + return ! ( |
|
| 2990 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 2991 | + || ( |
|
| 2992 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 2993 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 2994 | + ) |
|
| 2995 | + ); |
|
| 2996 | + } |
|
| 2997 | + |
|
| 2998 | + |
|
| 2999 | + |
|
| 3000 | + /** |
|
| 3001 | + * @return string |
|
| 3002 | + */ |
|
| 3003 | + public function getShowDatetimeSelector() |
|
| 3004 | + { |
|
| 3005 | + return $this->show_datetime_selector; |
|
| 3006 | + } |
|
| 3007 | + |
|
| 3008 | + |
|
| 3009 | + |
|
| 3010 | + /** |
|
| 3011 | + * @param bool $keys_only |
|
| 3012 | + * @return array |
|
| 3013 | + */ |
|
| 3014 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3015 | + { |
|
| 3016 | + return $keys_only |
|
| 3017 | + ? array( |
|
| 3018 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3019 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3020 | + ) |
|
| 3021 | + : array( |
|
| 3022 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3023 | + 'Do not show date & time filter', 'event_espresso' |
|
| 3024 | + ), |
|
| 3025 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3026 | + 'Maybe show date & time filter', 'event_espresso' |
|
| 3027 | + ), |
|
| 3028 | + ); |
|
| 3029 | + } |
|
| 3030 | + |
|
| 3031 | + |
|
| 3032 | + |
|
| 3033 | + /** |
|
| 3034 | + * @param string $show_datetime_selector |
|
| 3035 | + */ |
|
| 3036 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3037 | + { |
|
| 3038 | + $this->show_datetime_selector = in_array( |
|
| 3039 | + $show_datetime_selector, |
|
| 3040 | + $this->getShowDatetimeSelectorOptions(), |
|
| 3041 | + true |
|
| 3042 | + ) |
|
| 3043 | + ? $show_datetime_selector |
|
| 3044 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3045 | + } |
|
| 3046 | + |
|
| 3047 | + |
|
| 3048 | + |
|
| 3049 | + /** |
|
| 3050 | + * @return int |
|
| 3051 | + */ |
|
| 3052 | + public function getDatetimeSelectorThreshold() |
|
| 3053 | + { |
|
| 3054 | + return $this->datetime_selector_threshold; |
|
| 3055 | + } |
|
| 3056 | + |
|
| 3057 | + |
|
| 3058 | + |
|
| 3059 | + |
|
| 3060 | + /** |
|
| 3061 | + * @param int $datetime_selector_threshold |
|
| 3062 | + */ |
|
| 3063 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3064 | + { |
|
| 3065 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3066 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3067 | + } |
|
| 3068 | 3068 | |
| 3069 | 3069 | |
| 3070 | 3070 | |
@@ -3082,85 +3082,85 @@ discard block |
||
| 3082 | 3082 | class EE_Environment_Config extends EE_Config_Base |
| 3083 | 3083 | { |
| 3084 | 3084 | |
| 3085 | - /** |
|
| 3086 | - * Hold any php environment variables that we want to track. |
|
| 3087 | - * |
|
| 3088 | - * @var stdClass; |
|
| 3089 | - */ |
|
| 3090 | - public $php; |
|
| 3091 | - |
|
| 3092 | - |
|
| 3093 | - |
|
| 3094 | - /** |
|
| 3095 | - * constructor |
|
| 3096 | - */ |
|
| 3097 | - public function __construct() |
|
| 3098 | - { |
|
| 3099 | - $this->php = new stdClass(); |
|
| 3100 | - $this->_set_php_values(); |
|
| 3101 | - } |
|
| 3102 | - |
|
| 3103 | - |
|
| 3104 | - |
|
| 3105 | - /** |
|
| 3106 | - * This sets the php environment variables. |
|
| 3107 | - * |
|
| 3108 | - * @since 4.4.0 |
|
| 3109 | - * @return void |
|
| 3110 | - */ |
|
| 3111 | - protected function _set_php_values() |
|
| 3112 | - { |
|
| 3113 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3114 | - $this->php->version = phpversion(); |
|
| 3115 | - } |
|
| 3116 | - |
|
| 3117 | - |
|
| 3118 | - |
|
| 3119 | - /** |
|
| 3120 | - * helper method for determining whether input_count is |
|
| 3121 | - * reaching the potential maximum the server can handle |
|
| 3122 | - * according to max_input_vars |
|
| 3123 | - * |
|
| 3124 | - * @param int $input_count the count of input vars. |
|
| 3125 | - * @return array { |
|
| 3126 | - * An array that represents whether available space and if no available space the error |
|
| 3127 | - * message. |
|
| 3128 | - * @type bool $has_space whether more inputs can be added. |
|
| 3129 | - * @type string $msg Any message to be displayed. |
|
| 3130 | - * } |
|
| 3131 | - */ |
|
| 3132 | - public function max_input_vars_limit_check($input_count = 0) |
|
| 3133 | - { |
|
| 3134 | - if (! empty($this->php->max_input_vars) |
|
| 3135 | - && ($input_count >= $this->php->max_input_vars) |
|
| 3136 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
| 3137 | - ) { |
|
| 3138 | - return sprintf( |
|
| 3139 | - __( |
|
| 3140 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
| 3141 | - 'event_espresso' |
|
| 3142 | - ), |
|
| 3143 | - '<br>', |
|
| 3144 | - $input_count, |
|
| 3145 | - $this->php->max_input_vars |
|
| 3146 | - ); |
|
| 3147 | - } else { |
|
| 3148 | - return ''; |
|
| 3149 | - } |
|
| 3150 | - } |
|
| 3151 | - |
|
| 3152 | - |
|
| 3153 | - |
|
| 3154 | - /** |
|
| 3155 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3156 | - * |
|
| 3157 | - * @since 4.4.1 |
|
| 3158 | - * @return void |
|
| 3159 | - */ |
|
| 3160 | - public function recheck_values() |
|
| 3161 | - { |
|
| 3162 | - $this->_set_php_values(); |
|
| 3163 | - } |
|
| 3085 | + /** |
|
| 3086 | + * Hold any php environment variables that we want to track. |
|
| 3087 | + * |
|
| 3088 | + * @var stdClass; |
|
| 3089 | + */ |
|
| 3090 | + public $php; |
|
| 3091 | + |
|
| 3092 | + |
|
| 3093 | + |
|
| 3094 | + /** |
|
| 3095 | + * constructor |
|
| 3096 | + */ |
|
| 3097 | + public function __construct() |
|
| 3098 | + { |
|
| 3099 | + $this->php = new stdClass(); |
|
| 3100 | + $this->_set_php_values(); |
|
| 3101 | + } |
|
| 3102 | + |
|
| 3103 | + |
|
| 3104 | + |
|
| 3105 | + /** |
|
| 3106 | + * This sets the php environment variables. |
|
| 3107 | + * |
|
| 3108 | + * @since 4.4.0 |
|
| 3109 | + * @return void |
|
| 3110 | + */ |
|
| 3111 | + protected function _set_php_values() |
|
| 3112 | + { |
|
| 3113 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3114 | + $this->php->version = phpversion(); |
|
| 3115 | + } |
|
| 3116 | + |
|
| 3117 | + |
|
| 3118 | + |
|
| 3119 | + /** |
|
| 3120 | + * helper method for determining whether input_count is |
|
| 3121 | + * reaching the potential maximum the server can handle |
|
| 3122 | + * according to max_input_vars |
|
| 3123 | + * |
|
| 3124 | + * @param int $input_count the count of input vars. |
|
| 3125 | + * @return array { |
|
| 3126 | + * An array that represents whether available space and if no available space the error |
|
| 3127 | + * message. |
|
| 3128 | + * @type bool $has_space whether more inputs can be added. |
|
| 3129 | + * @type string $msg Any message to be displayed. |
|
| 3130 | + * } |
|
| 3131 | + */ |
|
| 3132 | + public function max_input_vars_limit_check($input_count = 0) |
|
| 3133 | + { |
|
| 3134 | + if (! empty($this->php->max_input_vars) |
|
| 3135 | + && ($input_count >= $this->php->max_input_vars) |
|
| 3136 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
| 3137 | + ) { |
|
| 3138 | + return sprintf( |
|
| 3139 | + __( |
|
| 3140 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
| 3141 | + 'event_espresso' |
|
| 3142 | + ), |
|
| 3143 | + '<br>', |
|
| 3144 | + $input_count, |
|
| 3145 | + $this->php->max_input_vars |
|
| 3146 | + ); |
|
| 3147 | + } else { |
|
| 3148 | + return ''; |
|
| 3149 | + } |
|
| 3150 | + } |
|
| 3151 | + |
|
| 3152 | + |
|
| 3153 | + |
|
| 3154 | + /** |
|
| 3155 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3156 | + * |
|
| 3157 | + * @since 4.4.1 |
|
| 3158 | + * @return void |
|
| 3159 | + */ |
|
| 3160 | + public function recheck_values() |
|
| 3161 | + { |
|
| 3162 | + $this->_set_php_values(); |
|
| 3163 | + } |
|
| 3164 | 3164 | |
| 3165 | 3165 | |
| 3166 | 3166 | |
@@ -3178,22 +3178,22 @@ discard block |
||
| 3178 | 3178 | class EE_Tax_Config extends EE_Config_Base |
| 3179 | 3179 | { |
| 3180 | 3180 | |
| 3181 | - /* |
|
| 3181 | + /* |
|
| 3182 | 3182 | * flag to indicate whether or not to display ticket prices with the taxes included |
| 3183 | 3183 | * |
| 3184 | 3184 | * @var boolean $prices_displayed_including_taxes |
| 3185 | 3185 | */ |
| 3186 | - public $prices_displayed_including_taxes; |
|
| 3186 | + public $prices_displayed_including_taxes; |
|
| 3187 | 3187 | |
| 3188 | 3188 | |
| 3189 | 3189 | |
| 3190 | - /** |
|
| 3191 | - * class constructor |
|
| 3192 | - */ |
|
| 3193 | - public function __construct() |
|
| 3194 | - { |
|
| 3195 | - $this->prices_displayed_including_taxes = true; |
|
| 3196 | - } |
|
| 3190 | + /** |
|
| 3191 | + * class constructor |
|
| 3192 | + */ |
|
| 3193 | + public function __construct() |
|
| 3194 | + { |
|
| 3195 | + $this->prices_displayed_including_taxes = true; |
|
| 3196 | + } |
|
| 3197 | 3197 | } |
| 3198 | 3198 | |
| 3199 | 3199 | |
@@ -3208,17 +3208,17 @@ discard block |
||
| 3208 | 3208 | class EE_Messages_Config extends EE_Config_Base |
| 3209 | 3209 | { |
| 3210 | 3210 | |
| 3211 | - /** |
|
| 3212 | - * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
| 3213 | - * A value of 0 represents never deleting. Default is 0. |
|
| 3214 | - * |
|
| 3215 | - * @var integer |
|
| 3216 | - */ |
|
| 3217 | - public $delete_threshold; |
|
| 3218 | - |
|
| 3219 | - public function __construct() { |
|
| 3220 | - $this->delete_threshold = 0; |
|
| 3221 | - } |
|
| 3211 | + /** |
|
| 3212 | + * This is an integer representing the deletion threshold in months for when old messages will get deleted. |
|
| 3213 | + * A value of 0 represents never deleting. Default is 0. |
|
| 3214 | + * |
|
| 3215 | + * @var integer |
|
| 3216 | + */ |
|
| 3217 | + public $delete_threshold; |
|
| 3218 | + |
|
| 3219 | + public function __construct() { |
|
| 3220 | + $this->delete_threshold = 0; |
|
| 3221 | + } |
|
| 3222 | 3222 | } |
| 3223 | 3223 | |
| 3224 | 3224 | |
@@ -3230,34 +3230,34 @@ discard block |
||
| 3230 | 3230 | class EE_Gateway_Config extends EE_Config_Base |
| 3231 | 3231 | { |
| 3232 | 3232 | |
| 3233 | - /** |
|
| 3234 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3235 | - * with any config info the gateway wants to store |
|
| 3236 | - * |
|
| 3237 | - * @var array |
|
| 3238 | - */ |
|
| 3239 | - public $payment_settings; |
|
| 3240 | - |
|
| 3241 | - /** |
|
| 3242 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3243 | - * the gateway is stored in the uploads directory |
|
| 3244 | - * |
|
| 3245 | - * @var array |
|
| 3246 | - */ |
|
| 3247 | - public $active_gateways; |
|
| 3248 | - |
|
| 3249 | - |
|
| 3250 | - |
|
| 3251 | - /** |
|
| 3252 | - * class constructor |
|
| 3253 | - * |
|
| 3254 | - * @deprecated |
|
| 3255 | - */ |
|
| 3256 | - public function __construct() |
|
| 3257 | - { |
|
| 3258 | - $this->payment_settings = array(); |
|
| 3259 | - $this->active_gateways = array('Invoice' => false); |
|
| 3260 | - } |
|
| 3233 | + /** |
|
| 3234 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3235 | + * with any config info the gateway wants to store |
|
| 3236 | + * |
|
| 3237 | + * @var array |
|
| 3238 | + */ |
|
| 3239 | + public $payment_settings; |
|
| 3240 | + |
|
| 3241 | + /** |
|
| 3242 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3243 | + * the gateway is stored in the uploads directory |
|
| 3244 | + * |
|
| 3245 | + * @var array |
|
| 3246 | + */ |
|
| 3247 | + public $active_gateways; |
|
| 3248 | + |
|
| 3249 | + |
|
| 3250 | + |
|
| 3251 | + /** |
|
| 3252 | + * class constructor |
|
| 3253 | + * |
|
| 3254 | + * @deprecated |
|
| 3255 | + */ |
|
| 3256 | + public function __construct() |
|
| 3257 | + { |
|
| 3258 | + $this->payment_settings = array(); |
|
| 3259 | + $this->active_gateways = array('Invoice' => false); |
|
| 3260 | + } |
|
| 3261 | 3261 | } |
| 3262 | 3262 | |
| 3263 | 3263 | // End of file EE_Config.core.php |