@@ -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 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * This sets up the email messenger for the EE_messages (notifications) subsystem in EE. |
31 | 31 | */ |
32 | -class EE_Email_messenger extends EE_messenger { |
|
32 | +class EE_Email_messenger extends EE_messenger { |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * The following are the properties that email requires for the message going out. |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | protected function _set_valid_shortcodes() { |
78 | 78 | //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the message type. |
79 | 79 | $this->_valid_shortcodes = array( |
80 | - 'to' => array('email','event_author', 'primary_registration_details', 'recipient_details'), |
|
80 | + 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
81 | 81 | 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details') |
82 | 82 | ); |
83 | 83 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'shortcodes' => array('organization', 'primary_registration_details', 'event_author', 'primary_registration_details', 'recipient_details') |
112 | 112 | ), |
113 | 113 | 'content' => array( |
114 | - 'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list', 'transaction', 'messenger') |
|
114 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list', 'transaction', 'messenger') |
|
115 | 115 | ), |
116 | 116 | 'attendee_list' => array( |
117 | 117 | 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'required' => array('[EVENT_LIST]') |
123 | 123 | ), |
124 | 124 | 'ticket_list' => array( |
125 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list','primary_registration_details', 'recipient_details'), |
|
125 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
126 | 126 | 'required' => array('[TICKET_LIST]') |
127 | 127 | ), |
128 | 128 | 'datetime_list' => array( |
@@ -141,21 +141,21 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @since 4.5.0 |
143 | 143 | */ |
144 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
145 | - if ( $sending_messenger_name = 'html' ) { |
|
146 | - add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10, 8 ); |
|
144 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
145 | + if ($sending_messenger_name = 'html') { |
|
146 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | 152 | |
153 | - public function add_email_css( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) { |
|
153 | + public function add_email_css($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) { |
|
154 | 154 | //prevent recursion on this callback. |
155 | - remove_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10 ); |
|
156 | - $variation = $this->get_variation( $template_pack, $message_type, $url, 'main', $variation, FALSE ); |
|
155 | + remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
156 | + $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, FALSE); |
|
157 | 157 | |
158 | - add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10, 8 ); |
|
158 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
159 | 159 | return $variation; |
160 | 160 | } |
161 | 161 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | 'required' => FALSE, |
188 | 188 | 'validation' => FALSE, |
189 | 189 | 'format' => '%s', |
190 | - 'value' => sprintf( __('Test email sent from %s', 'event_espresso'), get_bloginfo('name') ), |
|
190 | + 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
191 | 191 | 'default'=> '', |
192 | 192 | 'css_class' => '' |
193 | 193 | ) |
@@ -349,16 +349,16 @@ discard block |
||
349 | 349 | * @return bool | WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if present. |
350 | 350 | */ |
351 | 351 | protected function _send_message() { |
352 | - $success = wp_mail( |
|
353 | - html_entity_decode( $this->_to, ENT_QUOTES, "UTF-8" ), |
|
354 | - stripslashes( html_entity_decode( $this->_subject, ENT_QUOTES, "UTF-8" )), |
|
352 | + $success = wp_mail( |
|
353 | + html_entity_decode($this->_to, ENT_QUOTES, "UTF-8"), |
|
354 | + stripslashes(html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8")), |
|
355 | 355 | $this->_body(), |
356 | 356 | $this->_headers() |
357 | 357 | ); |
358 | - if ( ! $success ) { |
|
358 | + if ( ! $success) { |
|
359 | 359 | EE_Error::add_error( |
360 | 360 | sprintf( |
361 | - __( 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', 'event_espresso'), |
|
361 | + __('The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', 'event_espresso'), |
|
362 | 362 | $this->_to, |
363 | 363 | $this->_from, |
364 | 364 | '<br />' |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | * @return string html body of the message content and the related css. |
378 | 378 | */ |
379 | 379 | protected function _preview() { |
380 | - return $this->_body( true ); |
|
380 | + return $this->_body(true); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | */ |
393 | 393 | protected function _headers() { |
394 | 394 | $this->_ensure_has_from_email_address(); |
395 | - $from = stripslashes_deep( html_entity_decode($this->_from, ENT_QUOTES,"UTF-8" ) ); |
|
395 | + $from = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8")); |
|
396 | 396 | $headers = array( |
397 | 397 | 'MIME-Version: 1.0', |
398 | - 'From:' . $from, |
|
399 | - 'Reply-To:' . $from, |
|
398 | + 'From:'.$from, |
|
399 | + 'Reply-To:'.$from, |
|
400 | 400 | 'Content-Type:text/html; charset=utf-8' |
401 | 401 | ); |
402 | 402 | |
403 | 403 | //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the header. |
404 | - add_filter( 'wp_mail_from', array( $this, 'set_from_address' ), 100 ); |
|
405 | - add_filter( 'wp_mail_from_name', array( $this, 'set_from_name' ), 100 ); |
|
406 | - return apply_filters( 'FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this ); |
|
404 | + add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
405 | + add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
406 | + return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * address for the from address to avoid problems with sending emails. |
413 | 413 | */ |
414 | 414 | protected function _ensure_has_from_email_address() { |
415 | - if ( empty( $this->_from ) ) { |
|
415 | + if (empty($this->_from)) { |
|
416 | 416 | $this->_from = get_bloginfo('admin_email'); |
417 | 417 | } |
418 | 418 | } |
@@ -429,21 +429,21 @@ discard block |
||
429 | 429 | * @return array |
430 | 430 | */ |
431 | 431 | private function _parse_from() { |
432 | - if ( strpos( $this->_from, '<' ) !== false ) { |
|
433 | - $from_name = substr( $this->_from, 0, strpos( $this->_from, '<' ) - 1 ); |
|
434 | - $from_name = str_replace( '"', '', $from_name ); |
|
435 | - $from_name = trim( $from_name ); |
|
436 | - |
|
437 | - $from_email = substr( $this->_from, strpos( $this->_from, '<' ) + 1 ); |
|
438 | - $from_email = str_replace( '>', '', $from_email ); |
|
439 | - $from_email = trim( $from_email ); |
|
440 | - } elseif ( trim( $this->_from ) !== '' ) { |
|
432 | + if (strpos($this->_from, '<') !== false) { |
|
433 | + $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
434 | + $from_name = str_replace('"', '', $from_name); |
|
435 | + $from_name = trim($from_name); |
|
436 | + |
|
437 | + $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
438 | + $from_email = str_replace('>', '', $from_email); |
|
439 | + $from_email = trim($from_email); |
|
440 | + } elseif (trim($this->_from) !== '') { |
|
441 | 441 | $from_name = ''; |
442 | - $from_email = trim( $this->_from ); |
|
442 | + $from_email = trim($this->_from); |
|
443 | 443 | } else { |
444 | 444 | $from_name = $from_email = ''; |
445 | 445 | } |
446 | - return array( $from_name, $from_email ); |
|
446 | + return array($from_name, $from_email); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | |
@@ -456,10 +456,10 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @param string $from_email What the original from_email is. |
458 | 458 | */ |
459 | - public function set_from_address( $from_email ) { |
|
459 | + public function set_from_address($from_email) { |
|
460 | 460 | $parsed_from = $this->_parse_from(); |
461 | 461 | //includes fallback if the parsing failed. |
462 | - $from_email = is_array( $parsed_from ) && ! empty( $parsed_from[1] ) ? $parsed_from[1] : get_bloginfo( 'admin_email' ); |
|
462 | + $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) ? $parsed_from[1] : get_bloginfo('admin_email'); |
|
463 | 463 | return $from_email; |
464 | 464 | } |
465 | 465 | |
@@ -473,16 +473,16 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @param string $from_name The original from_name. |
475 | 475 | */ |
476 | - public function set_from_name( $from_name ) { |
|
476 | + public function set_from_name($from_name) { |
|
477 | 477 | $parsed_from = $this->_parse_from(); |
478 | - if ( is_array( $parsed_from) && ! empty( $parsed_from[0] ) ) { |
|
479 | - $from_name = $parsed_from[0]; |
|
478 | + if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
479 | + $from_name = $parsed_from[0]; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
483 | 483 | $from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name; |
484 | 484 | |
485 | - return stripslashes_deep( html_entity_decode($from_name, ENT_QUOTES,"UTF-8" ) ); |
|
485 | + return stripslashes_deep(html_entity_decode($from_name, ENT_QUOTES, "UTF-8")); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | * @param bool $preview will determine whether this is preview template or not. |
494 | 494 | * @return string formatted body for email. |
495 | 495 | */ |
496 | - protected function _body( $preview = false ) { |
|
496 | + protected function _body($preview = false) { |
|
497 | 497 | //setup template args! |
498 | 498 | $this->_template_args = array( |
499 | 499 | 'subject' => $this->_subject, |
500 | 500 | 'from' => $this->_from, |
501 | - 'main_body' => wpautop(stripslashes_deep( html_entity_decode($this->_content, ENT_QUOTES,"UTF-8" ) )) |
|
501 | + 'main_body' => wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))) |
|
502 | 502 | ); |
503 | - $body = $this->_get_main_template( $preview ); |
|
503 | + $body = $this->_get_main_template($preview); |
|
504 | 504 | |
505 | 505 | /** |
506 | 506 | * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
@@ -508,17 +508,17 @@ discard block |
||
508 | 508 | * @type bool $preview Indicates whether a preview is being generated or not. |
509 | 509 | * @return bool true indicates to use the inliner, false bypasses it. |
510 | 510 | */ |
511 | - if ( apply_filters( 'FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview ) ) { |
|
511 | + if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
512 | 512 | |
513 | 513 | //require CssToInlineStyles library and its dependencies via composer autoloader |
514 | - require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
514 | + require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php'; |
|
515 | 515 | |
516 | 516 | //now if this isn't a preview, let's setup the body so it has inline styles |
517 | - if ( ! $preview || ( $preview && defined( 'DOING_AJAX' ) ) ) { |
|
518 | - $style = file_get_contents( $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, FALSE, 'main', $this->_variation ), TRUE ); |
|
519 | - $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles( $body, $style ); |
|
520 | - $body = ltrim( $CSS->convert( true ), ">\n" ); //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
521 | - $body = ltrim( $body, "<?" ); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
517 | + if ( ! $preview || ($preview && defined('DOING_AJAX'))) { |
|
518 | + $style = file_get_contents($this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, FALSE, 'main', $this->_variation), TRUE); |
|
519 | + $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
520 | + $body = ltrim($CSS->convert(true), ">\n"); //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
521 | + $body = ltrim($body, "<?"); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | public function get_existing_test_settings() { |
538 | 538 | $settings = parent::get_existing_test_settings(); |
539 | 539 | //override subject if present because we always want it to be fresh. |
540 | - if ( is_array( $settings ) && ! empty( $settings['subject'] ) ) { |
|
541 | - $settings['subject'] = sprintf( __('Test email sent from %s', 'event_espresso'), get_bloginfo('name') ); |
|
540 | + if (is_array($settings) && ! empty($settings['subject'])) { |
|
541 | + $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
542 | 542 | } |
543 | 543 | return $settings; |
544 | 544 | } |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @param null $field_to_order_by What field is being used as the reference point. |
856 | 856 | * @param array $query_params Any additional conditions on the query. |
857 | - * @param null $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
857 | + * @param string $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
858 | 858 | * you can indicate just the columns you want returned |
859 | 859 | * @return array|EE_Base_Class |
860 | 860 | * @throws \EE_Error |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | * |
879 | 879 | * @param null $field_to_order_by What field is being used as the reference point. |
880 | 880 | * @param array $query_params Any additional conditions on the query. |
881 | - * @param null $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
881 | + * @param string $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
882 | 882 | * you can indicate just the column you want returned |
883 | 883 | * @return array|EE_Base_Class |
884 | 884 | * @throws \EE_Error |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * This method simply returns the RAW unprocessed value for the given property in this class |
948 | 948 | * |
949 | 949 | * @param string $field_name A valid fieldname |
950 | - * @return mixed Whatever the raw value stored on the property is. |
|
950 | + * @return integer|null Whatever the raw value stored on the property is. |
|
951 | 951 | * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist. |
952 | 952 | */ |
953 | 953 | public function get_raw($field_name) { |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * sets the time on a datetime property |
1239 | 1239 | * |
1240 | 1240 | * @access protected |
1241 | - * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
|
1241 | + * @param string $time a valid time string for php datetime functions (or DateTime object) |
|
1242 | 1242 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1243 | 1243 | * @throws \EE_Error |
1244 | 1244 | */ |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | * sets the date on a datetime property |
1253 | 1253 | * |
1254 | 1254 | * @access protected |
1255 | - * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
|
1255 | + * @param string $date a valid date string for php datetime functions ( or DateTime object) |
|
1256 | 1256 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1257 | 1257 | * @throws \EE_Error |
1258 | 1258 | */ |
@@ -1309,6 +1309,7 @@ discard block |
||
1309 | 1309 | * @param mixed (array|string) $args This is the arguments that will be passed to the callback. |
1310 | 1310 | * @param string $prepend You can include something to prepend on the timestamp |
1311 | 1311 | * @param string $append You can include something to append on the timestamp |
1312 | + * @param string $args |
|
1312 | 1313 | * @throws EE_Error |
1313 | 1314 | * @return string timestamp |
1314 | 1315 | */ |
@@ -1669,7 +1670,7 @@ discard block |
||
1669 | 1670 | * |
1670 | 1671 | * @param array $props_n_values incoming array of properties and their values |
1671 | 1672 | * @param string $classname the classname of the child class |
1672 | - * @param null $timezone |
|
1673 | + * @param string|null $timezone |
|
1673 | 1674 | * @param array $date_formats incoming date_formats in an array where the first value is the |
1674 | 1675 | * date_format and the second value is the time format |
1675 | 1676 | * @return mixed (EE_Base_Class|bool) |
@@ -1745,7 +1746,7 @@ discard block |
||
1745 | 1746 | /** |
1746 | 1747 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
1747 | 1748 | * @param string $model_classname |
1748 | - * @param null $timezone |
|
1749 | + * @param string|null $timezone |
|
1749 | 1750 | * @return EEM_Base |
1750 | 1751 | */ |
1751 | 1752 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
@@ -1422,24 +1422,24 @@ discard block |
||
1422 | 1422 | * |
1423 | 1423 | * @throws \EE_Error |
1424 | 1424 | */ |
1425 | - public function refresh_cache_of_related_objects() { |
|
1426 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1427 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1428 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1429 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1430 | - //this relation only stores a single model object, not an array |
|
1431 | - //but let's make it consistent |
|
1432 | - $related_objects = array( $related_objects ); |
|
1433 | - } |
|
1434 | - foreach( $related_objects as $related_object ) { |
|
1435 | - //only refresh their cache if they're in memory |
|
1436 | - if( $related_object instanceof EE_Base_Class ) { |
|
1425 | + public function refresh_cache_of_related_objects() { |
|
1426 | + foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1427 | + if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1428 | + $related_objects = $this->_model_relations[ $relation_name ]; |
|
1429 | + if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1430 | + //this relation only stores a single model object, not an array |
|
1431 | + //but let's make it consistent |
|
1432 | + $related_objects = array( $related_objects ); |
|
1433 | + } |
|
1434 | + foreach( $related_objects as $related_object ) { |
|
1435 | + //only refresh their cache if they're in memory |
|
1436 | + if( $related_object instanceof EE_Base_Class ) { |
|
1437 | 1437 | $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
1438 | - } |
|
1439 | - } |
|
1440 | - } |
|
1441 | - } |
|
1442 | - } |
|
1438 | + } |
|
1439 | + } |
|
1440 | + } |
|
1441 | + } |
|
1442 | + } |
|
1443 | 1443 | |
1444 | 1444 | |
1445 | 1445 | |
@@ -1680,7 +1680,7 @@ discard block |
||
1680 | 1680 | if ( self::_get_model( $classname )->has_primary_key_field() ) { |
1681 | 1681 | $primary_id_ref = self::_get_primary_key_name( $classname ); |
1682 | 1682 | if ( array_key_exists( $primary_id_ref, $props_n_values ) |
1683 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1683 | + && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1684 | 1684 | ) { |
1685 | 1685 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
1686 | 1686 | $props_n_values[ $primary_id_ref ] |
@@ -1832,9 +1832,9 @@ discard block |
||
1832 | 1832 | $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
1833 | 1833 | //clear cache so future get_many_related and get_first_related() return new results. |
1834 | 1834 | $this->clear_cache( $relationName, $otherObject, TRUE ); |
1835 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1836 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1837 | - } |
|
1835 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1836 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1837 | + } |
|
1838 | 1838 | } else { |
1839 | 1839 | //this thing doesn't exist in the DB, so just cache it |
1840 | 1840 | if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
@@ -1848,18 +1848,18 @@ discard block |
||
1848 | 1848 | } |
1849 | 1849 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
1850 | 1850 | } |
1851 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1852 | - //fix the reciprocal relation too |
|
1853 | - if( $otherObject->ID() ) { |
|
1854 | - //its saved so assumed relations exist in the DB, so we can just |
|
1855 | - //clear the cache so future queries use the updated info in the DB |
|
1856 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1857 | - } else { |
|
1858 | - |
|
1859 | - //it's not saved, so it caches relations like this |
|
1860 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1861 | - } |
|
1862 | - } |
|
1851 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1852 | + //fix the reciprocal relation too |
|
1853 | + if( $otherObject->ID() ) { |
|
1854 | + //its saved so assumed relations exist in the DB, so we can just |
|
1855 | + //clear the cache so future queries use the updated info in the DB |
|
1856 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1857 | + } else { |
|
1858 | + |
|
1859 | + //it's not saved, so it caches relations like this |
|
1860 | + $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1861 | + } |
|
1862 | + } |
|
1863 | 1863 | return $otherObject; |
1864 | 1864 | } |
1865 | 1865 | |
@@ -1890,9 +1890,9 @@ discard block |
||
1890 | 1890 | //this doesn't exist in the DB, just remove it from the cache |
1891 | 1891 | $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
1892 | 1892 | } |
1893 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1894 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1895 | - } |
|
1893 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1894 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1895 | + } |
|
1896 | 1896 | return $otherObject; |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1915,11 +1915,11 @@ discard block |
||
1915 | 1915 | //this doesn't exist in the DB, just remove it from the cache |
1916 | 1916 | $otherObjects = $this->clear_cache( $relationName, null, true ); |
1917 | 1917 | } |
1918 | - if( is_array( $otherObjects ) ) { |
|
1919 | - foreach ( $otherObjects as $otherObject ) { |
|
1920 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1921 | - } |
|
1922 | - } |
|
1918 | + if( is_array( $otherObjects ) ) { |
|
1919 | + foreach ( $otherObjects as $otherObject ) { |
|
1920 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1921 | + } |
|
1922 | + } |
|
1923 | 1923 | return $otherObjects; |
1924 | 1924 | } |
1925 | 1925 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -110,58 +110,58 @@ discard block |
||
110 | 110 | * format. |
111 | 111 | * @throws EE_Error |
112 | 112 | */ |
113 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){ |
|
113 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) { |
|
114 | 114 | |
115 | - $className=get_class($this); |
|
115 | + $className = get_class($this); |
|
116 | 116 | |
117 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
118 | - $model=$this->get_model(); |
|
119 | - $model_fields = $model->field_settings( FALSE ); |
|
117 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
118 | + $model = $this->get_model(); |
|
119 | + $model_fields = $model->field_settings(FALSE); |
|
120 | 120 | // ensure $fieldValues is an array |
121 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
121 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
122 | 122 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
123 | 123 | // verify client code has not passed any invalid field names |
124 | - foreach($fieldValues as $field_name=> $field_value){ |
|
125 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
126 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
124 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
125 | + if ( ! isset($model_fields[$field_name])) { |
|
126 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
130 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
130 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
131 | 131 | |
132 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
133 | - list( $this->_dt_frmt, $this->_tm_frmt ) = $date_formats; |
|
132 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
133 | + list($this->_dt_frmt, $this->_tm_frmt) = $date_formats; |
|
134 | 134 | } else { |
135 | 135 | //set default formats for date and time |
136 | - $this->_dt_frmt = (string) get_option( 'date_format', 'Y-m-d' ); |
|
137 | - $this->_tm_frmt = (string) get_option( 'time_format', 'g:i a' ); |
|
136 | + $this->_dt_frmt = (string) get_option('date_format', 'Y-m-d'); |
|
137 | + $this->_tm_frmt = (string) get_option('time_format', 'g:i a'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | //if db model is instantiating |
141 | - if ( $bydb ){ |
|
141 | + if ($bydb) { |
|
142 | 142 | //client code has indicated these field values are from the database |
143 | - foreach( $model_fields as $fieldName => $field ){ |
|
144 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
143 | + foreach ($model_fields as $fieldName => $field) { |
|
144 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
145 | 145 | } |
146 | 146 | } else { |
147 | 147 | //we're constructing a brand |
148 | 148 | //new instance of the model object. Generally, this means we'll need to do more field validation |
149 | - foreach( $model_fields as $fieldName => $field ){ |
|
150 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
149 | + foreach ($model_fields as $fieldName => $field) { |
|
150 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | //remember what values were passed to this constructor |
155 | 155 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
156 | 156 | //remember in entity mapper |
157 | - if( ! $bydb && $model->has_primary_key_field() && $this->ID() ){ |
|
157 | + if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) { |
|
158 | 158 | $model->add_to_entity_map($this); |
159 | 159 | } |
160 | 160 | //setup all the relations |
161 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
162 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
161 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
162 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
163 | 163 | $this->_model_relations[$relation_name] = NULL; |
164 | - }else{ |
|
164 | + } else { |
|
165 | 165 | $this->_model_relations[$relation_name] = array(); |
166 | 166 | } |
167 | 167 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * Action done at the end of each model object construction |
170 | 170 | * @param EE_Base_Class $this the model object just created |
171 | 171 | */ |
172 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
172 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @param boolean $allow_persist |
190 | 190 | * @return boolean |
191 | 191 | */ |
192 | - public function set_allow_persist( $allow_persist ) { |
|
192 | + public function set_allow_persist($allow_persist) { |
|
193 | 193 | return $this->_allow_persist = $allow_persist; |
194 | 194 | } |
195 | 195 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * @return mixed|null |
204 | 204 | * @throws \EE_Error |
205 | 205 | */ |
206 | - public function get_original( $field_name ){ |
|
207 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
208 | - $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
|
209 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
210 | - }else{ |
|
206 | + public function get_original($field_name) { |
|
207 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
208 | + $field_settings = $this->get_model()->field_settings_for($field_name)) { |
|
209 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
210 | + } else { |
|
211 | 211 | return NULL; |
212 | 212 | } |
213 | 213 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param EE_Base_Class $obj |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function get_class($obj){ |
|
220 | + public function get_class($obj) { |
|
221 | 221 | return get_class($obj); |
222 | 222 | } |
223 | 223 | |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | * @param bool $use_default |
233 | 233 | * @throws \EE_Error |
234 | 234 | */ |
235 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
236 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
237 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
235 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
236 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
237 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
238 | 238 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
239 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
240 | - $field_obj->set_timezone( $this->_timezone ); |
|
241 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
242 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
239 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
240 | + $field_obj->set_timezone($this->_timezone); |
|
241 | + $field_obj->set_date_format($this->_dt_frmt); |
|
242 | + $field_obj->set_time_format($this->_tm_frmt); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
246 | 246 | //should the value be null? |
247 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
247 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
248 | 248 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
249 | 249 | |
250 | 250 | /** |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | */ |
257 | 257 | if ( |
258 | 258 | $field_obj instanceof EE_Datetime_Field |
259 | - && $this->_fields[ $field_name ] !== null |
|
259 | + && $this->_fields[$field_name] !== null |
|
260 | 260 | && ! $this->_fields[$field_name] instanceof DateTime |
261 | 261 | ) { |
262 | - empty( $this->_fields[$field_name] ) |
|
263 | - ? $this->set( $field_name, time() ) |
|
264 | - : $this->set( $field_name, $this->_fields[$field_name] ); |
|
262 | + empty($this->_fields[$field_name]) |
|
263 | + ? $this->set($field_name, time()) |
|
264 | + : $this->set($field_name, $this->_fields[$field_name]); |
|
265 | 265 | } |
266 | 266 | |
267 | - }else{ |
|
267 | + } else { |
|
268 | 268 | $this->_fields[$field_name] = $holder_of_value; |
269 | 269 | } |
270 | 270 | |
271 | 271 | //if we're not in the constructor... |
272 | 272 | //now check if what we set was a primary key |
273 | - if( |
|
273 | + if ( |
|
274 | 274 | //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
275 | 275 | $this->_props_n_values_provided_in_constructor |
276 | 276 | && $field_value |
277 | - && $field_name === self::_get_primary_key_name( get_class( $this ) ) |
|
278 | - ){ |
|
277 | + && $field_name === self::_get_primary_key_name(get_class($this)) |
|
278 | + ) { |
|
279 | 279 | //if so, we want all this object's fields to be filled either with |
280 | 280 | //what we've explicitly set on this model |
281 | 281 | //or what we have in the db |
@@ -283,20 +283,20 @@ discard block |
||
283 | 283 | $fields_on_model = self::_get_model(get_class($this))->field_settings(); |
284 | 284 | |
285 | 285 | $obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value); |
286 | - foreach($fields_on_model as $field_obj){ |
|
287 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
288 | - && $field_obj->get_name() !== $field_name ){ |
|
286 | + foreach ($fields_on_model as $field_obj) { |
|
287 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
288 | + && $field_obj->get_name() !== $field_name) { |
|
289 | 289 | |
290 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
290 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | //oh this model object has an ID? well make sure its in the entity mapper |
294 | 294 | $this->get_model()->add_to_entity_map($this); |
295 | 295 | } |
296 | 296 | //let's unset any cache for this field_name from the $_cached_properties property. |
297 | - $this->_clear_cached_property( $field_name ); |
|
298 | - }else{ |
|
299 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
297 | + $this->_clear_cached_property($field_name); |
|
298 | + } else { |
|
299 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | } |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
314 | 314 | * @throws \EE_Error |
315 | 315 | */ |
316 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
317 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
318 | - $this->set( $field_name, $field_value ); |
|
316 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
317 | + if ($this->get_model()->has_field($field_name)) { |
|
318 | + $this->set($field_name, $field_value); |
|
319 | 319 | return true; |
320 | 320 | } else { |
321 | 321 | //ensure this object is saved first so that extra meta can be properly related. |
322 | 322 | $this->save(); |
323 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
323 | + return $this->update_extra_meta($field_name, $field_value); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | * @return mixed|null value for the field if found. null if not found. |
342 | 342 | * @throws \EE_Error |
343 | 343 | */ |
344 | - public function get_field_or_extra_meta( $field_name ) { |
|
345 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
346 | - $column_value = $this->get( $field_name ); |
|
344 | + public function get_field_or_extra_meta($field_name) { |
|
345 | + if ($this->get_model()->has_field($field_name)) { |
|
346 | + $column_value = $this->get($field_name); |
|
347 | 347 | } else { |
348 | 348 | //This isn't a column in the main table, let's see if it is in the extra meta. |
349 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
349 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
350 | 350 | } |
351 | 351 | return $column_value; |
352 | 352 | } |
@@ -362,18 +362,18 @@ discard block |
||
362 | 362 | * @return void |
363 | 363 | * @throws \EE_Error |
364 | 364 | */ |
365 | - public function set_timezone( $timezone = '' ) { |
|
366 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
365 | + public function set_timezone($timezone = '') { |
|
366 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
367 | 367 | //make sure we clear all cached properties because they won't be relevant now |
368 | 368 | $this->_clear_cached_properties(); |
369 | 369 | |
370 | 370 | //make sure we update field settings and the date for all EE_Datetime_Fields |
371 | - $model_fields = $this->get_model()->field_settings( false ); |
|
372 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
373 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
374 | - $field_obj->set_timezone( $this->_timezone ); |
|
375 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
376 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
371 | + $model_fields = $this->get_model()->field_settings(false); |
|
372 | + foreach ($model_fields as $field_name => $field_obj) { |
|
373 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
374 | + $field_obj->set_timezone($this->_timezone); |
|
375 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
376 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @param string $format should be a format recognizable by PHP date() functions. |
404 | 404 | */ |
405 | - public function set_date_format( $format ) { |
|
405 | + public function set_date_format($format) { |
|
406 | 406 | $this->_dt_frmt = $format; |
407 | 407 | //clear cached_properties because they won't be relevant now. |
408 | 408 | $this->_clear_cached_properties(); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @since 4.6 |
419 | 419 | * @param string $format should be a format recognizable by PHP date() functions. |
420 | 420 | */ |
421 | - public function set_time_format( $format ) { |
|
421 | + public function set_time_format($format) { |
|
422 | 422 | $this->_tm_frmt = $format; |
423 | 423 | //clear cached_properties because they won't be relevant now. |
424 | 424 | $this->_clear_cached_properties(); |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return mixed string|array |
437 | 437 | */ |
438 | - public function get_format( $full = true ) { |
|
439 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
438 | + public function get_format($full = true) { |
|
439 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | * @throws EE_Error |
455 | 455 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
456 | 456 | */ |
457 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
457 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
458 | 458 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
459 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
459 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
460 | 460 | return FALSE; |
461 | 461 | } |
462 | 462 | // also get "how" the object is related, or throw an error |
463 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
464 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
463 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
464 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
465 | 465 | } |
466 | 466 | // how many things are related ? |
467 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
467 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
468 | 468 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
469 | 469 | // so for these model objects just set it to be cached |
470 | 470 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -472,26 +472,26 @@ discard block |
||
472 | 472 | } else { |
473 | 473 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
474 | 474 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
475 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
475 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
476 | 476 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
477 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
477 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
478 | 478 | } |
479 | 479 | // first check for a cache_id which is normally empty |
480 | - if ( ! empty( $cache_id )) { |
|
480 | + if ( ! empty($cache_id)) { |
|
481 | 481 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
482 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
482 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
483 | 483 | $return = $cache_id; |
484 | - } elseif ( $object_to_cache->ID() ) { |
|
484 | + } elseif ($object_to_cache->ID()) { |
|
485 | 485 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
486 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
486 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
487 | 487 | $return = $object_to_cache->ID(); |
488 | 488 | } else { |
489 | 489 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
490 | 490 | $this->_model_relations[$relationName][] = $object_to_cache; |
491 | 491 | // move the internal pointer to the end of the array |
492 | - end( $this->_model_relations[$relationName] ); |
|
492 | + end($this->_model_relations[$relationName]); |
|
493 | 493 | // and grab the key so that we can return it |
494 | - $return = key( $this->_model_relations[$relationName] ); |
|
494 | + $return = key($this->_model_relations[$relationName]); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | } |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * @return void |
511 | 511 | * @throws \EE_Error |
512 | 512 | */ |
513 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
513 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
514 | 514 | //first make sure this property exists |
515 | 515 | $this->get_model()->field_settings_for($fieldname); |
516 | 516 | |
517 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
517 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
518 | 518 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
519 | 519 | } |
520 | 520 | |
@@ -535,36 +535,36 @@ discard block |
||
535 | 535 | * @return mixed whatever the value for the property is we're retrieving |
536 | 536 | * @throws \EE_Error |
537 | 537 | */ |
538 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
538 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
539 | 539 | //verify the field exists |
540 | 540 | $this->get_model()->field_settings_for($fieldname); |
541 | 541 | |
542 | 542 | $cache_type = $pretty ? 'pretty' : 'standard'; |
543 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
543 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
544 | 544 | |
545 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
545 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
546 | 546 | return $this->_cached_properties[$fieldname][$cache_type]; |
547 | 547 | } |
548 | 548 | |
549 | 549 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
550 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
550 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
551 | 551 | /** |
552 | 552 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
553 | 553 | * formats are correct. |
554 | 554 | */ |
555 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
556 | - $field_obj->set_timezone( $this->_timezone ); |
|
557 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
558 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
555 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
556 | + $field_obj->set_timezone($this->_timezone); |
|
557 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
558 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
559 | 559 | } |
560 | 560 | |
561 | - if( ! isset($this->_fields[$fieldname])){ |
|
561 | + if ( ! isset($this->_fields[$fieldname])) { |
|
562 | 562 | $this->_fields[$fieldname] = NULL; |
563 | 563 | } |
564 | 564 | $value = $pretty |
565 | 565 | ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) |
566 | - : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
567 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
566 | + : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
567 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
568 | 568 | return $value; |
569 | 569 | } |
570 | 570 | return null; |
@@ -590,9 +590,9 @@ discard block |
||
590 | 590 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
591 | 591 | * @return void |
592 | 592 | */ |
593 | - protected function _clear_cached_property( $property_name ) { |
|
594 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
595 | - unset( $this->_cached_properties[ $property_name ] ); |
|
593 | + protected function _clear_cached_property($property_name) { |
|
594 | + if (isset($this->_cached_properties[$property_name])) { |
|
595 | + unset($this->_cached_properties[$property_name]); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | * @return EE_Base_Class |
607 | 607 | * @throws \EE_Error |
608 | 608 | */ |
609 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
609 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
610 | 610 | $other_model_instance = self::_get_model_instance_with_name( |
611 | - self::_get_model_classname( $model_name ), |
|
611 | + self::_get_model_classname($model_name), |
|
612 | 612 | $this->_timezone |
613 | 613 | ); |
614 | - return $other_model_instance->ensure_is_obj( $object_or_id ); |
|
614 | + return $other_model_instance->ensure_is_obj($object_or_id); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | |
@@ -628,32 +628,32 @@ discard block |
||
628 | 628 | * @throws EE_Error |
629 | 629 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
630 | 630 | */ |
631 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
631 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
632 | 632 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
633 | 633 | $index_in_cache = ''; |
634 | - if( ! $relationship_to_model){ |
|
634 | + if ( ! $relationship_to_model) { |
|
635 | 635 | throw new EE_Error( |
636 | 636 | sprintf( |
637 | - __( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ), |
|
637 | + __("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), |
|
638 | 638 | $relationName, |
639 | - get_class( $this ) |
|
639 | + get_class($this) |
|
640 | 640 | ) |
641 | 641 | ); |
642 | 642 | } |
643 | - if($clear_all){ |
|
643 | + if ($clear_all) { |
|
644 | 644 | $obj_removed = true; |
645 | 645 | $this->_model_relations[$relationName] = null; |
646 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
646 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
647 | 647 | $obj_removed = $this->_model_relations[$relationName]; |
648 | 648 | $this->_model_relations[$relationName] = null; |
649 | - }else{ |
|
650 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
649 | + } else { |
|
650 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
651 | 651 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
652 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
652 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
653 | 653 | $index_found_at = NULL; |
654 | 654 | //find this object in the array even though it has a different key |
655 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
656 | - if( |
|
655 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
656 | + if ( |
|
657 | 657 | $obj instanceof EE_Base_Class |
658 | 658 | && ( |
659 | 659 | $obj == $object_to_remove_or_index_into_array |
@@ -664,34 +664,34 @@ discard block |
||
664 | 664 | break; |
665 | 665 | } |
666 | 666 | } |
667 | - if($index_found_at){ |
|
667 | + if ($index_found_at) { |
|
668 | 668 | $index_in_cache = $index_found_at; |
669 | - }else{ |
|
669 | + } else { |
|
670 | 670 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
671 | 671 | //if it wasn't in it to begin with. So we're done |
672 | 672 | return $object_to_remove_or_index_into_array; |
673 | 673 | } |
674 | 674 | } |
675 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
675 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
676 | 676 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
677 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
678 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
677 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
678 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
679 | 679 | $index_in_cache = $index; |
680 | 680 | } |
681 | 681 | } |
682 | - }else{ |
|
682 | + } else { |
|
683 | 683 | $index_in_cache = $object_to_remove_or_index_into_array; |
684 | 684 | } |
685 | 685 | //supposedly we've found it. But it could just be that the client code |
686 | 686 | //provided a bad index/object |
687 | 687 | if ( |
688 | 688 | isset( |
689 | - $this->_model_relations[ $relationName ], |
|
690 | - $this->_model_relations[ $relationName ][ $index_in_cache ] |
|
689 | + $this->_model_relations[$relationName], |
|
690 | + $this->_model_relations[$relationName][$index_in_cache] |
|
691 | 691 | ) |
692 | 692 | ) { |
693 | - $obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ]; |
|
694 | - unset( $this->_model_relations[ $relationName ][ $index_in_cache ] ); |
|
693 | + $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
|
694 | + unset($this->_model_relations[$relationName][$index_in_cache]); |
|
695 | 695 | } else { |
696 | 696 | //that thing was never cached anyways. |
697 | 697 | $obj_removed = null; |
@@ -712,24 +712,24 @@ discard block |
||
712 | 712 | * @return boolean TRUE on success, FALSE on fail |
713 | 713 | * @throws \EE_Error |
714 | 714 | */ |
715 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
715 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
716 | 716 | // verify that incoming object is of the correct type |
717 | - $obj_class = 'EE_' . $relationName; |
|
718 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
717 | + $obj_class = 'EE_'.$relationName; |
|
718 | + if ($newly_saved_object instanceof $obj_class) { |
|
719 | 719 | /* @type EE_Base_Class $newly_saved_object*/ |
720 | 720 | // now get the type of relation |
721 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
721 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
722 | 722 | // if this is a 1:1 relationship |
723 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
723 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
724 | 724 | // then just replace the cached object with the newly saved object |
725 | 725 | $this->_model_relations[$relationName] = $newly_saved_object; |
726 | 726 | return TRUE; |
727 | 727 | // or if it's some kind of sordid feral polyamorous relationship... |
728 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
728 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
729 | 729 | // then remove the current cached item |
730 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
730 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
731 | 731 | // and cache the newly saved object using it's new ID |
732 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
732 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
733 | 733 | return TRUE; |
734 | 734 | } |
735 | 735 | } |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | * @param string $relationName |
746 | 746 | * @return EE_Base_Class |
747 | 747 | */ |
748 | - public function get_one_from_cache($relationName){ |
|
749 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
750 | - if(is_array($cached_array_or_object)){ |
|
748 | + public function get_one_from_cache($relationName) { |
|
749 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
750 | + if (is_array($cached_array_or_object)) { |
|
751 | 751 | return array_shift($cached_array_or_object); |
752 | - }else{ |
|
752 | + } else { |
|
753 | 753 | return $cached_array_or_object; |
754 | 754 | } |
755 | 755 | } |
@@ -764,23 +764,23 @@ discard block |
||
764 | 764 | * @throws \EE_Error |
765 | 765 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
766 | 766 | */ |
767 | - public function get_all_from_cache($relationName){ |
|
768 | - $objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
767 | + public function get_all_from_cache($relationName) { |
|
768 | + $objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
769 | 769 | // if the result is not an array, but exists, make it an array |
770 | - $objects = is_array( $objects ) ? $objects : array( $objects ); |
|
770 | + $objects = is_array($objects) ? $objects : array($objects); |
|
771 | 771 | //bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143 |
772 | 772 | //basically, if this model object was stored in the session, and these cached model objects |
773 | 773 | //already have IDs, let's make sure they're in their model's entity mapper |
774 | 774 | //otherwise we will have duplicates next time we call |
775 | 775 | // EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
776 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
777 | - foreach( $objects as $model_object ){ |
|
778 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
776 | + $model = EE_Registry::instance()->load_model($relationName); |
|
777 | + foreach ($objects as $model_object) { |
|
778 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
779 | 779 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
780 | - if( $model_object->ID() ){ |
|
781 | - $model->add_to_entity_map( $model_object ); |
|
780 | + if ($model_object->ID()) { |
|
781 | + $model->add_to_entity_map($model_object); |
|
782 | 782 | } |
783 | - }else{ |
|
783 | + } else { |
|
784 | 784 | throw new EE_Error( |
785 | 785 | sprintf( |
786 | 786 | __( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | 'event_espresso' |
789 | 789 | ), |
790 | 790 | $relationName, |
791 | - gettype( $model_object ) |
|
791 | + gettype($model_object) |
|
792 | 792 | ) |
793 | 793 | ); |
794 | 794 | } |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * @return array|EE_Base_Class[] |
811 | 811 | * @throws \EE_Error |
812 | 812 | */ |
813 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
814 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
813 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
814 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
815 | 815 | ? $this->get_model()->get_primary_key_field()->get_name() |
816 | 816 | : $field_to_order_by; |
817 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
818 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
817 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
818 | + if (empty($field) || empty($current_value)) { |
|
819 | 819 | return array(); |
820 | 820 | } |
821 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
821 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | |
@@ -835,15 +835,15 @@ discard block |
||
835 | 835 | * @return array|EE_Base_Class[] |
836 | 836 | * @throws \EE_Error |
837 | 837 | */ |
838 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
839 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
838 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
839 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
840 | 840 | ? $this->get_model()->get_primary_key_field()->get_name() |
841 | 841 | : $field_to_order_by; |
842 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
843 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
842 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
843 | + if (empty($field) || empty($current_value)) { |
|
844 | 844 | return array(); |
845 | 845 | } |
846 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
846 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | |
@@ -859,15 +859,15 @@ discard block |
||
859 | 859 | * @return array|EE_Base_Class |
860 | 860 | * @throws \EE_Error |
861 | 861 | */ |
862 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
863 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
862 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
863 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
864 | 864 | ? $this->get_model()->get_primary_key_field()->get_name() |
865 | 865 | : $field_to_order_by; |
866 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
867 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
866 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
867 | + if (empty($field) || empty($current_value)) { |
|
868 | 868 | return array(); |
869 | 869 | } |
870 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
870 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | * @return array|EE_Base_Class |
884 | 884 | * @throws \EE_Error |
885 | 885 | */ |
886 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
887 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
886 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
887 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
888 | 888 | ? $this->get_model()->get_primary_key_field()->get_name() |
889 | 889 | : $field_to_order_by; |
890 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
891 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
890 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
891 | + if (empty($field) || empty($current_value)) { |
|
892 | 892 | return array(); |
893 | 893 | } |
894 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
894 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | |
@@ -904,25 +904,25 @@ discard block |
||
904 | 904 | * @param mixed $field_value_from_db |
905 | 905 | * @throws \EE_Error |
906 | 906 | */ |
907 | - public function set_from_db($field_name,$field_value_from_db){ |
|
907 | + public function set_from_db($field_name, $field_value_from_db) { |
|
908 | 908 | $field_obj = $this->get_model()->field_settings_for($field_name); |
909 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
909 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
910 | 910 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
911 | 911 | //eg, a CPT model object could have an entry in the posts table, but no |
912 | 912 | //entry in the meta table. Meaning that all its columns in the meta table |
913 | 913 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
914 | - if($field_value_from_db === NULL ){ |
|
915 | - if( $field_obj->is_nullable()){ |
|
914 | + if ($field_value_from_db === NULL) { |
|
915 | + if ($field_obj->is_nullable()) { |
|
916 | 916 | //if the field allows nulls, then let it be null |
917 | 917 | $field_value = NULL; |
918 | - }else{ |
|
918 | + } else { |
|
919 | 919 | $field_value = $field_obj->get_default_value(); |
920 | 920 | } |
921 | - }else{ |
|
922 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
921 | + } else { |
|
922 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
923 | 923 | } |
924 | 924 | $this->_fields[$field_name] = $field_value; |
925 | - $this->_clear_cached_property( $field_name ); |
|
925 | + $this->_clear_cached_property($field_name); |
|
926 | 926 | } |
927 | 927 | } |
928 | 928 | |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | * @return mixed |
939 | 939 | * @throws \EE_Error |
940 | 940 | */ |
941 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
942 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
941 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
942 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | |
@@ -972,10 +972,10 @@ discard block |
||
972 | 972 | * just null is returned (because that indicates that likely |
973 | 973 | * this field is nullable). |
974 | 974 | */ |
975 | - public function get_DateTime_object( $field_name ) { |
|
976 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
975 | + public function get_DateTime_object($field_name) { |
|
976 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
977 | 977 | |
978 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
978 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
979 | 979 | EE_Error::add_error( |
980 | 980 | sprintf( |
981 | 981 | __( |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | * @return void |
1008 | 1008 | * @throws \EE_Error |
1009 | 1009 | */ |
1010 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
1010 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
1011 | 1011 | echo $this->get_pretty($field_name, $extra_cache_ref); |
1012 | 1012 | } |
1013 | 1013 | |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | * @return void |
1022 | 1022 | * @throws \EE_Error |
1023 | 1023 | */ |
1024 | - public function f($field_name){ |
|
1025 | - $this->e($field_name,'form_input'); |
|
1024 | + public function f($field_name) { |
|
1025 | + $this->e($field_name, 'form_input'); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
@@ -1035,8 +1035,8 @@ discard block |
||
1035 | 1035 | * @return mixed |
1036 | 1036 | * @throws \EE_Error |
1037 | 1037 | */ |
1038 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
1039 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
1038 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
1039 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | |
@@ -1058,36 +1058,36 @@ discard block |
||
1058 | 1058 | * if field is not a valid dtt field, or void if echoing |
1059 | 1059 | * @throws \EE_Error |
1060 | 1060 | */ |
1061 | - protected function _get_datetime( $field_name, $dt_frmt = '', $tm_frmt = '', $date_or_time = '', $echo = false ) { |
|
1061 | + protected function _get_datetime($field_name, $dt_frmt = '', $tm_frmt = '', $date_or_time = '', $echo = false) { |
|
1062 | 1062 | |
1063 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1063 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1064 | 1064 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1065 | 1065 | |
1066 | 1066 | //validate field for datetime and returns field settings if valid. |
1067 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1067 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1068 | 1068 | |
1069 | 1069 | //clear cached property if either formats are not null. |
1070 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1071 | - $this->_clear_cached_property( $field_name ); |
|
1070 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1071 | + $this->_clear_cached_property($field_name); |
|
1072 | 1072 | //reset format properties because they are used in get() |
1073 | 1073 | $this->_dt_frmt = $in_dt_frmt; |
1074 | 1074 | $this->_tm_frmt = $in_tm_frmt; |
1075 | 1075 | } |
1076 | - if ( $echo ) { |
|
1077 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1076 | + if ($echo) { |
|
1077 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1078 | 1078 | } else { |
1079 | - $field->set_date_format( $in_dt_frmt ); |
|
1079 | + $field->set_date_format($in_dt_frmt); |
|
1080 | 1080 | } |
1081 | - if ( $echo ) { |
|
1082 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1081 | + if ($echo) { |
|
1082 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1083 | 1083 | } else { |
1084 | - $field->set_time_format( $in_tm_frmt ); |
|
1084 | + $field->set_time_format($in_tm_frmt); |
|
1085 | 1085 | } |
1086 | 1086 | //set timezone in field object |
1087 | - $field->set_timezone( $this->_timezone ); |
|
1087 | + $field->set_timezone($this->_timezone); |
|
1088 | 1088 | |
1089 | 1089 | //set the output returned |
1090 | - switch ( $date_or_time ) { |
|
1090 | + switch ($date_or_time) { |
|
1091 | 1091 | |
1092 | 1092 | case 'D' : |
1093 | 1093 | $field->set_date_time_output('date'); |
@@ -1102,11 +1102,11 @@ discard block |
||
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
1105 | - if ( $echo ) { |
|
1106 | - $this->e( $field_name, $date_or_time ); |
|
1105 | + if ($echo) { |
|
1106 | + $this->e($field_name, $date_or_time); |
|
1107 | 1107 | return ''; |
1108 | 1108 | } |
1109 | - return $this->get( $field_name, $date_or_time ); |
|
1109 | + return $this->get($field_name, $date_or_time); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | * @return string datetime value formatted |
1120 | 1120 | * @throws \EE_Error |
1121 | 1121 | */ |
1122 | - public function get_date( $field_name, $format = NULL ) { |
|
1123 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1122 | + public function get_date($field_name, $format = NULL) { |
|
1123 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | |
@@ -1130,8 +1130,8 @@ discard block |
||
1130 | 1130 | * @param null $format |
1131 | 1131 | * @throws \EE_Error |
1132 | 1132 | */ |
1133 | - public function e_date( $field_name, $format = NULL ) { |
|
1134 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1133 | + public function e_date($field_name, $format = NULL) { |
|
1134 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | |
@@ -1144,8 +1144,8 @@ discard block |
||
1144 | 1144 | * @return string datetime value formatted |
1145 | 1145 | * @throws \EE_Error |
1146 | 1146 | */ |
1147 | - public function get_time( $field_name, $format = NULL ) { |
|
1148 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1147 | + public function get_time($field_name, $format = NULL) { |
|
1148 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1155,8 +1155,8 @@ discard block |
||
1155 | 1155 | * @param null $format |
1156 | 1156 | * @throws \EE_Error |
1157 | 1157 | */ |
1158 | - public function e_time( $field_name, $format = NULL ) { |
|
1159 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1158 | + public function e_time($field_name, $format = NULL) { |
|
1159 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | |
@@ -1170,8 +1170,8 @@ discard block |
||
1170 | 1170 | * @return string datetime value formatted |
1171 | 1171 | * @throws \EE_Error |
1172 | 1172 | */ |
1173 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1174 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1173 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1174 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | |
@@ -1182,8 +1182,8 @@ discard block |
||
1182 | 1182 | * @param null $tm_frmt |
1183 | 1183 | * @throws \EE_Error |
1184 | 1184 | */ |
1185 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1186 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1185 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1186 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | * @throws \EE_Error |
1198 | 1198 | * field name. |
1199 | 1199 | */ |
1200 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1201 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1200 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1201 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1202 | 1202 | return date_i18n( |
1203 | 1203 | $format, |
1204 | - EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) |
|
1204 | + EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone) |
|
1205 | 1205 | ); |
1206 | 1206 | } |
1207 | 1207 | |
@@ -1214,14 +1214,14 @@ discard block |
||
1214 | 1214 | * @throws EE_Error |
1215 | 1215 | * @return EE_Datetime_Field |
1216 | 1216 | */ |
1217 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1217 | + protected function _get_dtt_field_settings($field_name) { |
|
1218 | 1218 | $field = $this->get_model()->field_settings_for($field_name); |
1219 | 1219 | |
1220 | 1220 | //check if field is dtt |
1221 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1221 | + if ($field instanceof EE_Datetime_Field) { |
|
1222 | 1222 | return $field; |
1223 | 1223 | } else { |
1224 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1224 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1225 | 1225 | } |
1226 | 1226 | } |
1227 | 1227 | |
@@ -1242,8 +1242,8 @@ discard block |
||
1242 | 1242 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1243 | 1243 | * @throws \EE_Error |
1244 | 1244 | */ |
1245 | - protected function _set_time_for( $time, $fieldname ) { |
|
1246 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1245 | + protected function _set_time_for($time, $fieldname) { |
|
1246 | + $this->_set_date_time('T', $time, $fieldname); |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | |
@@ -1256,8 +1256,8 @@ discard block |
||
1256 | 1256 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1257 | 1257 | * @throws \EE_Error |
1258 | 1258 | */ |
1259 | - protected function _set_date_for( $date, $fieldname ) { |
|
1260 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1259 | + protected function _set_date_for($date, $fieldname) { |
|
1260 | + $this->_set_date_time('D', $date, $fieldname); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | |
@@ -1271,26 +1271,26 @@ discard block |
||
1271 | 1271 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1272 | 1272 | * @throws \EE_Error |
1273 | 1273 | */ |
1274 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1275 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1276 | - $field->set_timezone( $this->_timezone ); |
|
1277 | - $field->set_date_format( $this->_dt_frmt ); |
|
1278 | - $field->set_time_format( $this->_tm_frmt ); |
|
1279 | - switch ( $what ) { |
|
1274 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1275 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1276 | + $field->set_timezone($this->_timezone); |
|
1277 | + $field->set_date_format($this->_dt_frmt); |
|
1278 | + $field->set_time_format($this->_tm_frmt); |
|
1279 | + switch ($what) { |
|
1280 | 1280 | case 'T' : |
1281 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time( |
|
1281 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( |
|
1282 | 1282 | $datetime_value, |
1283 | - $this->_fields[ $fieldname ] |
|
1283 | + $this->_fields[$fieldname] |
|
1284 | 1284 | ); |
1285 | 1285 | break; |
1286 | 1286 | case 'D' : |
1287 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date( |
|
1287 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( |
|
1288 | 1288 | $datetime_value, |
1289 | - $this->_fields[ $fieldname ] |
|
1289 | + $this->_fields[$fieldname] |
|
1290 | 1290 | ); |
1291 | 1291 | break; |
1292 | 1292 | case 'B' : |
1293 | - $this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value ); |
|
1293 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1294 | 1294 | break; |
1295 | 1295 | } |
1296 | 1296 | $this->_clear_cached_property($fieldname); |
@@ -1312,17 +1312,17 @@ discard block |
||
1312 | 1312 | * @throws EE_Error |
1313 | 1313 | * @return string timestamp |
1314 | 1314 | */ |
1315 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1315 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1316 | 1316 | $timezone = EEH_DTT_Helper::get_timezone(); |
1317 | - if ( $timezone === $this->_timezone ) { |
|
1317 | + if ($timezone === $this->_timezone) { |
|
1318 | 1318 | return ''; |
1319 | 1319 | } |
1320 | 1320 | $original_timezone = $this->_timezone; |
1321 | - $this->set_timezone( $timezone ); |
|
1321 | + $this->set_timezone($timezone); |
|
1322 | 1322 | |
1323 | 1323 | $fn = (array) $field_name; |
1324 | - $args = array_merge( $fn, (array) $args ); |
|
1325 | - if ( ! method_exists( $this, $callback ) ) { |
|
1324 | + $args = array_merge($fn, (array) $args); |
|
1325 | + if ( ! method_exists($this, $callback)) { |
|
1326 | 1326 | throw new EE_Error( |
1327 | 1327 | sprintf( |
1328 | 1328 | __( |
@@ -1334,9 +1334,9 @@ discard block |
||
1334 | 1334 | ); |
1335 | 1335 | } |
1336 | 1336 | $args = (array) $args; |
1337 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1337 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1338 | 1338 | |
1339 | - $this->set_timezone( $original_timezone ); |
|
1339 | + $this->set_timezone($original_timezone); |
|
1340 | 1340 | return $return; |
1341 | 1341 | } |
1342 | 1342 | |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | * @return boolean | int |
1351 | 1351 | * @throws \EE_Error |
1352 | 1352 | */ |
1353 | - public function delete(){ |
|
1353 | + public function delete() { |
|
1354 | 1354 | /** |
1355 | 1355 | * Called just before the `EE_Base_Class::_delete` method call. |
1356 | 1356 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | * |
1360 | 1360 | * @param EE_Base_Class $model_object about to be 'deleted' |
1361 | 1361 | */ |
1362 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1362 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1363 | 1363 | $result = $this->_delete(); |
1364 | 1364 | /** |
1365 | 1365 | * Called just after the `EE_Base_Class::_delete` method call. |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | * @param EE_Base_Class $model_object that was just 'deleted' |
1370 | 1370 | * @param boolean $result |
1371 | 1371 | */ |
1372 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1372 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1373 | 1373 | return $result; |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1395,22 +1395,22 @@ discard block |
||
1395 | 1395 | * @return bool | int |
1396 | 1396 | * @throws \EE_Error |
1397 | 1397 | */ |
1398 | - public function delete_permanently(){ |
|
1398 | + public function delete_permanently() { |
|
1399 | 1399 | /** |
1400 | 1400 | * Called just before HARD deleting a model object |
1401 | 1401 | * |
1402 | 1402 | * @param EE_Base_Class $model_object about to be 'deleted' |
1403 | 1403 | */ |
1404 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1405 | - $model=$this->get_model(); |
|
1406 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
1404 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1405 | + $model = $this->get_model(); |
|
1406 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
1407 | 1407 | $this->refresh_cache_of_related_objects(); |
1408 | 1408 | /** |
1409 | 1409 | * Called just after HARD deleting a model object |
1410 | 1410 | * @param EE_Base_Class $model_object that was just 'deleted' |
1411 | 1411 | * @param boolean $result |
1412 | 1412 | */ |
1413 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1413 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1414 | 1414 | return $result; |
1415 | 1415 | } |
1416 | 1416 | |
@@ -1423,18 +1423,18 @@ discard block |
||
1423 | 1423 | * @throws \EE_Error |
1424 | 1424 | */ |
1425 | 1425 | public function refresh_cache_of_related_objects() { |
1426 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1427 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1428 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1429 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1426 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1427 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1428 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1429 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1430 | 1430 | //this relation only stores a single model object, not an array |
1431 | 1431 | //but let's make it consistent |
1432 | - $related_objects = array( $related_objects ); |
|
1432 | + $related_objects = array($related_objects); |
|
1433 | 1433 | } |
1434 | - foreach( $related_objects as $related_object ) { |
|
1434 | + foreach ($related_objects as $related_object) { |
|
1435 | 1435 | //only refresh their cache if they're in memory |
1436 | - if( $related_object instanceof EE_Base_Class ) { |
|
1437 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1436 | + if ($related_object instanceof EE_Base_Class) { |
|
1437 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1438 | 1438 | } |
1439 | 1439 | } |
1440 | 1440 | } |
@@ -1454,17 +1454,17 @@ discard block |
||
1454 | 1454 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1455 | 1455 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1456 | 1456 | */ |
1457 | - public function save($set_cols_n_values=array()) { |
|
1457 | + public function save($set_cols_n_values = array()) { |
|
1458 | 1458 | /** |
1459 | 1459 | * Filters the fields we're about to save on the model object |
1460 | 1460 | * |
1461 | 1461 | * @param array $set_cols_n_values |
1462 | 1462 | * @param EE_Base_Class $model_object |
1463 | 1463 | */ |
1464 | - $set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1464 | + $set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1465 | 1465 | //set attributes as provided in $set_cols_n_values |
1466 | - foreach($set_cols_n_values as $column=>$value){ |
|
1467 | - $this->set($column,$value); |
|
1466 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1467 | + $this->set($column, $value); |
|
1468 | 1468 | } |
1469 | 1469 | /** |
1470 | 1470 | * Saving a model object. |
@@ -1472,8 +1472,8 @@ discard block |
||
1472 | 1472 | * Before we perform a save, this action is fired. |
1473 | 1473 | * @param EE_Base_Class $model_object the model object about to be saved. |
1474 | 1474 | */ |
1475 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1476 | - if( ! $this->allow_persist() ) { |
|
1475 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1476 | + if ( ! $this->allow_persist()) { |
|
1477 | 1477 | return 0; |
1478 | 1478 | } |
1479 | 1479 | //now get current attribute values |
@@ -1483,61 +1483,61 @@ discard block |
||
1483 | 1483 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1484 | 1484 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1485 | 1485 | //does this model have an autoincrement PK? |
1486 | - if($this->get_model()->has_primary_key_field()){ |
|
1487 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1486 | + if ($this->get_model()->has_primary_key_field()) { |
|
1487 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1488 | 1488 | //ok check if it's set, if so: update; if not, insert |
1489 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1490 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1489 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1490 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1491 | 1491 | } else { |
1492 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1493 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1494 | - if($results){ |
|
1492 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1493 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1494 | + if ($results) { |
|
1495 | 1495 | //if successful, set the primary key |
1496 | 1496 | //but don't use the normal SET method, because it will check if |
1497 | 1497 | //an item with the same ID exists in the mapper & db, then |
1498 | 1498 | //will find it in the db (because we just added it) and THAT object |
1499 | 1499 | //will get added to the mapper before we can add this one! |
1500 | 1500 | //but if we just avoid using the SET method, all that headache can be avoided |
1501 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1501 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1502 | 1502 | $this->_fields[$pk_field_name] = $results; |
1503 | 1503 | $this->_clear_cached_property($pk_field_name); |
1504 | - $this->get_model()->add_to_entity_map( $this ); |
|
1504 | + $this->get_model()->add_to_entity_map($this); |
|
1505 | 1505 | $this->_update_cached_related_model_objs_fks(); |
1506 | 1506 | } |
1507 | 1507 | } |
1508 | - }else{//PK is NOT auto-increment |
|
1508 | + } else {//PK is NOT auto-increment |
|
1509 | 1509 | //so check if one like it already exists in the db |
1510 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1511 | - if( WP_DEBUG && ! $this->in_entity_map() ){ |
|
1510 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1511 | + if (WP_DEBUG && ! $this->in_entity_map()) { |
|
1512 | 1512 | throw new EE_Error( |
1513 | 1513 | sprintf( |
1514 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1514 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1515 | 1515 | get_class($this), |
1516 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1517 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1516 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1517 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1518 | 1518 | '<br />' |
1519 | 1519 | ) |
1520 | 1520 | ); |
1521 | 1521 | } |
1522 | 1522 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1523 | - }else{ |
|
1523 | + } else { |
|
1524 | 1524 | $results = $this->get_model()->insert($save_cols_n_values); |
1525 | 1525 | $this->_update_cached_related_model_objs_fks(); |
1526 | 1526 | } |
1527 | 1527 | } |
1528 | - }else{//there is NO primary key |
|
1528 | + } else {//there is NO primary key |
|
1529 | 1529 | $already_in_db = false; |
1530 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1530 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1531 | 1531 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1532 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1532 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1533 | 1533 | $already_in_db = true; |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | - if( $already_in_db ){ |
|
1537 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1538 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
1539 | - }else{ |
|
1540 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1536 | + if ($already_in_db) { |
|
1537 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1538 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
1539 | + } else { |
|
1540 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1541 | 1541 | } |
1542 | 1542 | } |
1543 | 1543 | //restore the old assumption about values being prepared by the model object |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1551 | 1551 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1552 | 1552 | */ |
1553 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1553 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1554 | 1554 | return $results; |
1555 | 1555 | } |
1556 | 1556 | |
@@ -1565,15 +1565,15 @@ discard block |
||
1565 | 1565 | * @return void |
1566 | 1566 | * @throws \EE_Error |
1567 | 1567 | */ |
1568 | - protected function _update_cached_related_model_objs_fks(){ |
|
1569 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1570 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1571 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1568 | + protected function _update_cached_related_model_objs_fks() { |
|
1569 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1570 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1571 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1572 | 1572 | $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( |
1573 | 1573 | $this->get_model()->get_this_model_name() |
1574 | 1574 | ); |
1575 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1576 | - if( $related_model_obj_in_cache->ID() ){ |
|
1575 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1576 | + if ($related_model_obj_in_cache->ID()) { |
|
1577 | 1577 | $related_model_obj_in_cache->save(); |
1578 | 1578 | } |
1579 | 1579 | } |
@@ -1594,21 +1594,21 @@ discard block |
||
1594 | 1594 | * @return int ID of new model object on save; 0 on failure+ |
1595 | 1595 | * @throws \EE_Error |
1596 | 1596 | */ |
1597 | - public function save_new_cached_related_model_objs(){ |
|
1597 | + public function save_new_cached_related_model_objs() { |
|
1598 | 1598 | //make sure this has been saved |
1599 | - if( ! $this->ID()){ |
|
1599 | + if ( ! $this->ID()) { |
|
1600 | 1600 | $id = $this->save(); |
1601 | - }else{ |
|
1601 | + } else { |
|
1602 | 1602 | $id = $this->ID(); |
1603 | 1603 | } |
1604 | 1604 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1605 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1605 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1606 | 1606 | |
1607 | 1607 | |
1608 | - if($this->_model_relations[$relationName]){ |
|
1608 | + if ($this->_model_relations[$relationName]) { |
|
1609 | 1609 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1610 | 1610 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1611 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1611 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1612 | 1612 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1613 | 1613 | //but ONLY if it DOES NOT exist in the DB |
1614 | 1614 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1617,8 +1617,8 @@ discard block |
||
1617 | 1617 | $this->_add_relation_to($related_model_obj, $relationName); |
1618 | 1618 | $related_model_obj->save_new_cached_related_model_objs(); |
1619 | 1619 | // } |
1620 | - }else{ |
|
1621 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1620 | + } else { |
|
1621 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1622 | 1622 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1623 | 1623 | //but ONLY if it DOES NOT exist in the DB |
1624 | 1624 | // if( ! $related_model_obj->ID()){ |
@@ -1639,8 +1639,8 @@ discard block |
||
1639 | 1639 | * @return \EEM_Base | \EEM_CPT_Base |
1640 | 1640 | */ |
1641 | 1641 | public function get_model() { |
1642 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1643 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1642 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1643 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | |
@@ -1651,10 +1651,10 @@ discard block |
||
1651 | 1651 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1652 | 1652 | * @throws \EE_Error |
1653 | 1653 | */ |
1654 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1654 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1655 | 1655 | //TODO: will not work for Term_Relationships because they have no PK! |
1656 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1657 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1656 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1657 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1658 | 1658 | $id = $props_n_values[$primary_id_ref]; |
1659 | 1659 | return self::_get_model($classname)->get_from_entity_map($id); |
1660 | 1660 | } |
@@ -1675,37 +1675,37 @@ discard block |
||
1675 | 1675 | * @return mixed (EE_Base_Class|bool) |
1676 | 1676 | * @throws \EE_Error |
1677 | 1677 | */ |
1678 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1678 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1679 | 1679 | $existing = null; |
1680 | - if ( self::_get_model( $classname )->has_primary_key_field() ) { |
|
1681 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1682 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) |
|
1683 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1680 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1681 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1682 | + if (array_key_exists($primary_id_ref, $props_n_values) |
|
1683 | + && ! empty($props_n_values[$primary_id_ref]) |
|
1684 | 1684 | ) { |
1685 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1686 | - $props_n_values[ $primary_id_ref ] |
|
1685 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1686 | + $props_n_values[$primary_id_ref] |
|
1687 | 1687 | ); |
1688 | 1688 | } |
1689 | - } elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) { |
|
1689 | + } elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1690 | 1690 | //no primary key on this model, but there's still a matching item in the DB |
1691 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1692 | - self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values ) |
|
1691 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1692 | + self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values) |
|
1693 | 1693 | ); |
1694 | 1694 | } |
1695 | - if ( $existing ) { |
|
1695 | + if ($existing) { |
|
1696 | 1696 | |
1697 | 1697 | //set date formats if present before setting values |
1698 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1699 | - $existing->set_date_format( $date_formats[0] ); |
|
1700 | - $existing->set_time_format( $date_formats[1] ); |
|
1698 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1699 | + $existing->set_date_format($date_formats[0]); |
|
1700 | + $existing->set_time_format($date_formats[1]); |
|
1701 | 1701 | } else { |
1702 | 1702 | //set default formats for date and time |
1703 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1704 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1703 | + $existing->set_date_format(get_option('date_format')); |
|
1704 | + $existing->set_time_format(get_option('time_format')); |
|
1705 | 1705 | } |
1706 | 1706 | |
1707 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1708 | - $existing->set( $property, $field_value ); |
|
1707 | + foreach ($props_n_values as $property => $field_value) { |
|
1708 | + $existing->set($property, $field_value); |
|
1709 | 1709 | } |
1710 | 1710 | return $existing; |
1711 | 1711 | } else { |
@@ -1723,9 +1723,9 @@ discard block |
||
1723 | 1723 | * @throws EE_Error |
1724 | 1724 | * @return EEM_Base |
1725 | 1725 | */ |
1726 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1726 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1727 | 1727 | //find model for this class |
1728 | - if( ! $classname ){ |
|
1728 | + if ( ! $classname) { |
|
1729 | 1729 | throw new EE_Error( |
1730 | 1730 | sprintf( |
1731 | 1731 | __( |
@@ -1736,8 +1736,8 @@ discard block |
||
1736 | 1736 | ) |
1737 | 1737 | ); |
1738 | 1738 | } |
1739 | - $modelName=self::_get_model_classname($classname); |
|
1740 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1739 | + $modelName = self::_get_model_classname($classname); |
|
1740 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1741 | 1741 | } |
1742 | 1742 | |
1743 | 1743 | |
@@ -1748,10 +1748,10 @@ discard block |
||
1748 | 1748 | * @param null $timezone |
1749 | 1749 | * @return EEM_Base |
1750 | 1750 | */ |
1751 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1752 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1753 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1754 | - $model->set_timezone( $timezone ); |
|
1751 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1752 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1753 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1754 | + $model->set_timezone($timezone); |
|
1755 | 1755 | return $model; |
1756 | 1756 | } |
1757 | 1757 | |
@@ -1763,10 +1763,10 @@ discard block |
||
1763 | 1763 | * @param null $model_name |
1764 | 1764 | * @return string like EEM_Attendee |
1765 | 1765 | */ |
1766 | - private static function _get_model_classname( $model_name = null){ |
|
1767 | - if(strpos($model_name,"EE_")===0){ |
|
1768 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1769 | - }else{ |
|
1766 | + private static function _get_model_classname($model_name = null) { |
|
1767 | + if (strpos($model_name, "EE_") === 0) { |
|
1768 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1769 | + } else { |
|
1770 | 1770 | $model_classname = "EEM_".$model_name; |
1771 | 1771 | } |
1772 | 1772 | return $model_classname; |
@@ -1780,16 +1780,16 @@ discard block |
||
1780 | 1780 | * @throws EE_Error |
1781 | 1781 | * @return string |
1782 | 1782 | */ |
1783 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1784 | - if( ! $classname){ |
|
1783 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1784 | + if ( ! $classname) { |
|
1785 | 1785 | throw new EE_Error( |
1786 | 1786 | sprintf( |
1787 | - __( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ), |
|
1787 | + __("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), |
|
1788 | 1788 | $classname |
1789 | 1789 | ) |
1790 | 1790 | ); |
1791 | 1791 | } |
1792 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1792 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | |
@@ -1803,12 +1803,12 @@ discard block |
||
1803 | 1803 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1804 | 1804 | * @throws \EE_Error |
1805 | 1805 | */ |
1806 | - public function ID(){ |
|
1806 | + public function ID() { |
|
1807 | 1807 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1808 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1809 | - return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
|
1810 | - }else{ |
|
1811 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1808 | + if ($this->get_model()->has_primary_key_field()) { |
|
1809 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1810 | + } else { |
|
1811 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1812 | 1812 | } |
1813 | 1813 | } |
1814 | 1814 | |
@@ -1826,38 +1826,38 @@ discard block |
||
1826 | 1826 | * @throws EE_Error |
1827 | 1827 | * @return EE_Base_Class the object the relation was added to |
1828 | 1828 | */ |
1829 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1829 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1830 | 1830 | //if this thing exists in the DB, save the relation to the DB |
1831 | - if( $this->ID() ){ |
|
1832 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1831 | + if ($this->ID()) { |
|
1832 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1833 | 1833 | //clear cache so future get_many_related and get_first_related() return new results. |
1834 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1835 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1836 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1834 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1835 | + if ($otherObject instanceof EE_Base_Class) { |
|
1836 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1837 | 1837 | } |
1838 | 1838 | } else { |
1839 | 1839 | //this thing doesn't exist in the DB, so just cache it |
1840 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1841 | - throw new EE_Error( sprintf( |
|
1842 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1840 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1841 | + throw new EE_Error(sprintf( |
|
1842 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1843 | 1843 | $otherObjectModelObjectOrID, |
1844 | - get_class( $this ) |
|
1844 | + get_class($this) |
|
1845 | 1845 | )); |
1846 | 1846 | } else { |
1847 | 1847 | $otherObject = $otherObjectModelObjectOrID; |
1848 | 1848 | } |
1849 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1849 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1850 | 1850 | } |
1851 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1851 | + if ($otherObject instanceof EE_Base_Class) { |
|
1852 | 1852 | //fix the reciprocal relation too |
1853 | - if( $otherObject->ID() ) { |
|
1853 | + if ($otherObject->ID()) { |
|
1854 | 1854 | //its saved so assumed relations exist in the DB, so we can just |
1855 | 1855 | //clear the cache so future queries use the updated info in the DB |
1856 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1856 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1857 | 1857 | } else { |
1858 | 1858 | |
1859 | 1859 | //it's not saved, so it caches relations like this |
1860 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1860 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1861 | 1861 | } |
1862 | 1862 | } |
1863 | 1863 | return $otherObject; |
@@ -1881,17 +1881,17 @@ discard block |
||
1881 | 1881 | * @return EE_Base_Class the relation was removed from |
1882 | 1882 | * @throws \EE_Error |
1883 | 1883 | */ |
1884 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1885 | - if ( $this->ID() ) { |
|
1884 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1885 | + if ($this->ID()) { |
|
1886 | 1886 | //if this exists in the DB, save the relation change to the DB too |
1887 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1888 | - $this->clear_cache( $relationName, $otherObject ); |
|
1887 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1888 | + $this->clear_cache($relationName, $otherObject); |
|
1889 | 1889 | } else { |
1890 | 1890 | //this doesn't exist in the DB, just remove it from the cache |
1891 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1891 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1892 | 1892 | } |
1893 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1894 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | + if ($otherObject instanceof EE_Base_Class) { |
|
1894 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1895 | 1895 | } |
1896 | 1896 | return $otherObject; |
1897 | 1897 | } |
@@ -1906,18 +1906,18 @@ discard block |
||
1906 | 1906 | * @return EE_Base_Class |
1907 | 1907 | * @throws \EE_Error |
1908 | 1908 | */ |
1909 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1910 | - if ( $this->ID() ) { |
|
1909 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1910 | + if ($this->ID()) { |
|
1911 | 1911 | //if this exists in the DB, save the relation change to the DB too |
1912 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1913 | - $this->clear_cache( $relationName, null, true ); |
|
1912 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1913 | + $this->clear_cache($relationName, null, true); |
|
1914 | 1914 | } else { |
1915 | 1915 | //this doesn't exist in the DB, just remove it from the cache |
1916 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1916 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1917 | 1917 | } |
1918 | - if( is_array( $otherObjects ) ) { |
|
1919 | - foreach ( $otherObjects as $otherObject ) { |
|
1920 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1918 | + if (is_array($otherObjects)) { |
|
1919 | + foreach ($otherObjects as $otherObject) { |
|
1920 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1921 | 1921 | } |
1922 | 1922 | } |
1923 | 1923 | return $otherObjects; |
@@ -1937,27 +1937,27 @@ discard block |
||
1937 | 1937 | * @throws \EE_Error |
1938 | 1938 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1939 | 1939 | */ |
1940 | - public function get_many_related($relationName,$query_params = array()){ |
|
1941 | - if($this->ID()){ |
|
1940 | + public function get_many_related($relationName, $query_params = array()) { |
|
1941 | + if ($this->ID()) { |
|
1942 | 1942 | //this exists in the DB, so get the related things from either the cache or the DB |
1943 | 1943 | //if there are query parameters, forget about caching the related model objects. |
1944 | - if( $query_params ){ |
|
1944 | + if ($query_params) { |
|
1945 | 1945 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1946 | - }else{ |
|
1946 | + } else { |
|
1947 | 1947 | //did we already cache the result of this query? |
1948 | 1948 | $cached_results = $this->get_all_from_cache($relationName); |
1949 | - if ( ! $cached_results ){ |
|
1949 | + if ( ! $cached_results) { |
|
1950 | 1950 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1951 | 1951 | //if no query parameters were passed, then we got all the related model objects |
1952 | 1952 | //for that relation. We can cache them then. |
1953 | - foreach($related_model_objects as $related_model_object){ |
|
1953 | + foreach ($related_model_objects as $related_model_object) { |
|
1954 | 1954 | $this->cache($relationName, $related_model_object); |
1955 | 1955 | } |
1956 | - }else{ |
|
1956 | + } else { |
|
1957 | 1957 | $related_model_objects = $cached_results; |
1958 | 1958 | } |
1959 | 1959 | } |
1960 | - }else{ |
|
1960 | + } else { |
|
1961 | 1961 | //this doesn't exist in the DB, so just get the related things from the cache |
1962 | 1962 | $related_model_objects = $this->get_all_from_cache($relationName); |
1963 | 1963 | } |
@@ -1975,8 +1975,8 @@ discard block |
||
1975 | 1975 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
1976 | 1976 | * @return int |
1977 | 1977 | */ |
1978 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1979 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
1978 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1979 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
1980 | 1980 | } |
1981 | 1981 | |
1982 | 1982 | |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
1991 | 1991 | * @return int |
1992 | 1992 | */ |
1993 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
1993 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
1994 | 1994 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
1995 | 1995 | } |
1996 | 1996 | |
@@ -2004,33 +2004,33 @@ discard block |
||
2004 | 2004 | * @return EE_Base_Class (not an array, a single object) |
2005 | 2005 | * @throws \EE_Error |
2006 | 2006 | */ |
2007 | - public function get_first_related($relationName,$query_params = array()){ |
|
2008 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
2007 | + public function get_first_related($relationName, $query_params = array()) { |
|
2008 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
2009 | 2009 | |
2010 | 2010 | //if they've provided some query parameters, don't bother trying to cache the result |
2011 | 2011 | //also make sure we're not caching the result of get_first_related |
2012 | 2012 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2013 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2014 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2015 | - }else{ |
|
2013 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2014 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2015 | + } else { |
|
2016 | 2016 | //first, check if we've already cached the result of this query |
2017 | 2017 | $cached_result = $this->get_one_from_cache($relationName); |
2018 | - if ( ! $cached_result ){ |
|
2018 | + if ( ! $cached_result) { |
|
2019 | 2019 | |
2020 | 2020 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2021 | - $this->cache($relationName,$related_model_object); |
|
2022 | - }else{ |
|
2021 | + $this->cache($relationName, $related_model_object); |
|
2022 | + } else { |
|
2023 | 2023 | $related_model_object = $cached_result; |
2024 | 2024 | } |
2025 | 2025 | } |
2026 | - }else{ |
|
2026 | + } else { |
|
2027 | 2027 | $related_model_object = null; |
2028 | 2028 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2029 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2030 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2029 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2030 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2031 | 2031 | } |
2032 | 2032 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
2033 | - if( ! $related_model_object){ |
|
2033 | + if ( ! $related_model_object) { |
|
2034 | 2034 | $related_model_object = $this->get_one_from_cache($relationName); |
2035 | 2035 | } |
2036 | 2036 | |
@@ -2052,12 +2052,12 @@ discard block |
||
2052 | 2052 | * @return int how many deleted |
2053 | 2053 | * @throws \EE_Error |
2054 | 2054 | */ |
2055 | - public function delete_related($relationName,$query_params = array()){ |
|
2056 | - if($this->ID()){ |
|
2057 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2058 | - }else{ |
|
2055 | + public function delete_related($relationName, $query_params = array()) { |
|
2056 | + if ($this->ID()) { |
|
2057 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2058 | + } else { |
|
2059 | 2059 | $count = count($this->get_all_from_cache($relationName)); |
2060 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2060 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2061 | 2061 | } |
2062 | 2062 | return $count; |
2063 | 2063 | } |
@@ -2076,13 +2076,13 @@ discard block |
||
2076 | 2076 | * @return int how many deleted (including those soft deleted) |
2077 | 2077 | * @throws \EE_Error |
2078 | 2078 | */ |
2079 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
2080 | - if($this->ID()){ |
|
2081 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2082 | - }else{ |
|
2079 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
2080 | + if ($this->ID()) { |
|
2081 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2082 | + } else { |
|
2083 | 2083 | $count = count($this->get_all_from_cache($relationName)); |
2084 | 2084 | } |
2085 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2085 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2086 | 2086 | return $count; |
2087 | 2087 | } |
2088 | 2088 | |
@@ -2098,7 +2098,7 @@ discard block |
||
2098 | 2098 | * @param string $field_name property to check |
2099 | 2099 | * @return bool TRUE if existing,FALSE if not. |
2100 | 2100 | */ |
2101 | - public function is_set( $field_name ) { |
|
2101 | + public function is_set($field_name) { |
|
2102 | 2102 | return isset($this->_fields[$field_name]); |
2103 | 2103 | } |
2104 | 2104 | |
@@ -2110,11 +2110,11 @@ discard block |
||
2110 | 2110 | * @throws EE_Error |
2111 | 2111 | * @return bool TRUE if existing, throw EE_Error if not. |
2112 | 2112 | */ |
2113 | - protected function _property_exists( $properties ) { |
|
2113 | + protected function _property_exists($properties) { |
|
2114 | 2114 | |
2115 | - foreach ( (array) $properties as $property_name ) { |
|
2115 | + foreach ((array) $properties as $property_name) { |
|
2116 | 2116 | //first make sure this property exists |
2117 | - if ( ! $this->_fields[ $property_name ] ) { |
|
2117 | + if ( ! $this->_fields[$property_name]) { |
|
2118 | 2118 | throw new EE_Error( |
2119 | 2119 | sprintf( |
2120 | 2120 | __( |
@@ -2142,7 +2142,7 @@ discard block |
||
2142 | 2142 | $fields = $this->get_model()->field_settings(FALSE); |
2143 | 2143 | $properties = array(); |
2144 | 2144 | //remove prepended underscore |
2145 | - foreach ( $fields as $field_name => $settings ) { |
|
2145 | + foreach ($fields as $field_name => $settings) { |
|
2146 | 2146 | $properties[$field_name] = $this->get($field_name); |
2147 | 2147 | } |
2148 | 2148 | return $properties; |
@@ -2172,10 +2172,10 @@ discard block |
||
2172 | 2172 | * @throws EE_Error |
2173 | 2173 | * @return mixed whatever the plugin which calls add_filter decides |
2174 | 2174 | */ |
2175 | - public function __call($methodName,$args){ |
|
2176 | - $className=get_class($this); |
|
2177 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2178 | - if ( ! has_filter( $tagName ) ) { |
|
2175 | + public function __call($methodName, $args) { |
|
2176 | + $className = get_class($this); |
|
2177 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2178 | + if ( ! has_filter($tagName)) { |
|
2179 | 2179 | throw new EE_Error( |
2180 | 2180 | sprintf( |
2181 | 2181 | __( |
@@ -2188,7 +2188,7 @@ discard block |
||
2188 | 2188 | ) |
2189 | 2189 | ); |
2190 | 2190 | } |
2191 | - return apply_filters($tagName,null,$this,$args); |
|
2191 | + return apply_filters($tagName, null, $this, $args); |
|
2192 | 2192 | } |
2193 | 2193 | |
2194 | 2194 | |
@@ -2204,7 +2204,7 @@ discard block |
||
2204 | 2204 | * @throws \EE_Error |
2205 | 2205 | * NOTE: if the values haven't changed, returns 0 |
2206 | 2206 | */ |
2207 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2207 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2208 | 2208 | $query_params = array( |
2209 | 2209 | array( |
2210 | 2210 | 'EXM_key' => $meta_key, |
@@ -2212,17 +2212,17 @@ discard block |
||
2212 | 2212 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2213 | 2213 | ) |
2214 | 2214 | ); |
2215 | - if ( $previous_value !== null ) { |
|
2215 | + if ($previous_value !== null) { |
|
2216 | 2216 | $query_params[0]['EXM_value'] = $meta_value; |
2217 | 2217 | } |
2218 | - $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params ); |
|
2219 | - if ( ! $existing_rows_like_that ) { |
|
2220 | - return $this->add_extra_meta( $meta_key, $meta_value ); |
|
2218 | + $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
|
2219 | + if ( ! $existing_rows_like_that) { |
|
2220 | + return $this->add_extra_meta($meta_key, $meta_value); |
|
2221 | 2221 | } else { |
2222 | - foreach ( $existing_rows_like_that as $existing_row ) { |
|
2223 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2222 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2223 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2224 | 2224 | } |
2225 | - return count( $existing_rows_like_that ); |
|
2225 | + return count($existing_rows_like_that); |
|
2226 | 2226 | } |
2227 | 2227 | } |
2228 | 2228 | |
@@ -2239,8 +2239,8 @@ discard block |
||
2239 | 2239 | * @return boolean |
2240 | 2240 | * @throws \EE_Error |
2241 | 2241 | */ |
2242 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2243 | - if ( $unique ) { |
|
2242 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2243 | + if ($unique) { |
|
2244 | 2244 | $existing_extra_meta = EEM_Extra_Meta::instance()->get_one( |
2245 | 2245 | array( |
2246 | 2246 | array( |
@@ -2250,7 +2250,7 @@ discard block |
||
2250 | 2250 | ) |
2251 | 2251 | ) |
2252 | 2252 | ); |
2253 | - if ( $existing_extra_meta ) { |
|
2253 | + if ($existing_extra_meta) { |
|
2254 | 2254 | return false; |
2255 | 2255 | } |
2256 | 2256 | } |
@@ -2277,7 +2277,7 @@ discard block |
||
2277 | 2277 | * @return int number of extra meta rows deleted |
2278 | 2278 | * @throws \EE_Error |
2279 | 2279 | */ |
2280 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2280 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2281 | 2281 | $query_params = array( |
2282 | 2282 | array( |
2283 | 2283 | 'EXM_key' => $meta_key, |
@@ -2285,10 +2285,10 @@ discard block |
||
2285 | 2285 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2286 | 2286 | ) |
2287 | 2287 | ); |
2288 | - if ( $meta_value !== null ) { |
|
2288 | + if ($meta_value !== null) { |
|
2289 | 2289 | $query_params[0]['EXM_value'] = $meta_value; |
2290 | 2290 | } |
2291 | - return EEM_Extra_Meta::instance()->delete( $query_params ); |
|
2291 | + return EEM_Extra_Meta::instance()->delete($query_params); |
|
2292 | 2292 | } |
2293 | 2293 | |
2294 | 2294 | |
@@ -2304,25 +2304,25 @@ discard block |
||
2304 | 2304 | * @return mixed single value if $single; array if ! $single |
2305 | 2305 | * @throws \EE_Error |
2306 | 2306 | */ |
2307 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2308 | - if($single){ |
|
2309 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2310 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2307 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2308 | + if ($single) { |
|
2309 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2310 | + if ($result instanceof EE_Extra_Meta) { |
|
2311 | 2311 | return $result->value(); |
2312 | - }else{ |
|
2312 | + } else { |
|
2313 | 2313 | return $default; |
2314 | 2314 | } |
2315 | - }else{ |
|
2316 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2317 | - if($results){ |
|
2315 | + } else { |
|
2316 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2317 | + if ($results) { |
|
2318 | 2318 | $values = array(); |
2319 | - foreach($results as $result){ |
|
2320 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2319 | + foreach ($results as $result) { |
|
2320 | + if ($result instanceof EE_Extra_Meta) { |
|
2321 | 2321 | $values[$result->ID()] = $result->value(); |
2322 | 2322 | } |
2323 | 2323 | } |
2324 | 2324 | return $values; |
2325 | - }else{ |
|
2325 | + } else { |
|
2326 | 2326 | return $default; |
2327 | 2327 | } |
2328 | 2328 | } |
@@ -2344,20 +2344,20 @@ discard block |
||
2344 | 2344 | * @return array |
2345 | 2345 | * @throws \EE_Error |
2346 | 2346 | */ |
2347 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2347 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2348 | 2348 | $return_array = array(); |
2349 | - if($one_of_each_key){ |
|
2349 | + if ($one_of_each_key) { |
|
2350 | 2350 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2351 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2352 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2351 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2352 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2353 | 2353 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2354 | 2354 | } |
2355 | 2355 | } |
2356 | - }else{ |
|
2356 | + } else { |
|
2357 | 2357 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2358 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2359 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2360 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2358 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2359 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2360 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2361 | 2361 | $return_array[$extra_meta_obj->key()] = array(); |
2362 | 2362 | } |
2363 | 2363 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2375,19 +2375,19 @@ discard block |
||
2375 | 2375 | * @return string |
2376 | 2376 | * @throws \EE_Error |
2377 | 2377 | */ |
2378 | - public function name(){ |
|
2378 | + public function name() { |
|
2379 | 2379 | //find a field that's not a text field |
2380 | 2380 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2381 | - if($field_we_can_use){ |
|
2381 | + if ($field_we_can_use) { |
|
2382 | 2382 | return $this->get($field_we_can_use->get_name()); |
2383 | - }else{ |
|
2383 | + } else { |
|
2384 | 2384 | $first_few_properties = $this->model_field_array(); |
2385 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2385 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2386 | 2386 | $name_parts = array(); |
2387 | - foreach( $first_few_properties as $name=> $value ){ |
|
2387 | + foreach ($first_few_properties as $name=> $value) { |
|
2388 | 2388 | $name_parts[] = "$name:$value"; |
2389 | 2389 | } |
2390 | - return implode(",",$name_parts); |
|
2390 | + return implode(",", $name_parts); |
|
2391 | 2391 | } |
2392 | 2392 | } |
2393 | 2393 | |
@@ -2400,11 +2400,11 @@ discard block |
||
2400 | 2400 | * @return boolean |
2401 | 2401 | * @throws \EE_Error |
2402 | 2402 | */ |
2403 | - public function in_entity_map(){ |
|
2404 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2403 | + public function in_entity_map() { |
|
2404 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2405 | 2405 | //well, if we looked, did we find it in the entity map? |
2406 | 2406 | return TRUE; |
2407 | - }else{ |
|
2407 | + } else { |
|
2408 | 2408 | return FALSE; |
2409 | 2409 | } |
2410 | 2410 | } |
@@ -2415,21 +2415,21 @@ discard block |
||
2415 | 2415 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2416 | 2416 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2417 | 2417 | */ |
2418 | - public function refresh_from_db(){ |
|
2419 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2420 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2421 | - }else{ |
|
2418 | + public function refresh_from_db() { |
|
2419 | + if ($this->ID() && $this->in_entity_map()) { |
|
2420 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2421 | + } else { |
|
2422 | 2422 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2423 | 2423 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2424 | 2424 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2425 | 2425 | //absolutely nothing in it for this ID |
2426 | - if( WP_DEBUG ) { |
|
2426 | + if (WP_DEBUG) { |
|
2427 | 2427 | throw new EE_Error( |
2428 | 2428 | sprintf( |
2429 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2429 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2430 | 2430 | $this->ID(), |
2431 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2432 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2431 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2432 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2433 | 2433 | ) |
2434 | 2434 | ); |
2435 | 2435 | } |
@@ -2443,11 +2443,11 @@ discard block |
||
2443 | 2443 | * (probably a bad assumption they have made, oh well) |
2444 | 2444 | * @return string |
2445 | 2445 | */ |
2446 | - public function __toString(){ |
|
2446 | + public function __toString() { |
|
2447 | 2447 | try { |
2448 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2449 | - } catch ( Exception $e ) { |
|
2450 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
2448 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2449 | + } catch (Exception $e) { |
|
2450 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
2451 | 2451 | return ''; |
2452 | 2452 | } |
2453 | 2453 | } |
@@ -2483,16 +2483,16 @@ discard block |
||
2483 | 2483 | * @throws \EE_Error |
2484 | 2484 | */ |
2485 | 2485 | public function __sleep() { |
2486 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2487 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2488 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2489 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2490 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2491 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2486 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2487 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2488 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2489 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2490 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2491 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2492 | 2492 | } |
2493 | 2493 | } |
2494 | 2494 | } |
2495 | - return array_keys( get_object_vars( $this ) ); |
|
2495 | + return array_keys(get_object_vars($this)); |
|
2496 | 2496 | } |
2497 | 2497 | |
2498 | 2498 |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | /** |
922 | 922 | * Sets deleted |
923 | 923 | * @param boolean $deleted |
924 | - * @return boolean |
|
924 | + * @return boolean|null |
|
925 | 925 | */ |
926 | 926 | public function set_deleted($deleted) { |
927 | 927 | $this->set( 'REG_deleted', $deleted ); |
@@ -965,6 +965,7 @@ discard block |
||
965 | 965 | * |
966 | 966 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
967 | 967 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also consider registration status as well as datetime access. |
968 | + * @param integer $DTT_OR_ID |
|
968 | 969 | * |
969 | 970 | * @return bool |
970 | 971 | */ |
@@ -1103,7 +1104,7 @@ discard block |
||
1103 | 1104 | * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
1104 | 1105 | * "Latest" is defined by the `DTT_EVT_start` column. |
1105 | 1106 | * |
1106 | - * @return EE_Datetime|null |
|
1107 | + * @return null|EE_Base_Class |
|
1107 | 1108 | * @throws \EE_Error |
1108 | 1109 | */ |
1109 | 1110 | public function get_latest_related_datetime() { |
@@ -1374,7 +1375,7 @@ discard block |
||
1374 | 1375 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
1375 | 1376 | * Note: if there are no payments on the registration there will be no payment method returned. |
1376 | 1377 | * |
1377 | - * @return EE_Payment_Method|null |
|
1378 | + * @return null|EE_Base_Class |
|
1378 | 1379 | */ |
1379 | 1380 | public function payment_method() { |
1380 | 1381 | return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
@@ -645,9 +645,9 @@ discard block |
||
645 | 645 | |
646 | 646 | |
647 | 647 | /** |
648 | - * get Attendee Number |
|
649 | - * @access public |
|
650 | - */ |
|
648 | + * get Attendee Number |
|
649 | + * @access public |
|
650 | + */ |
|
651 | 651 | public function count() { |
652 | 652 | return $this->get( 'REG_count' ); |
653 | 653 | } |
@@ -1029,20 +1029,20 @@ discard block |
||
1029 | 1029 | |
1030 | 1030 | |
1031 | 1031 | |
1032 | - /** |
|
1033 | - * toggle Check-in status for this registration |
|
1034 | - * Check-ins are toggled in the following order: |
|
1035 | - * never checked in -> checked in |
|
1036 | - * checked in -> checked out |
|
1037 | - * checked out -> checked in |
|
1038 | - * |
|
1039 | - * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
1040 | - * If not included or null, then it is assumed latest datetime is being toggled. |
|
1041 | - * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
1042 | - * can be checked in or not. Otherwise this forces change in checkin status. |
|
1043 | - * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
1044 | - * @throws EE_Error |
|
1045 | - */ |
|
1032 | + /** |
|
1033 | + * toggle Check-in status for this registration |
|
1034 | + * Check-ins are toggled in the following order: |
|
1035 | + * never checked in -> checked in |
|
1036 | + * checked in -> checked out |
|
1037 | + * checked out -> checked in |
|
1038 | + * |
|
1039 | + * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
1040 | + * If not included or null, then it is assumed latest datetime is being toggled. |
|
1041 | + * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
1042 | + * can be checked in or not. Otherwise this forces change in checkin status. |
|
1043 | + * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
1044 | + * @throws EE_Error |
|
1045 | + */ |
|
1046 | 1046 | public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
1047 | 1047 | if ( empty( $DTT_ID ) ) { |
1048 | 1048 | $datetime = $this->get_latest_related_datetime(); |
@@ -1099,13 +1099,13 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | |
1101 | 1101 | |
1102 | - /** |
|
1103 | - * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
1104 | - * "Latest" is defined by the `DTT_EVT_start` column. |
|
1105 | - * |
|
1106 | - * @return EE_Datetime|null |
|
1107 | - * @throws \EE_Error |
|
1108 | - */ |
|
1102 | + /** |
|
1103 | + * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
1104 | + * "Latest" is defined by the `DTT_EVT_start` column. |
|
1105 | + * |
|
1106 | + * @return EE_Datetime|null |
|
1107 | + * @throws \EE_Error |
|
1108 | + */ |
|
1109 | 1109 | public function get_latest_related_datetime() { |
1110 | 1110 | return EEM_Datetime::instance()->get_one( |
1111 | 1111 | array( |
@@ -1119,12 +1119,12 @@ discard block |
||
1119 | 1119 | |
1120 | 1120 | |
1121 | 1121 | |
1122 | - /** |
|
1123 | - * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
1124 | - * "Earliest" is defined by the `DTT_EVT_start` column. |
|
1125 | - * |
|
1126 | - * @throws \EE_Error |
|
1127 | - */ |
|
1122 | + /** |
|
1123 | + * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
1124 | + * "Earliest" is defined by the `DTT_EVT_start` column. |
|
1125 | + * |
|
1126 | + * @throws \EE_Error |
|
1127 | + */ |
|
1128 | 1128 | public function get_earliest_related_datetime() { |
1129 | 1129 | return EEM_Datetime::instance()->get_one( |
1130 | 1130 | array( |
@@ -1138,18 +1138,18 @@ discard block |
||
1138 | 1138 | |
1139 | 1139 | |
1140 | 1140 | |
1141 | - /** |
|
1142 | - * This method simply returns the check-in status for this registration and the given datetime. |
|
1143 | - * If neither the datetime nor the checkin values are provided as arguments, |
|
1144 | - * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
1145 | - * |
|
1146 | - * @param int $DTT_ID The ID of the datetime we're checking against |
|
1147 | - * (if empty we'll get the primary datetime for |
|
1148 | - * this registration (via event) and use it's ID); |
|
1149 | - * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
1150 | - * @return int Integer representing Check-in status. |
|
1151 | - * @throws \EE_Error |
|
1152 | - */ |
|
1141 | + /** |
|
1142 | + * This method simply returns the check-in status for this registration and the given datetime. |
|
1143 | + * If neither the datetime nor the checkin values are provided as arguments, |
|
1144 | + * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
1145 | + * |
|
1146 | + * @param int $DTT_ID The ID of the datetime we're checking against |
|
1147 | + * (if empty we'll get the primary datetime for |
|
1148 | + * this registration (via event) and use it's ID); |
|
1149 | + * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
1150 | + * @return int Integer representing Check-in status. |
|
1151 | + * @throws \EE_Error |
|
1152 | + */ |
|
1153 | 1153 | public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = null ) { |
1154 | 1154 | $checkin_query_params = array( |
1155 | 1155 | 'order_by' => array( 'CHK_timestamp' => 'DESC' ) |
@@ -1161,8 +1161,8 @@ discard block |
||
1161 | 1161 | |
1162 | 1162 | //get checkin object (if exists) |
1163 | 1163 | $checkin = $checkin instanceof EE_Checkin |
1164 | - ? $checkin |
|
1165 | - : $this->get_first_related( 'Checkin', $checkin_query_params ); |
|
1164 | + ? $checkin |
|
1165 | + : $this->get_first_related( 'Checkin', $checkin_query_params ); |
|
1166 | 1166 | if ( $checkin instanceof EE_Checkin ) { |
1167 | 1167 | if ( $checkin->get( 'CHK_in' ) ) { |
1168 | 1168 | return EE_Registration::checkin_status_in; //checked in |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | |
1416 | 1416 | |
1417 | 1417 | |
1418 | - /*************************** DEPRECATED ***************************/ |
|
1418 | + /*************************** DEPRECATED ***************************/ |
|
1419 | 1419 | |
1420 | 1420 | |
1421 | 1421 | |
@@ -1465,24 +1465,24 @@ discard block |
||
1465 | 1465 | |
1466 | 1466 | |
1467 | 1467 | |
1468 | - /** |
|
1469 | - * Gets the primary datetime related to this registration via the related Event to this registration |
|
1470 | - * |
|
1471 | - * @deprecated 4.9.17 |
|
1472 | - * @return EE_Datetime |
|
1473 | - */ |
|
1474 | - public function get_related_primary_datetime() { |
|
1475 | - EE_Error::doing_it_wrong( |
|
1476 | - __METHOD__, |
|
1477 | - esc_html__( |
|
1478 | - 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
1479 | - 'event_espresso' |
|
1480 | - ), |
|
1481 | - '4.9.17', |
|
1482 | - '5.0.0' |
|
1483 | - ); |
|
1484 | - return $this->event()->primary_datetime(); |
|
1485 | - } |
|
1468 | + /** |
|
1469 | + * Gets the primary datetime related to this registration via the related Event to this registration |
|
1470 | + * |
|
1471 | + * @deprecated 4.9.17 |
|
1472 | + * @return EE_Datetime |
|
1473 | + */ |
|
1474 | + public function get_related_primary_datetime() { |
|
1475 | + EE_Error::doing_it_wrong( |
|
1476 | + __METHOD__, |
|
1477 | + esc_html__( |
|
1478 | + 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
1479 | + 'event_espresso' |
|
1480 | + ), |
|
1481 | + '4.9.17', |
|
1482 | + '5.0.0' |
|
1483 | + ); |
|
1484 | + return $this->event()->primary_datetime(); |
|
1485 | + } |
|
1486 | 1486 | |
1487 | 1487 | |
1488 | 1488 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
2 | 2 | |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * EE_Registration class |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * date_format and the second value is the time format |
44 | 44 | * @return EE_Registration |
45 | 45 | */ |
46 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
47 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
48 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
46 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
47 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
48 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * the website will be used. |
57 | 57 | * @return EE_Registration |
58 | 58 | */ |
59 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
60 | - return new self( $props_n_values, TRUE, $timezone ); |
|
59 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
60 | + return new self($props_n_values, TRUE, $timezone); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param int $EVT_ID Event ID |
69 | 69 | */ |
70 | - public function set_event( $EVT_ID = 0 ) { |
|
71 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
70 | + public function set_event($EVT_ID = 0) { |
|
71 | + $this->set('EVT_ID', $EVT_ID); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -79,18 +79,18 @@ discard block |
||
79 | 79 | * @param mixed $field_value |
80 | 80 | * @param bool $use_default |
81 | 81 | */ |
82 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
83 | - switch( $field_name ) { |
|
82 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
83 | + switch ($field_name) { |
|
84 | 84 | case 'REG_code' : |
85 | - if ( ! empty( $field_value ) && $this->reg_code() == '' ) { |
|
86 | - $this->set_reg_code( $field_value, $use_default ); |
|
85 | + if ( ! empty($field_value) && $this->reg_code() == '') { |
|
86 | + $this->set_reg_code($field_value, $use_default); |
|
87 | 87 | } |
88 | 88 | break; |
89 | 89 | case 'STS_ID' : |
90 | - $this->set_status( $field_value, $use_default ); |
|
90 | + $this->set_status($field_value, $use_default); |
|
91 | 91 | break; |
92 | 92 | default : |
93 | - parent::set( $field_name, $field_value, $use_default ); |
|
93 | + parent::set($field_name, $field_value, $use_default); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -107,42 +107,42 @@ discard block |
||
107 | 107 | * @return bool |
108 | 108 | * @throws \EE_Error |
109 | 109 | */ |
110 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
110 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
111 | 111 | // get current REG_Status |
112 | 112 | $old_STS_ID = $this->status_ID(); |
113 | 113 | // if status has changed |
114 | 114 | if ( |
115 | 115 | $this->ID() // ensure registration is in the db |
116 | 116 | && $old_STS_ID != $new_STS_ID // and that status has actually changed |
117 | - && ! empty( $old_STS_ID ) // and that old status is actually set |
|
118 | - && ! empty( $new_STS_ID ) // as well as the new status |
|
117 | + && ! empty($old_STS_ID) // and that old status is actually set |
|
118 | + && ! empty($new_STS_ID) // as well as the new status |
|
119 | 119 | ) { |
120 | 120 | // TO approved |
121 | - if ( $new_STS_ID === EEM_Registration::status_id_approved ) { |
|
121 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
122 | 122 | // reserve a space by incrementing ticket and datetime sold values |
123 | 123 | $this->_reserve_registration_space(); |
124 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
124 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
125 | 125 | // OR FROM approved |
126 | - } else if ( $old_STS_ID === EEM_Registration::status_id_approved ) { |
|
126 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
127 | 127 | // release a space by decrementing ticket and datetime sold values |
128 | 128 | $this->_release_registration_space(); |
129 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
129 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
130 | 130 | } |
131 | 131 | // update status |
132 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
132 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
133 | 133 | /** @type EE_Registration_Processor $registration_processor */ |
134 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
134 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
135 | 135 | /** @type EE_Transaction_Processor $transaction_processor */ |
136 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
136 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
137 | 137 | /** @type EE_Transaction_Payments $transaction_payments */ |
138 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
138 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
139 | 139 | // these reg statuses should not be considered in any calculations involving monies owing |
140 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) |
|
140 | + $closed_reg_statuses = ! empty($closed_reg_statuses) |
|
141 | 141 | ? $closed_reg_statuses |
142 | 142 | : EEM_Registration::closed_reg_statuses(); |
143 | 143 | if ( |
144 | - in_array( $new_STS_ID, $closed_reg_statuses ) |
|
145 | - && ! in_array( $old_STS_ID, $closed_reg_statuses ) |
|
144 | + in_array($new_STS_ID, $closed_reg_statuses) |
|
145 | + && ! in_array($old_STS_ID, $closed_reg_statuses) |
|
146 | 146 | ) { |
147 | 147 | // cancelled or declined registration |
148 | 148 | $registration_processor->update_registration_after_being_canceled_or_declined( |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | false |
156 | 156 | ); |
157 | 157 | } else if ( |
158 | - in_array( $old_STS_ID, $closed_reg_statuses ) |
|
159 | - && ! in_array( $new_STS_ID, $closed_reg_statuses ) |
|
158 | + in_array($old_STS_ID, $closed_reg_statuses) |
|
159 | + && ! in_array($new_STS_ID, $closed_reg_statuses) |
|
160 | 160 | ) { |
161 | 161 | // reinstating cancelled or declined registration |
162 | 162 | $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
163 | 163 | $this, |
164 | 164 | $closed_reg_statuses |
165 | 165 | ); |
166 | - $transaction_processor->update_transaction_after_reinstating_canceled_registration( $this ); |
|
166 | + $transaction_processor->update_transaction_after_reinstating_canceled_registration($this); |
|
167 | 167 | } |
168 | - $transaction_payments->recalculate_transaction_total( $this->transaction(), false ); |
|
169 | - $this->transaction()->update_status_based_on_total_paid( true ); |
|
170 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
168 | + $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
169 | + $this->transaction()->update_status_based_on_total_paid(true); |
|
170 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
171 | 171 | return TRUE; |
172 | 172 | } else { |
173 | 173 | //even though the old value matches the new value, it's still good to |
174 | 174 | //allow the parent set method to have a say |
175 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
175 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
176 | 176 | return TRUE; |
177 | 177 | } |
178 | 178 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * get Status ID |
184 | 184 | */ |
185 | 185 | public function status_ID() { |
186 | - return $this->get( 'STS_ID' ); |
|
186 | + return $this->get('STS_ID'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -208,12 +208,12 @@ discard block |
||
208 | 208 | * @param boolean $include_archived whether to include archived tickets or not. |
209 | 209 | * @return EE_Ticket |
210 | 210 | */ |
211 | - public function ticket( $include_archived = TRUE ) { |
|
211 | + public function ticket($include_archived = TRUE) { |
|
212 | 212 | $query_params = array(); |
213 | - if ( $include_archived ) { |
|
214 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
213 | + if ($include_archived) { |
|
214 | + $query_params['default_where_conditions'] = 'none'; |
|
215 | 215 | } |
216 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
216 | + return $this->get_first_related('Ticket', $query_params); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function wp_user() { |
243 | 243 | $event = $this->event(); |
244 | - if ( $event instanceof EE_Event ) { |
|
244 | + if ($event instanceof EE_Event) { |
|
245 | 245 | return $event->wp_user(); |
246 | 246 | } |
247 | 247 | return 0; |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @param int $ATT_ID Attendee ID |
268 | 268 | */ |
269 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
270 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
269 | + public function set_attendee_id($ATT_ID = 0) { |
|
270 | + $this->set('ATT_ID', $ATT_ID); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @param int $TXN_ID Transaction ID |
279 | 279 | */ |
280 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
281 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
280 | + public function set_transaction_id($TXN_ID = 0) { |
|
281 | + $this->set('TXN_ID', $TXN_ID); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @param string $REG_session PHP Session ID |
290 | 290 | */ |
291 | - public function set_session( $REG_session = '' ) { |
|
292 | - $this->set( 'REG_session', $REG_session ); |
|
291 | + public function set_session($REG_session = '') { |
|
292 | + $this->set('REG_session', $REG_session); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param string $REG_url_link Registration URL Link |
301 | 301 | */ |
302 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
303 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
302 | + public function set_reg_url_link($REG_url_link = '') { |
|
303 | + $this->set('REG_url_link', $REG_url_link); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @param int $REG_count Primary Attendee |
312 | 312 | */ |
313 | - public function set_count( $REG_count = 1 ) { |
|
314 | - $this->set( 'REG_count', $REG_count ); |
|
313 | + public function set_count($REG_count = 1) { |
|
314 | + $this->set('REG_count', $REG_count); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @param boolean $REG_group_size Group Registration |
323 | 323 | */ |
324 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
325 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
324 | + public function set_group_size($REG_group_size = FALSE) { |
|
325 | + $this->set('REG_group_size', $REG_group_size); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
400 | 400 | */ |
401 | - public function set_reg_date( $REG_date = FALSE ) { |
|
402 | - $this->set( 'REG_date', $REG_date ); |
|
401 | + public function set_reg_date($REG_date = FALSE) { |
|
402 | + $this->set('REG_date', $REG_date); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | * @access public |
411 | 411 | * @param float $REG_final_price |
412 | 412 | */ |
413 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
414 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
413 | + public function set_final_price($REG_final_price = 0.00) { |
|
414 | + $this->set('REG_final_price', $REG_final_price); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | * @access public |
423 | 423 | * @param float $REG_paid |
424 | 424 | */ |
425 | - public function set_paid( $REG_paid = 0.00 ) { |
|
426 | - $this->set( 'REG_paid', $REG_paid ); |
|
425 | + public function set_paid($REG_paid = 0.00) { |
|
426 | + $this->set('REG_paid', $REG_paid); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @param boolean $REG_att_is_going Attendee Is Going |
435 | 435 | */ |
436 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
437 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
436 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
437 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @return EE_Attendee |
445 | 445 | */ |
446 | 446 | public function attendee() { |
447 | - return $this->get_first_related( 'Attendee' ); |
|
447 | + return $this->get_first_related('Attendee'); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * get Event ID |
454 | 454 | */ |
455 | 455 | public function event_ID() { |
456 | - return $this->get( 'EVT_ID' ); |
|
456 | + return $this->get('EVT_ID'); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public function event_name() { |
465 | 465 | $event = $this->event_obj(); |
466 | - if ( $event ) { |
|
466 | + if ($event) { |
|
467 | 467 | return $event->name(); |
468 | 468 | } else { |
469 | 469 | return NULL; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return EE_Event |
478 | 478 | */ |
479 | 479 | public function event_obj() { |
480 | - return $this->get_first_related( 'Event' ); |
|
480 | + return $this->get_first_related('Event'); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * get Attendee ID |
487 | 487 | */ |
488 | 488 | public function attendee_ID() { |
489 | - return $this->get( 'ATT_ID' ); |
|
489 | + return $this->get('ATT_ID'); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * get PHP Session ID |
496 | 496 | */ |
497 | 497 | public function session_ID() { |
498 | - return $this->get( 'REG_session' ); |
|
498 | + return $this->get('REG_session'); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
506 | 506 | * @return string |
507 | 507 | */ |
508 | - public function receipt_url( $messenger = 'html' ) { |
|
508 | + public function receipt_url($messenger = 'html') { |
|
509 | 509 | |
510 | 510 | /** |
511 | 511 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -513,12 +513,12 @@ discard block |
||
513 | 513 | * @since 4.5.0 |
514 | 514 | */ |
515 | 515 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
516 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
516 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
517 | 517 | |
518 | - if ( $has_custom ) { |
|
519 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
518 | + if ($has_custom) { |
|
519 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
520 | 520 | } |
521 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
521 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -529,28 +529,28 @@ discard block |
||
529 | 529 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function invoice_url( $messenger = 'html' ) { |
|
532 | + public function invoice_url($messenger = 'html') { |
|
533 | 533 | /** |
534 | 534 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
535 | 535 | * |
536 | 536 | * @since 4.5.0 |
537 | 537 | */ |
538 | 538 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
539 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
539 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
540 | 540 | |
541 | - if ( $has_custom ) { |
|
542 | - if ( $messenger == 'html' ) { |
|
543 | - return $this->invoice_url( 'launch' ); |
|
541 | + if ($has_custom) { |
|
542 | + if ($messenger == 'html') { |
|
543 | + return $this->invoice_url('launch'); |
|
544 | 544 | } |
545 | 545 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
546 | 546 | |
547 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
548 | - if ( $messenger == 'html' ) { |
|
547 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
548 | + if ($messenger == 'html') { |
|
549 | 549 | $query_args['html'] = TRUE; |
550 | 550 | } |
551 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
551 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
552 | 552 | } |
553 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
553 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @throws \EE_Error |
564 | 564 | */ |
565 | 565 | public function reg_url_link() { |
566 | - return (string)$this->get( 'REG_url_link' ); |
|
566 | + return (string) $this->get('REG_url_link'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
574 | 574 | * @return void |
575 | 575 | */ |
576 | - public function e_invoice_url( $type = 'launch' ) { |
|
577 | - echo $this->invoice_url( $type ); |
|
576 | + public function e_invoice_url($type = 'launch') { |
|
577 | + echo $this->invoice_url($type); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * @return string |
595 | 595 | */ |
596 | 596 | public function payment_overview_url() { |
597 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
597 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | * @return string |
606 | 606 | */ |
607 | 607 | public function edit_attendee_information_url() { |
608 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
608 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @return string |
616 | 616 | */ |
617 | 617 | public function get_admin_edit_url() { |
618 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
618 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * is_primary_registrant? |
625 | 625 | */ |
626 | 626 | public function is_primary_registrant() { |
627 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
627 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | |
@@ -633,12 +633,12 @@ discard block |
||
633 | 633 | * This returns the primary registration object for this registration group (which may be this object). |
634 | 634 | * @return EE_Registration |
635 | 635 | */ |
636 | - public function get_primary_registration() { |
|
637 | - if ( $this->is_primary_registrant() ) |
|
636 | + public function get_primary_registration() { |
|
637 | + if ($this->is_primary_registrant()) |
|
638 | 638 | return $this; |
639 | 639 | |
640 | 640 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
641 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
641 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
642 | 642 | return $primary_registrant; |
643 | 643 | } |
644 | 644 | |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | * @access public |
650 | 650 | */ |
651 | 651 | public function count() { |
652 | - return $this->get( 'REG_count' ); |
|
652 | + return $this->get('REG_count'); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * get Group Size |
659 | 659 | */ |
660 | 660 | public function group_size() { |
661 | - return $this->get( 'REG_group_size' ); |
|
661 | + return $this->get('REG_group_size'); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * get Registration Date |
668 | 668 | */ |
669 | 669 | public function date() { |
670 | - return $this->get( 'REG_date' ); |
|
670 | + return $this->get('REG_date'); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -678,8 +678,8 @@ discard block |
||
678 | 678 | * @param string $time_format |
679 | 679 | * @return string |
680 | 680 | */ |
681 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
682 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
681 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
682 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @return float |
692 | 692 | */ |
693 | 693 | public function final_price() { |
694 | - return $this->get( 'REG_final_price' ); |
|
694 | + return $this->get('REG_final_price'); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * @return string |
703 | 703 | */ |
704 | 704 | public function pretty_final_price() { |
705 | - return $this->get_pretty( 'REG_final_price' ); |
|
705 | + return $this->get_pretty('REG_final_price'); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @return float |
713 | 713 | */ |
714 | 714 | public function paid() { |
715 | - return $this->get( 'REG_paid' ); |
|
715 | + return $this->get('REG_paid'); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * @return float |
723 | 723 | */ |
724 | 724 | public function pretty_paid() { |
725 | - return $this->get_pretty( 'REG_paid' ); |
|
725 | + return $this->get_pretty('REG_paid'); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | |
@@ -733,11 +733,11 @@ discard block |
||
733 | 733 | * @param array $requires_payment |
734 | 734 | * @return bool |
735 | 735 | */ |
736 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
736 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
737 | 737 | // these reg statuses require payment (if event is not free) |
738 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
738 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
739 | 739 | if ( |
740 | - in_array( $this->status_ID(), $requires_payment ) && |
|
740 | + in_array($this->status_ID(), $requires_payment) && |
|
741 | 741 | $this->final_price() != 0 && |
742 | 742 | $this->final_price() != $this->paid() |
743 | 743 | ) { |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | * @param bool $show_icons |
755 | 755 | * @return void |
756 | 756 | */ |
757 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
758 | - echo $this->pretty_status( $show_icons ); |
|
757 | + public function e_pretty_status($show_icons = FALSE) { |
|
758 | + echo $this->pretty_status($show_icons); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | |
@@ -766,10 +766,10 @@ discard block |
||
766 | 766 | * @param bool $show_icons |
767 | 767 | * @return string |
768 | 768 | */ |
769 | - public function pretty_status( $show_icons = FALSE ) { |
|
770 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
769 | + public function pretty_status($show_icons = FALSE) { |
|
770 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
771 | 771 | $icon = ''; |
772 | - switch ( $this->status_ID() ) { |
|
772 | + switch ($this->status_ID()) { |
|
773 | 773 | case EEM_Registration::status_id_approved: |
774 | 774 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
775 | 775 | break; |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
793 | 793 | break; |
794 | 794 | } |
795 | - return $icon . $status[ $this->status_ID() ]; |
|
795 | + return $icon.$status[$this->status_ID()]; |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | * get Attendee Is Going |
802 | 802 | */ |
803 | 803 | public function att_is_going() { |
804 | - return $this->get( 'REG_att_is_going' ); |
|
804 | + return $this->get('REG_att_is_going'); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | * @param array $query_params like EEM_Base::get_all |
812 | 812 | * @return EE_Answer[] |
813 | 813 | */ |
814 | - public function answers( $query_params = NULL ) { |
|
815 | - return $this->get_many_related( 'Answer', $query_params ); |
|
814 | + public function answers($query_params = NULL) { |
|
815 | + return $this->get_many_related('Answer', $query_params); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | |
@@ -826,9 +826,9 @@ discard block |
||
826 | 826 | * (because the answer might be an array of answer values, so passing pretty_value=true |
827 | 827 | * will convert it into some kind of string) |
828 | 828 | */ |
829 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
829 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
830 | 830 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
831 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
831 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | |
@@ -841,13 +841,13 @@ discard block |
||
841 | 841 | */ |
842 | 842 | public function question_groups() { |
843 | 843 | $question_groups = array(); |
844 | - if ( $this->event() instanceof EE_Event ) { |
|
844 | + if ($this->event() instanceof EE_Event) { |
|
845 | 845 | $question_groups = $this->event()->question_groups( |
846 | 846 | array( |
847 | 847 | array( |
848 | 848 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
849 | 849 | ), |
850 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
850 | + 'order_by' => array('QSG_order' => 'ASC') |
|
851 | 851 | ) |
852 | 852 | ); |
853 | 853 | } |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | */ |
865 | 865 | public function count_question_groups() { |
866 | 866 | $qg_count = 0; |
867 | - if ( $this->event() instanceof EE_Event ) { |
|
867 | + if ($this->event() instanceof EE_Event) { |
|
868 | 868 | $qg_count = $this->event()->count_related( |
869 | 869 | 'Question_Group', |
870 | 870 | array( |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | * @return string |
886 | 886 | */ |
887 | 887 | public function reg_date() { |
888 | - return $this->get_datetime( 'REG_date' ); |
|
888 | + return $this->get_datetime('REG_date'); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * @return EE_Datetime_Ticket |
898 | 898 | */ |
899 | 899 | public function datetime_ticket() { |
900 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
900 | + return $this->get_first_related('Datetime_Ticket'); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | |
@@ -907,15 +907,15 @@ discard block |
||
907 | 907 | * @param EE_Datetime_Ticket $datetime_ticket |
908 | 908 | * @return EE_Datetime_Ticket |
909 | 909 | */ |
910 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
911 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
910 | + public function set_datetime_ticket($datetime_ticket) { |
|
911 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
912 | 912 | } |
913 | 913 | /** |
914 | 914 | * Gets deleted |
915 | 915 | * @return boolean |
916 | 916 | */ |
917 | 917 | public function deleted() { |
918 | - return $this->get( 'REG_deleted' ); |
|
918 | + return $this->get('REG_deleted'); |
|
919 | 919 | } |
920 | 920 | |
921 | 921 | /** |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | * @return boolean |
925 | 925 | */ |
926 | 926 | public function set_deleted($deleted) { |
927 | - $this->set( 'REG_deleted', $deleted ); |
|
927 | + $this->set('REG_deleted', $deleted); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | * @return EE_Status |
935 | 935 | */ |
936 | 936 | public function status_obj() { |
937 | - return $this->get_first_related( 'Status' ); |
|
937 | + return $this->get_first_related('Status'); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | |
@@ -945,7 +945,7 @@ discard block |
||
945 | 945 | * @return int |
946 | 946 | */ |
947 | 947 | public function count_checkins() { |
948 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
948 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * @return int |
956 | 956 | */ |
957 | 957 | public function count_checkins_not_checkedout() { |
958 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
958 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | |
@@ -968,20 +968,20 @@ discard block |
||
968 | 968 | * |
969 | 969 | * @return bool |
970 | 970 | */ |
971 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
972 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
971 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
972 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
973 | 973 | |
974 | 974 | //first check registration status |
975 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
975 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
976 | 976 | return false; |
977 | 977 | } |
978 | 978 | //is there a datetime ticket that matches this dtt_ID? |
979 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
979 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
980 | 980 | return false; |
981 | 981 | } |
982 | 982 | |
983 | 983 | //final check is against TKT_uses |
984 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
984 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | |
@@ -994,10 +994,10 @@ discard block |
||
994 | 994 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
995 | 995 | * @return bool true means can checkin. false means cannot checkin. |
996 | 996 | */ |
997 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
998 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
997 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
998 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
999 | 999 | |
1000 | - if ( ! $DTT_ID ) { |
|
1000 | + if ( ! $DTT_ID) { |
|
1001 | 1001 | return false; |
1002 | 1002 | } |
1003 | 1003 | |
@@ -1005,23 +1005,23 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
1007 | 1007 | // or not. |
1008 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
1008 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
1009 | 1009 | return true; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
1013 | 1013 | //go ahead and toggle. |
1014 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
1014 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
1015 | 1015 | return true; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
1019 | 1019 | //disallows further check-ins. |
1020 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
1020 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
1021 | 1021 | // checkins have already reached their max number of uses |
1022 | 1022 | // so registrant can NOT checkin |
1023 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1024 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1023 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1024 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1025 | 1025 | return false; |
1026 | 1026 | } |
1027 | 1027 | return true; |
@@ -1043,15 +1043,15 @@ discard block |
||
1043 | 1043 | * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
1044 | 1044 | * @throws EE_Error |
1045 | 1045 | */ |
1046 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1047 | - if ( empty( $DTT_ID ) ) { |
|
1046 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1047 | + if (empty($DTT_ID)) { |
|
1048 | 1048 | $datetime = $this->get_latest_related_datetime(); |
1049 | 1049 | $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
1050 | 1050 | // verify the registration can checkin for the given DTT_ID |
1051 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1051 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1052 | 1052 | EE_Error::add_error( |
1053 | 1053 | sprintf( |
1054 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1054 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1055 | 1055 | $this->ID(), |
1056 | 1056 | $DTT_ID |
1057 | 1057 | ), |
@@ -1065,8 +1065,8 @@ discard block |
||
1065 | 1065 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1066 | 1066 | ); |
1067 | 1067 | //start by getting the current status so we know what status we'll be changing to. |
1068 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1069 | - $status_to = $status_paths[ $cur_status ]; |
|
1068 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1069 | + $status_to = $status_paths[$cur_status]; |
|
1070 | 1070 | // database only records true for checked IN or false for checked OUT |
1071 | 1071 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1072 | 1072 | $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
@@ -1074,24 +1074,24 @@ discard block |
||
1074 | 1074 | // because we are keeping track of Check-ins over time. |
1075 | 1075 | // Eventually we'll probably want to show a list table |
1076 | 1076 | // for the individual Check-ins so that they can be managed. |
1077 | - $checkin = EE_Checkin::new_instance( array( |
|
1077 | + $checkin = EE_Checkin::new_instance(array( |
|
1078 | 1078 | 'REG_ID' => $this->ID(), |
1079 | 1079 | 'DTT_ID' => $DTT_ID, |
1080 | 1080 | 'CHK_in' => $new_status |
1081 | - ) ); |
|
1081 | + )); |
|
1082 | 1082 | // if the record could not be saved then return false |
1083 | - if ( $checkin->save() === 0 ) { |
|
1084 | - if ( WP_DEBUG ) { |
|
1083 | + if ($checkin->save() === 0) { |
|
1084 | + if (WP_DEBUG) { |
|
1085 | 1085 | global $wpdb; |
1086 | 1086 | $error = sprintf( |
1087 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1087 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1088 | 1088 | '<br />', |
1089 | 1089 | $wpdb->last_error |
1090 | 1090 | ); |
1091 | 1091 | } else { |
1092 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1092 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1093 | 1093 | } |
1094 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1094 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1095 | 1095 | return false; |
1096 | 1096 | } |
1097 | 1097 | return $status_to; |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | array( |
1113 | 1113 | 'Ticket.Registration.REG_ID' => $this->ID() |
1114 | 1114 | ), |
1115 | - 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) |
|
1115 | + 'order_by' => array('DTT_EVT_start' => 'DESC') |
|
1116 | 1116 | ) |
1117 | 1117 | ); |
1118 | 1118 | } |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | array( |
1132 | 1132 | 'Ticket.Registration.REG_ID' => $this->ID() |
1133 | 1133 | ), |
1134 | - 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) |
|
1134 | + 'order_by' => array('DTT_EVT_start' => 'ASC') |
|
1135 | 1135 | ) |
1136 | 1136 | ); |
1137 | 1137 | } |
@@ -1150,21 +1150,21 @@ discard block |
||
1150 | 1150 | * @return int Integer representing Check-in status. |
1151 | 1151 | * @throws \EE_Error |
1152 | 1152 | */ |
1153 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = null ) { |
|
1153 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) { |
|
1154 | 1154 | $checkin_query_params = array( |
1155 | - 'order_by' => array( 'CHK_timestamp' => 'DESC' ) |
|
1155 | + 'order_by' => array('CHK_timestamp' => 'DESC') |
|
1156 | 1156 | ); |
1157 | 1157 | |
1158 | - if ( $DTT_ID > 0 ) { |
|
1159 | - $checkin_query_params[0] = array( 'DTT_ID' => $DTT_ID ); |
|
1158 | + if ($DTT_ID > 0) { |
|
1159 | + $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | //get checkin object (if exists) |
1163 | 1163 | $checkin = $checkin instanceof EE_Checkin |
1164 | 1164 | ? $checkin |
1165 | - : $this->get_first_related( 'Checkin', $checkin_query_params ); |
|
1166 | - if ( $checkin instanceof EE_Checkin ) { |
|
1167 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1165 | + : $this->get_first_related('Checkin', $checkin_query_params); |
|
1166 | + if ($checkin instanceof EE_Checkin) { |
|
1167 | + if ($checkin->get('CHK_in')) { |
|
1168 | 1168 | return EE_Registration::checkin_status_in; //checked in |
1169 | 1169 | } |
1170 | 1170 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1180,28 +1180,28 @@ discard block |
||
1180 | 1180 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1181 | 1181 | * @return string internationalized message |
1182 | 1182 | */ |
1183 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1183 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1184 | 1184 | //let's get the attendee first so we can include the name of the attendee |
1185 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1186 | - if ( $attendee instanceof EE_Attendee ) { |
|
1187 | - if ( $error ) { |
|
1188 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1185 | + $attendee = $this->get_first_related('Attendee'); |
|
1186 | + if ($attendee instanceof EE_Attendee) { |
|
1187 | + if ($error) { |
|
1188 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1189 | 1189 | } |
1190 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1190 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1191 | 1191 | //what is the status message going to be? |
1192 | - switch ( $cur_status ) { |
|
1192 | + switch ($cur_status) { |
|
1193 | 1193 | case EE_Registration::checkin_status_never : |
1194 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1194 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1195 | 1195 | break; |
1196 | 1196 | case EE_Registration::checkin_status_in : |
1197 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1197 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1198 | 1198 | break; |
1199 | 1199 | case EE_Registration::checkin_status_out : |
1200 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1200 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1201 | 1201 | break; |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1204 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | * get Registration Code |
1226 | 1226 | */ |
1227 | 1227 | public function reg_code() { |
1228 | - return $this->get( 'REG_code' ); |
|
1228 | + return $this->get('REG_code'); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | * get Transaction ID |
1235 | 1235 | */ |
1236 | 1236 | public function transaction_ID() { |
1237 | - return $this->get( 'TXN_ID' ); |
|
1237 | + return $this->get('TXN_ID'); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | * @return int |
1244 | 1244 | */ |
1245 | 1245 | public function ticket_ID() { |
1246 | - return $this->get( 'TKT_ID' ); |
|
1246 | + return $this->get('TKT_ID'); |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | |
@@ -1255,17 +1255,17 @@ discard block |
||
1255 | 1255 | * @param string $REG_code Registration Code |
1256 | 1256 | * @param boolean $use_default |
1257 | 1257 | */ |
1258 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1259 | - if ( empty( $REG_code )) { |
|
1260 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1258 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1259 | + if (empty($REG_code)) { |
|
1260 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1261 | 1261 | return; |
1262 | 1262 | } |
1263 | - if ( ! $this->reg_code() ) { |
|
1264 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1263 | + if ( ! $this->reg_code()) { |
|
1264 | + parent::set('REG_code', $REG_code, $use_default); |
|
1265 | 1265 | } else { |
1266 | 1266 | EE_Error::doing_it_wrong( |
1267 | - __CLASS__ . '::' . __FUNCTION__, |
|
1268 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1267 | + __CLASS__.'::'.__FUNCTION__, |
|
1268 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1269 | 1269 | '4.6.0' |
1270 | 1270 | ); |
1271 | 1271 | } |
@@ -1285,17 +1285,17 @@ discard block |
||
1285 | 1285 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1286 | 1286 | */ |
1287 | 1287 | public function get_all_other_registrations_in_group() { |
1288 | - if ( $this->group_size() < 2 ) { |
|
1288 | + if ($this->group_size() < 2) { |
|
1289 | 1289 | return array(); |
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | $query[0] = array( |
1293 | 1293 | 'TXN_ID' => $this->transaction_ID(), |
1294 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1294 | + 'REG_ID' => array('!=', $this->ID()), |
|
1295 | 1295 | 'TKT_ID' => $this->ticket_ID() |
1296 | 1296 | ); |
1297 | 1297 | |
1298 | - $registrations = $this->get_model()->get_all( $query ); |
|
1298 | + $registrations = $this->get_model()->get_all($query); |
|
1299 | 1299 | return $registrations; |
1300 | 1300 | } |
1301 | 1301 | |
@@ -1304,14 +1304,14 @@ discard block |
||
1304 | 1304 | * @return string |
1305 | 1305 | */ |
1306 | 1306 | public function get_admin_details_link() { |
1307 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1307 | + EE_Registry::instance()->load_helper('URL'); |
|
1308 | 1308 | return EEH_URL::add_query_args_and_nonce( |
1309 | 1309 | array( |
1310 | 1310 | 'page' => 'espresso_registrations', |
1311 | 1311 | 'action' => 'view_registration', |
1312 | 1312 | '_REG_ID' => $this->ID() |
1313 | 1313 | ), |
1314 | - admin_url( 'admin.php' ) |
|
1314 | + admin_url('admin.php') |
|
1315 | 1315 | ); |
1316 | 1316 | } |
1317 | 1317 | |
@@ -1336,12 +1336,12 @@ discard block |
||
1336 | 1336 | * @return string |
1337 | 1337 | */ |
1338 | 1338 | public function get_admin_overview_link() { |
1339 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1339 | + EE_Registry::instance()->load_helper('URL'); |
|
1340 | 1340 | return EEH_URL::add_query_args_and_nonce( |
1341 | 1341 | array( |
1342 | 1342 | 'page' => 'espresso_registrations' |
1343 | 1343 | ), |
1344 | - admin_url( 'admin.php' ) |
|
1344 | + admin_url('admin.php') |
|
1345 | 1345 | ); |
1346 | 1346 | } |
1347 | 1347 | |
@@ -1352,8 +1352,8 @@ discard block |
||
1352 | 1352 | * @return \EE_Registration[] |
1353 | 1353 | * @throws \EE_Error |
1354 | 1354 | */ |
1355 | - public function payments( $query_params = array() ) { |
|
1356 | - return $this->get_many_related( 'Payment', $query_params ); |
|
1355 | + public function payments($query_params = array()) { |
|
1356 | + return $this->get_many_related('Payment', $query_params); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | |
@@ -1363,8 +1363,8 @@ discard block |
||
1363 | 1363 | * @return \EE_Registration_Payment[] |
1364 | 1364 | * @throws \EE_Error |
1365 | 1365 | */ |
1366 | - public function registration_payments( $query_params = array() ) { |
|
1367 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
1366 | + public function registration_payments($query_params = array()) { |
|
1367 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | * @return EE_Payment_Method|null |
1378 | 1378 | */ |
1379 | 1379 | public function payment_method() { |
1380 | - return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
|
1380 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | ); |
353 | 353 | if ( $this->_current_page === 'espresso_registrations' && in_array( $this->_req_action, $routes_to_add_to ) ) { |
354 | 354 | if ( ( $this->_req_action === 'event_registrations' && empty( $this->_req_data['event_id'] ) ) |
355 | - || ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ) |
|
355 | + || ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ) |
|
356 | 356 | ) { |
357 | 357 | echo ''; |
358 | 358 | } else { |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | '<span class="send-selected-newsletter-count">0</span>' |
362 | 362 | ); |
363 | 363 | echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
364 | - . $button_text |
|
365 | - . '</button>'; |
|
364 | + . $button_text |
|
365 | + . '</button>'; |
|
366 | 366 | add_action( 'admin_footer', array( $this, 'newsletter_send_form_skeleton' ) ); |
367 | 367 | } |
368 | 368 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | $new_status = $this->_toggle_checkin_status(); |
796 | 796 | //setup new class to return via ajax |
797 | 797 | $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' |
798 | - . $new_status; |
|
798 | + . $new_status; |
|
799 | 799 | $this->_template_args['success'] = true; |
800 | 800 | $this->_return_json(); |
801 | 801 | } |
@@ -1178,8 +1178,8 @@ discard block |
||
1178 | 1178 | 'event_espresso' |
1179 | 1179 | ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
1180 | 1180 | $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' |
1181 | - . $edit_event_lnk |
|
1182 | - . '</span>'; |
|
1181 | + . $edit_event_lnk |
|
1182 | + . '</span>'; |
|
1183 | 1183 | } |
1184 | 1184 | $back_2_reg_url = self::add_query_args_and_nonce( array( 'action' => 'default' ), REG_ADMIN_URL ); |
1185 | 1185 | $back_2_reg_lnk = '<a href="' . $back_2_reg_url . '" title="' . esc_attr__( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -30,20 +30,20 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @param bool $routing |
32 | 32 | */ |
33 | - public function __construct( $routing = true ) { |
|
34 | - parent::__construct( $routing ); |
|
35 | - if ( ! defined( 'REG_CAF_TEMPLATE_PATH' ) ) { |
|
36 | - define( 'REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/' ); |
|
37 | - define( 'REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/' ); |
|
38 | - define( 'REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/' ); |
|
33 | + public function __construct($routing = true) { |
|
34 | + parent::__construct($routing); |
|
35 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
36 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
37 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
38 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | |
43 | 43 | |
44 | 44 | protected function _extend_page_config() { |
45 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
46 | - $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) |
|
45 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
46 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
47 | 47 | ? $this->_req_data['_REG_ID'] |
48 | 48 | : 0; |
49 | 49 | // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | 'capability' => 'ee_read_checkins', |
86 | 86 | ), |
87 | 87 | ); |
88 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
88 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
89 | 89 | $new_page_config = array( |
90 | 90 | 'reports' => array( |
91 | 91 | 'nav' => array( |
92 | - 'label' => __( 'Reports', 'event_espresso' ), |
|
92 | + 'label' => __('Reports', 'event_espresso'), |
|
93 | 93 | 'order' => 30, |
94 | 94 | ), |
95 | 95 | 'help_tabs' => array( |
96 | 96 | 'registrations_reports_help_tab' => array( |
97 | - 'title' => __( 'Registration Reports', 'event_espresso' ), |
|
97 | + 'title' => __('Registration Reports', 'event_espresso'), |
|
98 | 98 | 'filename' => 'registrations_reports', |
99 | 99 | ), |
100 | 100 | ), |
@@ -103,41 +103,41 @@ discard block |
||
103 | 103 | ), |
104 | 104 | 'event_registrations' => array( |
105 | 105 | 'nav' => array( |
106 | - 'label' => __( 'Event Check-In', 'event_espresso' ), |
|
106 | + 'label' => __('Event Check-In', 'event_espresso'), |
|
107 | 107 | 'order' => 10, |
108 | 108 | 'persistent' => true, |
109 | 109 | ), |
110 | 110 | 'help_tabs' => array( |
111 | 111 | 'registrations_event_checkin_help_tab' => array( |
112 | - 'title' => __( 'Registrations Event Check-In', 'event_espresso' ), |
|
112 | + 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
113 | 113 | 'filename' => 'registrations_event_checkin', |
114 | 114 | ), |
115 | 115 | 'registrations_event_checkin_table_column_headings_help_tab' => array( |
116 | - 'title' => __( 'Event Check-In Table Column Headings', 'event_espresso' ), |
|
116 | + 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
117 | 117 | 'filename' => 'registrations_event_checkin_table_column_headings', |
118 | 118 | ), |
119 | 119 | 'registrations_event_checkin_filters_help_tab' => array( |
120 | - 'title' => __( 'Event Check-In Filters', 'event_espresso' ), |
|
120 | + 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
121 | 121 | 'filename' => 'registrations_event_checkin_filters', |
122 | 122 | ), |
123 | 123 | 'registrations_event_checkin_views_help_tab' => array( |
124 | - 'title' => __( 'Event Check-In Views', 'event_espresso' ), |
|
124 | + 'title' => __('Event Check-In Views', 'event_espresso'), |
|
125 | 125 | 'filename' => 'registrations_event_checkin_views', |
126 | 126 | ), |
127 | 127 | 'registrations_event_checkin_other_help_tab' => array( |
128 | - 'title' => __( 'Event Check-In Other', 'event_espresso' ), |
|
128 | + 'title' => __('Event Check-In Other', 'event_espresso'), |
|
129 | 129 | 'filename' => 'registrations_event_checkin_other', |
130 | 130 | ), |
131 | 131 | ), |
132 | - 'help_tour' => array( 'Event_Checkin_Help_Tour' ), |
|
133 | - 'qtips' => array( 'Registration_List_Table_Tips' ), |
|
132 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
133 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
134 | 134 | 'list_table' => 'EE_Event_Registrations_List_Table', |
135 | 135 | 'metaboxes' => array(), |
136 | 136 | 'require_nonce' => false, |
137 | 137 | ), |
138 | 138 | 'registration_checkins' => array( |
139 | 139 | 'nav' => array( |
140 | - 'label' => __( 'Check-In Records', 'event_espresso' ), |
|
140 | + 'label' => __('Check-In Records', 'event_espresso'), |
|
141 | 141 | 'order' => 15, |
142 | 142 | 'persistent' => false, |
143 | 143 | ), |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'require_nonce' => false, |
148 | 148 | ), |
149 | 149 | ); |
150 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
150 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
151 | 151 | $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
152 | 152 | $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
153 | 153 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | protected function _ajax_hooks() { |
158 | 158 | parent::_ajax_hooks(); |
159 | - add_action( 'wp_ajax_get_newsletter_form_content', array( $this, 'get_newsletter_form_content' ) ); |
|
159 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -164,25 +164,25 @@ discard block |
||
164 | 164 | public function load_scripts_styles() { |
165 | 165 | parent::load_scripts_styles(); |
166 | 166 | //if newsletter message type is active then let's add filter and load js for it. |
167 | - if ( EEH_MSG_Template::is_mt_active( 'newsletter' ) ) { |
|
167 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
168 | 168 | //enqueue newsletter js |
169 | 169 | wp_enqueue_script( |
170 | 170 | 'ee-newsletter-trigger', |
171 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
172 | - array( 'ee-dialog' ), |
|
171 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
172 | + array('ee-dialog'), |
|
173 | 173 | EVENT_ESPRESSO_VERSION, |
174 | 174 | true |
175 | 175 | ); |
176 | 176 | wp_enqueue_style( |
177 | 177 | 'ee-newsletter-trigger-css', |
178 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
178 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', |
|
179 | 179 | array(), |
180 | 180 | EVENT_ESPRESSO_VERSION |
181 | 181 | ); |
182 | 182 | //hook in buttons for newsletter message type trigger. |
183 | 183 | add_action( |
184 | 184 | 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
185 | - array( $this, 'add_newsletter_action_buttons' ), |
|
185 | + array($this, 'add_newsletter_action_buttons'), |
|
186 | 186 | 10 |
187 | 187 | ); |
188 | 188 | } |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | public function load_scripts_styles_reports() { |
194 | 194 | wp_register_script( |
195 | 195 | 'ee-reg-reports-js', |
196 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
197 | - array( 'google-charts' ), |
|
196 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
197 | + array('google-charts'), |
|
198 | 198 | EVENT_ESPRESSO_VERSION, |
199 | 199 | true |
200 | 200 | ); |
201 | - wp_enqueue_script( 'ee-reg-reports-js' ); |
|
201 | + wp_enqueue_script('ee-reg-reports-js'); |
|
202 | 202 | $this->_registration_reports_js_setup(); |
203 | 203 | } |
204 | 204 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | protected function _add_screen_options_registration_checkins() { |
214 | 214 | $page_title = $this->_admin_page_title; |
215 | - $this->_admin_page_title = __( 'Check-In Records', 'event_espresso' ); |
|
215 | + $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
216 | 216 | $this->_per_page_screen_option(); |
217 | 217 | $this->_admin_page_title = $page_title; |
218 | 218 | } |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | $this->_views = array( |
224 | 224 | 'all' => array( |
225 | 225 | 'slug' => 'all', |
226 | - 'label' => __( 'All', 'event_espresso' ), |
|
226 | + 'label' => __('All', 'event_espresso'), |
|
227 | 227 | 'count' => 0, |
228 | - 'bulk_action' => ! isset( $this->_req_data['event_id'] ) |
|
228 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
229 | 229 | ? array() |
230 | 230 | : array( |
231 | - 'toggle_checkin_status' => __( 'Toggle Check-In', 'event_espresso' ), |
|
231 | + 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
|
232 | 232 | //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
233 | 233 | ), |
234 | 234 | ), |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | $this->_views = array( |
242 | 242 | 'all' => array( |
243 | 243 | 'slug' => 'all', |
244 | - 'label' => __( 'All', 'event_espresso' ), |
|
244 | + 'label' => __('All', 'event_espresso'), |
|
245 | 245 | 'count' => 0, |
246 | - 'bulk_action' => array( 'delete_checkin_rows' => __( 'Delete Check-In Rows', 'event_espresso' ) ), |
|
246 | + 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
247 | 247 | ), |
248 | 248 | ); |
249 | 249 | } |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public function get_newsletter_form_content() { |
261 | 261 | //do a nonce check cause we're not coming in from an normal route here. |
262 | - $nonce = isset( $this->_req_data['get_newsletter_form_content_nonce'] ) ? sanitize_text_field( |
|
262 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
263 | 263 | $this->_req_data['get_newsletter_form_content_nonce'] |
264 | 264 | ) : ''; |
265 | 265 | $nonce_ref = 'get_newsletter_form_content_nonce'; |
266 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
266 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
267 | 267 | //let's get the mtp for the incoming MTP_ ID |
268 | - if ( ! isset( $this->_req_data['GRP_ID'] ) ) { |
|
268 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
269 | 269 | EE_Error::add_error( |
270 | 270 | __( |
271 | 271 | 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | $this->_template_args['error'] = true; |
280 | 280 | $this->_return_json(); |
281 | 281 | } |
282 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_req_data['GRP_ID'] ); |
|
283 | - if ( ! $MTPG instanceof EE_Message_Template_Group ) { |
|
282 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
283 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
284 | 284 | EE_Error::add_error( |
285 | 285 | sprintf( |
286 | 286 | __( |
@@ -301,27 +301,27 @@ discard block |
||
301 | 301 | $MTPs = $MTPs['attendee']; |
302 | 302 | $template_fields = array(); |
303 | 303 | /** @var EE_Message_Template $MTP */ |
304 | - foreach ( $MTPs as $MTP ) { |
|
305 | - $field = $MTP->get( 'MTP_template_field' ); |
|
306 | - if ( $field === 'content' ) { |
|
307 | - $content = $MTP->get( 'MTP_content' ); |
|
308 | - if ( ! empty( $content['newsletter_content'] ) ) { |
|
304 | + foreach ($MTPs as $MTP) { |
|
305 | + $field = $MTP->get('MTP_template_field'); |
|
306 | + if ($field === 'content') { |
|
307 | + $content = $MTP->get('MTP_content'); |
|
308 | + if ( ! empty($content['newsletter_content'])) { |
|
309 | 309 | $template_fields['newsletter_content'] = $content['newsletter_content']; |
310 | 310 | } |
311 | 311 | continue; |
312 | 312 | } |
313 | - $template_fields[ $MTP->get( 'MTP_template_field' ) ] = $MTP->get( 'MTP_content' ); |
|
313 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
314 | 314 | } |
315 | 315 | $this->_template_args['success'] = true; |
316 | 316 | $this->_template_args['error'] = false; |
317 | 317 | $this->_template_args['data'] = array( |
318 | - 'batch_message_from' => isset( $template_fields['from'] ) |
|
318 | + 'batch_message_from' => isset($template_fields['from']) |
|
319 | 319 | ? $template_fields['from'] |
320 | 320 | : '', |
321 | - 'batch_message_subject' => isset( $template_fields['subject'] ) |
|
321 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
322 | 322 | ? $template_fields['subject'] |
323 | 323 | : '', |
324 | - 'batch_message_content' => isset( $template_fields['newsletter_content'] ) |
|
324 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
325 | 325 | ? $template_fields['newsletter_content'] |
326 | 326 | : '', |
327 | 327 | ); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param EE_Admin_List_Table $list_table |
338 | 338 | * @return void |
339 | 339 | */ |
340 | - public function add_newsletter_action_buttons( EE_Admin_List_Table $list_table ) { |
|
340 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) { |
|
341 | 341 | if ( ! EE_Registry::instance()->CAP->current_user_can( |
342 | 342 | 'ee_send_message', |
343 | 343 | 'espresso_registrations_newsletter_selected_send' |
@@ -350,20 +350,20 @@ discard block |
||
350 | 350 | 'event_registrations', |
351 | 351 | 'default', |
352 | 352 | ); |
353 | - if ( $this->_current_page === 'espresso_registrations' && in_array( $this->_req_action, $routes_to_add_to ) ) { |
|
354 | - if ( ( $this->_req_action === 'event_registrations' && empty( $this->_req_data['event_id'] ) ) |
|
355 | - || ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ) |
|
353 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
354 | + if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
355 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
356 | 356 | ) { |
357 | 357 | echo ''; |
358 | 358 | } else { |
359 | 359 | $button_text = sprintf( |
360 | - __( 'Send Batch Message (%s selected)', 'event_espresso' ), |
|
360 | + __('Send Batch Message (%s selected)', 'event_espresso'), |
|
361 | 361 | '<span class="send-selected-newsletter-count">0</span>' |
362 | 362 | ); |
363 | 363 | echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
364 | 364 | . $button_text |
365 | 365 | . '</button>'; |
366 | - add_action( 'admin_footer', array( $this, 'newsletter_send_form_skeleton' ) ); |
|
366 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | } |
@@ -374,36 +374,36 @@ discard block |
||
374 | 374 | $list_table = $this->_list_table_object; |
375 | 375 | $codes = array(); |
376 | 376 | //need to templates for the newsletter message type for the template selector. |
377 | - $values[] = array( 'text' => __( 'Select Template to Use', 'event_espresso' ), 'id' => 0 ); |
|
377 | + $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
378 | 378 | $mtps = EEM_Message_Template_Group::instance()->get_all( |
379 | - array( array( 'MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email' ) ) |
|
379 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
380 | 380 | ); |
381 | - foreach ( $mtps as $mtp ) { |
|
381 | + foreach ($mtps as $mtp) { |
|
382 | 382 | $name = $mtp->name(); |
383 | 383 | $values[] = array( |
384 | - 'text' => empty( $name ) ? __( 'Global', 'event_espresso' ) : $name, |
|
384 | + 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
385 | 385 | 'id' => $mtp->ID(), |
386 | 386 | ); |
387 | 387 | } |
388 | 388 | //need to get a list of shortcodes that are available for the newsletter message type. |
389 | - $shortcodes = EEH_MSG_Template::get_shortcodes( 'newsletter', 'email', array(), 'attendee', false ); |
|
390 | - foreach ( $shortcodes as $field => $shortcode_array ) { |
|
391 | - $codes[ $field ] = implode( ', ', array_keys( $shortcode_array ) ); |
|
389 | + $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
390 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
391 | + $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
392 | 392 | } |
393 | 393 | $shortcodes = $codes; |
394 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
394 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
395 | 395 | $form_template_args = array( |
396 | - 'form_action' => admin_url( 'admin.php?page=espresso_registrations' ), |
|
396 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
397 | 397 | 'form_route' => 'newsletter_selected_send', |
398 | 398 | 'form_nonce_name' => 'newsletter_selected_send_nonce', |
399 | - 'form_nonce' => wp_create_nonce( 'newsletter_selected_send_nonce' ), |
|
399 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
400 | 400 | 'redirect_back_to' => $this->_req_action, |
401 | - 'ajax_nonce' => wp_create_nonce( 'get_newsletter_form_content_nonce' ), |
|
402 | - 'template_selector' => EEH_Form_Fields::select_input( 'newsletter_mtp_selected', $values ), |
|
401 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
402 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
403 | 403 | 'shortcodes' => $shortcodes, |
404 | 404 | 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
405 | 405 | ); |
406 | - EEH_Template::display_template( $form_template, $form_template_args ); |
|
406 | + EEH_Template::display_template($form_template, $form_template_args); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | protected function _newsletter_selected_send() { |
419 | 419 | $success = true; |
420 | 420 | //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
421 | - if ( empty( $this->_req_data['newsletter_mtp_selected'] ) ) { |
|
421 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
422 | 422 | EE_Error::add_error( |
423 | 423 | __( |
424 | 424 | 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | ); |
431 | 431 | $success = false; |
432 | 432 | } |
433 | - if ( $success ) { |
|
433 | + if ($success) { |
|
434 | 434 | //update Message template in case there are any changes |
435 | 435 | $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
436 | 436 | $this->_req_data['newsletter_mtp_selected'] |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
439 | 439 | ? $Message_Template_Group->context_templates() |
440 | 440 | : array(); |
441 | - if ( empty( $Message_Templates ) ) { |
|
441 | + if (empty($Message_Templates)) { |
|
442 | 442 | EE_Error::add_error( |
443 | 443 | __( |
444 | 444 | 'Unable to retrieve message template fields from the db. Messages not sent.', |
@@ -450,25 +450,25 @@ discard block |
||
450 | 450 | ); |
451 | 451 | } |
452 | 452 | //let's just update the specific fields |
453 | - foreach ( $Message_Templates['attendee'] as $Message_Template ) { |
|
454 | - if ( $Message_Template instanceof EE_Message_Template ) { |
|
455 | - $field = $Message_Template->get( 'MTP_template_field' ); |
|
456 | - $content = $Message_Template->get( 'MTP_content' ); |
|
453 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
454 | + if ($Message_Template instanceof EE_Message_Template) { |
|
455 | + $field = $Message_Template->get('MTP_template_field'); |
|
456 | + $content = $Message_Template->get('MTP_content'); |
|
457 | 457 | $new_content = $content; |
458 | - switch ( $field ) { |
|
458 | + switch ($field) { |
|
459 | 459 | case 'from' : |
460 | - $new_content = ! empty( $this->_req_data['batch_message']['from'] ) |
|
460 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
461 | 461 | ? $this->_req_data['batch_message']['from'] |
462 | 462 | : $content; |
463 | 463 | break; |
464 | 464 | case 'subject' : |
465 | - $new_content = ! empty( $this->_req_data['batch_message']['subject'] ) |
|
465 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
466 | 466 | ? $this->_req_data['batch_message']['subject'] |
467 | 467 | : $content; |
468 | 468 | break; |
469 | 469 | case 'content' : |
470 | 470 | $new_content = $content; |
471 | - $new_content['newsletter_content'] = ! empty( $this->_req_data['batch_message']['content'] ) |
|
471 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
472 | 472 | ? $this->_req_data['batch_message']['content'] |
473 | 473 | : $content['newsletter_content']; |
474 | 474 | break; |
@@ -476,32 +476,32 @@ discard block |
||
476 | 476 | continue; |
477 | 477 | break; |
478 | 478 | } |
479 | - $Message_Template->set( 'MTP_content', $new_content ); |
|
479 | + $Message_Template->set('MTP_content', $new_content); |
|
480 | 480 | $Message_Template->save(); |
481 | 481 | } |
482 | 482 | } |
483 | 483 | //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
484 | - $id_type = ! empty( $this->_req_data['batch_message']['id_type'] ) |
|
484 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
485 | 485 | ? $this->_req_data['batch_message']['id_type'] |
486 | 486 | : 'registration'; |
487 | 487 | //id_type will affect how we assemble the ids. |
488 | - $ids = ! empty( $this->_req_data['batch_message']['ids'] ) |
|
489 | - ? json_decode( stripslashes( $this->_req_data['batch_message']['ids'] ) ) |
|
488 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
489 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
490 | 490 | : array(); |
491 | 491 | $registrations_used_for_contact_data = array(); |
492 | 492 | //using switch because eventually we'll have other contexts that will be used for generating messages. |
493 | - switch ( $id_type ) { |
|
493 | + switch ($id_type) { |
|
494 | 494 | case 'registration' : |
495 | 495 | $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
496 | 496 | array( |
497 | 497 | array( |
498 | - 'REG_ID' => array( 'IN', $ids ), |
|
498 | + 'REG_ID' => array('IN', $ids), |
|
499 | 499 | ), |
500 | 500 | ) |
501 | 501 | ); |
502 | 502 | break; |
503 | 503 | case 'contact' : |
504 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_latest_registration_for_each_of_given_contacts( $ids ); |
|
504 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_latest_registration_for_each_of_given_contacts($ids); |
|
505 | 505 | break; |
506 | 506 | } |
507 | 507 | do_action( |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | //kept for backward compat, internally we no longer use this action. |
513 | 513 | //@deprecated 4.8.36.rc.002 |
514 | 514 | $contacts = $id_type === 'registration' |
515 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids( $ids ) |
|
516 | - : EEM_Attendee::instance()->get_all( array( array( 'ATT_ID' => array( 'in', $ids ) ) ) ); |
|
515 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
516 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
517 | 517 | do_action( |
518 | 518 | 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
519 | 519 | $contacts, |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | ); |
522 | 522 | } |
523 | 523 | $query_args = array( |
524 | - 'action' => ! empty( $this->_req_data['redirect_back_to'] ) |
|
524 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
525 | 525 | ? $this->_req_data['redirect_back_to'] |
526 | 526 | : 'default', |
527 | 527 | ); |
528 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
528 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * @return void |
549 | 549 | */ |
550 | 550 | protected function _registration_reports() { |
551 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
551 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
552 | 552 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
553 | 553 | $template_path, |
554 | 554 | $this->_reports_template_data, |
@@ -566,26 +566,26 @@ discard block |
||
566 | 566 | * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
567 | 567 | * @return string |
568 | 568 | */ |
569 | - private function _registrations_per_day_report( $period = '-1 month' ) { |
|
569 | + private function _registrations_per_day_report($period = '-1 month') { |
|
570 | 570 | $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
571 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report( $period ); |
|
571 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
572 | 572 | $results = (array) $results; |
573 | 573 | $regs = array(); |
574 | 574 | $subtitle = ''; |
575 | - if ( $results ) { |
|
575 | + if ($results) { |
|
576 | 576 | $column_titles = array(); |
577 | 577 | $tracker = 0; |
578 | - foreach ( $results as $result ) { |
|
578 | + foreach ($results as $result) { |
|
579 | 579 | $report_column_values = array(); |
580 | - foreach ( $result as $property_name => $property_value ) { |
|
580 | + foreach ($result as $property_name => $property_value) { |
|
581 | 581 | $property_value = $property_name === 'Registration_REG_date' ? $property_value |
582 | 582 | : (int) $property_value; |
583 | 583 | $report_column_values[] = $property_value; |
584 | - if ( $tracker === 0 ) { |
|
585 | - if ( $property_name === 'Registration_REG_date' ) { |
|
586 | - $column_titles[] = __( 'Date (only days with registrations are shown)', 'event_espresso' ); |
|
584 | + if ($tracker === 0) { |
|
585 | + if ($property_name === 'Registration_REG_date') { |
|
586 | + $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
587 | 587 | } else { |
588 | - $column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' ); |
|
588 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | } |
@@ -593,34 +593,34 @@ discard block |
||
593 | 593 | $regs[] = $report_column_values; |
594 | 594 | } |
595 | 595 | //make sure the column_titles is pushed to the beginning of the array |
596 | - array_unshift( $regs, $column_titles ); |
|
596 | + array_unshift($regs, $column_titles); |
|
597 | 597 | //setup the date range. |
598 | - $DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() ); |
|
599 | - $beginning_date = new DateTime( "now " . $period, $DateTimeZone ); |
|
600 | - $ending_date = new DateTime( "now", $DateTimeZone ); |
|
598 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
599 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
600 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
601 | 601 | $subtitle = sprintf( |
602 | - _x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ), |
|
603 | - $beginning_date->format( 'Y-m-d' ), |
|
604 | - $ending_date->format( 'Y-m-d' ) |
|
602 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
603 | + $beginning_date->format('Y-m-d'), |
|
604 | + $ending_date->format('Y-m-d') |
|
605 | 605 | ); |
606 | 606 | } |
607 | - $report_title = __( 'Total Registrations per Day', 'event_espresso' ); |
|
607 | + $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
608 | 608 | $report_params = array( |
609 | 609 | 'title' => $report_title, |
610 | 610 | 'subtitle' => $subtitle, |
611 | 611 | 'id' => $report_ID, |
612 | 612 | 'regs' => $regs, |
613 | - 'noResults' => empty( $regs ), |
|
613 | + 'noResults' => empty($regs), |
|
614 | 614 | 'noRegsMsg' => sprintf( |
615 | 615 | __( |
616 | 616 | '%sThere are currently no registration records in the last month for this report.%s', |
617 | 617 | 'event_espresso' |
618 | 618 | ), |
619 | - '<h2>' . $report_title . '</h2><p>', |
|
619 | + '<h2>'.$report_title.'</h2><p>', |
|
620 | 620 | '</p>' |
621 | 621 | ), |
622 | 622 | ); |
623 | - wp_localize_script( 'ee-reg-reports-js', 'regPerDay', $report_params ); |
|
623 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
624 | 624 | return $report_ID; |
625 | 625 | } |
626 | 626 | |
@@ -632,29 +632,29 @@ discard block |
||
632 | 632 | * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
633 | 633 | * @return string |
634 | 634 | */ |
635 | - private function _registrations_per_event_report( $period = '-1 month' ) { |
|
635 | + private function _registrations_per_event_report($period = '-1 month') { |
|
636 | 636 | $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
637 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report( $period ); |
|
637 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
638 | 638 | $results = (array) $results; |
639 | 639 | $regs = array(); |
640 | 640 | $subtitle = ''; |
641 | - if ( $results ) { |
|
641 | + if ($results) { |
|
642 | 642 | $column_titles = array(); |
643 | 643 | $tracker = 0; |
644 | - foreach ( $results as $result ) { |
|
644 | + foreach ($results as $result) { |
|
645 | 645 | $report_column_values = array(); |
646 | - foreach ( $result as $property_name => $property_value ) { |
|
646 | + foreach ($result as $property_name => $property_value) { |
|
647 | 647 | $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
648 | 648 | $property_value, |
649 | 649 | 4, |
650 | 650 | '...' |
651 | 651 | ) : (int) $property_value; |
652 | 652 | $report_column_values[] = $property_value; |
653 | - if ( $tracker === 0 ) { |
|
654 | - if ( $property_name === 'Registration_Event' ) { |
|
655 | - $column_titles[] = __( 'Event', 'event_espresso' ); |
|
653 | + if ($tracker === 0) { |
|
654 | + if ($property_name === 'Registration_Event') { |
|
655 | + $column_titles[] = __('Event', 'event_espresso'); |
|
656 | 656 | } else { |
657 | - $column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' ); |
|
657 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
658 | 658 | } |
659 | 659 | } |
660 | 660 | } |
@@ -662,34 +662,34 @@ discard block |
||
662 | 662 | $regs[] = $report_column_values; |
663 | 663 | } |
664 | 664 | //make sure the column_titles is pushed to the beginning of the array |
665 | - array_unshift( $regs, $column_titles ); |
|
665 | + array_unshift($regs, $column_titles); |
|
666 | 666 | //setup the date range. |
667 | - $DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() ); |
|
668 | - $beginning_date = new DateTime( "now " . $period, $DateTimeZone ); |
|
669 | - $ending_date = new DateTime( "now", $DateTimeZone ); |
|
667 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
668 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
669 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
670 | 670 | $subtitle = sprintf( |
671 | - _x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ), |
|
672 | - $beginning_date->format( 'Y-m-d' ), |
|
673 | - $ending_date->format( 'Y-m-d' ) |
|
671 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
672 | + $beginning_date->format('Y-m-d'), |
|
673 | + $ending_date->format('Y-m-d') |
|
674 | 674 | ); |
675 | 675 | } |
676 | - $report_title = __( 'Total Registrations per Event', 'event_espresso' ); |
|
676 | + $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
677 | 677 | $report_params = array( |
678 | 678 | 'title' => $report_title, |
679 | 679 | 'subtitle' => $subtitle, |
680 | 680 | 'id' => $report_ID, |
681 | 681 | 'regs' => $regs, |
682 | - 'noResults' => empty( $regs ), |
|
682 | + 'noResults' => empty($regs), |
|
683 | 683 | 'noRegsMsg' => sprintf( |
684 | 684 | __( |
685 | 685 | '%sThere are currently no registration records in the last month for this report.%s', |
686 | 686 | 'event_espresso' |
687 | 687 | ), |
688 | - '<h2>' . $report_title . '</h2><p>', |
|
688 | + '<h2>'.$report_title.'</h2><p>', |
|
689 | 689 | '</p>' |
690 | 690 | ), |
691 | 691 | ); |
692 | - wp_localize_script( 'ee-reg-reports-js', 'regPerEvent', $report_params ); |
|
692 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
693 | 693 | return $report_ID; |
694 | 694 | } |
695 | 695 | |
@@ -703,63 +703,63 @@ discard block |
||
703 | 703 | * @throws \EE_Error |
704 | 704 | */ |
705 | 705 | protected function _registration_checkin_list_table() { |
706 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
707 | - $reg_id = isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : null; |
|
706 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
707 | + $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
708 | 708 | /** @var EE_Registration $reg */ |
709 | - $reg = EEM_Registration::instance()->get_one_by_ID( $reg_id ); |
|
709 | + $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
710 | 710 | $this->_admin_page_title .= $this->get_action_link_or_button( |
711 | 711 | 'new_registration', |
712 | 712 | 'add-registrant', |
713 | - array( 'event_id' => $reg->event_ID() ), |
|
713 | + array('event_id' => $reg->event_ID()), |
|
714 | 714 | 'add-new-h2' |
715 | 715 | ); |
716 | 716 | $legend_items = array( |
717 | 717 | 'checkin' => array( |
718 | 718 | 'class' => 'ee-icon ee-icon-check-in', |
719 | - 'desc' => __( 'This indicates the attendee has been checked in', 'event_espresso' ), |
|
719 | + 'desc' => __('This indicates the attendee has been checked in', 'event_espresso'), |
|
720 | 720 | ), |
721 | 721 | 'checkout' => array( |
722 | 722 | 'class' => 'ee-icon ee-icon-check-out', |
723 | - 'desc' => __( 'This indicates the attendee has been checked out', 'event_espresso' ), |
|
723 | + 'desc' => __('This indicates the attendee has been checked out', 'event_espresso'), |
|
724 | 724 | ), |
725 | 725 | ); |
726 | - $this->_template_args['after_list_table'] = $this->_display_legend( $legend_items ); |
|
727 | - $dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : null; |
|
728 | - $go_back_url = ! empty( $reg_id ) ? EE_Admin_Page::add_query_args_and_nonce( |
|
726 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
727 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
728 | + $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce( |
|
729 | 729 | array( |
730 | 730 | 'action' => 'event_registrations', |
731 | - 'event_id' => EEM_Registration::instance()->get_one_by_ID( $reg_id )->get_first_related( 'Event' )->ID( |
|
731 | + 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID( |
|
732 | 732 | ), |
733 | 733 | 'DTT_ID' => $dtt_id, |
734 | 734 | ), |
735 | 735 | $this->_admin_base_url |
736 | 736 | ) : ''; |
737 | - $this->_template_args['before_list_table'] = ! empty( $reg_id ) && ! empty( $dtt_id ) |
|
738 | - ? '<h2>' . sprintf( |
|
739 | - __( "%s's check in records for %s at the event, %s", 'event_espresso' ), |
|
737 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
738 | + ? '<h2>'.sprintf( |
|
739 | + __("%s's check in records for %s at the event, %s", 'event_espresso'), |
|
740 | 740 | '<span id="checkin-attendee-name">' |
741 | 741 | . EEM_Registration::instance() |
742 | - ->get_one_by_ID( $reg_id ) |
|
743 | - ->get_first_related( 'Attendee' ) |
|
744 | - ->full_name() . '</span>', |
|
745 | - '<span id="checkin-dtt"><a href="' . $go_back_url . '">' |
|
742 | + ->get_one_by_ID($reg_id) |
|
743 | + ->get_first_related('Attendee') |
|
744 | + ->full_name().'</span>', |
|
745 | + '<span id="checkin-dtt"><a href="'.$go_back_url.'">' |
|
746 | 746 | . EEM_Datetime::instance() |
747 | - ->get_one_by_ID( $dtt_id ) |
|
748 | - ->start_date_and_time() . ' - ' |
|
747 | + ->get_one_by_ID($dtt_id) |
|
748 | + ->start_date_and_time().' - ' |
|
749 | 749 | . EEM_Datetime::instance() |
750 | - ->get_one_by_ID( $dtt_id ) |
|
751 | - ->end_date_and_time() . '</a></span>', |
|
750 | + ->get_one_by_ID($dtt_id) |
|
751 | + ->end_date_and_time().'</a></span>', |
|
752 | 752 | '<span id="checkin-event-name">' |
753 | 753 | . EEM_Datetime::instance() |
754 | - ->get_one_by_ID( $dtt_id ) |
|
755 | - ->get_first_related( 'Event' ) |
|
756 | - ->get( 'EVT_name' ) . '</span>' |
|
757 | - ) . '</h2>' |
|
754 | + ->get_one_by_ID($dtt_id) |
|
755 | + ->get_first_related('Event') |
|
756 | + ->get('EVT_name').'</span>' |
|
757 | + ).'</h2>' |
|
758 | 758 | : ''; |
759 | - $this->_template_args['list_table_hidden_fields'] = ! empty( $reg_id ) |
|
760 | - ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
761 | - $this->_template_args['list_table_hidden_fields'] .= ! empty( $dtt_id ) |
|
762 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
759 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
760 | + ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : ''; |
|
761 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
762 | + ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
763 | 763 | $this->display_admin_list_table_page_with_no_sidebar(); |
764 | 764 | } |
765 | 765 | |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | */ |
773 | 773 | public function toggle_checkin_status() { |
774 | 774 | //first make sure we have the necessary data |
775 | - if ( ! isset( $this->_req_data['_regid'] ) ) { |
|
775 | + if ( ! isset($this->_req_data['_regid'])) { |
|
776 | 776 | EE_Error::add_error( |
777 | 777 | __( |
778 | 778 | 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
@@ -787,10 +787,10 @@ discard block |
||
787 | 787 | $this->_return_json(); |
788 | 788 | }; |
789 | 789 | //do a nonce check cause we're not coming in from an normal route here. |
790 | - $nonce = isset( $this->_req_data['checkinnonce'] ) ? sanitize_text_field( $this->_req_data['checkinnonce'] ) |
|
790 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
791 | 791 | : ''; |
792 | 792 | $nonce_ref = 'checkin_nonce'; |
793 | - $this->_verify_nonce( $nonce, $nonce_ref ); |
|
793 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
794 | 794 | //beautiful! Made it this far so let's get the status. |
795 | 795 | $new_status = $this->_toggle_checkin_status(); |
796 | 796 | //setup new class to return via ajax |
@@ -812,34 +812,34 @@ discard block |
||
812 | 812 | //first let's get the query args out of the way for the redirect |
813 | 813 | $query_args = array( |
814 | 814 | 'action' => 'event_registrations', |
815 | - 'event_id' => isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null, |
|
816 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : null, |
|
815 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
816 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
817 | 817 | ); |
818 | 818 | $new_status = false; |
819 | 819 | // bulk action check in toggle |
820 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
820 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
821 | 821 | // cycle thru checkboxes |
822 | - while ( list( $REG_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
823 | - $DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : null; |
|
824 | - $new_status = $this->_toggle_checkin( $REG_ID, $DTT_ID ); |
|
822 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
823 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
824 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
825 | 825 | } |
826 | - } elseif ( isset( $this->_req_data['_regid'] ) ) { |
|
826 | + } elseif (isset($this->_req_data['_regid'])) { |
|
827 | 827 | //coming from ajax request |
828 | - $DTT_ID = isset( $this->_req_data['dttid'] ) ? $this->_req_data['dttid'] : null; |
|
828 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
829 | 829 | $query_args['DTT_ID'] = $DTT_ID; |
830 | - $new_status = $this->_toggle_checkin( $this->_req_data['_regid'], $DTT_ID ); |
|
830 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
831 | 831 | } else { |
832 | 832 | EE_Error::add_error( |
833 | - __( 'Missing some required data to toggle the Check-in', 'event_espresso' ), |
|
833 | + __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
834 | 834 | __FILE__, |
835 | 835 | __FUNCTION__, |
836 | 836 | __LINE__ |
837 | 837 | ); |
838 | 838 | } |
839 | - if ( defined( 'DOING_AJAX' ) ) { |
|
839 | + if (defined('DOING_AJAX')) { |
|
840 | 840 | return $new_status; |
841 | 841 | } |
842 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
842 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | |
@@ -854,14 +854,14 @@ discard block |
||
854 | 854 | * @return int The new status toggled to. |
855 | 855 | * @throws \EE_Error |
856 | 856 | */ |
857 | - private function _toggle_checkin( $REG_ID, $DTT_ID ) { |
|
857 | + private function _toggle_checkin($REG_ID, $DTT_ID) { |
|
858 | 858 | /** @var EE_Registration $REG */ |
859 | - $REG = EEM_Registration::instance()->get_one_by_ID( $REG_ID ); |
|
860 | - $new_status = $REG->toggle_checkin_status( $DTT_ID ); |
|
861 | - if ( $new_status !== false ) { |
|
862 | - EE_Error::add_success( $REG->get_checkin_msg( $DTT_ID ) ); |
|
859 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
860 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
861 | + if ($new_status !== false) { |
|
862 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
863 | 863 | } else { |
864 | - EE_Error::add_error( $REG->get_checkin_msg( $DTT_ID, true ), __FILE__, __FUNCTION__, __LINE__ ); |
|
864 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
865 | 865 | $new_status = false; |
866 | 866 | } |
867 | 867 | return $new_status; |
@@ -879,13 +879,13 @@ discard block |
||
879 | 879 | protected function _delete_checkin_rows() { |
880 | 880 | $query_args = array( |
881 | 881 | 'action' => 'registration_checkins', |
882 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0, |
|
883 | - '_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0, |
|
882 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
883 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
884 | 884 | ); |
885 | 885 | $errors = 0; |
886 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) { |
|
887 | - while ( list( $CHK_ID, $value ) = each( $this->_req_data['checkbox'] ) ) { |
|
888 | - if ( ! EEM_Checkin::instance()->delete_by_ID( $CHK_ID ) ) { |
|
886 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
887 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
888 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
889 | 889 | $errors++; |
890 | 890 | } |
891 | 891 | } |
@@ -899,19 +899,19 @@ discard block |
||
899 | 899 | __FUNCTION__, |
900 | 900 | __LINE__ |
901 | 901 | ); |
902 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
902 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
903 | 903 | } |
904 | - if ( $errors > 0 ) { |
|
904 | + if ($errors > 0) { |
|
905 | 905 | EE_Error::add_error( |
906 | - sprintf( __( 'There were %d records that did not delete successfully', 'event_espresso' ), $errors ), |
|
906 | + sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
907 | 907 | __FILE__, |
908 | 908 | __FUNCTION__, |
909 | 909 | __LINE__ |
910 | 910 | ); |
911 | 911 | } else { |
912 | - EE_Error::add_success( __( 'Records were successfully deleted', 'event_espresso' ) ); |
|
912 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
913 | 913 | } |
914 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
914 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | |
@@ -925,19 +925,19 @@ discard block |
||
925 | 925 | protected function _delete_checkin_row() { |
926 | 926 | $query_args = array( |
927 | 927 | 'action' => 'registration_checkins', |
928 | - 'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0, |
|
929 | - '_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0, |
|
928 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
929 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
930 | 930 | ); |
931 | - if ( ! empty( $this->_req_data['CHK_ID'] ) ) { |
|
932 | - if ( ! EEM_Checkin::instance()->delete_by_ID( $this->_req_data['CHK_ID'] ) ) { |
|
931 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
932 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
933 | 933 | EE_Error::add_error( |
934 | - __( 'Something went wrong and this check-in record was not deleted', 'event_espresso' ), |
|
934 | + __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
935 | 935 | __FILE__, |
936 | 936 | __FUNCTION__, |
937 | 937 | __LINE__ |
938 | 938 | ); |
939 | 939 | } else { |
940 | - EE_Error::add_success( __( 'Check-In record successfully deleted', 'event_espresso' ) ); |
|
940 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
941 | 941 | } |
942 | 942 | } else { |
943 | 943 | EE_Error::add_error( |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | __LINE__ |
951 | 951 | ); |
952 | 952 | } |
953 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
953 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | |
@@ -963,12 +963,12 @@ discard block |
||
963 | 963 | * @throws \EE_Error |
964 | 964 | */ |
965 | 965 | protected function _event_registrations_list_table() { |
966 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
967 | - $this->_admin_page_title .= isset( $this->_req_data['event_id'] ) |
|
966 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
967 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
968 | 968 | ? $this->get_action_link_or_button( |
969 | 969 | 'new_registration', |
970 | 970 | 'add-registrant', |
971 | - array( 'event_id' => $this->_req_data['event_id'] ), |
|
971 | + array('event_id' => $this->_req_data['event_id']), |
|
972 | 972 | 'add-new-h2', |
973 | 973 | '', |
974 | 974 | false |
@@ -977,83 +977,83 @@ discard block |
||
977 | 977 | $legend_items = array( |
978 | 978 | 'star-icon' => array( |
979 | 979 | 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
980 | - 'desc' => __( 'This Registrant is the Primary Registrant', 'event_espresso' ), |
|
980 | + 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
981 | 981 | ), |
982 | 982 | 'checkin' => array( |
983 | 983 | 'class' => 'ee-icon ee-icon-check-in', |
984 | - 'desc' => __( 'This Registrant has been Checked In', 'event_espresso' ), |
|
984 | + 'desc' => __('This Registrant has been Checked In', 'event_espresso'), |
|
985 | 985 | ), |
986 | 986 | 'checkout' => array( |
987 | 987 | 'class' => 'ee-icon ee-icon-check-out', |
988 | - 'desc' => __( 'This Registrant has been Checked Out', 'event_espresso' ), |
|
988 | + 'desc' => __('This Registrant has been Checked Out', 'event_espresso'), |
|
989 | 989 | ), |
990 | 990 | 'nocheckinrecord' => array( |
991 | 991 | 'class' => 'dashicons dashicons-no', |
992 | - 'desc' => __( 'No Check-in Record has been Created for this Registrant', 'event_espresso' ), |
|
992 | + 'desc' => __('No Check-in Record has been Created for this Registrant', 'event_espresso'), |
|
993 | 993 | ), |
994 | 994 | 'view_details' => array( |
995 | 995 | 'class' => 'dashicons dashicons-search', |
996 | - 'desc' => __( 'View All Check-in Records for this Registrant', 'event_espresso' ), |
|
996 | + 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
997 | 997 | ), |
998 | 998 | 'approved_status' => array( |
999 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
1000 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ), |
|
999 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
1000 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
1001 | 1001 | ), |
1002 | 1002 | 'cancelled_status' => array( |
1003 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
1004 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ), |
|
1003 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
1004 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
1005 | 1005 | ), |
1006 | 1006 | 'declined_status' => array( |
1007 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
1008 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ), |
|
1007 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
1008 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
1009 | 1009 | ), |
1010 | 1010 | 'not_approved' => array( |
1011 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
1012 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ), |
|
1011 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
1012 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
1013 | 1013 | ), |
1014 | 1014 | 'pending_status' => array( |
1015 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
1016 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ), |
|
1015 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
1016 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
1017 | 1017 | ), |
1018 | 1018 | 'wait_list' => array( |
1019 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
1020 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ), |
|
1019 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
1020 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
1021 | 1021 | ), |
1022 | 1022 | ); |
1023 | - $this->_template_args['after_list_table'] = $this->_display_legend( $legend_items ); |
|
1024 | - $event_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null; |
|
1025 | - $this->_template_args['before_list_table'] = ! empty( $event_id ) |
|
1026 | - ? '<h2>' . sprintf( |
|
1027 | - __( 'Viewing Registrations for Event: %s', 'event_espresso' ), |
|
1028 | - EEM_Event::instance()->get_one_by_ID( $event_id )->get( 'EVT_name' ) |
|
1029 | - ) . '</h2>' |
|
1023 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
1024 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
1025 | + $this->_template_args['before_list_table'] = ! empty($event_id) |
|
1026 | + ? '<h2>'.sprintf( |
|
1027 | + __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
1028 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
1029 | + ).'</h2>' |
|
1030 | 1030 | : ''; |
1031 | 1031 | //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
1032 | 1032 | /** @var EE_Event $event */ |
1033 | - $event = EEM_Event::instance()->get_one_by_ID( $event_id ); |
|
1034 | - $DTT_ID = ! empty( $this->_req_data['DTT_ID'] ) ? absint( $this->_req_data['DTT_ID'] ) : 0; |
|
1033 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
1034 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
1035 | 1035 | $datetime = null; |
1036 | - if ( $event instanceof EE_Event ) { |
|
1036 | + if ($event instanceof EE_Event) { |
|
1037 | 1037 | $datetimes_on_event = $event->datetimes(); |
1038 | - if ( count( $datetimes_on_event ) === 1 ) { |
|
1039 | - $datetime = reset( $datetimes_on_event ); |
|
1038 | + if (count($datetimes_on_event) === 1) { |
|
1039 | + $datetime = reset($datetimes_on_event); |
|
1040 | 1040 | } |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID( $DTT_ID ); |
|
1044 | - if ( $datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '' ) { |
|
1045 | - $this->_template_args['before_list_table'] = substr( $this->_template_args['before_list_table'], 0, -5 ); |
|
1043 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
1044 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
1045 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
1046 | 1046 | $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
1047 | 1047 | $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
1048 | 1048 | $this->_template_args['before_list_table'] .= $datetime->name(); |
1049 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
1049 | + $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )'; |
|
1050 | 1050 | $this->_template_args['before_list_table'] .= '</span></h2>'; |
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
1054 | 1054 | //represents |
1055 | - if ( ! $datetime instanceof EE_Datetime ) { |
|
1056 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' . __( 'In this view, the check-in status represents the latest check-in record for the registration in that row.', 'event_espresso' ) . '</p>'; |
|
1055 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1056 | + $this->_template_args['before_list_table'] .= '<br><p class="description">'.__('In this view, the check-in status represents the latest check-in record for the registration in that row.', 'event_espresso').'</p>'; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -1072,15 +1072,15 @@ discard block |
||
1072 | 1072 | * @throws \EE_Error |
1073 | 1073 | * @access public |
1074 | 1074 | */ |
1075 | - public function get_event_attendees( $per_page = 10, $count = false, $trash = false, $orderby = '' ) { |
|
1076 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1077 | - require_once( EE_MODELS . 'EEM_Attendee.model.php' ); |
|
1075 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = '') { |
|
1076 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1077 | + require_once(EE_MODELS.'EEM_Attendee.model.php'); |
|
1078 | 1078 | //$ATT_MDL = EEM_Attendee::instance(); |
1079 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false; |
|
1080 | - $CAT_ID = isset( $this->_req_data['category_id'] ) ? absint( $this->_req_data['category_id'] ) : false; |
|
1081 | - $DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : null; |
|
1082 | - $this->_req_data['orderby'] = ! empty( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : $orderby; |
|
1083 | - switch ( $this->_req_data['orderby'] ) { |
|
1079 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
1080 | + $CAT_ID = isset($this->_req_data['category_id']) ? absint($this->_req_data['category_id']) : false; |
|
1081 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
1082 | + $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
1083 | + switch ($this->_req_data['orderby']) { |
|
1084 | 1084 | case '_REG_date': |
1085 | 1085 | $orderby = 'REG_date'; |
1086 | 1086 | break; |
@@ -1088,109 +1088,109 @@ discard block |
||
1088 | 1088 | $orderby = 'Attendee.ATT_lname'; |
1089 | 1089 | // $orderby = 'reg.REG_final_price'; |
1090 | 1090 | } |
1091 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) |
|
1091 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
1092 | 1092 | ? $this->_req_data['order'] : 'ASC'; |
1093 | - $current_page = isset( $this->_req_data['paged'] ) && ! empty( $this->_req_data['paged'] ) |
|
1093 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
1094 | 1094 | ? $this->_req_data['paged'] : 1; |
1095 | - $per_page = isset( $this->_req_data['perpage'] ) && ! empty( $this->_req_data['perpage'] ) |
|
1095 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
1096 | 1096 | ? $this->_req_data['perpage'] : $per_page; |
1097 | - $offset = ( $current_page - 1 ) * $per_page; |
|
1098 | - $limit = $count ? null : array( $offset, $per_page ); |
|
1097 | + $offset = ($current_page - 1) * $per_page; |
|
1098 | + $limit = $count ? null : array($offset, $per_page); |
|
1099 | 1099 | $query_params = array( |
1100 | 1100 | array( |
1101 | 1101 | 'Event.status' => array( |
1102 | 1102 | 'IN', |
1103 | - array_keys( EEM_Event::instance()->get_status_array() ), |
|
1103 | + array_keys(EEM_Event::instance()->get_status_array()), |
|
1104 | 1104 | ), |
1105 | 1105 | ), |
1106 | 1106 | ); |
1107 | - if ( $EVT_ID ) { |
|
1107 | + if ($EVT_ID) { |
|
1108 | 1108 | $query_params[0]['EVT_ID'] = $EVT_ID; |
1109 | 1109 | } |
1110 | - if ( $CAT_ID ) { |
|
1110 | + if ($CAT_ID) { |
|
1111 | 1111 | throw new EE_Error( |
1112 | 1112 | "You specified a Category Id for this query. Thats odd because we are now using terms and taxonomies. So did you mean the term taxonomy id o rthe term id?" |
1113 | 1113 | ); |
1114 | 1114 | } |
1115 | 1115 | //if DTT is included we do multiple datetimes. |
1116 | - if ( $DTT_ID ) { |
|
1116 | + if ($DTT_ID) { |
|
1117 | 1117 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
1118 | 1118 | } |
1119 | 1119 | //make sure we only have default where on the current regs |
1120 | 1120 | $query_params['default_where_conditions'] = 'this_model_only'; |
1121 | 1121 | $status_ids_array = apply_filters( |
1122 | 1122 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
1123 | - array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) |
|
1123 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
1124 | 1124 | ); |
1125 | - $query_params[0]['STS_ID'] = array( 'IN', $status_ids_array ); |
|
1126 | - if ( $trash ) { |
|
1125 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
1126 | + if ($trash) { |
|
1127 | 1127 | $query_params[0]['Attendee.status'] = EEM_CPT_Base::post_status_trashed; |
1128 | 1128 | } |
1129 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1130 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1129 | + if (isset($this->_req_data['s'])) { |
|
1130 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1131 | 1131 | $query_params[0]['OR'] = array( |
1132 | - 'Event.EVT_name' => array( 'LIKE', $sstr ), |
|
1133 | - 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
1134 | - 'Event.EVT_short_desc' => array( 'LIKE', $sstr ), |
|
1135 | - 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
|
1136 | - 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
|
1137 | - 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
|
1138 | - 'Attendee.ATT_email' => array( 'LIKE', $sstr ), |
|
1139 | - 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
|
1140 | - 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
|
1141 | - 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
|
1142 | - 'REG_final_price' => array( 'LIKE', $sstr ), |
|
1143 | - 'REG_code' => array( 'LIKE', $sstr ), |
|
1144 | - 'REG_count' => array( 'LIKE', $sstr ), |
|
1145 | - 'REG_group_size' => array( 'LIKE', $sstr ), |
|
1146 | - 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
|
1147 | - 'Ticket.TKT_description' => array( 'LIKE', $sstr ), |
|
1132 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
1133 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1134 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
1135 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
1136 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
1137 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
1138 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
1139 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
1140 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
1141 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
1142 | + 'REG_final_price' => array('LIKE', $sstr), |
|
1143 | + 'REG_code' => array('LIKE', $sstr), |
|
1144 | + 'REG_count' => array('LIKE', $sstr), |
|
1145 | + 'REG_group_size' => array('LIKE', $sstr), |
|
1146 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
1147 | + 'Ticket.TKT_description' => array('LIKE', $sstr), |
|
1148 | 1148 | ); |
1149 | 1149 | } |
1150 | - $query_params['order_by'][ $orderby ] = $sort; |
|
1150 | + $query_params['order_by'][$orderby] = $sort; |
|
1151 | 1151 | $query_params['limit'] = $limit; |
1152 | - $query_params['force_join'] = array( 'Attendee' );//force join to attendee model so that it gets cached, because we're going to need the attendee for each registration |
|
1153 | - if ( $count ) { |
|
1152 | + $query_params['force_join'] = array('Attendee'); //force join to attendee model so that it gets cached, because we're going to need the attendee for each registration |
|
1153 | + if ($count) { |
|
1154 | 1154 | $registrations = EEM_Registration::instance()->count( |
1155 | - array( $query_params[0], 'default_where_conditions' => 'this_model_only' ) |
|
1155 | + array($query_params[0], 'default_where_conditions' => 'this_model_only') |
|
1156 | 1156 | ); |
1157 | 1157 | } else { |
1158 | - $registrations = EEM_Registration::instance()->get_all( $query_params ); |
|
1158 | + $registrations = EEM_Registration::instance()->get_all($query_params); |
|
1159 | 1159 | // $registrations = EEM_Registration::instance(); |
1160 | 1160 | // $all_attendees = EEM_Attendee::instance()->get_event_attendees( $EVT_ID, $CAT_ID, $reg_status, $trash, $orderby, $sort, $limit, $output ); |
1161 | - if ( isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration ) { |
|
1161 | + if (isset($registrations[0]) && $registrations[0] instanceof EE_Registration) { |
|
1162 | 1162 | //EEH_Debug_Tools::printr( $all_attendees[0], '$all_attendees[0] <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
1163 | 1163 | // name |
1164 | 1164 | /** @var EE_Registration $first_registration */ |
1165 | 1165 | $first_registration = $registrations[0]; |
1166 | 1166 | $event_obj = $first_registration->event_obj(); |
1167 | - if ( $event_obj ) { |
|
1167 | + if ($event_obj) { |
|
1168 | 1168 | $event_name = $first_registration->event_obj()->name(); |
1169 | - $event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?';//$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1169 | + $event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?'; //$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1170 | 1170 | // edit event link |
1171 | - if ( $event_name !== '' ) { |
|
1171 | + if ($event_name !== '') { |
|
1172 | 1172 | $edit_event_url = self::add_query_args_and_nonce( |
1173 | - array( 'action' => 'edit_event', 'EVT_ID' => $EVT_ID ), |
|
1173 | + array('action' => 'edit_event', 'EVT_ID' => $EVT_ID), |
|
1174 | 1174 | EVENTS_ADMIN_URL |
1175 | 1175 | ); |
1176 | - $edit_event_lnk = '<a href="' . $edit_event_url . '" title="' . esc_attr__( |
|
1176 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__( |
|
1177 | 1177 | 'Edit ', |
1178 | 1178 | 'event_espresso' |
1179 | - ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
1179 | + ).$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
1180 | 1180 | $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' |
1181 | 1181 | . $edit_event_lnk |
1182 | 1182 | . '</span>'; |
1183 | 1183 | } |
1184 | - $back_2_reg_url = self::add_query_args_and_nonce( array( 'action' => 'default' ), REG_ADMIN_URL ); |
|
1185 | - $back_2_reg_lnk = '<a href="' . $back_2_reg_url . '" title="' . esc_attr__( |
|
1184 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action' => 'default'), REG_ADMIN_URL); |
|
1185 | + $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__( |
|
1186 | 1186 | 'click to return to viewing all registrations ', |
1187 | 1187 | 'event_espresso' |
1188 | - ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
|
1188 | + ).'">« '.__('Back to All Registrations', 'event_espresso').'</a>'; |
|
1189 | 1189 | $this->_template_args['before_admin_page_content'] = ' |
1190 | 1190 | <div id="admin-page-header"> |
1191 | - <h1><span class="small-text not-bold">' . __( 'Event: ', 'event_espresso' ) . '</span>' . $event_name . '</h1> |
|
1192 | - <h3><span class="small-text not-bold">' . __( 'Date: ', 'event_espresso' ) . '</span>' . $event_date . '</h3> |
|
1193 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
1191 | + <h1><span class="small-text not-bold">' . __('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
1192 | + <h3><span class="small-text not-bold">' . __('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
1193 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
1194 | 1194 | </div> |
1195 | 1195 | '; |
1196 | 1196 | } |
@@ -456,14 +456,14 @@ |
||
456 | 456 | //start and end date are the same but times are different |
457 | 457 | case ( $this->start_date() === $this->end_date() ) : |
458 | 458 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
459 | - . $conjunction |
|
460 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
459 | + . $conjunction |
|
460 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
461 | 461 | break; |
462 | 462 | //all other conditions |
463 | 463 | default : |
464 | 464 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
465 | - . $conjunction |
|
466 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
465 | + . $conjunction |
|
466 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
467 | 467 | break; |
468 | 468 | } |
469 | 469 | return $output; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * Sets qty of reserved tickets for this datetime |
241 | 241 | * |
242 | 242 | * @param int $reserved |
243 | - * @return boolean |
|
243 | + * @return boolean|null |
|
244 | 244 | */ |
245 | 245 | function set_reserved( $reserved ) { |
246 | 246 | // reserved can not go below zero |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * increments reserved by amount passed by $qty |
255 | 255 | * |
256 | 256 | * @param int $qty |
257 | - * @return boolean |
|
257 | + * @return boolean|null |
|
258 | 258 | */ |
259 | 259 | function increase_reserved( $qty = 1 ) { |
260 | 260 | $reserved = $this->reserved() + absint( $qty ); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * decrements (subtracts) reserved by amount passed by $qty |
268 | 268 | * |
269 | 269 | * @param int $qty |
270 | - * @return boolean |
|
270 | + * @return boolean|null |
|
271 | 271 | */ |
272 | 272 | function decrease_reserved( $qty = 1 ) { |
273 | 273 | $reserved = $this->reserved() - absint( $qty ); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * get event start date. Provide either the date format, or NULL to re-use the |
364 | 364 | * last-used format, or '' to use the default date format |
365 | 365 | * |
366 | - * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
366 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
367 | 367 | * @return mixed string on success, FALSE on fail |
368 | 368 | */ |
369 | 369 | public function start_date( $dt_frmt = NULL ) { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * get end date. Provide either the date format, or NULL to re-use the |
387 | 387 | * last-used format, or '' to use the default date format |
388 | 388 | * |
389 | - * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
389 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
390 | 390 | * @return mixed string on success, FALSE on fail |
391 | 391 | */ |
392 | 392 | public function end_date( $dt_frmt = NULL ) { |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @param string $dt_frmt - string representation of date format defaults to WP settings |
413 | 413 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with |
414 | 414 | * the end date ie: Jan 01 "to" Dec 31 |
415 | - * @return mixed string on success, FALSE on fail |
|
415 | + * @return string string on success, FALSE on fail |
|
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | * @param string $tm_format string representation of time format defaults to 'g:i a' |
485 | 485 | * @param string $conjunction conjunction junction what's your function ? |
486 | 486 | * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
487 | - * @return mixed string on success, FALSE on fail |
|
487 | + * @return string string on success, FALSE on fail |
|
488 | 488 | * @throws \EE_Error |
489 | 489 | */ |
490 | 490 | public function time_range( $tm_format = null, $conjunction = ' - ' ) { |
@@ -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 | * Event Espresso |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * date_format and the second value is the time format |
75 | 75 | * @return EE_Datetime |
76 | 76 | */ |
77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * the website will be used. |
88 | 88 | * @return EE_Datetime |
89 | 89 | */ |
90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
91 | + return new self($props_n_values, TRUE, $timezone); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @param $name |
98 | 98 | */ |
99 | - public function set_name( $name ) { |
|
100 | - $this->set( 'DTT_name', $name ); |
|
99 | + public function set_name($name) { |
|
100 | + $this->set('DTT_name', $name); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param $description |
107 | 107 | */ |
108 | - public function set_description( $description ) { |
|
109 | - $this->set( 'DTT_description', $description ); |
|
108 | + public function set_description($description) { |
|
109 | + $this->set('DTT_description', $description); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
120 | 120 | */ |
121 | - public function set_start_date( $date ) { |
|
122 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
121 | + public function set_start_date($date) { |
|
122 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
133 | 133 | */ |
134 | - public function set_start_time( $time ) { |
|
135 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
134 | + public function set_start_time($time) { |
|
135 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
146 | 146 | */ |
147 | - public function set_end_date( $date ) { |
|
148 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
147 | + public function set_end_date($date) { |
|
148 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
159 | 159 | */ |
160 | - public function set_end_time( $time ) { |
|
161 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
160 | + public function set_end_time($time) { |
|
161 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param int $reg_limit |
172 | 172 | */ |
173 | - public function set_reg_limit( $reg_limit ) { |
|
174 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
173 | + public function set_reg_limit($reg_limit) { |
|
174 | + $this->set('DTT_reg_limit', $reg_limit); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return mixed int on success, FALSE on fail |
184 | 184 | */ |
185 | 185 | public function sold() { |
186 | - return $this->get_raw( 'DTT_sold' ); |
|
186 | + return $this->get_raw('DTT_sold'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param int $sold |
195 | 195 | */ |
196 | - public function set_sold( $sold ) { |
|
196 | + public function set_sold($sold) { |
|
197 | 197 | // sold can not go below zero |
198 | - $sold = max( 0, $sold ); |
|
199 | - $this->set( 'DTT_sold', $sold ); |
|
198 | + $sold = max(0, $sold); |
|
199 | + $this->set('DTT_sold', $sold); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | * increments sold by amount passed by $qty |
206 | 206 | * @param int $qty |
207 | 207 | */ |
208 | - public function increase_sold( $qty = 1 ) { |
|
208 | + public function increase_sold($qty = 1) { |
|
209 | 209 | $sold = $this->sold() + $qty; |
210 | 210 | // remove ticket reservation |
211 | - $this->decrease_reserved( $qty ); |
|
212 | - $this->set_sold( $sold ); |
|
211 | + $this->decrease_reserved($qty); |
|
212 | + $this->set_sold($sold); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * decrements (subtracts) sold amount passed by $qty |
219 | 219 | * @param int $qty |
220 | 220 | */ |
221 | - public function decrease_sold( $qty = 1 ) { |
|
221 | + public function decrease_sold($qty = 1) { |
|
222 | 222 | $sold = $this->sold() - $qty; |
223 | - $this->set_sold( $sold ); |
|
223 | + $this->set_sold($sold); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @return int |
232 | 232 | */ |
233 | 233 | function reserved() { |
234 | - return $this->get_raw( 'DTT_reserved' ); |
|
234 | + return $this->get_raw('DTT_reserved'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | * @param int $reserved |
243 | 243 | * @return boolean |
244 | 244 | */ |
245 | - function set_reserved( $reserved ) { |
|
245 | + function set_reserved($reserved) { |
|
246 | 246 | // reserved can not go below zero |
247 | - $reserved = max( 0, intval( $reserved ) ); |
|
248 | - $this->set( 'DTT_reserved', $reserved ); |
|
247 | + $reserved = max(0, intval($reserved)); |
|
248 | + $this->set('DTT_reserved', $reserved); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | * @param int $qty |
257 | 257 | * @return boolean |
258 | 258 | */ |
259 | - function increase_reserved( $qty = 1 ) { |
|
260 | - $reserved = $this->reserved() + absint( $qty ); |
|
261 | - return $this->set_reserved( $reserved ); |
|
259 | + function increase_reserved($qty = 1) { |
|
260 | + $reserved = $this->reserved() + absint($qty); |
|
261 | + return $this->set_reserved($reserved); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | * @param int $qty |
270 | 270 | * @return boolean |
271 | 271 | */ |
272 | - function decrease_reserved( $qty = 1 ) { |
|
273 | - $reserved = $this->reserved() - absint( $qty ); |
|
274 | - return $this->set_reserved( $reserved ); |
|
272 | + function decrease_reserved($qty = 1) { |
|
273 | + $reserved = $this->reserved() - absint($qty); |
|
274 | + return $this->set_reserved($reserved); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return string |
293 | 293 | */ |
294 | 294 | public function name() { |
295 | - return $this->get( 'DTT_name' ); |
|
295 | + return $this->get('DTT_name'); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return string |
303 | 303 | */ |
304 | 304 | public function description() { |
305 | - return $this->get( 'DTT_description' ); |
|
305 | + return $this->get('DTT_description'); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return boolean TRUE if is primary, FALSE if not. |
313 | 313 | */ |
314 | 314 | public function is_primary() { |
315 | - return $this->get( 'DTT_is_primary' ); |
|
315 | + return $this->get('DTT_is_primary'); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @return int The order of the datetime for this event. |
323 | 323 | */ |
324 | 324 | public function order() { |
325 | - return $this->get( 'DTT_order' ); |
|
325 | + return $this->get('DTT_order'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @return int |
333 | 333 | */ |
334 | 334 | public function parent() { |
335 | - return $this->get( 'DTT_parent' ); |
|
335 | + return $this->get('DTT_parent'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -348,10 +348,10 @@ discard block |
||
348 | 348 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
349 | 349 | * @return string|bool|void string on success, FALSE on fail |
350 | 350 | */ |
351 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
351 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
352 | 352 | $field_name = "DTT_EVT_{$start_or_end}"; |
353 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
354 | - if ( ! $echo ) { |
|
353 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
354 | + if ( ! $echo) { |
|
355 | 355 | return $dtt; |
356 | 356 | } |
357 | 357 | return ''; |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
367 | 367 | * @return mixed string on success, FALSE on fail |
368 | 368 | */ |
369 | - public function start_date( $dt_frmt = NULL ) { |
|
370 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
369 | + public function start_date($dt_frmt = NULL) { |
|
370 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * Echoes start_date() |
377 | 377 | * @param string $dt_frmt |
378 | 378 | */ |
379 | - public function e_start_date( $dt_frmt = NULL ) { |
|
380 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
379 | + public function e_start_date($dt_frmt = NULL) { |
|
380 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
390 | 390 | * @return mixed string on success, FALSE on fail |
391 | 391 | */ |
392 | - public function end_date( $dt_frmt = NULL ) { |
|
393 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
392 | + public function end_date($dt_frmt = NULL) { |
|
393 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | * Echoes the end date. See end_date() |
400 | 400 | * @param string $dt_frmt |
401 | 401 | */ |
402 | - public function e_end_date( $dt_frmt = NULL ) { |
|
403 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
402 | + public function e_end_date($dt_frmt = NULL) { |
|
403 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | * @return mixed string on success, FALSE on fail |
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | - public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
419 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
420 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
421 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
422 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
418 | + public function date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
419 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
420 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
421 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
422 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param string $conjunction |
430 | 430 | * @throws \EE_Error |
431 | 431 | */ |
432 | - public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
433 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
432 | + public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
433 | + echo $this->date_range($dt_frmt, $conjunction); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
442 | 442 | * @return mixed string on success, FALSE on fail |
443 | 443 | */ |
444 | - public function start_time( $tm_format = NULL ) { |
|
445 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
444 | + public function start_time($tm_format = NULL) { |
|
445 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | /** |
451 | 451 | * @param null $tm_format |
452 | 452 | */ |
453 | - public function e_start_time( $tm_format = NULL ) { |
|
454 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
453 | + public function e_start_time($tm_format = NULL) { |
|
454 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
463 | 463 | * @return mixed string on success, FALSE on fail |
464 | 464 | */ |
465 | - public function end_time( $tm_format = NULL ) { |
|
466 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
465 | + public function end_time($tm_format = NULL) { |
|
466 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | /** |
472 | 472 | * @param null $tm_format |
473 | 473 | */ |
474 | - public function e_end_time( $tm_format = NULL ) { |
|
475 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
474 | + public function e_end_time($tm_format = NULL) { |
|
475 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -487,11 +487,11 @@ discard block |
||
487 | 487 | * @return mixed string on success, FALSE on fail |
488 | 488 | * @throws \EE_Error |
489 | 489 | */ |
490 | - public function time_range( $tm_format = null, $conjunction = ' - ' ) { |
|
491 | - $tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
492 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
493 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
494 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
490 | + public function time_range($tm_format = null, $conjunction = ' - ') { |
|
491 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
492 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
493 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
494 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | * @param string $conjunction |
502 | 502 | * @throws \EE_Error |
503 | 503 | */ |
504 | - public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
505 | - echo $this->time_range( $tm_format, $conjunction ); |
|
504 | + public function e_time_range($tm_format = NULL, $conjunction = ' - ') { |
|
505 | + echo $this->time_range($tm_format, $conjunction); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | |
@@ -518,28 +518,28 @@ discard block |
||
518 | 518 | * @return string |
519 | 519 | * @throws \EE_Error |
520 | 520 | */ |
521 | - public function date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
522 | - $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
|
523 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
524 | - $full_format = $dt_format . ' ' . $tm_format; |
|
521 | + public function date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
522 | + $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt; |
|
523 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
524 | + $full_format = $dt_format.' '.$tm_format; |
|
525 | 525 | |
526 | 526 | //the range output depends on various conditions |
527 | - switch ( true ) { |
|
527 | + switch (true) { |
|
528 | 528 | //start date timestamp and end date timestamp are the same. |
529 | - case ( $this->get_raw( 'DTT_EVT_start' ) === $this->get_raw( 'DTT_EVT_end' ) ) : |
|
530 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ); |
|
529 | + case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')) : |
|
530 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
531 | 531 | break; |
532 | 532 | //start and end date are the same but times are different |
533 | - case ( $this->start_date() === $this->end_date() ) : |
|
534 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
533 | + case ($this->start_date() === $this->end_date()) : |
|
534 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
535 | 535 | . $conjunction |
536 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
536 | + . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
537 | 537 | break; |
538 | 538 | //all other conditions |
539 | 539 | default : |
540 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
540 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
541 | 541 | . $conjunction |
542 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
542 | + . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
543 | 543 | break; |
544 | 544 | } |
545 | 545 | return $output; |
@@ -557,8 +557,8 @@ discard block |
||
557 | 557 | * @return void |
558 | 558 | * @throws \EE_Error |
559 | 559 | */ |
560 | - public function e_date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
561 | - echo $this->date_and_time_range( $dt_format, $tm_format, $conjunction ); |
|
560 | + public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
561 | + echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
571 | 571 | * @return mixed string on success, FALSE on fail |
572 | 572 | */ |
573 | - public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) { |
|
574 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
573 | + public function start_date_and_time($dt_format = NULL, $tm_format = NULL) { |
|
574 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @param null $dt_frmt |
581 | 581 | * @param null $tm_format |
582 | 582 | */ |
583 | - public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) { |
|
584 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
583 | + public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) { |
|
584 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -595,11 +595,11 @@ discard block |
||
595 | 595 | * @param bool $round_up |
596 | 596 | * @return float|int|mixed |
597 | 597 | */ |
598 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
599 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
600 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
598 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
599 | + $start = $this->get_raw('DTT_EVT_start'); |
|
600 | + $end = $this->get_raw('DTT_EVT_end'); |
|
601 | 601 | $length_in_units = $end - $start; |
602 | - switch ( $units ) { |
|
602 | + switch ($units) { |
|
603 | 603 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
604 | 604 | /** @noinspection PhpMissingBreakStatementInspection */ |
605 | 605 | case 'days': |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | $length_in_units /= 60; |
613 | 613 | case 'seconds': |
614 | 614 | default: |
615 | - $length_in_units = ceil( $length_in_units ); |
|
615 | + $length_in_units = ceil($length_in_units); |
|
616 | 616 | } |
617 | - if ( $round_up ) { |
|
618 | - $length_in_units = max( $length_in_units, 1 ); |
|
617 | + if ($round_up) { |
|
618 | + $length_in_units = max($length_in_units, 1); |
|
619 | 619 | } |
620 | 620 | return $length_in_units; |
621 | 621 | } |
@@ -629,8 +629,8 @@ discard block |
||
629 | 629 | * @param bool | string $tm_format - string representation of time format defaults to 'g:i a' |
630 | 630 | * @return mixed string on success, FALSE on fail |
631 | 631 | */ |
632 | - public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
633 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
632 | + public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
633 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | |
@@ -639,8 +639,8 @@ discard block |
||
639 | 639 | * @param bool $dt_frmt |
640 | 640 | * @param bool $tm_format |
641 | 641 | */ |
642 | - public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
643 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
642 | + public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
643 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | * @return int |
652 | 652 | */ |
653 | 653 | public function start() { |
654 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
654 | + return $this->get_raw('DTT_EVT_start'); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @return int |
663 | 663 | */ |
664 | 664 | public function end() { |
665 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
665 | + return $this->get_raw('DTT_EVT_end'); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | * @return mixed int on success, FALSE on fail |
674 | 674 | */ |
675 | 675 | public function reg_limit() { |
676 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
676 | + return $this->get_raw('DTT_reg_limit'); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | |
@@ -701,15 +701,15 @@ discard block |
||
701 | 701 | * the spaces remaining for this particular datetime, hence the flag. |
702 | 702 | * @return int |
703 | 703 | */ |
704 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
704 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
705 | 705 | // tickets remaining available for purchase |
706 | 706 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
707 | 707 | $dtt_remaining = $this->reg_limit() - $this->sold(); |
708 | - if ( ! $consider_tickets ) { |
|
708 | + if ( ! $consider_tickets) { |
|
709 | 709 | return $dtt_remaining; |
710 | 710 | } |
711 | 711 | $tickets_remaining = $this->tickets_remaining(); |
712 | - return min( $dtt_remaining, $tickets_remaining ); |
|
712 | + return min($dtt_remaining, $tickets_remaining); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | * @param array $query_params like EEM_Base::get_all's |
721 | 721 | * @return int |
722 | 722 | */ |
723 | - public function tickets_remaining( $query_params = array() ) { |
|
723 | + public function tickets_remaining($query_params = array()) { |
|
724 | 724 | $sum = 0; |
725 | - $tickets = $this->tickets( $query_params ); |
|
726 | - if ( ! empty( $tickets ) ) { |
|
727 | - foreach ( $tickets as $ticket ) { |
|
728 | - if ( $ticket instanceof EE_Ticket ) { |
|
725 | + $tickets = $this->tickets($query_params); |
|
726 | + if ( ! empty($tickets)) { |
|
727 | + foreach ($tickets as $ticket) { |
|
728 | + if ($ticket instanceof EE_Ticket) { |
|
729 | 729 | // get the actual amount of tickets that can be sold |
730 | - $qty = $ticket->qty( 'saleable' ); |
|
731 | - if ( $qty === EE_INF ) { |
|
730 | + $qty = $ticket->qty('saleable'); |
|
731 | + if ($qty === EE_INF) { |
|
732 | 732 | return EE_INF; |
733 | 733 | } |
734 | 734 | // no negative ticket quantities plz |
735 | - if ( $qty > 0 ) { |
|
735 | + if ($qty > 0) { |
|
736 | 736 | $sum += $qty; |
737 | 737 | } |
738 | 738 | } |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | * @param array $query_params like EEM_Base::get_all's |
750 | 750 | * @return int |
751 | 751 | */ |
752 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
753 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
752 | + public function sum_tickets_initially_available($query_params = array()) { |
|
753 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | * @return int |
763 | 763 | */ |
764 | 764 | public function total_tickets_available_at_this_datetime() { |
765 | - return $this->spaces_remaining( true ); |
|
765 | + return $this->spaces_remaining(true); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | * @return boolean |
774 | 774 | */ |
775 | 775 | public function is_upcoming() { |
776 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
776 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * @return boolean |
784 | 784 | */ |
785 | 785 | public function is_active() { |
786 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
786 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | * @return boolean |
794 | 794 | */ |
795 | 795 | public function is_expired() { |
796 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
796 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | |
@@ -804,16 +804,16 @@ discard block |
||
804 | 804 | */ |
805 | 805 | public function get_active_status() { |
806 | 806 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
807 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
807 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
808 | 808 | return EE_Datetime::sold_out; |
809 | 809 | } |
810 | - if ( $this->is_expired() ) { |
|
810 | + if ($this->is_expired()) { |
|
811 | 811 | return EE_Datetime::expired; |
812 | 812 | } |
813 | - if ( $this->is_upcoming() ) { |
|
813 | + if ($this->is_upcoming()) { |
|
814 | 814 | return EE_Datetime::upcoming; |
815 | 815 | } |
816 | - if ( $this->is_active() ) { |
|
816 | + if ($this->is_active()) { |
|
817 | 817 | return EE_Datetime::active; |
818 | 818 | } |
819 | 819 | return NULL; |
@@ -827,24 +827,24 @@ discard block |
||
827 | 827 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
828 | 828 | * @return string |
829 | 829 | */ |
830 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
831 | - if ( $use_dtt_name ) { |
|
830 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
831 | + if ($use_dtt_name) { |
|
832 | 832 | $dtt_name = $this->name(); |
833 | - if ( !empty( $dtt_name ) ) { |
|
833 | + if ( ! empty($dtt_name)) { |
|
834 | 834 | return $dtt_name; |
835 | 835 | } |
836 | 836 | } |
837 | 837 | //first condition is to see if the months are different |
838 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
839 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
838 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
839 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
840 | 840 | //next condition is if its the same month but different day |
841 | 841 | } |
842 | 842 | else { |
843 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
844 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
843 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
844 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
845 | 845 | } |
846 | 846 | else { |
847 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
847 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
848 | 848 | } |
849 | 849 | } |
850 | 850 | return $display_date; |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | *@param array $query_params see EEM_Base::get_all() |
859 | 859 | * @return EE_Ticket[] |
860 | 860 | */ |
861 | - public function tickets( $query_params = array() ) { |
|
862 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
861 | + public function tickets($query_params = array()) { |
|
862 | + return $this->get_many_related('Ticket', $query_params); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | |
@@ -869,21 +869,21 @@ discard block |
||
869 | 869 | * @param array $query_params like EEM_Base::get_all's |
870 | 870 | * @return EE_Ticket[] |
871 | 871 | */ |
872 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
872 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
873 | 873 | // first check if datetime is valid |
874 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
874 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
875 | 875 | return array(); |
876 | 876 | } |
877 | - if ( empty( $query_params ) ) { |
|
877 | + if (empty($query_params)) { |
|
878 | 878 | $query_params = array( |
879 | 879 | array( |
880 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
881 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
880 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
881 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
882 | 882 | 'TKT_deleted' => false |
883 | 883 | ) |
884 | 884 | ); |
885 | 885 | } |
886 | - return $this->tickets( $query_params ); |
|
886 | + return $this->tickets($query_params); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | * @return EE_Event |
894 | 894 | */ |
895 | 895 | public function event() { |
896 | - return $this->get_first_related( 'Event' ); |
|
896 | + return $this->get_first_related('Event'); |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | |
@@ -905,13 +905,13 @@ discard block |
||
905 | 905 | */ |
906 | 906 | public function update_sold() { |
907 | 907 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
908 | - array( array( |
|
908 | + array(array( |
|
909 | 909 | 'STS_ID' => EEM_Registration::status_id_approved, |
910 | 910 | 'REG_deleted' => 0, |
911 | 911 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
912 | - ) ) |
|
912 | + )) |
|
913 | 913 | ); |
914 | - $this->set( 'DTT_sold', $count_regs_for_this_datetime ); |
|
914 | + $this->set('DTT_sold', $count_regs_for_this_datetime); |
|
915 | 915 | $this->save(); |
916 | 916 | return $count_regs_for_this_datetime; |
917 | 917 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function instance() { |
42 | 42 | // check if class object is instantiated |
43 | - if ( ! self::$_instance instanceof EE_Admin ) { |
|
43 | + if ( ! self::$_instance instanceof EE_Admin) { |
|
44 | 44 | self::$_instance = new self(); |
45 | 45 | } |
46 | 46 | return self::$_instance; |
@@ -57,30 +57,30 @@ discard block |
||
57 | 57 | // define global EE_Admin constants |
58 | 58 | $this->_define_all_constants(); |
59 | 59 | // set autoloaders for our admin page classes based on included path information |
60 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN ); |
|
60 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
61 | 61 | // admin hooks |
62 | - add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 ); |
|
62 | + add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); |
|
63 | 63 | // load EE_Request_Handler early |
64 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' )); |
|
65 | - add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' )); |
|
64 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); |
|
65 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
66 | 66 | // post shortcode tracking |
67 | 67 | add_action( |
68 | 68 | 'AHEE__EE_System__initialize_last', |
69 | - array( 'EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin' ) |
|
69 | + array('EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin') |
|
70 | 70 | ); |
71 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 ); |
|
72 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 ); |
|
73 | - add_action( 'admin_init', array( $this, 'admin_init' ), 100 ); |
|
74 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 ); |
|
75 | - add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
76 | - add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 ); |
|
77 | - add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 ); |
|
78 | - add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' )); |
|
71 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); |
|
72 | + add_action('wp_loaded', array($this, 'wp_loaded'), 100); |
|
73 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
74 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); |
|
75 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
76 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
77 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
78 | + add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); |
|
79 | 79 | |
80 | 80 | //reset Environment config (we only do this on admin page loads); |
81 | 81 | EE_Registry::instance()->CFG->environment->recheck_values(); |
82 | 82 | |
83 | - do_action( 'AHEE__EE_Admin__loaded' ); |
|
83 | + do_action('AHEE__EE_Admin__loaded'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | private function _define_all_constants() { |
98 | - define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' ); |
|
99 | - define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' ); |
|
100 | - define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS ); |
|
101 | - define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' ); |
|
102 | - define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' )); |
|
98 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
99 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
100 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS); |
|
101 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
102 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | * @param string $plugin |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function filter_plugin_actions( $links, $plugin ) { |
|
115 | + public function filter_plugin_actions($links, $plugin) { |
|
116 | 116 | // set $main_file in stone |
117 | 117 | static $main_file; |
118 | 118 | // if $main_file is not set yet |
119 | - if ( ! $main_file ) { |
|
120 | - $main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE ); |
|
119 | + if ( ! $main_file) { |
|
120 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
121 | 121 | } |
122 | - if ( $plugin === $main_file ) { |
|
122 | + if ($plugin === $main_file) { |
|
123 | 123 | // compare current plugin to this one |
124 | - if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
125 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>'; |
|
126 | - array_unshift( $links, $maintenance_link ); |
|
124 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
125 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode. Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>'; |
|
126 | + array_unshift($links, $maintenance_link); |
|
127 | 127 | } else { |
128 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>'; |
|
129 | - $events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>'; |
|
128 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>'; |
|
129 | + $events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>'; |
|
130 | 130 | // add before other links |
131 | - array_unshift( $links, $org_settings_link, $events_link ); |
|
131 | + array_unshift($links, $org_settings_link, $events_link); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | return $links; |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return void |
144 | 144 | */ |
145 | 145 | public function get_request() { |
146 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
147 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
146 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
147 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | * @param array $admin_page_folder_names |
157 | 157 | * @return array |
158 | 158 | */ |
159 | - public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){ |
|
159 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) { |
|
160 | 160 | return array( |
161 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS, |
|
162 | - 'about' => EE_ADMIN_PAGES . 'about' . DS, |
|
163 | - 'support' => EE_ADMIN_PAGES . 'support' . DS |
|
161 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS, |
|
162 | + 'about' => EE_ADMIN_PAGES.'about'.DS, |
|
163 | + 'support' => EE_ADMIN_PAGES.'support'.DS |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
@@ -174,31 +174,31 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function init() { |
176 | 176 | //only enable most of the EE_Admin IF we're not in full maintenance mode |
177 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
177 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
178 | 178 | //ok so we want to enable the entire admin |
179 | - add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' )); |
|
180 | - add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
181 | - add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 ); |
|
179 | + add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback')); |
|
180 | + add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
181 | + add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9); |
|
182 | 182 | //at a glance dashboard widget |
183 | - add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 ); |
|
183 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
184 | 184 | //filter for get_edit_post_link used on comments for custom post types |
185 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 ); |
|
185 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
186 | 186 | } |
187 | 187 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
188 | - if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) { |
|
188 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
189 | 189 | try { |
190 | 190 | //this loads the controller for the admin pages which will setup routing etc |
191 | - EE_Registry::instance()->load_core( 'Admin_Page_Loader' ); |
|
192 | - } catch ( EE_Error $e ) { |
|
191 | + EE_Registry::instance()->load_core('Admin_Page_Loader'); |
|
192 | + } catch (EE_Error $e) { |
|
193 | 193 | $e->get_error(); |
194 | 194 | } |
195 | 195 | } |
196 | - add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 ); |
|
196 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
197 | 197 | //make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
198 | - add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 ); |
|
199 | - add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 ); |
|
198 | + add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); |
|
199 | + add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); |
|
200 | 200 | //exclude EE critical pages from all nav menus and wp_list_pages |
201 | - add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 ); |
|
201 | + add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | * @param object $post_type WP post type object |
212 | 212 | * @return object WP post type object |
213 | 213 | */ |
214 | - public function remove_pages_from_nav_menu( $post_type ) { |
|
214 | + public function remove_pages_from_nav_menu($post_type) { |
|
215 | 215 | //if this isn't the "pages" post type let's get out |
216 | - if ( $post_type->name !== 'page' ) { |
|
216 | + if ($post_type->name !== 'page') { |
|
217 | 217 | return $post_type; |
218 | 218 | } |
219 | 219 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
@@ -233,28 +233,28 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function enable_hidden_ee_nav_menu_metaboxes() { |
235 | 235 | global $wp_meta_boxes, $pagenow; |
236 | - if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) { |
|
236 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | $user = wp_get_current_user(); |
240 | 240 | //has this been done yet? |
241 | - if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) { |
|
241 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
245 | - $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID ); |
|
246 | - $initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) ); |
|
245 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
246 | + $initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page')); |
|
247 | 247 | |
248 | - if ( is_array( $hidden_meta_boxes ) ) { |
|
249 | - foreach ( $hidden_meta_boxes as $key => $meta_box_id ) { |
|
250 | - if ( in_array( $meta_box_id, $initial_meta_boxes ) ) { |
|
251 | - unset( $hidden_meta_boxes[ $key ] ); |
|
248 | + if (is_array($hidden_meta_boxes)) { |
|
249 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
250 | + if (in_array($meta_box_id, $initial_meta_boxes)) { |
|
251 | + unset($hidden_meta_boxes[$key]); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
257 | - update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true ); |
|
256 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
257 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return void |
274 | 274 | */ |
275 | 275 | public function register_custom_nav_menu_boxes() { |
276 | - add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' ); |
|
276 | + add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return string the (maybe) modified link |
291 | 291 | */ |
292 | - public function modify_edit_post_link( $link, $id ) { |
|
293 | - if ( ! $post = get_post( $id ) ){ |
|
292 | + public function modify_edit_post_link($link, $id) { |
|
293 | + if ( ! $post = get_post($id)) { |
|
294 | 294 | return $link; |
295 | 295 | } |
296 | - if ( $post->post_type === 'espresso_attendees' ) { |
|
296 | + if ($post->post_type === 'espresso_attendees') { |
|
297 | 297 | $query_args = array( |
298 | 298 | 'action' => 'edit_attendee', |
299 | 299 | 'post' => $id |
300 | 300 | ); |
301 | - return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') ); |
|
301 | + return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations')); |
|
302 | 302 | } |
303 | 303 | return $link; |
304 | 304 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | global $nav_menu_selected_id; |
311 | 311 | |
312 | 312 | $db_fields = false; |
313 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
313 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
314 | 314 | $current_tab = 'event-archives'; |
315 | 315 | |
316 | 316 | /*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
@@ -329,9 +329,9 @@ discard block |
||
329 | 329 | ?> |
330 | 330 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
331 | 331 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
332 | - <li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
333 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));} ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
334 | - <?php _e( 'Event Archive Pages', 'event_espresso' ); ?> |
|
332 | + <li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
333 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
334 | + <?php _e('Event Archive Pages', 'event_espresso'); ?> |
|
335 | 335 | </a> |
336 | 336 | </li> |
337 | 337 | <?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs. |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | <?php */ ?> |
350 | 350 | |
351 | 351 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
352 | - echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
352 | + echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
353 | 353 | ?>"> |
354 | 354 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
355 | 355 | <?php |
356 | 356 | $pages = $this->_get_extra_nav_menu_pages_items(); |
357 | 357 | $args['walker'] = $walker; |
358 | - echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args ); |
|
358 | + echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args); |
|
359 | 359 | ?> |
360 | 360 | </ul> |
361 | 361 | </div><!-- /.tabs-panel --> |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | <p class="button-controls"> |
364 | 364 | <span class="list-controls"> |
365 | 365 | <a href="<?php |
366 | - echo esc_url( add_query_arg( |
|
366 | + echo esc_url(add_query_arg( |
|
367 | 367 | array( |
368 | 368 | 'extra-nav-menu-pages-tab' => 'event-archives', |
369 | 369 | 'selectall' => 1, |
370 | 370 | ), |
371 | - remove_query_arg( $removed_args ) |
|
371 | + remove_query_arg($removed_args) |
|
372 | 372 | )); |
373 | 373 | ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a> |
374 | 374 | </span> |
375 | 375 | |
376 | 376 | <span class="add-to-menu"> |
377 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" /> |
|
377 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" /> |
|
378 | 378 | <span class="spinner"></span> |
379 | 379 | </span> |
380 | 380 | </p> |
@@ -395,10 +395,10 @@ discard block |
||
395 | 395 | private function _get_extra_nav_menu_pages_items() { |
396 | 396 | $menuitems[] = array( |
397 | 397 | 'title' => __('Event List', 'event_espresso'), |
398 | - 'url' => get_post_type_archive_link( 'espresso_events' ), |
|
398 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
399 | 399 | 'description' => __('Archive page for all events.', 'event_espresso') |
400 | 400 | ); |
401 | - return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems ); |
|
401 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @param $menu_item_values |
411 | 411 | * @return stdClass |
412 | 412 | */ |
413 | - private function _setup_extra_nav_menu_pages_items( $menu_item_values ) { |
|
413 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) { |
|
414 | 414 | $menu_item = new stdClass(); |
415 | 415 | $keys = array( |
416 | 416 | 'ID' => 0, |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | 'xfn' => '' |
431 | 431 | ); |
432 | 432 | |
433 | - foreach ( $keys as $key => $value) { |
|
434 | - $menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value; |
|
433 | + foreach ($keys as $key => $value) { |
|
434 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
435 | 435 | } |
436 | 436 | return $menu_item; |
437 | 437 | } |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | * - check if doing post processing of one of EE CPTs |
471 | 471 | * - instantiate the corresponding EE CPT model for the post_type being processed. |
472 | 472 | */ |
473 | - if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) { |
|
474 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
475 | - EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] ); |
|
473 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
474 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
475 | + EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * 'options-reading.php' core WordPress admin settings page. This is for user-proofing. |
482 | 482 | */ |
483 | 483 | global $pagenow; |
484 | - if ( $pagenow === 'options-reading.php' ) { |
|
485 | - add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) ); |
|
484 | + if ($pagenow === 'options-reading.php') { |
|
485 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | } |
@@ -494,25 +494,25 @@ discard block |
||
494 | 494 | * @param string $output Current output. |
495 | 495 | * @return string |
496 | 496 | */ |
497 | - public function modify_dropdown_pages( $output ) { |
|
497 | + public function modify_dropdown_pages($output) { |
|
498 | 498 | //get critical pages |
499 | 499 | $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
500 | 500 | |
501 | 501 | //split current output by line break for easier parsing. |
502 | - $split_output = explode( "\n", $output ); |
|
502 | + $split_output = explode("\n", $output); |
|
503 | 503 | |
504 | 504 | //loop through to remove any critical pages from the array. |
505 | - foreach ( $critical_pages as $page_id ) { |
|
506 | - $needle = 'value="' . $page_id . '"'; |
|
507 | - foreach( $split_output as $key => $haystack ) { |
|
508 | - if( strpos( $haystack, $needle ) !== false ) { |
|
509 | - unset( $split_output[$key] ); |
|
505 | + foreach ($critical_pages as $page_id) { |
|
506 | + $needle = 'value="'.$page_id.'"'; |
|
507 | + foreach ($split_output as $key => $haystack) { |
|
508 | + if (strpos($haystack, $needle) !== false) { |
|
509 | + unset($split_output[$key]); |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | 514 | //replace output with the new contents |
515 | - return implode( "\n", $split_output ); |
|
515 | + return implode("\n", $split_output); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -526,36 +526,36 @@ discard block |
||
526 | 526 | public function enqueue_admin_scripts() { |
527 | 527 | // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js. |
528 | 528 | // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script calls. |
529 | - wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
529 | + wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
530 | 530 | // register cookie script for future dependencies |
531 | - wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE ); |
|
531 | + wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE); |
|
532 | 532 | // jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
533 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
533 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
534 | 534 | // register jQuery Validate |
535 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
535 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE); |
|
536 | 536 | } |
537 | 537 | //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' ); |
538 | - if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) { |
|
538 | + if (apply_filters('FHEE_load_joyride', FALSE)) { |
|
539 | 539 | //joyride style |
540 | - wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); |
|
541 | - wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION ); |
|
542 | - wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE ); |
|
540 | + wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1'); |
|
541 | + wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION); |
|
542 | + wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE); |
|
543 | 543 | //joyride JS |
544 | - wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE ); |
|
544 | + wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE); |
|
545 | 545 | // wanna go for a joyride? |
546 | 546 | wp_enqueue_style('ee-joyride-css'); |
547 | 547 | wp_enqueue_script('jquery-joyride'); |
548 | 548 | } |
549 | 549 | //qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' ); |
550 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
550 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
551 | 551 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
552 | 552 | } |
553 | 553 | //accounting.js library |
554 | 554 | // @link http://josscrowcroft.github.io/accounting.js/ |
555 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
556 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
557 | - wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE ); |
|
558 | - wp_enqueue_script( 'ee-accounting' ); |
|
555 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
556 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
557 | + wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE); |
|
558 | + wp_enqueue_script('ee-accounting'); |
|
559 | 559 | // array of settings to get converted to JSON array via wp_localize_script |
560 | 560 | $currency_config = array( |
561 | 561 | 'currency' => array( |
@@ -602,11 +602,11 @@ discard block |
||
602 | 602 | public function get_persistent_admin_notices() { |
603 | 603 | // http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30 |
604 | 604 | $args = array( |
605 | - 'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '', |
|
606 | - 'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '', |
|
605 | + 'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '', |
|
606 | + 'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '', |
|
607 | 607 | ); |
608 | - $return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL ); |
|
609 | - echo EE_Error::get_persistent_admin_notices( $return_url ); |
|
608 | + $return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL); |
|
609 | + echo EE_Error::get_persistent_admin_notices($return_url); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -627,26 +627,26 @@ discard block |
||
627 | 627 | * @param $elements |
628 | 628 | * @return array |
629 | 629 | */ |
630 | - public function dashboard_glance_items( $elements ) { |
|
630 | + public function dashboard_glance_items($elements) { |
|
631 | 631 | $events = EEM_Event::instance()->count(); |
632 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') ); |
|
633 | - $items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) ); |
|
632 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php')); |
|
633 | + $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events)); |
|
634 | 634 | $items['events']['title'] = __('Click to view all Events', 'event_espresso'); |
635 | 635 | $registrations = EEM_Registration::instance()->count( |
636 | 636 | array( |
637 | 637 | array( |
638 | - 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) |
|
638 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete) |
|
639 | 639 | ) |
640 | 640 | ) |
641 | 641 | ); |
642 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') ); |
|
643 | - $items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) ); |
|
642 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php')); |
|
643 | + $items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations)); |
|
644 | 644 | $items['registrations']['title'] = __('Click to view all registrations', 'event_espresso'); |
645 | 645 | |
646 | - $items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items ); |
|
646 | + $items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
647 | 647 | |
648 | - foreach ( $items as $type => $item_properties ) { |
|
649 | - $elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] ); |
|
648 | + foreach ($items as $type => $item_properties) { |
|
649 | + $elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']); |
|
650 | 650 | } |
651 | 651 | return $elements; |
652 | 652 | } |
@@ -663,31 +663,31 @@ discard block |
||
663 | 663 | * @throws EE_Error |
664 | 664 | * @return string |
665 | 665 | */ |
666 | - public function check_for_invalid_datetime_formats( $value, $option ) { |
|
666 | + public function check_for_invalid_datetime_formats($value, $option) { |
|
667 | 667 | // check for date_format or time_format |
668 | - switch ( $option ) { |
|
668 | + switch ($option) { |
|
669 | 669 | case 'date_format' : |
670 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
670 | + $date_time_format = $value.' '.get_option('time_format'); |
|
671 | 671 | break; |
672 | 672 | case 'time_format' : |
673 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
673 | + $date_time_format = get_option('date_format').' '.$value; |
|
674 | 674 | break; |
675 | 675 | default : |
676 | 676 | $date_time_format = FALSE; |
677 | 677 | } |
678 | 678 | // do we have a date_time format to check ? |
679 | - if ( $date_time_format ) { |
|
680 | - $error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format ); |
|
679 | + if ($date_time_format) { |
|
680 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
681 | 681 | |
682 | - if ( is_array( $error_msg ) ) { |
|
683 | - $msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format ) . '</p><p><ul>'; |
|
682 | + if (is_array($error_msg)) { |
|
683 | + $msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>'; |
|
684 | 684 | |
685 | 685 | |
686 | - foreach ( $error_msg as $error ) { |
|
687 | - $msg .= '<li>' . $error . '</li>'; |
|
686 | + foreach ($error_msg as $error) { |
|
687 | + $msg .= '<li>'.$error.'</li>'; |
|
688 | 688 | } |
689 | 689 | |
690 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
690 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
691 | 691 | |
692 | 692 | // trigger WP settings error |
693 | 693 | add_settings_error( |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | ); |
698 | 698 | |
699 | 699 | // set format to something valid |
700 | - switch ( $option ) { |
|
700 | + switch ($option) { |
|
701 | 701 | case 'date_format' : |
702 | 702 | $value = 'F j, Y'; |
703 | 703 | break; |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | * @param $content |
720 | 720 | * @return string |
721 | 721 | */ |
722 | - public function its_eSpresso( $content ) { |
|
723 | - return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content ); |
|
722 | + public function its_eSpresso($content) { |
|
723 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * @return string |
733 | 733 | */ |
734 | 734 | public function espresso_admin_footer() { |
735 | - return \EEH_Template::powered_by_event_espresso( 'aln-cntr', '', array( 'utm_content' => 'admin_footer' )); |
|
735 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -751,12 +751,12 @@ discard block |
||
751 | 751 | * @param array $config |
752 | 752 | * @return void |
753 | 753 | */ |
754 | - public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) { |
|
755 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' ); |
|
756 | - if ( class_exists( 'EE_Register_Admin_Page' ) ) { |
|
754 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array()) { |
|
755 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3'); |
|
756 | + if (class_exists('EE_Register_Admin_Page')) { |
|
757 | 757 | $config['page_path'] = $page_path; |
758 | 758 | } |
759 | - EE_Register_Admin_Page::register( $page_basename, $config ); |
|
759 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
760 | 760 | |
761 | 761 | } |
762 | 762 | |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | * @param \WP_Post $post |
770 | 770 | * @return void |
771 | 771 | */ |
772 | - public static function parse_post_content_on_save( $post_ID, $post ) { |
|
772 | + public static function parse_post_content_on_save($post_ID, $post) { |
|
773 | 773 | EE_Error::doing_it_wrong( |
774 | 774 | __METHOD__, |
775 | 775 | __( |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | ), |
779 | 779 | '4.8.41' |
780 | 780 | ); |
781 | - EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $post_ID, $post ); |
|
781 | + EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($post_ID, $post); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @param $value |
792 | 792 | * @return void |
793 | 793 | */ |
794 | - public function reset_page_for_posts_on_change( $option, $old_value, $value ) { |
|
794 | + public function reset_page_for_posts_on_change($option, $old_value, $value) { |
|
795 | 795 | EE_Error::doing_it_wrong( |
796 | 796 | __METHOD__, |
797 | 797 | __( |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | ), |
801 | 801 | '4.8.41' |
802 | 802 | ); |
803 | - EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change( $option, $old_value, $value ); |
|
803 | + EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change($option, $old_value, $value); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | public function __construct() { |
44 | 44 | //set properties |
45 | 45 | $this->name = 'html'; |
46 | - $this->description = __( 'This messenger outputs a message to a browser for display.', 'event_espresso' ); |
|
46 | + $this->description = __('This messenger outputs a message to a browser for display.', 'event_espresso'); |
|
47 | 47 | $this->label = array( |
48 | - 'singular' => __( 'html', 'event_espresso' ), |
|
49 | - 'plural' => __( 'html', 'event_espresso' ), |
|
48 | + 'singular' => __('html', 'event_espresso'), |
|
49 | + 'plural' => __('html', 'event_espresso'), |
|
50 | 50 | ); |
51 | 51 | $this->activate_on_install = true; |
52 | 52 | // add the "powered by EE" credit link to the HTML receipt and invoice |
53 | 53 | add_filter( |
54 | 54 | 'FHEE__EE_Html_messenger___send_message__main_body', |
55 | - array( $this, 'add_powered_by_credit_link_to_receipt_and_invoice' ), |
|
55 | + array($this, 'add_powered_by_credit_link_to_receipt_and_invoice'), |
|
56 | 56 | 10, |
57 | 57 | 3 |
58 | 58 | ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @see abstract declaration in EE_messenger for details. |
92 | 92 | */ |
93 | 93 | protected function _set_admin_pages() { |
94 | - $this->admin_registered_pages = array( 'events_edit' => true ); |
|
94 | + $this->admin_registered_pages = array('events_edit' => true); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | protected function _set_validator_config() { |
112 | 112 | $this->_validator_config = array( |
113 | 113 | 'subject' => array( |
114 | - 'shortcodes' => array( 'organization', 'primary_registration_details', 'email', 'transaction' ), |
|
114 | + 'shortcodes' => array('organization', 'primary_registration_details', 'email', 'transaction'), |
|
115 | 115 | ), |
116 | 116 | 'content' => array( |
117 | 117 | 'shortcodes' => array( |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'primary_registration_list', |
138 | 138 | 'event_author', |
139 | 139 | ), |
140 | - 'required' => array( '[EVENT_LIST]' ), |
|
140 | + 'required' => array('[EVENT_LIST]'), |
|
141 | 141 | ), |
142 | 142 | 'ticket_list' => array( |
143 | 143 | 'shortcodes' => array( |
@@ -148,39 +148,39 @@ discard block |
||
148 | 148 | 'line_item_list', |
149 | 149 | 'venue', |
150 | 150 | ), |
151 | - 'required' => array( '[TICKET_LIST]' ), |
|
151 | + 'required' => array('[TICKET_LIST]'), |
|
152 | 152 | ), |
153 | 153 | 'ticket_line_item_no_pms' => array( |
154 | - 'shortcodes' => array( 'line_item', 'ticket' ), |
|
155 | - 'required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
154 | + 'shortcodes' => array('line_item', 'ticket'), |
|
155 | + 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
156 | 156 | ), |
157 | 157 | 'ticket_line_item_pms' => array( |
158 | - 'shortcodes' => array( 'line_item', 'ticket', 'line_item_list' ), |
|
159 | - 'required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
158 | + 'shortcodes' => array('line_item', 'ticket', 'line_item_list'), |
|
159 | + 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
160 | 160 | ), |
161 | 161 | 'price_modifier_line_item_list' => array( |
162 | - 'shortcodes' => array( 'line_item' ), |
|
163 | - 'required' => array( '[PRICE_MODIFIER_LINE_ITEM_LIST]' ), |
|
162 | + 'shortcodes' => array('line_item'), |
|
163 | + 'required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
164 | 164 | ), |
165 | 165 | 'datetime_list' => array( |
166 | - 'shortcodes' => array( 'datetime' ), |
|
167 | - 'required' => array( '[DATETIME_LIST]' ), |
|
166 | + 'shortcodes' => array('datetime'), |
|
167 | + 'required' => array('[DATETIME_LIST]'), |
|
168 | 168 | ), |
169 | 169 | 'attendee_list' => array( |
170 | - 'shortcodes' => array( 'attendee' ), |
|
171 | - 'required' => array( '[ATTENDEE_LIST]' ), |
|
170 | + 'shortcodes' => array('attendee'), |
|
171 | + 'required' => array('[ATTENDEE_LIST]'), |
|
172 | 172 | ), |
173 | 173 | 'tax_line_item_list' => array( |
174 | - 'shortcodes' => array( 'line_item' ), |
|
175 | - 'required' => array( '[TAX_LINE_ITEM_LIST]' ), |
|
174 | + 'shortcodes' => array('line_item'), |
|
175 | + 'required' => array('[TAX_LINE_ITEM_LIST]'), |
|
176 | 176 | ), |
177 | 177 | 'additional_line_item_list' => array( |
178 | - 'shortcodes' => array( 'line_item' ), |
|
179 | - 'required' => array( '[ADDITIONAL_LINE_ITEM_LIST]' ), |
|
178 | + 'shortcodes' => array('line_item'), |
|
179 | + 'required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
180 | 180 | ), |
181 | 181 | 'payment_list' => array( |
182 | - 'shortcodes' => array( 'payment' ), |
|
183 | - 'required' => array( '[PAYMENT_LIST_*]' ), |
|
182 | + 'shortcodes' => array('payment'), |
|
183 | + 'required' => array('[PAYMENT_LIST_*]'), |
|
184 | 184 | ), |
185 | 185 | ); |
186 | 186 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed. |
197 | 197 | * @return void |
198 | 198 | */ |
199 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
200 | - if ( $sending_messenger_name = 'pdf' ) { |
|
201 | - add_filter( 'EE_messenger__get_variation__variation', array( $this, 'add_html_css' ), 10, 8 ); |
|
199 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
200 | + if ($sending_messenger_name = 'pdf') { |
|
201 | + add_filter('EE_messenger__get_variation__variation', array($this, 'add_html_css'), 10, 8); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function enqueue_scripts_styles() { |
249 | 249 | parent::enqueue_scripts_styles(); |
250 | - do_action( 'AHEE__EE_Html_messenger__enqueue_scripts_styles' ); |
|
250 | + do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $this->_template_fields = array( |
276 | 276 | 'subject' => array( |
277 | 277 | 'input' => 'text', |
278 | - 'label' => __( 'Page Title', 'event_espresso' ), |
|
278 | + 'label' => __('Page Title', 'event_espresso'), |
|
279 | 279 | 'type' => 'string', |
280 | 280 | 'required' => true, |
281 | 281 | 'validation' => true, |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | 'content' => array( |
289 | 289 | 'main' => array( |
290 | 290 | 'input' => 'wp_editor', |
291 | - 'label' => __( 'Main Content', 'event_espresso' ), |
|
291 | + 'label' => __('Main Content', 'event_espresso'), |
|
292 | 292 | 'type' => 'string', |
293 | 293 | 'required' => true, |
294 | 294 | 'validation' => true, |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | 'validation' => true, |
304 | 304 | 'format' => '%s', |
305 | 305 | 'rows' => '15', |
306 | - 'shortcodes_required' => array( '[EVENT_LIST]' ), |
|
306 | + 'shortcodes_required' => array('[EVENT_LIST]'), |
|
307 | 307 | ), |
308 | 308 | 'ticket_list' => array( |
309 | 309 | 'input' => 'textarea', |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | 'format' => '%s', |
315 | 315 | 'css_class' => 'large-text', |
316 | 316 | 'rows' => '10', |
317 | - 'shortcodes_required' => array( '[TICKET_LIST]' ), |
|
317 | + 'shortcodes_required' => array('[TICKET_LIST]'), |
|
318 | 318 | ), |
319 | 319 | 'ticket_line_item_no_pms' => array( |
320 | 320 | 'input' => 'textarea', |
321 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
321 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>'.__( |
|
322 | 322 | 'Ticket Line Item List with no Price Modifiers', |
323 | 323 | 'event_espresso' |
324 | 324 | ), |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | 'format' => '%s', |
329 | 329 | 'css_class' => 'large-text', |
330 | 330 | 'rows' => '5', |
331 | - 'shortcodes_required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
331 | + 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
332 | 332 | ), |
333 | 333 | 'ticket_line_item_pms' => array( |
334 | 334 | 'input' => 'textarea', |
335 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
335 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>'.__( |
|
336 | 336 | 'Ticket Line Item List with Price Modifiers', |
337 | 337 | 'event_espresso' |
338 | 338 | ), |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | 'format' => '%s', |
343 | 343 | 'css_class' => 'large-text', |
344 | 344 | 'rows' => '5', |
345 | - 'shortcodes_required' => array( '[TICKET_LINE_ITEM_LIST]' ), |
|
345 | + 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
346 | 346 | ), |
347 | 347 | 'price_modifier_line_item_list' => array( |
348 | 348 | 'input' => 'textarea', |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | 'format' => '%s', |
354 | 354 | 'css_class' => 'large-text', |
355 | 355 | 'rows' => '5', |
356 | - 'shortcodes_required' => array( '[PRICE_MODIFIER_LINE_ITEM_LIST]' ), |
|
356 | + 'shortcodes_required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
357 | 357 | ), |
358 | 358 | 'datetime_list' => array( |
359 | 359 | 'input' => 'textarea', |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | 'format' => '%s', |
365 | 365 | 'css_class' => 'large-text', |
366 | 366 | 'rows' => '5', |
367 | - 'shortcodes_required' => array( '[DATETIME_LIST]' ), |
|
367 | + 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
368 | 368 | ), |
369 | 369 | 'attendee_list' => array( |
370 | 370 | 'input' => 'textarea', |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | 'format' => '%s', |
376 | 376 | 'css_class' => 'large-text', |
377 | 377 | 'rows' => '5', |
378 | - 'shortcodes_required' => array( '[ATTENDEE_LIST]' ), |
|
378 | + 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
379 | 379 | ), |
380 | 380 | 'tax_line_item_list' => array( |
381 | 381 | 'input' => 'textarea', |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | 'format' => '%s', |
387 | 387 | 'css_class' => 'large-text', |
388 | 388 | 'rows' => '5', |
389 | - 'shortcodes_required' => array( '[TAX_LINE_ITEM_LIST]' ), |
|
389 | + 'shortcodes_required' => array('[TAX_LINE_ITEM_LIST]'), |
|
390 | 390 | ), |
391 | 391 | 'additional_line_item_list' => array( |
392 | 392 | 'input' => 'textarea', |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | 'format' => '%s', |
398 | 398 | 'css_class' => 'large-text', |
399 | 399 | 'rows' => '5', |
400 | - 'shortcodes_required' => array( '[ADDITIONAL_LINE_ITEM_LIST]' ), |
|
400 | + 'shortcodes_required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
401 | 401 | ), |
402 | 402 | 'payment_list' => array( |
403 | 403 | 'input' => 'textarea', |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'format' => '%s', |
409 | 409 | 'css_class' => 'large-text', |
410 | 410 | 'rows' => '5', |
411 | - 'shortcodes_required' => array( '[PAYMENT_LIST_*]' ), |
|
411 | + 'shortcodes_required' => array('[PAYMENT_LIST_*]'), |
|
412 | 412 | ), |
413 | 413 | ), |
414 | 414 | ), |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @since 4.5.0 |
423 | 423 | */ |
424 | 424 | protected function _set_default_message_types() { |
425 | - $this->_default_message_types = array( 'receipt', 'invoice' ); |
|
425 | + $this->_default_message_types = array('receipt', 'invoice'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @since 4.5.0 |
433 | 433 | */ |
434 | 434 | protected function _set_valid_message_types() { |
435 | - $this->_valid_message_types = array( 'receipt', 'invoice' ); |
|
435 | + $this->_valid_message_types = array('receipt', 'invoice'); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | */ |
446 | 446 | protected function _send_message() { |
447 | 447 | $this->_template_args = array( |
448 | - 'page_title' => html_entity_decode( stripslashes( $this->_subject ), ENT_QUOTES, "UTF-8" ), |
|
448 | + 'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
449 | 449 | 'base_css' => $this->get_variation( |
450 | 450 | $this->_tmp_pack, |
451 | 451 | $this->_incoming_message_type->name, |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | ), |
484 | 484 | ); |
485 | 485 | $this->_deregister_wp_hooks(); |
486 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) ); |
|
486 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
487 | 487 | echo $this->_get_main_template(); |
488 | 488 | exit(); |
489 | 489 | } |
@@ -499,16 +499,16 @@ discard block |
||
499 | 499 | * @return void |
500 | 500 | */ |
501 | 501 | protected function _deregister_wp_hooks() { |
502 | - remove_all_actions( 'wp_head' ); |
|
503 | - remove_all_actions( 'wp_footer' ); |
|
504 | - remove_all_actions( 'wp_print_footer_scripts' ); |
|
505 | - remove_all_actions( 'wp_enqueue_scripts' ); |
|
502 | + remove_all_actions('wp_head'); |
|
503 | + remove_all_actions('wp_footer'); |
|
504 | + remove_all_actions('wp_print_footer_scripts'); |
|
505 | + remove_all_actions('wp_enqueue_scripts'); |
|
506 | 506 | global $wp_scripts, $wp_styles; |
507 | 507 | $wp_scripts = $wp_styles = array(); |
508 | 508 | //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
509 | - add_action( 'wp_footer', 'wp_print_footer_scripts' ); |
|
510 | - add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' ); |
|
511 | - add_action( 'wp_head', 'wp_enqueue_scripts' ); |
|
509 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
510 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
511 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | |
@@ -520,11 +520,11 @@ discard block |
||
520 | 520 | * @param bool $preview |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - protected function _get_main_template( $preview = false ) { |
|
524 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, 'main' ); |
|
523 | + protected function _get_main_template($preview = false) { |
|
524 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main'); |
|
525 | 525 | //include message type as a template arg |
526 | 526 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
527 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, true ); |
|
527 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -557,15 +557,15 @@ discard block |
||
557 | 557 | EE_message_type $incoming_message_type |
558 | 558 | ) { |
559 | 559 | if ( |
560 | - ( $incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt' ) |
|
561 | - && apply_filters( 'FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true ) |
|
560 | + ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt') |
|
561 | + && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true) |
|
562 | 562 | ) { |
563 | 563 | $content .= \EEH_Template::powered_by_event_espresso( |
564 | 564 | 'aln-cntr', |
565 | 565 | '', |
566 | - array( 'utm_content' => 'messages_system' ) |
|
566 | + array('utm_content' => 'messages_system') |
|
567 | 567 | ) |
568 | - . EEH_HTML::div( EEH_HTML::p(' ') ); |
|
568 | + . EEH_HTML::div(EEH_HTML::p(' ')); |
|
569 | 569 | } |
570 | 570 | return $content; |
571 | 571 | } |
@@ -20,81 +20,81 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Newsletter_Shortcodes extends EE_Shortcodes { |
22 | 22 | |
23 | - protected function _init_props() { |
|
24 | - $this->label = __("Batch Messages Shortcodes", 'event_espresso'); |
|
25 | - $this->description = __('All shortcodes used for the batch message type', 'event_espresso'); |
|
26 | - $this->_shortcodes = array( |
|
27 | - '[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field. Note that when triggering a batch message, whatever is added for the custom message will be inserted where this shortcode is placed.', 'event_espresso') |
|
28 | - ); |
|
29 | - } |
|
23 | + protected function _init_props() { |
|
24 | + $this->label = __("Batch Messages Shortcodes", 'event_espresso'); |
|
25 | + $this->description = __('All shortcodes used for the batch message type', 'event_espresso'); |
|
26 | + $this->_shortcodes = array( |
|
27 | + '[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field. Note that when triggering a batch message, whatever is added for the custom message will be inserted where this shortcode is placed.', 'event_espresso') |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - protected function _parser( $shortcode ) { |
|
34 | - if ( $shortcode == '[NEWSLETTER_CONTENT]' ) { |
|
35 | - $this->_validate_list_requirements(); |
|
36 | - $valid_shortcodes = array('recipient_details', 'organization'); |
|
37 | - $template = $this->_data['template']['newsletter_content']; |
|
38 | - $data = $this->_data; |
|
39 | - return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
40 | - } |
|
41 | - } |
|
33 | + protected function _parser( $shortcode ) { |
|
34 | + if ( $shortcode == '[NEWSLETTER_CONTENT]' ) { |
|
35 | + $this->_validate_list_requirements(); |
|
36 | + $valid_shortcodes = array('recipient_details', 'organization'); |
|
37 | + $template = $this->_data['template']['newsletter_content']; |
|
38 | + $data = $this->_data; |
|
39 | + return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'. |
|
46 | - * |
|
47 | - * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
48 | - * 'FHEE__EE_messenger__get_validator_config' filter. |
|
49 | - * |
|
50 | - * @since 4.3.0 |
|
51 | - * @param array $validator_config current validator configuration array |
|
52 | - * @param EE_messenger $messenger |
|
53 | - * @return array new validator config. |
|
54 | - */ |
|
55 | - public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) { |
|
56 | - if ( $messenger->name !== 'email' ) |
|
57 | - return $validator_config; |
|
44 | + /** |
|
45 | + * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'. |
|
46 | + * |
|
47 | + * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
48 | + * 'FHEE__EE_messenger__get_validator_config' filter. |
|
49 | + * |
|
50 | + * @since 4.3.0 |
|
51 | + * @param array $validator_config current validator configuration array |
|
52 | + * @param EE_messenger $messenger |
|
53 | + * @return array new validator config. |
|
54 | + */ |
|
55 | + public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) { |
|
56 | + if ( $messenger->name !== 'email' ) |
|
57 | + return $validator_config; |
|
58 | 58 | |
59 | - $validator_config['content']['shortcodes'][] = 'newsletter'; |
|
60 | - $validator_config['newsletter_content'] = array( |
|
61 | - 'shortcodes' => array('recipient_details', 'organization'), |
|
62 | - 'required' => array('[NEWSLETTER_CONTENT]') |
|
63 | - ); |
|
64 | - return $validator_config; |
|
65 | - } |
|
59 | + $validator_config['content']['shortcodes'][] = 'newsletter'; |
|
60 | + $validator_config['newsletter_content'] = array( |
|
61 | + 'shortcodes' => array('recipient_details', 'organization'), |
|
62 | + 'required' => array('[NEWSLETTER_CONTENT]') |
|
63 | + ); |
|
64 | + return $validator_config; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Callback set in args for EE_Register_Messages_Shortcode_Library::register for |
|
72 | - * 'msgr_template_fields_callback'. |
|
73 | - * |
|
74 | - * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
75 | - * FHEE__EE_messenger__get_template_fields filter. |
|
76 | - * |
|
77 | - * @since 4.3.0 |
|
78 | - * |
|
79 | - * @param array $template_fields current template fields setup array. |
|
80 | - * @param EE_messenger $messenger |
|
81 | - * @return array new/modified template fields array. |
|
82 | - */ |
|
83 | - public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) { |
|
84 | - if ( $messenger->name !== 'email' ) |
|
85 | - return $template_fields; |
|
70 | + /** |
|
71 | + * Callback set in args for EE_Register_Messages_Shortcode_Library::register for |
|
72 | + * 'msgr_template_fields_callback'. |
|
73 | + * |
|
74 | + * EE_Register_Messages_Shortcode_Library::register registers this callback with the |
|
75 | + * FHEE__EE_messenger__get_template_fields filter. |
|
76 | + * |
|
77 | + * @since 4.3.0 |
|
78 | + * |
|
79 | + * @param array $template_fields current template fields setup array. |
|
80 | + * @param EE_messenger $messenger |
|
81 | + * @return array new/modified template fields array. |
|
82 | + */ |
|
83 | + public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) { |
|
84 | + if ( $messenger->name !== 'email' ) |
|
85 | + return $template_fields; |
|
86 | 86 | |
87 | - $template_fields['extra']['content']['newsletter_content'] = array( |
|
88 | - 'input' => 'wp_editor', |
|
89 | - 'label' => '[NEWSLETTER_CONTENT]', |
|
90 | - 'type' => 'string', |
|
91 | - 'required' => TRUE, |
|
92 | - 'validation' => TRUE, |
|
93 | - 'format' => '%s', |
|
94 | - 'rows' => '15', |
|
95 | - 'shortcodes_required' => array('[NEWSLETTER_CONTENT]') |
|
96 | - ); |
|
97 | - return $template_fields; |
|
98 | - } |
|
87 | + $template_fields['extra']['content']['newsletter_content'] = array( |
|
88 | + 'input' => 'wp_editor', |
|
89 | + 'label' => '[NEWSLETTER_CONTENT]', |
|
90 | + 'type' => 'string', |
|
91 | + 'required' => TRUE, |
|
92 | + 'validation' => TRUE, |
|
93 | + 'format' => '%s', |
|
94 | + 'rows' => '15', |
|
95 | + 'shortcodes_required' => array('[NEWSLETTER_CONTENT]') |
|
96 | + ); |
|
97 | + return $template_fields; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | } //end class EE_Newsletter_Shortcodes |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ); |
64 | 64 | add_action( |
65 | 65 | 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
66 | - array( $this, 'verify_event_edit' ) |
|
66 | + array($this, 'verify_event_edit') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | $this->_admin_page_title = EVENTS_LABEL; |
80 | 80 | $this->_labels = array( |
81 | 81 | 'buttons' => array( |
82 | - 'add' => esc_html__( 'Add New Event', 'event_espresso' ), |
|
83 | - 'edit' => esc_html__( 'Edit Event', 'event_espresso' ), |
|
84 | - 'delete' => esc_html__( 'Delete Event', 'event_espresso' ), |
|
85 | - 'add_category' => esc_html__( 'Add New Category', 'event_espresso' ), |
|
86 | - 'edit_category' => esc_html__( 'Edit Category', 'event_espresso' ), |
|
87 | - 'delete_category' => esc_html__( 'Delete Category', 'event_espresso' ), |
|
82 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
83 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
84 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
85 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
86 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
87 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
88 | 88 | ), |
89 | 89 | 'editor_title' => array( |
90 | - 'espresso_events' => esc_html__( 'Enter event title here', 'event_espresso' ), |
|
90 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
91 | 91 | ), |
92 | 92 | 'publishbox' => array( |
93 | - 'create_new' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
94 | - 'edit' => esc_html__( 'Update Event', 'event_espresso' ), |
|
95 | - 'add_category' => esc_html__( 'Save New Category', 'event_espresso' ), |
|
96 | - 'edit_category' => esc_html__( 'Update Category', 'event_espresso' ), |
|
97 | - 'template_settings' => esc_html__( 'Update Settings', 'event_espresso' ), |
|
93 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
94 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
95 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
96 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
97 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
98 | 98 | ), |
99 | 99 | ); |
100 | 100 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | //load formatter helper |
106 | 106 | //load field generator helper |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
109 | 109 | ? $this->_req_data['EVT_ID'] : 0; |
110 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
110 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
111 | 111 | $this->_page_routes = array( |
112 | 112 | 'default' => array( |
113 | 113 | 'func' => '_events_overview_list_table', |
@@ -130,27 +130,27 @@ discard block |
||
130 | 130 | ), |
131 | 131 | 'trash_event' => array( |
132 | 132 | 'func' => '_trash_or_restore_event', |
133 | - 'args' => array( 'event_status' => 'trash' ), |
|
133 | + 'args' => array('event_status' => 'trash'), |
|
134 | 134 | 'capability' => 'ee_delete_event', |
135 | 135 | 'obj_id' => $evt_id, |
136 | 136 | 'noheader' => true, |
137 | 137 | ), |
138 | 138 | 'trash_events' => array( |
139 | 139 | 'func' => '_trash_or_restore_events', |
140 | - 'args' => array( 'event_status' => 'trash' ), |
|
140 | + 'args' => array('event_status' => 'trash'), |
|
141 | 141 | 'capability' => 'ee_delete_events', |
142 | 142 | 'noheader' => true, |
143 | 143 | ), |
144 | 144 | 'restore_event' => array( |
145 | 145 | 'func' => '_trash_or_restore_event', |
146 | - 'args' => array( 'event_status' => 'draft' ), |
|
146 | + 'args' => array('event_status' => 'draft'), |
|
147 | 147 | 'capability' => 'ee_delete_event', |
148 | 148 | 'obj_id' => $evt_id, |
149 | 149 | 'noheader' => true, |
150 | 150 | ), |
151 | 151 | 'restore_events' => array( |
152 | 152 | 'func' => '_trash_or_restore_events', |
153 | - 'args' => array( 'event_status' => 'draft' ), |
|
153 | + 'args' => array('event_status' => 'draft'), |
|
154 | 154 | 'capability' => 'ee_delete_events', |
155 | 155 | 'noheader' => true, |
156 | 156 | ), |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | 'add_category' => array( |
187 | 187 | 'func' => '_category_details', |
188 | 188 | 'capability' => 'ee_edit_event_category', |
189 | - 'args' => array( 'add' ), |
|
189 | + 'args' => array('add'), |
|
190 | 190 | ), |
191 | 191 | 'edit_category' => array( |
192 | 192 | 'func' => '_category_details', |
193 | 193 | 'capability' => 'ee_edit_event_category', |
194 | - 'args' => array( 'edit' ), |
|
194 | + 'args' => array('edit'), |
|
195 | 195 | ), |
196 | 196 | 'delete_categories' => array( |
197 | 197 | 'func' => '_delete_categories', |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | ), |
206 | 206 | 'insert_category' => array( |
207 | 207 | 'func' => '_insert_or_update_category', |
208 | - 'args' => array( 'new_category' => true ), |
|
208 | + 'args' => array('new_category' => true), |
|
209 | 209 | 'capability' => 'ee_edit_event_category', |
210 | 210 | 'noheader' => true, |
211 | 211 | ), |
212 | 212 | 'update_category' => array( |
213 | 213 | 'func' => '_insert_or_update_category', |
214 | - 'args' => array( 'new_category' => false ), |
|
214 | + 'args' => array('new_category' => false), |
|
215 | 215 | 'capability' => 'ee_edit_event_category', |
216 | 216 | 'noheader' => true, |
217 | 217 | ), |
@@ -228,29 +228,29 @@ discard block |
||
228 | 228 | $this->_page_config = array( |
229 | 229 | 'default' => array( |
230 | 230 | 'nav' => array( |
231 | - 'label' => esc_html__( 'Overview', 'event_espresso' ), |
|
231 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
232 | 232 | 'order' => 10, |
233 | 233 | ), |
234 | 234 | 'list_table' => 'Events_Admin_List_Table', |
235 | 235 | 'help_tabs' => array( |
236 | 236 | 'events_overview_help_tab' => array( |
237 | - 'title' => esc_html__( 'Events Overview', 'event_espresso' ), |
|
237 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
238 | 238 | 'filename' => 'events_overview', |
239 | 239 | ), |
240 | 240 | 'events_overview_table_column_headings_help_tab' => array( |
241 | - 'title' => esc_html__( 'Events Overview Table Column Headings', 'event_espresso' ), |
|
241 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
242 | 242 | 'filename' => 'events_overview_table_column_headings', |
243 | 243 | ), |
244 | 244 | 'events_overview_filters_help_tab' => array( |
245 | - 'title' => esc_html__( 'Events Overview Filters', 'event_espresso' ), |
|
245 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
246 | 246 | 'filename' => 'events_overview_filters', |
247 | 247 | ), |
248 | 248 | 'events_overview_view_help_tab' => array( |
249 | - 'title' => esc_html__( 'Events Overview Views', 'event_espresso' ), |
|
249 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
250 | 250 | 'filename' => 'events_overview_views', |
251 | 251 | ), |
252 | 252 | 'events_overview_other_help_tab' => array( |
253 | - 'title' => esc_html__( 'Events Overview Other', 'event_espresso' ), |
|
253 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
254 | 254 | 'filename' => 'events_overview_other', |
255 | 255 | ), |
256 | 256 | ), |
@@ -265,218 +265,218 @@ discard block |
||
265 | 265 | ), |
266 | 266 | 'create_new' => array( |
267 | 267 | 'nav' => array( |
268 | - 'label' => esc_html__( 'Add Event', 'event_espresso' ), |
|
268 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
269 | 269 | 'order' => 5, |
270 | 270 | 'persistent' => false, |
271 | 271 | ), |
272 | - 'metaboxes' => array( '_register_event_editor_meta_boxes' ), |
|
272 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
273 | 273 | 'help_tabs' => array( |
274 | 274 | 'event_editor_help_tab' => array( |
275 | - 'title' => esc_html__( 'Event Editor', 'event_espresso' ), |
|
275 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
276 | 276 | 'filename' => 'event_editor', |
277 | 277 | ), |
278 | 278 | 'event_editor_title_richtexteditor_help_tab' => array( |
279 | - 'title' => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ), |
|
279 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
280 | 280 | 'filename' => 'event_editor_title_richtexteditor', |
281 | 281 | ), |
282 | 282 | 'event_editor_venue_details_help_tab' => array( |
283 | - 'title' => esc_html__( 'Event Venue Details', 'event_espresso' ), |
|
283 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
284 | 284 | 'filename' => 'event_editor_venue_details', |
285 | 285 | ), |
286 | 286 | 'event_editor_event_datetimes_help_tab' => array( |
287 | - 'title' => esc_html__( 'Event Datetimes', 'event_espresso' ), |
|
287 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
288 | 288 | 'filename' => 'event_editor_event_datetimes', |
289 | 289 | ), |
290 | 290 | 'event_editor_event_tickets_help_tab' => array( |
291 | - 'title' => esc_html__( 'Event Tickets', 'event_espresso' ), |
|
291 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
292 | 292 | 'filename' => 'event_editor_event_tickets', |
293 | 293 | ), |
294 | 294 | 'event_editor_event_registration_options_help_tab' => array( |
295 | - 'title' => esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
295 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
296 | 296 | 'filename' => 'event_editor_event_registration_options', |
297 | 297 | ), |
298 | 298 | 'event_editor_tags_categories_help_tab' => array( |
299 | - 'title' => esc_html__( 'Event Tags & Categories', 'event_espresso' ), |
|
299 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
300 | 300 | 'filename' => 'event_editor_tags_categories', |
301 | 301 | ), |
302 | 302 | 'event_editor_questions_registrants_help_tab' => array( |
303 | - 'title' => esc_html__( 'Questions for Registrants', 'event_espresso' ), |
|
303 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
304 | 304 | 'filename' => 'event_editor_questions_registrants', |
305 | 305 | ), |
306 | 306 | 'event_editor_save_new_event_help_tab' => array( |
307 | - 'title' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
307 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
308 | 308 | 'filename' => 'event_editor_save_new_event', |
309 | 309 | ), |
310 | 310 | 'event_editor_other_help_tab' => array( |
311 | - 'title' => esc_html__( 'Event Other', 'event_espresso' ), |
|
311 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
312 | 312 | 'filename' => 'event_editor_other', |
313 | 313 | ), |
314 | 314 | ), |
315 | 315 | 'help_tour' => array( |
316 | 316 | 'Event_Editor_Help_Tour', |
317 | 317 | ), |
318 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
318 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
319 | 319 | 'require_nonce' => false, |
320 | 320 | ), |
321 | 321 | 'edit' => array( |
322 | 322 | 'nav' => array( |
323 | - 'label' => esc_html__( 'Edit Event', 'event_espresso' ), |
|
323 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
324 | 324 | 'order' => 5, |
325 | 325 | 'persistent' => false, |
326 | - 'url' => isset( $this->_req_data['post'] ) |
|
326 | + 'url' => isset($this->_req_data['post']) |
|
327 | 327 | ? EE_Admin_Page::add_query_args_and_nonce( |
328 | - array( 'post' => $this->_req_data['post'], 'action' => 'edit' ), |
|
328 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
329 | 329 | $this->_current_page_view_url |
330 | 330 | ) |
331 | 331 | : $this->_admin_base_url, |
332 | 332 | ), |
333 | - 'metaboxes' => array( '_register_event_editor_meta_boxes' ), |
|
333 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
334 | 334 | 'help_tabs' => array( |
335 | 335 | 'event_editor_help_tab' => array( |
336 | - 'title' => esc_html__( 'Event Editor', 'event_espresso' ), |
|
336 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
337 | 337 | 'filename' => 'event_editor', |
338 | 338 | ), |
339 | 339 | 'event_editor_title_richtexteditor_help_tab' => array( |
340 | - 'title' => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ), |
|
340 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
341 | 341 | 'filename' => 'event_editor_title_richtexteditor', |
342 | 342 | ), |
343 | 343 | 'event_editor_venue_details_help_tab' => array( |
344 | - 'title' => esc_html__( 'Event Venue Details', 'event_espresso' ), |
|
344 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
345 | 345 | 'filename' => 'event_editor_venue_details', |
346 | 346 | ), |
347 | 347 | 'event_editor_event_datetimes_help_tab' => array( |
348 | - 'title' => esc_html__( 'Event Datetimes', 'event_espresso' ), |
|
348 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
349 | 349 | 'filename' => 'event_editor_event_datetimes', |
350 | 350 | ), |
351 | 351 | 'event_editor_event_tickets_help_tab' => array( |
352 | - 'title' => esc_html__( 'Event Tickets', 'event_espresso' ), |
|
352 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
353 | 353 | 'filename' => 'event_editor_event_tickets', |
354 | 354 | ), |
355 | 355 | 'event_editor_event_registration_options_help_tab' => array( |
356 | - 'title' => esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
356 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
357 | 357 | 'filename' => 'event_editor_event_registration_options', |
358 | 358 | ), |
359 | 359 | 'event_editor_tags_categories_help_tab' => array( |
360 | - 'title' => esc_html__( 'Event Tags & Categories', 'event_espresso' ), |
|
360 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
361 | 361 | 'filename' => 'event_editor_tags_categories', |
362 | 362 | ), |
363 | 363 | 'event_editor_questions_registrants_help_tab' => array( |
364 | - 'title' => esc_html__( 'Questions for Registrants', 'event_espresso' ), |
|
364 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
365 | 365 | 'filename' => 'event_editor_questions_registrants', |
366 | 366 | ), |
367 | 367 | 'event_editor_save_new_event_help_tab' => array( |
368 | - 'title' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
368 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
369 | 369 | 'filename' => 'event_editor_save_new_event', |
370 | 370 | ), |
371 | 371 | 'event_editor_other_help_tab' => array( |
372 | - 'title' => esc_html__( 'Event Other', 'event_espresso' ), |
|
372 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
373 | 373 | 'filename' => 'event_editor_other', |
374 | 374 | ), |
375 | 375 | ), |
376 | 376 | /*'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ),*/ |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => false, |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
383 | 383 | 'nav' => array( |
384 | - 'label' => esc_html__( 'Default Settings', 'event_espresso' ), |
|
384 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
385 | 385 | 'order' => 40, |
386 | 386 | ), |
387 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
387 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
388 | 388 | 'labels' => array( |
389 | - 'publishbox' => esc_html__( 'Update Settings', 'event_espresso' ), |
|
389 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
390 | 390 | ), |
391 | 391 | 'help_tabs' => array( |
392 | 392 | 'default_settings_help_tab' => array( |
393 | - 'title' => esc_html__( 'Default Event Settings', 'event_espresso' ), |
|
393 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
394 | 394 | 'filename' => 'events_default_settings', |
395 | 395 | ), |
396 | 396 | 'default_settings_status_help_tab' => array( |
397 | - 'title' => esc_html__( 'Default Registration Status', 'event_espresso' ), |
|
397 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
398 | 398 | 'filename' => 'events_default_settings_status', |
399 | 399 | ), |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour' ), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => false, |
403 | 403 | ), |
404 | 404 | //template settings |
405 | 405 | 'template_settings' => array( |
406 | 406 | 'nav' => array( |
407 | - 'label' => esc_html__( 'Templates', 'event_espresso' ), |
|
407 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
408 | 408 | 'order' => 30, |
409 | 409 | ), |
410 | 410 | 'metaboxes' => $this->_default_espresso_metaboxes, |
411 | 411 | 'help_tabs' => array( |
412 | 412 | 'general_settings_templates_help_tab' => array( |
413 | - 'title' => esc_html__( 'Templates', 'event_espresso' ), |
|
413 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
414 | 414 | 'filename' => 'general_settings_templates', |
415 | 415 | ), |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => false, |
419 | 419 | ), |
420 | 420 | //event category stuff |
421 | 421 | 'add_category' => array( |
422 | 422 | 'nav' => array( |
423 | - 'label' => esc_html__( 'Add Category', 'event_espresso' ), |
|
423 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
424 | 424 | 'order' => 15, |
425 | 425 | 'persistent' => false, |
426 | 426 | ), |
427 | 427 | 'help_tabs' => array( |
428 | 428 | 'add_category_help_tab' => array( |
429 | - 'title' => esc_html__( 'Add New Event Category', 'event_espresso' ), |
|
429 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
430 | 430 | 'filename' => 'events_add_category', |
431 | 431 | ), |
432 | 432 | ), |
433 | - 'help_tour' => array( 'Event_Add_Category_Help_Tour' ), |
|
434 | - 'metaboxes' => array( '_publish_post_box' ), |
|
433 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
434 | + 'metaboxes' => array('_publish_post_box'), |
|
435 | 435 | 'require_nonce' => false, |
436 | 436 | ), |
437 | 437 | 'edit_category' => array( |
438 | 438 | 'nav' => array( |
439 | - 'label' => esc_html__( 'Edit Category', 'event_espresso' ), |
|
439 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
440 | 440 | 'order' => 15, |
441 | 441 | 'persistent' => false, |
442 | - 'url' => isset( $this->_req_data['EVT_CAT_ID'] ) |
|
442 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
443 | 443 | ? add_query_arg( |
444 | - array( 'EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), |
|
444 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
445 | 445 | $this->_current_page_view_url |
446 | 446 | ) |
447 | 447 | : $this->_admin_base_url, |
448 | 448 | ), |
449 | 449 | 'help_tabs' => array( |
450 | 450 | 'edit_category_help_tab' => array( |
451 | - 'title' => esc_html__( 'Edit Event Category', 'event_espresso' ), |
|
451 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
452 | 452 | 'filename' => 'events_edit_category', |
453 | 453 | ), |
454 | 454 | ), |
455 | 455 | /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
456 | - 'metaboxes' => array( '_publish_post_box' ), |
|
456 | + 'metaboxes' => array('_publish_post_box'), |
|
457 | 457 | 'require_nonce' => false, |
458 | 458 | ), |
459 | 459 | 'category_list' => array( |
460 | 460 | 'nav' => array( |
461 | - 'label' => esc_html__( 'Categories', 'event_espresso' ), |
|
461 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
462 | 462 | 'order' => 20, |
463 | 463 | ), |
464 | 464 | 'list_table' => 'Event_Categories_Admin_List_Table', |
465 | 465 | 'help_tabs' => array( |
466 | 466 | 'events_categories_help_tab' => array( |
467 | - 'title' => esc_html__( 'Event Categories', 'event_espresso' ), |
|
467 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
468 | 468 | 'filename' => 'events_categories', |
469 | 469 | ), |
470 | 470 | 'events_categories_table_column_headings_help_tab' => array( |
471 | - 'title' => esc_html__( 'Event Categories Table Column Headings', 'event_espresso' ), |
|
471 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
472 | 472 | 'filename' => 'events_categories_table_column_headings', |
473 | 473 | ), |
474 | 474 | 'events_categories_view_help_tab' => array( |
475 | - 'title' => esc_html__( 'Event Categories Views', 'event_espresso' ), |
|
475 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
476 | 476 | 'filename' => 'events_categories_views', |
477 | 477 | ), |
478 | 478 | 'events_categories_other_help_tab' => array( |
479 | - 'title' => esc_html__( 'Event Categories Other', 'event_espresso' ), |
|
479 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
480 | 480 | 'filename' => 'events_categories_other', |
481 | 481 | ), |
482 | 482 | ), |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | protected function _add_screen_options_category_list() { |
507 | 507 | $page_title = $this->_admin_page_title; |
508 | - $this->_admin_page_title = esc_html__( 'Categories', 'event_espresso' ); |
|
508 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
509 | 509 | $this->_per_page_screen_option(); |
510 | 510 | $this->_admin_page_title = $page_title; |
511 | 511 | } |
@@ -521,20 +521,20 @@ discard block |
||
521 | 521 | public function load_scripts_styles() { |
522 | 522 | wp_register_style( |
523 | 523 | 'events-admin-css', |
524 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
524 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
525 | 525 | array(), |
526 | 526 | EVENT_ESPRESSO_VERSION |
527 | 527 | ); |
528 | - wp_register_style( 'ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
529 | - wp_enqueue_style( 'events-admin-css' ); |
|
530 | - wp_enqueue_style( 'ee-cat-admin' ); |
|
528 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
529 | + wp_enqueue_style('events-admin-css'); |
|
530 | + wp_enqueue_style('ee-cat-admin'); |
|
531 | 531 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
532 | 532 | //registers for all views |
533 | 533 | //scripts |
534 | 534 | wp_register_script( |
535 | 535 | 'event_editor_js', |
536 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
537 | - array( 'ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon' ), |
|
536 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
537 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
538 | 538 | EVENT_ESPRESSO_VERSION, |
539 | 539 | true |
540 | 540 | ); |
@@ -560,22 +560,22 @@ discard block |
||
560 | 560 | */ |
561 | 561 | public function load_scripts_styles_edit() { |
562 | 562 | //styles |
563 | - wp_enqueue_style( 'espresso-ui-theme' ); |
|
563 | + wp_enqueue_style('espresso-ui-theme'); |
|
564 | 564 | wp_register_style( |
565 | 565 | 'event-editor-css', |
566 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
567 | - array( 'ee-admin-css' ), |
|
566 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
567 | + array('ee-admin-css'), |
|
568 | 568 | EVENT_ESPRESSO_VERSION |
569 | 569 | ); |
570 | - wp_enqueue_style( 'event-editor-css' ); |
|
570 | + wp_enqueue_style('event-editor-css'); |
|
571 | 571 | //scripts |
572 | 572 | wp_register_script( |
573 | 573 | 'event-datetime-metabox', |
574 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
575 | - array( 'event_editor_js', 'ee-datepicker' ), |
|
574 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
575 | + array('event_editor_js', 'ee-datepicker'), |
|
576 | 576 | EVENT_ESPRESSO_VERSION |
577 | 577 | ); |
578 | - wp_enqueue_script( 'event-datetime-metabox' ); |
|
578 | + wp_enqueue_script('event-datetime-metabox'); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | $this->_views = array( |
596 | 596 | 'all' => array( |
597 | 597 | 'slug' => 'all', |
598 | - 'label' => esc_html__( 'All', 'event_espresso' ), |
|
598 | + 'label' => esc_html__('All', 'event_espresso'), |
|
599 | 599 | 'count' => 0, |
600 | 600 | 'bulk_action' => array( |
601 | - 'delete_categories' => esc_html__( 'Delete Permanently', 'event_espresso' ), |
|
601 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
602 | 602 | ), |
603 | 603 | ), |
604 | 604 | ); |
@@ -634,14 +634,14 @@ discard block |
||
634 | 634 | * @access public |
635 | 635 | * @return void |
636 | 636 | */ |
637 | - public function verify_event_edit( $event = null ) { |
|
637 | + public function verify_event_edit($event = null) { |
|
638 | 638 | // no event? |
639 | - if ( empty( $event ) ) { |
|
639 | + if (empty($event)) { |
|
640 | 640 | // set event |
641 | 641 | $event = $this->_cpt_model_obj; |
642 | 642 | } |
643 | 643 | // STILL no event? |
644 | - if ( empty ( $event ) ) { |
|
644 | + if (empty ($event)) { |
|
645 | 645 | return; |
646 | 646 | } |
647 | 647 | $orig_status = $event->status(); |
@@ -655,32 +655,32 @@ discard block |
||
655 | 655 | return; |
656 | 656 | } |
657 | 657 | //made it here so it IS active... next check that any of the tickets are sold. |
658 | - if ( $event->is_sold_out( true ) ) { |
|
659 | - if ( $orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status ) { |
|
658 | + if ($event->is_sold_out(true)) { |
|
659 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
660 | 660 | EE_Error::add_attention( |
661 | 661 | sprintf( |
662 | 662 | esc_html__( |
663 | 663 | 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
664 | 664 | 'event_espresso' |
665 | 665 | ), |
666 | - EEH_Template::pretty_status( EEM_Event::sold_out, false, 'sentence' ) |
|
666 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
667 | 667 | ) |
668 | 668 | ); |
669 | 669 | } |
670 | 670 | return; |
671 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
671 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
672 | 672 | EE_Error::add_attention( |
673 | 673 | sprintf( |
674 | 674 | esc_html__( |
675 | 675 | 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
676 | 676 | 'event_espresso' |
677 | 677 | ), |
678 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
678 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
679 | 679 | ) |
680 | 680 | ); |
681 | 681 | } |
682 | 682 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
683 | - if ( ! $event->tickets_on_sale() ) { |
|
683 | + if ( ! $event->tickets_on_sale()) { |
|
684 | 684 | return; |
685 | 685 | } |
686 | 686 | //made it here so show warning |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | */ |
699 | 699 | protected function _edit_event_warning() { |
700 | 700 | // we don't want to add warnings during these requests |
701 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] === 'editpost' ) { |
|
701 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
702 | 702 | return; |
703 | 703 | } |
704 | 704 | EE_Error::add_attention( |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | * @return string |
718 | 718 | */ |
719 | 719 | protected function _create_new_cpt_item() { |
720 | - $gmt_offset = get_option( 'gmt_offset' ); |
|
720 | + $gmt_offset = get_option('gmt_offset'); |
|
721 | 721 | //only nag them about setting their timezone if it's their first event, and they haven't already done it |
722 | - if( $gmt_offset === '0' && ! EEM_Event::instance()->exists(array()) ) { |
|
722 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
723 | 723 | EE_Error::add_attention( |
724 | 724 | sprintf( |
725 | - __( 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
725 | + __('Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
726 | 726 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.'), |
727 | - '<a href="' . admin_url( 'options-general.php' ) . '">', |
|
727 | + '<a href="'.admin_url('options-general.php').'">', |
|
728 | 728 | '</a>' |
729 | 729 | ), |
730 | 730 | __FILE__, |
@@ -741,29 +741,29 @@ discard block |
||
741 | 741 | $this->_views = array( |
742 | 742 | 'all' => array( |
743 | 743 | 'slug' => 'all', |
744 | - 'label' => esc_html__( 'View All Events', 'event_espresso' ), |
|
744 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
745 | 745 | 'count' => 0, |
746 | 746 | 'bulk_action' => array( |
747 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
747 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
748 | 748 | ), |
749 | 749 | ), |
750 | 750 | 'draft' => array( |
751 | 751 | 'slug' => 'draft', |
752 | - 'label' => esc_html__( 'Draft', 'event_espresso' ), |
|
752 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
753 | 753 | 'count' => 0, |
754 | 754 | 'bulk_action' => array( |
755 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
755 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
756 | 756 | ), |
757 | 757 | ), |
758 | 758 | ); |
759 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
759 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
760 | 760 | $this->_views['trash'] = array( |
761 | 761 | 'slug' => 'trash', |
762 | - 'label' => esc_html__( 'Trash', 'event_espresso' ), |
|
762 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
763 | 763 | 'count' => 0, |
764 | 764 | 'bulk_action' => array( |
765 | - 'restore_events' => esc_html__( 'Restore From Trash', 'event_espresso' ), |
|
766 | - 'delete_events' => esc_html__( 'Delete Permanently', 'event_espresso' ), |
|
765 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
766 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
767 | 767 | ), |
768 | 768 | ); |
769 | 769 | } |
@@ -778,50 +778,50 @@ discard block |
||
778 | 778 | $items = array( |
779 | 779 | 'view_details' => array( |
780 | 780 | 'class' => 'dashicons dashicons-search', |
781 | - 'desc' => esc_html__( 'View Event', 'event_espresso' ), |
|
781 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
782 | 782 | ), |
783 | 783 | 'edit_event' => array( |
784 | 784 | 'class' => 'ee-icon ee-icon-calendar-edit', |
785 | - 'desc' => esc_html__( 'Edit Event Details', 'event_espresso' ), |
|
785 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
786 | 786 | ), |
787 | 787 | 'view_attendees' => array( |
788 | 788 | 'class' => 'dashicons dashicons-groups', |
789 | - 'desc' => esc_html__( 'View Registrations for Event', 'event_espresso' ), |
|
789 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
790 | 790 | ), |
791 | 791 | ); |
792 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
792 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
793 | 793 | $statuses = array( |
794 | 794 | 'sold_out_status' => array( |
795 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
796 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, false, 'sentence' ), |
|
795 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
796 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
797 | 797 | ), |
798 | 798 | 'active_status' => array( |
799 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
800 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, false, 'sentence' ), |
|
799 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
800 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
801 | 801 | ), |
802 | 802 | 'upcoming_status' => array( |
803 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
804 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, false, 'sentence' ), |
|
803 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
804 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
805 | 805 | ), |
806 | 806 | 'postponed_status' => array( |
807 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
808 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, false, 'sentence' ), |
|
807 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
808 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
809 | 809 | ), |
810 | 810 | 'cancelled_status' => array( |
811 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
812 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, false, 'sentence' ), |
|
811 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
812 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
813 | 813 | ), |
814 | 814 | 'expired_status' => array( |
815 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
816 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, false, 'sentence' ), |
|
815 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
816 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
817 | 817 | ), |
818 | 818 | 'inactive_status' => array( |
819 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
820 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, false, 'sentence' ), |
|
819 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
820 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
821 | 821 | ), |
822 | 822 | ); |
823 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
824 | - return array_merge( $items, $statuses ); |
|
823 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
824 | + return array_merge($items, $statuses); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | * @return EEM_Event |
833 | 833 | */ |
834 | 834 | private function _event_model() { |
835 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
836 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
835 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
836 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
837 | 837 | } |
838 | 838 | return $this->_event_model; |
839 | 839 | } |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | * @param string $new_slug what the slug is |
851 | 851 | * @return string The new html string for the permalink area |
852 | 852 | */ |
853 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
853 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
854 | 854 | //make sure this is only when editing |
855 | - if ( ! empty( $id ) ) { |
|
856 | - $post = get_post( $id ); |
|
855 | + if ( ! empty($id)) { |
|
856 | + $post = get_post($id); |
|
857 | 857 | $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
858 | - . esc_html__( 'Shortcode', 'event_espresso' ) |
|
858 | + . esc_html__('Shortcode', 'event_espresso') |
|
859 | 859 | . '</a> '; |
860 | 860 | $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
861 | 861 | . $post->ID |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | * @return void |
875 | 875 | */ |
876 | 876 | protected function _events_overview_list_table() { |
877 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
877 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
878 | 878 | $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( |
879 | - get_post_type_archive_link( 'espresso_events' ), |
|
880 | - esc_html__( "View Event Archive Page", "event_espresso" ), |
|
879 | + get_post_type_archive_link('espresso_events'), |
|
880 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
881 | 881 | 'button' |
882 | 882 | ); |
883 | - $this->_template_args['after_list_table'] .= $this->_display_legend( $this->_event_legend_items() ); |
|
884 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
883 | + $this->_template_args['after_list_table'] .= $this->_display_legend($this->_event_legend_items()); |
|
884 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
885 | 885 | 'create_new', |
886 | 886 | 'add', |
887 | 887 | array(), |
@@ -907,48 +907,48 @@ discard block |
||
907 | 907 | * @param string $post_id |
908 | 908 | * @param object $post |
909 | 909 | */ |
910 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
911 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
910 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
911 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
912 | 912 | //get out we're not processing an event save. |
913 | 913 | return; |
914 | 914 | } |
915 | 915 | $event_values = array( |
916 | - 'EVT_display_desc' => ! empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
917 | - 'EVT_display_ticket_selector' => ! empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
916 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
917 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
918 | 918 | 'EVT_additional_limit' => min( |
919 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
920 | - ! empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : null |
|
919 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
920 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
921 | 921 | ), |
922 | - 'EVT_default_registration_status' => ! empty( $this->_req_data['EVT_default_registration_status'] ) |
|
922 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
923 | 923 | ? $this->_req_data['EVT_default_registration_status'] |
924 | 924 | : EE_Registry::instance()->CFG->registration->default_STS_ID, |
925 | - 'EVT_member_only' => ! empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
926 | - 'EVT_allow_overflow' => ! empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
927 | - 'EVT_timezone_string' => ! empty( $this->_req_data['timezone_string'] ) |
|
925 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
926 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
927 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
928 | 928 | ? $this->_req_data['timezone_string'] : null, |
929 | - 'EVT_external_URL' => ! empty( $this->_req_data['externalURL'] ) |
|
929 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
930 | 930 | ? $this->_req_data['externalURL'] : null, |
931 | - 'EVT_phone' => ! empty( $this->_req_data['event_phone'] ) |
|
931 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
932 | 932 | ? $this->_req_data['event_phone'] : null, |
933 | 933 | ); |
934 | 934 | //update event |
935 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
935 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
936 | 936 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
937 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
938 | - $event = $this->_event_model()->get_one( array( $get_one_where ) ); |
|
937 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
938 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
939 | 939 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
940 | 940 | $event_update_callbacks = apply_filters( |
941 | 941 | 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
942 | - array( array( $this, '_default_venue_update' ), array( $this, '_default_tickets_update' ) ) |
|
942 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
943 | 943 | ); |
944 | 944 | $att_success = true; |
945 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
946 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
945 | + foreach ($event_update_callbacks as $e_callback) { |
|
946 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
947 | 947 | $att_success = ! $att_success ? $att_success |
948 | 948 | : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
949 | 949 | } |
950 | 950 | //any errors? |
951 | - if ( $success && false === $att_success ) { |
|
951 | + if ($success && false === $att_success) { |
|
952 | 952 | EE_Error::add_error( |
953 | 953 | esc_html__( |
954 | 954 | 'Event Details saved successfully but something went wrong with saving attachments.', |
@@ -958,9 +958,9 @@ discard block |
||
958 | 958 | __FUNCTION__, |
959 | 959 | __LINE__ |
960 | 960 | ); |
961 | - } else if ( $success === false ) { |
|
961 | + } else if ($success === false) { |
|
962 | 962 | EE_Error::add_error( |
963 | - esc_html__( 'Event Details did not save successfully.', 'event_espresso' ), |
|
963 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
964 | 964 | __FILE__, |
965 | 965 | __FUNCTION__, |
966 | 966 | __LINE__ |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | * @param int $post_id |
976 | 976 | * @param int $revision_id |
977 | 977 | */ |
978 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
978 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
979 | 979 | //copy existing event meta to new post |
980 | - $post_evt = $this->_event_model()->get_one_by_ID( $post_id ); |
|
981 | - if ( $post_evt instanceof EE_Event ) { |
|
980 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
981 | + if ($post_evt instanceof EE_Event) { |
|
982 | 982 | //meta revision restore |
983 | - $post_evt->restore_revision( $revision_id ); |
|
983 | + $post_evt->restore_revision($revision_id); |
|
984 | 984 | //related objs restore |
985 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
985 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | |
@@ -995,49 +995,49 @@ discard block |
||
995 | 995 | * @param array $data The request data from the form |
996 | 996 | * @return bool Success or fail. |
997 | 997 | */ |
998 | - protected function _default_venue_update( \EE_Event $evtobj, $data ) { |
|
999 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
1000 | - $venue_model = EE_Registry::instance()->load_model( 'Venue' ); |
|
998 | + protected function _default_venue_update(\EE_Event $evtobj, $data) { |
|
999 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
1000 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1001 | 1001 | $rows_affected = null; |
1002 | - $venue_id = ! empty( $data['venue_id'] ) ? $data['venue_id'] : null; |
|
1002 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1003 | 1003 | // very important. If we don't have a venue name... |
1004 | 1004 | // then we'll get out because not necessary to create empty venue |
1005 | - if ( empty( $data['venue_title'] ) ) { |
|
1005 | + if (empty($data['venue_title'])) { |
|
1006 | 1006 | return false; |
1007 | 1007 | } |
1008 | 1008 | $venue_array = array( |
1009 | - 'VNU_wp_user' => $evtobj->get( 'EVT_wp_user' ), |
|
1010 | - 'VNU_name' => ! empty( $data['venue_title'] ) ? $data['venue_title'] : null, |
|
1011 | - 'VNU_desc' => ! empty( $data['venue_description'] ) ? $data['venue_description'] : null, |
|
1012 | - 'VNU_identifier' => ! empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : null, |
|
1013 | - 'VNU_short_desc' => ! empty( $data['venue_short_description'] ) ? $data['venue_short_description'] |
|
1009 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1010 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1011 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1012 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1013 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1014 | 1014 | : null, |
1015 | - 'VNU_address' => ! empty( $data['address'] ) ? $data['address'] : null, |
|
1016 | - 'VNU_address2' => ! empty( $data['address2'] ) ? $data['address2'] : null, |
|
1017 | - 'VNU_city' => ! empty( $data['city'] ) ? $data['city'] : null, |
|
1018 | - 'STA_ID' => ! empty( $data['state'] ) ? $data['state'] : null, |
|
1019 | - 'CNT_ISO' => ! empty( $data['countries'] ) ? $data['countries'] : null, |
|
1020 | - 'VNU_zip' => ! empty( $data['zip'] ) ? $data['zip'] : null, |
|
1021 | - 'VNU_phone' => ! empty( $data['venue_phone'] ) ? $data['venue_phone'] : null, |
|
1022 | - 'VNU_capacity' => ! empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : null, |
|
1023 | - 'VNU_url' => ! empty( $data['venue_url'] ) ? $data['venue_url'] : null, |
|
1024 | - 'VNU_virtual_phone' => ! empty( $data['virtual_phone'] ) ? $data['virtual_phone'] : null, |
|
1025 | - 'VNU_virtual_url' => ! empty( $data['virtual_url'] ) ? $data['virtual_url'] : null, |
|
1026 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
1015 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1016 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1017 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1018 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1019 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1020 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1021 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1022 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1023 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1024 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1025 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1026 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1027 | 1027 | 'status' => 'publish', |
1028 | 1028 | ); |
1029 | 1029 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
1030 | - if ( ! empty( $venue_id ) ) { |
|
1031 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
1032 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
1030 | + if ( ! empty($venue_id)) { |
|
1031 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1032 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1033 | 1033 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
1034 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
1034 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1035 | 1035 | return $rows_affected > 0 ? true : false; |
1036 | 1036 | } else { |
1037 | 1037 | //we insert the venue |
1038 | - $venue_id = $venue_model->insert( $venue_array ); |
|
1039 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
1040 | - return ! empty( $venue_id ) ? true : false; |
|
1038 | + $venue_id = $venue_model->insert($venue_array); |
|
1039 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1040 | + return ! empty($venue_id) ? true : false; |
|
1041 | 1041 | } |
1042 | 1042 | //when we have the ancestor come in it's already been handled by the revision save. |
1043 | 1043 | } |
@@ -1051,51 +1051,51 @@ discard block |
||
1051 | 1051 | * @param array $data The request data from the form |
1052 | 1052 | * @return array |
1053 | 1053 | */ |
1054 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
1054 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
1055 | 1055 | $success = true; |
1056 | 1056 | $saved_dtt = null; |
1057 | 1057 | $saved_tickets = array(); |
1058 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1059 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
1058 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1059 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1060 | 1060 | //trim all values to ensure any excess whitespace is removed. |
1061 | - $dtt = array_map( 'trim', $dtt ); |
|
1062 | - $dtt['DTT_EVT_end'] = isset( $dtt['DTT_EVT_end'] ) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] |
|
1061 | + $dtt = array_map('trim', $dtt); |
|
1062 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1063 | 1063 | : $dtt['DTT_EVT_start']; |
1064 | 1064 | $datetime_values = array( |
1065 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : null, |
|
1065 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1066 | 1066 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
1067 | 1067 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
1068 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1068 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1069 | 1069 | 'DTT_order' => $row, |
1070 | 1070 | ); |
1071 | 1071 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
1072 | - if ( ! empty( $dtt['DTT_ID'] ) ) { |
|
1072 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1073 | 1073 | $DTM = EE_Registry::instance() |
1074 | - ->load_model( 'Datetime', array( $evtobj->get_timezone() ) ) |
|
1075 | - ->get_one_by_ID( $dtt['DTT_ID'] ); |
|
1076 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
1077 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
1078 | - foreach ( $datetime_values as $field => $value ) { |
|
1079 | - $DTM->set( $field, $value ); |
|
1074 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1075 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1076 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1077 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1078 | + foreach ($datetime_values as $field => $value) { |
|
1079 | + $DTM->set($field, $value); |
|
1080 | 1080 | } |
1081 | 1081 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
1082 | - $saved_dtts[ $DTM->ID() ] = $DTM; |
|
1082 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1083 | 1083 | } else { |
1084 | - $DTM = EE_Registry::instance()->load_class( 'Datetime', array( $datetime_values ), false, false ); |
|
1085 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
1086 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
1087 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
1088 | - foreach ( $datetime_values as $field => $value ) { |
|
1089 | - $DTM->set( $field, $value ); |
|
1084 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), false, false); |
|
1085 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1086 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1087 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
1088 | + foreach ($datetime_values as $field => $value) { |
|
1089 | + $DTM->set($field, $value); |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | $DTM->save(); |
1093 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
1093 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1094 | 1094 | //load DTT helper |
1095 | 1095 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1096 | - if ( $DTT->get_raw( 'DTT_EVT_start' ) > $DTT->get_raw( 'DTT_EVT_end' ) ) { |
|
1097 | - $DTT->set( 'DTT_EVT_end', $DTT->get( 'DTT_EVT_start' ) ); |
|
1098 | - $DTT = EEH_DTT_Helper::date_time_add( $DTT, 'DTT_EVT_end', 'days' ); |
|
1096 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1097 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1098 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1099 | 1099 | $DTT->save(); |
1100 | 1100 | } |
1101 | 1101 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
@@ -1106,20 +1106,20 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | //no dtts get deleted so we don't do any of that logic here. |
1108 | 1108 | //update tickets next |
1109 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode( ',', $data['ticket_IDs'] ) : array(); |
|
1110 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1111 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1109 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1110 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1111 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1112 | 1112 | $update_prices = false; |
1113 | - $ticket_price = isset( $data['edit_prices'][ $row ][1]['PRC_amount'] ) |
|
1114 | - ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0; |
|
1113 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1114 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1115 | 1115 | // trim inputs to ensure any excess whitespace is removed. |
1116 | - $tkt = array_map( 'trim', $tkt ); |
|
1117 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1116 | + $tkt = array_map('trim', $tkt); |
|
1117 | + if (empty($tkt['TKT_start_date'])) { |
|
1118 | 1118 | //let's use now in the set timezone. |
1119 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1120 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1119 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1120 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1121 | 1121 | } |
1122 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1122 | + if (empty($tkt['TKT_end_date'])) { |
|
1123 | 1123 | //use the start date of the first datetime |
1124 | 1124 | $dtt = $evtobj->first_datetime(); |
1125 | 1125 | $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
@@ -1128,22 +1128,22 @@ discard block |
||
1128 | 1128 | ); |
1129 | 1129 | } |
1130 | 1130 | $TKT_values = array( |
1131 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : null, |
|
1132 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1133 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1134 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1131 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1132 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1133 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1134 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1135 | 1135 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1136 | 1136 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1137 | - 'TKT_qty' => ! isset( $tkt['TKT_qty'] ) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1138 | - 'TKT_uses' => ! isset( $tkt['TKT_uses'] ) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1139 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1140 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1137 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1138 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1139 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1140 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1141 | 1141 | 'TKT_row' => $row, |
1142 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1142 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1143 | 1143 | 'TKT_price' => $ticket_price, |
1144 | 1144 | ); |
1145 | 1145 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1146 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1146 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1147 | 1147 | $TKT_values['TKT_ID'] = 0; |
1148 | 1148 | $TKT_values['TKT_is_default'] = 0; |
1149 | 1149 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1152,110 +1152,110 @@ discard block |
||
1152 | 1152 | //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
1153 | 1153 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1154 | 1154 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1155 | - if ( ! empty( $tkt['TKT_ID'] ) ) { |
|
1155 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1156 | 1156 | $TKT = EE_Registry::instance() |
1157 | - ->load_model( 'Ticket', array( $evtobj->get_timezone() ) ) |
|
1158 | - ->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1159 | - if ( $TKT instanceof EE_Ticket ) { |
|
1157 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1158 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1159 | + if ($TKT instanceof EE_Ticket) { |
|
1160 | 1160 | $ticket_sold = $TKT->count_related( |
1161 | 1161 | 'Registration', |
1162 | 1162 | array( |
1163 | 1163 | array( |
1164 | 1164 | 'STS_ID' => array( |
1165 | 1165 | 'NOT IN', |
1166 | - array( EEM_Registration::status_id_incomplete ), |
|
1166 | + array(EEM_Registration::status_id_incomplete), |
|
1167 | 1167 | ), |
1168 | 1168 | ), |
1169 | 1169 | ) |
1170 | 1170 | ) > 0 ? true : false; |
1171 | 1171 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1172 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) |
|
1172 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1173 | 1173 | && ! $TKT->get( |
1174 | 1174 | 'TKT_deleted' |
1175 | 1175 | ) ? true : false; |
1176 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1177 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1176 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1177 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1178 | 1178 | //set new values |
1179 | - foreach ( $TKT_values as $field => $value ) { |
|
1180 | - if ( $field == 'TKT_qty' ) { |
|
1181 | - $TKT->set_qty( $value ); |
|
1179 | + foreach ($TKT_values as $field => $value) { |
|
1180 | + if ($field == 'TKT_qty') { |
|
1181 | + $TKT->set_qty($value); |
|
1182 | 1182 | } else { |
1183 | - $TKT->set( $field, $value ); |
|
1183 | + $TKT->set($field, $value); |
|
1184 | 1184 | } |
1185 | 1185 | } |
1186 | 1186 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1187 | - if ( $create_new_TKT ) { |
|
1187 | + if ($create_new_TKT) { |
|
1188 | 1188 | //archive the old ticket first |
1189 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1189 | + $TKT->set('TKT_deleted', 1); |
|
1190 | 1190 | $TKT->save(); |
1191 | 1191 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1192 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1192 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1193 | 1193 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1194 | 1194 | $TKT = clone $TKT; |
1195 | - $TKT->set( 'TKT_ID', 0 ); |
|
1196 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1197 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1198 | - $TKT->set( 'TKT_sold', 0 ); |
|
1195 | + $TKT->set('TKT_ID', 0); |
|
1196 | + $TKT->set('TKT_deleted', 0); |
|
1197 | + $TKT->set('TKT_price', $ticket_price); |
|
1198 | + $TKT->set('TKT_sold', 0); |
|
1199 | 1199 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1200 | 1200 | $update_prices = true; |
1201 | 1201 | } |
1202 | 1202 | //make sure price is set if it hasn't been already |
1203 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1203 | + $TKT->set('TKT_price', $ticket_price); |
|
1204 | 1204 | } |
1205 | 1205 | } else { |
1206 | 1206 | //no TKT_id so a new TKT |
1207 | 1207 | $TKT_values['TKT_price'] = $ticket_price; |
1208 | - $TKT = EE_Registry::instance()->load_class( 'Ticket', array( $TKT_values ), false, false ); |
|
1209 | - if ( $TKT instanceof EE_Ticket ) { |
|
1208 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1209 | + if ($TKT instanceof EE_Ticket) { |
|
1210 | 1210 | //need to reset values to properly account for the date formats |
1211 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1212 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1213 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1211 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1212 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1213 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1214 | 1214 | //set new values |
1215 | - foreach ( $TKT_values as $field => $value ) { |
|
1216 | - if ( $field == 'TKT_qty' ) { |
|
1217 | - $TKT->set_qty( $value ); |
|
1215 | + foreach ($TKT_values as $field => $value) { |
|
1216 | + if ($field == 'TKT_qty') { |
|
1217 | + $TKT->set_qty($value); |
|
1218 | 1218 | } else { |
1219 | - $TKT->set( $field, $value ); |
|
1219 | + $TKT->set($field, $value); |
|
1220 | 1220 | } |
1221 | 1221 | } |
1222 | 1222 | $update_prices = true; |
1223 | 1223 | } |
1224 | 1224 | } |
1225 | 1225 | // cap ticket qty by datetime reg limits |
1226 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1226 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1227 | 1227 | //update ticket. |
1228 | 1228 | $TKT->save(); |
1229 | 1229 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1230 | - if ( $TKT->get_raw( 'TKT_start_date' ) > $TKT->get_raw( 'TKT_end_date' ) ) { |
|
1231 | - $TKT->set( 'TKT_end_date', $TKT->get( 'TKT_start_date' ) ); |
|
1232 | - $TKT = EEH_DTT_Helper::date_time_add( $TKT, 'TKT_end_date', 'days' ); |
|
1230 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1231 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1232 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1233 | 1233 | $TKT->save(); |
1234 | 1234 | } |
1235 | 1235 | //initially let's add the ticket to the dtt |
1236 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1237 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1236 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1237 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1238 | 1238 | //add prices to ticket |
1239 | - $this->_add_prices_to_ticket( $data['edit_prices'][ $row ], $TKT, $update_prices ); |
|
1239 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1240 | 1240 | } |
1241 | 1241 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1242 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1243 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1244 | - foreach ( $tickets_removed as $id ) { |
|
1245 | - $id = absint( $id ); |
|
1242 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1243 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1244 | + foreach ($tickets_removed as $id) { |
|
1245 | + $id = absint($id); |
|
1246 | 1246 | //get the ticket for this id |
1247 | - $tkt_to_remove = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $id ); |
|
1247 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1248 | 1248 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1249 | - $dtts = $tkt_to_remove->get_many_related( 'Datetime' ); |
|
1250 | - foreach ( $dtts as $dtt ) { |
|
1251 | - $tkt_to_remove->_remove_relation_to( $dtt, 'Datetime' ); |
|
1249 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1250 | + foreach ($dtts as $dtt) { |
|
1251 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1252 | 1252 | } |
1253 | 1253 | //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
1254 | - $tkt_to_remove->delete_related_permanently( 'Price' ); |
|
1254 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1255 | 1255 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1256 | 1256 | $tkt_to_remove->delete_permanently(); |
1257 | 1257 | } |
1258 | - return array( $saved_dtt, $saved_tickets ); |
|
1258 | + return array($saved_dtt, $saved_tickets); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | |
@@ -1272,29 +1272,29 @@ discard block |
||
1272 | 1272 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1273 | 1273 | * @return void |
1274 | 1274 | */ |
1275 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = false ) { |
|
1276 | - foreach ( $prices as $row => $prc ) { |
|
1275 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) { |
|
1276 | + foreach ($prices as $row => $prc) { |
|
1277 | 1277 | $PRC_values = array( |
1278 | - 'PRC_ID' => ! empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : null, |
|
1279 | - 'PRT_ID' => ! empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : null, |
|
1280 | - 'PRC_amount' => ! empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1281 | - 'PRC_name' => ! empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1282 | - 'PRC_desc' => ! empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1278 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1279 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1280 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1281 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1282 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1283 | 1283 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1284 | 1284 | 'PRC_order' => $row, |
1285 | 1285 | ); |
1286 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1286 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1287 | 1287 | $PRC_values['PRC_ID'] = 0; |
1288 | - $PRC = EE_Registry::instance()->load_class( 'Price', array( $PRC_values ), false, false ); |
|
1288 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1289 | 1289 | } else { |
1290 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1290 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1291 | 1291 | //update this price with new values |
1292 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1293 | - $PRC->set( $field, $newprc ); |
|
1292 | + foreach ($PRC_values as $field => $newprc) { |
|
1293 | + $PRC->set($field, $newprc); |
|
1294 | 1294 | } |
1295 | 1295 | $PRC->save(); |
1296 | 1296 | } |
1297 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1297 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | |
@@ -1326,7 +1326,7 @@ discard block |
||
1326 | 1326 | private function _generate_publish_box_extra_content() { |
1327 | 1327 | //load formatter helper |
1328 | 1328 | //args for getting related registrations |
1329 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1329 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1330 | 1330 | $not_approved_query_args = array( |
1331 | 1331 | array( |
1332 | 1332 | 'REG_deleted' => 0, |
@@ -1397,7 +1397,7 @@ discard block |
||
1397 | 1397 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
1398 | 1398 | // load template |
1399 | 1399 | EEH_Template::display_template( |
1400 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1400 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
1401 | 1401 | $publish_box_extra_args |
1402 | 1402 | ); |
1403 | 1403 | } |
@@ -1431,16 +1431,16 @@ discard block |
||
1431 | 1431 | $this->verify_cpt_object(); |
1432 | 1432 | add_meta_box( |
1433 | 1433 | 'espresso_event_editor_tickets', |
1434 | - esc_html__( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1435 | - array( $this, 'ticket_metabox' ), |
|
1434 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1435 | + array($this, 'ticket_metabox'), |
|
1436 | 1436 | $this->page_slug, |
1437 | 1437 | 'normal', |
1438 | 1438 | 'high' |
1439 | 1439 | ); |
1440 | 1440 | add_meta_box( |
1441 | 1441 | 'espresso_event_editor_event_options', |
1442 | - esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
1443 | - array( $this, 'registration_options_meta_box' ), |
|
1442 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1443 | + array($this, 'registration_options_meta_box'), |
|
1444 | 1444 | $this->page_slug, |
1445 | 1445 | 'side', |
1446 | 1446 | 'default' |
@@ -1468,65 +1468,65 @@ discard block |
||
1468 | 1468 | 'trash_icon' => 'ee-lock-icon', |
1469 | 1469 | 'disabled' => '', |
1470 | 1470 | ); |
1471 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : null; |
|
1472 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1471 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1472 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1473 | 1473 | /** |
1474 | 1474 | * 1. Start with retrieving Datetimes |
1475 | 1475 | * 2. Fore each datetime get related tickets |
1476 | 1476 | * 3. For each ticket get related prices |
1477 | 1477 | */ |
1478 | - $times = EE_Registry::instance()->load_model( 'Datetime' )->get_all_event_dates( $event_id ); |
|
1478 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1479 | 1479 | /** @type EE_Datetime $first_datetime */ |
1480 | - $first_datetime = reset( $times ); |
|
1480 | + $first_datetime = reset($times); |
|
1481 | 1481 | //do we get related tickets? |
1482 | - if ( $first_datetime instanceof EE_Datetime |
|
1482 | + if ($first_datetime instanceof EE_Datetime |
|
1483 | 1483 | && $first_datetime->ID() !== 0 |
1484 | 1484 | ) { |
1485 | - $existing_datetime_ids[] = $first_datetime->get( 'DTT_ID' ); |
|
1485 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1486 | 1486 | $template_args['time'] = $first_datetime; |
1487 | 1487 | $related_tickets = $first_datetime->tickets( |
1488 | 1488 | array( |
1489 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1489 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1490 | 1490 | 'default_where_conditions' => 'none', |
1491 | 1491 | ) |
1492 | 1492 | ); |
1493 | - if ( ! empty( $related_tickets ) ) { |
|
1494 | - $template_args['total_ticket_rows'] = count( $related_tickets ); |
|
1493 | + if ( ! empty($related_tickets)) { |
|
1494 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1495 | 1495 | $row = 0; |
1496 | - foreach ( $related_tickets as $ticket ) { |
|
1497 | - $existing_ticket_ids[] = $ticket->get( 'TKT_ID' ); |
|
1498 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket, false, $row ); |
|
1496 | + foreach ($related_tickets as $ticket) { |
|
1497 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1498 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1499 | 1499 | $row++; |
1500 | 1500 | } |
1501 | 1501 | } else { |
1502 | 1502 | $template_args['total_ticket_rows'] = 1; |
1503 | 1503 | /** @type EE_Ticket $ticket */ |
1504 | - $ticket = EE_Registry::instance()->load_model( 'Ticket' )->create_default_object(); |
|
1505 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1504 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1505 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1506 | 1506 | } |
1507 | 1507 | } else { |
1508 | 1508 | $template_args['time'] = $times[0]; |
1509 | 1509 | /** @type EE_Ticket $ticket */ |
1510 | - $ticket = EE_Registry::instance()->load_model( 'Ticket' )->get_all_default_tickets(); |
|
1511 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1510 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1511 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1512 | 1512 | // NOTE: we're just sending the first default row |
1513 | 1513 | // (decaf can't manage default tickets so this should be sufficient); |
1514 | 1514 | } |
1515 | 1515 | $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
1516 | 1516 | 'event_editor_event_datetimes_help_tab' |
1517 | 1517 | ); |
1518 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link( 'ticket_options_info' ); |
|
1519 | - $template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
1520 | - $template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
1518 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1519 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1520 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1521 | 1521 | $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
1522 | - EE_Registry::instance()->load_model( 'Ticket' )->create_default_object(), |
|
1522 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1523 | 1523 | true |
1524 | 1524 | ); |
1525 | 1525 | $template = apply_filters( |
1526 | 1526 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
1527 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1527 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
1528 | 1528 | ); |
1529 | - EEH_Template::display_template( $template, $template_args ); |
|
1529 | + EEH_Template::display_template($template, $template_args); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | |
@@ -1540,74 +1540,74 @@ discard block |
||
1540 | 1540 | * @param int $row |
1541 | 1541 | * @return string generated html for the ticket row. |
1542 | 1542 | */ |
1543 | - private function _get_ticket_row( $ticket, $skeleton = false, $row = 0 ) { |
|
1543 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) { |
|
1544 | 1544 | $template_args = array( |
1545 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1545 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1546 | 1546 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
1547 | 1547 | : '', |
1548 | 1548 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1549 | - 'TKT_ID' => $ticket->get( 'TKT_ID' ), |
|
1550 | - 'TKT_name' => $ticket->get( 'TKT_name' ), |
|
1551 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date( 'TKT_start_date', 'Y-m-d h:i a' ), |
|
1552 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date( 'TKT_end_date', 'Y-m-d h:i a' ), |
|
1553 | - 'TKT_is_default' => $ticket->get( 'TKT_is_default' ), |
|
1554 | - 'TKT_qty' => $ticket->get_pretty( 'TKT_qty', 'input' ), |
|
1549 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1550 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1551 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1552 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1553 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1554 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1555 | 1555 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1556 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get( 'TKT_sold' ), |
|
1557 | - 'trash_icon' => ( $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ) |
|
1558 | - && ( ! empty( $ticket ) && $ticket->get( 'TKT_sold' ) === 0 ) |
|
1556 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1557 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1558 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1559 | 1559 | ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
1560 | - 'disabled' => $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ? '' |
|
1560 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1561 | 1561 | : ' disabled=disabled', |
1562 | 1562 | ); |
1563 | 1563 | $price = $ticket->ID() !== 0 |
1564 | - ? $ticket->get_first_related( 'Price', array( 'default_where_conditions' => 'none' ) ) |
|
1565 | - : EE_Registry::instance()->load_model( 'Price' )->create_default_object(); |
|
1564 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1565 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1566 | 1566 | $price_args = array( |
1567 | 1567 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1568 | - 'PRC_amount' => $price->get( 'PRC_amount' ), |
|
1569 | - 'PRT_ID' => $price->get( 'PRT_ID' ), |
|
1570 | - 'PRC_ID' => $price->get( 'PRC_ID' ), |
|
1571 | - 'PRC_is_default' => $price->get( 'PRC_is_default' ), |
|
1568 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1569 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1570 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1571 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1572 | 1572 | ); |
1573 | 1573 | //make sure we have default start and end dates if skeleton |
1574 | 1574 | //handle rows that should NOT be empty |
1575 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1575 | + if (empty($template_args['TKT_start_date'])) { |
|
1576 | 1576 | //if empty then the start date will be now. |
1577 | - $template_args['TKT_start_date'] = date( 'Y-m-d h:i a', current_time( 'timestamp' ) ); |
|
1577 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1578 | 1578 | } |
1579 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1579 | + if (empty($template_args['TKT_end_date'])) { |
|
1580 | 1580 | //get the earliest datetime (if present); |
1581 | 1581 | $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
1582 | 1582 | ? $this->_cpt_model_obj->get_first_related( |
1583 | 1583 | 'Datetime', |
1584 | - array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) |
|
1584 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1585 | 1585 | ) |
1586 | 1586 | : null; |
1587 | - if ( ! empty( $earliest_dtt ) ) { |
|
1588 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime( 'DTT_EVT_start', 'Y-m-d', 'h:i a' ); |
|
1587 | + if ( ! empty($earliest_dtt)) { |
|
1588 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1589 | 1589 | } else { |
1590 | 1590 | $template_args['TKT_end_date'] = date( |
1591 | 1591 | 'Y-m-d h:i a', |
1592 | - mktime( 0, 0, 0, date( "m" ), date( "d" ) + 7, date( "Y" ) ) |
|
1592 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1593 | 1593 | ); |
1594 | 1594 | } |
1595 | 1595 | } |
1596 | - $template_args = array_merge( $template_args, $price_args ); |
|
1596 | + $template_args = array_merge($template_args, $price_args); |
|
1597 | 1597 | $template = apply_filters( |
1598 | 1598 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
1599 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1599 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
1600 | 1600 | $ticket |
1601 | 1601 | ); |
1602 | - return EEH_Template::display_template( $template, $template_args, true ); |
|
1602 | + return EEH_Template::display_template($template, $template_args, true); |
|
1603 | 1603 | } |
1604 | 1604 | |
1605 | 1605 | |
1606 | 1606 | |
1607 | 1607 | public function registration_options_meta_box() { |
1608 | 1608 | $yes_no_values = array( |
1609 | - array( 'id' => true, 'text' => esc_html__( 'Yes', 'event_espresso' ) ), |
|
1610 | - array( 'id' => false, 'text' => esc_html__( 'No', 'event_espresso' ) ), |
|
1609 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1610 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1611 | 1611 | ); |
1612 | 1612 | $default_reg_status_values = EEM_Registration::reg_status_array( |
1613 | 1613 | array( |
@@ -1619,7 +1619,7 @@ discard block |
||
1619 | 1619 | ); |
1620 | 1620 | //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
1621 | 1621 | $template_args['_event'] = $this->_cpt_model_obj; |
1622 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status( false ); |
|
1622 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1623 | 1623 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
1624 | 1624 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
1625 | 1625 | 'default_reg_status', |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | $default_reg_status_values |
1648 | 1648 | ); |
1649 | 1649 | EEH_Template::display_template( |
1650 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1650 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1651 | 1651 | $template_args |
1652 | 1652 | ); |
1653 | 1653 | } |
@@ -1666,97 +1666,97 @@ discard block |
||
1666 | 1666 | * that match the given _view and paging parameters. |
1667 | 1667 | * @return array an array of event objects. |
1668 | 1668 | */ |
1669 | - public function get_events( $per_page = 10, $current_page = 1, $count = false ) { |
|
1669 | + public function get_events($per_page = 10, $current_page = 1, $count = false) { |
|
1670 | 1670 | $EEME = $this->_event_model(); |
1671 | - $offset = ( $current_page - 1 ) * $per_page; |
|
1672 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1673 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1674 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : "DESC"; |
|
1675 | - if ( isset( $this->_req_data['month_range'] ) ) { |
|
1676 | - $pieces = explode( ' ', $this->_req_data['month_range'], 3 ); |
|
1677 | - $month_r = ! empty( $pieces[0] ) ? date( 'm', strtotime( $pieces[0] ) ) : ''; |
|
1678 | - $year_r = ! empty( $pieces[1] ) ? $pieces[1] : ''; |
|
1671 | + $offset = ($current_page - 1) * $per_page; |
|
1672 | + $limit = $count ? null : $offset.','.$per_page; |
|
1673 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1674 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1675 | + if (isset($this->_req_data['month_range'])) { |
|
1676 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1677 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1678 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1679 | 1679 | } |
1680 | 1680 | $where = array(); |
1681 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : null; |
|
1681 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1682 | 1682 | //determine what post_status our condition will have for the query. |
1683 | - switch ( $status ) { |
|
1683 | + switch ($status) { |
|
1684 | 1684 | case 'month' : |
1685 | 1685 | case 'today' : |
1686 | 1686 | case null : |
1687 | 1687 | case 'all' : |
1688 | 1688 | break; |
1689 | 1689 | case 'draft' : |
1690 | - $where['status'] = array( 'IN', array( 'draft', 'auto-draft' ) ); |
|
1690 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1691 | 1691 | break; |
1692 | 1692 | default : |
1693 | 1693 | $where['status'] = $status; |
1694 | 1694 | } |
1695 | 1695 | //categories? |
1696 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 |
|
1696 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1697 | 1697 | ? $this->_req_data['EVT_CAT'] : null; |
1698 | - if ( ! empty ( $category ) ) { |
|
1698 | + if ( ! empty ($category)) { |
|
1699 | 1699 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1700 | 1700 | $where['Term_Taxonomy.term_id'] = $category; |
1701 | 1701 | } |
1702 | 1702 | //date where conditions |
1703 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1704 | - if ( isset( $this->_req_data['month_range'] ) && $this->_req_data['month_range'] != '' ) { |
|
1703 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1704 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1705 | 1705 | $DateTime = new DateTime( |
1706 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1707 | - new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) |
|
1706 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
1707 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1708 | 1708 | ); |
1709 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1710 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format( 't' ) )->setTime( 23, 59, 59 )->format( |
|
1711 | - implode( ' ', $start_formats ) |
|
1709 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1710 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format( |
|
1711 | + implode(' ', $start_formats) |
|
1712 | 1712 | ); |
1713 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1714 | - } else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'today' ) { |
|
1715 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1716 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1717 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1718 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1719 | - } else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'month' ) { |
|
1720 | - $now = date( 'Y-m-01' ); |
|
1721 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1722 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1723 | - $end = $DateTime->setDate( date( 'Y' ), date( 'm' ), $DateTime->format( 't' ) ) |
|
1724 | - ->setTime( 23, 59, 59 ) |
|
1725 | - ->format( implode( ' ', $start_formats ) ); |
|
1726 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1713 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1714 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1715 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1716 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1717 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1718 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1719 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1720 | + $now = date('Y-m-01'); |
|
1721 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1722 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1723 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1724 | + ->setTime(23, 59, 59) |
|
1725 | + ->format(implode(' ', $start_formats)); |
|
1726 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1727 | 1727 | } |
1728 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1728 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1729 | 1729 | $where['EVT_wp_user'] = get_current_user_id(); |
1730 | 1730 | } else { |
1731 | - if ( ! isset( $where['status'] ) ) { |
|
1732 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1731 | + if ( ! isset($where['status'])) { |
|
1732 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1733 | 1733 | $where['OR'] = array( |
1734 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1734 | + 'status*restrict_private' => array('!=', 'private'), |
|
1735 | 1735 | 'AND' => array( |
1736 | - 'status*inclusive' => array( '=', 'private' ), |
|
1736 | + 'status*inclusive' => array('=', 'private'), |
|
1737 | 1737 | 'EVT_wp_user' => get_current_user_id(), |
1738 | 1738 | ), |
1739 | 1739 | ); |
1740 | 1740 | } |
1741 | 1741 | } |
1742 | 1742 | } |
1743 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1744 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1745 | - && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) |
|
1743 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1744 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1745 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1746 | 1746 | ) { |
1747 | 1747 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1748 | 1748 | } |
1749 | 1749 | } |
1750 | 1750 | //search query handling |
1751 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1752 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1751 | + if (isset($this->_req_data['s'])) { |
|
1752 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1753 | 1753 | $where['OR'] = array( |
1754 | - 'EVT_name' => array( 'LIKE', $search_string ), |
|
1755 | - 'EVT_desc' => array( 'LIKE', $search_string ), |
|
1756 | - 'EVT_short_desc' => array( 'LIKE', $search_string ), |
|
1754 | + 'EVT_name' => array('LIKE', $search_string), |
|
1755 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1756 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1757 | 1757 | ); |
1758 | 1758 | } |
1759 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1759 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1760 | 1760 | $query_params = apply_filters( |
1761 | 1761 | 'FHEE__Events_Admin_Page__get_events__query_params', |
1762 | 1762 | array( |
@@ -1769,23 +1769,23 @@ discard block |
||
1769 | 1769 | $this->_req_data |
1770 | 1770 | ); |
1771 | 1771 | //let's first check if we have special requests coming in. |
1772 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1773 | - switch ( $this->_req_data['active_status'] ) { |
|
1772 | + if (isset($this->_req_data['active_status'])) { |
|
1773 | + switch ($this->_req_data['active_status']) { |
|
1774 | 1774 | case 'upcoming' : |
1775 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1775 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1776 | 1776 | break; |
1777 | 1777 | case 'expired' : |
1778 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1778 | + return $EEME->get_expired_events($query_params, $count); |
|
1779 | 1779 | break; |
1780 | 1780 | case 'active' : |
1781 | - return $EEME->get_active_events( $query_params, $count ); |
|
1781 | + return $EEME->get_active_events($query_params, $count); |
|
1782 | 1782 | break; |
1783 | 1783 | case 'inactive' : |
1784 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1784 | + return $EEME->get_inactive_events($query_params, $count); |
|
1785 | 1785 | break; |
1786 | 1786 | } |
1787 | 1787 | } |
1788 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1788 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1789 | 1789 | return $events; |
1790 | 1790 | } |
1791 | 1791 | |
@@ -1796,9 +1796,9 @@ discard block |
||
1796 | 1796 | * |
1797 | 1797 | * @param string $post_id |
1798 | 1798 | */ |
1799 | - public function trash_cpt_item( $post_id ) { |
|
1799 | + public function trash_cpt_item($post_id) { |
|
1800 | 1800 | $this->_req_data['EVT_ID'] = $post_id; |
1801 | - $this->_trash_or_restore_event( 'trash', false ); |
|
1801 | + $this->_trash_or_restore_event('trash', false); |
|
1802 | 1802 | } |
1803 | 1803 | |
1804 | 1804 | |
@@ -1806,9 +1806,9 @@ discard block |
||
1806 | 1806 | /** |
1807 | 1807 | * @param string $post_id |
1808 | 1808 | */ |
1809 | - public function restore_cpt_item( $post_id ) { |
|
1809 | + public function restore_cpt_item($post_id) { |
|
1810 | 1810 | $this->_req_data['EVT_ID'] = $post_id; |
1811 | - $this->_trash_or_restore_event( 'draft', false ); |
|
1811 | + $this->_trash_or_restore_event('draft', false); |
|
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | |
@@ -1816,9 +1816,9 @@ discard block |
||
1816 | 1816 | /** |
1817 | 1817 | * @param string $post_id |
1818 | 1818 | */ |
1819 | - public function delete_cpt_item( $post_id ) { |
|
1819 | + public function delete_cpt_item($post_id) { |
|
1820 | 1820 | $this->_req_data['EVT_ID'] = $post_id; |
1821 | - $this->_delete_event( false ); |
|
1821 | + $this->_delete_event(false); |
|
1822 | 1822 | } |
1823 | 1823 | |
1824 | 1824 | |
@@ -1830,23 +1830,23 @@ discard block |
||
1830 | 1830 | * @param string $event_status |
1831 | 1831 | * @param bool $redirect_after |
1832 | 1832 | */ |
1833 | - protected function _trash_or_restore_event( $event_status = 'trash', $redirect_after = true ) { |
|
1833 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) { |
|
1834 | 1834 | //determine the event id and set to array. |
1835 | - $EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : false; |
|
1835 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1836 | 1836 | // loop thru events |
1837 | - if ( $EVT_ID ) { |
|
1837 | + if ($EVT_ID) { |
|
1838 | 1838 | // clean status |
1839 | - $event_status = sanitize_key( $event_status ); |
|
1839 | + $event_status = sanitize_key($event_status); |
|
1840 | 1840 | // grab status |
1841 | - if ( ! empty( $event_status ) ) { |
|
1842 | - $success = $this->_change_event_status( $EVT_ID, $event_status ); |
|
1841 | + if ( ! empty($event_status)) { |
|
1842 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1843 | 1843 | } else { |
1844 | 1844 | $success = false; |
1845 | 1845 | $msg = esc_html__( |
1846 | 1846 | 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
1847 | 1847 | 'event_espresso' |
1848 | 1848 | ); |
1849 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1849 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1850 | 1850 | } |
1851 | 1851 | } else { |
1852 | 1852 | $success = false; |
@@ -1854,11 +1854,11 @@ discard block |
||
1854 | 1854 | 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
1855 | 1855 | 'event_espresso' |
1856 | 1856 | ); |
1857 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1857 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1858 | 1858 | } |
1859 | 1859 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1860 | - if ( $redirect_after ) { |
|
1861 | - $this->_redirect_after_action( $success, 'Event', $action, array( 'action' => 'default' ) ); |
|
1860 | + if ($redirect_after) { |
|
1861 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1862 | 1862 | } |
1863 | 1863 | } |
1864 | 1864 | |
@@ -1871,18 +1871,18 @@ discard block |
||
1871 | 1871 | * @param string $event_status |
1872 | 1872 | * @return void |
1873 | 1873 | */ |
1874 | - protected function _trash_or_restore_events( $event_status = 'trash' ) { |
|
1874 | + protected function _trash_or_restore_events($event_status = 'trash') { |
|
1875 | 1875 | // clean status |
1876 | - $event_status = sanitize_key( $event_status ); |
|
1876 | + $event_status = sanitize_key($event_status); |
|
1877 | 1877 | // grab status |
1878 | - if ( ! empty( $event_status ) ) { |
|
1878 | + if ( ! empty($event_status)) { |
|
1879 | 1879 | $success = true; |
1880 | 1880 | //determine the event id and set to array. |
1881 | - $EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1881 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1882 | 1882 | // loop thru events |
1883 | - foreach ( $EVT_IDs as $EVT_ID ) { |
|
1884 | - if ( $EVT_ID = absint( $EVT_ID ) ) { |
|
1885 | - $results = $this->_change_event_status( $EVT_ID, $event_status ); |
|
1883 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1884 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1885 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1886 | 1886 | $success = $results !== false ? $success : false; |
1887 | 1887 | } else { |
1888 | 1888 | $msg = sprintf( |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | ), |
1893 | 1893 | $EVT_ID |
1894 | 1894 | ); |
1895 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1895 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1896 | 1896 | $success = false; |
1897 | 1897 | } |
1898 | 1898 | } |
@@ -1902,12 +1902,12 @@ discard block |
||
1902 | 1902 | 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
1903 | 1903 | 'event_espresso' |
1904 | 1904 | ); |
1905 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1905 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1906 | 1906 | } |
1907 | 1907 | // in order to force a pluralized result message we need to send back a success status greater than 1 |
1908 | 1908 | $success = $success ? 2 : false; |
1909 | 1909 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1910 | - $this->_redirect_after_action( $success, 'Events', $action, array( 'action' => 'default' ) ); |
|
1910 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1911 | 1911 | } |
1912 | 1912 | |
1913 | 1913 | |
@@ -1920,30 +1920,30 @@ discard block |
||
1920 | 1920 | * @param string $event_status |
1921 | 1921 | * @return bool |
1922 | 1922 | */ |
1923 | - private function _change_event_status( $EVT_ID = 0, $event_status = '' ) { |
|
1923 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1924 | 1924 | // grab event id |
1925 | - if ( ! $EVT_ID ) { |
|
1925 | + if ( ! $EVT_ID) { |
|
1926 | 1926 | $msg = esc_html__( |
1927 | 1927 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
1928 | 1928 | 'event_espresso' |
1929 | 1929 | ); |
1930 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1930 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1931 | 1931 | return false; |
1932 | 1932 | } |
1933 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1933 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1934 | 1934 | // clean status |
1935 | - $event_status = sanitize_key( $event_status ); |
|
1935 | + $event_status = sanitize_key($event_status); |
|
1936 | 1936 | // grab status |
1937 | - if ( empty( $event_status ) ) { |
|
1937 | + if (empty($event_status)) { |
|
1938 | 1938 | $msg = esc_html__( |
1939 | 1939 | 'An error occurred. No Event Status or an invalid Event Status was received.', |
1940 | 1940 | 'event_espresso' |
1941 | 1941 | ); |
1942 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1942 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1943 | 1943 | return false; |
1944 | 1944 | } |
1945 | 1945 | // was event trashed or restored ? |
1946 | - switch ( $event_status ) { |
|
1946 | + switch ($event_status) { |
|
1947 | 1947 | case 'draft' : |
1948 | 1948 | $action = 'restored from the trash'; |
1949 | 1949 | $hook = 'AHEE_event_restored_from_trash'; |
@@ -1957,15 +1957,15 @@ discard block |
||
1957 | 1957 | $hook = false; |
1958 | 1958 | } |
1959 | 1959 | //use class to change status |
1960 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1960 | + $this->_cpt_model_obj->set_status($event_status); |
|
1961 | 1961 | $success = $this->_cpt_model_obj->save(); |
1962 | - if ( $success === false ) { |
|
1963 | - $msg = sprintf( esc_html__( 'An error occurred. The event could not be %s.', 'event_espresso' ), $action ); |
|
1964 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1962 | + if ($success === false) { |
|
1963 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
1964 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1965 | 1965 | return false; |
1966 | 1966 | } |
1967 | - if ( $hook ) { |
|
1968 | - do_action( $hook ); |
|
1967 | + if ($hook) { |
|
1968 | + do_action($hook); |
|
1969 | 1969 | } |
1970 | 1970 | return true; |
1971 | 1971 | } |
@@ -1978,34 +1978,34 @@ discard block |
||
1978 | 1978 | * @access protected |
1979 | 1979 | * @param bool $redirect_after |
1980 | 1980 | */ |
1981 | - protected function _delete_event( $redirect_after = true ) { |
|
1981 | + protected function _delete_event($redirect_after = true) { |
|
1982 | 1982 | //determine the event id and set to array. |
1983 | - $EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : null; |
|
1984 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1983 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
1984 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1985 | 1985 | // loop thru events |
1986 | - if ( $EVT_ID ) { |
|
1987 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1986 | + if ($EVT_ID) { |
|
1987 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1988 | 1988 | // get list of events with no prices |
1989 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() ); |
|
1989 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
1990 | 1990 | // remove this event from the list of events with no prices |
1991 | - if ( isset( $espresso_no_ticket_prices[ $EVT_ID ] ) ) { |
|
1992 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1991 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
1992 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1993 | 1993 | } |
1994 | - update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices ); |
|
1994 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
1995 | 1995 | } else { |
1996 | 1996 | $success = false; |
1997 | 1997 | $msg = esc_html__( |
1998 | 1998 | 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
1999 | 1999 | 'event_espresso' |
2000 | 2000 | ); |
2001 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2001 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2002 | 2002 | } |
2003 | - if ( $redirect_after ) { |
|
2003 | + if ($redirect_after) { |
|
2004 | 2004 | $this->_redirect_after_action( |
2005 | 2005 | $success, |
2006 | 2006 | 'Event', |
2007 | 2007 | 'deleted', |
2008 | - array( 'action' => 'default', 'status' => 'trash' ) |
|
2008 | + array('action' => 'default', 'status' => 'trash') |
|
2009 | 2009 | ); |
2010 | 2010 | } |
2011 | 2011 | } |
@@ -2021,30 +2021,30 @@ discard block |
||
2021 | 2021 | protected function _delete_events() { |
2022 | 2022 | $success = true; |
2023 | 2023 | // get list of events with no prices |
2024 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() ); |
|
2024 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2025 | 2025 | //determine the event id and set to array. |
2026 | - $EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2026 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2027 | 2027 | // loop thru events |
2028 | - foreach ( $EVT_IDs as $EVT_ID ) { |
|
2029 | - $EVT_ID = absint( $EVT_ID ); |
|
2030 | - if ( $EVT_ID ) { |
|
2031 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
2028 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2029 | + $EVT_ID = absint($EVT_ID); |
|
2030 | + if ($EVT_ID) { |
|
2031 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2032 | 2032 | $success = $results !== false ? $success : false; |
2033 | 2033 | // remove this event from the list of events with no prices |
2034 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
2034 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2035 | 2035 | } else { |
2036 | 2036 | $success = false; |
2037 | 2037 | $msg = esc_html__( |
2038 | 2038 | 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
2039 | 2039 | 'event_espresso' |
2040 | 2040 | ); |
2041 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2041 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2042 | 2042 | } |
2043 | 2043 | } |
2044 | - update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices ); |
|
2044 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2045 | 2045 | // in order to force a pluralized result message we need to send back a success status greater than 1 |
2046 | 2046 | $success = $success ? 2 : false; |
2047 | - $this->_redirect_after_action( $success, 'Events', 'deleted', array( 'action' => 'default' ) ); |
|
2047 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | |
@@ -2056,70 +2056,70 @@ discard block |
||
2056 | 2056 | * @param int $EVT_ID |
2057 | 2057 | * @return bool |
2058 | 2058 | */ |
2059 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
2059 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
2060 | 2060 | // grab event id |
2061 | - if ( ! $EVT_ID ) { |
|
2061 | + if ( ! $EVT_ID) { |
|
2062 | 2062 | $msg = esc_html__( |
2063 | 2063 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
2064 | 2064 | 'event_espresso' |
2065 | 2065 | ); |
2066 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2066 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2067 | 2067 | return false; |
2068 | 2068 | } |
2069 | 2069 | if ( |
2070 | 2070 | ! $this->_cpt_model_obj instanceof EE_Event |
2071 | 2071 | || $this->_cpt_model_obj->ID() !== $EVT_ID |
2072 | 2072 | ) { |
2073 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
2073 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2074 | 2074 | } |
2075 | - if ( ! $this->_cpt_model_obj instanceof EE_Event ) { |
|
2075 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2076 | 2076 | return false; |
2077 | 2077 | } |
2078 | 2078 | //need to delete related tickets and prices first. |
2079 | - $datetimes = $this->_cpt_model_obj->get_many_related( 'Datetime' ); |
|
2080 | - foreach ( $datetimes as $datetime ) { |
|
2081 | - $this->_cpt_model_obj->_remove_relation_to( $datetime, 'Datetime' ); |
|
2082 | - $tickets = $datetime->get_many_related( 'Ticket' ); |
|
2083 | - foreach ( $tickets as $ticket ) { |
|
2084 | - $ticket->_remove_relation_to( $datetime, 'Datetime' ); |
|
2085 | - $ticket->delete_related_permanently( 'Price' ); |
|
2079 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2080 | + foreach ($datetimes as $datetime) { |
|
2081 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2082 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2083 | + foreach ($tickets as $ticket) { |
|
2084 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2085 | + $ticket->delete_related_permanently('Price'); |
|
2086 | 2086 | $ticket->delete_permanently(); |
2087 | 2087 | } |
2088 | 2088 | $datetime->delete(); |
2089 | 2089 | } |
2090 | 2090 | //what about related venues or terms? |
2091 | - $venues = $this->_cpt_model_obj->get_many_related( 'Venue' ); |
|
2092 | - foreach ( $venues as $venue ) { |
|
2093 | - $this->_cpt_model_obj->_remove_relation_to( $venue, 'Venue' ); |
|
2091 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2092 | + foreach ($venues as $venue) { |
|
2093 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2094 | 2094 | } |
2095 | 2095 | //any attached question groups? |
2096 | - $question_groups = $this->_cpt_model_obj->get_many_related( 'Question_Group' ); |
|
2097 | - if ( ! empty( $question_groups ) ) { |
|
2098 | - foreach ( $question_groups as $question_group ) { |
|
2099 | - $this->_cpt_model_obj->_remove_relation_to( $question_group, 'Question_Group' ); |
|
2096 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2097 | + if ( ! empty($question_groups)) { |
|
2098 | + foreach ($question_groups as $question_group) { |
|
2099 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2100 | 2100 | } |
2101 | 2101 | } |
2102 | 2102 | //Message Template Groups |
2103 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
2103 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2104 | 2104 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
2105 | 2105 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
2106 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
2107 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy( $term_taxonomy ); |
|
2106 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2107 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2108 | 2108 | } |
2109 | 2109 | $success = $this->_cpt_model_obj->delete_permanently(); |
2110 | 2110 | // did it all go as planned ? |
2111 | - if ( $success ) { |
|
2112 | - $msg = sprintf( esc_html__( 'Event ID # %d has been deleted.', 'event_espresso' ), $EVT_ID ); |
|
2113 | - EE_Error::add_success( $msg ); |
|
2111 | + if ($success) { |
|
2112 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2113 | + EE_Error::add_success($msg); |
|
2114 | 2114 | } else { |
2115 | 2115 | $msg = sprintf( |
2116 | - esc_html__( 'An error occurred. Event ID # %d could not be deleted.', 'event_espresso' ), |
|
2116 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2117 | 2117 | $EVT_ID |
2118 | 2118 | ); |
2119 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2119 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2120 | 2120 | return false; |
2121 | 2121 | } |
2122 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
2122 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2123 | 2123 | return true; |
2124 | 2124 | } |
2125 | 2125 | |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | * @return int |
2133 | 2133 | */ |
2134 | 2134 | public function total_events() { |
2135 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2135 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2136 | 2136 | return $count; |
2137 | 2137 | } |
2138 | 2138 | |
@@ -2146,9 +2146,9 @@ discard block |
||
2146 | 2146 | */ |
2147 | 2147 | public function total_events_draft() { |
2148 | 2148 | $where = array( |
2149 | - 'status' => array( 'IN', array( 'draft', 'auto-draft' ) ), |
|
2149 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2150 | 2150 | ); |
2151 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2151 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2152 | 2152 | return $count; |
2153 | 2153 | } |
2154 | 2154 | |
@@ -2164,7 +2164,7 @@ discard block |
||
2164 | 2164 | $where = array( |
2165 | 2165 | 'status' => 'trash', |
2166 | 2166 | ); |
2167 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2167 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2168 | 2168 | return $count; |
2169 | 2169 | } |
2170 | 2170 | |
@@ -2195,12 +2195,12 @@ discard block |
||
2195 | 2195 | EE_Registry::instance()->CFG->registration->default_STS_ID, |
2196 | 2196 | $this->_template_args['reg_status_array'] |
2197 | 2197 | ) |
2198 | - ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) |
|
2198 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2199 | 2199 | : EEM_Registration::status_id_pending_payment; |
2200 | - $this->_set_add_edit_form_tags( 'update_default_event_settings' ); |
|
2201 | - $this->_set_publish_post_box_vars( null, false, false, null, false ); |
|
2200 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2201 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2202 | 2202 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2203 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2203 | + EVENTS_TEMPLATE_PATH.'event_settings.template.php', |
|
2204 | 2204 | $this->_template_args, |
2205 | 2205 | true |
2206 | 2206 | ); |
@@ -2216,8 +2216,8 @@ discard block |
||
2216 | 2216 | * @return void |
2217 | 2217 | */ |
2218 | 2218 | protected function _update_default_event_settings() { |
2219 | - EE_Config::instance()->registration->default_STS_ID = isset( $this->_req_data['default_reg_status'] ) |
|
2220 | - ? sanitize_text_field( $this->_req_data['default_reg_status'] ) |
|
2219 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2220 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2221 | 2221 | : EEM_Registration::status_id_pending_payment; |
2222 | 2222 | $what = 'Default Event Settings'; |
2223 | 2223 | $success = $this->_update_espresso_configuration( |
@@ -2227,7 +2227,7 @@ discard block |
||
2227 | 2227 | __FUNCTION__, |
2228 | 2228 | __LINE__ |
2229 | 2229 | ); |
2230 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default_event_settings' ) ); |
|
2230 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | |
@@ -2237,20 +2237,20 @@ discard block |
||
2237 | 2237 | |
2238 | 2238 | |
2239 | 2239 | protected function _template_settings() { |
2240 | - $this->_admin_page_title = esc_html__( 'Template Settings (Preview)', 'event_espresso' ); |
|
2240 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2241 | 2241 | $this->_template_args['preview_img'] = '<img src="' |
2242 | 2242 | . EVENTS_ASSETS_URL |
2243 | 2243 | . DS |
2244 | 2244 | . 'images' |
2245 | 2245 | . DS |
2246 | 2246 | . 'caffeinated_template_features.jpg" alt="' |
2247 | - . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) |
|
2247 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2248 | 2248 | . '" />'; |
2249 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2249 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
2250 | 2250 | 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
2251 | 2251 | 'event_espresso' |
2252 | - ) . '</strong>'; |
|
2253 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2252 | + ).'</strong>'; |
|
2253 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | 2256 | |
@@ -2262,18 +2262,18 @@ discard block |
||
2262 | 2262 | * @return void |
2263 | 2263 | */ |
2264 | 2264 | private function _set_category_object() { |
2265 | - if ( isset( $this->_category->id ) && ! empty( $this->_category->id ) ) { |
|
2265 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2266 | 2266 | return; |
2267 | 2267 | } //already have the category object so get out. |
2268 | 2268 | //set default category object |
2269 | 2269 | $this->_set_empty_category_object(); |
2270 | 2270 | //only set if we've got an id |
2271 | - if ( ! isset( $this->_req_data['EVT_CAT_ID'] ) ) { |
|
2271 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2272 | 2272 | return; |
2273 | 2273 | } |
2274 | - $category_id = absint( $this->_req_data['EVT_CAT_ID'] ); |
|
2275 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2276 | - if ( ! empty( $term ) ) { |
|
2274 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2275 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2276 | + if ( ! empty($term)) { |
|
2277 | 2277 | $this->_category->category_name = $term->name; |
2278 | 2278 | $this->_category->category_identifier = $term->slug; |
2279 | 2279 | $this->_category->category_desc = $term->description; |
@@ -2293,9 +2293,9 @@ discard block |
||
2293 | 2293 | |
2294 | 2294 | |
2295 | 2295 | protected function _category_list_table() { |
2296 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2297 | - $this->_search_btn_label = esc_html__( 'Categories', 'event_espresso' ); |
|
2298 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2296 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2297 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2298 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
2299 | 2299 | 'add_category', |
2300 | 2300 | 'add_category', |
2301 | 2301 | array(), |
@@ -2309,20 +2309,20 @@ discard block |
||
2309 | 2309 | /** |
2310 | 2310 | * @param $view |
2311 | 2311 | */ |
2312 | - protected function _category_details( $view ) { |
|
2312 | + protected function _category_details($view) { |
|
2313 | 2313 | //load formatter helper |
2314 | 2314 | //load field generator helper |
2315 | 2315 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2316 | - $this->_set_add_edit_form_tags( $route ); |
|
2316 | + $this->_set_add_edit_form_tags($route); |
|
2317 | 2317 | $this->_set_category_object(); |
2318 | - $id = ! empty( $this->_category->id ) ? $this->_category->id : ''; |
|
2318 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2319 | 2319 | $delete_action = 'delete_category'; |
2320 | 2320 | //custom redirect |
2321 | 2321 | $redirect = EE_Admin_Page::add_query_args_and_nonce( |
2322 | - array( 'action' => 'category_list' ), |
|
2322 | + array('action' => 'category_list'), |
|
2323 | 2323 | $this->_admin_base_url |
2324 | 2324 | ); |
2325 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2325 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2326 | 2326 | //take care of contents |
2327 | 2327 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
2328 | 2328 | $this->display_admin_page_with_sidebar(); |
@@ -2336,21 +2336,21 @@ discard block |
||
2336 | 2336 | protected function _category_details_content() { |
2337 | 2337 | $editor_args['category_desc'] = array( |
2338 | 2338 | 'type' => 'wp_editor', |
2339 | - 'value' => EEH_Formatter::admin_format_content( $this->_category->category_desc ), |
|
2339 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2340 | 2340 | 'class' => 'my_editor_custom', |
2341 | - 'wpeditor_args' => array( 'media_buttons' => false ), |
|
2341 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2342 | 2342 | ); |
2343 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2343 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2344 | 2344 | $all_terms = get_terms( |
2345 | - array( 'espresso_event_categories' ), |
|
2346 | - array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) |
|
2345 | + array('espresso_event_categories'), |
|
2346 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2347 | 2347 | ); |
2348 | 2348 | //setup category select for term parents. |
2349 | 2349 | $category_select_values[] = array( |
2350 | - 'text' => esc_html__( 'No Parent', 'event_espresso' ), |
|
2350 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2351 | 2351 | 'id' => 0, |
2352 | 2352 | ); |
2353 | - foreach ( $all_terms as $term ) { |
|
2353 | + foreach ($all_terms as $term) { |
|
2354 | 2354 | $category_select_values[] = array( |
2355 | 2355 | 'text' => $term->name, |
2356 | 2356 | 'id' => $term->term_id, |
@@ -2364,28 +2364,28 @@ discard block |
||
2364 | 2364 | $template_args = array( |
2365 | 2365 | 'category' => $this->_category, |
2366 | 2366 | 'category_select' => $category_select, |
2367 | - 'unique_id_info_help_link' => $this->_get_help_tab_link( 'unique_id_info' ), |
|
2367 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2368 | 2368 | 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
2369 | 2369 | 'disable' => '', |
2370 | 2370 | 'disabled_message' => false, |
2371 | 2371 | ); |
2372 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2373 | - return EEH_Template::display_template( $template, $template_args, true ); |
|
2372 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2373 | + return EEH_Template::display_template($template, $template_args, true); |
|
2374 | 2374 | } |
2375 | 2375 | |
2376 | 2376 | |
2377 | 2377 | |
2378 | 2378 | protected function _delete_categories() { |
2379 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2379 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2380 | 2380 | : (array) $this->_req_data['category_id']; |
2381 | - foreach ( $cat_ids as $cat_id ) { |
|
2382 | - $this->_delete_category( $cat_id ); |
|
2381 | + foreach ($cat_ids as $cat_id) { |
|
2382 | + $this->_delete_category($cat_id); |
|
2383 | 2383 | } |
2384 | 2384 | //doesn't matter what page we're coming from... we're going to the same place after delete. |
2385 | 2385 | $query_args = array( |
2386 | 2386 | 'action' => 'category_list', |
2387 | 2387 | ); |
2388 | - $this->_redirect_after_action( 0, '', '', $query_args ); |
|
2388 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2389 | 2389 | } |
2390 | 2390 | |
2391 | 2391 | |
@@ -2393,9 +2393,9 @@ discard block |
||
2393 | 2393 | /** |
2394 | 2394 | * @param $cat_id |
2395 | 2395 | */ |
2396 | - protected function _delete_category( $cat_id ) { |
|
2397 | - $cat_id = absint( $cat_id ); |
|
2398 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2396 | + protected function _delete_category($cat_id) { |
|
2397 | + $cat_id = absint($cat_id); |
|
2398 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2399 | 2399 | } |
2400 | 2400 | |
2401 | 2401 | |
@@ -2403,18 +2403,18 @@ discard block |
||
2403 | 2403 | /** |
2404 | 2404 | * @param $new_category |
2405 | 2405 | */ |
2406 | - protected function _insert_or_update_category( $new_category ) { |
|
2407 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( true ); |
|
2406 | + protected function _insert_or_update_category($new_category) { |
|
2407 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2408 | 2408 | $success = 0; //we already have a success message so lets not send another. |
2409 | - if ( $cat_id ) { |
|
2409 | + if ($cat_id) { |
|
2410 | 2410 | $query_args = array( |
2411 | 2411 | 'action' => 'edit_category', |
2412 | 2412 | 'EVT_CAT_ID' => $cat_id, |
2413 | 2413 | ); |
2414 | 2414 | } else { |
2415 | - $query_args = array( 'action' => 'add_category' ); |
|
2415 | + $query_args = array('action' => 'add_category'); |
|
2416 | 2416 | } |
2417 | - $this->_redirect_after_action( $success, '', '', $query_args, true ); |
|
2417 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2418 | 2418 | } |
2419 | 2419 | |
2420 | 2420 | |
@@ -2423,14 +2423,14 @@ discard block |
||
2423 | 2423 | * @param bool $update |
2424 | 2424 | * @return bool|mixed|string |
2425 | 2425 | */ |
2426 | - private function _insert_category( $update = false ) { |
|
2426 | + private function _insert_category($update = false) { |
|
2427 | 2427 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2428 | - $category_name = isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2429 | - $category_desc = isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2430 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2431 | - if ( empty( $category_name ) ) { |
|
2432 | - $msg = esc_html__( 'You must add a name for the category.', 'event_espresso' ); |
|
2433 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2428 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2429 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2430 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2431 | + if (empty($category_name)) { |
|
2432 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2433 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2434 | 2434 | return false; |
2435 | 2435 | } |
2436 | 2436 | $term_args = array( |
@@ -2439,22 +2439,22 @@ discard block |
||
2439 | 2439 | 'parent' => $category_parent, |
2440 | 2440 | ); |
2441 | 2441 | //was the category_identifier input disabled? |
2442 | - if ( isset( $this->_req_data['category_identifier'] ) ) { |
|
2442 | + if (isset($this->_req_data['category_identifier'])) { |
|
2443 | 2443 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2444 | 2444 | } |
2445 | 2445 | $insert_ids = $update |
2446 | - ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) |
|
2447 | - : wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2448 | - if ( ! is_array( $insert_ids ) ) { |
|
2446 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2447 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2448 | + if ( ! is_array($insert_ids)) { |
|
2449 | 2449 | $msg = esc_html__( |
2450 | 2450 | 'An error occurred and the category has not been saved to the database.', |
2451 | 2451 | 'event_espresso' |
2452 | 2452 | ); |
2453 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2453 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2454 | 2454 | } else { |
2455 | 2455 | $cat_id = $insert_ids['term_id']; |
2456 | - $msg = sprintf( esc_html__( 'The category %s was successfully saved', 'event_espresso' ), $category_name ); |
|
2457 | - EE_Error::add_success( $msg ); |
|
2456 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2457 | + EE_Error::add_success($msg); |
|
2458 | 2458 | } |
2459 | 2459 | return $cat_id; |
2460 | 2460 | } |
@@ -2467,28 +2467,28 @@ discard block |
||
2467 | 2467 | * @param bool $count |
2468 | 2468 | * @return \EE_Base_Class[]|int |
2469 | 2469 | */ |
2470 | - public function get_categories( $per_page = 10, $current_page = 1, $count = false ) { |
|
2470 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) { |
|
2471 | 2471 | //testing term stuff |
2472 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2473 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2474 | - $limit = ( $current_page - 1 ) * $per_page; |
|
2475 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2476 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2477 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2472 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2473 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2474 | + $limit = ($current_page - 1) * $per_page; |
|
2475 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2476 | + if (isset($this->_req_data['s'])) { |
|
2477 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2478 | 2478 | $where['OR'] = array( |
2479 | - 'Term.name' => array( 'LIKE', $sstr ), |
|
2480 | - 'description' => array( 'LIKE', $sstr ), |
|
2479 | + 'Term.name' => array('LIKE', $sstr), |
|
2480 | + 'description' => array('LIKE', $sstr), |
|
2481 | 2481 | ); |
2482 | 2482 | } |
2483 | 2483 | $query_params = array( |
2484 | 2484 | $where, |
2485 | - 'order_by' => array( $orderby => $order ), |
|
2486 | - 'limit' => $limit . ',' . $per_page, |
|
2487 | - 'force_join' => array( 'Term' ), |
|
2485 | + 'order_by' => array($orderby => $order), |
|
2486 | + 'limit' => $limit.','.$per_page, |
|
2487 | + 'force_join' => array('Term'), |
|
2488 | 2488 | ); |
2489 | 2489 | $categories = $count |
2490 | - ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) |
|
2491 | - : EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2490 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2491 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2492 | 2492 | return $categories; |
2493 | 2493 | } |
2494 | 2494 |