@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return void |
92 | 92 | */ |
93 | 93 | public static function set_hooks() { |
94 | - add_action( 'wp_loaded', array( 'EES_Espresso_Thank_You', 'set_definitions' ), 2 ); |
|
94 | + add_action('wp_loaded', array('EES_Espresso_Thank_You', 'set_definitions'), 2); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -104,22 +104,22 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public static function set_hooks_admin() { |
106 | 106 | // AJAX for IPN monitoring |
107 | - add_filter( 'heartbeat_received', array( 'EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor' ), 10, 3 ); |
|
107 | + add_filter('heartbeat_received', array('EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor'), 10, 3); |
|
108 | 108 | add_filter( |
109 | 109 | 'heartbeat_nopriv_received', |
110 | - array( 'EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor' ), |
|
110 | + array('EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor'), |
|
111 | 111 | 10, |
112 | 112 | 3 |
113 | 113 | ); |
114 | 114 | add_action( |
115 | 115 | 'wp_ajax_espresso_resend_reg_confirmation_email', |
116 | - array( 'EES_Espresso_Thank_You', 'resend_reg_confirmation_email' ), |
|
116 | + array('EES_Espresso_Thank_You', 'resend_reg_confirmation_email'), |
|
117 | 117 | 10, |
118 | 118 | 2 |
119 | 119 | ); |
120 | 120 | add_action( |
121 | 121 | 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
122 | - array( 'EES_Espresso_Thank_You', 'resend_reg_confirmation_email' ), |
|
122 | + array('EES_Espresso_Thank_You', 'resend_reg_confirmation_email'), |
|
123 | 123 | 10, |
124 | 124 | 2 |
125 | 125 | ); |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @return void |
135 | 135 | */ |
136 | 136 | public static function set_definitions() { |
137 | - define( 'THANK_YOU_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
138 | - define( 'THANK_YOU_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ ) ) . 'templates' . DS ); |
|
137 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
138 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | * @return EE_Transaction |
148 | 148 | */ |
149 | 149 | public function get_txn() { |
150 | - if ( $this->_current_txn instanceof EE_Transaction ) { |
|
150 | + if ($this->_current_txn instanceof EE_Transaction) { |
|
151 | 151 | return $this->_current_txn; |
152 | 152 | } |
153 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
154 | - if ( ! $TXN_model instanceof EEM_Transaction ) { |
|
153 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
154 | + if ( ! $TXN_model instanceof EEM_Transaction) { |
|
155 | 155 | EE_Error::add_error( |
156 | - __( 'The transaction model could not be established.', 'event_espresso' ), |
|
156 | + __('The transaction model could not be established.', 'event_espresso'), |
|
157 | 157 | __FILE__, |
158 | 158 | __FUNCTION__, |
159 | 159 | __LINE__ |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | return null; |
162 | 162 | } |
163 | 163 | //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
164 | - $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link( $this->_reg_url_link ); |
|
164 | + $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
165 | 165 | // verify TXN |
166 | - if ( WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction ) { |
|
166 | + if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
167 | 167 | EE_Error::add_error( |
168 | 168 | __( |
169 | 169 | 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | * @param int $since |
188 | 188 | * @return mixed array of EE_Payment || FALSE |
189 | 189 | */ |
190 | - public function get_txn_payments( $since = 0 ) { |
|
191 | - if ( ! $this->get_txn() ) { |
|
190 | + public function get_txn_payments($since = 0) { |
|
191 | + if ( ! $this->get_txn()) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | - $args = array( 'order_by' => array( 'PAY_timestamp' => 'ASC' ) ); |
|
195 | - if ( $since > 0 ) { |
|
196 | - $args[0] = array( 'PAY_timestamp' => array( '>', $since ) ); |
|
194 | + $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
195 | + if ($since > 0) { |
|
196 | + $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
197 | 197 | } |
198 | 198 | // get array of payments with most recent first |
199 | - return $this->_current_txn->payments( $args ); |
|
199 | + return $this->_current_txn->payments($args); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | * @return void |
209 | 209 | */ |
210 | 210 | private function _get_reg_url_link() { |
211 | - if ( ! empty( $this->_reg_url_link ) ) { |
|
211 | + if ( ! empty($this->_reg_url_link)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | // only do thank you page stuff if we have a REG_url_link in the url |
215 | - if ( WP_DEBUG && ! EE_Registry::instance()->REQ->is_set( 'e_reg_url_link' ) ) { |
|
215 | + if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
216 | 216 | EE_Error::add_error( |
217 | 217 | __( |
218 | 218 | 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | return; |
226 | 226 | } |
227 | 227 | // check for reg_url_link |
228 | - $this->_reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link' ); |
|
228 | + $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * @param string $reg_url_link |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - public function set_reg_url_link( $reg_url_link = null ) { |
|
241 | - $this->_reg_url_link = ! empty( $reg_url_link ) ? $reg_url_link : $this->_reg_url_link; |
|
240 | + public function set_reg_url_link($reg_url_link = null) { |
|
241 | + $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -251,28 +251,28 @@ discard block |
||
251 | 251 | * @param WP $WP |
252 | 252 | * @return void |
253 | 253 | */ |
254 | - public function run( WP $WP ) { |
|
254 | + public function run(WP $WP) { |
|
255 | 255 | // remove site_url() from thank you page URL |
256 | - $thank_you_page_URL = substr( EE_Registry::instance()->CFG->core->thank_you_page_url(), strlen( home_url() ) ); |
|
256 | + $thank_you_page_URL = substr(EE_Registry::instance()->CFG->core->thank_you_page_url(), strlen(home_url())); |
|
257 | 257 | // remove other non-essential details from URL |
258 | - $thank_you_page_URL = trim( parse_url( $thank_you_page_URL, PHP_URL_PATH ), '/' ); |
|
258 | + $thank_you_page_URL = trim(parse_url($thank_you_page_URL, PHP_URL_PATH), '/'); |
|
259 | 259 | // ensure this shortcode doesn't trigger on anything BUT the thank you page |
260 | - if ( isset( $WP->request ) && trim( $WP->request, '/' ) !== $thank_you_page_URL ) { |
|
260 | + if (isset($WP->request) && trim($WP->request, '/') !== $thank_you_page_URL) { |
|
261 | 261 | return; |
262 | 262 | } else if ( |
263 | - isset( $WP->query_vars['page_id'] ) |
|
264 | - && (int)$WP->query_vars['page_id'] !== (int)EE_Registry::instance()->CFG->core->thank_you_page_id |
|
263 | + isset($WP->query_vars['page_id']) |
|
264 | + && (int) $WP->query_vars['page_id'] !== (int) EE_Registry::instance()->CFG->core->thank_you_page_id |
|
265 | 265 | ) { |
266 | 266 | return; |
267 | 267 | } |
268 | 268 | $this->_get_reg_url_link(); |
269 | 269 | // resend_reg_confirmation_email ? |
270 | - if ( EE_Registry::instance()->REQ->is_set( 'resend' ) ) { |
|
270 | + if (EE_Registry::instance()->REQ->is_set('resend')) { |
|
271 | 271 | EES_Espresso_Thank_You::resend_reg_confirmation_email(); |
272 | 272 | } |
273 | 273 | // load assets |
274 | - add_action( 'wp_enqueue_scripts', array( $this, 'load_js' ), 10 ); |
|
275 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
274 | + add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
275 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
276 | 276 | $this->_translate_strings(); |
277 | 277 | } |
278 | 278 | |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | public function load_js() { |
327 | 327 | wp_register_script( |
328 | 328 | 'thank_you_page', |
329 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
330 | - array( 'espresso_core', 'heartbeat' ), |
|
329 | + THANK_YOU_ASSETS_URL.'thank_you_page.js', |
|
330 | + array('espresso_core', 'heartbeat'), |
|
331 | 331 | EVENT_ESPRESSO_VERSION, |
332 | 332 | true |
333 | 333 | ); |
334 | - wp_enqueue_script( 'thank_you_page' ); |
|
334 | + wp_enqueue_script('thank_you_page'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public function init() { |
347 | 347 | $this->_get_reg_url_link(); |
348 | - if ( ! $this->get_txn() ) { |
|
349 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
348 | + if ( ! $this->get_txn()) { |
|
349 | + EE_Registry::instance()->load_helper('HTML'); |
|
350 | 350 | echo EEH_HTML::div( |
351 | - EEH_HTML::h4( __( 'We\'re sorry...', 'event_espresso' ), '', '' ) . |
|
351 | + EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', ''). |
|
352 | 352 | sprintf( |
353 | 353 | __( |
354 | 354 | 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | return null; |
363 | 363 | } |
364 | 364 | // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
365 | - if ( $this->_current_txn->status_ID() === EEM_Transaction::failed_status_code ) { |
|
366 | - $this->_current_txn->set_status( EEM_Transaction::incomplete_status_code ); |
|
365 | + if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
366 | + $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
367 | 367 | $this->_current_txn->save(); |
368 | 368 | } |
369 | 369 | $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
@@ -376,15 +376,15 @@ discard block |
||
376 | 376 | ); |
377 | 377 | $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
378 | 378 | // txn status ? |
379 | - if ( $this->_current_txn->is_completed() ) { |
|
379 | + if ($this->_current_txn->is_completed()) { |
|
380 | 380 | $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
381 | 381 | } else if ( |
382 | 382 | $this->_current_txn->is_incomplete() |
383 | - && ( $this->_primary_registrant->is_approved() |
|
384 | - || $this->_primary_registrant->is_pending_payment() ) |
|
383 | + && ($this->_primary_registrant->is_approved() |
|
384 | + || $this->_primary_registrant->is_pending_payment()) |
|
385 | 385 | ) { |
386 | 386 | $this->_show_try_pay_again_link = true; |
387 | - } else if ( $this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment() ) { |
|
387 | + } else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
388 | 388 | // its pending |
389 | 389 | $this->_show_try_pay_again_link = isset( |
390 | 390 | EE_Registry::instance()->CFG->registration->show_pending_payment_options |
@@ -410,23 +410,23 @@ discard block |
||
410 | 410 | } |
411 | 411 | // link to SPCO |
412 | 412 | $revisit_spco_url = add_query_arg( |
413 | - array( 'ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link ), |
|
413 | + array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
414 | 414 | EE_Registry::instance()->CFG->core->reg_page_url() |
415 | 415 | ); |
416 | 416 | // link to SPCO payment_options |
417 | 417 | $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
418 | 418 | ? $this->_primary_registrant->payment_overview_url() |
419 | 419 | : add_query_arg( |
420 | - array( 'step' => 'payment_options' ), |
|
420 | + array('step' => 'payment_options'), |
|
421 | 421 | $revisit_spco_url |
422 | 422 | ); |
423 | 423 | // link to SPCO attendee_information |
424 | 424 | $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
425 | 425 | ? $this->_primary_registrant->edit_attendee_information_url() |
426 | 426 | : false; |
427 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
428 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
429 | - do_action( 'AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn ); |
|
427 | + EE_Registry::instance()->load_helper('Template'); |
|
428 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
429 | + do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn); |
|
430 | 430 | // set no cache headers and constants |
431 | 431 | EE_System::do_not_cache(); |
432 | 432 | } |
@@ -441,16 +441,16 @@ discard block |
||
441 | 441 | * @return string |
442 | 442 | * @throws \EE_Error |
443 | 443 | */ |
444 | - public function process_shortcode( $attributes = array() ) { |
|
444 | + public function process_shortcode($attributes = array()) { |
|
445 | 445 | $this->init(); |
446 | - if ( ! $this->_current_txn instanceof EE_Transaction ) { |
|
446 | + if ( ! $this->_current_txn instanceof EE_Transaction) { |
|
447 | 447 | return EE_Error::get_notices(); |
448 | 448 | } |
449 | 449 | //EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
450 | 450 | //EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $this->_current_txn ), true, 'EE_Transaction: ' . $this->_current_txn->ID() ); |
451 | 451 | // link to receipt |
452 | - $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url( 'html' ); |
|
453 | - if ( ! empty( $template_args['TXN_receipt_url'] ) ) { |
|
452 | + $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
|
453 | + if ( ! empty($template_args['TXN_receipt_url'])) { |
|
454 | 454 | $template_args['order_conf_desc'] = __( |
455 | 455 | '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
456 | 456 | 'event_espresso' |
@@ -462,13 +462,13 @@ discard block |
||
462 | 462 | ); |
463 | 463 | } |
464 | 464 | $template_args['transaction'] = $this->_current_txn; |
465 | - $template_args['revisit'] = EE_Registry::instance()->REQ->get( 'revisit', false ); |
|
466 | - add_action( 'AHEE__thank_you_page_overview_template__content', array( $this, 'get_registration_details' ) ); |
|
467 | - if ( $this->_is_primary && ! $this->_current_txn->is_free() ) { |
|
468 | - add_action( 'AHEE__thank_you_page_overview_template__content', array( $this, 'get_ajax_content' ) ); |
|
465 | + $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false); |
|
466 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
467 | + if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
468 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
469 | 469 | } |
470 | 470 | return EEH_Template::locate_template( |
471 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
471 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php', |
|
472 | 472 | $template_args, |
473 | 473 | true, |
474 | 474 | true |
@@ -489,15 +489,15 @@ discard block |
||
489 | 489 | * @return array |
490 | 490 | * @throws \EE_Error |
491 | 491 | */ |
492 | - public static function thank_you_page_IPN_monitor( $response = array(), $data = array() ) { |
|
492 | + public static function thank_you_page_IPN_monitor($response = array(), $data = array()) { |
|
493 | 493 | // does this heartbeat contain our data ? |
494 | - if ( ! isset( $data['espresso_thank_you_page'] ) ) { |
|
494 | + if ( ! isset($data['espresso_thank_you_page'])) { |
|
495 | 495 | return $response; |
496 | 496 | } |
497 | 497 | // check for reg_url_link in the incoming heartbeat data |
498 | - if ( ! isset( $data['espresso_thank_you_page']['e_reg_url_link'] ) ) { |
|
498 | + if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) { |
|
499 | 499 | $response['espresso_thank_you_page'] = array( |
500 | - 'errors' => ! empty( $notices['errors'] ) |
|
500 | + 'errors' => ! empty($notices['errors']) |
|
501 | 501 | ? $notices['errors'] |
502 | 502 | : __( |
503 | 503 | 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
@@ -512,15 +512,15 @@ discard block |
||
512 | 512 | EES_Espresso_Thank_You::set_definitions(); |
513 | 513 | /** @var $espresso_thank_you_page EES_Espresso_Thank_You */ |
514 | 514 | $espresso_thank_you_page = EES_Espresso_Thank_You::instance(); |
515 | - $espresso_thank_you_page->set_reg_url_link( $data['espresso_thank_you_page']['e_reg_url_link'] ); |
|
515 | + $espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']); |
|
516 | 516 | $espresso_thank_you_page->init(); |
517 | 517 | //get TXN |
518 | 518 | $TXN = $espresso_thank_you_page->get_txn(); |
519 | 519 | // no TXN? then get out |
520 | - if ( ! $TXN instanceof EE_Transaction ) { |
|
520 | + if ( ! $TXN instanceof EE_Transaction) { |
|
521 | 521 | $notices = EE_Error::get_notices(); |
522 | 522 | $response['espresso_thank_you_page'] = array( |
523 | - 'errors' => ! empty( $notices['errors'] ) |
|
523 | + 'errors' => ! empty($notices['errors']) |
|
524 | 524 | ? $notices['errors'] |
525 | 525 | : sprintf( |
526 | 526 | __( |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | return $response; |
534 | 534 | } |
535 | 535 | // grab transient of TXN's status |
536 | - $txn_status = isset( $data['espresso_thank_you_page']['txn_status'] ) |
|
536 | + $txn_status = isset($data['espresso_thank_you_page']['txn_status']) |
|
537 | 537 | ? $data['espresso_thank_you_page']['txn_status'] |
538 | 538 | : null; |
539 | 539 | // has the TXN status changed since we last checked (or empty because this is the first time running through this code)? |
540 | - if ( $txn_status !== $TXN->status_ID() ) { |
|
540 | + if ($txn_status !== $TXN->status_ID()) { |
|
541 | 541 | // switch between two possible basic outcomes |
542 | - switch ( $TXN->status_ID() ) { |
|
542 | + switch ($TXN->status_ID()) { |
|
543 | 543 | // TXN has been updated in some way |
544 | 544 | case EEM_Transaction::overpaid_status_code: |
545 | 545 | case EEM_Transaction::complete_status_code: |
@@ -554,25 +554,25 @@ discard block |
||
554 | 554 | case EEM_Transaction::failed_status_code: |
555 | 555 | default: |
556 | 556 | // keep on waiting... |
557 | - return $espresso_thank_you_page->_update_server_wait_time( $data['espresso_thank_you_page'] ); |
|
557 | + return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']); |
|
558 | 558 | } |
559 | 559 | // or is the TXN still failed (never been updated) ??? |
560 | - } else if ( $TXN->failed() ) { |
|
560 | + } else if ($TXN->failed()) { |
|
561 | 561 | // keep on waiting... |
562 | - return $espresso_thank_you_page->_update_server_wait_time( $data['espresso_thank_you_page'] ); |
|
562 | + return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']); |
|
563 | 563 | } |
564 | 564 | // TXN is happening so let's get the payments now |
565 | 565 | // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked |
566 | - $since = isset( $data['espresso_thank_you_page']['get_payments_since'] ) |
|
566 | + $since = isset($data['espresso_thank_you_page']['get_payments_since']) |
|
567 | 567 | ? $data['espresso_thank_you_page']['get_payments_since'] |
568 | 568 | : 0; |
569 | 569 | // then check for payments |
570 | - $payments = $espresso_thank_you_page->get_txn_payments( $since ); |
|
570 | + $payments = $espresso_thank_you_page->get_txn_payments($since); |
|
571 | 571 | // has a payment been processed ? |
572 | - if ( ! empty( $payments ) || $espresso_thank_you_page->_is_offline_payment_method ) { |
|
573 | - if ( $since ) { |
|
572 | + if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) { |
|
573 | + if ($since) { |
|
574 | 574 | $response['espresso_thank_you_page'] = array( |
575 | - 'new_payments' => $espresso_thank_you_page->get_new_payments( $payments ), |
|
575 | + 'new_payments' => $espresso_thank_you_page->get_new_payments($payments), |
|
576 | 576 | 'transaction_details' => $espresso_thank_you_page->get_transaction_details(), |
577 | 577 | 'txn_status' => $TXN->status_ID() |
578 | 578 | ); |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
599 | 599 | * @return array |
600 | 600 | */ |
601 | - private function _update_server_wait_time( $thank_you_page_data = array() ) { |
|
601 | + private function _update_server_wait_time($thank_you_page_data = array()) { |
|
602 | 602 | $response['espresso_thank_you_page'] = array( |
603 | - 'still_waiting' => isset( $thank_you_page_data['initial_access'] ) |
|
603 | + 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
604 | 604 | ? time() - $thank_you_page_data['initial_access'] |
605 | 605 | : 0, |
606 | 606 | 'txn_status' => $this->_current_txn->status_ID() |
@@ -625,17 +625,17 @@ discard block |
||
625 | 625 | $template_args['is_primary'] = $this->_is_primary; |
626 | 626 | $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
627 | 627 | $template_args['resend_reg_confirmation_url'] = add_query_arg( |
628 | - array( 'token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true' ), |
|
628 | + array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
629 | 629 | EE_Registry::instance()->CFG->core->thank_you_page_url() |
630 | 630 | ); |
631 | 631 | // verify template arguments |
632 | - EEH_Template_Validator::verify_instanceof( $template_args['transaction'], '$transaction', 'EE_Transaction' ); |
|
632 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
633 | 633 | EEH_Template_Validator::verify_isnt_null( |
634 | 634 | $template_args['SPCO_attendee_information_url'], |
635 | 635 | '$SPCO_attendee_information_url' |
636 | 636 | ); |
637 | 637 | echo EEH_Template::locate_template( |
638 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
638 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php', |
|
639 | 639 | $template_args, |
640 | 640 | true, |
641 | 641 | true |
@@ -648,16 +648,16 @@ discard block |
||
648 | 648 | * resend_reg_confirmation_email |
649 | 649 | */ |
650 | 650 | public static function resend_reg_confirmation_email() { |
651 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
652 | - $reg_url_link = EE_Registry::instance()->REQ->get( 'token' ); |
|
651 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
652 | + $reg_url_link = EE_Registry::instance()->REQ->get('token'); |
|
653 | 653 | // was a REG_ID passed ? |
654 | - if ( $reg_url_link ) { |
|
655 | - $registration = EE_Registry::instance()->load_model( 'Registration' )->get_one( |
|
656 | - array( array( 'REG_url_link' => $reg_url_link ) ) |
|
654 | + if ($reg_url_link) { |
|
655 | + $registration = EE_Registry::instance()->load_model('Registration')->get_one( |
|
656 | + array(array('REG_url_link' => $reg_url_link)) |
|
657 | 657 | ); |
658 | - if ( $registration instanceof EE_Registration ) { |
|
658 | + if ($registration instanceof EE_Registration) { |
|
659 | 659 | // resend email |
660 | - EED_Messages::process_resend( array( '_REG_ID' => $registration->ID() ) ); |
|
660 | + EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
661 | 661 | } else { |
662 | 662 | EE_Error::add_error( |
663 | 663 | __( |
@@ -681,16 +681,16 @@ discard block |
||
681 | 681 | ); |
682 | 682 | } |
683 | 683 | // request sent via AJAX ? |
684 | - if ( EE_FRONT_AJAX ) { |
|
685 | - echo json_encode( EE_Error::get_notices( false ) ); |
|
684 | + if (EE_FRONT_AJAX) { |
|
685 | + echo json_encode(EE_Error::get_notices(false)); |
|
686 | 686 | die(); |
687 | 687 | // or was JS disabled ? |
688 | 688 | } else { |
689 | 689 | // save errors so that they get picked up on the next request |
690 | - EE_Error::get_notices( true, true ); |
|
690 | + EE_Error::get_notices(true, true); |
|
691 | 691 | wp_safe_redirect( |
692 | 692 | add_query_arg( |
693 | - array( 'e_reg_url_link' => $reg_url_link ), |
|
693 | + array('e_reg_url_link' => $reg_url_link), |
|
694 | 694 | EE_Registry::instance()->CFG->core->thank_you_page_url() |
695 | 695 | ) |
696 | 696 | ); |
@@ -706,26 +706,26 @@ discard block |
||
706 | 706 | * @return void |
707 | 707 | */ |
708 | 708 | public function get_ajax_content() { |
709 | - if ( ! $this->get_txn() ) { |
|
709 | + if ( ! $this->get_txn()) { |
|
710 | 710 | return; |
711 | 711 | } |
712 | 712 | // first determine which event(s) require pre-approval or not |
713 | 713 | $events = array(); |
714 | 714 | $events_requiring_pre_approval = array(); |
715 | - foreach ( $this->_current_txn->registrations() as $registration ) { |
|
716 | - if ( $registration instanceof EE_Registration ) { |
|
715 | + foreach ($this->_current_txn->registrations() as $registration) { |
|
716 | + if ($registration instanceof EE_Registration) { |
|
717 | 717 | $event = $registration->event(); |
718 | - if ( $event instanceof EE_Event ) { |
|
719 | - if ( $registration->is_not_approved() && $registration->event() instanceof EE_Event ) { |
|
720 | - $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
718 | + if ($event instanceof EE_Event) { |
|
719 | + if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
720 | + $events_requiring_pre_approval[$event->ID()] = $event; |
|
721 | 721 | } else { |
722 | - $events[ $event->ID() ] = $event; |
|
722 | + $events[$event->ID()] = $event; |
|
723 | 723 | } |
724 | 724 | } |
725 | 725 | } |
726 | 726 | } |
727 | - $this->display_details_for_events_requiring_pre_approval( $events_requiring_pre_approval ); |
|
728 | - $this->display_details_for_events( $events ); |
|
727 | + $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
728 | + $this->display_details_for_events($events); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | |
@@ -737,8 +737,8 @@ discard block |
||
737 | 737 | * @param EE_Event[] $events |
738 | 738 | * @return string |
739 | 739 | */ |
740 | - public function display_details_for_events( $events = array() ) { |
|
741 | - if ( ! empty( $events ) ) { |
|
740 | + public function display_details_for_events($events = array()) { |
|
741 | + if ( ! empty($events)) { |
|
742 | 742 | ?> |
743 | 743 | <div id="espresso-thank-you-page-ajax-content-dv"> |
744 | 744 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | 'event_espresso' |
751 | 751 | ); ?></span> |
752 | 752 | </div> |
753 | - <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed ) : ?> |
|
753 | + <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
|
754 | 754 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
755 | 755 | <?php echo apply_filters( |
756 | 756 | 'EES_Espresso_Thank_You__get_ajax_content__waiting_for_IPN_msg', |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | ); ?> |
762 | 762 | <br/> |
763 | 763 | <span class="jst-rght ee-block small-text lt-grey-text"> |
764 | - <?php _e( 'current wait time ', 'event_espresso' ); ?> |
|
764 | + <?php _e('current wait time ', 'event_espresso'); ?> |
|
765 | 765 | <span id="espresso-thank-you-page-ajax-time-dv">00:00:00</span></span> |
766 | 766 | </p> |
767 | 767 | <?php endif; ?> |
@@ -781,11 +781,11 @@ discard block |
||
781 | 781 | * @param EE_Event[] $events |
782 | 782 | * @return string |
783 | 783 | */ |
784 | - public function display_details_for_events_requiring_pre_approval( $events = array() ) { |
|
785 | - if ( ! empty( $events ) ) { |
|
784 | + public function display_details_for_events_requiring_pre_approval($events = array()) { |
|
785 | + if ( ! empty($events)) { |
|
786 | 786 | ?> |
787 | 787 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
788 | - <h4 class="orange-text"><?php _e( 'Important Notice:', 'event_espresso' ); ?></h4> |
|
788 | + <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4> |
|
789 | 789 | <p id="events-requiring-pre-approval-pg" class="small-text"> |
790 | 790 | <?php echo apply_filters( |
791 | 791 | 'AHEE__EES_Espresso_Thank_You__get_ajax_content__not_approved_message', |
@@ -796,8 +796,8 @@ discard block |
||
796 | 796 | ); ?> |
797 | 797 | </p> |
798 | 798 | <ul class="events-requiring-pre-approval-ul"> |
799 | - <?php foreach ( $events as $event ) { |
|
800 | - if ( $event instanceof EE_Event ) { |
|
799 | + <?php foreach ($events as $event) { |
|
800 | + if ($event instanceof EE_Event) { |
|
801 | 801 | echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
802 | 802 | $event->name(), |
803 | 803 | '</li>'; |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | $template_args = array(); |
825 | 825 | $template_args['transaction'] = $this->_current_txn; |
826 | 826 | $template_args['reg_url_link'] = $this->_reg_url_link; |
827 | - $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name( true ); |
|
827 | + $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
828 | 828 | // link to SPCO payment_options |
829 | 829 | $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
830 | 830 | $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
831 | 831 | // verify template arguments |
832 | - EEH_Template_Validator::verify_instanceof( $template_args['transaction'], '$transaction', 'EE_Transaction' ); |
|
832 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
833 | 833 | EEH_Template_Validator::verify_isnt_null( |
834 | 834 | $template_args['show_try_pay_again_link'], |
835 | 835 | '$show_try_pay_again_link' |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | '$SPCO_payment_options_url' |
840 | 840 | ); |
841 | 841 | return EEH_Template::locate_template( |
842 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
842 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php', |
|
843 | 843 | $template_args, |
844 | 844 | true, |
845 | 845 | true |
@@ -856,9 +856,9 @@ discard block |
||
856 | 856 | * @return string |
857 | 857 | * @throws \EE_Error |
858 | 858 | */ |
859 | - public function get_payment_row_html( $payment = null ) { |
|
859 | + public function get_payment_row_html($payment = null) { |
|
860 | 860 | $html = ''; |
861 | - if ( $payment instanceof EE_Payment ) { |
|
861 | + if ($payment instanceof EE_Payment) { |
|
862 | 862 | if ( |
863 | 863 | $payment->payment_method() instanceof EE_Payment_Method |
864 | 864 | && $payment->status() === EEM_Payment::status_id_failed |
@@ -867,31 +867,31 @@ discard block |
||
867 | 867 | // considering the registrant has made it to the Thank You page, |
868 | 868 | // any failed payments may actually be pending and the IPN is just slow |
869 | 869 | // so let's |
870 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
870 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
871 | 871 | } |
872 | 872 | $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
873 | - ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
873 | + ? '<br /><span class="small-text">'.$payment->gateway_response().'</span>' |
|
874 | 874 | : ''; |
875 | 875 | $html .= ' |
876 | 876 | <tr> |
877 | 877 | <td> |
878 | - ' . $payment->timestamp() . ' |
|
878 | + ' . $payment->timestamp().' |
|
879 | 879 | </td> |
880 | 880 | <td> |
881 | 881 | ' . ( |
882 | 882 | $payment->payment_method() instanceof EE_Payment_Method |
883 | 883 | ? $payment->payment_method()->name() |
884 | - : __( 'Unknown', 'event_espresso' ) |
|
885 | - ) . ' |
|
884 | + : __('Unknown', 'event_espresso') |
|
885 | + ).' |
|
886 | 886 | </td> |
887 | 887 | <td class="jst-rght"> |
888 | - ' . EEH_Template::format_currency( $payment->amount() ) . ' |
|
888 | + ' . EEH_Template::format_currency($payment->amount()).' |
|
889 | 889 | </td> |
890 | 890 | <td class="jst-rght" style="line-height:1;"> |
891 | - ' . $payment->pretty_status( true ) . $payment_declined_msg . ' |
|
891 | + ' . $payment->pretty_status(true).$payment_declined_msg.' |
|
892 | 892 | </td> |
893 | 893 | </tr>'; |
894 | - do_action( 'AHEE__thank_you_page_payment_details_template__after_each_payment', $payment ); |
|
894 | + do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
895 | 895 | } |
896 | 896 | return $html; |
897 | 897 | } |
@@ -906,14 +906,14 @@ discard block |
||
906 | 906 | * @return string |
907 | 907 | * @throws \EE_Error |
908 | 908 | */ |
909 | - public function get_payment_details( $payments = array() ) { |
|
909 | + public function get_payment_details($payments = array()) { |
|
910 | 910 | //prepare variables for displaying |
911 | 911 | $template_args = array(); |
912 | 912 | $template_args['transaction'] = $this->_current_txn; |
913 | 913 | $template_args['reg_url_link'] = $this->_reg_url_link; |
914 | 914 | $template_args['payments'] = array(); |
915 | - foreach ( $payments as $payment ) { |
|
916 | - $template_args['payments'][] = $this->get_payment_row_html( $payment ); |
|
915 | + foreach ($payments as $payment) { |
|
916 | + $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
917 | 917 | } |
918 | 918 | //create a hacky payment object, but dont save it |
919 | 919 | $payment = EE_Payment::new_instance( |
@@ -926,8 +926,8 @@ discard block |
||
926 | 926 | ) |
927 | 927 | ); |
928 | 928 | $payment_method = $this->_current_txn->payment_method(); |
929 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
930 | - $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content( $payment ); |
|
929 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
930 | + $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
931 | 931 | } else { |
932 | 932 | $template_args['gateway_content'] = ''; |
933 | 933 | } |
@@ -935,19 +935,19 @@ discard block |
||
935 | 935 | $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
936 | 936 | $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
937 | 937 | // verify template arguments |
938 | - EEH_Template_Validator::verify_instanceof( $template_args['transaction'], '$transaction', 'EE_Transaction' ); |
|
939 | - EEH_Template_Validator::verify_isnt_null( $template_args['payments'], '$payments' ); |
|
938 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
939 | + EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
940 | 940 | EEH_Template_Validator::verify_isnt_null( |
941 | 941 | $template_args['show_try_pay_again_link'], |
942 | 942 | '$show_try_pay_again_link' |
943 | 943 | ); |
944 | - EEH_Template_Validator::verify_isnt_null( $template_args['gateway_content'], '$gateway_content' ); |
|
944 | + EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
945 | 945 | EEH_Template_Validator::verify_isnt_null( |
946 | 946 | $template_args['SPCO_payment_options_url'], |
947 | 947 | '$SPCO_payment_options_url' |
948 | 948 | ); |
949 | 949 | return EEH_Template::locate_template( |
950 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
950 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php', |
|
951 | 951 | $template_args, |
952 | 952 | true, |
953 | 953 | true |
@@ -964,11 +964,11 @@ discard block |
||
964 | 964 | * @return string |
965 | 965 | * @throws \EE_Error |
966 | 966 | */ |
967 | - public function get_new_payments( $payments = array() ) { |
|
967 | + public function get_new_payments($payments = array()) { |
|
968 | 968 | $payments_html = ''; |
969 | 969 | //prepare variables for displaying |
970 | - foreach ( $payments as $payment ) { |
|
971 | - $payments_html .= $this->get_payment_row_html( $payment ); |
|
970 | + foreach ($payments as $payment) { |
|
971 | + $payments_html .= $this->get_payment_row_html($payment); |
|
972 | 972 | } |
973 | 973 | return $payments_html; |
974 | 974 | } |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * But either way, the string or the array's values can ONLY contain simple HTML tags. |
25 | 25 | * If you want to allow Full HTML in the value, use EE_Maybe_Serialized_Text_Field |
26 | 26 | */ |
27 | -class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field{ |
|
27 | +class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field { |
|
28 | 28 | /** |
29 | 29 | * removes all non-basic tags when setting |
30 | 30 | * @param string $value_inputted_for_field_on_model_object |
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
34 | - return parent::prepare_for_set( $this->_remove_tags( $value_inputted_for_field_on_model_object ) ); |
|
34 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param array|string $value |
40 | 40 | * @return array|string |
41 | 41 | */ |
42 | - protected function _remove_tags( $value ) { |
|
43 | - if( is_array( $value ) ) { |
|
44 | - foreach( $value as $key => $v ) { |
|
45 | - $value[ $key ] = $this->_remove_tags( $v ); |
|
42 | + protected function _remove_tags($value) { |
|
43 | + if (is_array($value)) { |
|
44 | + foreach ($value as $key => $v) { |
|
45 | + $value[$key] = $this->_remove_tags($v); |
|
46 | 46 | } |
47 | - }elseif( is_string( $value ) ) { |
|
48 | - $value = wp_kses("$value", $this->_get_allowed_tags() ); |
|
47 | + }elseif (is_string($value)) { |
|
48 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
49 | 49 | } |
50 | 50 | return $value; |
51 | 51 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return array|string |
57 | 57 | */ |
58 | 58 | function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
59 | - return $this->_remove_tags( parent::prepare_for_set_from_db( $value_found_in_db_for_model_object ) ); |
|
59 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @global array $allowedtags |
66 | 66 | * @return array |
67 | 67 | */ |
68 | - function _get_allowed_tags(){ |
|
69 | - return apply_filters( 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this ); |
|
68 | + function _get_allowed_tags() { |
|
69 | + return apply_filters('FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', EEH_HTML::get_simple_tags(), $this); |
|
70 | 70 | } |
71 | 71 | } |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' ); |
|
2 | +require_once(EE_MODELS.'fields/EE_Text_Field_Base.php'); |
|
3 | 3 | /** |
4 | 4 | * Only allows a select, small number of html tags: a,abbr,acronym,b,blockquote,cite,code,del,em,i,q,strike,strong,ol,ul,li |
5 | 5 | * If you want more use EE_Post_Content_Field, or if you want to allow ALL, use EE_Full_HTML_Field. |
6 | 6 | * If you want NONE, use EE_Plain_Text_Field. |
7 | 7 | */ |
8 | -class EE_Simple_HTML_Field extends EE_Text_Field_Base{ |
|
8 | +class EE_Simple_HTML_Field extends EE_Text_Field_Base { |
|
9 | 9 | /** |
10 | 10 | * removes all tags when setting |
11 | 11 | * @param string $value_inputted_for_field_on_model_object |
12 | 12 | * @return string |
13 | 13 | */ |
14 | 14 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
15 | - $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags() ); |
|
15 | + $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", EEH_HTML::get_simple_tags()); |
|
16 | 16 | return parent::prepare_for_set($value_with_select_tags); |
17 | 17 | } |
18 | 18 |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | * @since 4.6 |
11 | 11 | * |
12 | 12 | */ |
13 | -class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
13 | +class EE_Simple_HTML_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param null $validation_error_message |
17 | 17 | */ |
18 | - public function __construct( $validation_error_message = NULL ) { |
|
19 | - if( ! $validation_error_message ){ |
|
18 | + public function __construct($validation_error_message = NULL) { |
|
19 | + if ( ! $validation_error_message) { |
|
20 | 20 | $allowedtags = $this->_get_allowed_tags(); |
21 | - $validation_error_message = sprintf( __( "Only simple HTML tags are allowed. Eg, %s", "event_espresso" ), implode( ",", array_keys( $allowedtags ) ) ); |
|
21 | + $validation_error_message = sprintf(__("Only simple HTML tags are allowed. Eg, %s", "event_espresso"), implode(",", array_keys($allowedtags))); |
|
22 | 22 | } |
23 | - parent::__construct( $validation_error_message ); |
|
23 | + parent::__construct($validation_error_message); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function validate($normalized_value) { |
42 | 42 | $allowedtags = $this->_get_allowed_tags(); |
43 | - parent::validate( $normalized_value ); |
|
44 | - $normalized_value_sans_tags = wp_kses( "$normalized_value",$allowedtags ); |
|
45 | - if ( strlen( $normalized_value ) > strlen( $normalized_value_sans_tags ) ) { |
|
46 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'complex_html_tags' ); |
|
43 | + parent::validate($normalized_value); |
|
44 | + $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedtags); |
|
45 | + if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
46 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_HTML ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_HTML) { |
|
45 | 45 | self::$_instance = new EEH_HTML(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | $other_attributes = '', |
103 | 103 | $force_close = false |
104 | 104 | ) { |
105 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
106 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
107 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
108 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
109 | - $html = EEH_HTML::nl( 0, $tag ) . '<' . $tag . $attributes . '>'; |
|
110 | - $html .= ! empty( $content ) ? EEH_HTML::nl( 1, $tag ) . $content : ''; |
|
111 | - $indent = ! empty( $content ) || $force_close ? TRUE : FALSE; |
|
112 | - $html .= ! empty( $content ) || $force_close ? EEH_HTML::_close_tag( $tag, $id, $class, $indent ) : ''; |
|
105 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
106 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
107 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
108 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
109 | + $html = EEH_HTML::nl(0, $tag).'<'.$tag.$attributes.'>'; |
|
110 | + $html .= ! empty($content) ? EEH_HTML::nl(1, $tag).$content : ''; |
|
111 | + $indent = ! empty($content) || $force_close ? TRUE : FALSE; |
|
112 | + $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
113 | 113 | return $html; |
114 | 114 | } |
115 | 115 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | * @param bool $indent |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected static function _close_tag( $tag = 'div', $id = '', $class = '', $indent = TRUE ) { |
|
129 | + protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = TRUE) { |
|
130 | 130 | $comment = ''; |
131 | - if ( $id ) { |
|
132 | - $comment = EEH_HTML::comment( 'close ' . $id ) . EEH_HTML::nl( 0, $tag ); |
|
133 | - } else if ( $class ) { |
|
134 | - $comment = EEH_HTML::comment( 'close ' . $class ) . EEH_HTML::nl( 0, $tag ); |
|
131 | + if ($id) { |
|
132 | + $comment = EEH_HTML::comment('close '.$id).EEH_HTML::nl(0, $tag); |
|
133 | + } else if ($class) { |
|
134 | + $comment = EEH_HTML::comment('close '.$class).EEH_HTML::nl(0, $tag); |
|
135 | 135 | } |
136 | 136 | $html = $indent ? EEH_HTML::nl( -1, $tag ) : ''; |
137 | - $html .= '</' . $tag . '>' . $comment; |
|
137 | + $html .= '</'.$tag.'>'.$comment; |
|
138 | 138 | return $html; |
139 | 139 | } |
140 | 140 | |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public static function div( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
157 | - return EEH_HTML::_open_tag( 'div', $content, $id, $class, $style, $other_attributes ); |
|
156 | + public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
157 | + return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param string $class - html class attribute |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public static function divx( $id = '', $class = '' ) { |
|
171 | - return EEH_HTML::_close_tag( 'div', $id, $class ); |
|
170 | + public static function divx($id = '', $class = '') { |
|
171 | + return EEH_HTML::_close_tag('div', $id, $class); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public static function h1( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
188 | - return EEH_HTML::_open_tag( 'h1', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
187 | + public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
188 | + return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, TRUE); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public static function h2( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
205 | - return EEH_HTML::_open_tag( 'h2', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
204 | + public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
205 | + return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, TRUE); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public static function h3( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
222 | - return EEH_HTML::_open_tag( 'h3', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
221 | + public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
222 | + return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, TRUE); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public static function h4( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
239 | - return EEH_HTML::_open_tag( 'h4', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
238 | + public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
239 | + return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, TRUE); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - public static function h5( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
256 | - return EEH_HTML::_open_tag( 'h5', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
255 | + public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
256 | + return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, TRUE); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public static function h6( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
273 | - return EEH_HTML::_open_tag( 'h6', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
272 | + public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
273 | + return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, TRUE); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - public static function p( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
290 | - return EEH_HTML::_open_tag( 'p', $content, $id, $class, $style, $other_attributes, TRUE ); |
|
289 | + public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
290 | + return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, TRUE); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
303 | 303 | * @return string |
304 | 304 | */ |
305 | - public static function ul( $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
306 | - return EEH_HTML::_open_tag( 'ul', '', $id, $class, $style, $other_attributes ); |
|
305 | + public static function ul($id = '', $class = '', $style = '', $other_attributes = '') { |
|
306 | + return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -316,8 +316,8 @@ discard block |
||
316 | 316 | * @param string $class - html class attribute |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function ulx( $id = '', $class = '' ) { |
|
320 | - return EEH_HTML::_close_tag( 'ul', $id, $class ); |
|
319 | + public static function ulx($id = '', $class = '') { |
|
320 | + return EEH_HTML::_close_tag('ul', $id, $class); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public static function li( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
338 | - return EEH_HTML::_open_tag( 'li', $content, $id, $class, $style, $other_attributes ); |
|
337 | + public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
338 | + return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | * @param string $class - html class attribute |
349 | 349 | * @return string |
350 | 350 | */ |
351 | - public static function lix( $id = '', $class = '' ) { |
|
352 | - return EEH_HTML::_close_tag( 'li', $id, $class ); |
|
351 | + public static function lix($id = '', $class = '') { |
|
352 | + return EEH_HTML::_close_tag('li', $id, $class); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public static function table( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
369 | - return EEH_HTML::_open_tag( 'table', $content, $id, $class, $style, $other_attributes ); |
|
368 | + public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
369 | + return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $class - html class attribute |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public static function tablex( $id = '', $class = '' ) { |
|
382 | - return EEH_HTML::_close_tag( 'table', $id, $class ); |
|
381 | + public static function tablex($id = '', $class = '') { |
|
382 | + return EEH_HTML::_close_tag('table', $id, $class); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public static function thead( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
399 | - return EEH_HTML::_open_tag( 'thead', $content, $id, $class, $style, $other_attributes ); |
|
398 | + public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
399 | + return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param string $class - html class attribute |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - public static function theadx( $id = '', $class = '' ) { |
|
412 | - return EEH_HTML::_close_tag( 'thead', $id, $class ); |
|
411 | + public static function theadx($id = '', $class = '') { |
|
412 | + return EEH_HTML::_close_tag('thead', $id, $class); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public static function tbody( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
429 | - return EEH_HTML::_open_tag( 'tbody', $content, $id, $class, $style, $other_attributes ); |
|
428 | + public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
429 | + return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param string $class - html class attribute |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - public static function tbodyx( $id = '', $class = '' ) { |
|
442 | - return EEH_HTML::_close_tag( 'tbody', $id, $class ); |
|
441 | + public static function tbodyx($id = '', $class = '') { |
|
442 | + return EEH_HTML::_close_tag('tbody', $id, $class); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public static function tr( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
459 | - return EEH_HTML::_open_tag( 'tr', $content, $id, $class, $style, $other_attributes ); |
|
458 | + public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
459 | + return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | * @param string $class - html class attribute |
469 | 469 | * @return string |
470 | 470 | */ |
471 | - public static function trx( $id = '', $class = '' ) { |
|
472 | - return EEH_HTML::_close_tag( 'tr', $id, $class ); |
|
471 | + public static function trx($id = '', $class = '') { |
|
472 | + return EEH_HTML::_close_tag('tr', $id, $class); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -485,8 +485,8 @@ discard block |
||
485 | 485 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
486 | 486 | * @return string |
487 | 487 | */ |
488 | - public static function th( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
489 | - return EEH_HTML::_open_tag( 'th', $content, $id, $class, $style, $other_attributes ); |
|
488 | + public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
489 | + return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $class - html class attribute |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public static function thx( $id = '', $class = '' ) { |
|
502 | - return EEH_HTML::_close_tag( 'th', $id, $class ); |
|
501 | + public static function thx($id = '', $class = '') { |
|
502 | + return EEH_HTML::_close_tag('th', $id, $class); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public static function td( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
519 | - return EEH_HTML::_open_tag( 'td', $content, $id, $class, $style, $other_attributes ); |
|
518 | + public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
519 | + return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | * @param string $class - html class attribute |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public static function tdx( $id = '', $class = '' ) { |
|
532 | - return EEH_HTML::_close_tag( 'td', $id, $class ); |
|
531 | + public static function tdx($id = '', $class = '') { |
|
532 | + return EEH_HTML::_close_tag('td', $id, $class); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * @param int $colspan |
544 | 544 | * @return string |
545 | 545 | */ |
546 | - public static function no_row( $content = '', $colspan = 2 ) { |
|
546 | + public static function no_row($content = '', $colspan = 2) { |
|
547 | 547 | return EEH_HTML::tr( |
548 | - EEH_HTML::td( $content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"' ), |
|
549 | - '', '', 'padding:0; border:none;' |
|
548 | + EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="'.$colspan.'"'), |
|
549 | + '', '', 'padding:0; border:none;' |
|
550 | 550 | ); |
551 | 551 | } |
552 | 552 | |
@@ -566,14 +566,14 @@ discard block |
||
566 | 566 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
567 | 567 | * @return string |
568 | 568 | */ |
569 | - public static function link( $href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
570 | - $link_text = ! empty( $link_text ) ? $link_text : $href; |
|
571 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
572 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
573 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
574 | - $attributes .= ! empty( $title ) ? ' title="' . esc_attr( $title ) . '"' : ''; |
|
575 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
576 | - return '<a href="' . $href . '" ' . $attributes . '>' . $link_text . '</a>'; |
|
569 | + public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
570 | + $link_text = ! empty($link_text) ? $link_text : $href; |
|
571 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
572 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
573 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
574 | + $attributes .= ! empty($title) ? ' title="'.esc_attr($title).'"' : ''; |
|
575 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
576 | + return '<a href="'.$href.'" '.$attributes.'>'.$link_text.'</a>'; |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | |
@@ -590,14 +590,14 @@ discard block |
||
590 | 590 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - public static function img( $src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
594 | - $attributes = ! empty( $src ) ? ' src="' . esc_url_raw( $src ) . '"' : ''; |
|
595 | - $attributes .= ! empty( $alt ) ? ' alt="' . esc_attr( $alt ) . '"' : ''; |
|
596 | - $attributes .= ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
597 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
598 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
599 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
600 | - return '<img' . $attributes . '/>'; |
|
593 | + public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
594 | + $attributes = ! empty($src) ? ' src="'.esc_url_raw($src).'"' : ''; |
|
595 | + $attributes .= ! empty($alt) ? ' alt="'.esc_attr($alt).'"' : ''; |
|
596 | + $attributes .= ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
597 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
598 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
599 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
600 | + return '<img'.$attributes.'/>'; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -615,12 +615,12 @@ discard block |
||
615 | 615 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
616 | 616 | * @return string |
617 | 617 | */ |
618 | - protected static function _inline_tag( $tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
619 | - $attributes = ! empty( $id ) ? ' id="' . EEH_HTML::sanitize_id( $id ) . '"' : ''; |
|
620 | - $attributes .= ! empty( $class ) ? ' class="' . $class . '"' : ''; |
|
621 | - $attributes .= ! empty( $style ) ? ' style="' . $style . '"' : ''; |
|
622 | - $attributes .= ! empty( $other_attributes ) ? ' ' . $other_attributes : ''; |
|
623 | - return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
618 | + protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
619 | + $attributes = ! empty($id) ? ' id="'.EEH_HTML::sanitize_id($id).'"' : ''; |
|
620 | + $attributes .= ! empty($class) ? ' class="'.$class.'"' : ''; |
|
621 | + $attributes .= ! empty($style) ? ' style="'.$style.'"' : ''; |
|
622 | + $attributes .= ! empty($other_attributes) ? ' '.$other_attributes : ''; |
|
623 | + return '<'.$tag.' '.$attributes.'>'.$content.'</'.$tag.'>'; |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -636,8 +636,8 @@ discard block |
||
636 | 636 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
637 | 637 | * @return string |
638 | 638 | */ |
639 | - public static function label( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
640 | - return EEH_HTML::_inline_tag( 'label', $content, $id, $class, $style, $other_attributes ); |
|
639 | + public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
640 | + return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public static function span( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
657 | - return EEH_HTML::_inline_tag( 'span', $content, $id, $class, $style, $other_attributes ); |
|
656 | + public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
657 | + return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
671 | 671 | * @return string |
672 | 672 | */ |
673 | - public static function strong( $content = '', $id = '', $class = '', $style = '', $other_attributes = '' ) { |
|
674 | - return EEH_HTML::_inline_tag( 'strong', $content, $id, $class, $style, $other_attributes ); |
|
673 | + public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') { |
|
674 | + return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
@@ -683,8 +683,8 @@ discard block |
||
683 | 683 | * @param string $comment |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function comment( $comment = '' ) { |
|
687 | - return ! empty( $comment ) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
686 | + public static function comment($comment = '') { |
|
687 | + return ! empty($comment) ? EEH_HTML::nl().'<!-- '.$comment.' -->' : ''; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -695,8 +695,8 @@ discard block |
||
695 | 695 | * @param int $nmbr - the number of line breaks to return |
696 | 696 | * @return string |
697 | 697 | */ |
698 | - public static function br( $nmbr = 1 ) { |
|
699 | - return str_repeat( '<br />', $nmbr ); |
|
698 | + public static function br($nmbr = 1) { |
|
699 | + return str_repeat('<br />', $nmbr); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | * @param int $nmbr - the number of non-breaking spaces to return |
708 | 708 | * @return string |
709 | 709 | */ |
710 | - public static function nbsp( $nmbr = 1 ) { |
|
711 | - return str_repeat( ' ', $nmbr ); |
|
710 | + public static function nbsp($nmbr = 1) { |
|
711 | + return str_repeat(' ', $nmbr); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -722,9 +722,9 @@ discard block |
||
722 | 722 | * @param string $id |
723 | 723 | * @return string |
724 | 724 | */ |
725 | - public static function sanitize_id( $id = '' ) { |
|
726 | - $key = str_replace( ' ', '-', trim( $id ) ); |
|
727 | - return preg_replace( '/[^a-zA-Z0-9_\-]/', '', $key ); |
|
725 | + public static function sanitize_id($id = '') { |
|
726 | + $key = str_replace(' ', '-', trim($id)); |
|
727 | + return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | * @param string $tag |
737 | 737 | * @return string - newline character plus # of indents passed (can be + or -) |
738 | 738 | */ |
739 | - public static function nl( $indent = 0, $tag = 'none' ) { |
|
739 | + public static function nl($indent = 0, $tag = 'none') { |
|
740 | 740 | $html = "\n"; |
741 | - EEH_HTML::indent( $indent, $tag ); |
|
742 | - for ( $x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++ ) { |
|
741 | + EEH_HTML::indent($indent, $tag); |
|
742 | + for ($x = 0; $x < EEH_HTML::$_indent[$tag]; $x++) { |
|
743 | 743 | $html .= "\t"; |
744 | 744 | } |
745 | 745 | return $html; |
@@ -754,17 +754,17 @@ discard block |
||
754 | 754 | * @param int $indent can be negative to decrease the indentation level |
755 | 755 | * @param string $tag |
756 | 756 | */ |
757 | - public static function indent( $indent, $tag = 'none' ){ |
|
757 | + public static function indent($indent, $tag = 'none') { |
|
758 | 758 | static $default_indentation = FALSE; |
759 | - if ( ! $default_indentation ) { |
|
759 | + if ( ! $default_indentation) { |
|
760 | 760 | EEH_HTML::_set_default_indentation(); |
761 | 761 | $default_indentation = TRUE; |
762 | 762 | } |
763 | - if ( ! isset( EEH_HTML::$_indent[ $tag ] )) { |
|
764 | - EEH_HTML::$_indent[ $tag ] = 0; |
|
763 | + if ( ! isset(EEH_HTML::$_indent[$tag])) { |
|
764 | + EEH_HTML::$_indent[$tag] = 0; |
|
765 | 765 | } |
766 | - EEH_HTML::$_indent[ $tag ] += (int)$indent; |
|
767 | - EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
766 | + EEH_HTML::$_indent[$tag] += (int) $indent; |
|
767 | + EEH_HTML::$_indent[$tag] = EEH_HTML::$_indent[$tag] >= 0 ? EEH_HTML::$_indent[$tag] : 0; |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * @global array $allowedtags |
811 | 811 | * @return array |
812 | 812 | */ |
813 | - public static function get_simple_tags(){ |
|
813 | + public static function get_simple_tags() { |
|
814 | 814 | global $allowedtags; |
815 | 815 | $tags_we_allow = $allowedtags; |
816 | - $tags_we_allow['ol']=array(); |
|
817 | - $tags_we_allow['ul']=array(); |
|
818 | - $tags_we_allow['li']=array(); |
|
819 | - $tags_we_allow['br']=array(); |
|
820 | - $tags_we_allow['p']=array(); |
|
821 | - return apply_filters( 'FHEE__EEH_HTML__get_simple_tags', $tags_we_allow ); |
|
816 | + $tags_we_allow['ol'] = array(); |
|
817 | + $tags_we_allow['ul'] = array(); |
|
818 | + $tags_we_allow['li'] = array(); |
|
819 | + $tags_we_allow['br'] = array(); |
|
820 | + $tags_we_allow['p'] = array(); |
|
821 | + return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
25 | - exit( 'No direct script access allowed' ); |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | + exit('No direct script access allowed'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | class Model_Data_Translator { |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * @param string $requested_version |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) { |
|
44 | - if( is_array( $original_value_maybe_array ) ) { |
|
43 | + public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) { |
|
44 | + if (is_array($original_value_maybe_array)) { |
|
45 | 45 | $new_value_maybe_array = array(); |
46 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
47 | - $new_value_maybe_array[ $array_key ] = self::prepare_field_value_from_json( $field_obj, $array_item, $requested_version ); |
|
46 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
47 | + $new_value_maybe_array[$array_key] = self::prepare_field_value_from_json($field_obj, $array_item, $requested_version); |
|
48 | 48 | } |
49 | 49 | } else { |
50 | - $new_value_maybe_array = self::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version ); |
|
50 | + $new_value_maybe_array = self::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version); |
|
51 | 51 | } |
52 | 52 | return $new_value_maybe_array; |
53 | 53 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param string $requested_version |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) { |
|
63 | + public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) { |
|
64 | 64 | $new_value = null; |
65 | - if( $field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | - && in_array( $original_value, array( null, '' ), true ) ) { |
|
65 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | + && in_array($original_value, array(null, ''), true)) { |
|
67 | 67 | $new_value = EE_INF; |
68 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
69 | - $new_value = rest_parse_date( $original_value ); |
|
68 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
69 | + $new_value = rest_parse_date($original_value); |
|
70 | 70 | } else { |
71 | 71 | $new_value = $original_value; |
72 | 72 | } |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | * @param mixed $original_value |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
83 | - if( $original_value === EE_INF ) { |
|
82 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
83 | + if ($original_value === EE_INF) { |
|
84 | 84 | $new_value = self::ee_inf_in_rest; |
85 | - } elseif( $field_obj instanceof \EE_Datetime_Field && |
|
86 | - $original_value instanceof \DateTime ) { |
|
87 | - $new_value = $original_value->format( 'c' ); |
|
88 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
85 | + } elseif ($field_obj instanceof \EE_Datetime_Field && |
|
86 | + $original_value instanceof \DateTime) { |
|
87 | + $new_value = $original_value->format('c'); |
|
88 | + $new_value = mysql_to_rfc3339($new_value); |
|
89 | 89 | } else { |
90 | 90 | $new_value = $original_value; |
91 | 91 | } |
92 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
92 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
93 | 93 | $new_value, |
94 | 94 | $field_obj, |
95 | 95 | $original_value, |
@@ -105,39 +105,39 @@ discard block |
||
105 | 105 | * @param string $requested_version |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
108 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
109 | 109 | $query_param_for_models = array(); |
110 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
110 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
111 | 111 | $field = self::deduce_field_from_query_param( |
112 | - self::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
112 | + self::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
113 | 113 | $model |
114 | 114 | ); |
115 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
115 | + if ($field instanceof \EE_Model_Field_Base) { |
|
116 | 116 | //did they specify an operator? |
117 | - if( is_array( $query_param_value ) ) { |
|
118 | - $op = $query_param_value[ 0 ]; |
|
119 | - $translated_value = array( $op ); |
|
120 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
121 | - $value = $query_param_value[ 1 ]; |
|
122 | - $translated_value[1] = self::prepare_field_values_from_json( $field, $value, $requested_version ); |
|
117 | + if (is_array($query_param_value)) { |
|
118 | + $op = $query_param_value[0]; |
|
119 | + $translated_value = array($op); |
|
120 | + if (isset($query_param_value[1])) { |
|
121 | + $value = $query_param_value[1]; |
|
122 | + $translated_value[1] = self::prepare_field_values_from_json($field, $value, $requested_version); |
|
123 | 123 | } |
124 | 124 | } else { |
125 | - $translated_value = self::prepare_field_value_from_json( $field, $query_param_value, $requested_version ); |
|
125 | + $translated_value = self::prepare_field_value_from_json($field, $query_param_value, $requested_version); |
|
126 | 126 | } |
127 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
127 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
128 | 128 | } else { |
129 | 129 | //so it's not for a field, assume it's a logic query param key |
130 | - $query_param_for_models[ $query_param_key ] = self::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
130 | + $query_param_for_models[$query_param_key] = self::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | return $query_param_for_models; |
134 | 134 | } |
135 | 135 | |
136 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
136 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
137 | 137 | $pos_of_star = strpos($condition_query_param_key, '*'); |
138 | - if($pos_of_star === FALSE){ |
|
138 | + if ($pos_of_star === FALSE) { |
|
139 | 139 | return $condition_query_param_key; |
140 | - }else{ |
|
140 | + } else { |
|
141 | 141 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
142 | 142 | return $condition_query_param_sans_star; |
143 | 143 | } |
@@ -149,26 +149,26 @@ discard block |
||
149 | 149 | * @throws EE_Error |
150 | 150 | * @return EE_Model_Field_Base |
151 | 151 | */ |
152 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
152 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
153 | 153 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
154 | 154 | //which will help us find the database table and column |
155 | 155 | |
156 | - $query_param_parts = explode(".",$query_param_name); |
|
157 | - if(empty($query_param_parts)){ |
|
158 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
156 | + $query_param_parts = explode(".", $query_param_name); |
|
157 | + if (empty($query_param_parts)) { |
|
158 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
159 | 159 | } |
160 | 160 | $number_of_parts = count($query_param_parts); |
161 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
162 | - if($number_of_parts == 1){ |
|
161 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
162 | + if ($number_of_parts == 1) { |
|
163 | 163 | $field_name = $last_query_param_part; |
164 | - }else{// $number_of_parts >= 2 |
|
164 | + } else {// $number_of_parts >= 2 |
|
165 | 165 | //the last part is the column name, and there are only 2parts. therefore... |
166 | 166 | $field_name = $last_query_param_part; |
167 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
167 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
168 | 168 | } |
169 | - try{ |
|
169 | + try { |
|
170 | 170 | return $model->field_settings_for($field_name); |
171 | - }catch(\EE_Error $e){ |
|
171 | + } catch (\EE_Error $e) { |
|
172 | 172 | return null; |
173 | 173 | } |
174 | 174 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since 4.8.35.rc.001 |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Calculated_Model_Fields { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * the WP_Request object, |
39 | 39 | * the controller object |
40 | 40 | */ |
41 | - public function mapping( $refresh = false ) { |
|
42 | - if( ! $this->_mapping || $refresh ) { |
|
41 | + public function mapping($refresh = false) { |
|
42 | + if ( ! $this->_mapping || $refresh) { |
|
43 | 43 | $this->_mapping = $this->_generate_new_mapping(); |
44 | 44 | } |
45 | 45 | return $this->_mapping; |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function _generate_new_mapping() { |
54 | 54 | $rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\'; |
55 | - $event_calculations_class = $rest_api_calculations_namespace . 'Event'; |
|
56 | - $datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime'; |
|
57 | - $registration_class = $rest_api_calculations_namespace . 'Registration'; |
|
55 | + $event_calculations_class = $rest_api_calculations_namespace.'Event'; |
|
56 | + $datetime_calculations_class = $rest_api_calculations_namespace.'Datetime'; |
|
57 | + $registration_class = $rest_api_calculations_namespace.'Registration'; |
|
58 | 58 | return apply_filters( |
59 | 59 | 'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping', |
60 | 60 | array( |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * @param \EEM_Base $model |
92 | 92 | * @return array allowable values for this field |
93 | 93 | */ |
94 | - public function retrieve_calculated_fields_for_model( \EEM_Base $model ) { |
|
94 | + public function retrieve_calculated_fields_for_model(\EEM_Base $model) { |
|
95 | 95 | $mapping = $this->mapping(); |
96 | - if( isset( $mapping[ $model->get_this_model_name() ] ) ) { |
|
97 | - return array_keys( $mapping[ $model->get_this_model_name() ] ); |
|
96 | + if (isset($mapping[$model->get_this_model_name()])) { |
|
97 | + return array_keys($mapping[$model->get_this_model_name()]); |
|
98 | 98 | } else { |
99 | 99 | return array(); |
100 | 100 | } |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | * @return mixed|null |
114 | 114 | * @throws \EE_Error |
115 | 115 | */ |
116 | - public function retrieve_calculated_field_value( \EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller ) { |
|
116 | + public function retrieve_calculated_field_value(\EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller) { |
|
117 | 117 | $mapping = $this->mapping(); |
118 | - if( isset( $mapping[ $model->get_this_model_name() ] ) |
|
119 | - && isset( $mapping[ $model->get_this_model_name() ][ $field_name ] ) ) { |
|
120 | - $classname = $mapping[ $model->get_this_model_name() ][ $field_name ]; |
|
121 | - return call_user_func( array( $classname, $field_name ), $wpdb_row, $rest_request, $controller ); |
|
118 | + if (isset($mapping[$model->get_this_model_name()]) |
|
119 | + && isset($mapping[$model->get_this_model_name()][$field_name])) { |
|
120 | + $classname = $mapping[$model->get_this_model_name()][$field_name]; |
|
121 | + return call_user_func(array($classname, $field_name), $wpdb_row, $rest_request, $controller); |
|
122 | 122 | } |
123 | 123 | throw new Rest_Exception( |
124 | 124 | 'calculated_field_does_not_exist', |
125 | 125 | sprintf( |
126 | - __( 'There is no calculated field %1$s on resource %2$s', 'event_espresso' ), |
|
126 | + __('There is no calculated field %1$s on resource %2$s', 'event_espresso'), |
|
127 | 127 | $field_name, |
128 | 128 | $model->get_this_model_name() |
129 | 129 | ) |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -69,58 +69,58 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - public function __construct(){ |
|
73 | - if( ! $this->_model_name_extended){ |
|
72 | + public function __construct() { |
|
73 | + if ( ! $this->_model_name_extended) { |
|
74 | 74 | throw new EE_Error(sprintf(__("When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", "event_espresso"))); |
75 | 75 | } |
76 | 76 | $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end'; |
77 | - if ( did_action( $construct_end_action )) { |
|
77 | + if (did_action($construct_end_action)) { |
|
78 | 78 | throw new EE_Error( |
79 | 79 | sprintf( |
80 | - __( "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"), |
|
80 | + __("Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"), |
|
81 | 81 | get_class($this), |
82 | 82 | $this->_model_name_extended, |
83 | 83 | $construct_end_action |
84 | 84 | ) |
85 | 85 | ); |
86 | 86 | } |
87 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter')); |
|
88 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter')); |
|
89 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter')); |
|
87 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter')); |
|
88 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter')); |
|
89 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter')); |
|
90 | 90 | $this->_register_extending_methods(); |
91 | 91 | } |
92 | 92 | |
93 | - public function add_extra_tables_on_filter( $existing_tables ){ |
|
94 | - $tables = array_merge( $existing_tables, $this->_extra_tables ); |
|
93 | + public function add_extra_tables_on_filter($existing_tables) { |
|
94 | + $tables = array_merge($existing_tables, $this->_extra_tables); |
|
95 | 95 | return $tables; |
96 | 96 | } |
97 | - public function add_extra_fields_on_filter($existing_fields){ |
|
98 | - if( $this->_extra_fields){ |
|
99 | - foreach($this->_extra_fields as $table_alias => $fields){ |
|
100 | - if( ! isset( $existing_fields[ $table_alias ] ) ){ |
|
101 | - $existing_fields[ $table_alias ] = array(); |
|
97 | + public function add_extra_fields_on_filter($existing_fields) { |
|
98 | + if ($this->_extra_fields) { |
|
99 | + foreach ($this->_extra_fields as $table_alias => $fields) { |
|
100 | + if ( ! isset($existing_fields[$table_alias])) { |
|
101 | + $existing_fields[$table_alias] = array(); |
|
102 | 102 | } |
103 | - $existing_fields[$table_alias] = array_merge($existing_fields[$table_alias],$this->_extra_fields[$table_alias]); |
|
103 | + $existing_fields[$table_alias] = array_merge($existing_fields[$table_alias], $this->_extra_fields[$table_alias]); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | } |
107 | 107 | return $existing_fields; |
108 | 108 | } |
109 | - public function add_extra_relations_on_filter($existing_relations){ |
|
110 | - $relations = array_merge($existing_relations,$this->_extra_relations); |
|
109 | + public function add_extra_relations_on_filter($existing_relations) { |
|
110 | + $relations = array_merge($existing_relations, $this->_extra_relations); |
|
111 | 111 | return $relations; |
112 | 112 | } |
113 | 113 | /** |
114 | 114 | * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the |
115 | 115 | * model extended. (Internally uses filters, and the __call magic method) |
116 | 116 | */ |
117 | - protected function _register_extending_methods(){ |
|
117 | + protected function _register_extending_methods() { |
|
118 | 118 | $all_methods = get_class_methods(get_class($this)); |
119 | - foreach($all_methods as $method_name){ |
|
120 | - if(strpos($method_name, self::extending_method_prefix) === 0){ |
|
119 | + foreach ($all_methods as $method_name) { |
|
120 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
121 | 121 | $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
122 | 122 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
123 | - add_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10,10); |
|
123 | + add_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10, 10); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
@@ -129,27 +129,27 @@ discard block |
||
129 | 129 | * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the |
130 | 130 | * model extended. (Internally uses filters, and the __call magic method) |
131 | 131 | */ |
132 | - public function deregister(){ |
|
133 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter')); |
|
134 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter')); |
|
135 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter')); |
|
132 | + public function deregister() { |
|
133 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter')); |
|
134 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter')); |
|
135 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter')); |
|
136 | 136 | $all_methods = get_class_methods(get_class($this)); |
137 | - foreach($all_methods as $method_name){ |
|
138 | - if(strpos($method_name, self::extending_method_prefix) === 0){ |
|
137 | + foreach ($all_methods as $method_name) { |
|
138 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
139 | 139 | $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
140 | 140 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
141 | - remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10); |
|
141 | + remove_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10); |
|
142 | 142 | } |
143 | 143 | } |
144 | - $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
145 | - if ( class_exists( $model_to_reset ) ) { |
|
144 | + $model_to_reset = 'EEM_'.$this->_model_name_extended; |
|
145 | + if (class_exists($model_to_reset)) { |
|
146 | 146 | $model_to_reset::reset(); |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | |
151 | - public function __call($callback_method_name,$args){ |
|
152 | - if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){ |
|
151 | + public function __call($callback_method_name, $args) { |
|
152 | + if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) { |
|
153 | 153 | //it's a dynamic callback for a method name |
154 | 154 | $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name); |
155 | 155 | $original_return_val = $args[0]; |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | $this->_ = $model_called; |
158 | 158 | $args_provided_to_method_on_model = $args[2]; |
159 | 159 | $extending_method = self::extending_method_prefix.$method_called_on_model; |
160 | - if(method_exists($this, $extending_method)){ |
|
161 | - return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model); |
|
162 | - }else{ |
|
163 | - throw new EE_Error(sprintf(__("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"),$this->_model_name_extended,get_class($this),$extending_method,$extending_method)); |
|
160 | + if (method_exists($this, $extending_method)) { |
|
161 | + return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model); |
|
162 | + } else { |
|
163 | + throw new EE_Error(sprintf(__("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), $this->_model_name_extended, get_class($this), $extending_method, $extending_method)); |
|
164 | 164 | } |
165 | 165 | |
166 | - }else{ |
|
167 | - throw new EE_Error(sprintf(__("There is no method named '%s' on '%s'", "event_espresso"),$callback_method_name,get_class($this))); |
|
166 | + } else { |
|
167 | + throw new EE_Error(sprintf(__("There is no method named '%s' on '%s'", "event_espresso"), $callback_method_name, get_class($this))); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since $VID:$ |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Registration extends Calculations_Base { |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | * @return int |
31 | 31 | * @throws \EE_Error |
32 | 32 | */ |
33 | - public static function datetime_checkin_stati( $wpdb_row, $request, $controller ){ |
|
34 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Registration.REG_ID' ] ) ) { |
|
35 | - $reg = \EEM_Registration::instance()->get_one_by_ID( $wpdb_row[ 'Registration.REG_ID' ] ); |
|
33 | + public static function datetime_checkin_stati($wpdb_row, $request, $controller) { |
|
34 | + if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) { |
|
35 | + $reg = \EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']); |
|
36 | 36 | } else { |
37 | 37 | $reg = null; |
38 | 38 | } |
39 | - if( ! $reg instanceof \EE_Registration |
|
39 | + if ( ! $reg instanceof \EE_Registration |
|
40 | 40 | ) { |
41 | 41 | throw new \EE_Error( |
42 | 42 | sprintf( |
43 | - __( 'Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
44 | - $wpdb_row[ 'Registration.REG_ID' ], |
|
45 | - print_r( $wpdb_row, true ) |
|
43 | + __('Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
44 | + $wpdb_row['Registration.REG_ID'], |
|
45 | + print_r($wpdb_row, true) |
|
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | ) |
55 | 55 | ); |
56 | 56 | $checkin_stati = array(); |
57 | - foreach( $datetime_ids as $datetime_id ) { |
|
58 | - $status = $reg->check_in_status_for_datetime( $datetime_id ); |
|
59 | - switch( $status ) { |
|
57 | + foreach ($datetime_ids as $datetime_id) { |
|
58 | + $status = $reg->check_in_status_for_datetime($datetime_id); |
|
59 | + switch ($status) { |
|
60 | 60 | case \EE_Registration::checkin_status_out: |
61 | 61 | $status_pretty = 'OUT'; |
62 | 62 | break; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $status_pretty = 'NEVER'; |
69 | 69 | break; |
70 | 70 | } |
71 | - $checkin_stati[ $datetime_id ] = $status_pretty; |
|
71 | + $checkin_stati[$datetime_id] = $status_pretty; |
|
72 | 72 | } |
73 | 73 | return $checkin_stati; |
74 | 74 | } |